diff --git a/.gitignore b/.gitignore index 38d1147830..1f241f7eb9 100644 --- a/.gitignore +++ b/.gitignore @@ -123,9 +123,10 @@ project.properties /templates/lua-template-runtime/runtime /v*-deps-*.zip /v*-lua-runtime-*.zip +/v*-console-*.zip /tools/fbx-conv/ tests/cpp-tests/Resources/audio -/tests/js-tests/ /tests/lua-empty-test/src/cocos/ /tests/lua-game-controller-test/src/cocos/ /tests/lua-tests/src/cocos/ +/tests/js-tests/res/ diff --git a/.gitmodules b/.gitmodules index 0a247d2967..1046d0a4f6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "tests/cpp-tests/Resources/ccs-res"] path = tests/cpp-tests/Resources/ccs-res url = git://github.com/dumganhar/ccs-res.git +[submodule "web"] + path = web + url = git://github.com/cocos2d/cocos2d-html5.git diff --git a/.travis.yml b/.travis.yml index f0ecc43545..1bccfbf9d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,4 +37,4 @@ before_install: # whitelist branches: only: - - v3.6 + - v3 diff --git a/AUTHORS b/AUTHORS index 9575823d31..efe4f7c8b1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1091,6 +1091,7 @@ Developers: loadrunner Added romanian languange support + Added sensor property for PhysicsShape Almax27 RenderQueue command buffer optimize. @@ -1106,13 +1107,20 @@ Developers: milos1290 Added Lerp for Vec3 + Added ActionFloat perminovVS Optimize Vec3 and Vec2 Added `UserDefault::setDelegate()` + qiutaoleo + Added a feature to check case characters for filename on windows + HueyPark Fixed memory leak in HttpClient on iOS + + Dimon4eg + Fixed crash on AssetsManager Retired Core Developers: WenSheng Yang diff --git a/CHANGELOG b/CHANGELOG index 6ef17bb623..9aff56b1e8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,19 @@ -cocos2d-x-3.6 ?? +cocos2d-x-3.7 ?? + [NEW] 3d: added physics3d support + [NEW] C++: added ActionFloat + [NEW] FileUtils: checked filename case characters on windows + [NEW] FileUitls: added supporting loading files that which file path include utf-8 characters + [NEW] PhysicsShape: added sensor property + + [FIX] 3rd: fix PIE link error on iOS caused by libpng and libtiff + [FIX] AssetsManager: crashed issue + [FIX] EaseRateAction: no way to create an `EaseRateAction` instance + [FIX] Label: crashed if invoking `setString(text` after `getLetter(letterIndex)` and `letterIndex` is greater than the length of text + [FIX] Label: position is wrong if label content is changed after invoking `getLetter(letterIndex)` + [FIX] Label: shadow effect cause OpenGL error on iOS + [FIX] Label: outline effect doesn't match characters well + +cocos2d-x-3.6 Apr.30 2015 [NEW] 3rd: update chipmunk to v 6.2.2 on Windows 8.1 Universal App [NEW] 3rd: update freetype to v 2.5.5 on Windows 8.1 Universal App [NEW] C++: Added SpritePolygon diff --git a/CMakeLists.txt b/CMakeLists.txt index 644ac28cd6..d1c40c3b19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,15 +58,20 @@ endif() set(BUILD_CPP_TESTS_DEFAULT ON) set(BUILD_LUA_LIBS_DEFAULT ON) set(BUILD_LUA_TESTS_DEFAULT ON) +set(BUILD_JS_LIBS_DEFAULT OFF) +set(BUILD_JS_TESTS_DEFAULT OFF) # TODO: fix test samples for MSVC if(MSVC) set(BUILD_CPP_TESTS_DEFAULT OFF) set(BUILD_LUA_LIBS_DEFAULT OFF) set(BUILD_LUA_TESTS_DEFAULT OFF) + set(BUILD_JS_LIBS_DEFAULT OFF) + set(BUILD_JS_TESTS_DEFAULT OFF) endif() option(USE_CHIPMUNK "Use chipmunk for physics library" ON) option(USE_BOX2D "Use box2d for physics library" OFF) +option(USE_BULLET "Use bullet for physics3d library" ON) option(USE_WEBP "Use WebP codec" ${USE_WEBP_DEFAULT}) option(BUILD_SHARED_LIBS "Build shared libraries" OFF) option(DEBUG_MODE "Debug or release?" ON) @@ -77,6 +82,8 @@ option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON) option(BUILD_CPP_TESTS "Build TestCpp samples" ${BUILD_CPP_TESTS_DEFAULT}) option(BUILD_LUA_LIBS "Build lua libraries" ${BUILD_LUA_LIBS_DEFAULT}) option(BUILD_LUA_TESTS "Build TestLua samples" ${BUILD_LUA_TESTS_DEFAULT}) +option(BUILD_JS_LIBS "Build js libraries" ${BUILD_JS_LIBS_DEFAULT}) +option(BUILD_JS_TESTS "Build TestJS samples" ${BUILD_JS_TESTS_DEFAULT}) option(USE_PREBUILT_LIBS "Use prebuilt libraries in external directory" ${USE_PREBUILT_LIBS_DEFAULT}) if(USE_PREBUILT_LIBS AND MINGW) @@ -242,6 +249,24 @@ else() add_definitions(-DCC_ENABLE_BOX2D_INTEGRATION=0) endif(USE_BOX2D) +# Bullet (not prebuilded, exists as source) +if(USE_BULLET) + if(USE_PREBUILT_LIBS) + add_subdirectory(external/bullet) + set(BULLET_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/bullet) + set(BULLET_LIBRARIES bullet) + else() + cocos_find_package(bullet BULLET REQUIRED) + set(BULLET_LIBRARIES bullet) + endif() + message(STATUS "Bullet include dirs: ${BULLET_INCLUDE_DIRS}") + add_definitions(-DCC_ENABLE_BULLET_INTEGRATION=1) + add_definitions(-DCC_USE_PHYSICS=1) +else() + add_definitions(-DCC_ENABLE_BULLET_INTEGRATION=0) + add_definitions(-DCC_USE_3D_PHYSICS=0) +endif(USE_BULLET) + # Tinyxml2 (not prebuilded, exists as source) if(USE_PREBUILT_LIBS) add_subdirectory(external/tinyxml2) @@ -314,3 +339,18 @@ if(BUILD_LUA_LIBS) endif(BUILD_LUA_TESTS) endif(BUILD_LUA_LIBS) + +## JS +if(BUILD_JS_LIBS) + link_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/external/spidermonkey/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} + ) + + add_subdirectory(cocos/scripting/js-bindings) + + # build js tests + if(BUILD_JS_TESTS) + add_subdirectory(tests/js-tests/project) + endif(BUILD_JS_TESTS) + +endif(BUILD_JS_LIBS) diff --git a/README.md b/README.md index 672ca3f4af..de6121afb0 100644 --- a/README.md +++ b/README.md @@ -135,10 +135,10 @@ Build Requirements * Mac OS X 10.7+, Xcode 5.1+ * or Ubuntu 12.10+, CMake 2.6+ -* or Windows 7+, VS 2012+ +* or Windows 7+, VS 2013+ * Python 2.7.5 * NDK r10c+ is required to build Android games -* Windows Phone/Store 8.0 VS 2012+ +* Windows Phone/Store 8.0 VS 2013+ * Windows Phone/Store 8.1 VS 2013 Update 3+ @@ -186,7 +186,7 @@ $ bin/lua-empty-test/lua-empty-test * For Windows -Open the `cocos2d-x/build/cocos2d-win32.vc2012.sln` +Open the `cocos2d-x/build/cocos2d-win32.vc2013.sln` * For Windows 8.1 Universal Apps (Phone and Store) diff --git a/build/cocos2d-js-win32.vc2013.sln b/build/cocos2d-js-win32.vc2013.sln new file mode 100644 index 0000000000..4d7b7c6ec8 --- /dev/null +++ b/build/cocos2d-js-win32.vc2013.sln @@ -0,0 +1,69 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 12.0.21005.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\cocos\2d\libcocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "External", "External", "{92D54E36-7916-48EF-A951-224DD3B25442}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine", "..\cocos\editor-support\spine\proj.win32\libSpine.vcxproj", "{B7C2A162-DEC9-4418-972E-240AB3CBFCAE}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbox2d", "..\external\Box2D\proj.win32\libbox2d.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjscocos2d", "..\cocos\scripting\js-bindings\proj.win32\libjscocos2d.vcxproj", "{39379840-825A-45A0-B363-C09FFEF864BD}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "js-tests", "..\tests\js-tests\project\proj.win32\js-tests.vcxproj", "{D0F06A44-A245-4D13-A498-0120C203B539}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|Win32 = Debug|Win32 + Release|ARM = Release|ARM + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|ARM.ActiveCfg = Debug|Win32 + {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.ActiveCfg = Debug|Win32 + {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.Build.0 = Debug|Win32 + {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|ARM.ActiveCfg = Release|Win32 + {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.ActiveCfg = Release|Win32 + {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.Build.0 = Release|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Debug|ARM.ActiveCfg = Debug|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Debug|Win32.ActiveCfg = Debug|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Debug|Win32.Build.0 = Debug|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Release|ARM.ActiveCfg = Release|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Release|Win32.ActiveCfg = Release|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Release|Win32.Build.0 = Release|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Debug|ARM.ActiveCfg = Debug|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.ActiveCfg = Debug|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.Build.0 = Debug|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Release|ARM.ActiveCfg = Release|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.ActiveCfg = Release|Win32 + {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.Build.0 = Release|Win32 + {39379840-825A-45A0-B363-C09FFEF864BD}.Debug|ARM.ActiveCfg = Debug|Win32 + {39379840-825A-45A0-B363-C09FFEF864BD}.Debug|Win32.ActiveCfg = Debug|Win32 + {39379840-825A-45A0-B363-C09FFEF864BD}.Debug|Win32.Build.0 = Debug|Win32 + {39379840-825A-45A0-B363-C09FFEF864BD}.Release|ARM.ActiveCfg = Release|Win32 + {39379840-825A-45A0-B363-C09FFEF864BD}.Release|Win32.ActiveCfg = Release|Win32 + {39379840-825A-45A0-B363-C09FFEF864BD}.Release|Win32.Build.0 = Release|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Debug|ARM.ActiveCfg = Debug|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Debug|Win32.ActiveCfg = Debug|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Debug|Win32.Build.0 = Debug|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Release|ARM.ActiveCfg = Release|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Release|Win32.ActiveCfg = Release|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE} = {92D54E36-7916-48EF-A951-224DD3B25442} + {929480E7-23C0-4DF6-8456-096D71547116} = {92D54E36-7916-48EF-A951-224DD3B25442} + EndGlobalSection + GlobalSection(DPCodeReviewSolutionGUID) = preSolution + DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} + EndGlobalSection + GlobalSection(DPCodeReviewSolutionGUID) = preSolution + DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} + EndGlobalSection +EndGlobal diff --git a/build/cocos2d-js-win8.1-universal.sln b/build/cocos2d-js-win8.1-universal.sln new file mode 100644 index 0000000000..c7e811fd33 --- /dev/null +++ b/build/cocos2d-js-win8.1-universal.sln @@ -0,0 +1,218 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30723.0 +MinimumVisualStudioVersion = 12.0.21005.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libcocos2d", "libcocos2d", "{B3F299D4-B4CA-4F0B-8BE2-FB328483BC13}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d_8_1.Shared", "..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.Shared\libcocos2d_8_1.Shared.vcxitems", "{5D6F020F-7E72-4494-90A0-2DF11D235DF9}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d_8_1.Windows", "..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.Windows\libcocos2d_8_1.Windows.vcxproj", "{9335005F-678E-4E8E-9B84-50037216AEC8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d_8_1.WindowsPhone", "..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.WindowsPhone\libcocos2d_8_1.WindowsPhone.vcxproj", "{22F3B9DF-1209-4574-8331-003966F562BF}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "External", "External", "{85630454-74EA-4B5B-9B62-0E459B4476CB}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libbox2d", "libbox2d", "{B3D1A3D5-9F54-43AF-9322-230B53242B78}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbox2d.Shared", "..\external\Box2D\proj.win8.1-universal\libbox2d.Shared\libbox2d.Shared.vcxitems", "{4A3C6BA8-C227-498B-AA21-40BDA27B461F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbox2d.Windows", "..\external\Box2D\proj.win8.1-universal\libbox2d.Windows\libbox2d.Windows.vcxproj", "{3B26A12D-3A44-47EA-82D2-282660FC844D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbox2d.WindowsPhone", "..\external\Box2D\proj.win8.1-universal\libbox2d.WindowsPhone\libbox2d.WindowsPhone.vcxproj", "{22F798D8-BFFF-4754-996F-A5395343D5EC}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libSpine", "libSpine", "{6FEB795C-C98C-4C8C-A88B-A35DEE205348}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine.Shared", "..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.Shared\libSpine.Shared.vcxitems", "{ADAFD00D-A0D6-46EF-9F0B-EA2880BFE1DE}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine.Windows", "..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.Windows\libSpine.Windows.vcxproj", "{F3550FE0-C795-44F6-8FEB-093EB68143AE}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine.WindowsPhone", "..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.WindowsPhone\libSpine.WindowsPhone.vcxproj", "{CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "js-tests", "js-tests", "{8E24A044-D83D-476D-886D-F40E3CC621DF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "js-tests.Shared", "..\tests\js-tests\project\proj.win8.1-universal\App.Shared\js-tests.Shared.vcxitems", "{AE6763F6-1549-441E-AFB5-377BE1C776DC}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "js-tests.Windows", "..\tests\js-tests\project\proj.win8.1-universal\App.Windows\js-tests.Windows.vcxproj", "{70914FC8-7709-4CD6-B86B-C63FDE5478DB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "js-tests.WindowsPhone", "..\tests\js-tests\project\proj.win8.1-universal\App.WindowsPhone\js-tests.WindowsPhone.vcxproj", "{94874B5B-398F-448A-A366-35A35DC1DB9C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libcocos2d-jsb", "libcocos2d-jsb", "{60DCAEA9-E344-40C0-B90C-82FB8E671BD5}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjscocos2d.Shared", "..\cocos\scripting\js-bindings\proj.win8.1-universal\libjscocos2d\libjscocos2d.Shared\libjscocos2d.Shared.vcxitems", "{BEA66276-51DD-4C53-92A8-F3D1FEA50892}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjscocos2d.Windows", "..\cocos\scripting\js-bindings\proj.win8.1-universal\libjscocos2d\libjscocos2d.Windows\libjscocos2d.Windows.vcxproj", "{BCF5546D-66A0-4998-AFD6-C5514F618930}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjscocos2d.WindowsPhone", "..\cocos\scripting\js-bindings\proj.win8.1-universal\libjscocos2d\libjscocos2d.WindowsPhone\libjscocos2d.WindowsPhone.vcxproj", "{CA082EC4-17CE-430B-8207-D1E947A5D1E9}" +EndProject +Global + GlobalSection(SharedMSBuildProjectFiles) = preSolution + ..\tests\js-tests\project\proj.win8.1-universal\App.Shared\js-tests.Shared.vcxitems*{ae6763f6-1549-441e-afb5-377be1c776dc}*SharedItemsImports = 9 + ..\tests\js-tests\project\proj.win8.1-universal\App.Shared\js-tests.Shared.vcxitems*{94874b5b-398f-448a-a366-35a35dc1db9c}*SharedItemsImports = 4 + ..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.Shared\libcocos2d_8_1.Shared.vcxitems*{9335005f-678e-4e8e-9b84-50037216aec8}*SharedItemsImports = 4 + ..\tests\js-tests\project\proj.win8.1-universal\App.Shared\js-tests.Shared.vcxitems*{70914fc8-7709-4cd6-b86b-c63fde5478db}*SharedItemsImports = 4 + ..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.Shared\libSpine.Shared.vcxitems*{cc1da216-a80d-4be4-b309-acb6af313aff}*SharedItemsImports = 4 + ..\external\Box2D\proj.win8.1-universal\libbox2d.Shared\libbox2d.Shared.vcxitems*{4a3c6ba8-c227-498b-aa21-40bda27b461f}*SharedItemsImports = 9 + ..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.Shared\libSpine.Shared.vcxitems*{adafd00d-a0d6-46ef-9f0b-ea2880bfe1de}*SharedItemsImports = 9 + ..\cocos\scripting\js-bindings\proj.win8.1-universal\libjscocos2d\libjscocos2d.Shared\libjscocos2d.Shared.vcxitems*{ca082ec4-17ce-430b-8207-d1e947a5d1e9}*SharedItemsImports = 4 + ..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.Shared\libcocos2d_8_1.Shared.vcxitems*{5d6f020f-7e72-4494-90a0-2df11d235df9}*SharedItemsImports = 9 + ..\cocos\scripting\js-bindings\proj.win8.1-universal\libjscocos2d\libjscocos2d.Shared\libjscocos2d.Shared.vcxitems*{bea66276-51dd-4c53-92a8-f3d1fea50892}*SharedItemsImports = 9 + ..\cocos\scripting\js-bindings\proj.win8.1-universal\libjscocos2d\libjscocos2d.Shared\libjscocos2d.Shared.vcxitems*{bcf5546d-66a0-4998-afd6-c5514f618930}*SharedItemsImports = 4 + ..\external\Box2D\proj.win8.1-universal\libbox2d.Shared\libbox2d.Shared.vcxitems*{3b26a12d-3a44-47ea-82d2-282660fc844d}*SharedItemsImports = 4 + ..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.Shared\libcocos2d_8_1.Shared.vcxitems*{22f3b9df-1209-4574-8331-003966f562bf}*SharedItemsImports = 4 + ..\external\Box2D\proj.win8.1-universal\libbox2d.Shared\libbox2d.Shared.vcxitems*{22f798d8-bfff-4754-996f-a5395343d5ec}*SharedItemsImports = 4 + ..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.Shared\libSpine.Shared.vcxitems*{f3550fe0-c795-44f6-8feb-093eb68143ae}*SharedItemsImports = 4 + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|ARM = Release|ARM + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9335005F-678E-4E8E-9B84-50037216AEC8}.Debug|ARM.ActiveCfg = Debug|ARM + {9335005F-678E-4E8E-9B84-50037216AEC8}.Debug|ARM.Build.0 = Debug|ARM + {9335005F-678E-4E8E-9B84-50037216AEC8}.Debug|Win32.ActiveCfg = Debug|Win32 + {9335005F-678E-4E8E-9B84-50037216AEC8}.Debug|Win32.Build.0 = Debug|Win32 + {9335005F-678E-4E8E-9B84-50037216AEC8}.Debug|x64.ActiveCfg = Debug|x64 + {9335005F-678E-4E8E-9B84-50037216AEC8}.Debug|x64.Build.0 = Debug|x64 + {9335005F-678E-4E8E-9B84-50037216AEC8}.Release|ARM.ActiveCfg = Release|ARM + {9335005F-678E-4E8E-9B84-50037216AEC8}.Release|ARM.Build.0 = Release|ARM + {9335005F-678E-4E8E-9B84-50037216AEC8}.Release|Win32.ActiveCfg = Release|Win32 + {9335005F-678E-4E8E-9B84-50037216AEC8}.Release|Win32.Build.0 = Release|Win32 + {9335005F-678E-4E8E-9B84-50037216AEC8}.Release|x64.ActiveCfg = Release|x64 + {9335005F-678E-4E8E-9B84-50037216AEC8}.Release|x64.Build.0 = Release|x64 + {22F3B9DF-1209-4574-8331-003966F562BF}.Debug|ARM.ActiveCfg = Debug|ARM + {22F3B9DF-1209-4574-8331-003966F562BF}.Debug|ARM.Build.0 = Debug|ARM + {22F3B9DF-1209-4574-8331-003966F562BF}.Debug|Win32.ActiveCfg = Debug|Win32 + {22F3B9DF-1209-4574-8331-003966F562BF}.Debug|Win32.Build.0 = Debug|Win32 + {22F3B9DF-1209-4574-8331-003966F562BF}.Debug|x64.ActiveCfg = Debug|Win32 + {22F3B9DF-1209-4574-8331-003966F562BF}.Release|ARM.ActiveCfg = Release|ARM + {22F3B9DF-1209-4574-8331-003966F562BF}.Release|ARM.Build.0 = Release|ARM + {22F3B9DF-1209-4574-8331-003966F562BF}.Release|Win32.ActiveCfg = Release|Win32 + {22F3B9DF-1209-4574-8331-003966F562BF}.Release|Win32.Build.0 = Release|Win32 + {22F3B9DF-1209-4574-8331-003966F562BF}.Release|x64.ActiveCfg = Release|Win32 + {3B26A12D-3A44-47EA-82D2-282660FC844D}.Debug|ARM.ActiveCfg = Debug|ARM + {3B26A12D-3A44-47EA-82D2-282660FC844D}.Debug|ARM.Build.0 = Debug|ARM + {3B26A12D-3A44-47EA-82D2-282660FC844D}.Debug|Win32.ActiveCfg = Debug|Win32 + {3B26A12D-3A44-47EA-82D2-282660FC844D}.Debug|Win32.Build.0 = Debug|Win32 + {3B26A12D-3A44-47EA-82D2-282660FC844D}.Debug|x64.ActiveCfg = Debug|x64 + {3B26A12D-3A44-47EA-82D2-282660FC844D}.Debug|x64.Build.0 = Debug|x64 + {3B26A12D-3A44-47EA-82D2-282660FC844D}.Release|ARM.ActiveCfg = Release|ARM + {3B26A12D-3A44-47EA-82D2-282660FC844D}.Release|ARM.Build.0 = Release|ARM + {3B26A12D-3A44-47EA-82D2-282660FC844D}.Release|Win32.ActiveCfg = Release|Win32 + {3B26A12D-3A44-47EA-82D2-282660FC844D}.Release|Win32.Build.0 = Release|Win32 + {3B26A12D-3A44-47EA-82D2-282660FC844D}.Release|x64.ActiveCfg = Release|x64 + {3B26A12D-3A44-47EA-82D2-282660FC844D}.Release|x64.Build.0 = Release|x64 + {22F798D8-BFFF-4754-996F-A5395343D5EC}.Debug|ARM.ActiveCfg = Debug|ARM + {22F798D8-BFFF-4754-996F-A5395343D5EC}.Debug|ARM.Build.0 = Debug|ARM + {22F798D8-BFFF-4754-996F-A5395343D5EC}.Debug|Win32.ActiveCfg = Debug|Win32 + {22F798D8-BFFF-4754-996F-A5395343D5EC}.Debug|Win32.Build.0 = Debug|Win32 + {22F798D8-BFFF-4754-996F-A5395343D5EC}.Debug|x64.ActiveCfg = Debug|Win32 + {22F798D8-BFFF-4754-996F-A5395343D5EC}.Release|ARM.ActiveCfg = Release|ARM + {22F798D8-BFFF-4754-996F-A5395343D5EC}.Release|ARM.Build.0 = Release|ARM + {22F798D8-BFFF-4754-996F-A5395343D5EC}.Release|Win32.ActiveCfg = Release|Win32 + {22F798D8-BFFF-4754-996F-A5395343D5EC}.Release|Win32.Build.0 = Release|Win32 + {22F798D8-BFFF-4754-996F-A5395343D5EC}.Release|x64.ActiveCfg = Release|Win32 + {F3550FE0-C795-44F6-8FEB-093EB68143AE}.Debug|ARM.ActiveCfg = Debug|ARM + {F3550FE0-C795-44F6-8FEB-093EB68143AE}.Debug|ARM.Build.0 = Debug|ARM + {F3550FE0-C795-44F6-8FEB-093EB68143AE}.Debug|Win32.ActiveCfg = Debug|Win32 + {F3550FE0-C795-44F6-8FEB-093EB68143AE}.Debug|Win32.Build.0 = Debug|Win32 + {F3550FE0-C795-44F6-8FEB-093EB68143AE}.Debug|x64.ActiveCfg = Debug|x64 + {F3550FE0-C795-44F6-8FEB-093EB68143AE}.Debug|x64.Build.0 = Debug|x64 + {F3550FE0-C795-44F6-8FEB-093EB68143AE}.Release|ARM.ActiveCfg = Release|ARM + {F3550FE0-C795-44F6-8FEB-093EB68143AE}.Release|ARM.Build.0 = Release|ARM + {F3550FE0-C795-44F6-8FEB-093EB68143AE}.Release|Win32.ActiveCfg = Release|Win32 + {F3550FE0-C795-44F6-8FEB-093EB68143AE}.Release|Win32.Build.0 = Release|Win32 + {F3550FE0-C795-44F6-8FEB-093EB68143AE}.Release|x64.ActiveCfg = Release|x64 + {F3550FE0-C795-44F6-8FEB-093EB68143AE}.Release|x64.Build.0 = Release|x64 + {CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Debug|ARM.ActiveCfg = Debug|ARM + {CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Debug|ARM.Build.0 = Debug|ARM + {CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Debug|Win32.ActiveCfg = Debug|Win32 + {CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Debug|Win32.Build.0 = Debug|Win32 + {CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Debug|x64.ActiveCfg = Debug|Win32 + {CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Release|ARM.ActiveCfg = Release|ARM + {CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Release|ARM.Build.0 = Release|ARM + {CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Release|Win32.ActiveCfg = Release|Win32 + {CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Release|Win32.Build.0 = Release|Win32 + {CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Release|x64.ActiveCfg = Release|Win32 + {70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Debug|ARM.ActiveCfg = Debug|ARM + {70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Debug|ARM.Build.0 = Debug|ARM + {70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Debug|ARM.Deploy.0 = Debug|ARM + {70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Debug|Win32.ActiveCfg = Debug|Win32 + {70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Debug|Win32.Build.0 = Debug|Win32 + {70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Debug|Win32.Deploy.0 = Debug|Win32 + {70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Debug|x64.ActiveCfg = Debug|x64 + {70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Debug|x64.Build.0 = Debug|x64 + {70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Debug|x64.Deploy.0 = Debug|x64 + {70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Release|ARM.ActiveCfg = Release|ARM + {70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Release|ARM.Build.0 = Release|ARM + {70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Release|ARM.Deploy.0 = Release|ARM + {70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Release|Win32.ActiveCfg = Release|Win32 + {70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Release|Win32.Build.0 = Release|Win32 + {70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Release|Win32.Deploy.0 = Release|Win32 + {70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Release|x64.ActiveCfg = Release|x64 + {70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Release|x64.Build.0 = Release|x64 + {70914FC8-7709-4CD6-B86B-C63FDE5478DB}.Release|x64.Deploy.0 = Release|x64 + {94874B5B-398F-448A-A366-35A35DC1DB9C}.Debug|ARM.ActiveCfg = Debug|ARM + {94874B5B-398F-448A-A366-35A35DC1DB9C}.Debug|ARM.Build.0 = Debug|ARM + {94874B5B-398F-448A-A366-35A35DC1DB9C}.Debug|ARM.Deploy.0 = Debug|ARM + {94874B5B-398F-448A-A366-35A35DC1DB9C}.Debug|Win32.ActiveCfg = Debug|Win32 + {94874B5B-398F-448A-A366-35A35DC1DB9C}.Debug|Win32.Build.0 = Debug|Win32 + {94874B5B-398F-448A-A366-35A35DC1DB9C}.Debug|Win32.Deploy.0 = Debug|Win32 + {94874B5B-398F-448A-A366-35A35DC1DB9C}.Debug|x64.ActiveCfg = Debug|Win32 + {94874B5B-398F-448A-A366-35A35DC1DB9C}.Release|ARM.ActiveCfg = Release|ARM + {94874B5B-398F-448A-A366-35A35DC1DB9C}.Release|ARM.Build.0 = Release|ARM + {94874B5B-398F-448A-A366-35A35DC1DB9C}.Release|ARM.Deploy.0 = Release|ARM + {94874B5B-398F-448A-A366-35A35DC1DB9C}.Release|Win32.ActiveCfg = Release|Win32 + {94874B5B-398F-448A-A366-35A35DC1DB9C}.Release|Win32.Build.0 = Release|Win32 + {94874B5B-398F-448A-A366-35A35DC1DB9C}.Release|Win32.Deploy.0 = Release|Win32 + {94874B5B-398F-448A-A366-35A35DC1DB9C}.Release|x64.ActiveCfg = Release|Win32 + {BCF5546D-66A0-4998-AFD6-C5514F618930}.Debug|ARM.ActiveCfg = Debug|ARM + {BCF5546D-66A0-4998-AFD6-C5514F618930}.Debug|ARM.Build.0 = Debug|ARM + {BCF5546D-66A0-4998-AFD6-C5514F618930}.Debug|Win32.ActiveCfg = Debug|Win32 + {BCF5546D-66A0-4998-AFD6-C5514F618930}.Debug|Win32.Build.0 = Debug|Win32 + {BCF5546D-66A0-4998-AFD6-C5514F618930}.Debug|x64.ActiveCfg = Debug|x64 + {BCF5546D-66A0-4998-AFD6-C5514F618930}.Debug|x64.Build.0 = Debug|x64 + {BCF5546D-66A0-4998-AFD6-C5514F618930}.Release|ARM.ActiveCfg = Release|ARM + {BCF5546D-66A0-4998-AFD6-C5514F618930}.Release|ARM.Build.0 = Release|ARM + {BCF5546D-66A0-4998-AFD6-C5514F618930}.Release|Win32.ActiveCfg = Release|Win32 + {BCF5546D-66A0-4998-AFD6-C5514F618930}.Release|Win32.Build.0 = Release|Win32 + {BCF5546D-66A0-4998-AFD6-C5514F618930}.Release|x64.ActiveCfg = Release|x64 + {BCF5546D-66A0-4998-AFD6-C5514F618930}.Release|x64.Build.0 = Release|x64 + {CA082EC4-17CE-430B-8207-D1E947A5D1E9}.Debug|ARM.ActiveCfg = Debug|ARM + {CA082EC4-17CE-430B-8207-D1E947A5D1E9}.Debug|ARM.Build.0 = Debug|ARM + {CA082EC4-17CE-430B-8207-D1E947A5D1E9}.Debug|Win32.ActiveCfg = Debug|Win32 + {CA082EC4-17CE-430B-8207-D1E947A5D1E9}.Debug|Win32.Build.0 = Debug|Win32 + {CA082EC4-17CE-430B-8207-D1E947A5D1E9}.Debug|x64.ActiveCfg = Debug|Win32 + {CA082EC4-17CE-430B-8207-D1E947A5D1E9}.Release|ARM.ActiveCfg = Release|ARM + {CA082EC4-17CE-430B-8207-D1E947A5D1E9}.Release|ARM.Build.0 = Release|ARM + {CA082EC4-17CE-430B-8207-D1E947A5D1E9}.Release|Win32.ActiveCfg = Release|Win32 + {CA082EC4-17CE-430B-8207-D1E947A5D1E9}.Release|Win32.Build.0 = Release|Win32 + {CA082EC4-17CE-430B-8207-D1E947A5D1E9}.Release|x64.ActiveCfg = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {5D6F020F-7E72-4494-90A0-2DF11D235DF9} = {B3F299D4-B4CA-4F0B-8BE2-FB328483BC13} + {9335005F-678E-4E8E-9B84-50037216AEC8} = {B3F299D4-B4CA-4F0B-8BE2-FB328483BC13} + {22F3B9DF-1209-4574-8331-003966F562BF} = {B3F299D4-B4CA-4F0B-8BE2-FB328483BC13} + {B3D1A3D5-9F54-43AF-9322-230B53242B78} = {85630454-74EA-4B5B-9B62-0E459B4476CB} + {4A3C6BA8-C227-498B-AA21-40BDA27B461F} = {B3D1A3D5-9F54-43AF-9322-230B53242B78} + {3B26A12D-3A44-47EA-82D2-282660FC844D} = {B3D1A3D5-9F54-43AF-9322-230B53242B78} + {22F798D8-BFFF-4754-996F-A5395343D5EC} = {B3D1A3D5-9F54-43AF-9322-230B53242B78} + {6FEB795C-C98C-4C8C-A88B-A35DEE205348} = {85630454-74EA-4B5B-9B62-0E459B4476CB} + {ADAFD00D-A0D6-46EF-9F0B-EA2880BFE1DE} = {6FEB795C-C98C-4C8C-A88B-A35DEE205348} + {F3550FE0-C795-44F6-8FEB-093EB68143AE} = {6FEB795C-C98C-4C8C-A88B-A35DEE205348} + {CC1DA216-A80D-4BE4-B309-ACB6AF313AFF} = {6FEB795C-C98C-4C8C-A88B-A35DEE205348} + {AE6763F6-1549-441E-AFB5-377BE1C776DC} = {8E24A044-D83D-476D-886D-F40E3CC621DF} + {70914FC8-7709-4CD6-B86B-C63FDE5478DB} = {8E24A044-D83D-476D-886D-F40E3CC621DF} + {94874B5B-398F-448A-A366-35A35DC1DB9C} = {8E24A044-D83D-476D-886D-F40E3CC621DF} + {BEA66276-51DD-4C53-92A8-F3D1FEA50892} = {60DCAEA9-E344-40C0-B90C-82FB8E671BD5} + {BCF5546D-66A0-4998-AFD6-C5514F618930} = {60DCAEA9-E344-40C0-B90C-82FB8E671BD5} + {CA082EC4-17CE-430B-8207-D1E947A5D1E9} = {60DCAEA9-E344-40C0-B90C-82FB8E671BD5} + EndGlobalSection +EndGlobal diff --git a/build/cocos2d-win32.vc2012.sln b/build/cocos2d-win32.vc2013.sln similarity index 87% rename from build/cocos2d-win32.vc2012.sln rename to build/cocos2d-win32.vc2013.sln index 2b6824c9ef..bf1f8bb66a 100644 --- a/build/cocos2d-win32.vc2012.sln +++ b/build/cocos2d-win32.vc2013.sln @@ -1,8 +1,8 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 # Visual Studio 2013 VisualStudioVersion = 12.0.21005.1 -MinimumVisualStudioVersion = 10.0.40219.1 +MinimumVisualStudioVersion = 12.0.21005.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpp-tests", "..\tests\cpp-tests\proj.win32\cpp-tests.vcxproj", "{76A39BB2-9B84-4C65-98A5-654D86B86F2A}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua-tests", "..\tests\lua-tests\project\proj.win32\lua-tests.win32.vcxproj", "{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}" @@ -12,6 +12,9 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua-empty-test", "..\tests\lua-empty-test\project\proj.win32\lua-empty-test.vcxproj", "{13E55395-94A2-4CD9-BFC2-1A051F80C17D}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\cocos\2d\libcocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" + ProjectSection(ProjectDependencies) = postProject + {012DFF48-A13F-4F52-B07B-F8B9D21CE95B} = {012DFF48-A13F-4F52-B07B-F8B9D21CE95B} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libluacocos2d", "..\cocos\scripting\lua-bindings\proj.win32\libluacocos2d.vcxproj", "{9F2D6CE6-C893-4400-B50C-6DB70CC2562F}" EndProject @@ -21,6 +24,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine", "..\cocos\editor EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbox2d", "..\external\Box2D\proj.win32\libbox2d.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbullet", "..\external\bullet\proj.win32\libbullet.vcxproj", "{012DFF48-A13F-4F52-B07B-F8B9D21CE95B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM @@ -77,6 +82,12 @@ Global {929480E7-23C0-4DF6-8456-096D71547116}.Release|ARM.ActiveCfg = Release|Win32 {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.ActiveCfg = Release|Win32 {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.Build.0 = Release|Win32 + {012DFF48-A13F-4F52-B07B-F8B9D21CE95B}.Debug|ARM.ActiveCfg = Debug|Win32 + {012DFF48-A13F-4F52-B07B-F8B9D21CE95B}.Debug|Win32.ActiveCfg = Debug|Win32 + {012DFF48-A13F-4F52-B07B-F8B9D21CE95B}.Debug|Win32.Build.0 = Debug|Win32 + {012DFF48-A13F-4F52-B07B-F8B9D21CE95B}.Release|ARM.ActiveCfg = Release|Win32 + {012DFF48-A13F-4F52-B07B-F8B9D21CE95B}.Release|Win32.ActiveCfg = Release|Win32 + {012DFF48-A13F-4F52-B07B-F8B9D21CE95B}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -84,6 +95,7 @@ Global GlobalSection(NestedProjects) = preSolution {B7C2A162-DEC9-4418-972E-240AB3CBFCAE} = {92D54E36-7916-48EF-A951-224DD3B25442} {929480E7-23C0-4DF6-8456-096D71547116} = {92D54E36-7916-48EF-A951-224DD3B25442} + {012DFF48-A13F-4F52-B07B-F8B9D21CE95B} = {92D54E36-7916-48EF-A951-224DD3B25442} EndGlobalSection GlobalSection(DPCodeReviewSolutionGUID) = preSolution DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} diff --git a/build/cocos2d-win8.1-universal.sln b/build/cocos2d-win8.1-universal.sln index 697e7a7721..4ef61407d8 100644 --- a/build/cocos2d-win8.1-universal.sln +++ b/build/cocos2d-win8.1-universal.sln @@ -2,7 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 VisualStudioVersion = 12.0.31101.0 -MinimumVisualStudioVersion = 10.0.40219.1 +MinimumVisualStudioVersion = 12.0.21005.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libcocos2d", "libcocos2d", "{B3F299D4-B4CA-4F0B-8BE2-FB328483BC13}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d_8_1.Shared", "..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.Shared\libcocos2d_8_1.Shared.vcxitems", "{5D6F020F-7E72-4494-90A0-2DF11D235DF9}" diff --git a/build/cocos2d_js_tests.xcodeproj/project.pbxproj b/build/cocos2d_js_tests.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..8f129b6314 --- /dev/null +++ b/build/cocos2d_js_tests.xcodeproj/project.pbxproj @@ -0,0 +1,883 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 0541A76319738D8C00E45470 /* NativeOcClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 0541A75D19738D5A00E45470 /* NativeOcClass.m */; }; + 0541A77819750DE700E45470 /* NativeOcClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 0541A75D19738D5A00E45470 /* NativeOcClass.m */; }; + 0541A77A19750F7A00E45470 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0541A77919750F7A00E45470 /* AppKit.framework */; }; + 1A604F3418BF1D4900CC9A93 /* src in Resources */ = {isa = PBXBuildFile; fileRef = 1A604F3118BF1D4900CC9A93 /* src */; }; + 1A604F3518BF1D4900CC9A93 /* src in Resources */ = {isa = PBXBuildFile; fileRef = 1A604F3118BF1D4900CC9A93 /* src */; }; + 1A604F3918BF1D5600CC9A93 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A604F3718BF1D5600CC9A93 /* AppDelegate.cpp */; }; + 1A604F3A18BF1D5600CC9A93 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A604F3718BF1D5600CC9A93 /* AppDelegate.cpp */; }; + 1A604F4D18BF1D6000CC9A93 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A604F3D18BF1D6000CC9A93 /* AppController.mm */; }; + 1A604F4E18BF1D6000CC9A93 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A604F3E18BF1D6000CC9A93 /* Default-568h@2x.png */; }; + 1A604F4F18BF1D6000CC9A93 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A604F3F18BF1D6000CC9A93 /* Default.png */; }; + 1A604F5018BF1D6000CC9A93 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A604F4018BF1D6000CC9A93 /* Default@2x.png */; }; + 1A604F5118BF1D6000CC9A93 /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A604F4118BF1D6000CC9A93 /* Icon-114.png */; }; + 1A604F5218BF1D6000CC9A93 /* Icon-120.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A604F4218BF1D6000CC9A93 /* Icon-120.png */; }; + 1A604F5318BF1D6000CC9A93 /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A604F4318BF1D6000CC9A93 /* Icon-144.png */; }; + 1A604F5418BF1D6000CC9A93 /* Icon-152.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A604F4418BF1D6000CC9A93 /* Icon-152.png */; }; + 1A604F5518BF1D6000CC9A93 /* Icon-57.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A604F4518BF1D6000CC9A93 /* Icon-57.png */; }; + 1A604F5618BF1D6000CC9A93 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A604F4618BF1D6000CC9A93 /* Icon-72.png */; }; + 1A604F5718BF1D6000CC9A93 /* Icon-76.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A604F4718BF1D6000CC9A93 /* Icon-76.png */; }; + 1A604F5918BF1D6000CC9A93 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A604F4918BF1D6000CC9A93 /* main.m */; }; + 1A604F5A18BF1D6000CC9A93 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A604F4C18BF1D6000CC9A93 /* RootViewController.mm */; }; + 1A604F6418BF1D6600CC9A93 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1A604F5C18BF1D6600CC9A93 /* InfoPlist.strings */; }; + 1A604F6518BF1D6600CC9A93 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1A604F5E18BF1D6600CC9A93 /* MainMenu.xib */; }; + 1A604F6618BF1D6600CC9A93 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 1A604F6018BF1D6600CC9A93 /* Icon.icns */; }; + 1A604F6718BF1D6600CC9A93 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A604F6118BF1D6600CC9A93 /* main.cpp */; }; + 420BBD111AA8840E00493976 /* js_DrawNode3D_bindings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBD0F1AA8840E00493976 /* js_DrawNode3D_bindings.cpp */; }; + 420BBD121AA8840E00493976 /* js_DrawNode3D_bindings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBD0F1AA8840E00493976 /* js_DrawNode3D_bindings.cpp */; }; + 42BCD4A31AAF3BF500D035E5 /* js_Effect3D_bindings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42BCD4A11AAF3BF500D035E5 /* js_Effect3D_bindings.cpp */; }; + 42BCD4A41AAF3BF500D035E5 /* js_Effect3D_bindings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42BCD4A11AAF3BF500D035E5 /* js_Effect3D_bindings.cpp */; }; + A01E18F81784C59400B0CA4A /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A035A71117822E9E00987F6C /* libsqlite3.dylib */; }; + A035A5E01782290400987F6C /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A9F808C177E98A600D9A1CB /* libcurl.dylib */; }; + A035A71217822E9E00987F6C /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A035A71117822E9E00987F6C /* libsqlite3.dylib */; }; + BA0613B51AC23B2D003118D6 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BA0613B41AC23B2D003118D6 /* Security.framework */; }; + BA2350551948262700E17B2A /* script in Resources */ = {isa = PBXBuildFile; fileRef = BA2350541948262700E17B2A /* script */; }; + BA2350561948262700E17B2A /* script in Resources */ = {isa = PBXBuildFile; fileRef = BA2350541948262700E17B2A /* script */; }; + BAA7DEE418C84F5000D9A10E /* main.js in Resources */ = {isa = PBXBuildFile; fileRef = BAA7DEE218C84F5000D9A10E /* main.js */; }; + BAA7DEE518C84F5000D9A10E /* main.js in Resources */ = {isa = PBXBuildFile; fileRef = BAA7DEE218C84F5000D9A10E /* main.js */; }; + BAA7DEE618C84F5000D9A10E /* project.json in Resources */ = {isa = PBXBuildFile; fileRef = BAA7DEE318C84F5000D9A10E /* project.json */; }; + BAA7DEE718C84F5000D9A10E /* project.json in Resources */ = {isa = PBXBuildFile; fileRef = BAA7DEE318C84F5000D9A10E /* project.json */; }; + ED2719A21AE4F4F000C17085 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719A11AE4F4F000C17085 /* GameController.framework */; }; + ED2719A41AE4F51F00C17085 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719A31AE4F51F00C17085 /* StoreKit.framework */; }; + ED2719A61AE4F52F00C17085 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719A51AE4F52E00C17085 /* CoreTelephony.framework */; }; + ED2719A81AE4F53B00C17085 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719A71AE4F53B00C17085 /* Security.framework */; }; + ED2719AA1AE4F54500C17085 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719A91AE4F54500C17085 /* MediaPlayer.framework */; }; + ED2719AC1AE4F55000C17085 /* MessageUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719AB1AE4F55000C17085 /* MessageUI.framework */; }; + ED2719AE1AE4F55800C17085 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719AD1AE4F55800C17085 /* AdSupport.framework */; }; + ED2719B01AE4F56500C17085 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719AF1AE4F56500C17085 /* SystemConfiguration.framework */; }; + ED2719B21AE4F57200C17085 /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719B11AE4F57100C17085 /* CoreMotion.framework */; }; + ED2719B41AE4F57E00C17085 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719B31AE4F57E00C17085 /* libz.dylib */; }; + ED2719B61AE4F59500C17085 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719B51AE4F59500C17085 /* Foundation.framework */; }; + ED2719B81AE4F5A100C17085 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719B71AE4F5A100C17085 /* AudioToolbox.framework */; }; + ED2719BA1AE4F5A900C17085 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719B91AE4F5A900C17085 /* OpenAL.framework */; }; + ED2719BC1AE4F5B500C17085 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719BB1AE4F5B500C17085 /* QuartzCore.framework */; }; + ED2719BE1AE4F5BE00C17085 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719BD1AE4F5BE00C17085 /* CoreGraphics.framework */; }; + ED2719C01AE4F5C500C17085 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719BF1AE4F5C500C17085 /* OpenGLES.framework */; }; + ED2719C21AE4F5CC00C17085 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719C11AE4F5CC00C17085 /* UIKit.framework */; }; + ED2719C41AE4F5D300C17085 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719C31AE4F5D300C17085 /* AVFoundation.framework */; }; + ED2719C61AE4F60C00C17085 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719C51AE4F60C00C17085 /* libz.dylib */; }; + ED2719C81AE4F61600C17085 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719C71AE4F61500C17085 /* Foundation.framework */; }; + ED2719CA1AE4F61D00C17085 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719C91AE4F61D00C17085 /* AudioToolbox.framework */; }; + ED2719CC1AE4F62A00C17085 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719CB1AE4F62A00C17085 /* ApplicationServices.framework */; }; + ED2719CE1AE4F63200C17085 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719CD1AE4F63200C17085 /* OpenAL.framework */; }; + ED2719D01AE4F63D00C17085 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719CF1AE4F63D00C17085 /* QuartzCore.framework */; }; + ED2719D21AE4F64600C17085 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719D11AE4F64600C17085 /* OpenGL.framework */; }; + ED2719D41AE4F64D00C17085 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719D31AE4F64D00C17085 /* Cocoa.framework */; }; + ED2719D51AE4F86500C17085 /* libjscocos2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719611AE4E69800C17085 /* libjscocos2d iOS.a */; }; + ED2719DA1AE4F8EB00C17085 /* libcocos2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719591AE4E68200C17085 /* libcocos2d iOS.a */; }; + ED2719DB1AE4FA1200C17085 /* libcocos2d Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2719571AE4E68200C17085 /* libcocos2d Mac.a */; }; + ED2719DC1AE4FA1600C17085 /* libjscocos2d Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ED27195F1AE4E69800C17085 /* libjscocos2d Mac.a */; }; + ED743D1717D099F10004076B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDCC747E17C455FD007B692C /* IOKit.framework */; }; + EDCA13E81AEA4D4A00F445CA /* res in Resources */ = {isa = PBXBuildFile; fileRef = EDCA13E71AEA4D4A00F445CA /* res */; }; + EDCA13E91AEA4D4A00F445CA /* res in Resources */ = {isa = PBXBuildFile; fileRef = EDCA13E71AEA4D4A00F445CA /* res */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + ED2719561AE4E68200C17085 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1A604F0218BF1D1C00CC9A93 /* cocos2d_libs.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 1551A33F158F2AB200E66CFE; + remoteInfo = "libcocos2d Mac"; + }; + ED2719581AE4E68200C17085 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1A604F0218BF1D1C00CC9A93 /* cocos2d_libs.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = A07A4D641783777C0073F6A7; + remoteInfo = "libcocos2d iOS"; + }; + ED27195E1AE4E69800C17085 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1A604F2518BF1D2000CC9A93 /* cocos2d_js_bindings.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 1A5410A418B785A10016A3AF; + remoteInfo = "libjscocos2d Mac"; + }; + ED2719601AE4E69800C17085 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1A604F2518BF1D2000CC9A93 /* cocos2d_js_bindings.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 1A5410A518B785A10016A3AF; + remoteInfo = "libjscocos2d iOS"; + }; + ED2719941AE4F14A00C17085 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1A604F2518BF1D2000CC9A93 /* cocos2d_js_bindings.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = A07A4FB5178387750073F6A7; + remoteInfo = "libjscocos2d iOS"; + }; + ED2719961AE4F15100C17085 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1A604F0218BF1D1C00CC9A93 /* cocos2d_libs.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 1551A33E158F2AB200E66CFE; + remoteInfo = "libcocos2d Mac"; + }; + ED2719981AE4F15800C17085 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1A604F2518BF1D2000CC9A93 /* cocos2d_js_bindings.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = A03F31E81781479B006731B9; + remoteInfo = "libjscocos2d Mac"; + }; + ED27199E1AE4F48800C17085 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1A604F0218BF1D1C00CC9A93 /* cocos2d_libs.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = A07A4C241783777C0073F6A7; + remoteInfo = "libcocos2d iOS"; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 0541A75C19738D5A00E45470 /* NativeOcClass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NativeOcClass.h; path = ../proj.ios/NativeOcClass.h; sourceTree = ""; }; + 0541A75D19738D5A00E45470 /* NativeOcClass.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NativeOcClass.m; path = ../proj.ios/NativeOcClass.m; sourceTree = ""; }; + 0541A77919750F7A00E45470 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; + 1A604F0218BF1D1C00CC9A93 /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = cocos2d_libs.xcodeproj; sourceTree = ""; }; + 1A604F2518BF1D2000CC9A93 /* cocos2d_js_bindings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_js_bindings.xcodeproj; path = "../cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj"; sourceTree = ""; }; + 1A604F3118BF1D4900CC9A93 /* src */ = {isa = PBXFileReference; lastKnownFileType = folder; name = src; path = "../tests/js-tests/src"; sourceTree = ""; }; + 1A604F3718BF1D5600CC9A93 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; + 1A604F3818BF1D5600CC9A93 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 1A604F3C18BF1D6000CC9A93 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; + 1A604F3D18BF1D6000CC9A93 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; + 1A604F3E18BF1D6000CC9A93 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + 1A604F3F18BF1D6000CC9A93 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; + 1A604F4018BF1D6000CC9A93 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; + 1A604F4118BF1D6000CC9A93 /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-114.png"; sourceTree = ""; }; + 1A604F4218BF1D6000CC9A93 /* Icon-120.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-120.png"; sourceTree = ""; }; + 1A604F4318BF1D6000CC9A93 /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-144.png"; sourceTree = ""; }; + 1A604F4418BF1D6000CC9A93 /* Icon-152.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-152.png"; sourceTree = ""; }; + 1A604F4518BF1D6000CC9A93 /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-57.png"; sourceTree = ""; }; + 1A604F4618BF1D6000CC9A93 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; }; + 1A604F4718BF1D6000CC9A93 /* Icon-76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-76.png"; sourceTree = ""; }; + 1A604F4818BF1D6000CC9A93 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 1A604F4918BF1D6000CC9A93 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 1A604F4A18BF1D6000CC9A93 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; + 1A604F4B18BF1D6000CC9A93 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; + 1A604F4C18BF1D6000CC9A93 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; + 1A604F5D18BF1D6600CC9A93 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 1A604F5F18BF1D6600CC9A93 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; + 1A604F6018BF1D6600CC9A93 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; }; + 1A604F6118BF1D6600CC9A93 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; + 1A604F6218BF1D6600CC9A93 /* Test_Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Test_Info.plist; sourceTree = ""; }; + 1A604F6318BF1D6600CC9A93 /* Test_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Test_Prefix.pch; sourceTree = ""; }; + 1A9F808C177E98A600D9A1CB /* libcurl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcurl.dylib; path = usr/lib/libcurl.dylib; sourceTree = SDKROOT; }; + 420BBD0F1AA8840E00493976 /* js_DrawNode3D_bindings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_DrawNode3D_bindings.cpp; sourceTree = ""; }; + 420BBD101AA8840E00493976 /* js_DrawNode3D_bindings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_DrawNode3D_bindings.h; sourceTree = ""; }; + 42BCD4A11AAF3BF500D035E5 /* js_Effect3D_bindings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_Effect3D_bindings.cpp; sourceTree = ""; }; + 42BCD4A21AAF3BF500D035E5 /* js_Effect3D_bindings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_Effect3D_bindings.h; sourceTree = ""; }; + A01E17721784C06E00B0CA4A /* js-tests iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "js-tests iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + A035A5EC1782290400987F6C /* js-tests Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "js-tests Mac.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + A035A71117822E9E00987F6C /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; }; + BA0613B41AC23B2D003118D6 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; + BA2350541948262700E17B2A /* script */ = {isa = PBXFileReference; lastKnownFileType = text; name = script; path = "../cocos/scripting/js-bindings/script"; sourceTree = ""; }; + BAA7DEE218C84F5000D9A10E /* main.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = main.js; path = "../tests/js-tests/main.js"; sourceTree = ""; }; + BAA7DEE318C84F5000D9A10E /* project.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = project.json; path = "../tests/js-tests/project.json"; sourceTree = ""; }; + ED2719A11AE4F4F000C17085 /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/GameController.framework; sourceTree = DEVELOPER_DIR; }; + ED2719A31AE4F51F00C17085 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/StoreKit.framework; sourceTree = DEVELOPER_DIR; }; + ED2719A51AE4F52E00C17085 /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/CoreTelephony.framework; sourceTree = DEVELOPER_DIR; }; + ED2719A71AE4F53B00C17085 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; }; + ED2719A91AE4F54500C17085 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/MediaPlayer.framework; sourceTree = DEVELOPER_DIR; }; + ED2719AB1AE4F55000C17085 /* MessageUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MessageUI.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/MessageUI.framework; sourceTree = DEVELOPER_DIR; }; + ED2719AD1AE4F55800C17085 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/AdSupport.framework; sourceTree = DEVELOPER_DIR; }; + ED2719AF1AE4F56500C17085 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; }; + ED2719B11AE4F57100C17085 /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/CoreMotion.framework; sourceTree = DEVELOPER_DIR; }; + ED2719B31AE4F57E00C17085 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/usr/lib/libz.dylib; sourceTree = DEVELOPER_DIR; }; + ED2719B51AE4F59500C17085 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; + ED2719B71AE4F5A100C17085 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/AudioToolbox.framework; sourceTree = DEVELOPER_DIR; }; + ED2719B91AE4F5A900C17085 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/OpenAL.framework; sourceTree = DEVELOPER_DIR; }; + ED2719BB1AE4F5B500C17085 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/QuartzCore.framework; sourceTree = DEVELOPER_DIR; }; + ED2719BD1AE4F5BE00C17085 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; }; + ED2719BF1AE4F5C500C17085 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/OpenGLES.framework; sourceTree = DEVELOPER_DIR; }; + ED2719C11AE4F5CC00C17085 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; + ED2719C31AE4F5D300C17085 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/AVFoundation.framework; sourceTree = DEVELOPER_DIR; }; + ED2719C51AE4F60C00C17085 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; + ED2719C71AE4F61500C17085 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + ED2719C91AE4F61D00C17085 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; + ED2719CB1AE4F62A00C17085 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = System/Library/Frameworks/ApplicationServices.framework; sourceTree = SDKROOT; }; + ED2719CD1AE4F63200C17085 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; + ED2719CF1AE4F63D00C17085 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; + ED2719D11AE4F64600C17085 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; + ED2719D31AE4F64D00C17085 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; + EDCA13E71AEA4D4A00F445CA /* res */ = {isa = PBXFileReference; lastKnownFileType = folder; name = res; path = "../tests/js-tests/res"; sourceTree = ""; }; + EDCC747E17C455FD007B692C /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + A01E17601784C06E00B0CA4A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ED2719DA1AE4F8EB00C17085 /* libcocos2d iOS.a in Frameworks */, + ED2719D51AE4F86500C17085 /* libjscocos2d iOS.a in Frameworks */, + ED2719C41AE4F5D300C17085 /* AVFoundation.framework in Frameworks */, + ED2719C21AE4F5CC00C17085 /* UIKit.framework in Frameworks */, + ED2719C01AE4F5C500C17085 /* OpenGLES.framework in Frameworks */, + ED2719BE1AE4F5BE00C17085 /* CoreGraphics.framework in Frameworks */, + ED2719BC1AE4F5B500C17085 /* QuartzCore.framework in Frameworks */, + ED2719BA1AE4F5A900C17085 /* OpenAL.framework in Frameworks */, + ED2719B81AE4F5A100C17085 /* AudioToolbox.framework in Frameworks */, + ED2719B61AE4F59500C17085 /* Foundation.framework in Frameworks */, + ED2719B41AE4F57E00C17085 /* libz.dylib in Frameworks */, + ED2719B21AE4F57200C17085 /* CoreMotion.framework in Frameworks */, + ED2719B01AE4F56500C17085 /* SystemConfiguration.framework in Frameworks */, + ED2719AE1AE4F55800C17085 /* AdSupport.framework in Frameworks */, + ED2719AC1AE4F55000C17085 /* MessageUI.framework in Frameworks */, + ED2719AA1AE4F54500C17085 /* MediaPlayer.framework in Frameworks */, + ED2719A81AE4F53B00C17085 /* Security.framework in Frameworks */, + ED2719A61AE4F52F00C17085 /* CoreTelephony.framework in Frameworks */, + ED2719A41AE4F51F00C17085 /* StoreKit.framework in Frameworks */, + ED2719A21AE4F4F000C17085 /* GameController.framework in Frameworks */, + A01E18F81784C59400B0CA4A /* libsqlite3.dylib in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A035A5DA1782290400987F6C /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ED2719DC1AE4FA1600C17085 /* libjscocos2d Mac.a in Frameworks */, + ED2719DB1AE4FA1200C17085 /* libcocos2d Mac.a in Frameworks */, + ED2719D41AE4F64D00C17085 /* Cocoa.framework in Frameworks */, + ED2719D21AE4F64600C17085 /* OpenGL.framework in Frameworks */, + ED2719D01AE4F63D00C17085 /* QuartzCore.framework in Frameworks */, + ED2719CE1AE4F63200C17085 /* OpenAL.framework in Frameworks */, + ED2719CC1AE4F62A00C17085 /* ApplicationServices.framework in Frameworks */, + ED2719CA1AE4F61D00C17085 /* AudioToolbox.framework in Frameworks */, + ED2719C81AE4F61600C17085 /* Foundation.framework in Frameworks */, + ED2719C61AE4F60C00C17085 /* libz.dylib in Frameworks */, + BA0613B51AC23B2D003118D6 /* Security.framework in Frameworks */, + 0541A77A19750F7A00E45470 /* AppKit.framework in Frameworks */, + A035A71217822E9E00987F6C /* libsqlite3.dylib in Frameworks */, + A035A5E01782290400987F6C /* libcurl.dylib in Frameworks */, + ED743D1717D099F10004076B /* IOKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 19C28FACFE9D520D11CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + A035A5EC1782290400987F6C /* js-tests Mac.app */, + A01E17721784C06E00B0CA4A /* js-tests iOS.app */, + ); + name = Products; + sourceTree = ""; + }; + 1A2B72DA18D294AE00ED9E74 /* project */ = { + isa = PBXGroup; + children = ( + 1A604F3618BF1D5600CC9A93 /* Classes */, + 1A604F3B18BF1D6000CC9A93 /* proj.ios */, + 1A604F5B18BF1D6600CC9A93 /* proj.mac */, + ); + name = project; + sourceTree = ""; + }; + 1A604F2E18BF1D3300CC9A93 /* js-tests */ = { + isa = PBXGroup; + children = ( + EDCA13E71AEA4D4A00F445CA /* res */, + BAA7DEE218C84F5000D9A10E /* main.js */, + 1A2B72DA18D294AE00ED9E74 /* project */, + BAA7DEE318C84F5000D9A10E /* project.json */, + 1A604F3118BF1D4900CC9A93 /* src */, + ); + name = "js-tests"; + sourceTree = ""; + }; + 1A604F3618BF1D5600CC9A93 /* Classes */ = { + isa = PBXGroup; + children = ( + 42BCD4A11AAF3BF500D035E5 /* js_Effect3D_bindings.cpp */, + 42BCD4A21AAF3BF500D035E5 /* js_Effect3D_bindings.h */, + 420BBD0F1AA8840E00493976 /* js_DrawNode3D_bindings.cpp */, + 420BBD101AA8840E00493976 /* js_DrawNode3D_bindings.h */, + 0541A75C19738D5A00E45470 /* NativeOcClass.h */, + 0541A75D19738D5A00E45470 /* NativeOcClass.m */, + 1A604F3718BF1D5600CC9A93 /* AppDelegate.cpp */, + 1A604F3818BF1D5600CC9A93 /* AppDelegate.h */, + ); + name = Classes; + path = "../tests/js-tests/project/Classes"; + sourceTree = ""; + }; + 1A604F3B18BF1D6000CC9A93 /* proj.ios */ = { + isa = PBXGroup; + children = ( + 1A604F3C18BF1D6000CC9A93 /* AppController.h */, + 1A604F3D18BF1D6000CC9A93 /* AppController.mm */, + 1A604F3E18BF1D6000CC9A93 /* Default-568h@2x.png */, + 1A604F3F18BF1D6000CC9A93 /* Default.png */, + 1A604F4018BF1D6000CC9A93 /* Default@2x.png */, + 1A604F4118BF1D6000CC9A93 /* Icon-114.png */, + 1A604F4218BF1D6000CC9A93 /* Icon-120.png */, + 1A604F4318BF1D6000CC9A93 /* Icon-144.png */, + 1A604F4418BF1D6000CC9A93 /* Icon-152.png */, + 1A604F4518BF1D6000CC9A93 /* Icon-57.png */, + 1A604F4618BF1D6000CC9A93 /* Icon-72.png */, + 1A604F4718BF1D6000CC9A93 /* Icon-76.png */, + 1A604F4818BF1D6000CC9A93 /* Info.plist */, + 1A604F4918BF1D6000CC9A93 /* main.m */, + 1A604F4A18BF1D6000CC9A93 /* Prefix.pch */, + 1A604F4B18BF1D6000CC9A93 /* RootViewController.h */, + 1A604F4C18BF1D6000CC9A93 /* RootViewController.mm */, + ); + name = proj.ios; + path = "../tests/js-tests/project/proj.ios"; + sourceTree = ""; + }; + 1A604F5B18BF1D6600CC9A93 /* proj.mac */ = { + isa = PBXGroup; + children = ( + 1A604F5C18BF1D6600CC9A93 /* InfoPlist.strings */, + 1A604F5E18BF1D6600CC9A93 /* MainMenu.xib */, + 1A604F6018BF1D6600CC9A93 /* Icon.icns */, + 1A604F6118BF1D6600CC9A93 /* main.cpp */, + 1A604F6218BF1D6600CC9A93 /* Test_Info.plist */, + 1A604F6318BF1D6600CC9A93 /* Test_Prefix.pch */, + ); + name = proj.mac; + path = "../tests/js-tests/project/proj.mac"; + sourceTree = ""; + }; + 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { + isa = PBXGroup; + children = ( + 1A604F2518BF1D2000CC9A93 /* cocos2d_js_bindings.xcodeproj */, + 1A604F0218BF1D1C00CC9A93 /* cocos2d_libs.xcodeproj */, + 29B97323FDCFA39411CA2CEA /* Frameworks */, + BAC9055D195C2D2500307000 /* script */, + 1A604F2E18BF1D3300CC9A93 /* js-tests */, + 19C28FACFE9D520D11CA2CBB /* Products */, + ); + name = CustomTemplate; + sourceTree = ""; + }; + 29B97323FDCFA39411CA2CEA /* Frameworks */ = { + isa = PBXGroup; + children = ( + ED2719D31AE4F64D00C17085 /* Cocoa.framework */, + ED2719D11AE4F64600C17085 /* OpenGL.framework */, + ED2719CF1AE4F63D00C17085 /* QuartzCore.framework */, + ED2719CD1AE4F63200C17085 /* OpenAL.framework */, + ED2719CB1AE4F62A00C17085 /* ApplicationServices.framework */, + ED2719C91AE4F61D00C17085 /* AudioToolbox.framework */, + ED2719C71AE4F61500C17085 /* Foundation.framework */, + ED2719C51AE4F60C00C17085 /* libz.dylib */, + ED2719C31AE4F5D300C17085 /* AVFoundation.framework */, + ED2719C11AE4F5CC00C17085 /* UIKit.framework */, + ED2719BF1AE4F5C500C17085 /* OpenGLES.framework */, + ED2719BD1AE4F5BE00C17085 /* CoreGraphics.framework */, + ED2719BB1AE4F5B500C17085 /* QuartzCore.framework */, + ED2719B91AE4F5A900C17085 /* OpenAL.framework */, + ED2719B71AE4F5A100C17085 /* AudioToolbox.framework */, + ED2719B51AE4F59500C17085 /* Foundation.framework */, + ED2719B31AE4F57E00C17085 /* libz.dylib */, + ED2719B11AE4F57100C17085 /* CoreMotion.framework */, + ED2719AF1AE4F56500C17085 /* SystemConfiguration.framework */, + ED2719AD1AE4F55800C17085 /* AdSupport.framework */, + ED2719AB1AE4F55000C17085 /* MessageUI.framework */, + ED2719A91AE4F54500C17085 /* MediaPlayer.framework */, + ED2719A71AE4F53B00C17085 /* Security.framework */, + ED2719A51AE4F52E00C17085 /* CoreTelephony.framework */, + ED2719A31AE4F51F00C17085 /* StoreKit.framework */, + ED2719A11AE4F4F000C17085 /* GameController.framework */, + BA0613B41AC23B2D003118D6 /* Security.framework */, + 0541A77919750F7A00E45470 /* AppKit.framework */, + A035A71117822E9E00987F6C /* libsqlite3.dylib */, + 1A9F808C177E98A600D9A1CB /* libcurl.dylib */, + EDCC747E17C455FD007B692C /* IOKit.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + BAC9055D195C2D2500307000 /* script */ = { + isa = PBXGroup; + children = ( + BA2350541948262700E17B2A /* script */, + ); + name = script; + sourceTree = ""; + }; + ED2719521AE4E68200C17085 /* Products */ = { + isa = PBXGroup; + children = ( + ED2719571AE4E68200C17085 /* libcocos2d Mac.a */, + ED2719591AE4E68200C17085 /* libcocos2d iOS.a */, + ); + name = Products; + sourceTree = ""; + }; + ED27195A1AE4E69800C17085 /* Products */ = { + isa = PBXGroup; + children = ( + ED27195F1AE4E69800C17085 /* libjscocos2d Mac.a */, + ED2719611AE4E69800C17085 /* libjscocos2d iOS.a */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + A01E16C01784C06E00B0CA4A /* js-tests iOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = A01E176F1784C06E00B0CA4A /* Build configuration list for PBXNativeTarget "js-tests iOS" */; + buildPhases = ( + EDCA13EE1AEA4E7B00F445CA /* ShellScript */, + A01E16CB1784C06E00B0CA4A /* Resources */, + A01E16F51784C06E00B0CA4A /* Sources */, + A01E17601784C06E00B0CA4A /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ED2719951AE4F14A00C17085 /* PBXTargetDependency */, + ED27199F1AE4F48800C17085 /* PBXTargetDependency */, + ); + name = "js-tests iOS"; + productName = iphone; + productReference = A01E17721784C06E00B0CA4A /* js-tests iOS.app */; + productType = "com.apple.product-type.application"; + }; + A035A5441782290400987F6C /* js-tests Mac */ = { + isa = PBXNativeTarget; + buildConfigurationList = A035A5E91782290400987F6C /* Build configuration list for PBXNativeTarget "js-tests Mac" */; + buildPhases = ( + EDCA13E61AEA4C8100F445CA /* Run Script */, + A035A54F1782290400987F6C /* Resources */, + A035A5701782290400987F6C /* Sources */, + A035A5DA1782290400987F6C /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ED2719991AE4F15800C17085 /* PBXTargetDependency */, + ED2719971AE4F15100C17085 /* PBXTargetDependency */, + ); + name = "js-tests Mac"; + productName = iphone; + productReference = A035A5EC1782290400987F6C /* js-tests Mac.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 29B97313FDCFA39411CA2CEA /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0510; + }; + buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "cocos2d_js_tests" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 1; + knownRegions = ( + English, + Japanese, + French, + German, + en, + ); + mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; + projectDirPath = ""; + projectReferences = ( + { + ProductGroup = ED27195A1AE4E69800C17085 /* Products */; + ProjectRef = 1A604F2518BF1D2000CC9A93 /* cocos2d_js_bindings.xcodeproj */; + }, + { + ProductGroup = ED2719521AE4E68200C17085 /* Products */; + ProjectRef = 1A604F0218BF1D1C00CC9A93 /* cocos2d_libs.xcodeproj */; + }, + ); + projectRoot = ""; + targets = ( + A035A5441782290400987F6C /* js-tests Mac */, + A01E16C01784C06E00B0CA4A /* js-tests iOS */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXReferenceProxy section */ + ED2719571AE4E68200C17085 /* libcocos2d Mac.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libcocos2d Mac.a"; + remoteRef = ED2719561AE4E68200C17085 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + ED2719591AE4E68200C17085 /* libcocos2d iOS.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libcocos2d iOS.a"; + remoteRef = ED2719581AE4E68200C17085 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + ED27195F1AE4E69800C17085 /* libjscocos2d Mac.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libjscocos2d Mac.a"; + remoteRef = ED27195E1AE4E69800C17085 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + ED2719611AE4E69800C17085 /* libjscocos2d iOS.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libjscocos2d iOS.a"; + remoteRef = ED2719601AE4E69800C17085 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + +/* Begin PBXResourcesBuildPhase section */ + A01E16CB1784C06E00B0CA4A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BA2350561948262700E17B2A /* script in Resources */, + BAA7DEE718C84F5000D9A10E /* project.json in Resources */, + 1A604F5518BF1D6000CC9A93 /* Icon-57.png in Resources */, + EDCA13E91AEA4D4A00F445CA /* res in Resources */, + 1A604F5218BF1D6000CC9A93 /* Icon-120.png in Resources */, + 1A604F5618BF1D6000CC9A93 /* Icon-72.png in Resources */, + 1A604F5118BF1D6000CC9A93 /* Icon-114.png in Resources */, + 1A604F5718BF1D6000CC9A93 /* Icon-76.png in Resources */, + 1A604F3518BF1D4900CC9A93 /* src in Resources */, + 1A604F5018BF1D6000CC9A93 /* Default@2x.png in Resources */, + 1A604F4E18BF1D6000CC9A93 /* Default-568h@2x.png in Resources */, + 1A604F5318BF1D6000CC9A93 /* Icon-144.png in Resources */, + 1A604F5418BF1D6000CC9A93 /* Icon-152.png in Resources */, + 1A604F4F18BF1D6000CC9A93 /* Default.png in Resources */, + BAA7DEE518C84F5000D9A10E /* main.js in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A035A54F1782290400987F6C /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BAA7DEE618C84F5000D9A10E /* project.json in Resources */, + 1A604F6418BF1D6600CC9A93 /* InfoPlist.strings in Resources */, + BA2350551948262700E17B2A /* script in Resources */, + 1A604F6618BF1D6600CC9A93 /* Icon.icns in Resources */, + 1A604F3418BF1D4900CC9A93 /* src in Resources */, + EDCA13E81AEA4D4A00F445CA /* res in Resources */, + 1A604F6518BF1D6600CC9A93 /* MainMenu.xib in Resources */, + BAA7DEE418C84F5000D9A10E /* main.js in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + EDCA13E61AEA4C8100F445CA /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "#!/bin/bash\ncocos_dir=${SRCROOT}/../tests/js-tests/res\nif [ -d \"${cocos_dir}\" ]; then\nrm -rv \"${cocos_dir}\"\nmkdir \"${cocos_dir}\"\nelse\nmkdir \"${cocos_dir}\"\nfi\n\ncp -r \"${SRCROOT}/../tests/cpp-tests/Resources/\" \"${cocos_dir}\""; + }; + EDCA13EE1AEA4E7B00F445CA /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "#!/bin/bash\ncocos_dir=${SRCROOT}/../tests/js-tests/res\nif [ -d \"${cocos_dir}\" ]; then\nrm -rv \"${cocos_dir}\"\nmkdir \"${cocos_dir}\"\nelse\nmkdir \"${cocos_dir}\"\nfi\n\ncp -r \"${SRCROOT}/../tests/cpp-tests/Resources/\" \"${cocos_dir}\""; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + A01E16F51784C06E00B0CA4A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0541A76319738D8C00E45470 /* NativeOcClass.m in Sources */, + 1A604F5A18BF1D6000CC9A93 /* RootViewController.mm in Sources */, + 42BCD4A41AAF3BF500D035E5 /* js_Effect3D_bindings.cpp in Sources */, + 420BBD121AA8840E00493976 /* js_DrawNode3D_bindings.cpp in Sources */, + 1A604F3A18BF1D5600CC9A93 /* AppDelegate.cpp in Sources */, + 1A604F5918BF1D6000CC9A93 /* main.m in Sources */, + 1A604F4D18BF1D6000CC9A93 /* AppController.mm in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A035A5701782290400987F6C /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0541A77819750DE700E45470 /* NativeOcClass.m in Sources */, + 1A604F6718BF1D6600CC9A93 /* main.cpp in Sources */, + 42BCD4A31AAF3BF500D035E5 /* js_Effect3D_bindings.cpp in Sources */, + 420BBD111AA8840E00493976 /* js_DrawNode3D_bindings.cpp in Sources */, + 1A604F3918BF1D5600CC9A93 /* AppDelegate.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + ED2719951AE4F14A00C17085 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "libjscocos2d iOS"; + targetProxy = ED2719941AE4F14A00C17085 /* PBXContainerItemProxy */; + }; + ED2719971AE4F15100C17085 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "libcocos2d Mac"; + targetProxy = ED2719961AE4F15100C17085 /* PBXContainerItemProxy */; + }; + ED2719991AE4F15800C17085 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "libjscocos2d Mac"; + targetProxy = ED2719981AE4F15800C17085 /* PBXContainerItemProxy */; + }; + ED27199F1AE4F48800C17085 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "libcocos2d iOS"; + targetProxy = ED27199E1AE4F48800C17085 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 1A604F5C18BF1D6600CC9A93 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 1A604F5D18BF1D6600CC9A93 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + 1A604F5E18BF1D6600CC9A93 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 1A604F5F18BF1D6600CC9A93 /* en */, + ); + name = MainMenu.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + A01E17701784C06E00B0CA4A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COMPRESS_PNG_FILES = NO; + COPY_PHASE_STRIP = NO; + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + GCC_DYNAMIC_NO_PIC = NO; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + CC_TARGET_OS_IPHONE, + COCOS2D_JAVASCRIPT, + ); + GCC_SYMBOLS_PRIVATE_EXTERN = YES; + HEADER_SEARCH_PATHS = ""; + INFOPLIST_FILE = "$(SRCROOT)/../tests/js-tests/project/proj.ios/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; + OTHER_LDFLAGS = "-ObjC"; + PROVISIONING_PROFILE = ""; + SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../external/spidermonkey/include/ios"; + VALID_ARCHS = "arm64 armv7"; + }; + name = Debug; + }; + A01E17711784C06E00B0CA4A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COMPRESS_PNG_FILES = NO; + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + CC_TARGET_OS_IPHONE, + COCOS2D_JAVASCRIPT, + ); + GCC_SYMBOLS_PRIVATE_EXTERN = YES; + HEADER_SEARCH_PATHS = ""; + INFOPLIST_FILE = "$(SRCROOT)/../tests/js-tests/project/proj.ios/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; + OTHER_LDFLAGS = "-ObjC"; + PROVISIONING_PROFILE = ""; + SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../external/spidermonkey/include/ios"; + VALIDATE_PRODUCT = YES; + VALID_ARCHS = "arm64 armv7"; + }; + name = Release; + }; + A035A5EA1782290400987F6C /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)", + ); + GCC_DYNAMIC_NO_PIC = NO; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + COCOS2D_JAVASCRIPT, + CC_TARGET_OS_MAC, + CC_KEYBOARD_SUPPORT, + ); + GCC_SYMBOLS_PRIVATE_EXTERN = YES; + HEADER_SEARCH_PATHS = ""; + INFOPLIST_FILE = "$(SRCROOT)/../tests/js-tests/project/proj.mac/Test_Info.plist"; + SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external/spidermonkey/include/mac"; + }; + name = Debug; + }; + A035A5EB1782290400987F6C /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)", + ); + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + COCOS2D_JAVASCRIPT, + CC_TARGET_OS_MAC, + CC_KEYBOARD_SUPPORT, + ); + GCC_SYMBOLS_PRIVATE_EXTERN = YES; + HEADER_SEARCH_PATHS = ""; + INFOPLIST_FILE = "$(SRCROOT)/../tests/js-tests/project/proj.mac/Test_Info.plist"; + SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/mac $(SRCROOT)/../external/glfw3/include/mac $(SRCROOT)/../external/spidermonkey/include/mac"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + C01FCF4F08A954540054247B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + COMBINE_HIDPI_IMAGES = YES; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "COCOS2D_DEBUG=1", + USE_FILE32API, + "CC_ENABLE_CHIPMUNK_INTEGRATION=1", + ); + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ""; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/physics $(SRCROOT)/../cocos/math/kazmath $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/gui $(SRCROOT)/../cocos/network $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../extensions $(SRCROOT)/../external $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../cocos/scripting/js-bindings/auto $(SRCROOT)/../cocos/scripting/js-bindings/manual"; + }; + name = Debug; + }; + C01FCF5008A954540054247B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + COMBINE_HIDPI_IMAGES = YES; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_PREPROCESSOR_DEFINITIONS = ( + NDEBUG, + USE_FILE32API, + "CC_ENABLE_CHIPMUNK_INTEGRATION=1", + ); + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ""; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/physics $(SRCROOT)/../cocos/math/kazmath $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/gui $(SRCROOT)/../cocos/network $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../extensions $(SRCROOT)/../external $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../cocos/scripting/js-bindings/auto $(SRCROOT)/../cocos/scripting/js-bindings/manual"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + A01E176F1784C06E00B0CA4A /* Build configuration list for PBXNativeTarget "js-tests iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A01E17701784C06E00B0CA4A /* Debug */, + A01E17711784C06E00B0CA4A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; + A035A5E91782290400987F6C /* Build configuration list for PBXNativeTarget "js-tests Mac" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A035A5EA1782290400987F6C /* Debug */, + A035A5EB1782290400987F6C /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; + C01FCF4E08A954540054247B /* Build configuration list for PBXProject "cocos2d_js_tests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C01FCF4F08A954540054247B /* Debug */, + C01FCF5008A954540054247B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; +/* End XCConfigurationList section */ + }; + rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; +} diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 0eb0e33133..e70a9e08a6 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1373,6 +1373,22 @@ 4D76BE3B1A4AAF0A00102962 /* CCActionTimelineNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D76BE381A4AAF0A00102962 /* CCActionTimelineNode.cpp */; }; 4D76BE3C1A4AAF0A00102962 /* CCActionTimelineNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D76BE391A4AAF0A00102962 /* CCActionTimelineNode.h */; }; 4D76BE3D1A4AAF0A00102962 /* CCActionTimelineNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D76BE391A4AAF0A00102962 /* CCActionTimelineNode.h */; }; + 5012168E1AC47380009A4BEA /* CCRenderState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5012168C1AC47380009A4BEA /* CCRenderState.cpp */; }; + 5012168F1AC47380009A4BEA /* CCRenderState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5012168C1AC47380009A4BEA /* CCRenderState.cpp */; }; + 501216901AC47380009A4BEA /* CCRenderState.h in Headers */ = {isa = PBXBuildFile; fileRef = 5012168D1AC47380009A4BEA /* CCRenderState.h */; }; + 501216911AC47380009A4BEA /* CCRenderState.h in Headers */ = {isa = PBXBuildFile; fileRef = 5012168D1AC47380009A4BEA /* CCRenderState.h */; }; + 501216941AC47393009A4BEA /* CCPass.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 501216921AC47393009A4BEA /* CCPass.cpp */; }; + 501216951AC47393009A4BEA /* CCPass.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 501216921AC47393009A4BEA /* CCPass.cpp */; }; + 501216961AC47393009A4BEA /* CCPass.h in Headers */ = {isa = PBXBuildFile; fileRef = 501216931AC47393009A4BEA /* CCPass.h */; }; + 501216971AC47393009A4BEA /* CCPass.h in Headers */ = {isa = PBXBuildFile; fileRef = 501216931AC47393009A4BEA /* CCPass.h */; }; + 5012169A1AC473A3009A4BEA /* CCTechnique.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 501216981AC473A3009A4BEA /* CCTechnique.cpp */; }; + 5012169B1AC473A3009A4BEA /* CCTechnique.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 501216981AC473A3009A4BEA /* CCTechnique.cpp */; }; + 5012169C1AC473A3009A4BEA /* CCTechnique.h in Headers */ = {isa = PBXBuildFile; fileRef = 501216991AC473A3009A4BEA /* CCTechnique.h */; }; + 5012169D1AC473A3009A4BEA /* CCTechnique.h in Headers */ = {isa = PBXBuildFile; fileRef = 501216991AC473A3009A4BEA /* CCTechnique.h */; }; + 501216A01AC473AD009A4BEA /* CCMaterial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5012169E1AC473AD009A4BEA /* CCMaterial.cpp */; }; + 501216A11AC473AD009A4BEA /* CCMaterial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5012169E1AC473AD009A4BEA /* CCMaterial.cpp */; }; + 501216A21AC473AD009A4BEA /* CCMaterial.h in Headers */ = {isa = PBXBuildFile; fileRef = 5012169F1AC473AD009A4BEA /* CCMaterial.h */; }; + 501216A31AC473AD009A4BEA /* CCMaterial.h in Headers */ = {isa = PBXBuildFile; fileRef = 5012169F1AC473AD009A4BEA /* CCMaterial.h */; }; 5027253A190BF1B900AAF4ED /* cocos2d.h in Headers */ = {isa = PBXBuildFile; fileRef = 50272538190BF1B900AAF4ED /* cocos2d.h */; }; 5027253B190BF1B900AAF4ED /* cocos2d.h in Headers */ = {isa = PBXBuildFile; fileRef = 50272538190BF1B900AAF4ED /* cocos2d.h */; }; 5027253C190BF1B900AAF4ED /* cocos2d.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50272539190BF1B900AAF4ED /* cocos2d.cpp */; }; @@ -2597,6 +2613,832 @@ B68779051A8CA82E00643ABF /* CCParticleSystem3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B68778F61A8CA82E00643ABF /* CCParticleSystem3D.cpp */; }; B68779061A8CA82E00643ABF /* CCParticleSystem3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B68778F71A8CA82E00643ABF /* CCParticleSystem3D.h */; }; B68779071A8CA82E00643ABF /* CCParticleSystem3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B68778F71A8CA82E00643ABF /* CCParticleSystem3D.h */; }; + B6CAAFE21AF9A9E100B9B856 /* CCPhysics3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAAFD21AF9A9E100B9B856 /* CCPhysics3D.cpp */; }; + B6CAAFE31AF9A9E100B9B856 /* CCPhysics3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAAFD21AF9A9E100B9B856 /* CCPhysics3D.cpp */; }; + B6CAAFE41AF9A9E100B9B856 /* CCPhysics3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAAFD31AF9A9E100B9B856 /* CCPhysics3D.h */; }; + B6CAAFE51AF9A9E100B9B856 /* CCPhysics3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAAFD31AF9A9E100B9B856 /* CCPhysics3D.h */; }; + B6CAAFE61AF9A9E100B9B856 /* CCPhysics3DComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAAFD41AF9A9E100B9B856 /* CCPhysics3DComponent.cpp */; }; + B6CAAFE71AF9A9E100B9B856 /* CCPhysics3DComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAAFD41AF9A9E100B9B856 /* CCPhysics3DComponent.cpp */; }; + B6CAAFE81AF9A9E100B9B856 /* CCPhysics3DComponent.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAAFD51AF9A9E100B9B856 /* CCPhysics3DComponent.h */; }; + B6CAAFE91AF9A9E100B9B856 /* CCPhysics3DComponent.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAAFD51AF9A9E100B9B856 /* CCPhysics3DComponent.h */; }; + B6CAAFEA1AF9A9E100B9B856 /* CCPhysics3DConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAAFD61AF9A9E100B9B856 /* CCPhysics3DConstraint.cpp */; }; + B6CAAFEB1AF9A9E100B9B856 /* CCPhysics3DConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAAFD61AF9A9E100B9B856 /* CCPhysics3DConstraint.cpp */; }; + B6CAAFEC1AF9A9E100B9B856 /* CCPhysics3DConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAAFD71AF9A9E100B9B856 /* CCPhysics3DConstraint.h */; }; + B6CAAFED1AF9A9E100B9B856 /* CCPhysics3DConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAAFD71AF9A9E100B9B856 /* CCPhysics3DConstraint.h */; }; + B6CAAFEE1AF9A9E100B9B856 /* CCPhysics3DDebugDrawer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAAFD81AF9A9E100B9B856 /* CCPhysics3DDebugDrawer.cpp */; }; + B6CAAFEF1AF9A9E100B9B856 /* CCPhysics3DDebugDrawer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAAFD81AF9A9E100B9B856 /* CCPhysics3DDebugDrawer.cpp */; }; + B6CAAFF01AF9A9E100B9B856 /* CCPhysics3DDebugDrawer.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAAFD91AF9A9E100B9B856 /* CCPhysics3DDebugDrawer.h */; }; + B6CAAFF11AF9A9E100B9B856 /* CCPhysics3DDebugDrawer.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAAFD91AF9A9E100B9B856 /* CCPhysics3DDebugDrawer.h */; }; + B6CAAFF21AF9A9E100B9B856 /* CCPhysics3DObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAAFDA1AF9A9E100B9B856 /* CCPhysics3DObject.cpp */; }; + B6CAAFF31AF9A9E100B9B856 /* CCPhysics3DObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAAFDA1AF9A9E100B9B856 /* CCPhysics3DObject.cpp */; }; + B6CAAFF41AF9A9E100B9B856 /* CCPhysics3DObject.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAAFDB1AF9A9E100B9B856 /* CCPhysics3DObject.h */; }; + B6CAAFF51AF9A9E100B9B856 /* CCPhysics3DObject.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAAFDB1AF9A9E100B9B856 /* CCPhysics3DObject.h */; }; + B6CAAFF61AF9A9E100B9B856 /* CCPhysics3DShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAAFDC1AF9A9E100B9B856 /* CCPhysics3DShape.cpp */; }; + B6CAAFF71AF9A9E100B9B856 /* CCPhysics3DShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAAFDC1AF9A9E100B9B856 /* CCPhysics3DShape.cpp */; }; + B6CAAFF81AF9A9E100B9B856 /* CCPhysics3DShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAAFDD1AF9A9E100B9B856 /* CCPhysics3DShape.h */; }; + B6CAAFF91AF9A9E100B9B856 /* CCPhysics3DShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAAFDD1AF9A9E100B9B856 /* CCPhysics3DShape.h */; }; + B6CAAFFA1AF9A9E100B9B856 /* CCPhysics3DWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAAFDE1AF9A9E100B9B856 /* CCPhysics3DWorld.cpp */; }; + B6CAAFFB1AF9A9E100B9B856 /* CCPhysics3DWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAAFDE1AF9A9E100B9B856 /* CCPhysics3DWorld.cpp */; }; + B6CAAFFC1AF9A9E100B9B856 /* CCPhysics3DWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAAFDF1AF9A9E100B9B856 /* CCPhysics3DWorld.h */; }; + B6CAAFFD1AF9A9E100B9B856 /* CCPhysics3DWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAAFDF1AF9A9E100B9B856 /* CCPhysics3DWorld.h */; }; + B6CAAFFE1AF9A9E100B9B856 /* CCPhysicsSprite3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAAFE01AF9A9E100B9B856 /* CCPhysicsSprite3D.cpp */; }; + B6CAAFFF1AF9A9E100B9B856 /* CCPhysicsSprite3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAAFE01AF9A9E100B9B856 /* CCPhysicsSprite3D.cpp */; }; + B6CAB0001AF9A9E100B9B856 /* CCPhysicsSprite3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAAFE11AF9A9E100B9B856 /* CCPhysicsSprite3D.h */; }; + B6CAB0011AF9A9E100B9B856 /* CCPhysicsSprite3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAAFE11AF9A9E100B9B856 /* CCPhysicsSprite3D.h */; }; + B6CAB1E11AF9AA1A00B9B856 /* btBulletCollisionCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0031AF9AA1900B9B856 /* btBulletCollisionCommon.h */; }; + B6CAB1E21AF9AA1A00B9B856 /* btBulletCollisionCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0031AF9AA1900B9B856 /* btBulletCollisionCommon.h */; }; + B6CAB1E31AF9AA1A00B9B856 /* btBulletDynamicsCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0041AF9AA1900B9B856 /* btBulletDynamicsCommon.h */; }; + B6CAB1E41AF9AA1A00B9B856 /* btBulletDynamicsCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0041AF9AA1900B9B856 /* btBulletDynamicsCommon.h */; }; + B6CAB1E51AF9AA1A00B9B856 /* Bullet-C-Api.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0051AF9AA1900B9B856 /* Bullet-C-Api.h */; }; + B6CAB1E61AF9AA1A00B9B856 /* Bullet-C-Api.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0051AF9AA1900B9B856 /* Bullet-C-Api.h */; }; + B6CAB1E71AF9AA1A00B9B856 /* btAxisSweep3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0081AF9AA1900B9B856 /* btAxisSweep3.cpp */; }; + B6CAB1E81AF9AA1A00B9B856 /* btAxisSweep3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0081AF9AA1900B9B856 /* btAxisSweep3.cpp */; }; + B6CAB1E91AF9AA1A00B9B856 /* btAxisSweep3.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0091AF9AA1900B9B856 /* btAxisSweep3.h */; }; + B6CAB1EA1AF9AA1A00B9B856 /* btAxisSweep3.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0091AF9AA1900B9B856 /* btAxisSweep3.h */; }; + B6CAB1EB1AF9AA1A00B9B856 /* btBroadphaseInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB00A1AF9AA1900B9B856 /* btBroadphaseInterface.h */; }; + B6CAB1EC1AF9AA1A00B9B856 /* btBroadphaseInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB00A1AF9AA1900B9B856 /* btBroadphaseInterface.h */; }; + B6CAB1ED1AF9AA1A00B9B856 /* btBroadphaseProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB00B1AF9AA1900B9B856 /* btBroadphaseProxy.cpp */; }; + B6CAB1EE1AF9AA1A00B9B856 /* btBroadphaseProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB00B1AF9AA1900B9B856 /* btBroadphaseProxy.cpp */; }; + B6CAB1EF1AF9AA1A00B9B856 /* btBroadphaseProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB00C1AF9AA1900B9B856 /* btBroadphaseProxy.h */; }; + B6CAB1F01AF9AA1A00B9B856 /* btBroadphaseProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB00C1AF9AA1900B9B856 /* btBroadphaseProxy.h */; }; + B6CAB1F11AF9AA1A00B9B856 /* btCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB00D1AF9AA1900B9B856 /* btCollisionAlgorithm.cpp */; }; + B6CAB1F21AF9AA1A00B9B856 /* btCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB00D1AF9AA1900B9B856 /* btCollisionAlgorithm.cpp */; }; + B6CAB1F31AF9AA1A00B9B856 /* btCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB00E1AF9AA1900B9B856 /* btCollisionAlgorithm.h */; }; + B6CAB1F41AF9AA1A00B9B856 /* btCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB00E1AF9AA1900B9B856 /* btCollisionAlgorithm.h */; }; + B6CAB1F51AF9AA1A00B9B856 /* btDbvt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB00F1AF9AA1900B9B856 /* btDbvt.cpp */; }; + B6CAB1F61AF9AA1A00B9B856 /* btDbvt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB00F1AF9AA1900B9B856 /* btDbvt.cpp */; }; + B6CAB1F71AF9AA1A00B9B856 /* btDbvt.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0101AF9AA1900B9B856 /* btDbvt.h */; }; + B6CAB1F81AF9AA1A00B9B856 /* btDbvt.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0101AF9AA1900B9B856 /* btDbvt.h */; }; + B6CAB1F91AF9AA1A00B9B856 /* btDbvtBroadphase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0111AF9AA1900B9B856 /* btDbvtBroadphase.cpp */; }; + B6CAB1FA1AF9AA1A00B9B856 /* btDbvtBroadphase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0111AF9AA1900B9B856 /* btDbvtBroadphase.cpp */; }; + B6CAB1FB1AF9AA1A00B9B856 /* btDbvtBroadphase.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0121AF9AA1900B9B856 /* btDbvtBroadphase.h */; }; + B6CAB1FC1AF9AA1A00B9B856 /* btDbvtBroadphase.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0121AF9AA1900B9B856 /* btDbvtBroadphase.h */; }; + B6CAB1FD1AF9AA1A00B9B856 /* btDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0131AF9AA1900B9B856 /* btDispatcher.cpp */; }; + B6CAB1FE1AF9AA1A00B9B856 /* btDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0131AF9AA1900B9B856 /* btDispatcher.cpp */; }; + B6CAB1FF1AF9AA1A00B9B856 /* btDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0141AF9AA1900B9B856 /* btDispatcher.h */; }; + B6CAB2001AF9AA1A00B9B856 /* btDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0141AF9AA1900B9B856 /* btDispatcher.h */; }; + B6CAB2011AF9AA1A00B9B856 /* btMultiSapBroadphase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0151AF9AA1900B9B856 /* btMultiSapBroadphase.cpp */; }; + B6CAB2021AF9AA1A00B9B856 /* btMultiSapBroadphase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0151AF9AA1900B9B856 /* btMultiSapBroadphase.cpp */; }; + B6CAB2031AF9AA1A00B9B856 /* btMultiSapBroadphase.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0161AF9AA1900B9B856 /* btMultiSapBroadphase.h */; }; + B6CAB2041AF9AA1A00B9B856 /* btMultiSapBroadphase.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0161AF9AA1900B9B856 /* btMultiSapBroadphase.h */; }; + B6CAB2051AF9AA1A00B9B856 /* btOverlappingPairCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0171AF9AA1900B9B856 /* btOverlappingPairCache.cpp */; }; + B6CAB2061AF9AA1A00B9B856 /* btOverlappingPairCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0171AF9AA1900B9B856 /* btOverlappingPairCache.cpp */; }; + B6CAB2071AF9AA1A00B9B856 /* btOverlappingPairCache.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0181AF9AA1900B9B856 /* btOverlappingPairCache.h */; }; + B6CAB2081AF9AA1A00B9B856 /* btOverlappingPairCache.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0181AF9AA1900B9B856 /* btOverlappingPairCache.h */; }; + B6CAB2091AF9AA1A00B9B856 /* btOverlappingPairCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0191AF9AA1900B9B856 /* btOverlappingPairCallback.h */; }; + B6CAB20A1AF9AA1A00B9B856 /* btOverlappingPairCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0191AF9AA1900B9B856 /* btOverlappingPairCallback.h */; }; + B6CAB20B1AF9AA1A00B9B856 /* btQuantizedBvh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB01A1AF9AA1900B9B856 /* btQuantizedBvh.cpp */; }; + B6CAB20C1AF9AA1A00B9B856 /* btQuantizedBvh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB01A1AF9AA1900B9B856 /* btQuantizedBvh.cpp */; }; + B6CAB20D1AF9AA1A00B9B856 /* btQuantizedBvh.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB01B1AF9AA1900B9B856 /* btQuantizedBvh.h */; }; + B6CAB20E1AF9AA1A00B9B856 /* btQuantizedBvh.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB01B1AF9AA1900B9B856 /* btQuantizedBvh.h */; }; + B6CAB20F1AF9AA1A00B9B856 /* btSimpleBroadphase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB01C1AF9AA1900B9B856 /* btSimpleBroadphase.cpp */; }; + B6CAB2101AF9AA1A00B9B856 /* btSimpleBroadphase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB01C1AF9AA1900B9B856 /* btSimpleBroadphase.cpp */; }; + B6CAB2111AF9AA1A00B9B856 /* btSimpleBroadphase.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB01D1AF9AA1900B9B856 /* btSimpleBroadphase.h */; }; + B6CAB2121AF9AA1A00B9B856 /* btSimpleBroadphase.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB01D1AF9AA1900B9B856 /* btSimpleBroadphase.h */; }; + B6CAB2131AF9AA1A00B9B856 /* btActivatingCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB01F1AF9AA1900B9B856 /* btActivatingCollisionAlgorithm.cpp */; }; + B6CAB2141AF9AA1A00B9B856 /* btActivatingCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB01F1AF9AA1900B9B856 /* btActivatingCollisionAlgorithm.cpp */; }; + B6CAB2151AF9AA1A00B9B856 /* btActivatingCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0201AF9AA1900B9B856 /* btActivatingCollisionAlgorithm.h */; }; + B6CAB2161AF9AA1A00B9B856 /* btActivatingCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0201AF9AA1900B9B856 /* btActivatingCollisionAlgorithm.h */; }; + B6CAB2171AF9AA1A00B9B856 /* btBox2dBox2dCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0211AF9AA1900B9B856 /* btBox2dBox2dCollisionAlgorithm.cpp */; }; + B6CAB2181AF9AA1A00B9B856 /* btBox2dBox2dCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0211AF9AA1900B9B856 /* btBox2dBox2dCollisionAlgorithm.cpp */; }; + B6CAB2191AF9AA1A00B9B856 /* btBox2dBox2dCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0221AF9AA1900B9B856 /* btBox2dBox2dCollisionAlgorithm.h */; }; + B6CAB21A1AF9AA1A00B9B856 /* btBox2dBox2dCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0221AF9AA1900B9B856 /* btBox2dBox2dCollisionAlgorithm.h */; }; + B6CAB21B1AF9AA1A00B9B856 /* btBoxBoxCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0231AF9AA1900B9B856 /* btBoxBoxCollisionAlgorithm.cpp */; }; + B6CAB21C1AF9AA1A00B9B856 /* btBoxBoxCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0231AF9AA1900B9B856 /* btBoxBoxCollisionAlgorithm.cpp */; }; + B6CAB21D1AF9AA1A00B9B856 /* btBoxBoxCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0241AF9AA1900B9B856 /* btBoxBoxCollisionAlgorithm.h */; }; + B6CAB21E1AF9AA1A00B9B856 /* btBoxBoxCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0241AF9AA1900B9B856 /* btBoxBoxCollisionAlgorithm.h */; }; + B6CAB21F1AF9AA1A00B9B856 /* btBoxBoxDetector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0251AF9AA1900B9B856 /* btBoxBoxDetector.cpp */; }; + B6CAB2201AF9AA1A00B9B856 /* btBoxBoxDetector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0251AF9AA1900B9B856 /* btBoxBoxDetector.cpp */; }; + B6CAB2211AF9AA1A00B9B856 /* btBoxBoxDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0261AF9AA1900B9B856 /* btBoxBoxDetector.h */; }; + B6CAB2221AF9AA1A00B9B856 /* btBoxBoxDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0261AF9AA1900B9B856 /* btBoxBoxDetector.h */; }; + B6CAB2231AF9AA1A00B9B856 /* btCollisionConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0271AF9AA1900B9B856 /* btCollisionConfiguration.h */; }; + B6CAB2241AF9AA1A00B9B856 /* btCollisionConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0271AF9AA1900B9B856 /* btCollisionConfiguration.h */; }; + B6CAB2251AF9AA1A00B9B856 /* btCollisionCreateFunc.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0281AF9AA1900B9B856 /* btCollisionCreateFunc.h */; }; + B6CAB2261AF9AA1A00B9B856 /* btCollisionCreateFunc.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0281AF9AA1900B9B856 /* btCollisionCreateFunc.h */; }; + B6CAB2271AF9AA1A00B9B856 /* btCollisionDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0291AF9AA1900B9B856 /* btCollisionDispatcher.cpp */; }; + B6CAB2281AF9AA1A00B9B856 /* btCollisionDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0291AF9AA1900B9B856 /* btCollisionDispatcher.cpp */; }; + B6CAB2291AF9AA1A00B9B856 /* btCollisionDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB02A1AF9AA1900B9B856 /* btCollisionDispatcher.h */; }; + B6CAB22A1AF9AA1A00B9B856 /* btCollisionDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB02A1AF9AA1900B9B856 /* btCollisionDispatcher.h */; }; + B6CAB22B1AF9AA1A00B9B856 /* btCollisionObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB02B1AF9AA1900B9B856 /* btCollisionObject.cpp */; }; + B6CAB22C1AF9AA1A00B9B856 /* btCollisionObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB02B1AF9AA1900B9B856 /* btCollisionObject.cpp */; }; + B6CAB22D1AF9AA1A00B9B856 /* btCollisionObject.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB02C1AF9AA1900B9B856 /* btCollisionObject.h */; }; + B6CAB22E1AF9AA1A00B9B856 /* btCollisionObject.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB02C1AF9AA1900B9B856 /* btCollisionObject.h */; }; + B6CAB22F1AF9AA1A00B9B856 /* btCollisionObjectWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB02D1AF9AA1900B9B856 /* btCollisionObjectWrapper.h */; }; + B6CAB2301AF9AA1A00B9B856 /* btCollisionObjectWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB02D1AF9AA1900B9B856 /* btCollisionObjectWrapper.h */; }; + B6CAB2311AF9AA1A00B9B856 /* btCollisionWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB02E1AF9AA1900B9B856 /* btCollisionWorld.cpp */; }; + B6CAB2321AF9AA1A00B9B856 /* btCollisionWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB02E1AF9AA1900B9B856 /* btCollisionWorld.cpp */; }; + B6CAB2331AF9AA1A00B9B856 /* btCollisionWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB02F1AF9AA1900B9B856 /* btCollisionWorld.h */; }; + B6CAB2341AF9AA1A00B9B856 /* btCollisionWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB02F1AF9AA1900B9B856 /* btCollisionWorld.h */; }; + B6CAB2351AF9AA1A00B9B856 /* btCompoundCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0301AF9AA1900B9B856 /* btCompoundCollisionAlgorithm.cpp */; }; + B6CAB2361AF9AA1A00B9B856 /* btCompoundCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0301AF9AA1900B9B856 /* btCompoundCollisionAlgorithm.cpp */; }; + B6CAB2371AF9AA1A00B9B856 /* btCompoundCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0311AF9AA1900B9B856 /* btCompoundCollisionAlgorithm.h */; }; + B6CAB2381AF9AA1A00B9B856 /* btCompoundCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0311AF9AA1900B9B856 /* btCompoundCollisionAlgorithm.h */; }; + B6CAB2391AF9AA1A00B9B856 /* btCompoundCompoundCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0321AF9AA1900B9B856 /* btCompoundCompoundCollisionAlgorithm.cpp */; }; + B6CAB23A1AF9AA1A00B9B856 /* btCompoundCompoundCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0321AF9AA1900B9B856 /* btCompoundCompoundCollisionAlgorithm.cpp */; }; + B6CAB23B1AF9AA1A00B9B856 /* btCompoundCompoundCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0331AF9AA1900B9B856 /* btCompoundCompoundCollisionAlgorithm.h */; }; + B6CAB23C1AF9AA1A00B9B856 /* btCompoundCompoundCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0331AF9AA1900B9B856 /* btCompoundCompoundCollisionAlgorithm.h */; }; + B6CAB23D1AF9AA1A00B9B856 /* btConvex2dConvex2dAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0341AF9AA1900B9B856 /* btConvex2dConvex2dAlgorithm.cpp */; }; + B6CAB23E1AF9AA1A00B9B856 /* btConvex2dConvex2dAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0341AF9AA1900B9B856 /* btConvex2dConvex2dAlgorithm.cpp */; }; + B6CAB23F1AF9AA1A00B9B856 /* btConvex2dConvex2dAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0351AF9AA1900B9B856 /* btConvex2dConvex2dAlgorithm.h */; }; + B6CAB2401AF9AA1A00B9B856 /* btConvex2dConvex2dAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0351AF9AA1900B9B856 /* btConvex2dConvex2dAlgorithm.h */; }; + B6CAB2411AF9AA1A00B9B856 /* btConvexConcaveCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0361AF9AA1900B9B856 /* btConvexConcaveCollisionAlgorithm.cpp */; }; + B6CAB2421AF9AA1A00B9B856 /* btConvexConcaveCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0361AF9AA1900B9B856 /* btConvexConcaveCollisionAlgorithm.cpp */; }; + B6CAB2431AF9AA1A00B9B856 /* btConvexConcaveCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0371AF9AA1900B9B856 /* btConvexConcaveCollisionAlgorithm.h */; }; + B6CAB2441AF9AA1A00B9B856 /* btConvexConcaveCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0371AF9AA1900B9B856 /* btConvexConcaveCollisionAlgorithm.h */; }; + B6CAB2451AF9AA1A00B9B856 /* btConvexConvexAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0381AF9AA1900B9B856 /* btConvexConvexAlgorithm.cpp */; }; + B6CAB2461AF9AA1A00B9B856 /* btConvexConvexAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0381AF9AA1900B9B856 /* btConvexConvexAlgorithm.cpp */; }; + B6CAB2471AF9AA1A00B9B856 /* btConvexConvexAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0391AF9AA1900B9B856 /* btConvexConvexAlgorithm.h */; }; + B6CAB2481AF9AA1A00B9B856 /* btConvexConvexAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0391AF9AA1900B9B856 /* btConvexConvexAlgorithm.h */; }; + B6CAB2491AF9AA1A00B9B856 /* btConvexPlaneCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB03A1AF9AA1900B9B856 /* btConvexPlaneCollisionAlgorithm.cpp */; }; + B6CAB24A1AF9AA1A00B9B856 /* btConvexPlaneCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB03A1AF9AA1900B9B856 /* btConvexPlaneCollisionAlgorithm.cpp */; }; + B6CAB24B1AF9AA1A00B9B856 /* btConvexPlaneCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB03B1AF9AA1900B9B856 /* btConvexPlaneCollisionAlgorithm.h */; }; + B6CAB24C1AF9AA1A00B9B856 /* btConvexPlaneCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB03B1AF9AA1900B9B856 /* btConvexPlaneCollisionAlgorithm.h */; }; + B6CAB24D1AF9AA1A00B9B856 /* btDefaultCollisionConfiguration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB03C1AF9AA1900B9B856 /* btDefaultCollisionConfiguration.cpp */; }; + B6CAB24E1AF9AA1A00B9B856 /* btDefaultCollisionConfiguration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB03C1AF9AA1900B9B856 /* btDefaultCollisionConfiguration.cpp */; }; + B6CAB24F1AF9AA1A00B9B856 /* btDefaultCollisionConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB03D1AF9AA1900B9B856 /* btDefaultCollisionConfiguration.h */; }; + B6CAB2501AF9AA1A00B9B856 /* btDefaultCollisionConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB03D1AF9AA1900B9B856 /* btDefaultCollisionConfiguration.h */; }; + B6CAB2511AF9AA1A00B9B856 /* btEmptyCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB03E1AF9AA1900B9B856 /* btEmptyCollisionAlgorithm.cpp */; }; + B6CAB2521AF9AA1A00B9B856 /* btEmptyCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB03E1AF9AA1900B9B856 /* btEmptyCollisionAlgorithm.cpp */; }; + B6CAB2531AF9AA1A00B9B856 /* btEmptyCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB03F1AF9AA1900B9B856 /* btEmptyCollisionAlgorithm.h */; }; + B6CAB2541AF9AA1A00B9B856 /* btEmptyCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB03F1AF9AA1900B9B856 /* btEmptyCollisionAlgorithm.h */; }; + B6CAB2551AF9AA1A00B9B856 /* btGhostObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0401AF9AA1900B9B856 /* btGhostObject.cpp */; }; + B6CAB2561AF9AA1A00B9B856 /* btGhostObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0401AF9AA1900B9B856 /* btGhostObject.cpp */; }; + B6CAB2571AF9AA1A00B9B856 /* btGhostObject.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0411AF9AA1900B9B856 /* btGhostObject.h */; }; + B6CAB2581AF9AA1A00B9B856 /* btGhostObject.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0411AF9AA1900B9B856 /* btGhostObject.h */; }; + B6CAB2591AF9AA1A00B9B856 /* btHashedSimplePairCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0421AF9AA1900B9B856 /* btHashedSimplePairCache.cpp */; }; + B6CAB25A1AF9AA1A00B9B856 /* btHashedSimplePairCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0421AF9AA1900B9B856 /* btHashedSimplePairCache.cpp */; }; + B6CAB25B1AF9AA1A00B9B856 /* btHashedSimplePairCache.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0431AF9AA1900B9B856 /* btHashedSimplePairCache.h */; }; + B6CAB25C1AF9AA1A00B9B856 /* btHashedSimplePairCache.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0431AF9AA1900B9B856 /* btHashedSimplePairCache.h */; }; + B6CAB25D1AF9AA1A00B9B856 /* btInternalEdgeUtility.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0441AF9AA1900B9B856 /* btInternalEdgeUtility.cpp */; }; + B6CAB25E1AF9AA1A00B9B856 /* btInternalEdgeUtility.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0441AF9AA1900B9B856 /* btInternalEdgeUtility.cpp */; }; + B6CAB25F1AF9AA1A00B9B856 /* btInternalEdgeUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0451AF9AA1900B9B856 /* btInternalEdgeUtility.h */; }; + B6CAB2601AF9AA1A00B9B856 /* btInternalEdgeUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0451AF9AA1900B9B856 /* btInternalEdgeUtility.h */; }; + B6CAB2611AF9AA1A00B9B856 /* btManifoldResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0461AF9AA1900B9B856 /* btManifoldResult.cpp */; }; + B6CAB2621AF9AA1A00B9B856 /* btManifoldResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0461AF9AA1900B9B856 /* btManifoldResult.cpp */; }; + B6CAB2631AF9AA1A00B9B856 /* btManifoldResult.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0471AF9AA1900B9B856 /* btManifoldResult.h */; }; + B6CAB2641AF9AA1A00B9B856 /* btManifoldResult.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0471AF9AA1900B9B856 /* btManifoldResult.h */; }; + B6CAB2651AF9AA1A00B9B856 /* btSimulationIslandManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0481AF9AA1900B9B856 /* btSimulationIslandManager.cpp */; }; + B6CAB2661AF9AA1A00B9B856 /* btSimulationIslandManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0481AF9AA1900B9B856 /* btSimulationIslandManager.cpp */; }; + B6CAB2671AF9AA1A00B9B856 /* btSimulationIslandManager.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0491AF9AA1900B9B856 /* btSimulationIslandManager.h */; }; + B6CAB2681AF9AA1A00B9B856 /* btSimulationIslandManager.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0491AF9AA1900B9B856 /* btSimulationIslandManager.h */; }; + B6CAB2691AF9AA1A00B9B856 /* btSphereBoxCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB04A1AF9AA1900B9B856 /* btSphereBoxCollisionAlgorithm.cpp */; }; + B6CAB26A1AF9AA1A00B9B856 /* btSphereBoxCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB04A1AF9AA1900B9B856 /* btSphereBoxCollisionAlgorithm.cpp */; }; + B6CAB26B1AF9AA1A00B9B856 /* btSphereBoxCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB04B1AF9AA1900B9B856 /* btSphereBoxCollisionAlgorithm.h */; }; + B6CAB26C1AF9AA1A00B9B856 /* btSphereBoxCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB04B1AF9AA1900B9B856 /* btSphereBoxCollisionAlgorithm.h */; }; + B6CAB26D1AF9AA1A00B9B856 /* btSphereSphereCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB04C1AF9AA1900B9B856 /* btSphereSphereCollisionAlgorithm.cpp */; }; + B6CAB26E1AF9AA1A00B9B856 /* btSphereSphereCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB04C1AF9AA1900B9B856 /* btSphereSphereCollisionAlgorithm.cpp */; }; + B6CAB26F1AF9AA1A00B9B856 /* btSphereSphereCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB04D1AF9AA1900B9B856 /* btSphereSphereCollisionAlgorithm.h */; }; + B6CAB2701AF9AA1A00B9B856 /* btSphereSphereCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB04D1AF9AA1900B9B856 /* btSphereSphereCollisionAlgorithm.h */; }; + B6CAB2711AF9AA1A00B9B856 /* btSphereTriangleCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB04E1AF9AA1900B9B856 /* btSphereTriangleCollisionAlgorithm.cpp */; }; + B6CAB2721AF9AA1A00B9B856 /* btSphereTriangleCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB04E1AF9AA1900B9B856 /* btSphereTriangleCollisionAlgorithm.cpp */; }; + B6CAB2731AF9AA1A00B9B856 /* btSphereTriangleCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB04F1AF9AA1900B9B856 /* btSphereTriangleCollisionAlgorithm.h */; }; + B6CAB2741AF9AA1A00B9B856 /* btSphereTriangleCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB04F1AF9AA1900B9B856 /* btSphereTriangleCollisionAlgorithm.h */; }; + B6CAB2751AF9AA1A00B9B856 /* btUnionFind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0501AF9AA1900B9B856 /* btUnionFind.cpp */; }; + B6CAB2761AF9AA1A00B9B856 /* btUnionFind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0501AF9AA1900B9B856 /* btUnionFind.cpp */; }; + B6CAB2771AF9AA1A00B9B856 /* btUnionFind.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0511AF9AA1900B9B856 /* btUnionFind.h */; }; + B6CAB2781AF9AA1A00B9B856 /* btUnionFind.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0511AF9AA1900B9B856 /* btUnionFind.h */; }; + B6CAB2791AF9AA1A00B9B856 /* SphereTriangleDetector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0521AF9AA1900B9B856 /* SphereTriangleDetector.cpp */; }; + B6CAB27A1AF9AA1A00B9B856 /* SphereTriangleDetector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0521AF9AA1900B9B856 /* SphereTriangleDetector.cpp */; }; + B6CAB27B1AF9AA1A00B9B856 /* SphereTriangleDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0531AF9AA1900B9B856 /* SphereTriangleDetector.h */; }; + B6CAB27C1AF9AA1A00B9B856 /* SphereTriangleDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0531AF9AA1900B9B856 /* SphereTriangleDetector.h */; }; + B6CAB27D1AF9AA1A00B9B856 /* btBox2dShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0551AF9AA1900B9B856 /* btBox2dShape.cpp */; }; + B6CAB27E1AF9AA1A00B9B856 /* btBox2dShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0551AF9AA1900B9B856 /* btBox2dShape.cpp */; }; + B6CAB27F1AF9AA1A00B9B856 /* btBox2dShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0561AF9AA1900B9B856 /* btBox2dShape.h */; }; + B6CAB2801AF9AA1A00B9B856 /* btBox2dShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0561AF9AA1900B9B856 /* btBox2dShape.h */; }; + B6CAB2811AF9AA1A00B9B856 /* btBoxShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0571AF9AA1900B9B856 /* btBoxShape.cpp */; }; + B6CAB2821AF9AA1A00B9B856 /* btBoxShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0571AF9AA1900B9B856 /* btBoxShape.cpp */; }; + B6CAB2831AF9AA1A00B9B856 /* btBoxShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0581AF9AA1900B9B856 /* btBoxShape.h */; }; + B6CAB2841AF9AA1A00B9B856 /* btBoxShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0581AF9AA1900B9B856 /* btBoxShape.h */; }; + B6CAB2851AF9AA1A00B9B856 /* btBvhTriangleMeshShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0591AF9AA1900B9B856 /* btBvhTriangleMeshShape.cpp */; }; + B6CAB2861AF9AA1A00B9B856 /* btBvhTriangleMeshShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0591AF9AA1900B9B856 /* btBvhTriangleMeshShape.cpp */; }; + B6CAB2871AF9AA1A00B9B856 /* btBvhTriangleMeshShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB05A1AF9AA1900B9B856 /* btBvhTriangleMeshShape.h */; }; + B6CAB2881AF9AA1A00B9B856 /* btBvhTriangleMeshShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB05A1AF9AA1900B9B856 /* btBvhTriangleMeshShape.h */; }; + B6CAB2891AF9AA1A00B9B856 /* btCapsuleShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB05B1AF9AA1900B9B856 /* btCapsuleShape.cpp */; }; + B6CAB28A1AF9AA1A00B9B856 /* btCapsuleShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB05B1AF9AA1900B9B856 /* btCapsuleShape.cpp */; }; + B6CAB28B1AF9AA1A00B9B856 /* btCapsuleShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB05C1AF9AA1900B9B856 /* btCapsuleShape.h */; }; + B6CAB28C1AF9AA1A00B9B856 /* btCapsuleShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB05C1AF9AA1900B9B856 /* btCapsuleShape.h */; }; + B6CAB28D1AF9AA1A00B9B856 /* btCollisionMargin.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB05D1AF9AA1900B9B856 /* btCollisionMargin.h */; }; + B6CAB28E1AF9AA1A00B9B856 /* btCollisionMargin.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB05D1AF9AA1900B9B856 /* btCollisionMargin.h */; }; + B6CAB28F1AF9AA1A00B9B856 /* btCollisionShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB05E1AF9AA1900B9B856 /* btCollisionShape.cpp */; }; + B6CAB2901AF9AA1A00B9B856 /* btCollisionShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB05E1AF9AA1900B9B856 /* btCollisionShape.cpp */; }; + B6CAB2911AF9AA1A00B9B856 /* btCollisionShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB05F1AF9AA1900B9B856 /* btCollisionShape.h */; }; + B6CAB2921AF9AA1A00B9B856 /* btCollisionShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB05F1AF9AA1900B9B856 /* btCollisionShape.h */; }; + B6CAB2931AF9AA1A00B9B856 /* btCompoundShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0601AF9AA1900B9B856 /* btCompoundShape.cpp */; }; + B6CAB2941AF9AA1A00B9B856 /* btCompoundShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0601AF9AA1900B9B856 /* btCompoundShape.cpp */; }; + B6CAB2951AF9AA1A00B9B856 /* btCompoundShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0611AF9AA1900B9B856 /* btCompoundShape.h */; }; + B6CAB2961AF9AA1A00B9B856 /* btCompoundShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0611AF9AA1900B9B856 /* btCompoundShape.h */; }; + B6CAB2971AF9AA1A00B9B856 /* btConcaveShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0621AF9AA1900B9B856 /* btConcaveShape.cpp */; }; + B6CAB2981AF9AA1A00B9B856 /* btConcaveShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0621AF9AA1900B9B856 /* btConcaveShape.cpp */; }; + B6CAB2991AF9AA1A00B9B856 /* btConcaveShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0631AF9AA1900B9B856 /* btConcaveShape.h */; }; + B6CAB29A1AF9AA1A00B9B856 /* btConcaveShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0631AF9AA1900B9B856 /* btConcaveShape.h */; }; + B6CAB29B1AF9AA1A00B9B856 /* btConeShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0641AF9AA1900B9B856 /* btConeShape.cpp */; }; + B6CAB29C1AF9AA1A00B9B856 /* btConeShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0641AF9AA1900B9B856 /* btConeShape.cpp */; }; + B6CAB29D1AF9AA1A00B9B856 /* btConeShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0651AF9AA1900B9B856 /* btConeShape.h */; }; + B6CAB29E1AF9AA1A00B9B856 /* btConeShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0651AF9AA1900B9B856 /* btConeShape.h */; }; + B6CAB29F1AF9AA1A00B9B856 /* btConvex2dShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0661AF9AA1900B9B856 /* btConvex2dShape.cpp */; }; + B6CAB2A01AF9AA1A00B9B856 /* btConvex2dShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0661AF9AA1900B9B856 /* btConvex2dShape.cpp */; }; + B6CAB2A11AF9AA1A00B9B856 /* btConvex2dShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0671AF9AA1900B9B856 /* btConvex2dShape.h */; }; + B6CAB2A21AF9AA1A00B9B856 /* btConvex2dShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0671AF9AA1900B9B856 /* btConvex2dShape.h */; }; + B6CAB2A31AF9AA1A00B9B856 /* btConvexHullShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0681AF9AA1900B9B856 /* btConvexHullShape.cpp */; }; + B6CAB2A41AF9AA1A00B9B856 /* btConvexHullShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0681AF9AA1900B9B856 /* btConvexHullShape.cpp */; }; + B6CAB2A51AF9AA1A00B9B856 /* btConvexHullShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0691AF9AA1900B9B856 /* btConvexHullShape.h */; }; + B6CAB2A61AF9AA1A00B9B856 /* btConvexHullShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0691AF9AA1900B9B856 /* btConvexHullShape.h */; }; + B6CAB2A71AF9AA1A00B9B856 /* btConvexInternalShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB06A1AF9AA1900B9B856 /* btConvexInternalShape.cpp */; }; + B6CAB2A81AF9AA1A00B9B856 /* btConvexInternalShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB06A1AF9AA1900B9B856 /* btConvexInternalShape.cpp */; }; + B6CAB2A91AF9AA1A00B9B856 /* btConvexInternalShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB06B1AF9AA1900B9B856 /* btConvexInternalShape.h */; }; + B6CAB2AA1AF9AA1A00B9B856 /* btConvexInternalShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB06B1AF9AA1900B9B856 /* btConvexInternalShape.h */; }; + B6CAB2AB1AF9AA1A00B9B856 /* btConvexPointCloudShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB06C1AF9AA1900B9B856 /* btConvexPointCloudShape.cpp */; }; + B6CAB2AC1AF9AA1A00B9B856 /* btConvexPointCloudShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB06C1AF9AA1900B9B856 /* btConvexPointCloudShape.cpp */; }; + B6CAB2AD1AF9AA1A00B9B856 /* btConvexPointCloudShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB06D1AF9AA1900B9B856 /* btConvexPointCloudShape.h */; }; + B6CAB2AE1AF9AA1A00B9B856 /* btConvexPointCloudShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB06D1AF9AA1900B9B856 /* btConvexPointCloudShape.h */; }; + B6CAB2AF1AF9AA1A00B9B856 /* btConvexPolyhedron.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB06E1AF9AA1900B9B856 /* btConvexPolyhedron.cpp */; }; + B6CAB2B01AF9AA1A00B9B856 /* btConvexPolyhedron.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB06E1AF9AA1900B9B856 /* btConvexPolyhedron.cpp */; }; + B6CAB2B11AF9AA1A00B9B856 /* btConvexPolyhedron.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB06F1AF9AA1900B9B856 /* btConvexPolyhedron.h */; }; + B6CAB2B21AF9AA1A00B9B856 /* btConvexPolyhedron.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB06F1AF9AA1900B9B856 /* btConvexPolyhedron.h */; }; + B6CAB2B31AF9AA1A00B9B856 /* btConvexShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0701AF9AA1900B9B856 /* btConvexShape.cpp */; }; + B6CAB2B41AF9AA1A00B9B856 /* btConvexShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0701AF9AA1900B9B856 /* btConvexShape.cpp */; }; + B6CAB2B51AF9AA1A00B9B856 /* btConvexShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0711AF9AA1900B9B856 /* btConvexShape.h */; }; + B6CAB2B61AF9AA1A00B9B856 /* btConvexShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0711AF9AA1900B9B856 /* btConvexShape.h */; }; + B6CAB2B71AF9AA1A00B9B856 /* btConvexTriangleMeshShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0721AF9AA1900B9B856 /* btConvexTriangleMeshShape.cpp */; }; + B6CAB2B81AF9AA1A00B9B856 /* btConvexTriangleMeshShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0721AF9AA1900B9B856 /* btConvexTriangleMeshShape.cpp */; }; + B6CAB2B91AF9AA1A00B9B856 /* btConvexTriangleMeshShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0731AF9AA1900B9B856 /* btConvexTriangleMeshShape.h */; }; + B6CAB2BA1AF9AA1A00B9B856 /* btConvexTriangleMeshShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0731AF9AA1900B9B856 /* btConvexTriangleMeshShape.h */; }; + B6CAB2BB1AF9AA1A00B9B856 /* btCylinderShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0741AF9AA1900B9B856 /* btCylinderShape.cpp */; }; + B6CAB2BC1AF9AA1A00B9B856 /* btCylinderShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0741AF9AA1900B9B856 /* btCylinderShape.cpp */; }; + B6CAB2BD1AF9AA1A00B9B856 /* btCylinderShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0751AF9AA1900B9B856 /* btCylinderShape.h */; }; + B6CAB2BE1AF9AA1A00B9B856 /* btCylinderShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0751AF9AA1900B9B856 /* btCylinderShape.h */; }; + B6CAB2BF1AF9AA1A00B9B856 /* btEmptyShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0761AF9AA1900B9B856 /* btEmptyShape.cpp */; }; + B6CAB2C01AF9AA1A00B9B856 /* btEmptyShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0761AF9AA1900B9B856 /* btEmptyShape.cpp */; }; + B6CAB2C11AF9AA1A00B9B856 /* btEmptyShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0771AF9AA1900B9B856 /* btEmptyShape.h */; }; + B6CAB2C21AF9AA1A00B9B856 /* btEmptyShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0771AF9AA1900B9B856 /* btEmptyShape.h */; }; + B6CAB2C31AF9AA1A00B9B856 /* btHeightfieldTerrainShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0781AF9AA1900B9B856 /* btHeightfieldTerrainShape.cpp */; }; + B6CAB2C41AF9AA1A00B9B856 /* btHeightfieldTerrainShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0781AF9AA1900B9B856 /* btHeightfieldTerrainShape.cpp */; }; + B6CAB2C51AF9AA1A00B9B856 /* btHeightfieldTerrainShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0791AF9AA1900B9B856 /* btHeightfieldTerrainShape.h */; }; + B6CAB2C61AF9AA1A00B9B856 /* btHeightfieldTerrainShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0791AF9AA1900B9B856 /* btHeightfieldTerrainShape.h */; }; + B6CAB2C71AF9AA1A00B9B856 /* btMaterial.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB07A1AF9AA1900B9B856 /* btMaterial.h */; }; + B6CAB2C81AF9AA1A00B9B856 /* btMaterial.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB07A1AF9AA1900B9B856 /* btMaterial.h */; }; + B6CAB2C91AF9AA1A00B9B856 /* btMinkowskiSumShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB07B1AF9AA1900B9B856 /* btMinkowskiSumShape.cpp */; }; + B6CAB2CA1AF9AA1A00B9B856 /* btMinkowskiSumShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB07B1AF9AA1900B9B856 /* btMinkowskiSumShape.cpp */; }; + B6CAB2CB1AF9AA1A00B9B856 /* btMinkowskiSumShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB07C1AF9AA1900B9B856 /* btMinkowskiSumShape.h */; }; + B6CAB2CC1AF9AA1A00B9B856 /* btMinkowskiSumShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB07C1AF9AA1900B9B856 /* btMinkowskiSumShape.h */; }; + B6CAB2CD1AF9AA1A00B9B856 /* btMultimaterialTriangleMeshShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB07D1AF9AA1900B9B856 /* btMultimaterialTriangleMeshShape.cpp */; }; + B6CAB2CE1AF9AA1A00B9B856 /* btMultimaterialTriangleMeshShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB07D1AF9AA1900B9B856 /* btMultimaterialTriangleMeshShape.cpp */; }; + B6CAB2CF1AF9AA1A00B9B856 /* btMultimaterialTriangleMeshShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB07E1AF9AA1900B9B856 /* btMultimaterialTriangleMeshShape.h */; }; + B6CAB2D01AF9AA1A00B9B856 /* btMultimaterialTriangleMeshShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB07E1AF9AA1900B9B856 /* btMultimaterialTriangleMeshShape.h */; }; + B6CAB2D11AF9AA1A00B9B856 /* btMultiSphereShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB07F1AF9AA1900B9B856 /* btMultiSphereShape.cpp */; }; + B6CAB2D21AF9AA1A00B9B856 /* btMultiSphereShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB07F1AF9AA1900B9B856 /* btMultiSphereShape.cpp */; }; + B6CAB2D31AF9AA1A00B9B856 /* btMultiSphereShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0801AF9AA1900B9B856 /* btMultiSphereShape.h */; }; + B6CAB2D41AF9AA1A00B9B856 /* btMultiSphereShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0801AF9AA1900B9B856 /* btMultiSphereShape.h */; }; + B6CAB2D51AF9AA1A00B9B856 /* btOptimizedBvh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0811AF9AA1900B9B856 /* btOptimizedBvh.cpp */; }; + B6CAB2D61AF9AA1A00B9B856 /* btOptimizedBvh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0811AF9AA1900B9B856 /* btOptimizedBvh.cpp */; }; + B6CAB2D71AF9AA1A00B9B856 /* btOptimizedBvh.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0821AF9AA1900B9B856 /* btOptimizedBvh.h */; }; + B6CAB2D81AF9AA1A00B9B856 /* btOptimizedBvh.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0821AF9AA1900B9B856 /* btOptimizedBvh.h */; }; + B6CAB2D91AF9AA1A00B9B856 /* btPolyhedralConvexShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0831AF9AA1900B9B856 /* btPolyhedralConvexShape.cpp */; }; + B6CAB2DA1AF9AA1A00B9B856 /* btPolyhedralConvexShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0831AF9AA1900B9B856 /* btPolyhedralConvexShape.cpp */; }; + B6CAB2DB1AF9AA1A00B9B856 /* btPolyhedralConvexShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0841AF9AA1900B9B856 /* btPolyhedralConvexShape.h */; }; + B6CAB2DC1AF9AA1A00B9B856 /* btPolyhedralConvexShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0841AF9AA1900B9B856 /* btPolyhedralConvexShape.h */; }; + B6CAB2DD1AF9AA1A00B9B856 /* btScaledBvhTriangleMeshShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0851AF9AA1900B9B856 /* btScaledBvhTriangleMeshShape.cpp */; }; + B6CAB2DE1AF9AA1A00B9B856 /* btScaledBvhTriangleMeshShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0851AF9AA1900B9B856 /* btScaledBvhTriangleMeshShape.cpp */; }; + B6CAB2DF1AF9AA1A00B9B856 /* btScaledBvhTriangleMeshShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0861AF9AA1900B9B856 /* btScaledBvhTriangleMeshShape.h */; }; + B6CAB2E01AF9AA1A00B9B856 /* btScaledBvhTriangleMeshShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0861AF9AA1900B9B856 /* btScaledBvhTriangleMeshShape.h */; }; + B6CAB2E11AF9AA1A00B9B856 /* btShapeHull.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0871AF9AA1900B9B856 /* btShapeHull.cpp */; }; + B6CAB2E21AF9AA1A00B9B856 /* btShapeHull.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0871AF9AA1900B9B856 /* btShapeHull.cpp */; }; + B6CAB2E31AF9AA1A00B9B856 /* btShapeHull.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0881AF9AA1900B9B856 /* btShapeHull.h */; }; + B6CAB2E41AF9AA1A00B9B856 /* btShapeHull.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0881AF9AA1900B9B856 /* btShapeHull.h */; }; + B6CAB2E51AF9AA1A00B9B856 /* btSphereShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0891AF9AA1900B9B856 /* btSphereShape.cpp */; }; + B6CAB2E61AF9AA1A00B9B856 /* btSphereShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0891AF9AA1900B9B856 /* btSphereShape.cpp */; }; + B6CAB2E71AF9AA1A00B9B856 /* btSphereShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB08A1AF9AA1900B9B856 /* btSphereShape.h */; }; + B6CAB2E81AF9AA1A00B9B856 /* btSphereShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB08A1AF9AA1900B9B856 /* btSphereShape.h */; }; + B6CAB2E91AF9AA1A00B9B856 /* btStaticPlaneShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB08B1AF9AA1900B9B856 /* btStaticPlaneShape.cpp */; }; + B6CAB2EA1AF9AA1A00B9B856 /* btStaticPlaneShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB08B1AF9AA1900B9B856 /* btStaticPlaneShape.cpp */; }; + B6CAB2EB1AF9AA1A00B9B856 /* btStaticPlaneShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB08C1AF9AA1900B9B856 /* btStaticPlaneShape.h */; }; + B6CAB2EC1AF9AA1A00B9B856 /* btStaticPlaneShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB08C1AF9AA1900B9B856 /* btStaticPlaneShape.h */; }; + B6CAB2ED1AF9AA1A00B9B856 /* btStridingMeshInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB08D1AF9AA1900B9B856 /* btStridingMeshInterface.cpp */; }; + B6CAB2EE1AF9AA1A00B9B856 /* btStridingMeshInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB08D1AF9AA1900B9B856 /* btStridingMeshInterface.cpp */; }; + B6CAB2EF1AF9AA1A00B9B856 /* btStridingMeshInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB08E1AF9AA1900B9B856 /* btStridingMeshInterface.h */; }; + B6CAB2F01AF9AA1A00B9B856 /* btStridingMeshInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB08E1AF9AA1900B9B856 /* btStridingMeshInterface.h */; }; + B6CAB2F11AF9AA1A00B9B856 /* btTetrahedronShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB08F1AF9AA1900B9B856 /* btTetrahedronShape.cpp */; }; + B6CAB2F21AF9AA1A00B9B856 /* btTetrahedronShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB08F1AF9AA1900B9B856 /* btTetrahedronShape.cpp */; }; + B6CAB2F31AF9AA1A00B9B856 /* btTetrahedronShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0901AF9AA1900B9B856 /* btTetrahedronShape.h */; }; + B6CAB2F41AF9AA1A00B9B856 /* btTetrahedronShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0901AF9AA1900B9B856 /* btTetrahedronShape.h */; }; + B6CAB2F51AF9AA1A00B9B856 /* btTriangleBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0911AF9AA1900B9B856 /* btTriangleBuffer.cpp */; }; + B6CAB2F61AF9AA1A00B9B856 /* btTriangleBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0911AF9AA1900B9B856 /* btTriangleBuffer.cpp */; }; + B6CAB2F71AF9AA1A00B9B856 /* btTriangleBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0921AF9AA1900B9B856 /* btTriangleBuffer.h */; }; + B6CAB2F81AF9AA1A00B9B856 /* btTriangleBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0921AF9AA1900B9B856 /* btTriangleBuffer.h */; }; + B6CAB2F91AF9AA1A00B9B856 /* btTriangleCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0931AF9AA1900B9B856 /* btTriangleCallback.cpp */; }; + B6CAB2FA1AF9AA1A00B9B856 /* btTriangleCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0931AF9AA1900B9B856 /* btTriangleCallback.cpp */; }; + B6CAB2FB1AF9AA1A00B9B856 /* btTriangleCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0941AF9AA1900B9B856 /* btTriangleCallback.h */; }; + B6CAB2FC1AF9AA1A00B9B856 /* btTriangleCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0941AF9AA1900B9B856 /* btTriangleCallback.h */; }; + B6CAB2FD1AF9AA1A00B9B856 /* btTriangleIndexVertexArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0951AF9AA1900B9B856 /* btTriangleIndexVertexArray.cpp */; }; + B6CAB2FE1AF9AA1A00B9B856 /* btTriangleIndexVertexArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0951AF9AA1900B9B856 /* btTriangleIndexVertexArray.cpp */; }; + B6CAB2FF1AF9AA1A00B9B856 /* btTriangleIndexVertexArray.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0961AF9AA1900B9B856 /* btTriangleIndexVertexArray.h */; }; + B6CAB3001AF9AA1A00B9B856 /* btTriangleIndexVertexArray.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0961AF9AA1900B9B856 /* btTriangleIndexVertexArray.h */; }; + B6CAB3011AF9AA1A00B9B856 /* btTriangleIndexVertexMaterialArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0971AF9AA1900B9B856 /* btTriangleIndexVertexMaterialArray.cpp */; }; + B6CAB3021AF9AA1A00B9B856 /* btTriangleIndexVertexMaterialArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0971AF9AA1900B9B856 /* btTriangleIndexVertexMaterialArray.cpp */; }; + B6CAB3031AF9AA1A00B9B856 /* btTriangleIndexVertexMaterialArray.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0981AF9AA1900B9B856 /* btTriangleIndexVertexMaterialArray.h */; }; + B6CAB3041AF9AA1A00B9B856 /* btTriangleIndexVertexMaterialArray.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0981AF9AA1900B9B856 /* btTriangleIndexVertexMaterialArray.h */; }; + B6CAB3051AF9AA1A00B9B856 /* btTriangleInfoMap.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0991AF9AA1900B9B856 /* btTriangleInfoMap.h */; }; + B6CAB3061AF9AA1A00B9B856 /* btTriangleInfoMap.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0991AF9AA1900B9B856 /* btTriangleInfoMap.h */; }; + B6CAB3071AF9AA1A00B9B856 /* btTriangleMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB09A1AF9AA1900B9B856 /* btTriangleMesh.cpp */; }; + B6CAB3081AF9AA1A00B9B856 /* btTriangleMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB09A1AF9AA1900B9B856 /* btTriangleMesh.cpp */; }; + B6CAB3091AF9AA1A00B9B856 /* btTriangleMesh.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB09B1AF9AA1900B9B856 /* btTriangleMesh.h */; }; + B6CAB30A1AF9AA1A00B9B856 /* btTriangleMesh.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB09B1AF9AA1900B9B856 /* btTriangleMesh.h */; }; + B6CAB30B1AF9AA1A00B9B856 /* btTriangleMeshShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB09C1AF9AA1900B9B856 /* btTriangleMeshShape.cpp */; }; + B6CAB30C1AF9AA1A00B9B856 /* btTriangleMeshShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB09C1AF9AA1900B9B856 /* btTriangleMeshShape.cpp */; }; + B6CAB30D1AF9AA1A00B9B856 /* btTriangleMeshShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB09D1AF9AA1900B9B856 /* btTriangleMeshShape.h */; }; + B6CAB30E1AF9AA1A00B9B856 /* btTriangleMeshShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB09D1AF9AA1900B9B856 /* btTriangleMeshShape.h */; }; + B6CAB30F1AF9AA1A00B9B856 /* btTriangleShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB09E1AF9AA1900B9B856 /* btTriangleShape.h */; }; + B6CAB3101AF9AA1A00B9B856 /* btTriangleShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB09E1AF9AA1900B9B856 /* btTriangleShape.h */; }; + B6CAB3111AF9AA1A00B9B856 /* btUniformScalingShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB09F1AF9AA1900B9B856 /* btUniformScalingShape.cpp */; }; + B6CAB3121AF9AA1A00B9B856 /* btUniformScalingShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB09F1AF9AA1900B9B856 /* btUniformScalingShape.cpp */; }; + B6CAB3131AF9AA1A00B9B856 /* btUniformScalingShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0A01AF9AA1900B9B856 /* btUniformScalingShape.h */; }; + B6CAB3141AF9AA1A00B9B856 /* btUniformScalingShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0A01AF9AA1900B9B856 /* btUniformScalingShape.h */; }; + B6CAB3151AF9AA1A00B9B856 /* btBoxCollision.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0A21AF9AA1900B9B856 /* btBoxCollision.h */; }; + B6CAB3161AF9AA1A00B9B856 /* btBoxCollision.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0A21AF9AA1900B9B856 /* btBoxCollision.h */; }; + B6CAB3171AF9AA1A00B9B856 /* btClipPolygon.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0A31AF9AA1900B9B856 /* btClipPolygon.h */; }; + B6CAB3181AF9AA1A00B9B856 /* btClipPolygon.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0A31AF9AA1900B9B856 /* btClipPolygon.h */; }; + B6CAB3191AF9AA1A00B9B856 /* btCompoundFromGimpact.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0A41AF9AA1900B9B856 /* btCompoundFromGimpact.h */; }; + B6CAB31A1AF9AA1A00B9B856 /* btCompoundFromGimpact.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0A41AF9AA1900B9B856 /* btCompoundFromGimpact.h */; }; + B6CAB31B1AF9AA1A00B9B856 /* btContactProcessing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0A51AF9AA1900B9B856 /* btContactProcessing.cpp */; }; + B6CAB31C1AF9AA1A00B9B856 /* btContactProcessing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0A51AF9AA1900B9B856 /* btContactProcessing.cpp */; }; + B6CAB31D1AF9AA1A00B9B856 /* btContactProcessing.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0A61AF9AA1900B9B856 /* btContactProcessing.h */; }; + B6CAB31E1AF9AA1A00B9B856 /* btContactProcessing.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0A61AF9AA1900B9B856 /* btContactProcessing.h */; }; + B6CAB31F1AF9AA1A00B9B856 /* btGenericPoolAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0A71AF9AA1900B9B856 /* btGenericPoolAllocator.cpp */; }; + B6CAB3201AF9AA1A00B9B856 /* btGenericPoolAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0A71AF9AA1900B9B856 /* btGenericPoolAllocator.cpp */; }; + B6CAB3211AF9AA1A00B9B856 /* btGenericPoolAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0A81AF9AA1900B9B856 /* btGenericPoolAllocator.h */; }; + B6CAB3221AF9AA1A00B9B856 /* btGenericPoolAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0A81AF9AA1900B9B856 /* btGenericPoolAllocator.h */; }; + B6CAB3231AF9AA1A00B9B856 /* btGeometryOperations.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0A91AF9AA1900B9B856 /* btGeometryOperations.h */; }; + B6CAB3241AF9AA1A00B9B856 /* btGeometryOperations.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0A91AF9AA1900B9B856 /* btGeometryOperations.h */; }; + B6CAB3251AF9AA1A00B9B856 /* btGImpactBvh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0AA1AF9AA1900B9B856 /* btGImpactBvh.cpp */; }; + B6CAB3261AF9AA1A00B9B856 /* btGImpactBvh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0AA1AF9AA1900B9B856 /* btGImpactBvh.cpp */; }; + B6CAB3271AF9AA1A00B9B856 /* btGImpactBvh.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0AB1AF9AA1900B9B856 /* btGImpactBvh.h */; }; + B6CAB3281AF9AA1A00B9B856 /* btGImpactBvh.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0AB1AF9AA1900B9B856 /* btGImpactBvh.h */; }; + B6CAB3291AF9AA1A00B9B856 /* btGImpactCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0AC1AF9AA1900B9B856 /* btGImpactCollisionAlgorithm.cpp */; }; + B6CAB32A1AF9AA1A00B9B856 /* btGImpactCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0AC1AF9AA1900B9B856 /* btGImpactCollisionAlgorithm.cpp */; }; + B6CAB32B1AF9AA1A00B9B856 /* btGImpactCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0AD1AF9AA1900B9B856 /* btGImpactCollisionAlgorithm.h */; }; + B6CAB32C1AF9AA1A00B9B856 /* btGImpactCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0AD1AF9AA1900B9B856 /* btGImpactCollisionAlgorithm.h */; }; + B6CAB32D1AF9AA1A00B9B856 /* btGImpactMassUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0AE1AF9AA1900B9B856 /* btGImpactMassUtil.h */; }; + B6CAB32E1AF9AA1A00B9B856 /* btGImpactMassUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0AE1AF9AA1900B9B856 /* btGImpactMassUtil.h */; }; + B6CAB32F1AF9AA1A00B9B856 /* btGImpactQuantizedBvh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0AF1AF9AA1900B9B856 /* btGImpactQuantizedBvh.cpp */; }; + B6CAB3301AF9AA1A00B9B856 /* btGImpactQuantizedBvh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0AF1AF9AA1900B9B856 /* btGImpactQuantizedBvh.cpp */; }; + B6CAB3311AF9AA1A00B9B856 /* btGImpactQuantizedBvh.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0B01AF9AA1900B9B856 /* btGImpactQuantizedBvh.h */; }; + B6CAB3321AF9AA1A00B9B856 /* btGImpactQuantizedBvh.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0B01AF9AA1900B9B856 /* btGImpactQuantizedBvh.h */; }; + B6CAB3331AF9AA1A00B9B856 /* btGImpactShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0B11AF9AA1900B9B856 /* btGImpactShape.cpp */; }; + B6CAB3341AF9AA1A00B9B856 /* btGImpactShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0B11AF9AA1900B9B856 /* btGImpactShape.cpp */; }; + B6CAB3351AF9AA1A00B9B856 /* btGImpactShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0B21AF9AA1900B9B856 /* btGImpactShape.h */; }; + B6CAB3361AF9AA1A00B9B856 /* btGImpactShape.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0B21AF9AA1900B9B856 /* btGImpactShape.h */; }; + B6CAB3371AF9AA1A00B9B856 /* btQuantization.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0B31AF9AA1900B9B856 /* btQuantization.h */; }; + B6CAB3381AF9AA1A00B9B856 /* btQuantization.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0B31AF9AA1900B9B856 /* btQuantization.h */; }; + B6CAB3391AF9AA1A00B9B856 /* btTriangleShapeEx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0B41AF9AA1900B9B856 /* btTriangleShapeEx.cpp */; }; + B6CAB33A1AF9AA1A00B9B856 /* btTriangleShapeEx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0B41AF9AA1900B9B856 /* btTriangleShapeEx.cpp */; }; + B6CAB33B1AF9AA1A00B9B856 /* btTriangleShapeEx.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0B51AF9AA1900B9B856 /* btTriangleShapeEx.h */; }; + B6CAB33C1AF9AA1A00B9B856 /* btTriangleShapeEx.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0B51AF9AA1900B9B856 /* btTriangleShapeEx.h */; }; + B6CAB33D1AF9AA1A00B9B856 /* gim_array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0B61AF9AA1900B9B856 /* gim_array.h */; }; + B6CAB33E1AF9AA1A00B9B856 /* gim_array.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0B61AF9AA1900B9B856 /* gim_array.h */; }; + B6CAB33F1AF9AA1A00B9B856 /* gim_basic_geometry_operations.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0B71AF9AA1900B9B856 /* gim_basic_geometry_operations.h */; }; + B6CAB3401AF9AA1A00B9B856 /* gim_basic_geometry_operations.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0B71AF9AA1900B9B856 /* gim_basic_geometry_operations.h */; }; + B6CAB3411AF9AA1A00B9B856 /* gim_bitset.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0B81AF9AA1900B9B856 /* gim_bitset.h */; }; + B6CAB3421AF9AA1A00B9B856 /* gim_bitset.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0B81AF9AA1900B9B856 /* gim_bitset.h */; }; + B6CAB3431AF9AA1A00B9B856 /* gim_box_collision.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0B91AF9AA1900B9B856 /* gim_box_collision.h */; }; + B6CAB3441AF9AA1A00B9B856 /* gim_box_collision.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0B91AF9AA1900B9B856 /* gim_box_collision.h */; }; + B6CAB3451AF9AA1A00B9B856 /* gim_box_set.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0BA1AF9AA1900B9B856 /* gim_box_set.cpp */; }; + B6CAB3461AF9AA1A00B9B856 /* gim_box_set.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0BA1AF9AA1900B9B856 /* gim_box_set.cpp */; }; + B6CAB3471AF9AA1A00B9B856 /* gim_box_set.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0BB1AF9AA1900B9B856 /* gim_box_set.h */; }; + B6CAB3481AF9AA1A00B9B856 /* gim_box_set.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0BB1AF9AA1900B9B856 /* gim_box_set.h */; }; + B6CAB3491AF9AA1A00B9B856 /* gim_clip_polygon.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0BC1AF9AA1900B9B856 /* gim_clip_polygon.h */; }; + B6CAB34A1AF9AA1A00B9B856 /* gim_clip_polygon.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0BC1AF9AA1900B9B856 /* gim_clip_polygon.h */; }; + B6CAB34B1AF9AA1A00B9B856 /* gim_contact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0BD1AF9AA1900B9B856 /* gim_contact.cpp */; }; + B6CAB34C1AF9AA1A00B9B856 /* gim_contact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0BD1AF9AA1900B9B856 /* gim_contact.cpp */; }; + B6CAB34D1AF9AA1A00B9B856 /* gim_contact.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0BE1AF9AA1900B9B856 /* gim_contact.h */; }; + B6CAB34E1AF9AA1A00B9B856 /* gim_contact.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0BE1AF9AA1900B9B856 /* gim_contact.h */; }; + B6CAB34F1AF9AA1A00B9B856 /* gim_geom_types.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0BF1AF9AA1900B9B856 /* gim_geom_types.h */; }; + B6CAB3501AF9AA1A00B9B856 /* gim_geom_types.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0BF1AF9AA1900B9B856 /* gim_geom_types.h */; }; + B6CAB3511AF9AA1A00B9B856 /* gim_geometry.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0C01AF9AA1900B9B856 /* gim_geometry.h */; }; + B6CAB3521AF9AA1A00B9B856 /* gim_geometry.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0C01AF9AA1900B9B856 /* gim_geometry.h */; }; + B6CAB3531AF9AA1A00B9B856 /* gim_hash_table.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0C11AF9AA1900B9B856 /* gim_hash_table.h */; }; + B6CAB3541AF9AA1A00B9B856 /* gim_hash_table.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0C11AF9AA1900B9B856 /* gim_hash_table.h */; }; + B6CAB3551AF9AA1A00B9B856 /* gim_linear_math.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0C21AF9AA1900B9B856 /* gim_linear_math.h */; }; + B6CAB3561AF9AA1A00B9B856 /* gim_linear_math.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0C21AF9AA1900B9B856 /* gim_linear_math.h */; }; + B6CAB3571AF9AA1A00B9B856 /* gim_math.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0C31AF9AA1900B9B856 /* gim_math.h */; }; + B6CAB3581AF9AA1A00B9B856 /* gim_math.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0C31AF9AA1900B9B856 /* gim_math.h */; }; + B6CAB3591AF9AA1A00B9B856 /* gim_memory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0C41AF9AA1900B9B856 /* gim_memory.cpp */; }; + B6CAB35A1AF9AA1A00B9B856 /* gim_memory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0C41AF9AA1900B9B856 /* gim_memory.cpp */; }; + B6CAB35B1AF9AA1A00B9B856 /* gim_memory.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0C51AF9AA1900B9B856 /* gim_memory.h */; }; + B6CAB35C1AF9AA1A00B9B856 /* gim_memory.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0C51AF9AA1900B9B856 /* gim_memory.h */; }; + B6CAB35D1AF9AA1A00B9B856 /* gim_radixsort.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0C61AF9AA1900B9B856 /* gim_radixsort.h */; }; + B6CAB35E1AF9AA1A00B9B856 /* gim_radixsort.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0C61AF9AA1900B9B856 /* gim_radixsort.h */; }; + B6CAB35F1AF9AA1A00B9B856 /* gim_tri_collision.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0C71AF9AA1900B9B856 /* gim_tri_collision.cpp */; }; + B6CAB3601AF9AA1A00B9B856 /* gim_tri_collision.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0C71AF9AA1900B9B856 /* gim_tri_collision.cpp */; }; + B6CAB3611AF9AA1A00B9B856 /* gim_tri_collision.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0C81AF9AA1900B9B856 /* gim_tri_collision.h */; }; + B6CAB3621AF9AA1A00B9B856 /* gim_tri_collision.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0C81AF9AA1900B9B856 /* gim_tri_collision.h */; }; + B6CAB3631AF9AA1A00B9B856 /* btContinuousConvexCollision.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0CA1AF9AA1900B9B856 /* btContinuousConvexCollision.cpp */; }; + B6CAB3641AF9AA1A00B9B856 /* btContinuousConvexCollision.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0CA1AF9AA1900B9B856 /* btContinuousConvexCollision.cpp */; }; + B6CAB3651AF9AA1A00B9B856 /* btContinuousConvexCollision.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0CB1AF9AA1900B9B856 /* btContinuousConvexCollision.h */; }; + B6CAB3661AF9AA1A00B9B856 /* btContinuousConvexCollision.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0CB1AF9AA1900B9B856 /* btContinuousConvexCollision.h */; }; + B6CAB3671AF9AA1A00B9B856 /* btConvexCast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0CC1AF9AA1900B9B856 /* btConvexCast.cpp */; }; + B6CAB3681AF9AA1A00B9B856 /* btConvexCast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0CC1AF9AA1900B9B856 /* btConvexCast.cpp */; }; + B6CAB3691AF9AA1A00B9B856 /* btConvexCast.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0CD1AF9AA1900B9B856 /* btConvexCast.h */; }; + B6CAB36A1AF9AA1A00B9B856 /* btConvexCast.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0CD1AF9AA1900B9B856 /* btConvexCast.h */; }; + B6CAB36B1AF9AA1A00B9B856 /* btConvexPenetrationDepthSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0CE1AF9AA1900B9B856 /* btConvexPenetrationDepthSolver.h */; }; + B6CAB36C1AF9AA1A00B9B856 /* btConvexPenetrationDepthSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0CE1AF9AA1900B9B856 /* btConvexPenetrationDepthSolver.h */; }; + B6CAB36D1AF9AA1A00B9B856 /* btDiscreteCollisionDetectorInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0CF1AF9AA1900B9B856 /* btDiscreteCollisionDetectorInterface.h */; }; + B6CAB36E1AF9AA1A00B9B856 /* btDiscreteCollisionDetectorInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0CF1AF9AA1900B9B856 /* btDiscreteCollisionDetectorInterface.h */; }; + B6CAB36F1AF9AA1A00B9B856 /* btGjkConvexCast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0D01AF9AA1900B9B856 /* btGjkConvexCast.cpp */; }; + B6CAB3701AF9AA1A00B9B856 /* btGjkConvexCast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0D01AF9AA1900B9B856 /* btGjkConvexCast.cpp */; }; + B6CAB3711AF9AA1A00B9B856 /* btGjkConvexCast.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0D11AF9AA1900B9B856 /* btGjkConvexCast.h */; }; + B6CAB3721AF9AA1A00B9B856 /* btGjkConvexCast.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0D11AF9AA1900B9B856 /* btGjkConvexCast.h */; }; + B6CAB3731AF9AA1A00B9B856 /* btGjkEpa2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0D21AF9AA1900B9B856 /* btGjkEpa2.cpp */; }; + B6CAB3741AF9AA1A00B9B856 /* btGjkEpa2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0D21AF9AA1900B9B856 /* btGjkEpa2.cpp */; }; + B6CAB3751AF9AA1A00B9B856 /* btGjkEpa2.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0D31AF9AA1900B9B856 /* btGjkEpa2.h */; }; + B6CAB3761AF9AA1A00B9B856 /* btGjkEpa2.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0D31AF9AA1900B9B856 /* btGjkEpa2.h */; }; + B6CAB3771AF9AA1A00B9B856 /* btGjkEpaPenetrationDepthSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0D41AF9AA1900B9B856 /* btGjkEpaPenetrationDepthSolver.cpp */; }; + B6CAB3781AF9AA1A00B9B856 /* btGjkEpaPenetrationDepthSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0D41AF9AA1900B9B856 /* btGjkEpaPenetrationDepthSolver.cpp */; }; + B6CAB3791AF9AA1A00B9B856 /* btGjkEpaPenetrationDepthSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0D51AF9AA1900B9B856 /* btGjkEpaPenetrationDepthSolver.h */; }; + B6CAB37A1AF9AA1A00B9B856 /* btGjkEpaPenetrationDepthSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0D51AF9AA1900B9B856 /* btGjkEpaPenetrationDepthSolver.h */; }; + B6CAB37B1AF9AA1A00B9B856 /* btGjkPairDetector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0D61AF9AA1900B9B856 /* btGjkPairDetector.cpp */; }; + B6CAB37C1AF9AA1A00B9B856 /* btGjkPairDetector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0D61AF9AA1900B9B856 /* btGjkPairDetector.cpp */; }; + B6CAB37D1AF9AA1A00B9B856 /* btGjkPairDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0D71AF9AA1900B9B856 /* btGjkPairDetector.h */; }; + B6CAB37E1AF9AA1A00B9B856 /* btGjkPairDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0D71AF9AA1900B9B856 /* btGjkPairDetector.h */; }; + B6CAB37F1AF9AA1A00B9B856 /* btManifoldPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0D81AF9AA1900B9B856 /* btManifoldPoint.h */; }; + B6CAB3801AF9AA1A00B9B856 /* btManifoldPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0D81AF9AA1900B9B856 /* btManifoldPoint.h */; }; + B6CAB3811AF9AA1A00B9B856 /* btMinkowskiPenetrationDepthSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0D91AF9AA1900B9B856 /* btMinkowskiPenetrationDepthSolver.cpp */; }; + B6CAB3821AF9AA1A00B9B856 /* btMinkowskiPenetrationDepthSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0D91AF9AA1900B9B856 /* btMinkowskiPenetrationDepthSolver.cpp */; }; + B6CAB3831AF9AA1A00B9B856 /* btMinkowskiPenetrationDepthSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0DA1AF9AA1900B9B856 /* btMinkowskiPenetrationDepthSolver.h */; }; + B6CAB3841AF9AA1A00B9B856 /* btMinkowskiPenetrationDepthSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0DA1AF9AA1900B9B856 /* btMinkowskiPenetrationDepthSolver.h */; }; + B6CAB3851AF9AA1A00B9B856 /* btPersistentManifold.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0DB1AF9AA1900B9B856 /* btPersistentManifold.cpp */; }; + B6CAB3861AF9AA1A00B9B856 /* btPersistentManifold.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0DB1AF9AA1900B9B856 /* btPersistentManifold.cpp */; }; + B6CAB3871AF9AA1A00B9B856 /* btPersistentManifold.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0DC1AF9AA1900B9B856 /* btPersistentManifold.h */; }; + B6CAB3881AF9AA1A00B9B856 /* btPersistentManifold.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0DC1AF9AA1900B9B856 /* btPersistentManifold.h */; }; + B6CAB3891AF9AA1A00B9B856 /* btPointCollector.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0DD1AF9AA1900B9B856 /* btPointCollector.h */; }; + B6CAB38A1AF9AA1A00B9B856 /* btPointCollector.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0DD1AF9AA1900B9B856 /* btPointCollector.h */; }; + B6CAB38B1AF9AA1A00B9B856 /* btPolyhedralContactClipping.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0DE1AF9AA1900B9B856 /* btPolyhedralContactClipping.cpp */; }; + B6CAB38C1AF9AA1A00B9B856 /* btPolyhedralContactClipping.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0DE1AF9AA1900B9B856 /* btPolyhedralContactClipping.cpp */; }; + B6CAB38D1AF9AA1A00B9B856 /* btPolyhedralContactClipping.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0DF1AF9AA1900B9B856 /* btPolyhedralContactClipping.h */; }; + B6CAB38E1AF9AA1A00B9B856 /* btPolyhedralContactClipping.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0DF1AF9AA1900B9B856 /* btPolyhedralContactClipping.h */; }; + B6CAB38F1AF9AA1A00B9B856 /* btRaycastCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0E01AF9AA1900B9B856 /* btRaycastCallback.cpp */; }; + B6CAB3901AF9AA1A00B9B856 /* btRaycastCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0E01AF9AA1900B9B856 /* btRaycastCallback.cpp */; }; + B6CAB3911AF9AA1A00B9B856 /* btRaycastCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0E11AF9AA1900B9B856 /* btRaycastCallback.h */; }; + B6CAB3921AF9AA1A00B9B856 /* btRaycastCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0E11AF9AA1900B9B856 /* btRaycastCallback.h */; }; + B6CAB3931AF9AA1A00B9B856 /* btSimplexSolverInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0E21AF9AA1900B9B856 /* btSimplexSolverInterface.h */; }; + B6CAB3941AF9AA1A00B9B856 /* btSimplexSolverInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0E21AF9AA1900B9B856 /* btSimplexSolverInterface.h */; }; + B6CAB3951AF9AA1A00B9B856 /* btSubSimplexConvexCast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0E31AF9AA1900B9B856 /* btSubSimplexConvexCast.cpp */; }; + B6CAB3961AF9AA1A00B9B856 /* btSubSimplexConvexCast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0E31AF9AA1900B9B856 /* btSubSimplexConvexCast.cpp */; }; + B6CAB3971AF9AA1A00B9B856 /* btSubSimplexConvexCast.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0E41AF9AA1900B9B856 /* btSubSimplexConvexCast.h */; }; + B6CAB3981AF9AA1A00B9B856 /* btSubSimplexConvexCast.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0E41AF9AA1900B9B856 /* btSubSimplexConvexCast.h */; }; + B6CAB3991AF9AA1A00B9B856 /* btVoronoiSimplexSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0E51AF9AA1900B9B856 /* btVoronoiSimplexSolver.cpp */; }; + B6CAB39A1AF9AA1A00B9B856 /* btVoronoiSimplexSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0E51AF9AA1900B9B856 /* btVoronoiSimplexSolver.cpp */; }; + B6CAB39B1AF9AA1A00B9B856 /* btVoronoiSimplexSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0E61AF9AA1900B9B856 /* btVoronoiSimplexSolver.h */; }; + B6CAB39C1AF9AA1A00B9B856 /* btVoronoiSimplexSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0E61AF9AA1900B9B856 /* btVoronoiSimplexSolver.h */; }; + B6CAB39D1AF9AA1A00B9B856 /* btCharacterControllerInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0E91AF9AA1900B9B856 /* btCharacterControllerInterface.h */; }; + B6CAB39E1AF9AA1A00B9B856 /* btCharacterControllerInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0E91AF9AA1900B9B856 /* btCharacterControllerInterface.h */; }; + B6CAB39F1AF9AA1A00B9B856 /* btKinematicCharacterController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0EA1AF9AA1900B9B856 /* btKinematicCharacterController.cpp */; }; + B6CAB3A01AF9AA1A00B9B856 /* btKinematicCharacterController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0EA1AF9AA1900B9B856 /* btKinematicCharacterController.cpp */; }; + B6CAB3A11AF9AA1A00B9B856 /* btKinematicCharacterController.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0EB1AF9AA1900B9B856 /* btKinematicCharacterController.h */; }; + B6CAB3A21AF9AA1A00B9B856 /* btKinematicCharacterController.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0EB1AF9AA1900B9B856 /* btKinematicCharacterController.h */; }; + B6CAB3A31AF9AA1A00B9B856 /* btConeTwistConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0ED1AF9AA1900B9B856 /* btConeTwistConstraint.cpp */; }; + B6CAB3A41AF9AA1A00B9B856 /* btConeTwistConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0ED1AF9AA1900B9B856 /* btConeTwistConstraint.cpp */; }; + B6CAB3A51AF9AA1A00B9B856 /* btConeTwistConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0EE1AF9AA1900B9B856 /* btConeTwistConstraint.h */; }; + B6CAB3A61AF9AA1A00B9B856 /* btConeTwistConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0EE1AF9AA1900B9B856 /* btConeTwistConstraint.h */; }; + B6CAB3A71AF9AA1A00B9B856 /* btConstraintSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0EF1AF9AA1900B9B856 /* btConstraintSolver.h */; }; + B6CAB3A81AF9AA1A00B9B856 /* btConstraintSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0EF1AF9AA1900B9B856 /* btConstraintSolver.h */; }; + B6CAB3A91AF9AA1A00B9B856 /* btContactConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0F01AF9AA1900B9B856 /* btContactConstraint.cpp */; }; + B6CAB3AA1AF9AA1A00B9B856 /* btContactConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0F01AF9AA1900B9B856 /* btContactConstraint.cpp */; }; + B6CAB3AB1AF9AA1A00B9B856 /* btContactConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0F11AF9AA1900B9B856 /* btContactConstraint.h */; }; + B6CAB3AC1AF9AA1A00B9B856 /* btContactConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0F11AF9AA1900B9B856 /* btContactConstraint.h */; }; + B6CAB3AD1AF9AA1A00B9B856 /* btContactSolverInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0F21AF9AA1900B9B856 /* btContactSolverInfo.h */; }; + B6CAB3AE1AF9AA1A00B9B856 /* btContactSolverInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0F21AF9AA1900B9B856 /* btContactSolverInfo.h */; }; + B6CAB3AF1AF9AA1A00B9B856 /* btFixedConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0F31AF9AA1900B9B856 /* btFixedConstraint.cpp */; }; + B6CAB3B01AF9AA1A00B9B856 /* btFixedConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0F31AF9AA1900B9B856 /* btFixedConstraint.cpp */; }; + B6CAB3B11AF9AA1A00B9B856 /* btFixedConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0F41AF9AA1900B9B856 /* btFixedConstraint.h */; }; + B6CAB3B21AF9AA1A00B9B856 /* btFixedConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0F41AF9AA1900B9B856 /* btFixedConstraint.h */; }; + B6CAB3B31AF9AA1A00B9B856 /* btGearConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0F51AF9AA1900B9B856 /* btGearConstraint.cpp */; }; + B6CAB3B41AF9AA1A00B9B856 /* btGearConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0F51AF9AA1900B9B856 /* btGearConstraint.cpp */; }; + B6CAB3B51AF9AA1A00B9B856 /* btGearConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0F61AF9AA1900B9B856 /* btGearConstraint.h */; }; + B6CAB3B61AF9AA1A00B9B856 /* btGearConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0F61AF9AA1900B9B856 /* btGearConstraint.h */; }; + B6CAB3B71AF9AA1A00B9B856 /* btGeneric6DofConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0F71AF9AA1900B9B856 /* btGeneric6DofConstraint.cpp */; }; + B6CAB3B81AF9AA1A00B9B856 /* btGeneric6DofConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0F71AF9AA1900B9B856 /* btGeneric6DofConstraint.cpp */; }; + B6CAB3B91AF9AA1A00B9B856 /* btGeneric6DofConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0F81AF9AA1900B9B856 /* btGeneric6DofConstraint.h */; }; + B6CAB3BA1AF9AA1A00B9B856 /* btGeneric6DofConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0F81AF9AA1900B9B856 /* btGeneric6DofConstraint.h */; }; + B6CAB3BB1AF9AA1A00B9B856 /* btGeneric6DofSpringConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0F91AF9AA1900B9B856 /* btGeneric6DofSpringConstraint.cpp */; }; + B6CAB3BC1AF9AA1A00B9B856 /* btGeneric6DofSpringConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0F91AF9AA1900B9B856 /* btGeneric6DofSpringConstraint.cpp */; }; + B6CAB3BD1AF9AA1A00B9B856 /* btGeneric6DofSpringConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0FA1AF9AA1900B9B856 /* btGeneric6DofSpringConstraint.h */; }; + B6CAB3BE1AF9AA1A00B9B856 /* btGeneric6DofSpringConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0FA1AF9AA1900B9B856 /* btGeneric6DofSpringConstraint.h */; }; + B6CAB3BF1AF9AA1A00B9B856 /* btHinge2Constraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0FB1AF9AA1900B9B856 /* btHinge2Constraint.cpp */; }; + B6CAB3C01AF9AA1A00B9B856 /* btHinge2Constraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0FB1AF9AA1900B9B856 /* btHinge2Constraint.cpp */; }; + B6CAB3C11AF9AA1A00B9B856 /* btHinge2Constraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0FC1AF9AA1900B9B856 /* btHinge2Constraint.h */; }; + B6CAB3C21AF9AA1A00B9B856 /* btHinge2Constraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0FC1AF9AA1900B9B856 /* btHinge2Constraint.h */; }; + B6CAB3C31AF9AA1A00B9B856 /* btHingeConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0FD1AF9AA1900B9B856 /* btHingeConstraint.cpp */; }; + B6CAB3C41AF9AA1A00B9B856 /* btHingeConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB0FD1AF9AA1900B9B856 /* btHingeConstraint.cpp */; }; + B6CAB3C51AF9AA1A00B9B856 /* btHingeConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0FE1AF9AA1900B9B856 /* btHingeConstraint.h */; }; + B6CAB3C61AF9AA1A00B9B856 /* btHingeConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0FE1AF9AA1900B9B856 /* btHingeConstraint.h */; }; + B6CAB3C71AF9AA1A00B9B856 /* btJacobianEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0FF1AF9AA1900B9B856 /* btJacobianEntry.h */; }; + B6CAB3C81AF9AA1A00B9B856 /* btJacobianEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB0FF1AF9AA1900B9B856 /* btJacobianEntry.h */; }; + B6CAB3C91AF9AA1A00B9B856 /* btPoint2PointConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1001AF9AA1900B9B856 /* btPoint2PointConstraint.cpp */; }; + B6CAB3CA1AF9AA1A00B9B856 /* btPoint2PointConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1001AF9AA1900B9B856 /* btPoint2PointConstraint.cpp */; }; + B6CAB3CB1AF9AA1A00B9B856 /* btPoint2PointConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1011AF9AA1900B9B856 /* btPoint2PointConstraint.h */; }; + B6CAB3CC1AF9AA1A00B9B856 /* btPoint2PointConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1011AF9AA1900B9B856 /* btPoint2PointConstraint.h */; }; + B6CAB3CD1AF9AA1A00B9B856 /* btSequentialImpulseConstraintSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1021AF9AA1900B9B856 /* btSequentialImpulseConstraintSolver.cpp */; }; + B6CAB3CE1AF9AA1A00B9B856 /* btSequentialImpulseConstraintSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1021AF9AA1900B9B856 /* btSequentialImpulseConstraintSolver.cpp */; }; + B6CAB3CF1AF9AA1A00B9B856 /* btSequentialImpulseConstraintSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1031AF9AA1900B9B856 /* btSequentialImpulseConstraintSolver.h */; }; + B6CAB3D01AF9AA1A00B9B856 /* btSequentialImpulseConstraintSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1031AF9AA1900B9B856 /* btSequentialImpulseConstraintSolver.h */; }; + B6CAB3D11AF9AA1A00B9B856 /* btSliderConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1041AF9AA1900B9B856 /* btSliderConstraint.cpp */; }; + B6CAB3D21AF9AA1A00B9B856 /* btSliderConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1041AF9AA1900B9B856 /* btSliderConstraint.cpp */; }; + B6CAB3D31AF9AA1A00B9B856 /* btSliderConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1051AF9AA1900B9B856 /* btSliderConstraint.h */; }; + B6CAB3D41AF9AA1A00B9B856 /* btSliderConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1051AF9AA1900B9B856 /* btSliderConstraint.h */; }; + B6CAB3D51AF9AA1A00B9B856 /* btSolve2LinearConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1061AF9AA1900B9B856 /* btSolve2LinearConstraint.cpp */; }; + B6CAB3D61AF9AA1A00B9B856 /* btSolve2LinearConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1061AF9AA1900B9B856 /* btSolve2LinearConstraint.cpp */; }; + B6CAB3D71AF9AA1A00B9B856 /* btSolve2LinearConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1071AF9AA1900B9B856 /* btSolve2LinearConstraint.h */; }; + B6CAB3D81AF9AA1A00B9B856 /* btSolve2LinearConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1071AF9AA1900B9B856 /* btSolve2LinearConstraint.h */; }; + B6CAB3D91AF9AA1A00B9B856 /* btSolverBody.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1081AF9AA1900B9B856 /* btSolverBody.h */; }; + B6CAB3DA1AF9AA1A00B9B856 /* btSolverBody.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1081AF9AA1900B9B856 /* btSolverBody.h */; }; + B6CAB3DB1AF9AA1A00B9B856 /* btSolverConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1091AF9AA1900B9B856 /* btSolverConstraint.h */; }; + B6CAB3DC1AF9AA1A00B9B856 /* btSolverConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1091AF9AA1900B9B856 /* btSolverConstraint.h */; }; + B6CAB3DD1AF9AA1A00B9B856 /* btTypedConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB10A1AF9AA1900B9B856 /* btTypedConstraint.cpp */; }; + B6CAB3DE1AF9AA1A00B9B856 /* btTypedConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB10A1AF9AA1900B9B856 /* btTypedConstraint.cpp */; }; + B6CAB3DF1AF9AA1A00B9B856 /* btTypedConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB10B1AF9AA1900B9B856 /* btTypedConstraint.h */; }; + B6CAB3E01AF9AA1A00B9B856 /* btTypedConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB10B1AF9AA1900B9B856 /* btTypedConstraint.h */; }; + B6CAB3E11AF9AA1A00B9B856 /* btUniversalConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB10C1AF9AA1900B9B856 /* btUniversalConstraint.cpp */; }; + B6CAB3E21AF9AA1A00B9B856 /* btUniversalConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB10C1AF9AA1900B9B856 /* btUniversalConstraint.cpp */; }; + B6CAB3E31AF9AA1A00B9B856 /* btUniversalConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB10D1AF9AA1900B9B856 /* btUniversalConstraint.h */; }; + B6CAB3E41AF9AA1A00B9B856 /* btUniversalConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB10D1AF9AA1900B9B856 /* btUniversalConstraint.h */; }; + B6CAB3E51AF9AA1A00B9B856 /* btActionInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB10F1AF9AA1900B9B856 /* btActionInterface.h */; }; + B6CAB3E61AF9AA1A00B9B856 /* btActionInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB10F1AF9AA1900B9B856 /* btActionInterface.h */; }; + B6CAB3E71AF9AA1A00B9B856 /* btDiscreteDynamicsWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1101AF9AA1900B9B856 /* btDiscreteDynamicsWorld.cpp */; }; + B6CAB3E81AF9AA1A00B9B856 /* btDiscreteDynamicsWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1101AF9AA1900B9B856 /* btDiscreteDynamicsWorld.cpp */; }; + B6CAB3E91AF9AA1A00B9B856 /* btDiscreteDynamicsWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1111AF9AA1900B9B856 /* btDiscreteDynamicsWorld.h */; }; + B6CAB3EA1AF9AA1A00B9B856 /* btDiscreteDynamicsWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1111AF9AA1900B9B856 /* btDiscreteDynamicsWorld.h */; }; + B6CAB3EB1AF9AA1A00B9B856 /* btDynamicsWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1121AF9AA1900B9B856 /* btDynamicsWorld.h */; }; + B6CAB3EC1AF9AA1A00B9B856 /* btDynamicsWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1121AF9AA1900B9B856 /* btDynamicsWorld.h */; }; + B6CAB3ED1AF9AA1A00B9B856 /* btRigidBody.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1131AF9AA1900B9B856 /* btRigidBody.cpp */; }; + B6CAB3EE1AF9AA1A00B9B856 /* btRigidBody.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1131AF9AA1900B9B856 /* btRigidBody.cpp */; }; + B6CAB3EF1AF9AA1A00B9B856 /* btRigidBody.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1141AF9AA1900B9B856 /* btRigidBody.h */; }; + B6CAB3F01AF9AA1A00B9B856 /* btRigidBody.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1141AF9AA1900B9B856 /* btRigidBody.h */; }; + B6CAB3F11AF9AA1A00B9B856 /* btSimpleDynamicsWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1151AF9AA1900B9B856 /* btSimpleDynamicsWorld.cpp */; }; + B6CAB3F21AF9AA1A00B9B856 /* btSimpleDynamicsWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1151AF9AA1900B9B856 /* btSimpleDynamicsWorld.cpp */; }; + B6CAB3F31AF9AA1A00B9B856 /* btSimpleDynamicsWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1161AF9AA1900B9B856 /* btSimpleDynamicsWorld.h */; }; + B6CAB3F41AF9AA1A00B9B856 /* btSimpleDynamicsWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1161AF9AA1900B9B856 /* btSimpleDynamicsWorld.h */; }; + B6CAB3F51AF9AA1A00B9B856 /* Bullet-C-API.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1171AF9AA1900B9B856 /* Bullet-C-API.cpp */; }; + B6CAB3F61AF9AA1A00B9B856 /* Bullet-C-API.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1171AF9AA1900B9B856 /* Bullet-C-API.cpp */; }; + B6CAB3F71AF9AA1A00B9B856 /* btMultiBody.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1191AF9AA1900B9B856 /* btMultiBody.cpp */; }; + B6CAB3F81AF9AA1A00B9B856 /* btMultiBody.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1191AF9AA1900B9B856 /* btMultiBody.cpp */; }; + B6CAB3F91AF9AA1A00B9B856 /* btMultiBody.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB11A1AF9AA1900B9B856 /* btMultiBody.h */; }; + B6CAB3FA1AF9AA1A00B9B856 /* btMultiBody.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB11A1AF9AA1900B9B856 /* btMultiBody.h */; }; + B6CAB3FB1AF9AA1A00B9B856 /* btMultiBodyConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB11B1AF9AA1900B9B856 /* btMultiBodyConstraint.cpp */; }; + B6CAB3FC1AF9AA1A00B9B856 /* btMultiBodyConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB11B1AF9AA1900B9B856 /* btMultiBodyConstraint.cpp */; }; + B6CAB3FD1AF9AA1A00B9B856 /* btMultiBodyConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB11C1AF9AA1900B9B856 /* btMultiBodyConstraint.h */; }; + B6CAB3FE1AF9AA1A00B9B856 /* btMultiBodyConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB11C1AF9AA1900B9B856 /* btMultiBodyConstraint.h */; }; + B6CAB3FF1AF9AA1A00B9B856 /* btMultiBodyConstraintSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB11D1AF9AA1900B9B856 /* btMultiBodyConstraintSolver.cpp */; }; + B6CAB4001AF9AA1A00B9B856 /* btMultiBodyConstraintSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB11D1AF9AA1900B9B856 /* btMultiBodyConstraintSolver.cpp */; }; + B6CAB4011AF9AA1A00B9B856 /* btMultiBodyConstraintSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB11E1AF9AA1900B9B856 /* btMultiBodyConstraintSolver.h */; }; + B6CAB4021AF9AA1A00B9B856 /* btMultiBodyConstraintSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB11E1AF9AA1900B9B856 /* btMultiBodyConstraintSolver.h */; }; + B6CAB4031AF9AA1A00B9B856 /* btMultiBodyDynamicsWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB11F1AF9AA1900B9B856 /* btMultiBodyDynamicsWorld.cpp */; }; + B6CAB4041AF9AA1A00B9B856 /* btMultiBodyDynamicsWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB11F1AF9AA1900B9B856 /* btMultiBodyDynamicsWorld.cpp */; }; + B6CAB4051AF9AA1A00B9B856 /* btMultiBodyDynamicsWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1201AF9AA1900B9B856 /* btMultiBodyDynamicsWorld.h */; }; + B6CAB4061AF9AA1A00B9B856 /* btMultiBodyDynamicsWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1201AF9AA1900B9B856 /* btMultiBodyDynamicsWorld.h */; }; + B6CAB4071AF9AA1A00B9B856 /* btMultiBodyJointLimitConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1211AF9AA1900B9B856 /* btMultiBodyJointLimitConstraint.cpp */; }; + B6CAB4081AF9AA1A00B9B856 /* btMultiBodyJointLimitConstraint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1211AF9AA1900B9B856 /* btMultiBodyJointLimitConstraint.cpp */; }; + B6CAB4091AF9AA1A00B9B856 /* btMultiBodyJointLimitConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1221AF9AA1900B9B856 /* btMultiBodyJointLimitConstraint.h */; }; + B6CAB40A1AF9AA1A00B9B856 /* btMultiBodyJointLimitConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1221AF9AA1900B9B856 /* btMultiBodyJointLimitConstraint.h */; }; + B6CAB40B1AF9AA1A00B9B856 /* btMultiBodyJointMotor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1231AF9AA1900B9B856 /* btMultiBodyJointMotor.cpp */; }; + B6CAB40C1AF9AA1A00B9B856 /* btMultiBodyJointMotor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1231AF9AA1900B9B856 /* btMultiBodyJointMotor.cpp */; }; + B6CAB40D1AF9AA1A00B9B856 /* btMultiBodyJointMotor.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1241AF9AA1900B9B856 /* btMultiBodyJointMotor.h */; }; + B6CAB40E1AF9AA1A00B9B856 /* btMultiBodyJointMotor.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1241AF9AA1900B9B856 /* btMultiBodyJointMotor.h */; }; + B6CAB40F1AF9AA1A00B9B856 /* btMultiBodyLink.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1251AF9AA1900B9B856 /* btMultiBodyLink.h */; }; + B6CAB4101AF9AA1A00B9B856 /* btMultiBodyLink.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1251AF9AA1900B9B856 /* btMultiBodyLink.h */; }; + B6CAB4111AF9AA1A00B9B856 /* btMultiBodyLinkCollider.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1261AF9AA1900B9B856 /* btMultiBodyLinkCollider.h */; }; + B6CAB4121AF9AA1A00B9B856 /* btMultiBodyLinkCollider.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1261AF9AA1900B9B856 /* btMultiBodyLinkCollider.h */; }; + B6CAB4131AF9AA1A00B9B856 /* btMultiBodyPoint2Point.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1271AF9AA1900B9B856 /* btMultiBodyPoint2Point.cpp */; }; + B6CAB4141AF9AA1A00B9B856 /* btMultiBodyPoint2Point.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1271AF9AA1900B9B856 /* btMultiBodyPoint2Point.cpp */; }; + B6CAB4151AF9AA1A00B9B856 /* btMultiBodyPoint2Point.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1281AF9AA1900B9B856 /* btMultiBodyPoint2Point.h */; }; + B6CAB4161AF9AA1A00B9B856 /* btMultiBodyPoint2Point.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1281AF9AA1900B9B856 /* btMultiBodyPoint2Point.h */; }; + B6CAB4171AF9AA1A00B9B856 /* btMultiBodySolverConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1291AF9AA1900B9B856 /* btMultiBodySolverConstraint.h */; }; + B6CAB4181AF9AA1A00B9B856 /* btMultiBodySolverConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1291AF9AA1900B9B856 /* btMultiBodySolverConstraint.h */; }; + B6CAB4191AF9AA1A00B9B856 /* btDantzigLCP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB12B1AF9AA1900B9B856 /* btDantzigLCP.cpp */; }; + B6CAB41A1AF9AA1A00B9B856 /* btDantzigLCP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB12B1AF9AA1900B9B856 /* btDantzigLCP.cpp */; }; + B6CAB41B1AF9AA1A00B9B856 /* btDantzigLCP.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB12C1AF9AA1900B9B856 /* btDantzigLCP.h */; }; + B6CAB41C1AF9AA1A00B9B856 /* btDantzigLCP.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB12C1AF9AA1900B9B856 /* btDantzigLCP.h */; }; + B6CAB41D1AF9AA1A00B9B856 /* btDantzigSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB12D1AF9AA1900B9B856 /* btDantzigSolver.h */; }; + B6CAB41E1AF9AA1A00B9B856 /* btDantzigSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB12D1AF9AA1900B9B856 /* btDantzigSolver.h */; }; + B6CAB41F1AF9AA1A00B9B856 /* btMLCPSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB12E1AF9AA1900B9B856 /* btMLCPSolver.cpp */; }; + B6CAB4201AF9AA1A00B9B856 /* btMLCPSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB12E1AF9AA1900B9B856 /* btMLCPSolver.cpp */; }; + B6CAB4211AF9AA1A00B9B856 /* btMLCPSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB12F1AF9AA1900B9B856 /* btMLCPSolver.h */; }; + B6CAB4221AF9AA1A00B9B856 /* btMLCPSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB12F1AF9AA1900B9B856 /* btMLCPSolver.h */; }; + B6CAB4231AF9AA1A00B9B856 /* btMLCPSolverInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1301AF9AA1900B9B856 /* btMLCPSolverInterface.h */; }; + B6CAB4241AF9AA1A00B9B856 /* btMLCPSolverInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1301AF9AA1900B9B856 /* btMLCPSolverInterface.h */; }; + B6CAB4251AF9AA1A00B9B856 /* btPATHSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1311AF9AA1900B9B856 /* btPATHSolver.h */; }; + B6CAB4261AF9AA1A00B9B856 /* btPATHSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1311AF9AA1900B9B856 /* btPATHSolver.h */; }; + B6CAB4271AF9AA1A00B9B856 /* btSolveProjectedGaussSeidel.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1321AF9AA1900B9B856 /* btSolveProjectedGaussSeidel.h */; }; + B6CAB4281AF9AA1A00B9B856 /* btSolveProjectedGaussSeidel.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1321AF9AA1900B9B856 /* btSolveProjectedGaussSeidel.h */; }; + B6CAB4291AF9AA1A00B9B856 /* btRaycastVehicle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1341AF9AA1900B9B856 /* btRaycastVehicle.cpp */; }; + B6CAB42A1AF9AA1A00B9B856 /* btRaycastVehicle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1341AF9AA1900B9B856 /* btRaycastVehicle.cpp */; }; + B6CAB42B1AF9AA1A00B9B856 /* btRaycastVehicle.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1351AF9AA1900B9B856 /* btRaycastVehicle.h */; }; + B6CAB42C1AF9AA1A00B9B856 /* btRaycastVehicle.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1351AF9AA1900B9B856 /* btRaycastVehicle.h */; }; + B6CAB42D1AF9AA1A00B9B856 /* btVehicleRaycaster.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1361AF9AA1900B9B856 /* btVehicleRaycaster.h */; }; + B6CAB42E1AF9AA1A00B9B856 /* btVehicleRaycaster.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1361AF9AA1900B9B856 /* btVehicleRaycaster.h */; }; + B6CAB42F1AF9AA1A00B9B856 /* btWheelInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1371AF9AA1900B9B856 /* btWheelInfo.cpp */; }; + B6CAB4301AF9AA1A00B9B856 /* btWheelInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1371AF9AA1900B9B856 /* btWheelInfo.cpp */; }; + B6CAB4311AF9AA1A00B9B856 /* btWheelInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1381AF9AA1900B9B856 /* btWheelInfo.h */; }; + B6CAB4321AF9AA1A00B9B856 /* btWheelInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1381AF9AA1900B9B856 /* btWheelInfo.h */; }; + B6CAB4331AF9AA1A00B9B856 /* btGpu3DGridBroadphase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB13A1AF9AA1900B9B856 /* btGpu3DGridBroadphase.cpp */; }; + B6CAB4341AF9AA1A00B9B856 /* btGpu3DGridBroadphase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB13A1AF9AA1900B9B856 /* btGpu3DGridBroadphase.cpp */; }; + B6CAB4351AF9AA1A00B9B856 /* btGpu3DGridBroadphase.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB13B1AF9AA1900B9B856 /* btGpu3DGridBroadphase.h */; }; + B6CAB4361AF9AA1A00B9B856 /* btGpu3DGridBroadphase.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB13B1AF9AA1900B9B856 /* btGpu3DGridBroadphase.h */; }; + B6CAB4371AF9AA1A00B9B856 /* btGpu3DGridBroadphaseSharedCode.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB13C1AF9AA1900B9B856 /* btGpu3DGridBroadphaseSharedCode.h */; }; + B6CAB4381AF9AA1A00B9B856 /* btGpu3DGridBroadphaseSharedCode.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB13C1AF9AA1900B9B856 /* btGpu3DGridBroadphaseSharedCode.h */; }; + B6CAB4391AF9AA1A00B9B856 /* btGpu3DGridBroadphaseSharedDefs.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB13D1AF9AA1900B9B856 /* btGpu3DGridBroadphaseSharedDefs.h */; }; + B6CAB43A1AF9AA1A00B9B856 /* btGpu3DGridBroadphaseSharedDefs.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB13D1AF9AA1900B9B856 /* btGpu3DGridBroadphaseSharedDefs.h */; }; + B6CAB43B1AF9AA1A00B9B856 /* btGpu3DGridBroadphaseSharedTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB13E1AF9AA1900B9B856 /* btGpu3DGridBroadphaseSharedTypes.h */; }; + B6CAB43C1AF9AA1A00B9B856 /* btGpu3DGridBroadphaseSharedTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB13E1AF9AA1900B9B856 /* btGpu3DGridBroadphaseSharedTypes.h */; }; + B6CAB43D1AF9AA1A00B9B856 /* btGpuDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB13F1AF9AA1900B9B856 /* btGpuDefines.h */; }; + B6CAB43E1AF9AA1A00B9B856 /* btGpuDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB13F1AF9AA1900B9B856 /* btGpuDefines.h */; }; + B6CAB43F1AF9AA1A00B9B856 /* btGpuUtilsSharedCode.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1401AF9AA1900B9B856 /* btGpuUtilsSharedCode.h */; }; + B6CAB4401AF9AA1A00B9B856 /* btGpuUtilsSharedCode.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1401AF9AA1900B9B856 /* btGpuUtilsSharedCode.h */; }; + B6CAB4411AF9AA1A00B9B856 /* btGpuUtilsSharedDefs.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1411AF9AA1900B9B856 /* btGpuUtilsSharedDefs.h */; }; + B6CAB4421AF9AA1A00B9B856 /* btGpuUtilsSharedDefs.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1411AF9AA1900B9B856 /* btGpuUtilsSharedDefs.h */; }; + B6CAB4431AF9AA1A00B9B856 /* btParallelConstraintSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1421AF9AA1900B9B856 /* btParallelConstraintSolver.cpp */; }; + B6CAB4441AF9AA1A00B9B856 /* btParallelConstraintSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1421AF9AA1900B9B856 /* btParallelConstraintSolver.cpp */; }; + B6CAB4451AF9AA1A00B9B856 /* btParallelConstraintSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1431AF9AA1900B9B856 /* btParallelConstraintSolver.h */; }; + B6CAB4461AF9AA1A00B9B856 /* btParallelConstraintSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1431AF9AA1900B9B856 /* btParallelConstraintSolver.h */; }; + B6CAB4471AF9AA1A00B9B856 /* btThreadSupportInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1441AF9AA1900B9B856 /* btThreadSupportInterface.cpp */; }; + B6CAB4481AF9AA1A00B9B856 /* btThreadSupportInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1441AF9AA1900B9B856 /* btThreadSupportInterface.cpp */; }; + B6CAB4491AF9AA1A00B9B856 /* btThreadSupportInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1451AF9AA1900B9B856 /* btThreadSupportInterface.h */; }; + B6CAB44A1AF9AA1A00B9B856 /* btThreadSupportInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1451AF9AA1900B9B856 /* btThreadSupportInterface.h */; }; + B6CAB49B1AF9AA1A00B9B856 /* HeapManager.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1841AF9AA1A00B9B856 /* HeapManager.h */; }; + B6CAB49C1AF9AA1A00B9B856 /* HeapManager.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1841AF9AA1A00B9B856 /* HeapManager.h */; }; + B6CAB49D1AF9AA1A00B9B856 /* PlatformDefinitions.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1851AF9AA1A00B9B856 /* PlatformDefinitions.h */; }; + B6CAB49E1AF9AA1A00B9B856 /* PlatformDefinitions.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1851AF9AA1A00B9B856 /* PlatformDefinitions.h */; }; + B6CAB49F1AF9AA1A00B9B856 /* PosixThreadSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1861AF9AA1A00B9B856 /* PosixThreadSupport.cpp */; }; + B6CAB4A01AF9AA1A00B9B856 /* PosixThreadSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1861AF9AA1A00B9B856 /* PosixThreadSupport.cpp */; }; + B6CAB4A11AF9AA1A00B9B856 /* PosixThreadSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1871AF9AA1A00B9B856 /* PosixThreadSupport.h */; }; + B6CAB4A21AF9AA1A00B9B856 /* PosixThreadSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1871AF9AA1A00B9B856 /* PosixThreadSupport.h */; }; + B6CAB4A31AF9AA1A00B9B856 /* PpuAddressSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1881AF9AA1A00B9B856 /* PpuAddressSpace.h */; }; + B6CAB4A41AF9AA1A00B9B856 /* PpuAddressSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1881AF9AA1A00B9B856 /* PpuAddressSpace.h */; }; + B6CAB4A51AF9AA1A00B9B856 /* SequentialThreadSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1891AF9AA1A00B9B856 /* SequentialThreadSupport.cpp */; }; + B6CAB4A61AF9AA1A00B9B856 /* SequentialThreadSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1891AF9AA1A00B9B856 /* SequentialThreadSupport.cpp */; }; + B6CAB4A71AF9AA1A00B9B856 /* SequentialThreadSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB18A1AF9AA1A00B9B856 /* SequentialThreadSupport.h */; }; + B6CAB4A81AF9AA1A00B9B856 /* SequentialThreadSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB18A1AF9AA1A00B9B856 /* SequentialThreadSupport.h */; }; + B6CAB4A91AF9AA1A00B9B856 /* SpuCollisionObjectWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB18B1AF9AA1A00B9B856 /* SpuCollisionObjectWrapper.cpp */; }; + B6CAB4AA1AF9AA1A00B9B856 /* SpuCollisionObjectWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB18B1AF9AA1A00B9B856 /* SpuCollisionObjectWrapper.cpp */; }; + B6CAB4AB1AF9AA1A00B9B856 /* SpuCollisionObjectWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB18C1AF9AA1A00B9B856 /* SpuCollisionObjectWrapper.h */; }; + B6CAB4AC1AF9AA1A00B9B856 /* SpuCollisionObjectWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB18C1AF9AA1A00B9B856 /* SpuCollisionObjectWrapper.h */; }; + B6CAB4AD1AF9AA1A00B9B856 /* SpuCollisionTaskProcess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB18D1AF9AA1A00B9B856 /* SpuCollisionTaskProcess.cpp */; }; + B6CAB4AE1AF9AA1A00B9B856 /* SpuCollisionTaskProcess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB18D1AF9AA1A00B9B856 /* SpuCollisionTaskProcess.cpp */; }; + B6CAB4AF1AF9AA1A00B9B856 /* SpuCollisionTaskProcess.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB18E1AF9AA1A00B9B856 /* SpuCollisionTaskProcess.h */; }; + B6CAB4B01AF9AA1A00B9B856 /* SpuCollisionTaskProcess.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB18E1AF9AA1A00B9B856 /* SpuCollisionTaskProcess.h */; }; + B6CAB4B11AF9AA1A00B9B856 /* SpuContactManifoldCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB18F1AF9AA1A00B9B856 /* SpuContactManifoldCollisionAlgorithm.cpp */; }; + B6CAB4B21AF9AA1A00B9B856 /* SpuContactManifoldCollisionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB18F1AF9AA1A00B9B856 /* SpuContactManifoldCollisionAlgorithm.cpp */; }; + B6CAB4B31AF9AA1A00B9B856 /* SpuContactManifoldCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1901AF9AA1A00B9B856 /* SpuContactManifoldCollisionAlgorithm.h */; }; + B6CAB4B41AF9AA1A00B9B856 /* SpuContactManifoldCollisionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1901AF9AA1A00B9B856 /* SpuContactManifoldCollisionAlgorithm.h */; }; + B6CAB4B51AF9AA1A00B9B856 /* SpuDoubleBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1911AF9AA1A00B9B856 /* SpuDoubleBuffer.h */; }; + B6CAB4B61AF9AA1A00B9B856 /* SpuDoubleBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1911AF9AA1A00B9B856 /* SpuDoubleBuffer.h */; }; + B6CAB4B71AF9AA1A00B9B856 /* SpuFakeDma.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1921AF9AA1A00B9B856 /* SpuFakeDma.cpp */; }; + B6CAB4B81AF9AA1A00B9B856 /* SpuFakeDma.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1921AF9AA1A00B9B856 /* SpuFakeDma.cpp */; }; + B6CAB4B91AF9AA1A00B9B856 /* SpuFakeDma.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1931AF9AA1A00B9B856 /* SpuFakeDma.h */; }; + B6CAB4BA1AF9AA1A00B9B856 /* SpuFakeDma.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1931AF9AA1A00B9B856 /* SpuFakeDma.h */; }; + B6CAB4BB1AF9AA1A00B9B856 /* SpuGatheringCollisionDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1941AF9AA1A00B9B856 /* SpuGatheringCollisionDispatcher.cpp */; }; + B6CAB4BC1AF9AA1A00B9B856 /* SpuGatheringCollisionDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1941AF9AA1A00B9B856 /* SpuGatheringCollisionDispatcher.cpp */; }; + B6CAB4BD1AF9AA1A00B9B856 /* SpuGatheringCollisionDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1951AF9AA1A00B9B856 /* SpuGatheringCollisionDispatcher.h */; }; + B6CAB4BE1AF9AA1A00B9B856 /* SpuGatheringCollisionDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1951AF9AA1A00B9B856 /* SpuGatheringCollisionDispatcher.h */; }; + B6CAB4BF1AF9AA1A00B9B856 /* SpuLibspe2Support.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1961AF9AA1A00B9B856 /* SpuLibspe2Support.cpp */; }; + B6CAB4C01AF9AA1A00B9B856 /* SpuLibspe2Support.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1961AF9AA1A00B9B856 /* SpuLibspe2Support.cpp */; }; + B6CAB4C11AF9AA1A00B9B856 /* SpuLibspe2Support.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1971AF9AA1A00B9B856 /* SpuLibspe2Support.h */; }; + B6CAB4C21AF9AA1A00B9B856 /* SpuLibspe2Support.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1971AF9AA1A00B9B856 /* SpuLibspe2Support.h */; }; + B6CAB4C31AF9AA1A00B9B856 /* Box.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1991AF9AA1A00B9B856 /* Box.h */; }; + B6CAB4C41AF9AA1A00B9B856 /* Box.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1991AF9AA1A00B9B856 /* Box.h */; }; + B6CAB4C51AF9AA1A00B9B856 /* boxBoxDistance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB19A1AF9AA1A00B9B856 /* boxBoxDistance.cpp */; }; + B6CAB4C61AF9AA1A00B9B856 /* boxBoxDistance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB19A1AF9AA1A00B9B856 /* boxBoxDistance.cpp */; }; + B6CAB4C71AF9AA1A00B9B856 /* boxBoxDistance.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB19B1AF9AA1A00B9B856 /* boxBoxDistance.h */; }; + B6CAB4C81AF9AA1A00B9B856 /* boxBoxDistance.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB19B1AF9AA1A00B9B856 /* boxBoxDistance.h */; }; + B6CAB4C91AF9AA1A00B9B856 /* SpuCollisionShapes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB19C1AF9AA1A00B9B856 /* SpuCollisionShapes.cpp */; }; + B6CAB4CA1AF9AA1A00B9B856 /* SpuCollisionShapes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB19C1AF9AA1A00B9B856 /* SpuCollisionShapes.cpp */; }; + B6CAB4CB1AF9AA1A00B9B856 /* SpuCollisionShapes.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB19D1AF9AA1A00B9B856 /* SpuCollisionShapes.h */; }; + B6CAB4CC1AF9AA1A00B9B856 /* SpuCollisionShapes.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB19D1AF9AA1A00B9B856 /* SpuCollisionShapes.h */; }; + B6CAB4CD1AF9AA1A00B9B856 /* SpuContactResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB19E1AF9AA1A00B9B856 /* SpuContactResult.cpp */; }; + B6CAB4CE1AF9AA1A00B9B856 /* SpuContactResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB19E1AF9AA1A00B9B856 /* SpuContactResult.cpp */; }; + B6CAB4CF1AF9AA1A00B9B856 /* SpuContactResult.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB19F1AF9AA1A00B9B856 /* SpuContactResult.h */; }; + B6CAB4D01AF9AA1A00B9B856 /* SpuContactResult.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB19F1AF9AA1A00B9B856 /* SpuContactResult.h */; }; + B6CAB4D11AF9AA1A00B9B856 /* SpuConvexPenetrationDepthSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1A01AF9AA1A00B9B856 /* SpuConvexPenetrationDepthSolver.h */; }; + B6CAB4D21AF9AA1A00B9B856 /* SpuConvexPenetrationDepthSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1A01AF9AA1A00B9B856 /* SpuConvexPenetrationDepthSolver.h */; }; + B6CAB4D31AF9AA1A00B9B856 /* SpuGatheringCollisionTask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1A11AF9AA1A00B9B856 /* SpuGatheringCollisionTask.cpp */; }; + B6CAB4D41AF9AA1A00B9B856 /* SpuGatheringCollisionTask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1A11AF9AA1A00B9B856 /* SpuGatheringCollisionTask.cpp */; }; + B6CAB4D51AF9AA1A00B9B856 /* SpuGatheringCollisionTask.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1A21AF9AA1A00B9B856 /* SpuGatheringCollisionTask.h */; }; + B6CAB4D61AF9AA1A00B9B856 /* SpuGatheringCollisionTask.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1A21AF9AA1A00B9B856 /* SpuGatheringCollisionTask.h */; }; + B6CAB4D71AF9AA1A00B9B856 /* SpuLocalSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1A31AF9AA1A00B9B856 /* SpuLocalSupport.h */; }; + B6CAB4D81AF9AA1A00B9B856 /* SpuLocalSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1A31AF9AA1A00B9B856 /* SpuLocalSupport.h */; }; + B6CAB4D91AF9AA1A00B9B856 /* SpuMinkowskiPenetrationDepthSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1A41AF9AA1A00B9B856 /* SpuMinkowskiPenetrationDepthSolver.cpp */; }; + B6CAB4DA1AF9AA1A00B9B856 /* SpuMinkowskiPenetrationDepthSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1A41AF9AA1A00B9B856 /* SpuMinkowskiPenetrationDepthSolver.cpp */; }; + B6CAB4DB1AF9AA1A00B9B856 /* SpuMinkowskiPenetrationDepthSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1A51AF9AA1A00B9B856 /* SpuMinkowskiPenetrationDepthSolver.h */; }; + B6CAB4DC1AF9AA1A00B9B856 /* SpuMinkowskiPenetrationDepthSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1A51AF9AA1A00B9B856 /* SpuMinkowskiPenetrationDepthSolver.h */; }; + B6CAB4DD1AF9AA1A00B9B856 /* SpuPreferredPenetrationDirections.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1A61AF9AA1A00B9B856 /* SpuPreferredPenetrationDirections.h */; }; + B6CAB4DE1AF9AA1A00B9B856 /* SpuPreferredPenetrationDirections.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1A61AF9AA1A00B9B856 /* SpuPreferredPenetrationDirections.h */; }; + B6CAB4DF1AF9AA1A00B9B856 /* SpuSampleTask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1A81AF9AA1A00B9B856 /* SpuSampleTask.cpp */; }; + B6CAB4E01AF9AA1A00B9B856 /* SpuSampleTask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1A81AF9AA1A00B9B856 /* SpuSampleTask.cpp */; }; + B6CAB4E11AF9AA1A00B9B856 /* SpuSampleTask.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1A91AF9AA1A00B9B856 /* SpuSampleTask.h */; }; + B6CAB4E21AF9AA1A00B9B856 /* SpuSampleTask.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1A91AF9AA1A00B9B856 /* SpuSampleTask.h */; }; + B6CAB4E31AF9AA1A00B9B856 /* SpuSampleTaskProcess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1AA1AF9AA1A00B9B856 /* SpuSampleTaskProcess.cpp */; }; + B6CAB4E41AF9AA1A00B9B856 /* SpuSampleTaskProcess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1AA1AF9AA1A00B9B856 /* SpuSampleTaskProcess.cpp */; }; + B6CAB4E51AF9AA1A00B9B856 /* SpuSampleTaskProcess.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1AB1AF9AA1A00B9B856 /* SpuSampleTaskProcess.h */; }; + B6CAB4E61AF9AA1A00B9B856 /* SpuSampleTaskProcess.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1AB1AF9AA1A00B9B856 /* SpuSampleTaskProcess.h */; }; + B6CAB4E71AF9AA1A00B9B856 /* SpuSync.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1AC1AF9AA1A00B9B856 /* SpuSync.h */; }; + B6CAB4E81AF9AA1A00B9B856 /* SpuSync.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1AC1AF9AA1A00B9B856 /* SpuSync.h */; }; + B6CAB4E91AF9AA1A00B9B856 /* TrbDynBody.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1AD1AF9AA1A00B9B856 /* TrbDynBody.h */; }; + B6CAB4EA1AF9AA1A00B9B856 /* TrbDynBody.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1AD1AF9AA1A00B9B856 /* TrbDynBody.h */; }; + B6CAB4EB1AF9AA1A00B9B856 /* TrbStateVec.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1AE1AF9AA1A00B9B856 /* TrbStateVec.h */; }; + B6CAB4EC1AF9AA1A00B9B856 /* TrbStateVec.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1AE1AF9AA1A00B9B856 /* TrbStateVec.h */; }; + B6CAB4ED1AF9AA1A00B9B856 /* vectormath2bullet.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1AF1AF9AA1A00B9B856 /* vectormath2bullet.h */; }; + B6CAB4EE1AF9AA1A00B9B856 /* vectormath2bullet.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1AF1AF9AA1A00B9B856 /* vectormath2bullet.h */; }; + B6CAB4EF1AF9AA1A00B9B856 /* Win32ThreadSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1B01AF9AA1A00B9B856 /* Win32ThreadSupport.cpp */; }; + B6CAB4F01AF9AA1A00B9B856 /* Win32ThreadSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1B01AF9AA1A00B9B856 /* Win32ThreadSupport.cpp */; }; + B6CAB4F11AF9AA1A00B9B856 /* Win32ThreadSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1B11AF9AA1A00B9B856 /* Win32ThreadSupport.h */; }; + B6CAB4F21AF9AA1A00B9B856 /* Win32ThreadSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1B11AF9AA1A00B9B856 /* Win32ThreadSupport.h */; }; + B6CAB4F31AF9AA1A00B9B856 /* btAabbUtil2.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1B31AF9AA1A00B9B856 /* btAabbUtil2.h */; }; + B6CAB4F41AF9AA1A00B9B856 /* btAabbUtil2.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1B31AF9AA1A00B9B856 /* btAabbUtil2.h */; }; + B6CAB4F51AF9AA1A00B9B856 /* btAlignedAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1B41AF9AA1A00B9B856 /* btAlignedAllocator.cpp */; }; + B6CAB4F61AF9AA1A00B9B856 /* btAlignedAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1B41AF9AA1A00B9B856 /* btAlignedAllocator.cpp */; }; + B6CAB4F71AF9AA1A00B9B856 /* btAlignedAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1B51AF9AA1A00B9B856 /* btAlignedAllocator.h */; }; + B6CAB4F81AF9AA1A00B9B856 /* btAlignedAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1B51AF9AA1A00B9B856 /* btAlignedAllocator.h */; }; + B6CAB4F91AF9AA1A00B9B856 /* btAlignedObjectArray.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1B61AF9AA1A00B9B856 /* btAlignedObjectArray.h */; }; + B6CAB4FA1AF9AA1A00B9B856 /* btAlignedObjectArray.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1B61AF9AA1A00B9B856 /* btAlignedObjectArray.h */; }; + B6CAB4FB1AF9AA1A00B9B856 /* btConvexHull.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1B71AF9AA1A00B9B856 /* btConvexHull.cpp */; }; + B6CAB4FC1AF9AA1A00B9B856 /* btConvexHull.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1B71AF9AA1A00B9B856 /* btConvexHull.cpp */; }; + B6CAB4FD1AF9AA1A00B9B856 /* btConvexHull.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1B81AF9AA1A00B9B856 /* btConvexHull.h */; }; + B6CAB4FE1AF9AA1A00B9B856 /* btConvexHull.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1B81AF9AA1A00B9B856 /* btConvexHull.h */; }; + B6CAB4FF1AF9AA1A00B9B856 /* btConvexHullComputer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1B91AF9AA1A00B9B856 /* btConvexHullComputer.cpp */; }; + B6CAB5001AF9AA1A00B9B856 /* btConvexHullComputer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1B91AF9AA1A00B9B856 /* btConvexHullComputer.cpp */; }; + B6CAB5011AF9AA1A00B9B856 /* btConvexHullComputer.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1BA1AF9AA1A00B9B856 /* btConvexHullComputer.h */; }; + B6CAB5021AF9AA1A00B9B856 /* btConvexHullComputer.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1BA1AF9AA1A00B9B856 /* btConvexHullComputer.h */; }; + B6CAB5031AF9AA1A00B9B856 /* btDefaultMotionState.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1BB1AF9AA1A00B9B856 /* btDefaultMotionState.h */; }; + B6CAB5041AF9AA1A00B9B856 /* btDefaultMotionState.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1BB1AF9AA1A00B9B856 /* btDefaultMotionState.h */; }; + B6CAB5051AF9AA1A00B9B856 /* btGeometryUtil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1BC1AF9AA1A00B9B856 /* btGeometryUtil.cpp */; }; + B6CAB5061AF9AA1A00B9B856 /* btGeometryUtil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1BC1AF9AA1A00B9B856 /* btGeometryUtil.cpp */; }; + B6CAB5071AF9AA1A00B9B856 /* btGeometryUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1BD1AF9AA1A00B9B856 /* btGeometryUtil.h */; }; + B6CAB5081AF9AA1A00B9B856 /* btGeometryUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1BD1AF9AA1A00B9B856 /* btGeometryUtil.h */; }; + B6CAB5091AF9AA1A00B9B856 /* btGrahamScan2dConvexHull.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1BE1AF9AA1A00B9B856 /* btGrahamScan2dConvexHull.h */; }; + B6CAB50A1AF9AA1A00B9B856 /* btGrahamScan2dConvexHull.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1BE1AF9AA1A00B9B856 /* btGrahamScan2dConvexHull.h */; }; + B6CAB50B1AF9AA1A00B9B856 /* btHashMap.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1BF1AF9AA1A00B9B856 /* btHashMap.h */; }; + B6CAB50C1AF9AA1A00B9B856 /* btHashMap.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1BF1AF9AA1A00B9B856 /* btHashMap.h */; }; + B6CAB50D1AF9AA1A00B9B856 /* btIDebugDraw.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1C01AF9AA1A00B9B856 /* btIDebugDraw.h */; }; + B6CAB50E1AF9AA1A00B9B856 /* btIDebugDraw.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1C01AF9AA1A00B9B856 /* btIDebugDraw.h */; }; + B6CAB50F1AF9AA1A00B9B856 /* btList.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1C11AF9AA1A00B9B856 /* btList.h */; }; + B6CAB5101AF9AA1A00B9B856 /* btList.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1C11AF9AA1A00B9B856 /* btList.h */; }; + B6CAB5111AF9AA1A00B9B856 /* btMatrix3x3.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1C21AF9AA1A00B9B856 /* btMatrix3x3.h */; }; + B6CAB5121AF9AA1A00B9B856 /* btMatrix3x3.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1C21AF9AA1A00B9B856 /* btMatrix3x3.h */; }; + B6CAB5131AF9AA1A00B9B856 /* btMatrixX.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1C31AF9AA1A00B9B856 /* btMatrixX.h */; }; + B6CAB5141AF9AA1A00B9B856 /* btMatrixX.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1C31AF9AA1A00B9B856 /* btMatrixX.h */; }; + B6CAB5151AF9AA1A00B9B856 /* btMinMax.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1C41AF9AA1A00B9B856 /* btMinMax.h */; }; + B6CAB5161AF9AA1A00B9B856 /* btMinMax.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1C41AF9AA1A00B9B856 /* btMinMax.h */; }; + B6CAB5171AF9AA1A00B9B856 /* btMotionState.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1C51AF9AA1A00B9B856 /* btMotionState.h */; }; + B6CAB5181AF9AA1A00B9B856 /* btMotionState.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1C51AF9AA1A00B9B856 /* btMotionState.h */; }; + B6CAB5191AF9AA1A00B9B856 /* btPolarDecomposition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1C61AF9AA1A00B9B856 /* btPolarDecomposition.cpp */; }; + B6CAB51A1AF9AA1A00B9B856 /* btPolarDecomposition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1C61AF9AA1A00B9B856 /* btPolarDecomposition.cpp */; }; + B6CAB51B1AF9AA1A00B9B856 /* btPolarDecomposition.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1C71AF9AA1A00B9B856 /* btPolarDecomposition.h */; }; + B6CAB51C1AF9AA1A00B9B856 /* btPolarDecomposition.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1C71AF9AA1A00B9B856 /* btPolarDecomposition.h */; }; + B6CAB51D1AF9AA1A00B9B856 /* btPoolAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1C81AF9AA1A00B9B856 /* btPoolAllocator.h */; }; + B6CAB51E1AF9AA1A00B9B856 /* btPoolAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1C81AF9AA1A00B9B856 /* btPoolAllocator.h */; }; + B6CAB51F1AF9AA1A00B9B856 /* btQuadWord.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1C91AF9AA1A00B9B856 /* btQuadWord.h */; }; + B6CAB5201AF9AA1A00B9B856 /* btQuadWord.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1C91AF9AA1A00B9B856 /* btQuadWord.h */; }; + B6CAB5211AF9AA1A00B9B856 /* btQuaternion.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1CA1AF9AA1A00B9B856 /* btQuaternion.h */; }; + B6CAB5221AF9AA1A00B9B856 /* btQuaternion.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1CA1AF9AA1A00B9B856 /* btQuaternion.h */; }; + B6CAB5231AF9AA1A00B9B856 /* btQuickprof.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1CB1AF9AA1A00B9B856 /* btQuickprof.cpp */; }; + B6CAB5241AF9AA1A00B9B856 /* btQuickprof.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1CB1AF9AA1A00B9B856 /* btQuickprof.cpp */; }; + B6CAB5251AF9AA1A00B9B856 /* btQuickprof.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1CC1AF9AA1A00B9B856 /* btQuickprof.h */; }; + B6CAB5261AF9AA1A00B9B856 /* btQuickprof.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1CC1AF9AA1A00B9B856 /* btQuickprof.h */; }; + B6CAB5271AF9AA1A00B9B856 /* btRandom.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1CD1AF9AA1A00B9B856 /* btRandom.h */; }; + B6CAB5281AF9AA1A00B9B856 /* btRandom.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1CD1AF9AA1A00B9B856 /* btRandom.h */; }; + B6CAB5291AF9AA1A00B9B856 /* btScalar.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1CE1AF9AA1A00B9B856 /* btScalar.h */; }; + B6CAB52A1AF9AA1A00B9B856 /* btScalar.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1CE1AF9AA1A00B9B856 /* btScalar.h */; }; + B6CAB52B1AF9AA1A00B9B856 /* btSerializer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1CF1AF9AA1A00B9B856 /* btSerializer.cpp */; }; + B6CAB52C1AF9AA1A00B9B856 /* btSerializer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1CF1AF9AA1A00B9B856 /* btSerializer.cpp */; }; + B6CAB52D1AF9AA1A00B9B856 /* btSerializer.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1D01AF9AA1A00B9B856 /* btSerializer.h */; }; + B6CAB52E1AF9AA1A00B9B856 /* btSerializer.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1D01AF9AA1A00B9B856 /* btSerializer.h */; }; + B6CAB52F1AF9AA1A00B9B856 /* btStackAlloc.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1D11AF9AA1A00B9B856 /* btStackAlloc.h */; }; + B6CAB5301AF9AA1A00B9B856 /* btStackAlloc.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1D11AF9AA1A00B9B856 /* btStackAlloc.h */; }; + B6CAB5311AF9AA1A00B9B856 /* btTransform.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1D21AF9AA1A00B9B856 /* btTransform.h */; }; + B6CAB5321AF9AA1A00B9B856 /* btTransform.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1D21AF9AA1A00B9B856 /* btTransform.h */; }; + B6CAB5331AF9AA1A00B9B856 /* btTransformUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1D31AF9AA1A00B9B856 /* btTransformUtil.h */; }; + B6CAB5341AF9AA1A00B9B856 /* btTransformUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1D31AF9AA1A00B9B856 /* btTransformUtil.h */; }; + B6CAB5351AF9AA1A00B9B856 /* btVector3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1D41AF9AA1A00B9B856 /* btVector3.cpp */; }; + B6CAB5361AF9AA1A00B9B856 /* btVector3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1D41AF9AA1A00B9B856 /* btVector3.cpp */; }; + B6CAB5371AF9AA1A00B9B856 /* btVector3.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1D51AF9AA1A00B9B856 /* btVector3.h */; }; + B6CAB5381AF9AA1A00B9B856 /* btVector3.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1D51AF9AA1A00B9B856 /* btVector3.h */; }; + B6CAB5391AF9AA1A00B9B856 /* cl.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1D71AF9AA1A00B9B856 /* cl.h */; }; + B6CAB53A1AF9AA1A00B9B856 /* cl.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1D71AF9AA1A00B9B856 /* cl.h */; }; + B6CAB53B1AF9AA1A00B9B856 /* cl_gl.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1D81AF9AA1A00B9B856 /* cl_gl.h */; }; + B6CAB53C1AF9AA1A00B9B856 /* cl_gl.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1D81AF9AA1A00B9B856 /* cl_gl.h */; }; + B6CAB53D1AF9AA1A00B9B856 /* cl_MiniCL_Defs.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1D91AF9AA1A00B9B856 /* cl_MiniCL_Defs.h */; }; + B6CAB53E1AF9AA1A00B9B856 /* cl_MiniCL_Defs.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1D91AF9AA1A00B9B856 /* cl_MiniCL_Defs.h */; }; + B6CAB53F1AF9AA1A00B9B856 /* cl_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1DA1AF9AA1A00B9B856 /* cl_platform.h */; }; + B6CAB5401AF9AA1A00B9B856 /* cl_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1DA1AF9AA1A00B9B856 /* cl_platform.h */; }; + B6CAB5411AF9AA1A00B9B856 /* MiniCL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1DB1AF9AA1A00B9B856 /* MiniCL.cpp */; }; + B6CAB5421AF9AA1A00B9B856 /* MiniCL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1DB1AF9AA1A00B9B856 /* MiniCL.cpp */; }; + B6CAB5431AF9AA1A00B9B856 /* MiniCLTask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1DD1AF9AA1A00B9B856 /* MiniCLTask.cpp */; }; + B6CAB5441AF9AA1A00B9B856 /* MiniCLTask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1DD1AF9AA1A00B9B856 /* MiniCLTask.cpp */; }; + B6CAB5451AF9AA1A00B9B856 /* MiniCLTask.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1DE1AF9AA1A00B9B856 /* MiniCLTask.h */; }; + B6CAB5461AF9AA1A00B9B856 /* MiniCLTask.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1DE1AF9AA1A00B9B856 /* MiniCLTask.h */; }; + B6CAB5471AF9AA1A00B9B856 /* MiniCLTaskScheduler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1DF1AF9AA1A00B9B856 /* MiniCLTaskScheduler.cpp */; }; + B6CAB5481AF9AA1A00B9B856 /* MiniCLTaskScheduler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB1DF1AF9AA1A00B9B856 /* MiniCLTaskScheduler.cpp */; }; + B6CAB5491AF9AA1A00B9B856 /* MiniCLTaskScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1E01AF9AA1A00B9B856 /* MiniCLTaskScheduler.h */; }; + B6CAB54A1AF9AA1A00B9B856 /* MiniCLTaskScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CAB1E01AF9AA1A00B9B856 /* MiniCLTaskScheduler.h */; }; B6D38B8A1AC3AFAC00043997 /* CCSkybox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D38B861AC3AFAC00043997 /* CCSkybox.cpp */; }; B6D38B8B1AC3AFAC00043997 /* CCSkybox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6D38B861AC3AFAC00043997 /* CCSkybox.cpp */; }; B6D38B8C1AC3AFAC00043997 /* CCSkybox.h in Headers */ = {isa = PBXBuildFile; fileRef = B6D38B871AC3AFAC00043997 /* CCSkybox.h */; }; @@ -3343,6 +4185,14 @@ 46C02E0618E91123004B7456 /* xxhash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xxhash.h; sourceTree = ""; }; 4D76BE381A4AAF0A00102962 /* CCActionTimelineNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionTimelineNode.cpp; sourceTree = ""; }; 4D76BE391A4AAF0A00102962 /* CCActionTimelineNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionTimelineNode.h; sourceTree = ""; }; + 5012168C1AC47380009A4BEA /* CCRenderState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCRenderState.cpp; sourceTree = ""; }; + 5012168D1AC47380009A4BEA /* CCRenderState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCRenderState.h; sourceTree = ""; }; + 501216921AC47393009A4BEA /* CCPass.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPass.cpp; sourceTree = ""; }; + 501216931AC47393009A4BEA /* CCPass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPass.h; sourceTree = ""; }; + 501216981AC473A3009A4BEA /* CCTechnique.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTechnique.cpp; sourceTree = ""; }; + 501216991AC473A3009A4BEA /* CCTechnique.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTechnique.h; sourceTree = ""; }; + 5012169E1AC473AD009A4BEA /* CCMaterial.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCMaterial.cpp; sourceTree = ""; }; + 5012169F1AC473AD009A4BEA /* CCMaterial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMaterial.h; sourceTree = ""; }; 50272538190BF1B900AAF4ED /* cocos2d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cocos2d.h; path = ../cocos/cocos2d.h; sourceTree = ""; }; 50272539190BF1B900AAF4ED /* cocos2d.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cocos2d.cpp; path = ../cocos/cocos2d.cpp; sourceTree = ""; }; 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureColorAlphaTest.frag; sourceTree = ""; }; @@ -4035,6 +4885,419 @@ B68778F51A8CA82E00643ABF /* CCParticle3DRender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCParticle3DRender.h; path = Particle3D/CCParticle3DRender.h; sourceTree = ""; }; B68778F61A8CA82E00643ABF /* CCParticleSystem3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCParticleSystem3D.cpp; path = Particle3D/CCParticleSystem3D.cpp; sourceTree = ""; }; B68778F71A8CA82E00643ABF /* CCParticleSystem3D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCParticleSystem3D.h; path = Particle3D/CCParticleSystem3D.h; sourceTree = ""; }; + B6CAAFD21AF9A9E100B9B856 /* CCPhysics3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCPhysics3D.cpp; path = ../cocos/physics3d/CCPhysics3D.cpp; sourceTree = ""; }; + B6CAAFD31AF9A9E100B9B856 /* CCPhysics3D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCPhysics3D.h; path = ../cocos/physics3d/CCPhysics3D.h; sourceTree = ""; }; + B6CAAFD41AF9A9E100B9B856 /* CCPhysics3DComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCPhysics3DComponent.cpp; path = ../cocos/physics3d/CCPhysics3DComponent.cpp; sourceTree = ""; }; + B6CAAFD51AF9A9E100B9B856 /* CCPhysics3DComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCPhysics3DComponent.h; path = ../cocos/physics3d/CCPhysics3DComponent.h; sourceTree = ""; }; + B6CAAFD61AF9A9E100B9B856 /* CCPhysics3DConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCPhysics3DConstraint.cpp; path = ../cocos/physics3d/CCPhysics3DConstraint.cpp; sourceTree = ""; }; + B6CAAFD71AF9A9E100B9B856 /* CCPhysics3DConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCPhysics3DConstraint.h; path = ../cocos/physics3d/CCPhysics3DConstraint.h; sourceTree = ""; }; + B6CAAFD81AF9A9E100B9B856 /* CCPhysics3DDebugDrawer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCPhysics3DDebugDrawer.cpp; path = ../cocos/physics3d/CCPhysics3DDebugDrawer.cpp; sourceTree = ""; }; + B6CAAFD91AF9A9E100B9B856 /* CCPhysics3DDebugDrawer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCPhysics3DDebugDrawer.h; path = ../cocos/physics3d/CCPhysics3DDebugDrawer.h; sourceTree = ""; }; + B6CAAFDA1AF9A9E100B9B856 /* CCPhysics3DObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCPhysics3DObject.cpp; path = ../cocos/physics3d/CCPhysics3DObject.cpp; sourceTree = ""; }; + B6CAAFDB1AF9A9E100B9B856 /* CCPhysics3DObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCPhysics3DObject.h; path = ../cocos/physics3d/CCPhysics3DObject.h; sourceTree = ""; }; + B6CAAFDC1AF9A9E100B9B856 /* CCPhysics3DShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCPhysics3DShape.cpp; path = ../cocos/physics3d/CCPhysics3DShape.cpp; sourceTree = ""; }; + B6CAAFDD1AF9A9E100B9B856 /* CCPhysics3DShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCPhysics3DShape.h; path = ../cocos/physics3d/CCPhysics3DShape.h; sourceTree = ""; }; + B6CAAFDE1AF9A9E100B9B856 /* CCPhysics3DWorld.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCPhysics3DWorld.cpp; path = ../cocos/physics3d/CCPhysics3DWorld.cpp; sourceTree = ""; }; + B6CAAFDF1AF9A9E100B9B856 /* CCPhysics3DWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCPhysics3DWorld.h; path = ../cocos/physics3d/CCPhysics3DWorld.h; sourceTree = ""; }; + B6CAAFE01AF9A9E100B9B856 /* CCPhysicsSprite3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCPhysicsSprite3D.cpp; path = ../cocos/physics3d/CCPhysicsSprite3D.cpp; sourceTree = ""; }; + B6CAAFE11AF9A9E100B9B856 /* CCPhysicsSprite3D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCPhysicsSprite3D.h; path = ../cocos/physics3d/CCPhysicsSprite3D.h; sourceTree = ""; }; + B6CAB0031AF9AA1900B9B856 /* btBulletCollisionCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = btBulletCollisionCommon.h; path = ../external/bullet/btBulletCollisionCommon.h; sourceTree = ""; }; + B6CAB0041AF9AA1900B9B856 /* btBulletDynamicsCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = btBulletDynamicsCommon.h; path = ../external/bullet/btBulletDynamicsCommon.h; sourceTree = ""; }; + B6CAB0051AF9AA1900B9B856 /* Bullet-C-Api.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "Bullet-C-Api.h"; path = "../external/bullet/Bullet-C-Api.h"; sourceTree = ""; }; + B6CAB0081AF9AA1900B9B856 /* btAxisSweep3.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btAxisSweep3.cpp; sourceTree = ""; }; + B6CAB0091AF9AA1900B9B856 /* btAxisSweep3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btAxisSweep3.h; sourceTree = ""; }; + B6CAB00A1AF9AA1900B9B856 /* btBroadphaseInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btBroadphaseInterface.h; sourceTree = ""; }; + B6CAB00B1AF9AA1900B9B856 /* btBroadphaseProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btBroadphaseProxy.cpp; sourceTree = ""; }; + B6CAB00C1AF9AA1900B9B856 /* btBroadphaseProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btBroadphaseProxy.h; sourceTree = ""; }; + B6CAB00D1AF9AA1900B9B856 /* btCollisionAlgorithm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btCollisionAlgorithm.cpp; sourceTree = ""; }; + B6CAB00E1AF9AA1900B9B856 /* btCollisionAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btCollisionAlgorithm.h; sourceTree = ""; }; + B6CAB00F1AF9AA1900B9B856 /* btDbvt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btDbvt.cpp; sourceTree = ""; }; + B6CAB0101AF9AA1900B9B856 /* btDbvt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btDbvt.h; sourceTree = ""; }; + B6CAB0111AF9AA1900B9B856 /* btDbvtBroadphase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btDbvtBroadphase.cpp; sourceTree = ""; }; + B6CAB0121AF9AA1900B9B856 /* btDbvtBroadphase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btDbvtBroadphase.h; sourceTree = ""; }; + B6CAB0131AF9AA1900B9B856 /* btDispatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btDispatcher.cpp; sourceTree = ""; }; + B6CAB0141AF9AA1900B9B856 /* btDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btDispatcher.h; sourceTree = ""; }; + B6CAB0151AF9AA1900B9B856 /* btMultiSapBroadphase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btMultiSapBroadphase.cpp; sourceTree = ""; }; + B6CAB0161AF9AA1900B9B856 /* btMultiSapBroadphase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMultiSapBroadphase.h; sourceTree = ""; }; + B6CAB0171AF9AA1900B9B856 /* btOverlappingPairCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btOverlappingPairCache.cpp; sourceTree = ""; }; + B6CAB0181AF9AA1900B9B856 /* btOverlappingPairCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btOverlappingPairCache.h; sourceTree = ""; }; + B6CAB0191AF9AA1900B9B856 /* btOverlappingPairCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btOverlappingPairCallback.h; sourceTree = ""; }; + B6CAB01A1AF9AA1900B9B856 /* btQuantizedBvh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btQuantizedBvh.cpp; sourceTree = ""; }; + B6CAB01B1AF9AA1900B9B856 /* btQuantizedBvh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btQuantizedBvh.h; sourceTree = ""; }; + B6CAB01C1AF9AA1900B9B856 /* btSimpleBroadphase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btSimpleBroadphase.cpp; sourceTree = ""; }; + B6CAB01D1AF9AA1900B9B856 /* btSimpleBroadphase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btSimpleBroadphase.h; sourceTree = ""; }; + B6CAB01F1AF9AA1900B9B856 /* btActivatingCollisionAlgorithm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btActivatingCollisionAlgorithm.cpp; sourceTree = ""; }; + B6CAB0201AF9AA1900B9B856 /* btActivatingCollisionAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btActivatingCollisionAlgorithm.h; sourceTree = ""; }; + B6CAB0211AF9AA1900B9B856 /* btBox2dBox2dCollisionAlgorithm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btBox2dBox2dCollisionAlgorithm.cpp; sourceTree = ""; }; + B6CAB0221AF9AA1900B9B856 /* btBox2dBox2dCollisionAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btBox2dBox2dCollisionAlgorithm.h; sourceTree = ""; }; + B6CAB0231AF9AA1900B9B856 /* btBoxBoxCollisionAlgorithm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btBoxBoxCollisionAlgorithm.cpp; sourceTree = ""; }; + B6CAB0241AF9AA1900B9B856 /* btBoxBoxCollisionAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btBoxBoxCollisionAlgorithm.h; sourceTree = ""; }; + B6CAB0251AF9AA1900B9B856 /* btBoxBoxDetector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btBoxBoxDetector.cpp; sourceTree = ""; }; + B6CAB0261AF9AA1900B9B856 /* btBoxBoxDetector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btBoxBoxDetector.h; sourceTree = ""; }; + B6CAB0271AF9AA1900B9B856 /* btCollisionConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btCollisionConfiguration.h; sourceTree = ""; }; + B6CAB0281AF9AA1900B9B856 /* btCollisionCreateFunc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btCollisionCreateFunc.h; sourceTree = ""; }; + B6CAB0291AF9AA1900B9B856 /* btCollisionDispatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btCollisionDispatcher.cpp; sourceTree = ""; }; + B6CAB02A1AF9AA1900B9B856 /* btCollisionDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btCollisionDispatcher.h; sourceTree = ""; }; + B6CAB02B1AF9AA1900B9B856 /* btCollisionObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btCollisionObject.cpp; sourceTree = ""; }; + B6CAB02C1AF9AA1900B9B856 /* btCollisionObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btCollisionObject.h; sourceTree = ""; }; + B6CAB02D1AF9AA1900B9B856 /* btCollisionObjectWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btCollisionObjectWrapper.h; sourceTree = ""; }; + B6CAB02E1AF9AA1900B9B856 /* btCollisionWorld.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btCollisionWorld.cpp; sourceTree = ""; }; + B6CAB02F1AF9AA1900B9B856 /* btCollisionWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btCollisionWorld.h; sourceTree = ""; }; + B6CAB0301AF9AA1900B9B856 /* btCompoundCollisionAlgorithm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btCompoundCollisionAlgorithm.cpp; sourceTree = ""; }; + B6CAB0311AF9AA1900B9B856 /* btCompoundCollisionAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btCompoundCollisionAlgorithm.h; sourceTree = ""; }; + B6CAB0321AF9AA1900B9B856 /* btCompoundCompoundCollisionAlgorithm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btCompoundCompoundCollisionAlgorithm.cpp; sourceTree = ""; }; + B6CAB0331AF9AA1900B9B856 /* btCompoundCompoundCollisionAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btCompoundCompoundCollisionAlgorithm.h; sourceTree = ""; }; + B6CAB0341AF9AA1900B9B856 /* btConvex2dConvex2dAlgorithm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btConvex2dConvex2dAlgorithm.cpp; sourceTree = ""; }; + B6CAB0351AF9AA1900B9B856 /* btConvex2dConvex2dAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btConvex2dConvex2dAlgorithm.h; sourceTree = ""; }; + B6CAB0361AF9AA1900B9B856 /* btConvexConcaveCollisionAlgorithm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btConvexConcaveCollisionAlgorithm.cpp; sourceTree = ""; }; + B6CAB0371AF9AA1900B9B856 /* btConvexConcaveCollisionAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btConvexConcaveCollisionAlgorithm.h; sourceTree = ""; }; + B6CAB0381AF9AA1900B9B856 /* btConvexConvexAlgorithm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btConvexConvexAlgorithm.cpp; sourceTree = ""; }; + B6CAB0391AF9AA1900B9B856 /* btConvexConvexAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btConvexConvexAlgorithm.h; sourceTree = ""; }; + B6CAB03A1AF9AA1900B9B856 /* btConvexPlaneCollisionAlgorithm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btConvexPlaneCollisionAlgorithm.cpp; sourceTree = ""; }; + B6CAB03B1AF9AA1900B9B856 /* btConvexPlaneCollisionAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btConvexPlaneCollisionAlgorithm.h; sourceTree = ""; }; + B6CAB03C1AF9AA1900B9B856 /* btDefaultCollisionConfiguration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btDefaultCollisionConfiguration.cpp; sourceTree = ""; }; + B6CAB03D1AF9AA1900B9B856 /* btDefaultCollisionConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btDefaultCollisionConfiguration.h; sourceTree = ""; }; + B6CAB03E1AF9AA1900B9B856 /* btEmptyCollisionAlgorithm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btEmptyCollisionAlgorithm.cpp; sourceTree = ""; }; + B6CAB03F1AF9AA1900B9B856 /* btEmptyCollisionAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btEmptyCollisionAlgorithm.h; sourceTree = ""; }; + B6CAB0401AF9AA1900B9B856 /* btGhostObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btGhostObject.cpp; sourceTree = ""; }; + B6CAB0411AF9AA1900B9B856 /* btGhostObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGhostObject.h; sourceTree = ""; }; + B6CAB0421AF9AA1900B9B856 /* btHashedSimplePairCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btHashedSimplePairCache.cpp; sourceTree = ""; }; + B6CAB0431AF9AA1900B9B856 /* btHashedSimplePairCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btHashedSimplePairCache.h; sourceTree = ""; }; + B6CAB0441AF9AA1900B9B856 /* btInternalEdgeUtility.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btInternalEdgeUtility.cpp; sourceTree = ""; }; + B6CAB0451AF9AA1900B9B856 /* btInternalEdgeUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btInternalEdgeUtility.h; sourceTree = ""; }; + B6CAB0461AF9AA1900B9B856 /* btManifoldResult.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btManifoldResult.cpp; sourceTree = ""; }; + B6CAB0471AF9AA1900B9B856 /* btManifoldResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btManifoldResult.h; sourceTree = ""; }; + B6CAB0481AF9AA1900B9B856 /* btSimulationIslandManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btSimulationIslandManager.cpp; sourceTree = ""; }; + B6CAB0491AF9AA1900B9B856 /* btSimulationIslandManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btSimulationIslandManager.h; sourceTree = ""; }; + B6CAB04A1AF9AA1900B9B856 /* btSphereBoxCollisionAlgorithm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btSphereBoxCollisionAlgorithm.cpp; sourceTree = ""; }; + B6CAB04B1AF9AA1900B9B856 /* btSphereBoxCollisionAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btSphereBoxCollisionAlgorithm.h; sourceTree = ""; }; + B6CAB04C1AF9AA1900B9B856 /* btSphereSphereCollisionAlgorithm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btSphereSphereCollisionAlgorithm.cpp; sourceTree = ""; }; + B6CAB04D1AF9AA1900B9B856 /* btSphereSphereCollisionAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btSphereSphereCollisionAlgorithm.h; sourceTree = ""; }; + B6CAB04E1AF9AA1900B9B856 /* btSphereTriangleCollisionAlgorithm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btSphereTriangleCollisionAlgorithm.cpp; sourceTree = ""; }; + B6CAB04F1AF9AA1900B9B856 /* btSphereTriangleCollisionAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btSphereTriangleCollisionAlgorithm.h; sourceTree = ""; }; + B6CAB0501AF9AA1900B9B856 /* btUnionFind.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btUnionFind.cpp; sourceTree = ""; }; + B6CAB0511AF9AA1900B9B856 /* btUnionFind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btUnionFind.h; sourceTree = ""; }; + B6CAB0521AF9AA1900B9B856 /* SphereTriangleDetector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SphereTriangleDetector.cpp; sourceTree = ""; }; + B6CAB0531AF9AA1900B9B856 /* SphereTriangleDetector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SphereTriangleDetector.h; sourceTree = ""; }; + B6CAB0551AF9AA1900B9B856 /* btBox2dShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btBox2dShape.cpp; sourceTree = ""; }; + B6CAB0561AF9AA1900B9B856 /* btBox2dShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btBox2dShape.h; sourceTree = ""; }; + B6CAB0571AF9AA1900B9B856 /* btBoxShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btBoxShape.cpp; sourceTree = ""; }; + B6CAB0581AF9AA1900B9B856 /* btBoxShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btBoxShape.h; sourceTree = ""; }; + B6CAB0591AF9AA1900B9B856 /* btBvhTriangleMeshShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btBvhTriangleMeshShape.cpp; sourceTree = ""; }; + B6CAB05A1AF9AA1900B9B856 /* btBvhTriangleMeshShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btBvhTriangleMeshShape.h; sourceTree = ""; }; + B6CAB05B1AF9AA1900B9B856 /* btCapsuleShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btCapsuleShape.cpp; sourceTree = ""; }; + B6CAB05C1AF9AA1900B9B856 /* btCapsuleShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btCapsuleShape.h; sourceTree = ""; }; + B6CAB05D1AF9AA1900B9B856 /* btCollisionMargin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btCollisionMargin.h; sourceTree = ""; }; + B6CAB05E1AF9AA1900B9B856 /* btCollisionShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btCollisionShape.cpp; sourceTree = ""; }; + B6CAB05F1AF9AA1900B9B856 /* btCollisionShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btCollisionShape.h; sourceTree = ""; }; + B6CAB0601AF9AA1900B9B856 /* btCompoundShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btCompoundShape.cpp; sourceTree = ""; }; + B6CAB0611AF9AA1900B9B856 /* btCompoundShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btCompoundShape.h; sourceTree = ""; }; + B6CAB0621AF9AA1900B9B856 /* btConcaveShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btConcaveShape.cpp; sourceTree = ""; }; + B6CAB0631AF9AA1900B9B856 /* btConcaveShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btConcaveShape.h; sourceTree = ""; }; + B6CAB0641AF9AA1900B9B856 /* btConeShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btConeShape.cpp; sourceTree = ""; }; + B6CAB0651AF9AA1900B9B856 /* btConeShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btConeShape.h; sourceTree = ""; }; + B6CAB0661AF9AA1900B9B856 /* btConvex2dShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btConvex2dShape.cpp; sourceTree = ""; }; + B6CAB0671AF9AA1900B9B856 /* btConvex2dShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btConvex2dShape.h; sourceTree = ""; }; + B6CAB0681AF9AA1900B9B856 /* btConvexHullShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btConvexHullShape.cpp; sourceTree = ""; }; + B6CAB0691AF9AA1900B9B856 /* btConvexHullShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btConvexHullShape.h; sourceTree = ""; }; + B6CAB06A1AF9AA1900B9B856 /* btConvexInternalShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btConvexInternalShape.cpp; sourceTree = ""; }; + B6CAB06B1AF9AA1900B9B856 /* btConvexInternalShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btConvexInternalShape.h; sourceTree = ""; }; + B6CAB06C1AF9AA1900B9B856 /* btConvexPointCloudShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btConvexPointCloudShape.cpp; sourceTree = ""; }; + B6CAB06D1AF9AA1900B9B856 /* btConvexPointCloudShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btConvexPointCloudShape.h; sourceTree = ""; }; + B6CAB06E1AF9AA1900B9B856 /* btConvexPolyhedron.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btConvexPolyhedron.cpp; sourceTree = ""; }; + B6CAB06F1AF9AA1900B9B856 /* btConvexPolyhedron.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btConvexPolyhedron.h; sourceTree = ""; }; + B6CAB0701AF9AA1900B9B856 /* btConvexShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btConvexShape.cpp; sourceTree = ""; }; + B6CAB0711AF9AA1900B9B856 /* btConvexShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btConvexShape.h; sourceTree = ""; }; + B6CAB0721AF9AA1900B9B856 /* btConvexTriangleMeshShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btConvexTriangleMeshShape.cpp; sourceTree = ""; }; + B6CAB0731AF9AA1900B9B856 /* btConvexTriangleMeshShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btConvexTriangleMeshShape.h; sourceTree = ""; }; + B6CAB0741AF9AA1900B9B856 /* btCylinderShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btCylinderShape.cpp; sourceTree = ""; }; + B6CAB0751AF9AA1900B9B856 /* btCylinderShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btCylinderShape.h; sourceTree = ""; }; + B6CAB0761AF9AA1900B9B856 /* btEmptyShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btEmptyShape.cpp; sourceTree = ""; }; + B6CAB0771AF9AA1900B9B856 /* btEmptyShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btEmptyShape.h; sourceTree = ""; }; + B6CAB0781AF9AA1900B9B856 /* btHeightfieldTerrainShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btHeightfieldTerrainShape.cpp; sourceTree = ""; }; + B6CAB0791AF9AA1900B9B856 /* btHeightfieldTerrainShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btHeightfieldTerrainShape.h; sourceTree = ""; }; + B6CAB07A1AF9AA1900B9B856 /* btMaterial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMaterial.h; sourceTree = ""; }; + B6CAB07B1AF9AA1900B9B856 /* btMinkowskiSumShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btMinkowskiSumShape.cpp; sourceTree = ""; }; + B6CAB07C1AF9AA1900B9B856 /* btMinkowskiSumShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMinkowskiSumShape.h; sourceTree = ""; }; + B6CAB07D1AF9AA1900B9B856 /* btMultimaterialTriangleMeshShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btMultimaterialTriangleMeshShape.cpp; sourceTree = ""; }; + B6CAB07E1AF9AA1900B9B856 /* btMultimaterialTriangleMeshShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMultimaterialTriangleMeshShape.h; sourceTree = ""; }; + B6CAB07F1AF9AA1900B9B856 /* btMultiSphereShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btMultiSphereShape.cpp; sourceTree = ""; }; + B6CAB0801AF9AA1900B9B856 /* btMultiSphereShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMultiSphereShape.h; sourceTree = ""; }; + B6CAB0811AF9AA1900B9B856 /* btOptimizedBvh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btOptimizedBvh.cpp; sourceTree = ""; }; + B6CAB0821AF9AA1900B9B856 /* btOptimizedBvh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btOptimizedBvh.h; sourceTree = ""; }; + B6CAB0831AF9AA1900B9B856 /* btPolyhedralConvexShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btPolyhedralConvexShape.cpp; sourceTree = ""; }; + B6CAB0841AF9AA1900B9B856 /* btPolyhedralConvexShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btPolyhedralConvexShape.h; sourceTree = ""; }; + B6CAB0851AF9AA1900B9B856 /* btScaledBvhTriangleMeshShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btScaledBvhTriangleMeshShape.cpp; sourceTree = ""; }; + B6CAB0861AF9AA1900B9B856 /* btScaledBvhTriangleMeshShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btScaledBvhTriangleMeshShape.h; sourceTree = ""; }; + B6CAB0871AF9AA1900B9B856 /* btShapeHull.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btShapeHull.cpp; sourceTree = ""; }; + B6CAB0881AF9AA1900B9B856 /* btShapeHull.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btShapeHull.h; sourceTree = ""; }; + B6CAB0891AF9AA1900B9B856 /* btSphereShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btSphereShape.cpp; sourceTree = ""; }; + B6CAB08A1AF9AA1900B9B856 /* btSphereShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btSphereShape.h; sourceTree = ""; }; + B6CAB08B1AF9AA1900B9B856 /* btStaticPlaneShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btStaticPlaneShape.cpp; sourceTree = ""; }; + B6CAB08C1AF9AA1900B9B856 /* btStaticPlaneShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btStaticPlaneShape.h; sourceTree = ""; }; + B6CAB08D1AF9AA1900B9B856 /* btStridingMeshInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btStridingMeshInterface.cpp; sourceTree = ""; }; + B6CAB08E1AF9AA1900B9B856 /* btStridingMeshInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btStridingMeshInterface.h; sourceTree = ""; }; + B6CAB08F1AF9AA1900B9B856 /* btTetrahedronShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btTetrahedronShape.cpp; sourceTree = ""; }; + B6CAB0901AF9AA1900B9B856 /* btTetrahedronShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btTetrahedronShape.h; sourceTree = ""; }; + B6CAB0911AF9AA1900B9B856 /* btTriangleBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btTriangleBuffer.cpp; sourceTree = ""; }; + B6CAB0921AF9AA1900B9B856 /* btTriangleBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btTriangleBuffer.h; sourceTree = ""; }; + B6CAB0931AF9AA1900B9B856 /* btTriangleCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btTriangleCallback.cpp; sourceTree = ""; }; + B6CAB0941AF9AA1900B9B856 /* btTriangleCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btTriangleCallback.h; sourceTree = ""; }; + B6CAB0951AF9AA1900B9B856 /* btTriangleIndexVertexArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btTriangleIndexVertexArray.cpp; sourceTree = ""; }; + B6CAB0961AF9AA1900B9B856 /* btTriangleIndexVertexArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btTriangleIndexVertexArray.h; sourceTree = ""; }; + B6CAB0971AF9AA1900B9B856 /* btTriangleIndexVertexMaterialArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btTriangleIndexVertexMaterialArray.cpp; sourceTree = ""; }; + B6CAB0981AF9AA1900B9B856 /* btTriangleIndexVertexMaterialArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btTriangleIndexVertexMaterialArray.h; sourceTree = ""; }; + B6CAB0991AF9AA1900B9B856 /* btTriangleInfoMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btTriangleInfoMap.h; sourceTree = ""; }; + B6CAB09A1AF9AA1900B9B856 /* btTriangleMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btTriangleMesh.cpp; sourceTree = ""; }; + B6CAB09B1AF9AA1900B9B856 /* btTriangleMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btTriangleMesh.h; sourceTree = ""; }; + B6CAB09C1AF9AA1900B9B856 /* btTriangleMeshShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btTriangleMeshShape.cpp; sourceTree = ""; }; + B6CAB09D1AF9AA1900B9B856 /* btTriangleMeshShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btTriangleMeshShape.h; sourceTree = ""; }; + B6CAB09E1AF9AA1900B9B856 /* btTriangleShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btTriangleShape.h; sourceTree = ""; }; + B6CAB09F1AF9AA1900B9B856 /* btUniformScalingShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btUniformScalingShape.cpp; sourceTree = ""; }; + B6CAB0A01AF9AA1900B9B856 /* btUniformScalingShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btUniformScalingShape.h; sourceTree = ""; }; + B6CAB0A21AF9AA1900B9B856 /* btBoxCollision.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btBoxCollision.h; sourceTree = ""; }; + B6CAB0A31AF9AA1900B9B856 /* btClipPolygon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btClipPolygon.h; sourceTree = ""; }; + B6CAB0A41AF9AA1900B9B856 /* btCompoundFromGimpact.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btCompoundFromGimpact.h; sourceTree = ""; }; + B6CAB0A51AF9AA1900B9B856 /* btContactProcessing.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btContactProcessing.cpp; sourceTree = ""; }; + B6CAB0A61AF9AA1900B9B856 /* btContactProcessing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btContactProcessing.h; sourceTree = ""; }; + B6CAB0A71AF9AA1900B9B856 /* btGenericPoolAllocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btGenericPoolAllocator.cpp; sourceTree = ""; }; + B6CAB0A81AF9AA1900B9B856 /* btGenericPoolAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGenericPoolAllocator.h; sourceTree = ""; }; + B6CAB0A91AF9AA1900B9B856 /* btGeometryOperations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGeometryOperations.h; sourceTree = ""; }; + B6CAB0AA1AF9AA1900B9B856 /* btGImpactBvh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btGImpactBvh.cpp; sourceTree = ""; }; + B6CAB0AB1AF9AA1900B9B856 /* btGImpactBvh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGImpactBvh.h; sourceTree = ""; }; + B6CAB0AC1AF9AA1900B9B856 /* btGImpactCollisionAlgorithm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btGImpactCollisionAlgorithm.cpp; sourceTree = ""; }; + B6CAB0AD1AF9AA1900B9B856 /* btGImpactCollisionAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGImpactCollisionAlgorithm.h; sourceTree = ""; }; + B6CAB0AE1AF9AA1900B9B856 /* btGImpactMassUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGImpactMassUtil.h; sourceTree = ""; }; + B6CAB0AF1AF9AA1900B9B856 /* btGImpactQuantizedBvh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btGImpactQuantizedBvh.cpp; sourceTree = ""; }; + B6CAB0B01AF9AA1900B9B856 /* btGImpactQuantizedBvh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGImpactQuantizedBvh.h; sourceTree = ""; }; + B6CAB0B11AF9AA1900B9B856 /* btGImpactShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btGImpactShape.cpp; sourceTree = ""; }; + B6CAB0B21AF9AA1900B9B856 /* btGImpactShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGImpactShape.h; sourceTree = ""; }; + B6CAB0B31AF9AA1900B9B856 /* btQuantization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btQuantization.h; sourceTree = ""; }; + B6CAB0B41AF9AA1900B9B856 /* btTriangleShapeEx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btTriangleShapeEx.cpp; sourceTree = ""; }; + B6CAB0B51AF9AA1900B9B856 /* btTriangleShapeEx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btTriangleShapeEx.h; sourceTree = ""; }; + B6CAB0B61AF9AA1900B9B856 /* gim_array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gim_array.h; sourceTree = ""; }; + B6CAB0B71AF9AA1900B9B856 /* gim_basic_geometry_operations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gim_basic_geometry_operations.h; sourceTree = ""; }; + B6CAB0B81AF9AA1900B9B856 /* gim_bitset.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gim_bitset.h; sourceTree = ""; }; + B6CAB0B91AF9AA1900B9B856 /* gim_box_collision.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gim_box_collision.h; sourceTree = ""; }; + B6CAB0BA1AF9AA1900B9B856 /* gim_box_set.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gim_box_set.cpp; sourceTree = ""; }; + B6CAB0BB1AF9AA1900B9B856 /* gim_box_set.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gim_box_set.h; sourceTree = ""; }; + B6CAB0BC1AF9AA1900B9B856 /* gim_clip_polygon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gim_clip_polygon.h; sourceTree = ""; }; + B6CAB0BD1AF9AA1900B9B856 /* gim_contact.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gim_contact.cpp; sourceTree = ""; }; + B6CAB0BE1AF9AA1900B9B856 /* gim_contact.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gim_contact.h; sourceTree = ""; }; + B6CAB0BF1AF9AA1900B9B856 /* gim_geom_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gim_geom_types.h; sourceTree = ""; }; + B6CAB0C01AF9AA1900B9B856 /* gim_geometry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gim_geometry.h; sourceTree = ""; }; + B6CAB0C11AF9AA1900B9B856 /* gim_hash_table.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gim_hash_table.h; sourceTree = ""; }; + B6CAB0C21AF9AA1900B9B856 /* gim_linear_math.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gim_linear_math.h; sourceTree = ""; }; + B6CAB0C31AF9AA1900B9B856 /* gim_math.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gim_math.h; sourceTree = ""; }; + B6CAB0C41AF9AA1900B9B856 /* gim_memory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gim_memory.cpp; sourceTree = ""; }; + B6CAB0C51AF9AA1900B9B856 /* gim_memory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gim_memory.h; sourceTree = ""; }; + B6CAB0C61AF9AA1900B9B856 /* gim_radixsort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gim_radixsort.h; sourceTree = ""; }; + B6CAB0C71AF9AA1900B9B856 /* gim_tri_collision.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gim_tri_collision.cpp; sourceTree = ""; }; + B6CAB0C81AF9AA1900B9B856 /* gim_tri_collision.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gim_tri_collision.h; sourceTree = ""; }; + B6CAB0CA1AF9AA1900B9B856 /* btContinuousConvexCollision.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btContinuousConvexCollision.cpp; sourceTree = ""; }; + B6CAB0CB1AF9AA1900B9B856 /* btContinuousConvexCollision.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btContinuousConvexCollision.h; sourceTree = ""; }; + B6CAB0CC1AF9AA1900B9B856 /* btConvexCast.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btConvexCast.cpp; sourceTree = ""; }; + B6CAB0CD1AF9AA1900B9B856 /* btConvexCast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btConvexCast.h; sourceTree = ""; }; + B6CAB0CE1AF9AA1900B9B856 /* btConvexPenetrationDepthSolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btConvexPenetrationDepthSolver.h; sourceTree = ""; }; + B6CAB0CF1AF9AA1900B9B856 /* btDiscreteCollisionDetectorInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btDiscreteCollisionDetectorInterface.h; sourceTree = ""; }; + B6CAB0D01AF9AA1900B9B856 /* btGjkConvexCast.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btGjkConvexCast.cpp; sourceTree = ""; }; + B6CAB0D11AF9AA1900B9B856 /* btGjkConvexCast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGjkConvexCast.h; sourceTree = ""; }; + B6CAB0D21AF9AA1900B9B856 /* btGjkEpa2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btGjkEpa2.cpp; sourceTree = ""; }; + B6CAB0D31AF9AA1900B9B856 /* btGjkEpa2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGjkEpa2.h; sourceTree = ""; }; + B6CAB0D41AF9AA1900B9B856 /* btGjkEpaPenetrationDepthSolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btGjkEpaPenetrationDepthSolver.cpp; sourceTree = ""; }; + B6CAB0D51AF9AA1900B9B856 /* btGjkEpaPenetrationDepthSolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGjkEpaPenetrationDepthSolver.h; sourceTree = ""; }; + B6CAB0D61AF9AA1900B9B856 /* btGjkPairDetector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btGjkPairDetector.cpp; sourceTree = ""; }; + B6CAB0D71AF9AA1900B9B856 /* btGjkPairDetector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGjkPairDetector.h; sourceTree = ""; }; + B6CAB0D81AF9AA1900B9B856 /* btManifoldPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btManifoldPoint.h; sourceTree = ""; }; + B6CAB0D91AF9AA1900B9B856 /* btMinkowskiPenetrationDepthSolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btMinkowskiPenetrationDepthSolver.cpp; sourceTree = ""; }; + B6CAB0DA1AF9AA1900B9B856 /* btMinkowskiPenetrationDepthSolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMinkowskiPenetrationDepthSolver.h; sourceTree = ""; }; + B6CAB0DB1AF9AA1900B9B856 /* btPersistentManifold.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btPersistentManifold.cpp; sourceTree = ""; }; + B6CAB0DC1AF9AA1900B9B856 /* btPersistentManifold.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btPersistentManifold.h; sourceTree = ""; }; + B6CAB0DD1AF9AA1900B9B856 /* btPointCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btPointCollector.h; sourceTree = ""; }; + B6CAB0DE1AF9AA1900B9B856 /* btPolyhedralContactClipping.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btPolyhedralContactClipping.cpp; sourceTree = ""; }; + B6CAB0DF1AF9AA1900B9B856 /* btPolyhedralContactClipping.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btPolyhedralContactClipping.h; sourceTree = ""; }; + B6CAB0E01AF9AA1900B9B856 /* btRaycastCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btRaycastCallback.cpp; sourceTree = ""; }; + B6CAB0E11AF9AA1900B9B856 /* btRaycastCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btRaycastCallback.h; sourceTree = ""; }; + B6CAB0E21AF9AA1900B9B856 /* btSimplexSolverInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btSimplexSolverInterface.h; sourceTree = ""; }; + B6CAB0E31AF9AA1900B9B856 /* btSubSimplexConvexCast.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btSubSimplexConvexCast.cpp; sourceTree = ""; }; + B6CAB0E41AF9AA1900B9B856 /* btSubSimplexConvexCast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btSubSimplexConvexCast.h; sourceTree = ""; }; + B6CAB0E51AF9AA1900B9B856 /* btVoronoiSimplexSolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btVoronoiSimplexSolver.cpp; sourceTree = ""; }; + B6CAB0E61AF9AA1900B9B856 /* btVoronoiSimplexSolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btVoronoiSimplexSolver.h; sourceTree = ""; }; + B6CAB0E91AF9AA1900B9B856 /* btCharacterControllerInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btCharacterControllerInterface.h; sourceTree = ""; }; + B6CAB0EA1AF9AA1900B9B856 /* btKinematicCharacterController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btKinematicCharacterController.cpp; sourceTree = ""; }; + B6CAB0EB1AF9AA1900B9B856 /* btKinematicCharacterController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btKinematicCharacterController.h; sourceTree = ""; }; + B6CAB0ED1AF9AA1900B9B856 /* btConeTwistConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btConeTwistConstraint.cpp; sourceTree = ""; }; + B6CAB0EE1AF9AA1900B9B856 /* btConeTwistConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btConeTwistConstraint.h; sourceTree = ""; }; + B6CAB0EF1AF9AA1900B9B856 /* btConstraintSolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btConstraintSolver.h; sourceTree = ""; }; + B6CAB0F01AF9AA1900B9B856 /* btContactConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btContactConstraint.cpp; sourceTree = ""; }; + B6CAB0F11AF9AA1900B9B856 /* btContactConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btContactConstraint.h; sourceTree = ""; }; + B6CAB0F21AF9AA1900B9B856 /* btContactSolverInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btContactSolverInfo.h; sourceTree = ""; }; + B6CAB0F31AF9AA1900B9B856 /* btFixedConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btFixedConstraint.cpp; sourceTree = ""; }; + B6CAB0F41AF9AA1900B9B856 /* btFixedConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btFixedConstraint.h; sourceTree = ""; }; + B6CAB0F51AF9AA1900B9B856 /* btGearConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btGearConstraint.cpp; sourceTree = ""; }; + B6CAB0F61AF9AA1900B9B856 /* btGearConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGearConstraint.h; sourceTree = ""; }; + B6CAB0F71AF9AA1900B9B856 /* btGeneric6DofConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btGeneric6DofConstraint.cpp; sourceTree = ""; }; + B6CAB0F81AF9AA1900B9B856 /* btGeneric6DofConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGeneric6DofConstraint.h; sourceTree = ""; }; + B6CAB0F91AF9AA1900B9B856 /* btGeneric6DofSpringConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btGeneric6DofSpringConstraint.cpp; sourceTree = ""; }; + B6CAB0FA1AF9AA1900B9B856 /* btGeneric6DofSpringConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGeneric6DofSpringConstraint.h; sourceTree = ""; }; + B6CAB0FB1AF9AA1900B9B856 /* btHinge2Constraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btHinge2Constraint.cpp; sourceTree = ""; }; + B6CAB0FC1AF9AA1900B9B856 /* btHinge2Constraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btHinge2Constraint.h; sourceTree = ""; }; + B6CAB0FD1AF9AA1900B9B856 /* btHingeConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btHingeConstraint.cpp; sourceTree = ""; }; + B6CAB0FE1AF9AA1900B9B856 /* btHingeConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btHingeConstraint.h; sourceTree = ""; }; + B6CAB0FF1AF9AA1900B9B856 /* btJacobianEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btJacobianEntry.h; sourceTree = ""; }; + B6CAB1001AF9AA1900B9B856 /* btPoint2PointConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btPoint2PointConstraint.cpp; sourceTree = ""; }; + B6CAB1011AF9AA1900B9B856 /* btPoint2PointConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btPoint2PointConstraint.h; sourceTree = ""; }; + B6CAB1021AF9AA1900B9B856 /* btSequentialImpulseConstraintSolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btSequentialImpulseConstraintSolver.cpp; sourceTree = ""; }; + B6CAB1031AF9AA1900B9B856 /* btSequentialImpulseConstraintSolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btSequentialImpulseConstraintSolver.h; sourceTree = ""; }; + B6CAB1041AF9AA1900B9B856 /* btSliderConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btSliderConstraint.cpp; sourceTree = ""; }; + B6CAB1051AF9AA1900B9B856 /* btSliderConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btSliderConstraint.h; sourceTree = ""; }; + B6CAB1061AF9AA1900B9B856 /* btSolve2LinearConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btSolve2LinearConstraint.cpp; sourceTree = ""; }; + B6CAB1071AF9AA1900B9B856 /* btSolve2LinearConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btSolve2LinearConstraint.h; sourceTree = ""; }; + B6CAB1081AF9AA1900B9B856 /* btSolverBody.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btSolverBody.h; sourceTree = ""; }; + B6CAB1091AF9AA1900B9B856 /* btSolverConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btSolverConstraint.h; sourceTree = ""; }; + B6CAB10A1AF9AA1900B9B856 /* btTypedConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btTypedConstraint.cpp; sourceTree = ""; }; + B6CAB10B1AF9AA1900B9B856 /* btTypedConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btTypedConstraint.h; sourceTree = ""; }; + B6CAB10C1AF9AA1900B9B856 /* btUniversalConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btUniversalConstraint.cpp; sourceTree = ""; }; + B6CAB10D1AF9AA1900B9B856 /* btUniversalConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btUniversalConstraint.h; sourceTree = ""; }; + B6CAB10F1AF9AA1900B9B856 /* btActionInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btActionInterface.h; sourceTree = ""; }; + B6CAB1101AF9AA1900B9B856 /* btDiscreteDynamicsWorld.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btDiscreteDynamicsWorld.cpp; sourceTree = ""; }; + B6CAB1111AF9AA1900B9B856 /* btDiscreteDynamicsWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btDiscreteDynamicsWorld.h; sourceTree = ""; }; + B6CAB1121AF9AA1900B9B856 /* btDynamicsWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btDynamicsWorld.h; sourceTree = ""; }; + B6CAB1131AF9AA1900B9B856 /* btRigidBody.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btRigidBody.cpp; sourceTree = ""; }; + B6CAB1141AF9AA1900B9B856 /* btRigidBody.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btRigidBody.h; sourceTree = ""; }; + B6CAB1151AF9AA1900B9B856 /* btSimpleDynamicsWorld.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btSimpleDynamicsWorld.cpp; sourceTree = ""; }; + B6CAB1161AF9AA1900B9B856 /* btSimpleDynamicsWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btSimpleDynamicsWorld.h; sourceTree = ""; }; + B6CAB1171AF9AA1900B9B856 /* Bullet-C-API.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "Bullet-C-API.cpp"; sourceTree = ""; }; + B6CAB1191AF9AA1900B9B856 /* btMultiBody.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btMultiBody.cpp; sourceTree = ""; }; + B6CAB11A1AF9AA1900B9B856 /* btMultiBody.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMultiBody.h; sourceTree = ""; }; + B6CAB11B1AF9AA1900B9B856 /* btMultiBodyConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btMultiBodyConstraint.cpp; sourceTree = ""; }; + B6CAB11C1AF9AA1900B9B856 /* btMultiBodyConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMultiBodyConstraint.h; sourceTree = ""; }; + B6CAB11D1AF9AA1900B9B856 /* btMultiBodyConstraintSolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btMultiBodyConstraintSolver.cpp; sourceTree = ""; }; + B6CAB11E1AF9AA1900B9B856 /* btMultiBodyConstraintSolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMultiBodyConstraintSolver.h; sourceTree = ""; }; + B6CAB11F1AF9AA1900B9B856 /* btMultiBodyDynamicsWorld.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btMultiBodyDynamicsWorld.cpp; sourceTree = ""; }; + B6CAB1201AF9AA1900B9B856 /* btMultiBodyDynamicsWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMultiBodyDynamicsWorld.h; sourceTree = ""; }; + B6CAB1211AF9AA1900B9B856 /* btMultiBodyJointLimitConstraint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btMultiBodyJointLimitConstraint.cpp; sourceTree = ""; }; + B6CAB1221AF9AA1900B9B856 /* btMultiBodyJointLimitConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMultiBodyJointLimitConstraint.h; sourceTree = ""; }; + B6CAB1231AF9AA1900B9B856 /* btMultiBodyJointMotor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btMultiBodyJointMotor.cpp; sourceTree = ""; }; + B6CAB1241AF9AA1900B9B856 /* btMultiBodyJointMotor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMultiBodyJointMotor.h; sourceTree = ""; }; + B6CAB1251AF9AA1900B9B856 /* btMultiBodyLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMultiBodyLink.h; sourceTree = ""; }; + B6CAB1261AF9AA1900B9B856 /* btMultiBodyLinkCollider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMultiBodyLinkCollider.h; sourceTree = ""; }; + B6CAB1271AF9AA1900B9B856 /* btMultiBodyPoint2Point.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btMultiBodyPoint2Point.cpp; sourceTree = ""; }; + B6CAB1281AF9AA1900B9B856 /* btMultiBodyPoint2Point.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMultiBodyPoint2Point.h; sourceTree = ""; }; + B6CAB1291AF9AA1900B9B856 /* btMultiBodySolverConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMultiBodySolverConstraint.h; sourceTree = ""; }; + B6CAB12B1AF9AA1900B9B856 /* btDantzigLCP.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btDantzigLCP.cpp; sourceTree = ""; }; + B6CAB12C1AF9AA1900B9B856 /* btDantzigLCP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btDantzigLCP.h; sourceTree = ""; }; + B6CAB12D1AF9AA1900B9B856 /* btDantzigSolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btDantzigSolver.h; sourceTree = ""; }; + B6CAB12E1AF9AA1900B9B856 /* btMLCPSolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btMLCPSolver.cpp; sourceTree = ""; }; + B6CAB12F1AF9AA1900B9B856 /* btMLCPSolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMLCPSolver.h; sourceTree = ""; }; + B6CAB1301AF9AA1900B9B856 /* btMLCPSolverInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMLCPSolverInterface.h; sourceTree = ""; }; + B6CAB1311AF9AA1900B9B856 /* btPATHSolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btPATHSolver.h; sourceTree = ""; }; + B6CAB1321AF9AA1900B9B856 /* btSolveProjectedGaussSeidel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btSolveProjectedGaussSeidel.h; sourceTree = ""; }; + B6CAB1341AF9AA1900B9B856 /* btRaycastVehicle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btRaycastVehicle.cpp; sourceTree = ""; }; + B6CAB1351AF9AA1900B9B856 /* btRaycastVehicle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btRaycastVehicle.h; sourceTree = ""; }; + B6CAB1361AF9AA1900B9B856 /* btVehicleRaycaster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btVehicleRaycaster.h; sourceTree = ""; }; + B6CAB1371AF9AA1900B9B856 /* btWheelInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btWheelInfo.cpp; sourceTree = ""; }; + B6CAB1381AF9AA1900B9B856 /* btWheelInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btWheelInfo.h; sourceTree = ""; }; + B6CAB13A1AF9AA1900B9B856 /* btGpu3DGridBroadphase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btGpu3DGridBroadphase.cpp; sourceTree = ""; }; + B6CAB13B1AF9AA1900B9B856 /* btGpu3DGridBroadphase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGpu3DGridBroadphase.h; sourceTree = ""; }; + B6CAB13C1AF9AA1900B9B856 /* btGpu3DGridBroadphaseSharedCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGpu3DGridBroadphaseSharedCode.h; sourceTree = ""; }; + B6CAB13D1AF9AA1900B9B856 /* btGpu3DGridBroadphaseSharedDefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGpu3DGridBroadphaseSharedDefs.h; sourceTree = ""; }; + B6CAB13E1AF9AA1900B9B856 /* btGpu3DGridBroadphaseSharedTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGpu3DGridBroadphaseSharedTypes.h; sourceTree = ""; }; + B6CAB13F1AF9AA1900B9B856 /* btGpuDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGpuDefines.h; sourceTree = ""; }; + B6CAB1401AF9AA1900B9B856 /* btGpuUtilsSharedCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGpuUtilsSharedCode.h; sourceTree = ""; }; + B6CAB1411AF9AA1900B9B856 /* btGpuUtilsSharedDefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGpuUtilsSharedDefs.h; sourceTree = ""; }; + B6CAB1421AF9AA1900B9B856 /* btParallelConstraintSolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btParallelConstraintSolver.cpp; sourceTree = ""; }; + B6CAB1431AF9AA1900B9B856 /* btParallelConstraintSolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btParallelConstraintSolver.h; sourceTree = ""; }; + B6CAB1441AF9AA1900B9B856 /* btThreadSupportInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btThreadSupportInterface.cpp; sourceTree = ""; }; + B6CAB1451AF9AA1900B9B856 /* btThreadSupportInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btThreadSupportInterface.h; sourceTree = ""; }; + B6CAB1841AF9AA1A00B9B856 /* HeapManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeapManager.h; sourceTree = ""; }; + B6CAB1851AF9AA1A00B9B856 /* PlatformDefinitions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformDefinitions.h; sourceTree = ""; }; + B6CAB1861AF9AA1A00B9B856 /* PosixThreadSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PosixThreadSupport.cpp; sourceTree = ""; }; + B6CAB1871AF9AA1A00B9B856 /* PosixThreadSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PosixThreadSupport.h; sourceTree = ""; }; + B6CAB1881AF9AA1A00B9B856 /* PpuAddressSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PpuAddressSpace.h; sourceTree = ""; }; + B6CAB1891AF9AA1A00B9B856 /* SequentialThreadSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SequentialThreadSupport.cpp; sourceTree = ""; }; + B6CAB18A1AF9AA1A00B9B856 /* SequentialThreadSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SequentialThreadSupport.h; sourceTree = ""; }; + B6CAB18B1AF9AA1A00B9B856 /* SpuCollisionObjectWrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpuCollisionObjectWrapper.cpp; sourceTree = ""; }; + B6CAB18C1AF9AA1A00B9B856 /* SpuCollisionObjectWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpuCollisionObjectWrapper.h; sourceTree = ""; }; + B6CAB18D1AF9AA1A00B9B856 /* SpuCollisionTaskProcess.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpuCollisionTaskProcess.cpp; sourceTree = ""; }; + B6CAB18E1AF9AA1A00B9B856 /* SpuCollisionTaskProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpuCollisionTaskProcess.h; sourceTree = ""; }; + B6CAB18F1AF9AA1A00B9B856 /* SpuContactManifoldCollisionAlgorithm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpuContactManifoldCollisionAlgorithm.cpp; sourceTree = ""; }; + B6CAB1901AF9AA1A00B9B856 /* SpuContactManifoldCollisionAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpuContactManifoldCollisionAlgorithm.h; sourceTree = ""; }; + B6CAB1911AF9AA1A00B9B856 /* SpuDoubleBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpuDoubleBuffer.h; sourceTree = ""; }; + B6CAB1921AF9AA1A00B9B856 /* SpuFakeDma.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpuFakeDma.cpp; sourceTree = ""; }; + B6CAB1931AF9AA1A00B9B856 /* SpuFakeDma.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpuFakeDma.h; sourceTree = ""; }; + B6CAB1941AF9AA1A00B9B856 /* SpuGatheringCollisionDispatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpuGatheringCollisionDispatcher.cpp; sourceTree = ""; }; + B6CAB1951AF9AA1A00B9B856 /* SpuGatheringCollisionDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpuGatheringCollisionDispatcher.h; sourceTree = ""; }; + B6CAB1961AF9AA1A00B9B856 /* SpuLibspe2Support.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpuLibspe2Support.cpp; sourceTree = ""; }; + B6CAB1971AF9AA1A00B9B856 /* SpuLibspe2Support.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpuLibspe2Support.h; sourceTree = ""; }; + B6CAB1991AF9AA1A00B9B856 /* Box.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Box.h; sourceTree = ""; }; + B6CAB19A1AF9AA1A00B9B856 /* boxBoxDistance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = boxBoxDistance.cpp; sourceTree = ""; }; + B6CAB19B1AF9AA1A00B9B856 /* boxBoxDistance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = boxBoxDistance.h; sourceTree = ""; }; + B6CAB19C1AF9AA1A00B9B856 /* SpuCollisionShapes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpuCollisionShapes.cpp; sourceTree = ""; }; + B6CAB19D1AF9AA1A00B9B856 /* SpuCollisionShapes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpuCollisionShapes.h; sourceTree = ""; }; + B6CAB19E1AF9AA1A00B9B856 /* SpuContactResult.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpuContactResult.cpp; sourceTree = ""; }; + B6CAB19F1AF9AA1A00B9B856 /* SpuContactResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpuContactResult.h; sourceTree = ""; }; + B6CAB1A01AF9AA1A00B9B856 /* SpuConvexPenetrationDepthSolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpuConvexPenetrationDepthSolver.h; sourceTree = ""; }; + B6CAB1A11AF9AA1A00B9B856 /* SpuGatheringCollisionTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpuGatheringCollisionTask.cpp; sourceTree = ""; }; + B6CAB1A21AF9AA1A00B9B856 /* SpuGatheringCollisionTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpuGatheringCollisionTask.h; sourceTree = ""; }; + B6CAB1A31AF9AA1A00B9B856 /* SpuLocalSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpuLocalSupport.h; sourceTree = ""; }; + B6CAB1A41AF9AA1A00B9B856 /* SpuMinkowskiPenetrationDepthSolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpuMinkowskiPenetrationDepthSolver.cpp; sourceTree = ""; }; + B6CAB1A51AF9AA1A00B9B856 /* SpuMinkowskiPenetrationDepthSolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpuMinkowskiPenetrationDepthSolver.h; sourceTree = ""; }; + B6CAB1A61AF9AA1A00B9B856 /* SpuPreferredPenetrationDirections.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpuPreferredPenetrationDirections.h; sourceTree = ""; }; + B6CAB1A81AF9AA1A00B9B856 /* SpuSampleTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpuSampleTask.cpp; sourceTree = ""; }; + B6CAB1A91AF9AA1A00B9B856 /* SpuSampleTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpuSampleTask.h; sourceTree = ""; }; + B6CAB1AA1AF9AA1A00B9B856 /* SpuSampleTaskProcess.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpuSampleTaskProcess.cpp; sourceTree = ""; }; + B6CAB1AB1AF9AA1A00B9B856 /* SpuSampleTaskProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpuSampleTaskProcess.h; sourceTree = ""; }; + B6CAB1AC1AF9AA1A00B9B856 /* SpuSync.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpuSync.h; sourceTree = ""; }; + B6CAB1AD1AF9AA1A00B9B856 /* TrbDynBody.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TrbDynBody.h; sourceTree = ""; }; + B6CAB1AE1AF9AA1A00B9B856 /* TrbStateVec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TrbStateVec.h; sourceTree = ""; }; + B6CAB1AF1AF9AA1A00B9B856 /* vectormath2bullet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vectormath2bullet.h; sourceTree = ""; }; + B6CAB1B01AF9AA1A00B9B856 /* Win32ThreadSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Win32ThreadSupport.cpp; sourceTree = ""; }; + B6CAB1B11AF9AA1A00B9B856 /* Win32ThreadSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Win32ThreadSupport.h; sourceTree = ""; }; + B6CAB1B31AF9AA1A00B9B856 /* btAabbUtil2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btAabbUtil2.h; sourceTree = ""; }; + B6CAB1B41AF9AA1A00B9B856 /* btAlignedAllocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btAlignedAllocator.cpp; sourceTree = ""; }; + B6CAB1B51AF9AA1A00B9B856 /* btAlignedAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btAlignedAllocator.h; sourceTree = ""; }; + B6CAB1B61AF9AA1A00B9B856 /* btAlignedObjectArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btAlignedObjectArray.h; sourceTree = ""; }; + B6CAB1B71AF9AA1A00B9B856 /* btConvexHull.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btConvexHull.cpp; sourceTree = ""; }; + B6CAB1B81AF9AA1A00B9B856 /* btConvexHull.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btConvexHull.h; sourceTree = ""; }; + B6CAB1B91AF9AA1A00B9B856 /* btConvexHullComputer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btConvexHullComputer.cpp; sourceTree = ""; }; + B6CAB1BA1AF9AA1A00B9B856 /* btConvexHullComputer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btConvexHullComputer.h; sourceTree = ""; }; + B6CAB1BB1AF9AA1A00B9B856 /* btDefaultMotionState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btDefaultMotionState.h; sourceTree = ""; }; + B6CAB1BC1AF9AA1A00B9B856 /* btGeometryUtil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btGeometryUtil.cpp; sourceTree = ""; }; + B6CAB1BD1AF9AA1A00B9B856 /* btGeometryUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGeometryUtil.h; sourceTree = ""; }; + B6CAB1BE1AF9AA1A00B9B856 /* btGrahamScan2dConvexHull.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btGrahamScan2dConvexHull.h; sourceTree = ""; }; + B6CAB1BF1AF9AA1A00B9B856 /* btHashMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btHashMap.h; sourceTree = ""; }; + B6CAB1C01AF9AA1A00B9B856 /* btIDebugDraw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btIDebugDraw.h; sourceTree = ""; }; + B6CAB1C11AF9AA1A00B9B856 /* btList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btList.h; sourceTree = ""; }; + B6CAB1C21AF9AA1A00B9B856 /* btMatrix3x3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMatrix3x3.h; sourceTree = ""; }; + B6CAB1C31AF9AA1A00B9B856 /* btMatrixX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMatrixX.h; sourceTree = ""; }; + B6CAB1C41AF9AA1A00B9B856 /* btMinMax.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMinMax.h; sourceTree = ""; }; + B6CAB1C51AF9AA1A00B9B856 /* btMotionState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btMotionState.h; sourceTree = ""; }; + B6CAB1C61AF9AA1A00B9B856 /* btPolarDecomposition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btPolarDecomposition.cpp; sourceTree = ""; }; + B6CAB1C71AF9AA1A00B9B856 /* btPolarDecomposition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btPolarDecomposition.h; sourceTree = ""; }; + B6CAB1C81AF9AA1A00B9B856 /* btPoolAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btPoolAllocator.h; sourceTree = ""; }; + B6CAB1C91AF9AA1A00B9B856 /* btQuadWord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btQuadWord.h; sourceTree = ""; }; + B6CAB1CA1AF9AA1A00B9B856 /* btQuaternion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btQuaternion.h; sourceTree = ""; }; + B6CAB1CB1AF9AA1A00B9B856 /* btQuickprof.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btQuickprof.cpp; sourceTree = ""; }; + B6CAB1CC1AF9AA1A00B9B856 /* btQuickprof.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btQuickprof.h; sourceTree = ""; }; + B6CAB1CD1AF9AA1A00B9B856 /* btRandom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btRandom.h; sourceTree = ""; }; + B6CAB1CE1AF9AA1A00B9B856 /* btScalar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btScalar.h; sourceTree = ""; }; + B6CAB1CF1AF9AA1A00B9B856 /* btSerializer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btSerializer.cpp; sourceTree = ""; }; + B6CAB1D01AF9AA1A00B9B856 /* btSerializer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btSerializer.h; sourceTree = ""; }; + B6CAB1D11AF9AA1A00B9B856 /* btStackAlloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btStackAlloc.h; sourceTree = ""; }; + B6CAB1D21AF9AA1A00B9B856 /* btTransform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btTransform.h; sourceTree = ""; }; + B6CAB1D31AF9AA1A00B9B856 /* btTransformUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btTransformUtil.h; sourceTree = ""; }; + B6CAB1D41AF9AA1A00B9B856 /* btVector3.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = btVector3.cpp; sourceTree = ""; }; + B6CAB1D51AF9AA1A00B9B856 /* btVector3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btVector3.h; sourceTree = ""; }; + B6CAB1D71AF9AA1A00B9B856 /* cl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cl.h; sourceTree = ""; }; + B6CAB1D81AF9AA1A00B9B856 /* cl_gl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cl_gl.h; sourceTree = ""; }; + B6CAB1D91AF9AA1A00B9B856 /* cl_MiniCL_Defs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cl_MiniCL_Defs.h; sourceTree = ""; }; + B6CAB1DA1AF9AA1A00B9B856 /* cl_platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cl_platform.h; sourceTree = ""; }; + B6CAB1DB1AF9AA1A00B9B856 /* MiniCL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MiniCL.cpp; sourceTree = ""; }; + B6CAB1DD1AF9AA1A00B9B856 /* MiniCLTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MiniCLTask.cpp; sourceTree = ""; }; + B6CAB1DE1AF9AA1A00B9B856 /* MiniCLTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MiniCLTask.h; sourceTree = ""; }; + B6CAB1DF1AF9AA1A00B9B856 /* MiniCLTaskScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MiniCLTaskScheduler.cpp; sourceTree = ""; }; + B6CAB1E01AF9AA1A00B9B856 /* MiniCLTaskScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MiniCLTaskScheduler.h; sourceTree = ""; }; B6D38B861AC3AFAC00043997 /* CCSkybox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSkybox.cpp; sourceTree = ""; }; B6D38B871AC3AFAC00043997 /* CCSkybox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSkybox.h; sourceTree = ""; }; B6D38B881AC3AFAC00043997 /* CCTextureCube.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTextureCube.cpp; sourceTree = ""; }; @@ -4151,6 +5414,7 @@ 46A170851807CE87005B8026 /* math */, 1AAF5360180E3374000584C8 /* network */, 46A170611807CE7A005B8026 /* physics */, + B6CAAFD11AF9A98E00B9B856 /* physics3d */, 50ABBEDB1926664700A911A9 /* platform */, 1551A340158F2AB200E66CFE /* Products */, 500DC89819105D41007B91BF /* renderer */, @@ -4645,6 +5909,7 @@ 1A57033E180BD0490088DEC7 /* external */ = { isa = PBXGroup; children = ( + B6CAB0021AF9A9EE00B9B856 /* bullet */, 15FB20781AE7C57D00C31518 /* poly2tri */, 382383E11A258FA7002C4610 /* flatbuffers */, 1AC026971914068200FA920D /* ConvertUTF */, @@ -5950,6 +7215,14 @@ B257B45E198A353E00D9A687 /* CCPrimitiveCommand.cpp */, B257B45F198A353E00D9A687 /* CCPrimitiveCommand.h */, 5034CA5D191D591900CE6051 /* shaders */, + 5012168C1AC47380009A4BEA /* CCRenderState.cpp */, + 5012168D1AC47380009A4BEA /* CCRenderState.h */, + 501216921AC47393009A4BEA /* CCPass.cpp */, + 501216931AC47393009A4BEA /* CCPass.h */, + 501216981AC473A3009A4BEA /* CCTechnique.cpp */, + 501216991AC473A3009A4BEA /* CCTechnique.h */, + 5012169E1AC473AD009A4BEA /* CCMaterial.cpp */, + 5012169F1AC473AD009A4BEA /* CCMaterial.h */, ); name = renderer; path = ../cocos/renderer; @@ -6630,6 +7903,590 @@ name = ParticleUniverse; sourceTree = ""; }; + B6CAAFD11AF9A98E00B9B856 /* physics3d */ = { + isa = PBXGroup; + children = ( + B6CAAFD21AF9A9E100B9B856 /* CCPhysics3D.cpp */, + B6CAAFD31AF9A9E100B9B856 /* CCPhysics3D.h */, + B6CAAFD41AF9A9E100B9B856 /* CCPhysics3DComponent.cpp */, + B6CAAFD51AF9A9E100B9B856 /* CCPhysics3DComponent.h */, + B6CAAFD61AF9A9E100B9B856 /* CCPhysics3DConstraint.cpp */, + B6CAAFD71AF9A9E100B9B856 /* CCPhysics3DConstraint.h */, + B6CAAFD81AF9A9E100B9B856 /* CCPhysics3DDebugDrawer.cpp */, + B6CAAFD91AF9A9E100B9B856 /* CCPhysics3DDebugDrawer.h */, + B6CAAFDA1AF9A9E100B9B856 /* CCPhysics3DObject.cpp */, + B6CAAFDB1AF9A9E100B9B856 /* CCPhysics3DObject.h */, + B6CAAFDC1AF9A9E100B9B856 /* CCPhysics3DShape.cpp */, + B6CAAFDD1AF9A9E100B9B856 /* CCPhysics3DShape.h */, + B6CAAFDE1AF9A9E100B9B856 /* CCPhysics3DWorld.cpp */, + B6CAAFDF1AF9A9E100B9B856 /* CCPhysics3DWorld.h */, + B6CAAFE01AF9A9E100B9B856 /* CCPhysicsSprite3D.cpp */, + B6CAAFE11AF9A9E100B9B856 /* CCPhysicsSprite3D.h */, + ); + name = physics3d; + sourceTree = ""; + }; + B6CAB0021AF9A9EE00B9B856 /* bullet */ = { + isa = PBXGroup; + children = ( + B6CAB0031AF9AA1900B9B856 /* btBulletCollisionCommon.h */, + B6CAB0041AF9AA1900B9B856 /* btBulletDynamicsCommon.h */, + B6CAB0051AF9AA1900B9B856 /* Bullet-C-Api.h */, + B6CAB0061AF9AA1900B9B856 /* BulletCollision */, + B6CAB0E71AF9AA1900B9B856 /* BulletDynamics */, + B6CAB1391AF9AA1900B9B856 /* BulletMultiThreaded */, + B6CAB1B21AF9AA1A00B9B856 /* LinearMath */, + B6CAB1D61AF9AA1A00B9B856 /* MiniCL */, + ); + name = bullet; + sourceTree = ""; + }; + B6CAB0061AF9AA1900B9B856 /* BulletCollision */ = { + isa = PBXGroup; + children = ( + B6CAB0071AF9AA1900B9B856 /* BroadphaseCollision */, + B6CAB01E1AF9AA1900B9B856 /* CollisionDispatch */, + B6CAB0541AF9AA1900B9B856 /* CollisionShapes */, + B6CAB0A11AF9AA1900B9B856 /* Gimpact */, + B6CAB0C91AF9AA1900B9B856 /* NarrowPhaseCollision */, + ); + name = BulletCollision; + path = ../external/bullet/BulletCollision; + sourceTree = ""; + }; + B6CAB0071AF9AA1900B9B856 /* BroadphaseCollision */ = { + isa = PBXGroup; + children = ( + B6CAB0081AF9AA1900B9B856 /* btAxisSweep3.cpp */, + B6CAB0091AF9AA1900B9B856 /* btAxisSweep3.h */, + B6CAB00A1AF9AA1900B9B856 /* btBroadphaseInterface.h */, + B6CAB00B1AF9AA1900B9B856 /* btBroadphaseProxy.cpp */, + B6CAB00C1AF9AA1900B9B856 /* btBroadphaseProxy.h */, + B6CAB00D1AF9AA1900B9B856 /* btCollisionAlgorithm.cpp */, + B6CAB00E1AF9AA1900B9B856 /* btCollisionAlgorithm.h */, + B6CAB00F1AF9AA1900B9B856 /* btDbvt.cpp */, + B6CAB0101AF9AA1900B9B856 /* btDbvt.h */, + B6CAB0111AF9AA1900B9B856 /* btDbvtBroadphase.cpp */, + B6CAB0121AF9AA1900B9B856 /* btDbvtBroadphase.h */, + B6CAB0131AF9AA1900B9B856 /* btDispatcher.cpp */, + B6CAB0141AF9AA1900B9B856 /* btDispatcher.h */, + B6CAB0151AF9AA1900B9B856 /* btMultiSapBroadphase.cpp */, + B6CAB0161AF9AA1900B9B856 /* btMultiSapBroadphase.h */, + B6CAB0171AF9AA1900B9B856 /* btOverlappingPairCache.cpp */, + B6CAB0181AF9AA1900B9B856 /* btOverlappingPairCache.h */, + B6CAB0191AF9AA1900B9B856 /* btOverlappingPairCallback.h */, + B6CAB01A1AF9AA1900B9B856 /* btQuantizedBvh.cpp */, + B6CAB01B1AF9AA1900B9B856 /* btQuantizedBvh.h */, + B6CAB01C1AF9AA1900B9B856 /* btSimpleBroadphase.cpp */, + B6CAB01D1AF9AA1900B9B856 /* btSimpleBroadphase.h */, + ); + path = BroadphaseCollision; + sourceTree = ""; + }; + B6CAB01E1AF9AA1900B9B856 /* CollisionDispatch */ = { + isa = PBXGroup; + children = ( + B6CAB01F1AF9AA1900B9B856 /* btActivatingCollisionAlgorithm.cpp */, + B6CAB0201AF9AA1900B9B856 /* btActivatingCollisionAlgorithm.h */, + B6CAB0211AF9AA1900B9B856 /* btBox2dBox2dCollisionAlgorithm.cpp */, + B6CAB0221AF9AA1900B9B856 /* btBox2dBox2dCollisionAlgorithm.h */, + B6CAB0231AF9AA1900B9B856 /* btBoxBoxCollisionAlgorithm.cpp */, + B6CAB0241AF9AA1900B9B856 /* btBoxBoxCollisionAlgorithm.h */, + B6CAB0251AF9AA1900B9B856 /* btBoxBoxDetector.cpp */, + B6CAB0261AF9AA1900B9B856 /* btBoxBoxDetector.h */, + B6CAB0271AF9AA1900B9B856 /* btCollisionConfiguration.h */, + B6CAB0281AF9AA1900B9B856 /* btCollisionCreateFunc.h */, + B6CAB0291AF9AA1900B9B856 /* btCollisionDispatcher.cpp */, + B6CAB02A1AF9AA1900B9B856 /* btCollisionDispatcher.h */, + B6CAB02B1AF9AA1900B9B856 /* btCollisionObject.cpp */, + B6CAB02C1AF9AA1900B9B856 /* btCollisionObject.h */, + B6CAB02D1AF9AA1900B9B856 /* btCollisionObjectWrapper.h */, + B6CAB02E1AF9AA1900B9B856 /* btCollisionWorld.cpp */, + B6CAB02F1AF9AA1900B9B856 /* btCollisionWorld.h */, + B6CAB0301AF9AA1900B9B856 /* btCompoundCollisionAlgorithm.cpp */, + B6CAB0311AF9AA1900B9B856 /* btCompoundCollisionAlgorithm.h */, + B6CAB0321AF9AA1900B9B856 /* btCompoundCompoundCollisionAlgorithm.cpp */, + B6CAB0331AF9AA1900B9B856 /* btCompoundCompoundCollisionAlgorithm.h */, + B6CAB0341AF9AA1900B9B856 /* btConvex2dConvex2dAlgorithm.cpp */, + B6CAB0351AF9AA1900B9B856 /* btConvex2dConvex2dAlgorithm.h */, + B6CAB0361AF9AA1900B9B856 /* btConvexConcaveCollisionAlgorithm.cpp */, + B6CAB0371AF9AA1900B9B856 /* btConvexConcaveCollisionAlgorithm.h */, + B6CAB0381AF9AA1900B9B856 /* btConvexConvexAlgorithm.cpp */, + B6CAB0391AF9AA1900B9B856 /* btConvexConvexAlgorithm.h */, + B6CAB03A1AF9AA1900B9B856 /* btConvexPlaneCollisionAlgorithm.cpp */, + B6CAB03B1AF9AA1900B9B856 /* btConvexPlaneCollisionAlgorithm.h */, + B6CAB03C1AF9AA1900B9B856 /* btDefaultCollisionConfiguration.cpp */, + B6CAB03D1AF9AA1900B9B856 /* btDefaultCollisionConfiguration.h */, + B6CAB03E1AF9AA1900B9B856 /* btEmptyCollisionAlgorithm.cpp */, + B6CAB03F1AF9AA1900B9B856 /* btEmptyCollisionAlgorithm.h */, + B6CAB0401AF9AA1900B9B856 /* btGhostObject.cpp */, + B6CAB0411AF9AA1900B9B856 /* btGhostObject.h */, + B6CAB0421AF9AA1900B9B856 /* btHashedSimplePairCache.cpp */, + B6CAB0431AF9AA1900B9B856 /* btHashedSimplePairCache.h */, + B6CAB0441AF9AA1900B9B856 /* btInternalEdgeUtility.cpp */, + B6CAB0451AF9AA1900B9B856 /* btInternalEdgeUtility.h */, + B6CAB0461AF9AA1900B9B856 /* btManifoldResult.cpp */, + B6CAB0471AF9AA1900B9B856 /* btManifoldResult.h */, + B6CAB0481AF9AA1900B9B856 /* btSimulationIslandManager.cpp */, + B6CAB0491AF9AA1900B9B856 /* btSimulationIslandManager.h */, + B6CAB04A1AF9AA1900B9B856 /* btSphereBoxCollisionAlgorithm.cpp */, + B6CAB04B1AF9AA1900B9B856 /* btSphereBoxCollisionAlgorithm.h */, + B6CAB04C1AF9AA1900B9B856 /* btSphereSphereCollisionAlgorithm.cpp */, + B6CAB04D1AF9AA1900B9B856 /* btSphereSphereCollisionAlgorithm.h */, + B6CAB04E1AF9AA1900B9B856 /* btSphereTriangleCollisionAlgorithm.cpp */, + B6CAB04F1AF9AA1900B9B856 /* btSphereTriangleCollisionAlgorithm.h */, + B6CAB0501AF9AA1900B9B856 /* btUnionFind.cpp */, + B6CAB0511AF9AA1900B9B856 /* btUnionFind.h */, + B6CAB0521AF9AA1900B9B856 /* SphereTriangleDetector.cpp */, + B6CAB0531AF9AA1900B9B856 /* SphereTriangleDetector.h */, + ); + path = CollisionDispatch; + sourceTree = ""; + }; + B6CAB0541AF9AA1900B9B856 /* CollisionShapes */ = { + isa = PBXGroup; + children = ( + B6CAB0551AF9AA1900B9B856 /* btBox2dShape.cpp */, + B6CAB0561AF9AA1900B9B856 /* btBox2dShape.h */, + B6CAB0571AF9AA1900B9B856 /* btBoxShape.cpp */, + B6CAB0581AF9AA1900B9B856 /* btBoxShape.h */, + B6CAB0591AF9AA1900B9B856 /* btBvhTriangleMeshShape.cpp */, + B6CAB05A1AF9AA1900B9B856 /* btBvhTriangleMeshShape.h */, + B6CAB05B1AF9AA1900B9B856 /* btCapsuleShape.cpp */, + B6CAB05C1AF9AA1900B9B856 /* btCapsuleShape.h */, + B6CAB05D1AF9AA1900B9B856 /* btCollisionMargin.h */, + B6CAB05E1AF9AA1900B9B856 /* btCollisionShape.cpp */, + B6CAB05F1AF9AA1900B9B856 /* btCollisionShape.h */, + B6CAB0601AF9AA1900B9B856 /* btCompoundShape.cpp */, + B6CAB0611AF9AA1900B9B856 /* btCompoundShape.h */, + B6CAB0621AF9AA1900B9B856 /* btConcaveShape.cpp */, + B6CAB0631AF9AA1900B9B856 /* btConcaveShape.h */, + B6CAB0641AF9AA1900B9B856 /* btConeShape.cpp */, + B6CAB0651AF9AA1900B9B856 /* btConeShape.h */, + B6CAB0661AF9AA1900B9B856 /* btConvex2dShape.cpp */, + B6CAB0671AF9AA1900B9B856 /* btConvex2dShape.h */, + B6CAB0681AF9AA1900B9B856 /* btConvexHullShape.cpp */, + B6CAB0691AF9AA1900B9B856 /* btConvexHullShape.h */, + B6CAB06A1AF9AA1900B9B856 /* btConvexInternalShape.cpp */, + B6CAB06B1AF9AA1900B9B856 /* btConvexInternalShape.h */, + B6CAB06C1AF9AA1900B9B856 /* btConvexPointCloudShape.cpp */, + B6CAB06D1AF9AA1900B9B856 /* btConvexPointCloudShape.h */, + B6CAB06E1AF9AA1900B9B856 /* btConvexPolyhedron.cpp */, + B6CAB06F1AF9AA1900B9B856 /* btConvexPolyhedron.h */, + B6CAB0701AF9AA1900B9B856 /* btConvexShape.cpp */, + B6CAB0711AF9AA1900B9B856 /* btConvexShape.h */, + B6CAB0721AF9AA1900B9B856 /* btConvexTriangleMeshShape.cpp */, + B6CAB0731AF9AA1900B9B856 /* btConvexTriangleMeshShape.h */, + B6CAB0741AF9AA1900B9B856 /* btCylinderShape.cpp */, + B6CAB0751AF9AA1900B9B856 /* btCylinderShape.h */, + B6CAB0761AF9AA1900B9B856 /* btEmptyShape.cpp */, + B6CAB0771AF9AA1900B9B856 /* btEmptyShape.h */, + B6CAB0781AF9AA1900B9B856 /* btHeightfieldTerrainShape.cpp */, + B6CAB0791AF9AA1900B9B856 /* btHeightfieldTerrainShape.h */, + B6CAB07A1AF9AA1900B9B856 /* btMaterial.h */, + B6CAB07B1AF9AA1900B9B856 /* btMinkowskiSumShape.cpp */, + B6CAB07C1AF9AA1900B9B856 /* btMinkowskiSumShape.h */, + B6CAB07D1AF9AA1900B9B856 /* btMultimaterialTriangleMeshShape.cpp */, + B6CAB07E1AF9AA1900B9B856 /* btMultimaterialTriangleMeshShape.h */, + B6CAB07F1AF9AA1900B9B856 /* btMultiSphereShape.cpp */, + B6CAB0801AF9AA1900B9B856 /* btMultiSphereShape.h */, + B6CAB0811AF9AA1900B9B856 /* btOptimizedBvh.cpp */, + B6CAB0821AF9AA1900B9B856 /* btOptimizedBvh.h */, + B6CAB0831AF9AA1900B9B856 /* btPolyhedralConvexShape.cpp */, + B6CAB0841AF9AA1900B9B856 /* btPolyhedralConvexShape.h */, + B6CAB0851AF9AA1900B9B856 /* btScaledBvhTriangleMeshShape.cpp */, + B6CAB0861AF9AA1900B9B856 /* btScaledBvhTriangleMeshShape.h */, + B6CAB0871AF9AA1900B9B856 /* btShapeHull.cpp */, + B6CAB0881AF9AA1900B9B856 /* btShapeHull.h */, + B6CAB0891AF9AA1900B9B856 /* btSphereShape.cpp */, + B6CAB08A1AF9AA1900B9B856 /* btSphereShape.h */, + B6CAB08B1AF9AA1900B9B856 /* btStaticPlaneShape.cpp */, + B6CAB08C1AF9AA1900B9B856 /* btStaticPlaneShape.h */, + B6CAB08D1AF9AA1900B9B856 /* btStridingMeshInterface.cpp */, + B6CAB08E1AF9AA1900B9B856 /* btStridingMeshInterface.h */, + B6CAB08F1AF9AA1900B9B856 /* btTetrahedronShape.cpp */, + B6CAB0901AF9AA1900B9B856 /* btTetrahedronShape.h */, + B6CAB0911AF9AA1900B9B856 /* btTriangleBuffer.cpp */, + B6CAB0921AF9AA1900B9B856 /* btTriangleBuffer.h */, + B6CAB0931AF9AA1900B9B856 /* btTriangleCallback.cpp */, + B6CAB0941AF9AA1900B9B856 /* btTriangleCallback.h */, + B6CAB0951AF9AA1900B9B856 /* btTriangleIndexVertexArray.cpp */, + B6CAB0961AF9AA1900B9B856 /* btTriangleIndexVertexArray.h */, + B6CAB0971AF9AA1900B9B856 /* btTriangleIndexVertexMaterialArray.cpp */, + B6CAB0981AF9AA1900B9B856 /* btTriangleIndexVertexMaterialArray.h */, + B6CAB0991AF9AA1900B9B856 /* btTriangleInfoMap.h */, + B6CAB09A1AF9AA1900B9B856 /* btTriangleMesh.cpp */, + B6CAB09B1AF9AA1900B9B856 /* btTriangleMesh.h */, + B6CAB09C1AF9AA1900B9B856 /* btTriangleMeshShape.cpp */, + B6CAB09D1AF9AA1900B9B856 /* btTriangleMeshShape.h */, + B6CAB09E1AF9AA1900B9B856 /* btTriangleShape.h */, + B6CAB09F1AF9AA1900B9B856 /* btUniformScalingShape.cpp */, + B6CAB0A01AF9AA1900B9B856 /* btUniformScalingShape.h */, + ); + path = CollisionShapes; + sourceTree = ""; + }; + B6CAB0A11AF9AA1900B9B856 /* Gimpact */ = { + isa = PBXGroup; + children = ( + B6CAB0A21AF9AA1900B9B856 /* btBoxCollision.h */, + B6CAB0A31AF9AA1900B9B856 /* btClipPolygon.h */, + B6CAB0A41AF9AA1900B9B856 /* btCompoundFromGimpact.h */, + B6CAB0A51AF9AA1900B9B856 /* btContactProcessing.cpp */, + B6CAB0A61AF9AA1900B9B856 /* btContactProcessing.h */, + B6CAB0A71AF9AA1900B9B856 /* btGenericPoolAllocator.cpp */, + B6CAB0A81AF9AA1900B9B856 /* btGenericPoolAllocator.h */, + B6CAB0A91AF9AA1900B9B856 /* btGeometryOperations.h */, + B6CAB0AA1AF9AA1900B9B856 /* btGImpactBvh.cpp */, + B6CAB0AB1AF9AA1900B9B856 /* btGImpactBvh.h */, + B6CAB0AC1AF9AA1900B9B856 /* btGImpactCollisionAlgorithm.cpp */, + B6CAB0AD1AF9AA1900B9B856 /* btGImpactCollisionAlgorithm.h */, + B6CAB0AE1AF9AA1900B9B856 /* btGImpactMassUtil.h */, + B6CAB0AF1AF9AA1900B9B856 /* btGImpactQuantizedBvh.cpp */, + B6CAB0B01AF9AA1900B9B856 /* btGImpactQuantizedBvh.h */, + B6CAB0B11AF9AA1900B9B856 /* btGImpactShape.cpp */, + B6CAB0B21AF9AA1900B9B856 /* btGImpactShape.h */, + B6CAB0B31AF9AA1900B9B856 /* btQuantization.h */, + B6CAB0B41AF9AA1900B9B856 /* btTriangleShapeEx.cpp */, + B6CAB0B51AF9AA1900B9B856 /* btTriangleShapeEx.h */, + B6CAB0B61AF9AA1900B9B856 /* gim_array.h */, + B6CAB0B71AF9AA1900B9B856 /* gim_basic_geometry_operations.h */, + B6CAB0B81AF9AA1900B9B856 /* gim_bitset.h */, + B6CAB0B91AF9AA1900B9B856 /* gim_box_collision.h */, + B6CAB0BA1AF9AA1900B9B856 /* gim_box_set.cpp */, + B6CAB0BB1AF9AA1900B9B856 /* gim_box_set.h */, + B6CAB0BC1AF9AA1900B9B856 /* gim_clip_polygon.h */, + B6CAB0BD1AF9AA1900B9B856 /* gim_contact.cpp */, + B6CAB0BE1AF9AA1900B9B856 /* gim_contact.h */, + B6CAB0BF1AF9AA1900B9B856 /* gim_geom_types.h */, + B6CAB0C01AF9AA1900B9B856 /* gim_geometry.h */, + B6CAB0C11AF9AA1900B9B856 /* gim_hash_table.h */, + B6CAB0C21AF9AA1900B9B856 /* gim_linear_math.h */, + B6CAB0C31AF9AA1900B9B856 /* gim_math.h */, + B6CAB0C41AF9AA1900B9B856 /* gim_memory.cpp */, + B6CAB0C51AF9AA1900B9B856 /* gim_memory.h */, + B6CAB0C61AF9AA1900B9B856 /* gim_radixsort.h */, + B6CAB0C71AF9AA1900B9B856 /* gim_tri_collision.cpp */, + B6CAB0C81AF9AA1900B9B856 /* gim_tri_collision.h */, + ); + path = Gimpact; + sourceTree = ""; + }; + B6CAB0C91AF9AA1900B9B856 /* NarrowPhaseCollision */ = { + isa = PBXGroup; + children = ( + B6CAB0CA1AF9AA1900B9B856 /* btContinuousConvexCollision.cpp */, + B6CAB0CB1AF9AA1900B9B856 /* btContinuousConvexCollision.h */, + B6CAB0CC1AF9AA1900B9B856 /* btConvexCast.cpp */, + B6CAB0CD1AF9AA1900B9B856 /* btConvexCast.h */, + B6CAB0CE1AF9AA1900B9B856 /* btConvexPenetrationDepthSolver.h */, + B6CAB0CF1AF9AA1900B9B856 /* btDiscreteCollisionDetectorInterface.h */, + B6CAB0D01AF9AA1900B9B856 /* btGjkConvexCast.cpp */, + B6CAB0D11AF9AA1900B9B856 /* btGjkConvexCast.h */, + B6CAB0D21AF9AA1900B9B856 /* btGjkEpa2.cpp */, + B6CAB0D31AF9AA1900B9B856 /* btGjkEpa2.h */, + B6CAB0D41AF9AA1900B9B856 /* btGjkEpaPenetrationDepthSolver.cpp */, + B6CAB0D51AF9AA1900B9B856 /* btGjkEpaPenetrationDepthSolver.h */, + B6CAB0D61AF9AA1900B9B856 /* btGjkPairDetector.cpp */, + B6CAB0D71AF9AA1900B9B856 /* btGjkPairDetector.h */, + B6CAB0D81AF9AA1900B9B856 /* btManifoldPoint.h */, + B6CAB0D91AF9AA1900B9B856 /* btMinkowskiPenetrationDepthSolver.cpp */, + B6CAB0DA1AF9AA1900B9B856 /* btMinkowskiPenetrationDepthSolver.h */, + B6CAB0DB1AF9AA1900B9B856 /* btPersistentManifold.cpp */, + B6CAB0DC1AF9AA1900B9B856 /* btPersistentManifold.h */, + B6CAB0DD1AF9AA1900B9B856 /* btPointCollector.h */, + B6CAB0DE1AF9AA1900B9B856 /* btPolyhedralContactClipping.cpp */, + B6CAB0DF1AF9AA1900B9B856 /* btPolyhedralContactClipping.h */, + B6CAB0E01AF9AA1900B9B856 /* btRaycastCallback.cpp */, + B6CAB0E11AF9AA1900B9B856 /* btRaycastCallback.h */, + B6CAB0E21AF9AA1900B9B856 /* btSimplexSolverInterface.h */, + B6CAB0E31AF9AA1900B9B856 /* btSubSimplexConvexCast.cpp */, + B6CAB0E41AF9AA1900B9B856 /* btSubSimplexConvexCast.h */, + B6CAB0E51AF9AA1900B9B856 /* btVoronoiSimplexSolver.cpp */, + B6CAB0E61AF9AA1900B9B856 /* btVoronoiSimplexSolver.h */, + ); + path = NarrowPhaseCollision; + sourceTree = ""; + }; + B6CAB0E71AF9AA1900B9B856 /* BulletDynamics */ = { + isa = PBXGroup; + children = ( + B6CAB0E81AF9AA1900B9B856 /* Character */, + B6CAB0EC1AF9AA1900B9B856 /* ConstraintSolver */, + B6CAB10E1AF9AA1900B9B856 /* Dynamics */, + B6CAB1181AF9AA1900B9B856 /* Featherstone */, + B6CAB12A1AF9AA1900B9B856 /* MLCPSolvers */, + B6CAB1331AF9AA1900B9B856 /* Vehicle */, + ); + name = BulletDynamics; + path = ../external/bullet/BulletDynamics; + sourceTree = ""; + }; + B6CAB0E81AF9AA1900B9B856 /* Character */ = { + isa = PBXGroup; + children = ( + B6CAB0E91AF9AA1900B9B856 /* btCharacterControllerInterface.h */, + B6CAB0EA1AF9AA1900B9B856 /* btKinematicCharacterController.cpp */, + B6CAB0EB1AF9AA1900B9B856 /* btKinematicCharacterController.h */, + ); + path = Character; + sourceTree = ""; + }; + B6CAB0EC1AF9AA1900B9B856 /* ConstraintSolver */ = { + isa = PBXGroup; + children = ( + B6CAB0ED1AF9AA1900B9B856 /* btConeTwistConstraint.cpp */, + B6CAB0EE1AF9AA1900B9B856 /* btConeTwistConstraint.h */, + B6CAB0EF1AF9AA1900B9B856 /* btConstraintSolver.h */, + B6CAB0F01AF9AA1900B9B856 /* btContactConstraint.cpp */, + B6CAB0F11AF9AA1900B9B856 /* btContactConstraint.h */, + B6CAB0F21AF9AA1900B9B856 /* btContactSolverInfo.h */, + B6CAB0F31AF9AA1900B9B856 /* btFixedConstraint.cpp */, + B6CAB0F41AF9AA1900B9B856 /* btFixedConstraint.h */, + B6CAB0F51AF9AA1900B9B856 /* btGearConstraint.cpp */, + B6CAB0F61AF9AA1900B9B856 /* btGearConstraint.h */, + B6CAB0F71AF9AA1900B9B856 /* btGeneric6DofConstraint.cpp */, + B6CAB0F81AF9AA1900B9B856 /* btGeneric6DofConstraint.h */, + B6CAB0F91AF9AA1900B9B856 /* btGeneric6DofSpringConstraint.cpp */, + B6CAB0FA1AF9AA1900B9B856 /* btGeneric6DofSpringConstraint.h */, + B6CAB0FB1AF9AA1900B9B856 /* btHinge2Constraint.cpp */, + B6CAB0FC1AF9AA1900B9B856 /* btHinge2Constraint.h */, + B6CAB0FD1AF9AA1900B9B856 /* btHingeConstraint.cpp */, + B6CAB0FE1AF9AA1900B9B856 /* btHingeConstraint.h */, + B6CAB0FF1AF9AA1900B9B856 /* btJacobianEntry.h */, + B6CAB1001AF9AA1900B9B856 /* btPoint2PointConstraint.cpp */, + B6CAB1011AF9AA1900B9B856 /* btPoint2PointConstraint.h */, + B6CAB1021AF9AA1900B9B856 /* btSequentialImpulseConstraintSolver.cpp */, + B6CAB1031AF9AA1900B9B856 /* btSequentialImpulseConstraintSolver.h */, + B6CAB1041AF9AA1900B9B856 /* btSliderConstraint.cpp */, + B6CAB1051AF9AA1900B9B856 /* btSliderConstraint.h */, + B6CAB1061AF9AA1900B9B856 /* btSolve2LinearConstraint.cpp */, + B6CAB1071AF9AA1900B9B856 /* btSolve2LinearConstraint.h */, + B6CAB1081AF9AA1900B9B856 /* btSolverBody.h */, + B6CAB1091AF9AA1900B9B856 /* btSolverConstraint.h */, + B6CAB10A1AF9AA1900B9B856 /* btTypedConstraint.cpp */, + B6CAB10B1AF9AA1900B9B856 /* btTypedConstraint.h */, + B6CAB10C1AF9AA1900B9B856 /* btUniversalConstraint.cpp */, + B6CAB10D1AF9AA1900B9B856 /* btUniversalConstraint.h */, + ); + path = ConstraintSolver; + sourceTree = ""; + }; + B6CAB10E1AF9AA1900B9B856 /* Dynamics */ = { + isa = PBXGroup; + children = ( + B6CAB10F1AF9AA1900B9B856 /* btActionInterface.h */, + B6CAB1101AF9AA1900B9B856 /* btDiscreteDynamicsWorld.cpp */, + B6CAB1111AF9AA1900B9B856 /* btDiscreteDynamicsWorld.h */, + B6CAB1121AF9AA1900B9B856 /* btDynamicsWorld.h */, + B6CAB1131AF9AA1900B9B856 /* btRigidBody.cpp */, + B6CAB1141AF9AA1900B9B856 /* btRigidBody.h */, + B6CAB1151AF9AA1900B9B856 /* btSimpleDynamicsWorld.cpp */, + B6CAB1161AF9AA1900B9B856 /* btSimpleDynamicsWorld.h */, + B6CAB1171AF9AA1900B9B856 /* Bullet-C-API.cpp */, + ); + path = Dynamics; + sourceTree = ""; + }; + B6CAB1181AF9AA1900B9B856 /* Featherstone */ = { + isa = PBXGroup; + children = ( + B6CAB1191AF9AA1900B9B856 /* btMultiBody.cpp */, + B6CAB11A1AF9AA1900B9B856 /* btMultiBody.h */, + B6CAB11B1AF9AA1900B9B856 /* btMultiBodyConstraint.cpp */, + B6CAB11C1AF9AA1900B9B856 /* btMultiBodyConstraint.h */, + B6CAB11D1AF9AA1900B9B856 /* btMultiBodyConstraintSolver.cpp */, + B6CAB11E1AF9AA1900B9B856 /* btMultiBodyConstraintSolver.h */, + B6CAB11F1AF9AA1900B9B856 /* btMultiBodyDynamicsWorld.cpp */, + B6CAB1201AF9AA1900B9B856 /* btMultiBodyDynamicsWorld.h */, + B6CAB1211AF9AA1900B9B856 /* btMultiBodyJointLimitConstraint.cpp */, + B6CAB1221AF9AA1900B9B856 /* btMultiBodyJointLimitConstraint.h */, + B6CAB1231AF9AA1900B9B856 /* btMultiBodyJointMotor.cpp */, + B6CAB1241AF9AA1900B9B856 /* btMultiBodyJointMotor.h */, + B6CAB1251AF9AA1900B9B856 /* btMultiBodyLink.h */, + B6CAB1261AF9AA1900B9B856 /* btMultiBodyLinkCollider.h */, + B6CAB1271AF9AA1900B9B856 /* btMultiBodyPoint2Point.cpp */, + B6CAB1281AF9AA1900B9B856 /* btMultiBodyPoint2Point.h */, + B6CAB1291AF9AA1900B9B856 /* btMultiBodySolverConstraint.h */, + ); + path = Featherstone; + sourceTree = ""; + }; + B6CAB12A1AF9AA1900B9B856 /* MLCPSolvers */ = { + isa = PBXGroup; + children = ( + B6CAB12B1AF9AA1900B9B856 /* btDantzigLCP.cpp */, + B6CAB12C1AF9AA1900B9B856 /* btDantzigLCP.h */, + B6CAB12D1AF9AA1900B9B856 /* btDantzigSolver.h */, + B6CAB12E1AF9AA1900B9B856 /* btMLCPSolver.cpp */, + B6CAB12F1AF9AA1900B9B856 /* btMLCPSolver.h */, + B6CAB1301AF9AA1900B9B856 /* btMLCPSolverInterface.h */, + B6CAB1311AF9AA1900B9B856 /* btPATHSolver.h */, + B6CAB1321AF9AA1900B9B856 /* btSolveProjectedGaussSeidel.h */, + ); + path = MLCPSolvers; + sourceTree = ""; + }; + B6CAB1331AF9AA1900B9B856 /* Vehicle */ = { + isa = PBXGroup; + children = ( + B6CAB1341AF9AA1900B9B856 /* btRaycastVehicle.cpp */, + B6CAB1351AF9AA1900B9B856 /* btRaycastVehicle.h */, + B6CAB1361AF9AA1900B9B856 /* btVehicleRaycaster.h */, + B6CAB1371AF9AA1900B9B856 /* btWheelInfo.cpp */, + B6CAB1381AF9AA1900B9B856 /* btWheelInfo.h */, + ); + path = Vehicle; + sourceTree = ""; + }; + B6CAB1391AF9AA1900B9B856 /* BulletMultiThreaded */ = { + isa = PBXGroup; + children = ( + B6CAB13A1AF9AA1900B9B856 /* btGpu3DGridBroadphase.cpp */, + B6CAB13B1AF9AA1900B9B856 /* btGpu3DGridBroadphase.h */, + B6CAB13C1AF9AA1900B9B856 /* btGpu3DGridBroadphaseSharedCode.h */, + B6CAB13D1AF9AA1900B9B856 /* btGpu3DGridBroadphaseSharedDefs.h */, + B6CAB13E1AF9AA1900B9B856 /* btGpu3DGridBroadphaseSharedTypes.h */, + B6CAB13F1AF9AA1900B9B856 /* btGpuDefines.h */, + B6CAB1401AF9AA1900B9B856 /* btGpuUtilsSharedCode.h */, + B6CAB1411AF9AA1900B9B856 /* btGpuUtilsSharedDefs.h */, + B6CAB1421AF9AA1900B9B856 /* btParallelConstraintSolver.cpp */, + B6CAB1431AF9AA1900B9B856 /* btParallelConstraintSolver.h */, + B6CAB1441AF9AA1900B9B856 /* btThreadSupportInterface.cpp */, + B6CAB1451AF9AA1900B9B856 /* btThreadSupportInterface.h */, + B6CAB1841AF9AA1A00B9B856 /* HeapManager.h */, + B6CAB1851AF9AA1A00B9B856 /* PlatformDefinitions.h */, + B6CAB1861AF9AA1A00B9B856 /* PosixThreadSupport.cpp */, + B6CAB1871AF9AA1A00B9B856 /* PosixThreadSupport.h */, + B6CAB1881AF9AA1A00B9B856 /* PpuAddressSpace.h */, + B6CAB1891AF9AA1A00B9B856 /* SequentialThreadSupport.cpp */, + B6CAB18A1AF9AA1A00B9B856 /* SequentialThreadSupport.h */, + B6CAB18B1AF9AA1A00B9B856 /* SpuCollisionObjectWrapper.cpp */, + B6CAB18C1AF9AA1A00B9B856 /* SpuCollisionObjectWrapper.h */, + B6CAB18D1AF9AA1A00B9B856 /* SpuCollisionTaskProcess.cpp */, + B6CAB18E1AF9AA1A00B9B856 /* SpuCollisionTaskProcess.h */, + B6CAB18F1AF9AA1A00B9B856 /* SpuContactManifoldCollisionAlgorithm.cpp */, + B6CAB1901AF9AA1A00B9B856 /* SpuContactManifoldCollisionAlgorithm.h */, + B6CAB1911AF9AA1A00B9B856 /* SpuDoubleBuffer.h */, + B6CAB1921AF9AA1A00B9B856 /* SpuFakeDma.cpp */, + B6CAB1931AF9AA1A00B9B856 /* SpuFakeDma.h */, + B6CAB1941AF9AA1A00B9B856 /* SpuGatheringCollisionDispatcher.cpp */, + B6CAB1951AF9AA1A00B9B856 /* SpuGatheringCollisionDispatcher.h */, + B6CAB1961AF9AA1A00B9B856 /* SpuLibspe2Support.cpp */, + B6CAB1971AF9AA1A00B9B856 /* SpuLibspe2Support.h */, + B6CAB1981AF9AA1A00B9B856 /* SpuNarrowPhaseCollisionTask */, + B6CAB1A71AF9AA1A00B9B856 /* SpuSampleTask */, + B6CAB1AA1AF9AA1A00B9B856 /* SpuSampleTaskProcess.cpp */, + B6CAB1AB1AF9AA1A00B9B856 /* SpuSampleTaskProcess.h */, + B6CAB1AC1AF9AA1A00B9B856 /* SpuSync.h */, + B6CAB1AD1AF9AA1A00B9B856 /* TrbDynBody.h */, + B6CAB1AE1AF9AA1A00B9B856 /* TrbStateVec.h */, + B6CAB1AF1AF9AA1A00B9B856 /* vectormath2bullet.h */, + B6CAB1B01AF9AA1A00B9B856 /* Win32ThreadSupport.cpp */, + B6CAB1B11AF9AA1A00B9B856 /* Win32ThreadSupport.h */, + ); + name = BulletMultiThreaded; + path = ../external/bullet/BulletMultiThreaded; + sourceTree = ""; + }; + B6CAB1981AF9AA1A00B9B856 /* SpuNarrowPhaseCollisionTask */ = { + isa = PBXGroup; + children = ( + B6CAB1991AF9AA1A00B9B856 /* Box.h */, + B6CAB19A1AF9AA1A00B9B856 /* boxBoxDistance.cpp */, + B6CAB19B1AF9AA1A00B9B856 /* boxBoxDistance.h */, + B6CAB19C1AF9AA1A00B9B856 /* SpuCollisionShapes.cpp */, + B6CAB19D1AF9AA1A00B9B856 /* SpuCollisionShapes.h */, + B6CAB19E1AF9AA1A00B9B856 /* SpuContactResult.cpp */, + B6CAB19F1AF9AA1A00B9B856 /* SpuContactResult.h */, + B6CAB1A01AF9AA1A00B9B856 /* SpuConvexPenetrationDepthSolver.h */, + B6CAB1A11AF9AA1A00B9B856 /* SpuGatheringCollisionTask.cpp */, + B6CAB1A21AF9AA1A00B9B856 /* SpuGatheringCollisionTask.h */, + B6CAB1A31AF9AA1A00B9B856 /* SpuLocalSupport.h */, + B6CAB1A41AF9AA1A00B9B856 /* SpuMinkowskiPenetrationDepthSolver.cpp */, + B6CAB1A51AF9AA1A00B9B856 /* SpuMinkowskiPenetrationDepthSolver.h */, + B6CAB1A61AF9AA1A00B9B856 /* SpuPreferredPenetrationDirections.h */, + ); + path = SpuNarrowPhaseCollisionTask; + sourceTree = ""; + }; + B6CAB1A71AF9AA1A00B9B856 /* SpuSampleTask */ = { + isa = PBXGroup; + children = ( + B6CAB1A81AF9AA1A00B9B856 /* SpuSampleTask.cpp */, + B6CAB1A91AF9AA1A00B9B856 /* SpuSampleTask.h */, + ); + path = SpuSampleTask; + sourceTree = ""; + }; + B6CAB1B21AF9AA1A00B9B856 /* LinearMath */ = { + isa = PBXGroup; + children = ( + B6CAB1B31AF9AA1A00B9B856 /* btAabbUtil2.h */, + B6CAB1B41AF9AA1A00B9B856 /* btAlignedAllocator.cpp */, + B6CAB1B51AF9AA1A00B9B856 /* btAlignedAllocator.h */, + B6CAB1B61AF9AA1A00B9B856 /* btAlignedObjectArray.h */, + B6CAB1B71AF9AA1A00B9B856 /* btConvexHull.cpp */, + B6CAB1B81AF9AA1A00B9B856 /* btConvexHull.h */, + B6CAB1B91AF9AA1A00B9B856 /* btConvexHullComputer.cpp */, + B6CAB1BA1AF9AA1A00B9B856 /* btConvexHullComputer.h */, + B6CAB1BB1AF9AA1A00B9B856 /* btDefaultMotionState.h */, + B6CAB1BC1AF9AA1A00B9B856 /* btGeometryUtil.cpp */, + B6CAB1BD1AF9AA1A00B9B856 /* btGeometryUtil.h */, + B6CAB1BE1AF9AA1A00B9B856 /* btGrahamScan2dConvexHull.h */, + B6CAB1BF1AF9AA1A00B9B856 /* btHashMap.h */, + B6CAB1C01AF9AA1A00B9B856 /* btIDebugDraw.h */, + B6CAB1C11AF9AA1A00B9B856 /* btList.h */, + B6CAB1C21AF9AA1A00B9B856 /* btMatrix3x3.h */, + B6CAB1C31AF9AA1A00B9B856 /* btMatrixX.h */, + B6CAB1C41AF9AA1A00B9B856 /* btMinMax.h */, + B6CAB1C51AF9AA1A00B9B856 /* btMotionState.h */, + B6CAB1C61AF9AA1A00B9B856 /* btPolarDecomposition.cpp */, + B6CAB1C71AF9AA1A00B9B856 /* btPolarDecomposition.h */, + B6CAB1C81AF9AA1A00B9B856 /* btPoolAllocator.h */, + B6CAB1C91AF9AA1A00B9B856 /* btQuadWord.h */, + B6CAB1CA1AF9AA1A00B9B856 /* btQuaternion.h */, + B6CAB1CB1AF9AA1A00B9B856 /* btQuickprof.cpp */, + B6CAB1CC1AF9AA1A00B9B856 /* btQuickprof.h */, + B6CAB1CD1AF9AA1A00B9B856 /* btRandom.h */, + B6CAB1CE1AF9AA1A00B9B856 /* btScalar.h */, + B6CAB1CF1AF9AA1A00B9B856 /* btSerializer.cpp */, + B6CAB1D01AF9AA1A00B9B856 /* btSerializer.h */, + B6CAB1D11AF9AA1A00B9B856 /* btStackAlloc.h */, + B6CAB1D21AF9AA1A00B9B856 /* btTransform.h */, + B6CAB1D31AF9AA1A00B9B856 /* btTransformUtil.h */, + B6CAB1D41AF9AA1A00B9B856 /* btVector3.cpp */, + B6CAB1D51AF9AA1A00B9B856 /* btVector3.h */, + ); + name = LinearMath; + path = ../external/bullet/LinearMath; + sourceTree = ""; + }; + B6CAB1D61AF9AA1A00B9B856 /* MiniCL */ = { + isa = PBXGroup; + children = ( + B6CAB1D71AF9AA1A00B9B856 /* cl.h */, + B6CAB1D81AF9AA1A00B9B856 /* cl_gl.h */, + B6CAB1D91AF9AA1A00B9B856 /* cl_MiniCL_Defs.h */, + B6CAB1DA1AF9AA1A00B9B856 /* cl_platform.h */, + B6CAB1DB1AF9AA1A00B9B856 /* MiniCL.cpp */, + B6CAB1DC1AF9AA1A00B9B856 /* MiniCLTask */, + B6CAB1DF1AF9AA1A00B9B856 /* MiniCLTaskScheduler.cpp */, + B6CAB1E01AF9AA1A00B9B856 /* MiniCLTaskScheduler.h */, + ); + name = MiniCL; + path = ../external/bullet/MiniCL; + sourceTree = ""; + }; + B6CAB1DC1AF9AA1A00B9B856 /* MiniCLTask */ = { + isa = PBXGroup; + children = ( + B6CAB1DD1AF9AA1A00B9B856 /* MiniCLTask.cpp */, + B6CAB1DE1AF9AA1A00B9B856 /* MiniCLTask.h */, + ); + path = MiniCLTask; + sourceTree = ""; + }; D0FD03391A3B51AA00825BB5 /* allocator */ = { isa = PBXGroup; children = ( @@ -6660,17 +8517,26 @@ 50ABBE9B1925AB6F00A911A9 /* CCRef.h in Headers */, 50ABBE851925AB6F00A911A9 /* ccFPSImages.h in Headers */, B665E2701AA80A6500DDB1C5 /* CCPUDoFreezeEventHandlerTranslator.h in Headers */, + B6CAB4251AF9AA1A00B9B856 /* btPATHSolver.h in Headers */, 15AE1A5319AAD40300C27E9E /* b2Draw.h in Headers */, B665E25C1AA80A6500DDB1C5 /* CCPUDoEnableComponentEventHandler.h in Headers */, + B6CAB33B1AF9AA1A00B9B856 /* btTriangleShapeEx.h in Headers */, + B6CAB4C71AF9AA1A00B9B856 /* boxBoxDistance.h in Headers */, 38B8E2E319E671D2002D7CE7 /* UILayoutComponent.h in Headers */, B6D38B8C1AC3AFAC00043997 /* CCSkybox.h in Headers */, 5034CA39191D591100CE6051 /* ccShader_PositionColorLengthTexture.frag in Headers */, 292DB14B19B4574100A80320 /* UIEditBoxImpl-mac.h in Headers */, + B6CAB39D1AF9AA1A00B9B856 /* btCharacterControllerInterface.h in Headers */, B29A7E3F19EE1B7700872B35 /* AnimationState.h in Headers */, + B6CAB50F1AF9AA1A00B9B856 /* btList.h in Headers */, D0FD03591A3B51AA00825BB5 /* CCAllocatorStrategyDefault.h in Headers */, B665E2901AA80A6500DDB1C5 /* CCPUDynamicAttributeTranslator.h in Headers */, + B6CAB3531AF9AA1A00B9B856 /* gim_hash_table.h in Headers */, 50ABBE891925AB6F00A911A9 /* CCMap.h in Headers */, + B6CAB3131AF9AA1A00B9B856 /* btUniformScalingShape.h in Headers */, 50ABBE8D1925AB6F00A911A9 /* CCNS.h in Headers */, + B6CAB1E91AF9AA1A00B9B856 /* btAxisSweep3.h in Headers */, + B6CAB2331AF9AA1A00B9B856 /* btCollisionWorld.h in Headers */, B29A7DFD19EE1B7700872B35 /* IkConstraintData.h in Headers */, 50ABBEA51925AB6F00A911A9 /* CCScriptSupport.h in Headers */, 292DB14519B4574100A80320 /* UIEditBoxImpl-android.h in Headers */, @@ -6678,30 +8544,40 @@ B665E2E41AA80A6500DDB1C5 /* CCPULineAffectorTranslator.h in Headers */, B665E2781AA80A6500DDB1C5 /* CCPUDoPlacementParticleEventHandlerTranslator.h in Headers */, 15AE18EB19AAD35000C27E9E /* CCActionNode.h in Headers */, + B6CAB2151AF9AA1A00B9B856 /* btActivatingCollisionAlgorithm.h in Headers */, B665E2501AA80A6500DDB1C5 /* CCPUColorAffectorTranslator.h in Headers */, B665E3901AA80A6500DDB1C5 /* CCPUPlaneCollider.h in Headers */, + B6CAB4A71AF9AA1A00B9B856 /* SequentialThreadSupport.h in Headers */, + B6CAB31D1AF9AA1A00B9B856 /* btContactProcessing.h in Headers */, 15AE1A3819AAD3D500C27E9E /* b2Shape.h in Headers */, 15AE18FC19AAD35000C27E9E /* CCComBase.h in Headers */, 1ABA68B01888D700007D1BB4 /* CCFontCharMap.h in Headers */, 15AE1B5219AADA9900C27E9E /* UIPageView.h in Headers */, + B6CAB3911AF9AA1A00B9B856 /* btRaycastCallback.h in Headers */, 5091A7A319BFABA800AC8789 /* CCPlatformDefine.h in Headers */, + B6CAB4F71AF9AA1A00B9B856 /* btAlignedAllocator.h in Headers */, 5034CA3F191D591100CE6051 /* ccShader_Position_uColor.vert in Headers */, B665E4381AA80A6600DDB1C5 /* CCPUVortexAffector.h in Headers */, B29A7DD319EE1B7700872B35 /* Skin.h in Headers */, 50ABBD461925AB0000A911A9 /* CCVertex.h in Headers */, B63990CE1A490AFE00B07923 /* CCAsyncTaskPool.h in Headers */, + B6CAAFF81AF9A9E100B9B856 /* CCPhysics3DShape.h in Headers */, B665E2201AA80A6500DDB1C5 /* CCPUBehaviourManager.h in Headers */, 15AE180A19AAD2F700C27E9E /* CCAABB.h in Headers */, B665E28C1AA80A6500DDB1C5 /* CCPUDynamicAttribute.h in Headers */, B665E3941AA80A6500DDB1C5 /* CCPUPlaneColliderTranslator.h in Headers */, 46A170E71807CECA005B8026 /* CCPhysicsBody.h in Headers */, B665E22C1AA80A6500DDB1C5 /* CCPUBoxCollider.h in Headers */, + B6CAB4011AF9AA1A00B9B856 /* btMultiBodyConstraintSolver.h in Headers */, + B6CAB2FB1AF9AA1A00B9B856 /* btTriangleCallback.h in Headers */, 15AE1A5A19AAD40300C27E9E /* b2StackAllocator.h in Headers */, B665E4101AA80A6600DDB1C5 /* CCPUTechniqueTranslator.h in Headers */, + B6CAB3691AF9AA1A00B9B856 /* btConvexCast.h in Headers */, 38F526401A48363B000DB7F7 /* ArmatureNodeReader.h in Headers */, B665E2E81AA80A6500DDB1C5 /* CCPULinearForceAffector.h in Headers */, B29A7E3119EE1B7700872B35 /* SkinnedMeshAttachment.h in Headers */, 15AE1B6F19AADA9900C27E9E /* GUIDefine.h in Headers */, + B6CAB25F1AF9AA1A00B9B856 /* btInternalEdgeUtility.h in Headers */, 15AE1A8119AAD40300C27E9E /* b2FrictionJoint.h in Headers */, 15AE18DD19AAD35000C27E9E /* CocoLoader.h in Headers */, 46A170EB1807CECA005B8026 /* CCPhysicsJoint.h in Headers */, @@ -6710,6 +8586,7 @@ 15AE184619AAD2F700C27E9E /* CCSprite3DMaterial.h in Headers */, B68779061A8CA82E00643ABF /* CCParticleSystem3D.h in Headers */, 50ABBD3E1925AB0000A911A9 /* CCGeometry.h in Headers */, + B6CAB34F1AF9AA1A00B9B856 /* gim_geom_types.h in Headers */, 15AE1A7719AAD40300C27E9E /* b2EdgeAndPolygonContact.h in Headers */, 15AE18F719AAD35000C27E9E /* CCBatchNode.h in Headers */, 15AE181419AAD2F700C27E9E /* CCAnimationCurve.h in Headers */, @@ -6718,14 +8595,17 @@ B665E2601AA80A6500DDB1C5 /* CCPUDoEnableComponentEventHandlerTranslator.h in Headers */, 15AE1C1419AAE2C600C27E9E /* CCPhysicsSprite.h in Headers */, 46A170EE1807CECA005B8026 /* CCPhysicsShape.h in Headers */, + B6CAB3D91AF9AA1A00B9B856 /* btSolverBody.h in Headers */, 15AE1A5C19AAD40300C27E9E /* b2Timer.h in Headers */, B665E1FC1AA80A6500DDB1C5 /* CCPUAffectorTranslator.h in Headers */, 50ABBED31925AB6F00A911A9 /* uthash.h in Headers */, + B6CAB4B51AF9AA1A00B9B856 /* SpuDoubleBuffer.h in Headers */, 46A170E91807CECA005B8026 /* CCPhysicsContact.h in Headers */, 15AE1A2219AAD3D500C27E9E /* Box2D.h in Headers */, 15AE191419AAD35000C27E9E /* CCSGUIReader.h in Headers */, B29A7E0119EE1B7700872B35 /* extension.h in Headers */, 15AE196D19AAD35700C27E9E /* CCActionTimeline.h in Headers */, + B6CAB2BD1AF9AA1A00B9B856 /* btCylinderShape.h in Headers */, 15AE1A6D19AAD40300C27E9E /* b2ChainAndPolygonContact.h in Headers */, 3E2F27A719CFBFE400E7C490 /* AudioEngine.h in Headers */, 15AE183A19AAD2F700C27E9E /* CCRay.h in Headers */, @@ -6734,6 +8614,7 @@ B665E2C41AA80A6500DDB1C5 /* CCPUGeometryRotatorTranslator.h in Headers */, 46A170F01807CECA005B8026 /* CCPhysicsWorld.h in Headers */, 15AE199D19AAD39600C27E9E /* ScrollViewReader.h in Headers */, + B6CAB3471AF9AA1A00B9B856 /* gim_box_set.h in Headers */, DABC9FAB19E7DFA900FA252C /* CCClippingRectangleNode.h in Headers */, B68778FE1A8CA82E00643ABF /* CCParticle3DEmitter.h in Headers */, 50ABBEC11925AB6F00A911A9 /* CCValue.h in Headers */, @@ -6744,19 +8625,25 @@ 15B3708A19EE414C00ABE682 /* Manifest.h in Headers */, 50ABBE731925AB6F00A911A9 /* CCEventListenerMouse.h in Headers */, 1A570063180BC5A10088DEC7 /* CCAction.h in Headers */, + B6CAB40F1AF9AA1A00B9B856 /* btMultiBodyLink.h in Headers */, 1A570067180BC5A10088DEC7 /* CCActionCamera.h in Headers */, 15AE1AD919AAD41000C27E9E /* b2Rope.h in Headers */, 15AE187B19AAD33D00C27E9E /* CCBAnimationManager.h in Headers */, B665E2841AA80A6500DDB1C5 /* CCPUDoStopSystemEventHandler.h in Headers */, + B6CAB52D1AF9AA1A00B9B856 /* btSerializer.h in Headers */, B665E3E01AA80A6600DDB1C5 /* CCPUSimpleSpline.h in Headers */, B665E42C1AA80A6600DDB1C5 /* CCPUVelocityMatchingAffector.h in Headers */, B665E3B41AA80A6500DDB1C5 /* CCPURendererTranslator.h in Headers */, + B6CAAFF01AF9A9E100B9B856 /* CCPhysics3DDebugDrawer.h in Headers */, 1A57006B180BC5A10088DEC7 /* CCActionCatmullRom.h in Headers */, B665E3BC1AA80A6500DDB1C5 /* CCPURibbonTrailRender.h in Headers */, + B6CAB3371AF9AA1A00B9B856 /* btQuantization.h in Headers */, + B6CAB4371AF9AA1A00B9B856 /* btGpu3DGridBroadphaseSharedCode.h in Headers */, B665E2A81AA80A6500DDB1C5 /* CCPUEventHandlerTranslator.h in Headers */, 4D76BE3C1A4AAF0A00102962 /* CCActionTimelineNode.h in Headers */, B665E27C1AA80A6500DDB1C5 /* CCPUDoScaleEventHandler.h in Headers */, 1A57006F180BC5A10088DEC7 /* CCActionEase.h in Headers */, + B6CAB2CB1AF9AA1A00B9B856 /* btMinkowskiSumShape.h in Headers */, B665E29C1AA80A6500DDB1C5 /* CCPUEmitterTranslator.h in Headers */, 15AE1BD719AAE01E00C27E9E /* CCControlSlider.h in Headers */, 15AE1BE519AAE01E00C27E9E /* CCTableView.h in Headers */, @@ -6764,18 +8651,25 @@ 15AE1BD319AAE01E00C27E9E /* CCControlPotentiometer.h in Headers */, 15AE1B6E19AADA9900C27E9E /* UIHelper.h in Headers */, B230ED7319B417AE00364AA8 /* CCTrianglesCommand.h in Headers */, + B6CAB2F71AF9AA1A00B9B856 /* btTriangleBuffer.h in Headers */, B665E2D41AA80A6500DDB1C5 /* CCPUInterParticleColliderTranslator.h in Headers */, 15AE187F19AAD33D00C27E9E /* CCBKeyframe.h in Headers */, B665E2B41AA80A6500DDB1C5 /* CCPUForceField.h in Headers */, 1A570073180BC5A10088DEC7 /* CCActionGrid.h in Headers */, 15AE1BCC19AAE01E00C27E9E /* CCControlButton.h in Headers */, + B6CAB3D71AF9AA1A00B9B856 /* btSolve2LinearConstraint.h in Headers */, + B6CAB3E51AF9AA1A00B9B856 /* btActionInterface.h in Headers */, 5034CA3B191D591100CE6051 /* ccShader_PositionColor.vert in Headers */, B665E3101AA80A6500DDB1C5 /* CCPUObserver.h in Headers */, + B6CAB2071AF9AA1A00B9B856 /* btOverlappingPairCache.h in Headers */, 1A570077180BC5A10088DEC7 /* CCActionGrid3D.h in Headers */, 1A57007B180BC5A10088DEC7 /* CCActionInstant.h in Headers */, + B6CAB38D1AF9AA1A00B9B856 /* btPolyhedralContactClipping.h in Headers */, 15AE182A19AAD2F700C27E9E /* CCMeshSkin.h in Headers */, B276EF5F1988D1D500CD400F /* CCVertexIndexData.h in Headers */, 1A57007F180BC5A10088DEC7 /* CCActionInterval.h in Headers */, + B6CAB3491AF9AA1A00B9B856 /* gim_clip_polygon.h in Headers */, + B6CAAFE41AF9A9E100B9B856 /* CCPhysics3D.h in Headers */, 15AE1A7F19AAD40300C27E9E /* b2DistanceJoint.h in Headers */, B665E3301AA80A6500DDB1C5 /* CCPUOnCountObserverTranslator.h in Headers */, 15AE188719AAD33D00C27E9E /* CCBSequenceProperty.h in Headers */, @@ -6783,25 +8677,40 @@ 1A01C69A18F57BE800EFE3A6 /* CCSet.h in Headers */, 182C5CB31A95964700C30D34 /* Node3DReader.h in Headers */, 1A570083180BC5A10088DEC7 /* CCActionManager.h in Headers */, + B6CAB2251AF9AA1A00B9B856 /* btCollisionCreateFunc.h in Headers */, 1A570087180BC5A10088DEC7 /* CCActionPageTurn3D.h in Headers */, 50ABBD911925AB4100A911A9 /* CCGLProgramCache.h in Headers */, 50ED2BDA19BE76D300A0AB90 /* UIVideoPlayer.h in Headers */, + B6CAB3AB1AF9AA1A00B9B856 /* btContactConstraint.h in Headers */, + B6CAB4391AF9AA1A00B9B856 /* btGpu3DGridBroadphaseSharedDefs.h in Headers */, 15AE199919AAD39600C27E9E /* LoadingBarReader.h in Headers */, + B6CAB4E71AF9AA1A00B9B856 /* SpuSync.h in Headers */, 15AE1A8F19AAD40300C27E9E /* b2RopeJoint.h in Headers */, 15AE18ED19AAD35000C27E9E /* CCActionObject.h in Headers */, + B6CAB4F31AF9AA1A00B9B856 /* btAabbUtil2.h in Headers */, ED9C6A9618599AD8000A5232 /* CCNodeGrid.h in Headers */, + B6CAB4151AF9AA1A00B9B856 /* btMultiBodyPoint2Point.h in Headers */, + B6CAB4491AF9AA1A00B9B856 /* btThreadSupportInterface.h in Headers */, 15AE18A719AAD33D00C27E9E /* CCScrollViewLoader.h in Headers */, 15FB20891AE7C57D00C31518 /* shapes.h in Headers */, 15AE184819AAD2F700C27E9E /* cocos3d.h in Headers */, + B6CAB2531AF9AA1A00B9B856 /* btEmptyCollisionAlgorithm.h in Headers */, 50ABBEC31925AB6F00A911A9 /* CCVector.h in Headers */, 1A57008B180BC5A10088DEC7 /* CCActionProgressTimer.h in Headers */, + B6CAB2A51AF9AA1A00B9B856 /* btConvexHullShape.h in Headers */, B665E2EC1AA80A6500DDB1C5 /* CCPULinearForceAffectorTranslator.h in Headers */, 382384151A259092002C4610 /* NodeReaderProtocol.h in Headers */, B665E2DC1AA80A6500DDB1C5 /* CCPUJetAffectorTranslator.h in Headers */, 382384111A259092002C4610 /* NodeReaderDefine.h in Headers */, 50ABBD8D1925AB4100A911A9 /* CCGLProgram.h in Headers */, 50ABBEA11925AB6F00A911A9 /* CCScheduler.h in Headers */, + B6CAB2211AF9AA1A00B9B856 /* btBoxBoxDetector.h in Headers */, + B6CAB5271AF9AA1A00B9B856 /* btRandom.h in Headers */, + B6CAB28D1AF9AA1A00B9B856 /* btCollisionMargin.h in Headers */, + B6CAB1FB1AF9AA1A00B9B856 /* btDbvtBroadphase.h in Headers */, 15AE1B6219AADA9900C27E9E /* UIButton.h in Headers */, + B6CAB4CF1AF9AA1A00B9B856 /* SpuContactResult.h in Headers */, + B6CAB4E11AF9AA1A00B9B856 /* SpuSampleTask.h in Headers */, 50ABBDB71925AB4100A911A9 /* CCTexture2D.h in Headers */, 50ABBE811925AB6F00A911A9 /* CCEventType.h in Headers */, B665E2B81AA80A6500DDB1C5 /* CCPUForceFieldAffector.h in Headers */, @@ -6813,33 +8722,44 @@ B665E2F41AA80A6500DDB1C5 /* CCPULineEmitterTranslator.h in Headers */, B665E2D81AA80A6500DDB1C5 /* CCPUJetAffector.h in Headers */, 1A570093180BC5A10088DEC7 /* CCActionTween.h in Headers */, + B6CAB3CF1AF9AA1A00B9B856 /* btSequentialImpulseConstraintSolver.h in Headers */, 50ABBD4A1925AB0000A911A9 /* Mat4.h in Headers */, + B6CAB36B1AF9AA1A00B9B856 /* btConvexPenetrationDepthSolver.h in Headers */, 15AE1A6919AAD40300C27E9E /* b2WorldCallbacks.h in Headers */, 29394CF419B01DBA00D2DE1A /* UIWebViewImpl-ios.h in Headers */, B665E3C01AA80A6500DDB1C5 /* CCPUScaleAffector.h in Headers */, B665E2401AA80A6500DDB1C5 /* CCPUCircleEmitterTranslator.h in Headers */, + B6CAB3C71AF9AA1A00B9B856 /* btJacobianEntry.h in Headers */, B29A7E1719EE1B7700872B35 /* Atlas.h in Headers */, + B6CAB30D1AF9AA1A00B9B856 /* btTriangleMeshShape.h in Headers */, 1A57009A180BC5C10088DEC7 /* CCAtlasNode.h in Headers */, + B6CAB3211AF9AA1A00B9B856 /* btGenericPoolAllocator.h in Headers */, D0FD035B1A3B51AA00825BB5 /* CCAllocatorStrategyFixedBlock.h in Headers */, + B6CAB5031AF9AA1A00B9B856 /* btDefaultMotionState.h in Headers */, 15AE190819AAD35000C27E9E /* CCDatas.h in Headers */, B665E3281AA80A6500DDB1C5 /* CCPUOnCollisionObserverTranslator.h in Headers */, B29A7E1119EE1B7700872B35 /* EventData.h in Headers */, 1A5700A0180BC5D20088DEC7 /* CCNode.h in Headers */, 50ABC0671926664800A911A9 /* CCPlatformDefine-mac.h in Headers */, + B6CAB34D1AF9AA1A00B9B856 /* gim_contact.h in Headers */, B665E40C1AA80A6600DDB1C5 /* CCPUSphereSurfaceEmitterTranslator.h in Headers */, 15AE189A19AAD33D00C27E9E /* CCMenuLoader.h in Headers */, 46C02E0918E91123004B7456 /* xxhash.h in Headers */, 15AE1A6B19AAD40300C27E9E /* b2ChainAndCircleContact.h in Headers */, + B6CAB4451AF9AA1A00B9B856 /* btParallelConstraintSolver.h in Headers */, 1A570110180BC8EE0088DEC7 /* CCDrawingPrimitives.h in Headers */, + B6CAB5091AF9AA1A00B9B856 /* btGrahamScan2dConvexHull.h in Headers */, 50CB247D19D9C5A100687767 /* AudioPlayer.h in Headers */, 1A570114180BC8EE0088DEC7 /* CCDrawNode.h in Headers */, B665E3141AA80A6500DDB1C5 /* CCPUObserverManager.h in Headers */, B665E2E01AA80A6500DDB1C5 /* CCPULineAffector.h in Headers */, 15AE1A6019AAD40300C27E9E /* b2ContactManager.h in Headers */, 15B3707A19EE414C00ABE682 /* AssetsManagerEx.h in Headers */, + B6CAB2A11AF9AA1A00B9B856 /* btConvex2dShape.h in Headers */, 15AE188319AAD33D00C27E9E /* CCBSelectorResolver.h in Headers */, B29A7E2719EE1B7700872B35 /* spine-cocos2dx.h in Headers */, B665E2F01AA80A6500DDB1C5 /* CCPULineEmitter.h in Headers */, + B6CAB49D1AF9AA1A00B9B856 /* PlatformDefinitions.h in Headers */, 15AE1B5819AADA9900C27E9E /* UISlider.h in Headers */, 1A57011D180BC90D0088DEC7 /* CCGrabber.h in Headers */, B665E3C81AA80A6600DDB1C5 /* CCPUScaleVelocityAffector.h in Headers */, @@ -6854,29 +8774,44 @@ B29A7E2919EE1B7700872B35 /* SkeletonData.h in Headers */, 1AC0269C1914068200FA920D /* ConvertUTF.h in Headers */, 15AE1A7119AAD40300C27E9E /* b2Contact.h in Headers */, + B6CAB23B1AF9AA1A00B9B856 /* btCompoundCompoundCollisionAlgorithm.h in Headers */, 50ABBED11925AB6F00A911A9 /* TGAlib.h in Headers */, 1A57019F180BCB590088DEC7 /* CCFont.h in Headers */, + B6CAB20D1AF9AA1A00B9B856 /* btQuantizedBvh.h in Headers */, DA8C62A419E52C6400000516 /* ioapi_mem.h in Headers */, + B6CAB53B1AF9AA1A00B9B856 /* cl_gl.h in Headers */, 1A5701A3180BCB590088DEC7 /* CCFontAtlas.h in Headers */, 15AE18E919AAD35000C27E9E /* CCActionManagerEx.h in Headers */, 1A01C68618F57BE800EFE3A6 /* CCArray.h in Headers */, 1A5701A7180BCB590088DEC7 /* CCFontAtlasCache.h in Headers */, + B6CAB3D31AF9AA1A00B9B856 /* btSliderConstraint.h in Headers */, 15AE1A7D19AAD40300C27E9E /* b2MotorJoint.h in Headers */, B68779021A8CA82E00643ABF /* CCParticle3DRender.h in Headers */, + B6CAB2471AF9AA1A00B9B856 /* btConvexConvexAlgorithm.h in Headers */, + B6CAB3A71AF9AA1A00B9B856 /* btConstraintSolver.h in Headers */, + B6CAB3EF1AF9AA1A00B9B856 /* btRigidBody.h in Headers */, 15AE1B6C19AADA9900C27E9E /* UIWidget.h in Headers */, B665E2681AA80A6500DDB1C5 /* CCPUDoExpireEventHandlerTranslator.h in Headers */, 15FB208B1AE7C57D00C31518 /* utils.h in Headers */, + B6CAB3411AF9AA1A00B9B856 /* gim_bitset.h in Headers */, 15AE180E19AAD2F700C27E9E /* CCAnimate3D.h in Headers */, 1A5701B3180BCB590088DEC7 /* CCFontFNT.h in Headers */, 38F526421A48363B000DB7F7 /* CSArmatureNode_generated.h in Headers */, + B6CAB2771AF9AA1A00B9B856 /* btUnionFind.h in Headers */, + B6CAB2111AF9AA1A00B9B856 /* btSimpleBroadphase.h in Headers */, 15AE1BD919AAE01E00C27E9E /* CCControlStepper.h in Headers */, 15AE192119AAD35000C27E9E /* CocoStudio.h in Headers */, + B6CAB3891AF9AA1A00B9B856 /* btPointCollector.h in Headers */, 15AE18A119AAD33D00C27E9E /* CCNodeLoaderListener.h in Headers */, 5034CA47191D591100CE6051 /* ccShader_Label_normal.frag in Headers */, 15AE182219AAD2F700C27E9E /* CCBundleReader.h in Headers */, 15AE18A519AAD33D00C27E9E /* CCScale9SpriteLoader.h in Headers */, 5E9F61281A3FFE3D0038DE01 /* CCFrustum.h in Headers */, + B6CAB3E91AF9AA1A00B9B856 /* btDiscreteDynamicsWorld.h in Headers */, + B6CAB2F31AF9AA1A00B9B856 /* btTetrahedronShape.h in Headers */, + B6CAB4231AF9AA1A00B9B856 /* btMLCPSolverInterface.h in Headers */, 50ED2BE019BEAF7900A0AB90 /* UIEditBoxImpl-win32.h in Headers */, + B6CAB5011AF9AA1A00B9B856 /* btConvexHullComputer.h in Headers */, 15AE197119AAD35700C27E9E /* CCFrame.h in Headers */, 15AE1A6519AAD40300C27E9E /* b2TimeStep.h in Headers */, 15AE182E19AAD2F700C27E9E /* CCMeshVertexIndexData.h in Headers */, @@ -6885,59 +8820,79 @@ B665E3B81AA80A6500DDB1C5 /* CCPURibbonTrail.h in Headers */, 1A5701B7180BCB5A0088DEC7 /* CCFontFreeType.h in Headers */, B665E20C1AA80A6500DDB1C5 /* CCPUBaseColliderTranslator.h in Headers */, + B6CAB3711AF9AA1A00B9B856 /* btGjkConvexCast.h in Headers */, D0FD03551A3B51AA00825BB5 /* CCAllocatorMacros.h in Headers */, 3823842A1A2590F9002C4610 /* NodeReader.h in Headers */, 1A5701BB180BCB5A0088DEC7 /* CCLabel.h in Headers */, + B6CAB3231AF9AA1A00B9B856 /* btGeometryOperations.h in Headers */, D0FD035D1A3B51AA00825BB5 /* CCAllocatorStrategyGlobalSmallBlock.h in Headers */, + B6CAB41B1AF9AA1A00B9B856 /* btDantzigLCP.h in Headers */, 15AE182619AAD2F700C27E9E /* CCMesh.h in Headers */, 15AE192019AAD35000C27E9E /* CCUtilMath.h in Headers */, + B6CAB25B1AF9AA1A00B9B856 /* btHashedSimplePairCache.h in Headers */, B665E4201AA80A6600DDB1C5 /* CCPUTextureRotatorTranslator.h in Headers */, 15AE1BC119AADFFB00C27E9E /* cocos-ext.h in Headers */, 1A5701BF180BCB5A0088DEC7 /* CCLabelAtlas.h in Headers */, 50ABBED91925AB6F00A911A9 /* ZipUtils.h in Headers */, 50643BDB19BFAF4400EF68ED /* CCStdC.h in Headers */, 1A5701C3180BCB5A0088DEC7 /* CCLabelBMFont.h in Headers */, + B6CAB33F1AF9AA1A00B9B856 /* gim_basic_geometry_operations.h in Headers */, + B6CAAFFC1AF9A9E100B9B856 /* CCPhysics3DWorld.h in Headers */, 50ABBE5F1925AB6F00A911A9 /* CCEventListener.h in Headers */, 15AE197519AAD35700C27E9E /* CCTimeLine.h in Headers */, 1A5701C9180BCB5A0088DEC7 /* CCLabelTextFormatter.h in Headers */, 5034CA37191D591100CE6051 /* ccShader_PositionColorLengthTexture.vert in Headers */, + B6CAB32D1AF9AA1A00B9B856 /* btGImpactMassUtil.h in Headers */, 15AE1B6419AADA9900C27E9E /* UICheckBox.h in Headers */, 1A5701CD180BCB5A0088DEC7 /* CCLabelTTF.h in Headers */, 15AE1A3319AAD3D500C27E9E /* b2CircleShape.h in Headers */, 1A5701E0180BCB8C0088DEC7 /* CCLayer.h in Headers */, 1A5701E4180BCB8C0088DEC7 /* CCScene.h in Headers */, 15FB20701AE7BE7400C31518 /* SpritePolygonCache.h in Headers */, + B6CAB2C11AF9AA1A00B9B856 /* btEmptyShape.h in Headers */, B665E3D81AA80A6600DDB1C5 /* CCPUScriptParser.h in Headers */, 382384091A25900F002C4610 /* FlatBuffersSerialize.h in Headers */, + B6CAB2A91AF9AA1A00B9B856 /* btConvexInternalShape.h in Headers */, 15AE1BDD19AAE01E00C27E9E /* CCControlUtils.h in Headers */, + B6CAB3271AF9AA1A00B9B856 /* btGImpactBvh.h in Headers */, 15AE198D19AAD36E00C27E9E /* CheckBoxReader.h in Headers */, B29A7E0919EE1B7700872B35 /* AttachmentLoader.h in Headers */, 1A01C68818F57BE800EFE3A6 /* CCBool.h in Headers */, B29A7E3319EE1B7700872B35 /* SlotData.h in Headers */, B665E2741AA80A6500DDB1C5 /* CCPUDoPlacementParticleEventHandler.h in Headers */, + B6CAB2FF1AF9AA1A00B9B856 /* btTriangleIndexVertexArray.h in Headers */, 15AE18E519AAD35000C27E9E /* CCActionFrame.h in Headers */, 50ABBEAD1925AB6F00A911A9 /* ccTypes.h in Headers */, 1A087AEA1860400400196EF5 /* edtaa3func.h in Headers */, + B6CAB43D1AF9AA1A00B9B856 /* btGpuDefines.h in Headers */, 15AE181C19AAD2F700C27E9E /* CCBundle3D.h in Headers */, 15AE189919AAD33D00C27E9E /* CCMenuItemLoader.h in Headers */, + B6CAB35D1AF9AA1A00B9B856 /* gim_radixsort.h in Headers */, + B6CAB4AB1AF9AA1A00B9B856 /* SpuCollisionObjectWrapper.h in Headers */, 15AE1B5E19AADA9900C27E9E /* UITextBMFont.h in Headers */, B665E3601AA80A6500DDB1C5 /* CCPUOnRandomObserverTranslator.h in Headers */, 15AE18E719AAD35000C27E9E /* CCActionFrameEasing.h in Headers */, + B6CAB3511AF9AA1A00B9B856 /* gim_geometry.h in Headers */, 1A5701E8180BCB8C0088DEC7 /* CCTransition.h in Headers */, 1A5701EC180BCB8C0088DEC7 /* CCTransitionPageTurn.h in Headers */, + B6CAB37D1AF9AA1A00B9B856 /* btGjkPairDetector.h in Headers */, + B6CAB3031AF9AA1A00B9B856 /* btTriangleIndexVertexMaterialArray.h in Headers */, B665E35C1AA80A6500DDB1C5 /* CCPUOnRandomObserver.h in Headers */, 15AE196F19AAD35700C27E9E /* CCActionTimelineCache.h in Headers */, 1A5701F0180BCB8C0088DEC7 /* CCTransitionProgress.h in Headers */, 1A5701F9180BCBAD0088DEC7 /* CCMenu.h in Headers */, + B6CAB4A11AF9AA1A00B9B856 /* PosixThreadSupport.h in Headers */, B665E3001AA80A6500DDB1C5 /* CCPUMaterialTranslator.h in Headers */, B665E33C1AA80A6500DDB1C5 /* CCPUOnEventFlagObserver.h in Headers */, 50ABBD401925AB0000A911A9 /* CCMath.h in Headers */, B29A7E1F19EE1B7700872B35 /* BoneData.h in Headers */, + B6CAB3191AF9AA1A00B9B856 /* btCompoundFromGimpact.h in Headers */, 15AE1A9319AAD40300C27E9E /* b2WheelJoint.h in Headers */, ED74D7691A5B8A2600157FD4 /* CCPhysicsHelper.h in Headers */, B665E3F01AA80A6600DDB1C5 /* CCPUSlaveBehaviourTranslator.h in Headers */, 15AE1A3119AAD3D500C27E9E /* b2ChainShape.h in Headers */, 1A5701FD180BCBAD0088DEC7 /* CCMenuItem.h in Headers */, + B6CAB2AD1AF9AA1A00B9B856 /* btConvexPointCloudShape.h in Headers */, 1A570204180BCBD40088DEC7 /* CCClippingNode.h in Headers */, 15AE1A7B19AAD40300C27E9E /* b2PolygonContact.h in Headers */, 15AE1A2919AAD3D500C27E9E /* b2Collision.h in Headers */, @@ -6947,39 +8902,54 @@ B665E3081AA80A6500DDB1C5 /* CCPUMeshSurfaceEmitterTranslator.h in Headers */, 15AE184219AAD2F700C27E9E /* CCSprite3D.h in Headers */, B665E3181AA80A6500DDB1C5 /* CCPUObserverTranslator.h in Headers */, + B6CAB5111AF9AA1A00B9B856 /* btMatrix3x3.h in Headers */, B665E3201AA80A6500DDB1C5 /* CCPUOnClearObserverTranslator.h in Headers */, B665E2A01AA80A6500DDB1C5 /* CCPUEventHandler.h in Headers */, + B6CAB5291AF9AA1A00B9B856 /* btScalar.h in Headers */, 15AE18A019AAD33D00C27E9E /* CCNodeLoaderLibrary.h in Headers */, + B6CAB3311AF9AA1A00B9B856 /* btGImpactQuantizedBvh.h in Headers */, B665E3B01AA80A6500DDB1C5 /* CCPURender.h in Headers */, + B6CAB2291AF9AA1A00B9B856 /* btCollisionDispatcher.h in Headers */, 1A01C6A618F58F7500EFE3A6 /* CCNotificationCenter.h in Headers */, B665E3A81AA80A6500DDB1C5 /* CCPURandomiser.h in Headers */, 1A57020A180BCBDF0088DEC7 /* CCMotionStreak.h in Headers */, 1A570212180BCBF40088DEC7 /* CCProgressTimer.h in Headers */, + B6CAB2E71AF9AA1A00B9B856 /* btSphereShape.h in Headers */, 1A570216180BCBF40088DEC7 /* CCRenderTexture.h in Headers */, 1A01C69618F57BE800EFE3A6 /* CCInteger.h in Headers */, B665E3F41AA80A6600DDB1C5 /* CCPUSlaveEmitter.h in Headers */, 15AE1B6919AADA9900C27E9E /* UIDeprecated.h in Headers */, 1A570223180BCC1A0088DEC7 /* CCParticleBatchNode.h in Headers */, + B6CAB53F1AF9AA1A00B9B856 /* cl_platform.h in Headers */, 15AE1A8319AAD40300C27E9E /* b2GearJoint.h in Headers */, 15AE1BD519AAE01E00C27E9E /* CCControlSaturationBrightnessPicker.h in Headers */, + B6CAB30F1AF9AA1A00B9B856 /* btTriangleShape.h in Headers */, 15AE186919AAD31D00C27E9E /* CocosDenshion.h in Headers */, B29A7DE719EE1B7700872B35 /* spine.h in Headers */, B665E3841AA80A6500DDB1C5 /* CCPUPathFollower.h in Headers */, B665E3F81AA80A6600DDB1C5 /* CCPUSlaveEmitterTranslator.h in Headers */, 50ABBD891925AB4100A911A9 /* CCCustomCommand.h in Headers */, 15AE1A8719AAD40300C27E9E /* b2MouseJoint.h in Headers */, + B6CAB5171AF9AA1A00B9B856 /* btMotionState.h in Headers */, + B6CAB4D11AF9AA1A00B9B856 /* SpuConvexPenetrationDepthSolver.h in Headers */, + B6CAB3171AF9AA1A00B9B856 /* btClipPolygon.h in Headers */, 5034CA43191D591100CE6051 /* ccShader_Label.vert in Headers */, + B6CAB1E11AF9AA1A00B9B856 /* btBulletCollisionCommon.h in Headers */, 15AE189719AAD33D00C27E9E /* CCMenuItemImageLoader.h in Headers */, B665E2001AA80A6500DDB1C5 /* CCPUAlignAffector.h in Headers */, 15AE189319AAD33D00C27E9E /* CCLayerGradientLoader.h in Headers */, B29A7DF919EE1B7700872B35 /* Json.h in Headers */, + B6CAB3971AF9AA1A00B9B856 /* btSubSimplexConvexCast.h in Headers */, 15AE18EF19AAD35000C27E9E /* CCArmature.h in Headers */, B665E3981AA80A6500DDB1C5 /* CCPUPointEmitter.h in Headers */, 15AE19A719AAD39600C27E9E /* TextReader.h in Headers */, + B6CAB27F1AF9AA1A00B9B856 /* btBox2dShape.h in Headers */, 1A570227180BCC1A0088DEC7 /* CCParticleExamples.h in Headers */, 1A57022B180BCC1A0088DEC7 /* CCParticleSystem.h in Headers */, 15AE190E19AAD35000C27E9E /* CCDisplayManager.h in Headers */, + B6CAB50B1AF9AA1A00B9B856 /* btHashMap.h in Headers */, 15AE1A6719AAD40300C27E9E /* b2World.h in Headers */, + B6CAB3571AF9AA1A00B9B856 /* gim_math.h in Headers */, 15AE199B19AAD39600C27E9E /* PageViewReader.h in Headers */, B665E2A41AA80A6500DDB1C5 /* CCPUEventHandlerManager.h in Headers */, 15AE1A6219AAD40300C27E9E /* b2Fixture.h in Headers */, @@ -6995,62 +8965,97 @@ 50ABBE4F1925AB6F00A911A9 /* CCEventCustom.h in Headers */, 50ABBD521925AB0000A911A9 /* Quaternion.h in Headers */, 15AE186219AAD31D00C27E9E /* CDAudioManager.h in Headers */, + B6CAB3931AF9AA1A00B9B856 /* btSimplexSolverInterface.h in Headers */, + B6CAB22D1AF9AA1A00B9B856 /* btCollisionObject.h in Headers */, + B6CAB2CF1AF9AA1A00B9B856 /* btMultimaterialTriangleMeshShape.h in Headers */, 15AE18F119AAD35000C27E9E /* CCArmatureAnimation.h in Headers */, 1A57022F180BCC1A0088DEC7 /* CCParticleSystemQuad.h in Headers */, + B6CAB4EB1AF9AA1A00B9B856 /* TrbStateVec.h in Headers */, + B6CAB2831AF9AA1A00B9B856 /* btBoxShape.h in Headers */, B665E37C1AA80A6500DDB1C5 /* CCPUParticleSystem3D.h in Headers */, 15AE188519AAD33D00C27E9E /* CCBSequence.h in Headers */, 15FB20951AE7C57D00C31518 /* cdt.h in Headers */, B665E3541AA80A6500DDB1C5 /* CCPUOnQuotaObserver.h in Headers */, + B6CAB4F11AF9AA1A00B9B856 /* Win32ThreadSupport.h in Headers */, 50643BE219BFCF1800EF68ED /* CCPlatformConfig.h in Headers */, B29A7DF519EE1B7700872B35 /* Skeleton.h in Headers */, + B6CAB4DB1AF9AA1A00B9B856 /* SpuMinkowskiPenetrationDepthSolver.h in Headers */, 382384031A259005002C4610 /* CSParseBinary_generated.h in Headers */, + B6CAB4F91AF9AA1A00B9B856 /* btAlignedObjectArray.h in Headers */, 5034CA49191D591100CE6051 /* ccShader_Label_df.frag in Headers */, 292DB14119B4574100A80320 /* UIEditBoxImpl.h in Headers */, B29A7DD919EE1B7700872B35 /* SkeletonRenderer.h in Headers */, 50CB247919D9C5A100687767 /* AudioEngine-inl.h in Headers */, 1A01C68C18F57BE800EFE3A6 /* CCDeprecated.h in Headers */, + B6CAB0001AF9A9E100B9B856 /* CCPhysicsSprite3D.h in Headers */, + B6CAB4411AF9AA1A00B9B856 /* btGpuUtilsSharedDefs.h in Headers */, 50ABBD561925AB0000A911A9 /* TransformUtils.h in Headers */, + B6CAB4DD1AF9AA1A00B9B856 /* SpuPreferredPenetrationDirections.h in Headers */, + B6CAB2431AF9AA1A00B9B856 /* btConvexConcaveCollisionAlgorithm.h in Headers */, 299754F6193EC95400A54AC3 /* ObjectFactory.h in Headers */, 38ACD1FE1A27111900C3093D /* WidgetCallBackHandlerProtocol.h in Headers */, 50ABBD991925AB4100A911A9 /* CCGLProgramStateCache.h in Headers */, B665E41C1AA80A6600DDB1C5 /* CCPUTextureRotator.h in Headers */, + B6CAB2231AF9AA1A00B9B856 /* btCollisionConfiguration.h in Headers */, + B6CAB2191AF9AA1A00B9B856 /* btBox2dBox2dCollisionAlgorithm.h in Headers */, 5034CA3D191D591100CE6051 /* ccShader_PositionColor.frag in Headers */, 15AE18FB19AAD35000C27E9E /* CCColliderDetector.h in Headers */, 1A570280180BCC900088DEC7 /* CCSprite.h in Headers */, 292DB14719B4574100A80320 /* UIEditBoxImpl-ios.h in Headers */, B665E3FC1AA80A6600DDB1C5 /* CCPUSphere.h in Headers */, + B6CAB51B1AF9AA1A00B9B856 /* btPolarDecomposition.h in Headers */, 15AE1A9119AAD40300C27E9E /* b2WeldJoint.h in Headers */, 15AE1A5419AAD40300C27E9E /* b2GrowableStack.h in Headers */, 15AE1B4E19AADA9900C27E9E /* UIListView.h in Headers */, 1A570284180BCC900088DEC7 /* CCSpriteBatchNode.h in Headers */, 5034CA2B191D591100CE6051 /* ccShader_PositionTextureA8Color.vert in Headers */, B665E2041AA80A6500DDB1C5 /* CCPUAlignAffectorTranslator.h in Headers */, + B6CAB3A11AF9AA1A00B9B856 /* btKinematicCharacterController.h in Headers */, 15AE1BCE19AAE01E00C27E9E /* CCControlColourPicker.h in Headers */, 382384461A25915C002C4610 /* SpriteReader.h in Headers */, B665E2481AA80A6500DDB1C5 /* CCPUCollisionAvoidanceAffectorTranslator.h in Headers */, 1A570288180BCC900088DEC7 /* CCSpriteFrame.h in Headers */, + B6CAB43B1AF9AA1A00B9B856 /* btGpu3DGridBroadphaseSharedTypes.h in Headers */, B665E3AC1AA80A6500DDB1C5 /* CCPURandomiserTranslator.h in Headers */, B665E2CC1AA80A6500DDB1C5 /* CCPUGravityAffectorTranslator.h in Headers */, 15AE189519AAD33D00C27E9E /* CCLayerLoader.h in Headers */, 1A57028C180BCC900088DEC7 /* CCSpriteFrameCache.h in Headers */, + B6CAB21D1AF9AA1A00B9B856 /* btBoxBoxCollisionAlgorithm.h in Headers */, + B6CAAFEC1AF9A9E100B9B856 /* CCPhysics3DConstraint.h in Headers */, 5027253A190BF1B900AAF4ED /* cocos2d.h in Headers */, B665E3041AA80A6500DDB1C5 /* CCPUMeshSurfaceEmitter.h in Headers */, 15AE1B5A19AADA9900C27E9E /* UIText.h in Headers */, B665E21C1AA80A6500DDB1C5 /* CCPUBehaviour.h in Headers */, 15AE184A19AAD30500C27E9E /* Export.h in Headers */, + B6CAB3051AF9AA1A00B9B856 /* btTriangleInfoMap.h in Headers */, + B6CAB2C51AF9AA1A00B9B856 /* btHeightfieldTerrainShape.h in Headers */, B665E3501AA80A6500DDB1C5 /* CCPUOnPositionObserverTranslator.h in Headers */, B68778FA1A8CA82E00643ABF /* CCParticle3DAffector.h in Headers */, 15AE1BA019AADFDF00C27E9E /* UILayout.h in Headers */, 1A570294180BCCAB0088DEC7 /* CCAnimation.h in Headers */, B665E4081AA80A6600DDB1C5 /* CCPUSphereSurfaceEmitter.h in Headers */, + B6CAB28B1AF9AA1A00B9B856 /* btCapsuleShape.h in Headers */, 382384001A258FA7002C4610 /* util.h in Headers */, 50ABBD421925AB0000A911A9 /* CCMathBase.h in Headers */, + B6CAB5491AF9AA1A00B9B856 /* MiniCLTaskScheduler.h in Headers */, + B6CAB2031AF9AA1A00B9B856 /* btMultiSapBroadphase.h in Headers */, 1A570298180BCCAB0088DEC7 /* CCAnimationCache.h in Headers */, + B6CAB43F1AF9AA1A00B9B856 /* btGpuUtilsSharedCode.h in Headers */, B665E4181AA80A6600DDB1C5 /* CCPUTextureAnimatorTranslator.h in Headers */, + B6CAB3CB1AF9AA1A00B9B856 /* btPoint2PointConstraint.h in Headers */, B665E2C81AA80A6500DDB1C5 /* CCPUGravityAffector.h in Headers */, + 501216A21AC473AD009A4BEA /* CCMaterial.h in Headers */, 50ABC05D1926664800A911A9 /* CCApplication-mac.h in Headers */, + B6CAB2871AF9AA1A00B9B856 /* btBvhTriangleMeshShape.h in Headers */, + B6CAB51D1AF9AA1A00B9B856 /* btPoolAllocator.h in Headers */, + B6CAB3EB1AF9AA1A00B9B856 /* btDynamicsWorld.h in Headers */, + B6CAB29D1AF9AA1A00B9B856 /* btConeShape.h in Headers */, + B6CAB4A31AF9AA1A00B9B856 /* PpuAddressSpace.h in Headers */, 15AE190019AAD35000C27E9E /* CCComAudio.h in Headers */, + B6CAB3DB1AF9AA1A00B9B856 /* btSolverConstraint.h in Headers */, + B6CAB2911AF9AA1A00B9B856 /* btCollisionShape.h in Headers */, B665E3481AA80A6500DDB1C5 /* CCPUOnExpireObserverTranslator.h in Headers */, + B6CAB2B11AF9AA1A00B9B856 /* btConvexPolyhedron.h in Headers */, 15AE190419AAD35000C27E9E /* CCComRender.h in Headers */, B29A7E1919EE1B7700872B35 /* Event.h in Headers */, 15AE18AA19AAD33D00C27E9E /* CocosBuilder.h in Headers */, @@ -7058,42 +9063,58 @@ B665E2181AA80A6500DDB1C5 /* CCPUBeamRender.h in Headers */, 15AE1A7919AAD40300C27E9E /* b2PolygonAndCircleContact.h in Headers */, B665E2081AA80A6500DDB1C5 /* CCPUBaseCollider.h in Headers */, + B6CAB40D1AF9AA1A00B9B856 /* btMultiBodyJointMotor.h in Headers */, 15AE199719AAD39600C27E9E /* ListViewReader.h in Headers */, B29A7E1D19EE1B7700872B35 /* PolygonBatch.h in Headers */, B665E3441AA80A6500DDB1C5 /* CCPUOnExpireObserver.h in Headers */, 50ABBD4E1925AB0000A911A9 /* MathUtil.h in Headers */, 15AE1A7319AAD40300C27E9E /* b2ContactSolver.h in Headers */, + B6CAB3B91AF9AA1A00B9B856 /* btGeneric6DofConstraint.h in Headers */, + B6CAB24B1AF9AA1A00B9B856 /* btConvexPlaneCollisionAlgorithm.h in Headers */, + B6CAB5391AF9AA1A00B9B856 /* cl.h in Headers */, 15AE1BC219AADFFB00C27E9E /* ExtensionMacros.h in Headers */, B665E4001AA80A6600DDB1C5 /* CCPUSphereCollider.h in Headers */, + B6CAB42D1AF9AA1A00B9B856 /* btVehicleRaycaster.h in Headers */, 15AE1BDF19AAE01E00C27E9E /* CCInvocation.h in Headers */, 50ABBE431925AB6F00A911A9 /* CCDirector.h in Headers */, 15AE1A5819AAD40300C27E9E /* b2Settings.h in Headers */, 15AE181819AAD2F700C27E9E /* CCAttachNode.h in Headers */, + B6CAB4CB1AF9AA1A00B9B856 /* SpuCollisionShapes.h in Headers */, 1A12775B18DFCC540005F345 /* CCTweenFunction.h in Headers */, + B6CAB4271AF9AA1A00B9B856 /* btSolveProjectedGaussSeidel.h in Headers */, 1A5702CA180BCE370088DEC7 /* CCTextFieldTTF.h in Headers */, 15EFA213198A2BB5000C57D3 /* CCProtectedNode.h in Headers */, + B6CAB3551AF9AA1A00B9B856 /* gim_linear_math.h in Headers */, 1A5702EC180BCE750088DEC7 /* CCTileMapAtlas.h in Headers */, 15AE18E019AAD35000C27E9E /* TriggerBase.h in Headers */, 15AE187D19AAD33D00C27E9E /* CCBFileLoader.h in Headers */, 15AE181219AAD2F700C27E9E /* CCAnimation3D.h in Headers */, 182C5CD81A98F30500C30D34 /* Sprite3DReader.h in Headers */, 1A5702F0180BCE750088DEC7 /* CCTMXLayer.h in Headers */, + 501216961AC47393009A4BEA /* CCPass.h in Headers */, 50ABC01B1926664800A911A9 /* CCSAXParser.h in Headers */, 50ABBED51925AB6F00A911A9 /* utlist.h in Headers */, 1A5702F4180BCE750088DEC7 /* CCTMXObjectGroup.h in Headers */, + B6CAB1EF1AF9AA1A00B9B856 /* btBroadphaseProxy.h in Headers */, + B6CAB3871AF9AA1A00B9B856 /* btPersistentManifold.h in Headers */, 50ABBDAF1925AB4100A911A9 /* CCRenderer.h in Headers */, B665E30C1AA80A6500DDB1C5 /* CCPUNoise.h in Headers */, + B6CAB3A51AF9AA1A00B9B856 /* btConeTwistConstraint.h in Headers */, 15AE181E19AAD2F700C27E9E /* CCBundle3DData.h in Headers */, 1A5702F8180BCE750088DEC7 /* CCTMXTiledMap.h in Headers */, B665E2801AA80A6500DDB1C5 /* CCPUDoScaleEventHandlerTranslator.h in Headers */, 5034CA21191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest.frag in Headers */, D0FD03491A3B51AA00825BB5 /* CCAllocatorBase.h in Headers */, + B6CAB4FD1AF9AA1A00B9B856 /* btConvexHull.h in Headers */, 15AE1A2419AAD3D500C27E9E /* b2BroadPhase.h in Headers */, B29A7E3919EE1B7700872B35 /* Animation.h in Headers */, B665E2B01AA80A6500DDB1C5 /* CCPUFlockCenteringAffectorTranslator.h in Headers */, + B6CAB2EF1AF9AA1A00B9B856 /* btStridingMeshInterface.h in Headers */, + B6CAB23F1AF9AA1A00B9B856 /* btConvex2dConvex2dAlgorithm.h in Headers */, 382384381A259126002C4610 /* ProjectNodeReader.h in Headers */, 15FB20991AE7C57D00C31518 /* sweep.h in Headers */, B665E3C41AA80A6600DDB1C5 /* CCPUScaleAffectorTranslator.h in Headers */, + B6CAB2631AF9AA1A00B9B856 /* btManifoldResult.h in Headers */, 15AE191019AAD35000C27E9E /* CCInputDelegate.h in Headers */, B665E4301AA80A6600DDB1C5 /* CCPUVelocityMatchingAffectorTranslator.h in Headers */, 15AE184C19AAD30800C27E9E /* SimpleAudioEngine.h in Headers */, @@ -7101,26 +9122,45 @@ B665E24C1AA80A6500DDB1C5 /* CCPUColorAffector.h in Headers */, 29394CF019B01DBA00D2DE1A /* UIWebView.h in Headers */, 15AE186519AAD31D00C27E9E /* CDOpenALSupport.h in Headers */, + B6CAAFE81AF9A9E100B9B856 /* CCPhysics3DComponent.h in Headers */, 15AE1B5C19AADA9900C27E9E /* UITextAtlas.h in Headers */, 1A5702FC180BCE750088DEC7 /* CCTMXXMLParser.h in Headers */, 15AE1B6019AADA9900C27E9E /* UITextField.h in Headers */, 15AE190619AAD35000C27E9E /* CCDataReaderHelper.h in Headers */, 15AE1A6419AAD40300C27E9E /* b2Island.h in Headers */, 382383EE1A258FA7002C4610 /* flatbuffers.h in Headers */, + B6CAB4B31AF9AA1A00B9B856 /* SpuContactManifoldCollisionAlgorithm.h in Headers */, 15AE1B5619AADA9900C27E9E /* UIScrollView.h in Headers */, + B6CAB2731AF9AA1A00B9B856 /* btSphereTriangleCollisionAlgorithm.h in Headers */, + B6CAB3AD1AF9AA1A00B9B856 /* btContactSolverInfo.h in Headers */, 50ABBDBB1925AB4100A911A9 /* CCTextureAtlas.h in Headers */, 15FB20911AE7C57D00C31518 /* advancing_front.h in Headers */, 1A570302180BCE890088DEC7 /* CCParallaxNode.h in Headers */, 50ABBE4B1925AB6F00A911A9 /* CCEventAcceleration.h in Headers */, + B6CAB5151AF9AA1A00B9B856 /* btMinMax.h in Headers */, + B6CAB5311AF9AA1A00B9B856 /* btTransform.h in Headers */, + B6CAB2571AF9AA1A00B9B856 /* btGhostObject.h in Headers */, + B6CAB4BD1AF9AA1A00B9B856 /* SpuGatheringCollisionDispatcher.h in Headers */, 1A57030E180BCF190088DEC7 /* CCComponent.h in Headers */, + B6CAB33D1AF9AA1A00B9B856 /* gim_array.h in Headers */, + B6CAB2DB1AF9AA1A00B9B856 /* btPolyhedralConvexShape.h in Headers */, + B6CAB5251AF9AA1A00B9B856 /* btQuickprof.h in Headers */, B665E2AC1AA80A6500DDB1C5 /* CCPUFlockCenteringAffector.h in Headers */, + B6CAB4E91AF9AA1A00B9B856 /* TrbDynBody.h in Headers */, 1A570312180BCF190088DEC7 /* CCComponentContainer.h in Headers */, 15AE1B7119AADA9900C27E9E /* CocosGUI.h in Headers */, B665E2381AA80A6500DDB1C5 /* CCPUBoxEmitterTranslator.h in Headers */, + B6CAB4211AF9AA1A00B9B856 /* btMLCPSolver.h in Headers */, 15AE1A2D19AAD3D500C27E9E /* b2DynamicTree.h in Headers */, + B6CAB3E31AF9AA1A00B9B856 /* btUniversalConstraint.h in Headers */, B665E39C1AA80A6500DDB1C5 /* CCPUPointEmitterTranslator.h in Headers */, + B6CAB41D1AF9AA1A00B9B856 /* btDantzigSolver.h in Headers */, 50ABBD851925AB4100A911A9 /* CCBatchCommand.h in Headers */, + B6CAB3351AF9AA1A00B9B856 /* btGImpactShape.h in Headers */, 15AE1A6F19AAD40300C27E9E /* b2CircleContact.h in Headers */, + B6CAB3431AF9AA1A00B9B856 /* gim_box_collision.h in Headers */, + B6CAB39B1AF9AA1A00B9B856 /* btVoronoiSimplexSolver.h in Headers */, + B6CAB1EB1AF9AA1A00B9B856 /* btBroadphaseInterface.h in Headers */, B665E3E81AA80A6600DDB1C5 /* CCPUSineForceAffectorTranslator.h in Headers */, 15AE191619AAD35000C27E9E /* CCSkin.h in Headers */, 50ABC0651926664800A911A9 /* CCGL-mac.h in Headers */, @@ -7129,23 +9169,29 @@ 15AE1A8B19AAD40300C27E9E /* b2PulleyJoint.h in Headers */, 15AE1A5119AAD40300C27E9E /* b2BlockAllocator.h in Headers */, 15AE199119AAD37200C27E9E /* ImageViewReader.h in Headers */, + B6CAB42B1AF9AA1A00B9B856 /* btRaycastVehicle.h in Headers */, 15AE18FE19AAD35000C27E9E /* CCComAttribute.h in Headers */, B665E38C1AA80A6500DDB1C5 /* CCPUPlane.h in Headers */, B665E3801AA80A6500DDB1C5 /* CCPUParticleSystem3DTranslator.h in Headers */, 50ABBD621925AB0000A911A9 /* Vec4.h in Headers */, + B6CAB4E51AF9AA1A00B9B856 /* SpuSampleTaskProcess.h in Headers */, + B6CAB2B51AF9AA1A00B9B856 /* btConvexShape.h in Headers */, B60C5BD619AC68B10056FBDE /* CCBillBoard.h in Headers */, 15AE1BA419AADFDF00C27E9E /* UILayoutManager.h in Headers */, B6D38B901AC3AFAC00043997 /* CCTextureCube.h in Headers */, 1A01C69418F57BE800EFE3A6 /* CCFloat.h in Headers */, 1A57034D180BD09B0088DEC7 /* tinyxml2.h in Headers */, + B6CAB4C31AF9AA1A00B9B856 /* Box.h in Headers */, 15AE18F519AAD35000C27E9E /* CCArmatureDefine.h in Headers */, 15AE188219AAD33D00C27E9E /* CCBReader.h in Headers */, 1A570356180BD0B00088DEC7 /* ioapi.h in Headers */, 15AE191819AAD35000C27E9E /* CCSpriteFrameCacheHelper.h in Headers */, 15AE1BA219AADFDF00C27E9E /* UILayoutParameter.h in Headers */, + B6CAB4351AF9AA1A00B9B856 /* btGpu3DGridBroadphase.h in Headers */, 50ABBE331925AB6F00A911A9 /* CCConfiguration.h in Headers */, B665E2101AA80A6500DDB1C5 /* CCPUBaseForceAffector.h in Headers */, 382F7ADE1AB1292A002EBECF /* CCObjectExtensionData.h in Headers */, + B6CAB4D51AF9AA1A00B9B856 /* SpuGatheringCollisionTask.h in Headers */, 15AE199519AAD39600C27E9E /* LayoutReader.h in Headers */, 15AE183219AAD2F700C27E9E /* CCOBB.h in Headers */, 15AE1BE319AAE01E00C27E9E /* CCScrollView.h in Headers */, @@ -7155,23 +9201,36 @@ 3823841C1A2590D2002C4610 /* ComAudioReader.h in Headers */, 50ABC01F1926664800A911A9 /* CCThread.h in Headers */, B665E4141AA80A6600DDB1C5 /* CCPUTextureAnimator.h in Headers */, + B6CAB3F31AF9AA1A00B9B856 /* btSimpleDynamicsWorld.h in Headers */, 1A57035A180BD0B00088DEC7 /* unzip.h in Headers */, + B6CAB1FF1AF9AA1A00B9B856 /* btDispatcher.h in Headers */, 15AE188B19AAD33D00C27E9E /* CCControlLoader.h in Headers */, B29A7DF719EE1B7700872B35 /* Attachment.h in Headers */, 15FB208D1AE7C57D00C31518 /* poly2tri.h in Headers */, + B6CAB3091AF9AA1A00B9B856 /* btTriangleMesh.h in Headers */, + B6CAB4AF1AF9AA1A00B9B856 /* SpuCollisionTaskProcess.h in Headers */, 15AE1BCA19AAE01E00C27E9E /* CCControl.h in Headers */, + B6CAB3C11AF9AA1A00B9B856 /* btHinge2Constraint.h in Headers */, 50ABBDBF1925AB4100A911A9 /* CCTextureCache.h in Headers */, + B6CAB2E31AF9AA1A00B9B856 /* btShapeHull.h in Headers */, B29A7E0D19EE1B7700872B35 /* Bone.h in Headers */, 15AE186719AAD31D00C27E9E /* CDXMacOSXSupport.h in Headers */, + B6CAB5131AF9AA1A00B9B856 /* btMatrixX.h in Headers */, + B6CAB4091AF9AA1A00B9B856 /* btMultiBodyJointLimitConstraint.h in Headers */, + B6CAB4B91AF9AA1A00B9B856 /* SpuFakeDma.h in Headers */, B29A7DCD19EE1B7700872B35 /* Slot.h in Headers */, + B6CAB1E31AF9AA1A00B9B856 /* btBulletDynamicsCommon.h in Headers */, 382384311A259112002C4610 /* ParticleReader.h in Headers */, + B6CAB3BD1AF9AA1A00B9B856 /* btGeneric6DofSpringConstraint.h in Headers */, B665E3D01AA80A6600DDB1C5 /* CCPUScriptCompiler.h in Headers */, 5034CA35191D591100CE6051 /* ccShader_PositionTexture.frag in Headers */, 15AE1BB219AADFEF00C27E9E /* HttpClient.h in Headers */, + B6CAB3FD1AF9AA1A00B9B856 /* btMultiBodyConstraint.h in Headers */, 15AE197619AAD35700C27E9E /* CCTimelineMacro.h in Headers */, 50ABBE6F1925AB6F00A911A9 /* CCEventListenerKeyboard.h in Headers */, 15AE1A5619AAD40300C27E9E /* b2Math.h in Headers */, 18956BB41A9DFBFD006E9155 /* Particle3DReader.h in Headers */, + B6CAB5071AF9AA1A00B9B856 /* btGeometryUtil.h in Headers */, 50ABBE9D1925AB6F00A911A9 /* CCRefPtr.h in Headers */, 15AE198319AAD36400C27E9E /* WidgetReader.h in Headers */, B257B461198A353E00D9A687 /* CCPrimitiveCommand.h in Headers */, @@ -7187,33 +9246,52 @@ 15AE1A8D19AAD40300C27E9E /* b2RevoluteJoint.h in Headers */, 50ABBE291925AB6F00A911A9 /* CCAutoreleasePool.h in Headers */, 299CF1FD19A434BC00C378C1 /* ccRandom.h in Headers */, + B6CAB5451AF9AA1A00B9B856 /* MiniCLTask.h in Headers */, 15AE1A2F19AAD3D500C27E9E /* b2TimeOfImpact.h in Headers */, 15AE18F319AAD35000C27E9E /* CCArmatureDataManager.h in Headers */, B665E2C01AA80A6500DDB1C5 /* CCPUGeometryRotator.h in Headers */, 50ABBE471925AB6F00A911A9 /* CCEvent.h in Headers */, + 5012169C1AC473A3009A4BEA /* CCTechnique.h in Headers */, 15AE1B9E19AADFDF00C27E9E /* UIVBox.h in Headers */, 15AE192319AAD35000C27E9E /* DictionaryHelper.h in Headers */, + B6CAB2DF1AF9AA1A00B9B856 /* btScaledBvhTriangleMeshShape.h in Headers */, + B6CAB3B51AF9AA1A00B9B856 /* btGearConstraint.h in Headers */, + B6CAB4051AF9AA1A00B9B856 /* btMultiBodyDynamicsWorld.h in Headers */, B665E3D41AA80A6600DDB1C5 /* CCPUScriptLexer.h in Headers */, B257B4501989D5E800D9A687 /* CCPrimitive.h in Headers */, + B6CAB2C71AF9AA1A00B9B856 /* btMaterial.h in Headers */, B29A7DCF19EE1B7700872B35 /* RegionAttachment.h in Headers */, 15B3707E19EE414C00ABE682 /* CCEventAssetsManagerEx.h in Headers */, 50ABBE6B1925AB6F00A911A9 /* CCEventListenerFocus.h in Headers */, + B6CAAFF41AF9A9E100B9B856 /* CCPhysics3DObject.h in Headers */, + B6CAB4D71AF9AA1A00B9B856 /* SpuLocalSupport.h in Headers */, + B6CAB2671AF9AA1A00B9B856 /* btSimulationIslandManager.h in Headers */, 50ABBDA51925AB4100A911A9 /* CCQuadCommand.h in Headers */, + B6CAB3751AF9AA1A00B9B856 /* btGjkEpa2.h in Headers */, 15AE1BCF19AAE01E00C27E9E /* CCControlExtensions.h in Headers */, + B6CAB1F31AF9AA1A00B9B856 /* btCollisionAlgorithm.h in Headers */, 15AE1A3519AAD3D500C27E9E /* b2EdgeShape.h in Headers */, + B6CAB3151AF9AA1A00B9B856 /* btBoxCollision.h in Headers */, 50643BD919BFAF4400EF68ED /* CCApplication.h in Headers */, B665E3581AA80A6500DDB1C5 /* CCPUOnQuotaObserverTranslator.h in Headers */, + B6CAB2371AF9AA1A00B9B856 /* btCompoundCollisionAlgorithm.h in Headers */, B665E3DC1AA80A6600DDB1C5 /* CCPUScriptTranslator.h in Headers */, + B6CAB49B1AF9AA1A00B9B856 /* HeapManager.h in Headers */, 15AE183619AAD2F700C27E9E /* CCObjLoader.h in Headers */, 15AE1BE719AAE01E00C27E9E /* CCTableViewCell.h in Headers */, 15AE1A8919AAD40300C27E9E /* b2PrismaticJoint.h in Headers */, + B6CAB5211AF9AA1A00B9B856 /* btQuaternion.h in Headers */, B665E2341AA80A6500DDB1C5 /* CCPUBoxEmitter.h in Headers */, + B6CAB26F1AF9AA1A00B9B856 /* btSphereSphereCollisionAlgorithm.h in Headers */, B665E3EC1AA80A6600DDB1C5 /* CCPUSlaveBehaviour.h in Headers */, 50ABBD3A1925AB0000A911A9 /* CCAffineTransform.h in Headers */, 15AE186C19AAD31D00C27E9E /* SimpleAudioEngine_objc.h in Headers */, B29A7E2319EE1B7700872B35 /* IkConstraint.h in Headers */, 15AE1BB319AADFEF00C27E9E /* HttpRequest.h in Headers */, + B6CAB3B11AF9AA1A00B9B856 /* btFixedConstraint.h in Headers */, 3823843F1A259140002C4610 /* SingleNodeReader.h in Headers */, + B6CAB35B1AF9AA1A00B9B856 /* gim_memory.h in Headers */, + B6CAB3DF1AF9AA1A00B9B856 /* btTypedConstraint.h in Headers */, 50ABBE571925AB6F00A911A9 /* CCEventFocus.h in Headers */, 1A01C69218F57BE800EFE3A6 /* CCDouble.h in Headers */, 15AE18F919AAD35000C27E9E /* CCBone.h in Headers */, @@ -7226,17 +9304,21 @@ B665E2281AA80A6500DDB1C5 /* CCPUBillboardChain.h in Headers */, 15AE18A919AAD33D00C27E9E /* CCSpriteLoader.h in Headers */, 15AE198419AAD36400C27E9E /* WidgetReaderProtocol.h in Headers */, + B6CAB53D1AF9AA1A00B9B856 /* cl_MiniCL_Defs.h in Headers */, 50ABBEC91925AB6F00A911A9 /* firePngData.h in Headers */, 292DB16119B461CA00A80320 /* ExtensionDeprecated.h in Headers */, 503DD8F51926B0DB00CD74DD /* CCIMEDelegate.h in Headers */, 3EACC9A619F5014D00EB3C5E /* CCLight.h in Headers */, 50ABBD5A1925AB0000A911A9 /* Vec2.h in Headers */, B665E2581AA80A6500DDB1C5 /* CCPUDoAffectorEventHandlerTranslator.h in Headers */, + B6CAB50D1AF9AA1A00B9B856 /* btIDebugDraw.h in Headers */, B665E2F81AA80A6500DDB1C5 /* CCPUListener.h in Headers */, + B6CAB3F91AF9AA1A00B9B856 /* btMultiBody.h in Headers */, 15AE1BDB19AAE01E00C27E9E /* CCControlSwitch.h in Headers */, B24AA987195A675C007B4522 /* CCFastTMXLayer.h in Headers */, 15AE188F19AAD33D00C27E9E /* CCLabelTTFLoader.h in Headers */, 50ABBEBD1925AB6F00A911A9 /* ccUtils.h in Headers */, + B6CAB4171AF9AA1A00B9B856 /* btMultiBodySolverConstraint.h in Headers */, 15AE19A119AAD39600C27E9E /* TextAtlasReader.h in Headers */, 50ABC0231926664800A911A9 /* CCGLViewImpl-desktop.h in Headers */, 382384231A2590DA002C4610 /* GameMapReader.h in Headers */, @@ -7247,14 +9329,19 @@ 15AE1B5019AADA9900C27E9E /* UILoadingBar.h in Headers */, 50ABBFFD1926664800A911A9 /* CCFileUtils-apple.h in Headers */, 15B3708219EE414C00ABE682 /* CCEventListenerAssetsManagerEx.h in Headers */, + B6CAB2951AF9AA1A00B9B856 /* btCompoundShape.h in Headers */, B665E23C1AA80A6500DDB1C5 /* CCPUCircleEmitter.h in Headers */, + B6CAB2991AF9AA1A00B9B856 /* btConcaveShape.h in Headers */, + B6CAB1E51AF9AA1A00B9B856 /* Bullet-C-Api.h in Headers */, 15B3708619EE414C00ABE682 /* Downloader.h in Headers */, + B6CAB4111AF9AA1A00B9B856 /* btMultiBodyLinkCollider.h in Headers */, B665E36C1AA80A6500DDB1C5 /* CCPUOnVelocityObserver.h in Headers */, B665E26C1AA80A6500DDB1C5 /* CCPUDoFreezeEventHandler.h in Headers */, 5E9F612C1A3FFE3D0038DE01 /* CCPlane.h in Headers */, 5034CA41191D591100CE6051 /* ccShader_Position_uColor.frag in Headers */, 50ABBE7F1925AB6F00A911A9 /* CCEventTouch.h in Headers */, 50ABBE5B1925AB6F00A911A9 /* CCEventKeyboard.h in Headers */, + B6CAB2D31AF9AA1A00B9B856 /* btMultiSphereShape.h in Headers */, B665E1F41AA80A6500DDB1C5 /* CCPUAffector.h in Headers */, 1A01C69E18F57BE800EFE3A6 /* CCString.h in Headers */, 15FB206C1AE7BE7400C31518 /* SpritePolygon.h in Headers */, @@ -7270,10 +9357,16 @@ 50ABBE3F1925AB6F00A911A9 /* CCDataVisitor.h in Headers */, 15AE199F19AAD39600C27E9E /* SliderReader.h in Headers */, B665E2641AA80A6500DDB1C5 /* CCPUDoExpireEventHandler.h in Headers */, + B6CAB2B91AF9AA1A00B9B856 /* btConvexTriangleMeshShape.h in Headers */, + B6CAB32B1AF9AA1A00B9B856 /* btGImpactCollisionAlgorithm.h in Headers */, + B6CAB24F1AF9AA1A00B9B856 /* btDefaultCollisionConfiguration.h in Headers */, 50ABBD9D1925AB4100A911A9 /* ccGLStateCache.h in Headers */, B665E3241AA80A6500DDB1C5 /* CCPUOnCollisionObserver.h in Headers */, + B6CAB4C11AF9AA1A00B9B856 /* SpuLibspe2Support.h in Headers */, + B6CAB26B1AF9AA1A00B9B856 /* btSphereBoxCollisionAlgorithm.h in Headers */, B29A7E0319EE1B7700872B35 /* BoundingBoxAttachment.h in Headers */, 50ABBEB91925AB6F00A911A9 /* ccUTF8.h in Headers */, + B6CAB3C51AF9AA1A00B9B856 /* btHingeConstraint.h in Headers */, 15AE191A19AAD35000C27E9E /* CCSSceneReader.h in Headers */, B665E2241AA80A6500DDB1C5 /* CCPUBehaviourTranslator.h in Headers */, 292DB13F19B4574100A80320 /* UIEditBox.h in Headers */, @@ -7282,10 +9375,12 @@ 50ABBE671925AB6F00A911A9 /* CCEventListenerCustom.h in Headers */, 15AE18E219AAD35000C27E9E /* TriggerMng.h in Headers */, B665E3CC1AA80A6600DDB1C5 /* CCPUScaleVelocityAffectorTranslator.h in Headers */, + B6CAB2D71AF9AA1A00B9B856 /* btOptimizedBvh.h in Headers */, 50ABBE2F1925AB6F00A911A9 /* ccConfig.h in Headers */, 15AE188019AAD33D00C27E9E /* CCBMemberVariableAssigner.h in Headers */, 1AAF5851180E40B9000584C8 /* LocalStorage.h in Headers */, 1A01C69018F57BE800EFE3A6 /* CCDictionary.h in Headers */, + B6CAB4ED1AF9AA1A00B9B856 /* vectormath2bullet.h in Headers */, 1A9DCA29180E6955007A3AD4 /* CCGLBufferedNode.h in Headers */, 50ABC0031926664800A911A9 /* CCLock-apple.h in Headers */, 50ABBE2D1925AB6F00A911A9 /* ccCArray.h in Headers */, @@ -7304,36 +9399,53 @@ 15AE189C19AAD33D00C27E9E /* CCNode+CCBRelativePositioning.h in Headers */, 15AE190A19AAD35000C27E9E /* CCDecorativeDisplay.h in Headers */, 50ABBDB31925AB4100A911A9 /* ccShaders.h in Headers */, + B6CAB3831AF9AA1A00B9B856 /* btMinkowskiPenetrationDepthSolver.h in Headers */, 50ABBDAB1925AB4100A911A9 /* CCRenderCommandPool.h in Headers */, 5034CA45191D591100CE6051 /* ccShader_Label_outline.frag in Headers */, + B6CAB4311AF9AA1A00B9B856 /* btWheelInfo.h in Headers */, D0FD035F1A3B51AA00825BB5 /* CCAllocatorStrategyPool.h in Headers */, + B6CAB3611AF9AA1A00B9B856 /* gim_tri_collision.h in Headers */, B665E3741AA80A6500DDB1C5 /* CCPUParticleFollower.h in Headers */, 50ABBEB11925AB6F00A911A9 /* CCUserDefault.h in Headers */, B29A7DEF19EE1B7700872B35 /* SkeletonBounds.h in Headers */, D0FD034D1A3B51AA00825BB5 /* CCAllocatorDiagnostics.h in Headers */, 50ABBEC71925AB6F00A911A9 /* etc1.h in Headers */, + B6CAB27B1AF9AA1A00B9B856 /* SphereTriangleDetector.h in Headers */, B29A7E3519EE1B7700872B35 /* AnimationStateData.h in Headers */, B665E2FC1AA80A6500DDB1C5 /* CCPUMaterialManager.h in Headers */, 15AE1BC619AAE00000C27E9E /* AssetsManager.h in Headers */, 50ABBEA91925AB6F00A911A9 /* CCTouch.h in Headers */, + B6CAB51F1AF9AA1A00B9B856 /* btQuadWord.h in Headers */, 15AE1A5E19AAD40300C27E9E /* b2Body.h in Headers */, + B6CAB22F1AF9AA1A00B9B856 /* btCollisionObjectWrapper.h in Headers */, 50ABBE971925AB6F00A911A9 /* CCProtocols.h in Headers */, 50ABC0691926664800A911A9 /* CCStdC-mac.h in Headers */, + B6CAB52F1AF9AA1A00B9B856 /* btStackAlloc.h in Headers */, + B6CAB1F71AF9AA1A00B9B856 /* btDbvt.h in Headers */, B665E34C1AA80A6500DDB1C5 /* CCPUOnPositionObserver.h in Headers */, + 501216901AC47380009A4BEA /* CCRenderState.h in Headers */, + B6CAB2091AF9AA1A00B9B856 /* btOverlappingPairCallback.h in Headers */, 15AE1A2B19AAD3D500C27E9E /* b2Distance.h in Headers */, 15AE198919AAD36A00C27E9E /* ButtonReader.h in Headers */, 15AE190219AAD35000C27E9E /* CCComController.h in Headers */, + B6CAB37F1AF9AA1A00B9B856 /* btManifoldPoint.h in Headers */, 15AE18DE19AAD35000C27E9E /* TriggerObj.h in Headers */, 15AE183E19AAD2F700C27E9E /* CCSkeleton3D.h in Headers */, + B6CAB5371AF9AA1A00B9B856 /* btVector3.h in Headers */, + B6CAB2EB1AF9AA1A00B9B856 /* btStaticPlaneShape.h in Headers */, 3EACC9A219F5014D00EB3C5E /* CCCamera.h in Headers */, + B6CAB5331AF9AA1A00B9B856 /* btTransformUtil.h in Headers */, 50ABBECD1925AB6F00A911A9 /* s3tc.h in Headers */, + B6CAB3651AF9AA1A00B9B856 /* btContinuousConvexCollision.h in Headers */, 15AE1BD119AAE01E00C27E9E /* CCControlHuePicker.h in Headers */, D0FD03571A3B51AA00825BB5 /* CCAllocatorMutex.h in Headers */, + B6CAB36D1AF9AA1A00B9B856 /* btDiscreteCollisionDetectorInterface.h in Headers */, 50ABBE771925AB6F00A911A9 /* CCEventListenerTouch.h in Headers */, 5034CA33191D591100CE6051 /* ccShader_PositionTexture_uColor.frag in Headers */, B665E4341AA80A6600DDB1C5 /* CCPUVertexEmitter.h in Headers */, 50ABC0171926664800A911A9 /* CCImage.h in Headers */, 50ABBDA91925AB4100A911A9 /* CCRenderCommand.h in Headers */, + B6CAB3791AF9AA1A00B9B856 /* btGjkEpaPenetrationDepthSolver.h in Headers */, 50ABBD951925AB4100A911A9 /* CCGLProgramState.h in Headers */, 50ABC0091926664800A911A9 /* CCCommon.h in Headers */, 50ABBE531925AB6F00A911A9 /* CCEventDispatcher.h in Headers */, @@ -7348,23 +9460,32 @@ files = ( 503DD8F01926736A00CD74DD /* CCStdC-ios.h in Headers */, 15AE1A9A19AAD40300C27E9E /* b2Math.h in Headers */, + B6CAB3221AF9AA1A00B9B856 /* btGenericPoolAllocator.h in Headers */, B665E3851AA80A6500DDB1C5 /* CCPUPathFollower.h in Headers */, 46A170FF1807CECB005B8026 /* CCPhysicsContact.h in Headers */, + B6CAB37E1AF9AA1A00B9B856 /* btGjkPairDetector.h in Headers */, + B6CAB3101AF9AA1A00B9B856 /* btTriangleShape.h in Headers */, + B6CAB5141AF9AA1A00B9B856 /* btMatrixX.h in Headers */, 3EACC9A319F5014D00EB3C5E /* CCCamera.h in Headers */, B29A7E1A19EE1B7700872B35 /* Event.h in Headers */, 15AE1AC719AAD40300C27E9E /* b2GearJoint.h in Headers */, B665E2ED1AA80A6500DDB1C5 /* CCPULinearForceAffectorTranslator.h in Headers */, + B6CAB20A1AF9AA1A00B9B856 /* btOverlappingPairCallback.h in Headers */, 50ABBDA21925AB4100A911A9 /* CCGroupCommand.h in Headers */, 15AE18C219AAD33D00C27E9E /* CCLayerColorLoader.h in Headers */, 50643BDA19BFAF4400EF68ED /* CCApplication.h in Headers */, + B6CAB53A1AF9AA1A00B9B856 /* cl.h in Headers */, 15AE181519AAD2F700C27E9E /* CCAnimationCurve.h in Headers */, + B6CAB28C1AF9AA1A00B9B856 /* btCapsuleShape.h in Headers */, B665E4191AA80A6600DDB1C5 /* CCPUTextureAnimatorTranslator.h in Headers */, 503DD8EF1926736A00CD74DD /* CCPlatformDefine-ios.h in Headers */, 15AE196919AAD35100C27E9E /* CocoStudio.h in Headers */, 46A171041807CECB005B8026 /* CCPhysicsShape.h in Headers */, 15AE183319AAD2F700C27E9E /* CCOBB.h in Headers */, + B6CAB3E61AF9AA1A00B9B856 /* btActionInterface.h in Headers */, B665E33D1AA80A6500DDB1C5 /* CCPUOnEventFlagObserver.h in Headers */, 15AE18B119AAD33D00C27E9E /* CCBMemberVariableAssigner.h in Headers */, + B6CAB2AA1AF9AA1A00B9B856 /* btConvexInternalShape.h in Headers */, B665E3791AA80A6500DDB1C5 /* CCPUParticleFollowerTranslator.h in Headers */, 292DB14019B4574100A80320 /* UIEditBox.h in Headers */, 50ABBD3B1925AB0000A911A9 /* CCAffineTransform.h in Headers */, @@ -7373,9 +9494,13 @@ B29A7E3A19EE1B7700872B35 /* Animation.h in Headers */, 15FB208C1AE7C57D00C31518 /* utils.h in Headers */, B665E2B51AA80A6500DDB1C5 /* CCPUForceField.h in Headers */, + B6CAB36E1AF9AA1A00B9B856 /* btDiscreteCollisionDetectorInterface.h in Headers */, B665E2D91AA80A6500DDB1C5 /* CCPUJetAffector.h in Headers */, 15B3708319EE414C00ABE682 /* CCEventListenerAssetsManagerEx.h in Headers */, + B6CAB4361AF9AA1A00B9B856 /* btGpu3DGridBroadphase.h in Headers */, D0FD03521A3B51AA00825BB5 /* CCAllocatorGlobal.h in Headers */, + B6CAB3DC1AF9AA1A00B9B856 /* btSolverConstraint.h in Headers */, + B6CAB4B61AF9AA1A00B9B856 /* SpuDoubleBuffer.h in Headers */, B665E3D11AA80A6600DDB1C5 /* CCPUScriptCompiler.h in Headers */, B665E3B91AA80A6500DDB1C5 /* CCPURibbonTrail.h in Headers */, 50ABBE7C1925AB6F00A911A9 /* CCEventMouse.h in Headers */, @@ -7395,54 +9520,81 @@ 15AE19B319AAD39700C27E9E /* SliderReader.h in Headers */, 15AE1B7919AADA9A00C27E9E /* UIRichText.h in Headers */, B665E3C11AA80A6500DDB1C5 /* CCPUScaleAffector.h in Headers */, + B6CAB3BA1AF9AA1A00B9B856 /* btGeneric6DofConstraint.h in Headers */, + B6CAB2F81AF9AA1A00B9B856 /* btTriangleBuffer.h in Headers */, 15AE1A4A19AAD3D500C27E9E /* b2CircleShape.h in Headers */, + B6CAB2A61AF9AA1A00B9B856 /* btConvexHullShape.h in Headers */, 50ABBE861925AB6F00A911A9 /* ccFPSImages.h in Headers */, 15B3708719EE414C00ABE682 /* Downloader.h in Headers */, + B6CAB2BE1AF9AA1A00B9B856 /* btCylinderShape.h in Headers */, + B6CAB3F01AF9AA1A00B9B856 /* btRigidBody.h in Headers */, 15AE192619AAD35100C27E9E /* TriggerObj.h in Headers */, B665E2E51AA80A6500DDB1C5 /* CCPULineAffectorTranslator.h in Headers */, 50ABBE2E1925AB6F00A911A9 /* ccCArray.h in Headers */, + B6CAB2C81AF9AA1A00B9B856 /* btMaterial.h in Headers */, 15B3707B19EE414C00ABE682 /* AssetsManagerEx.h in Headers */, B665E3E91AA80A6600DDB1C5 /* CCPUSineForceAffectorTranslator.h in Headers */, + B6CAB2001AF9AA1A00B9B856 /* btDispatcher.h in Headers */, + B6CAB2641AF9AA1A00B9B856 /* btManifoldResult.h in Headers */, + B6CAB5161AF9AA1A00B9B856 /* btMinMax.h in Headers */, 15AE1B9119AADA9A00C27E9E /* UIWidget.h in Headers */, + B6CAB4CC1AF9AA1A00B9B856 /* SpuCollisionShapes.h in Headers */, B665E2611AA80A6500DDB1C5 /* CCPUDoEnableComponentEventHandlerTranslator.h in Headers */, 50ABC0041926664800A911A9 /* CCLock-apple.h in Headers */, B29A7DFE19EE1B7700872B35 /* IkConstraintData.h in Headers */, 382384401A259140002C4610 /* SingleNodeReader.h in Headers */, B665E2751AA80A6500DDB1C5 /* CCPUDoPlacementParticleEventHandler.h in Headers */, + B6CAB35C1AF9AA1A00B9B856 /* gim_memory.h in Headers */, + B6CAB43A1AF9AA1A00B9B856 /* btGpu3DGridBroadphaseSharedDefs.h in Headers */, 15AE1A4019AAD3D500C27E9E /* b2Collision.h in Headers */, B665E36D1AA80A6500DDB1C5 /* CCPUOnVelocityObserver.h in Headers */, + B6CAB4061AF9AA1A00B9B856 /* btMultiBodyDynamicsWorld.h in Headers */, ED74D76A1A5B8A2600157FD4 /* CCPhysicsHelper.h in Headers */, 5034CA40191D591100CE6051 /* ccShader_Position_uColor.vert in Headers */, B665E2891AA80A6500DDB1C5 /* CCPUDoStopSystemEventHandlerTranslator.h in Headers */, 15AE184719AAD2F700C27E9E /* CCSprite3DMaterial.h in Headers */, + B6CAB5101AF9AA1A00B9B856 /* btList.h in Headers */, 15AE1BFC19AAE01E00C27E9E /* CCControlUtils.h in Headers */, 15AE193519AAD35100C27E9E /* CCActionObject.h in Headers */, 15AE1AA919AAD40300C27E9E /* b2TimeStep.h in Headers */, B665E2C91AA80A6500DDB1C5 /* CCPUGravityAffector.h in Headers */, 15AE197A19AAD35700C27E9E /* CCActionTimelineCache.h in Headers */, + B6CAB5301AF9AA1A00B9B856 /* btStackAlloc.h in Headers */, 15AE19B919AAD39700C27E9E /* TextFieldReader.h in Headers */, 15AE181319AAD2F700C27E9E /* CCAnimation3D.h in Headers */, 50ABBEC21925AB6F00A911A9 /* CCValue.h in Headers */, + B6CAB4FE1AF9AA1A00B9B856 /* btConvexHull.h in Headers */, 50ABBECA1925AB6F00A911A9 /* firePngData.h in Headers */, B257B4511989D5E800D9A687 /* CCPrimitive.h in Headers */, 50643BE319BFCF1800EF68ED /* CCPlatformConfig.h in Headers */, B665E27D1AA80A6500DDB1C5 /* CCPUDoScaleEventHandler.h in Headers */, + B6CAB29E1AF9AA1A00B9B856 /* btConeShape.h in Headers */, 15AE181F19AAD2F700C27E9E /* CCBundle3DData.h in Headers */, 15AE193119AAD35100C27E9E /* CCActionManagerEx.h in Headers */, 15AE185B19AAD31200C27E9E /* CDOpenALSupport.h in Headers */, 50ABBE401925AB6F00A911A9 /* CCDataVisitor.h in Headers */, + B6CAB3401AF9AA1A00B9B856 /* gim_basic_geometry_operations.h in Headers */, 15AE19B719AAD39700C27E9E /* TextBMFontReader.h in Headers */, 1A570064180BC5A10088DEC7 /* CCAction.h in Headers */, + B6CAB4BA1AF9AA1A00B9B856 /* SpuFakeDma.h in Headers */, + B6CAB4BE1AF9AA1A00B9B856 /* SpuGatheringCollisionDispatcher.h in Headers */, 15AE1BA819AADFDF00C27E9E /* UIRelativeBox.h in Headers */, 503DD8EC1926736A00CD74DD /* CCGLViewImpl-ios.h in Headers */, 15AE18D819AAD33D00C27E9E /* CCScrollViewLoader.h in Headers */, + B6CAB4B41AF9AA1A00B9B856 /* SpuContactManifoldCollisionAlgorithm.h in Headers */, 15AE18DB19AAD33D00C27E9E /* CocosBuilder.h in Headers */, + B6CAB2601AF9AA1A00B9B856 /* btInternalEdgeUtility.h in Headers */, B665E1F51AA80A6500DDB1C5 /* CCPUAffector.h in Headers */, 15AE1ACD19AAD40300C27E9E /* b2PrismaticJoint.h in Headers */, + B6CAB2B21AF9AA1A00B9B856 /* btConvexPolyhedron.h in Headers */, 50ABBEBA1925AB6F00A911A9 /* ccUTF8.h in Headers */, + B6CAB3A61AF9AA1A00B9B856 /* btConeTwistConstraint.h in Headers */, + B6CAB32E1AF9AA1A00B9B856 /* btGImpactMassUtil.h in Headers */, + B6CAB43C1AF9AA1A00B9B856 /* btGpu3DGridBroadphaseSharedTypes.h in Headers */, 50643BD619BFAEDA00EF68ED /* CCPlatformDefine.h in Headers */, 1A570068180BC5A10088DEC7 /* CCActionCamera.h in Headers */, B29A7E1E19EE1B7700872B35 /* PolygonBatch.h in Headers */, + B6CAB4E61AF9AA1A00B9B856 /* SpuSampleTaskProcess.h in Headers */, 15AE18BC19AAD33D00C27E9E /* CCControlLoader.h in Headers */, 15AE18C019AAD33D00C27E9E /* CCLabelTTFLoader.h in Headers */, 1A57006C180BC5A10088DEC7 /* CCActionCatmullRom.h in Headers */, @@ -7450,16 +9602,20 @@ 5034CA3A191D591100CE6051 /* ccShader_PositionColorLengthTexture.frag in Headers */, D0FD034E1A3B51AA00825BB5 /* CCAllocatorDiagnostics.h in Headers */, B665E2A51AA80A6500DDB1C5 /* CCPUEventHandlerManager.h in Headers */, + B6CAB1FC1AF9AA1A00B9B856 /* btDbvtBroadphase.h in Headers */, DABC9FAC19E7DFA900FA252C /* CCClippingRectangleNode.h in Headers */, B665E4311AA80A6600DDB1C5 /* CCPUVelocityMatchingAffectorTranslator.h in Headers */, + B6CAB2C21AF9AA1A00B9B856 /* btEmptyShape.h in Headers */, B665E3C51AA80A6600DDB1C5 /* CCPUScaleAffectorTranslator.h in Headers */, B665E4351AA80A6600DDB1C5 /* CCPUVertexEmitter.h in Headers */, B665E2451AA80A6500DDB1C5 /* CCPUCollisionAvoidanceAffector.h in Headers */, + B6CAB3381AF9AA1A00B9B856 /* btQuantization.h in Headers */, 50ABBEC41925AB6F00A911A9 /* CCVector.h in Headers */, 15FB20711AE7BE7400C31518 /* SpritePolygonCache.h in Headers */, 50ABBE501925AB6F00A911A9 /* CCEventCustom.h in Headers */, 15AE1AD719AAD40300C27E9E /* b2WheelJoint.h in Headers */, B665E3311AA80A6500DDB1C5 /* CCPUOnCountObserverTranslator.h in Headers */, + B6CAB41C1AF9AA1A00B9B856 /* btDantzigLCP.h in Headers */, B665E2051AA80A6500DDB1C5 /* CCPUAlignAffectorTranslator.h in Headers */, 1A570070180BC5A10088DEC7 /* CCActionEase.h in Headers */, 1A570074180BC5A10088DEC7 /* CCActionGrid.h in Headers */, @@ -7470,7 +9626,10 @@ 50ABBD631925AB0000A911A9 /* Vec4.h in Headers */, B665E3A91AA80A6500DDB1C5 /* CCPURandomiser.h in Headers */, 15AE19AF19AAD39700C27E9E /* PageViewReader.h in Headers */, + B6CAB29A1AF9AA1A00B9B856 /* btConcaveShape.h in Headers */, + B6CAB2AE1AF9AA1A00B9B856 /* btConvexPointCloudShape.h in Headers */, B29A7DD419EE1B7700872B35 /* Skin.h in Headers */, + B6CAB2221AF9AA1A00B9B856 /* btBoxBoxDetector.h in Headers */, B29A7E2419EE1B7700872B35 /* IkConstraint.h in Headers */, 1A01C68918F57BE800EFE3A6 /* CCBool.h in Headers */, B665E2851AA80A6500DDB1C5 /* CCPUDoStopSystemEventHandler.h in Headers */, @@ -7483,8 +9642,10 @@ 382384121A259092002C4610 /* NodeReaderDefine.h in Headers */, 50ABBE781925AB6F00A911A9 /* CCEventListenerTouch.h in Headers */, 15AE1BC019AADFF000C27E9E /* WebSocket.h in Headers */, + B6CAB1E21AF9AA1A00B9B856 /* btBulletCollisionCommon.h in Headers */, B665E2FD1AA80A6500DDB1C5 /* CCPUMaterialManager.h in Headers */, 3823840A1A25900F002C4610 /* FlatBuffersSerialize.h in Headers */, + B6CAB3C61AF9AA1A00B9B856 /* btHingeConstraint.h in Headers */, 1A570080180BC5A10088DEC7 /* CCActionInterval.h in Headers */, B665E2A11AA80A6500DDB1C5 /* CCPUEventHandler.h in Headers */, 15AE192D19AAD35100C27E9E /* CCActionFrame.h in Headers */, @@ -7492,8 +9653,15 @@ 1A570084180BC5A10088DEC7 /* CCActionManager.h in Headers */, B665E3151AA80A6500DDB1C5 /* CCPUObserverManager.h in Headers */, 15AE18C619AAD33D00C27E9E /* CCLayerLoader.h in Headers */, + B6CAB4A41AF9AA1A00B9B856 /* PpuAddressSpace.h in Headers */, + B6CAB2041AF9AA1A00B9B856 /* btMultiSapBroadphase.h in Headers */, B665E2C51AA80A6500DDB1C5 /* CCPUGeometryRotatorTranslator.h in Headers */, + B6CAB2781AF9AA1A00B9B856 /* btUnionFind.h in Headers */, + B6CAB4A81AF9AA1A00B9B856 /* SequentialThreadSupport.h in Headers */, + B6CAB2D81AF9AA1A00B9B856 /* btOptimizedBvh.h in Headers */, + B6CAB3DA1AF9AA1A00B9B856 /* btSolverBody.h in Headers */, 50ABC0141926664800A911A9 /* CCGLView.h in Headers */, + B6CAB5341AF9AA1A00B9B856 /* btTransformUtil.h in Headers */, 1A570088180BC5A10088DEC7 /* CCActionPageTurn3D.h in Headers */, 15AE1B9319AADA9A00C27E9E /* UIHelper.h in Headers */, 50ABBD9E1925AB4100A911A9 /* ccGLStateCache.h in Headers */, @@ -7501,25 +9669,32 @@ B665E30D1AA80A6500DDB1C5 /* CCPUNoise.h in Headers */, 15AE1B9619AADA9A00C27E9E /* CocosGUI.h in Headers */, 1A57008C180BC5A10088DEC7 /* CCActionProgressTimer.h in Headers */, + B6CAB3FE1AF9AA1A00B9B856 /* btMultiBodyConstraint.h in Headers */, B665E21D1AA80A6500DDB1C5 /* CCPUBehaviour.h in Headers */, 1A570090180BC5A10088DEC7 /* CCActionTiledGrid.h in Headers */, B665E2A91AA80A6500DDB1C5 /* CCPUEventHandlerTranslator.h in Headers */, + B6CAB41E1AF9AA1A00B9B856 /* btDantzigSolver.h in Headers */, DA8C62A519E52C6400000516 /* ioapi_mem.h in Headers */, + B6CAB2B61AF9AA1A00B9B856 /* btConvexShape.h in Headers */, 1A570094180BC5A10088DEC7 /* CCActionTween.h in Headers */, 1A57009B180BC5C10088DEC7 /* CCAtlasNode.h in Headers */, 15AE184919AAD2F700C27E9E /* cocos3d.h in Headers */, 1A5700A1180BC5D20088DEC7 /* CCNode.h in Headers */, 15AE181919AAD2F700C27E9E /* CCAttachNode.h in Headers */, + B6CAB23C1AF9AA1A00B9B856 /* btCompoundCompoundCollisionAlgorithm.h in Headers */, 292DB14C19B4574100A80320 /* UIEditBoxImpl-mac.h in Headers */, 15AE1BF019AAE01E00C27E9E /* CCControlHuePicker.h in Headers */, B665E3611AA80A6500DDB1C5 /* CCPUOnRandomObserverTranslator.h in Headers */, B665E3111AA80A6500DDB1C5 /* CCPUObserver.h in Headers */, 15AE18B819AAD33D00C27E9E /* CCBSequenceProperty.h in Headers */, B665E2311AA80A6500DDB1C5 /* CCPUBoxColliderTranslator.h in Headers */, + B6CAB4DE1AF9AA1A00B9B856 /* SpuPreferredPenetrationDirections.h in Headers */, 503DD8E41926736A00CD74DD /* CCDirectorCaller-ios.h in Headers */, 15AE198119AAD35700C27E9E /* CCTimelineMacro.h in Headers */, B29A7E0219EE1B7700872B35 /* extension.h in Headers */, + B6CAB2A21AF9AA1A00B9B856 /* btConvex2dShape.h in Headers */, B665E24D1AA80A6500DDB1C5 /* CCPUColorAffector.h in Headers */, + B6CAB4D61AF9AA1A00B9B856 /* SpuGatheringCollisionTask.h in Headers */, 15AE1B7719AADA9A00C27E9E /* UIPageView.h in Headers */, 50ABBD8A1925AB4100A911A9 /* CCCustomCommand.h in Headers */, 299754F7193EC95400A54AC3 /* ObjectFactory.h in Headers */, @@ -7528,32 +9703,45 @@ B665E3991AA80A6500DDB1C5 /* CCPUPointEmitter.h in Headers */, B29A7E4019EE1B7700872B35 /* AnimationState.h in Headers */, 50ABC0101926664800A911A9 /* CCFileUtils.h in Headers */, + B6CAB53C1AF9AA1A00B9B856 /* cl_gl.h in Headers */, 15AE19A919AAD39700C27E9E /* LayoutReader.h in Headers */, B665E29D1AA80A6500DDB1C5 /* CCPUEmitterTranslator.h in Headers */, 15AE1B7B19AADA9A00C27E9E /* UIScrollView.h in Headers */, 5034CA30191D591100CE6051 /* ccShader_PositionTexture.vert in Headers */, 382384391A259126002C4610 /* ProjectNodeReader.h in Headers */, 1A570111180BC8EE0088DEC7 /* CCDrawingPrimitives.h in Headers */, + B6CAB5121AF9AA1A00B9B856 /* btMatrix3x3.h in Headers */, 50ABBE381925AB6F00A911A9 /* CCConsole.h in Headers */, + B6CAB3EA1AF9AA1A00B9B856 /* btDiscreteDynamicsWorld.h in Headers */, 50ABBE8A1925AB6F00A911A9 /* CCMap.h in Headers */, B665E32D1AA80A6500DDB1C5 /* CCPUOnCountObserver.h in Headers */, 503DD8E61926736A00CD74DD /* CCEAGLView-ios.h in Headers */, 50ABBE4C1925AB6F00A911A9 /* CCEventAcceleration.h in Headers */, B665E2F91AA80A6500DDB1C5 /* CCPUListener.h in Headers */, + B6CAB4F41AF9AA1A00B9B856 /* btAabbUtil2.h in Headers */, 50ABBD571925AB0000A911A9 /* TransformUtils.h in Headers */, B665E2711AA80A6500DDB1C5 /* CCPUDoFreezeEventHandlerTranslator.h in Headers */, 1A570115180BC8EE0088DEC7 /* CCDrawNode.h in Headers */, + B6CAB2341AF9AA1A00B9B856 /* btCollisionWorld.h in Headers */, 1A57011E180BC90D0088DEC7 /* CCGrabber.h in Headers */, + B6CAB4A21AF9AA1A00B9B856 /* PosixThreadSupport.h in Headers */, + B6CAB3061AF9AA1A00B9B856 /* btTriangleInfoMap.h in Headers */, 1A570122180BC90D0088DEC7 /* CCGrid.h in Headers */, 15AE1AB319AAD40300C27E9E /* b2CircleContact.h in Headers */, + B6CAB3161AF9AA1A00B9B856 /* btBoxCollision.h in Headers */, 5034CA2E191D591100CE6051 /* ccShader_PositionTextureA8Color.frag in Headers */, + B6CAB31A1AF9AA1A00B9B856 /* btCompoundFromGimpact.h in Headers */, 15AE1A4F19AAD3D500C27E9E /* b2Shape.h in Headers */, 29394CF519B01DBA00D2DE1A /* UIWebViewImpl-ios.h in Headers */, 50ABBD5B1925AB0000A911A9 /* Vec2.h in Headers */, D0FD035E1A3B51AA00825BB5 /* CCAllocatorStrategyGlobalSmallBlock.h in Headers */, 50ABBD411925AB0000A911A9 /* CCMath.h in Headers */, 1A5701A0180BCB590088DEC7 /* CCFont.h in Headers */, + B6CAB2EC1AF9AA1A00B9B856 /* btStaticPlaneShape.h in Headers */, + B6CAB2DC1AF9AA1A00B9B856 /* btPolyhedralConvexShape.h in Headers */, 292DB14819B4574100A80320 /* UIEditBoxImpl-ios.h in Headers */, + B6CAB54A1AF9AA1A00B9B856 /* MiniCLTaskScheduler.h in Headers */, + B6CAB3621AF9AA1A00B9B856 /* gim_tri_collision.h in Headers */, 3E2BDADE19C030ED0055CDCD /* AudioEngine.h in Headers */, B665E3011AA80A6500DDB1C5 /* CCPUMaterialTranslator.h in Headers */, 50ABBD9A1925AB4100A911A9 /* CCGLProgramStateCache.h in Headers */, @@ -7565,35 +9753,47 @@ B60C5BD719AC68B10056FBDE /* CCBillBoard.h in Headers */, B230ED7419B417AE00364AA8 /* CCTrianglesCommand.h in Headers */, B665E2911AA80A6500DDB1C5 /* CCPUDynamicAttributeTranslator.h in Headers */, + B6CAB3D01AF9AA1A00B9B856 /* btSequentialImpulseConstraintSolver.h in Headers */, 50ED2BE119BEAF7900A0AB90 /* UIEditBoxImpl-win32.h in Headers */, 15AE1ACB19AAD40300C27E9E /* b2MouseJoint.h in Headers */, B665E3491AA80A6500DDB1C5 /* CCPUOnExpireObserverTranslator.h in Headers */, 50ABBD3F1925AB0000A911A9 /* CCGeometry.h in Headers */, + B6CAB4F21AF9AA1A00B9B856 /* Win32ThreadSupport.h in Headers */, B665E3291AA80A6500DDB1C5 /* CCPUOnCollisionObserverTranslator.h in Headers */, B29A7DD019EE1B7700872B35 /* RegionAttachment.h in Headers */, D0FD034A1A3B51AA00825BB5 /* CCAllocatorBase.h in Headers */, + B6CAB51E1AF9AA1A00B9B856 /* btPoolAllocator.h in Headers */, 15AE1AD319AAD40300C27E9E /* b2RopeJoint.h in Headers */, + B6CAB3581AF9AA1A00B9B856 /* gim_math.h in Headers */, 50ABBFFE1926664800A911A9 /* CCFileUtils-apple.h in Headers */, 15AE1AAD19AAD40300C27E9E /* b2WorldCallbacks.h in Headers */, 1A5701A4180BCB590088DEC7 /* CCFontAtlas.h in Headers */, + B6CAB4C41AF9AA1A00B9B856 /* Box.h in Headers */, 15AE1C0219AAE01E00C27E9E /* CCScrollView.h in Headers */, 1A5701A8180BCB590088DEC7 /* CCFontAtlasCache.h in Headers */, B665E3E51AA80A6600DDB1C5 /* CCPUSineForceAffector.h in Headers */, 182C5CE81A9D725400C30D34 /* UserCameraReader.h in Headers */, 15AE1A4C19AAD3D500C27E9E /* b2EdgeShape.h in Headers */, + B6CAB39C1AF9AA1A00B9B856 /* btVoronoiSimplexSolver.h in Headers */, + B6CAB2701AF9AA1A00B9B856 /* btSphereSphereCollisionAlgorithm.h in Headers */, 1A5701B4180BCB590088DEC7 /* CCFontFNT.h in Headers */, 15AE18D419AAD33D00C27E9E /* CCParticleSystemQuadLoader.h in Headers */, B665E3411AA80A6500DDB1C5 /* CCPUOnEventFlagObserverTranslator.h in Headers */, + B6CAB5041AF9AA1A00B9B856 /* btDefaultMotionState.h in Headers */, + B6CAB52A1AF9AA1A00B9B856 /* btScalar.h in Headers */, B29A7DFA19EE1B7700872B35 /* Json.h in Headers */, 3823842B1A2590F9002C4610 /* NodeReader.h in Headers */, + B6CAB3241AF9AA1A00B9B856 /* btGeometryOperations.h in Headers */, 1A5701B8180BCB5A0088DEC7 /* CCFontFreeType.h in Headers */, 15AE182719AAD2F700C27E9E /* CCMesh.h in Headers */, + B6CAB1EC1AF9AA1A00B9B856 /* btBroadphaseInterface.h in Headers */, 15AE199319AAD37300C27E9E /* ImageViewReader.h in Headers */, B665E2791AA80A6500DDB1C5 /* CCPUDoPlacementParticleEventHandlerTranslator.h in Headers */, 15AE1A4819AAD3D500C27E9E /* b2ChainShape.h in Headers */, B665E3091AA80A6500DDB1C5 /* CCPUMeshSurfaceEmitterTranslator.h in Headers */, 15AE18CB19AAD33D00C27E9E /* CCMenuLoader.h in Headers */, B665E4011AA80A6600DDB1C5 /* CCPUSphereCollider.h in Headers */, + B6CAB31E1AF9AA1A00B9B856 /* btContactProcessing.h in Headers */, 1A5701BC180BCB5A0088DEC7 /* CCLabel.h in Headers */, B665E2D51AA80A6500DDB1C5 /* CCPUInterParticleColliderTranslator.h in Headers */, 1A5701C0180BCB5A0088DEC7 /* CCLabelAtlas.h in Headers */, @@ -7601,34 +9801,55 @@ 50ABBE681925AB6F00A911A9 /* CCEventListenerCustom.h in Headers */, B665E2AD1AA80A6500DDB1C5 /* CCPUFlockCenteringAffector.h in Headers */, 15AE196B19AAD35100C27E9E /* DictionaryHelper.h in Headers */, + B6CAB4C21AF9AA1A00B9B856 /* SpuLibspe2Support.h in Headers */, + B6CAB5021AF9AA1A00B9B856 /* btConvexHullComputer.h in Headers */, B665E2411AA80A6500DDB1C5 /* CCPUCircleEmitterTranslator.h in Headers */, + B6CAB2BA1AF9AA1A00B9B856 /* btConvexTriangleMeshShape.h in Headers */, 15AE1AA619AAD40300C27E9E /* b2Fixture.h in Headers */, + B6CAB3C21AF9AA1A00B9B856 /* btHinge2Constraint.h in Headers */, + B6CAB2121AF9AA1A00B9B856 /* btSimpleBroadphase.h in Headers */, + B6CAB4EE1AF9AA1A00B9B856 /* vectormath2bullet.h in Headers */, 15AE1BBA19AADFF000C27E9E /* HttpClient.h in Headers */, + B6CAB2241AF9AA1A00B9B856 /* btCollisionConfiguration.h in Headers */, 292DB14619B4574100A80320 /* UIEditBoxImpl-android.h in Headers */, + B6CAB49E1AF9AA1A00B9B856 /* PlatformDefinitions.h in Headers */, B665E2DD1AA80A6500DDB1C5 /* CCPUJetAffectorTranslator.h in Headers */, 15AE1B9419AADA9A00C27E9E /* GUIDefine.h in Headers */, + B6CAB3E41AF9AA1A00B9B856 /* btUniversalConstraint.h in Headers */, 15AE183B19AAD2F700C27E9E /* CCRay.h in Headers */, 5034CA42191D591100CE6051 /* ccShader_Position_uColor.frag in Headers */, 1A5701C4180BCB5A0088DEC7 /* CCLabelBMFont.h in Headers */, + B6CAB4D01AF9AA1A00B9B856 /* SpuContactResult.h in Headers */, 15AE193F19AAD35100C27E9E /* CCBatchNode.h in Headers */, B665E37D1AA80A6500DDB1C5 /* CCPUParticleSystem3D.h in Headers */, B665E25D1AA80A6500DDB1C5 /* CCPUDoEnableComponentEventHandler.h in Headers */, + B6CAB3141AF9AA1A00B9B856 /* btUniformScalingShape.h in Headers */, B665E39D1AA80A6500DDB1C5 /* CCPUPointEmitterTranslator.h in Headers */, + B6CAB4261AF9AA1A00B9B856 /* btPATHSolver.h in Headers */, 15AE1C1819AAE2C700C27E9E /* CCPhysicsSprite.h in Headers */, 15AE1BC819AAE00000C27E9E /* AssetsManager.h in Headers */, B665E2E11AA80A6500DDB1C5 /* CCPULineAffector.h in Headers */, B29A7E0419EE1B7700872B35 /* BoundingBoxAttachment.h in Headers */, + B6CAB51C1AF9AA1A00B9B856 /* btPolarDecomposition.h in Headers */, 52B47A2E1A5349A3004E4C60 /* HttpAsynConnection.h in Headers */, + B6CAB2E41AF9AA1A00B9B856 /* btShapeHull.h in Headers */, 15AE1BBC19AADFF000C27E9E /* HttpResponse.h in Headers */, 15AE186019AAD31200C27E9E /* SimpleAudioEngine_objc.h in Headers */, 50ABBDA61925AB4100A911A9 /* CCQuadCommand.h in Headers */, 15AE1BB019AADFDF00C27E9E /* UILayoutManager.h in Headers */, + B6CAB2E01AF9AA1A00B9B856 /* btScaledBvhTriangleMeshShape.h in Headers */, 50ABBE9E1925AB6F00A911A9 /* CCRefPtr.h in Headers */, 15AE18DA19AAD33D00C27E9E /* CCSpriteLoader.h in Headers */, + B6CAB4401AF9AA1A00B9B856 /* btGpuUtilsSharedCode.h in Headers */, 15AE196219AAD35100C27E9E /* CCSSceneReader.h in Headers */, 1A01C69518F57BE800EFE3A6 /* CCFloat.h in Headers */, B665E2011AA80A6500DDB1C5 /* CCPUAlignAffector.h in Headers */, + B6CAB49C1AF9AA1A00B9B856 /* HeapManager.h in Headers */, 1A5701CA180BCB5A0088DEC7 /* CCLabelTextFormatter.h in Headers */, + B6CAB25C1AF9AA1A00B9B856 /* btHashedSimplePairCache.h in Headers */, + B6CAB5201AF9AA1A00B9B856 /* btQuadWord.h in Headers */, + B6CAB4E21AF9AA1A00B9B856 /* SpuSampleTask.h in Headers */, + B6CAB5221AF9AA1A00B9B856 /* btQuaternion.h in Headers */, 50643BDC19BFAF4400EF68ED /* CCStdC.h in Headers */, 5034CA22191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest.frag in Headers */, 15AE1B8E19AADA9A00C27E9E /* UIDeprecated.h in Headers */, @@ -7649,17 +9870,25 @@ 1A5701CE180BCB5A0088DEC7 /* CCLabelTTF.h in Headers */, 15AE1AB119AAD40300C27E9E /* b2ChainAndPolygonContact.h in Headers */, B665E4211AA80A6600DDB1C5 /* CCPUTextureRotatorTranslator.h in Headers */, + 501216911AC47380009A4BEA /* CCRenderState.h in Headers */, + B6CAB2081AF9AA1A00B9B856 /* btOverlappingPairCache.h in Headers */, 1A5701E1180BCB8C0088DEC7 /* CCLayer.h in Headers */, + B6CAB40E1AF9AA1A00B9B856 /* btMultiBodyJointMotor.h in Headers */, + B6CAB2801AF9AA1A00B9B856 /* btBox2dShape.h in Headers */, + B6CAB2541AF9AA1A00B9B856 /* btEmptyCollisionAlgorithm.h in Headers */, B665E3691AA80A6500DDB1C5 /* CCPUOnTimeObserverTranslator.h in Headers */, 15AE1BEE19AAE01E00C27E9E /* CCControlExtensions.h in Headers */, 1A5701E5180BCB8C0088DEC7 /* CCScene.h in Headers */, + B6CAB2F41AF9AA1A00B9B856 /* btTetrahedronShape.h in Headers */, 1A5701E9180BCB8C0088DEC7 /* CCTransition.h in Headers */, 15AE198F19AAD36E00C27E9E /* CheckBoxReader.h in Headers */, B665E3911AA80A6500DDB1C5 /* CCPUPlaneCollider.h in Headers */, 382384011A258FA7002C4610 /* util.h in Headers */, 18956BB51A9DFBFD006E9155 /* Particle3DReader.h in Headers */, + B6CAB34A1AF9AA1A00B9B856 /* gim_clip_polygon.h in Headers */, B665E3F91AA80A6600DDB1C5 /* CCPUSlaveEmitterTranslator.h in Headers */, B665E2551AA80A6500DDB1C5 /* CCPUDoAffectorEventHandler.h in Headers */, + B6CAB4161AF9AA1A00B9B856 /* btMultiBodyPoint2Point.h in Headers */, 50ABBED41925AB6F00A911A9 /* uthash.h in Headers */, B665E3AD1AA80A6500DDB1C5 /* CCPURandomiserTranslator.h in Headers */, B29A7E0A19EE1B7700872B35 /* AttachmentLoader.h in Headers */, @@ -7672,9 +9901,12 @@ 1A5701FE180BCBAD0088DEC7 /* CCMenuItem.h in Headers */, 50ABC00C1926664800A911A9 /* CCDevice.h in Headers */, 1A570205180BCBD40088DEC7 /* CCClippingNode.h in Headers */, + B6CAB3041AF9AA1A00B9B856 /* btTriangleIndexVertexMaterialArray.h in Headers */, 15AE1B8919AADA9A00C27E9E /* UICheckBox.h in Headers */, + B6CAB2161AF9AA1A00B9B856 /* btActivatingCollisionAlgorithm.h in Headers */, 5034CA34191D591100CE6051 /* ccShader_PositionTexture_uColor.frag in Headers */, B665E40D1AA80A6600DDB1C5 /* CCPUSphereSurfaceEmitterTranslator.h in Headers */, + B6CAB38A1AF9AA1A00B9B856 /* btPointCollector.h in Headers */, B29A7DF819EE1B7700872B35 /* Attachment.h in Headers */, 15AE197C19AAD35700C27E9E /* CCFrame.h in Headers */, B665E31D1AA80A6500DDB1C5 /* CCPUOnClearObserver.h in Headers */, @@ -7685,11 +9917,15 @@ B665E2651AA80A6500DDB1C5 /* CCPUDoExpireEventHandler.h in Headers */, 15FB208A1AE7C57D00C31518 /* shapes.h in Headers */, 50ABBEA21925AB6F00A911A9 /* CCScheduler.h in Headers */, + B6CAB38E1AF9AA1A00B9B856 /* btPolyhedralContactClipping.h in Headers */, 1A57020B180BCBDF0088DEC7 /* CCMotionStreak.h in Headers */, B665E2211AA80A6500DDB1C5 /* CCPUBehaviourManager.h in Headers */, 15AE195219AAD35100C27E9E /* CCDecorativeDisplay.h in Headers */, 15AE196619AAD35100C27E9E /* CCTween.h in Headers */, 15AE194619AAD35100C27E9E /* CCComAttribute.h in Headers */, + B6CAB5181AF9AA1A00B9B856 /* btMotionState.h in Headers */, + B6CAAFE51AF9A9E100B9B856 /* CCPhysics3D.h in Headers */, + B6CAB1F41AF9AA1A00B9B856 /* btCollisionAlgorithm.h in Headers */, 382384241A2590DA002C4610 /* GameMapReader.h in Headers */, 15AE1ABD19AAD40300C27E9E /* b2PolygonAndCircleContact.h in Headers */, 15AE1AA819AAD40300C27E9E /* b2Island.h in Headers */, @@ -7700,11 +9936,14 @@ 38F526431A48363B000DB7F7 /* CSArmatureNode_generated.h in Headers */, 1A570217180BCBF40088DEC7 /* CCRenderTexture.h in Headers */, B603F1AB1AC8EA0900A9579C /* CCTerrain.h in Headers */, + B6CAB5461AF9AA1A00B9B856 /* MiniCLTask.h in Headers */, 15AE1ABB19AAD40300C27E9E /* b2EdgeAndPolygonContact.h in Headers */, 15AE198719AAD36400C27E9E /* WidgetReaderProtocol.h in Headers */, B665E3ED1AA80A6600DDB1C5 /* CCPUSlaveBehaviour.h in Headers */, + B6CAB42C1AF9AA1A00B9B856 /* btRaycastVehicle.h in Headers */, 15AE198619AAD36400C27E9E /* WidgetReader.h in Headers */, 1A570224180BCC1A0088DEC7 /* CCParticleBatchNode.h in Headers */, + B6CAB32C1AF9AA1A00B9B856 /* btGImpactCollisionAlgorithm.h in Headers */, 15FB20961AE7C57D00C31518 /* cdt.h in Headers */, 15AE1AC919AAD40300C27E9E /* b2Joint.h in Headers */, 382383EF1A258FA7002C4610 /* flatbuffers.h in Headers */, @@ -7713,38 +9952,53 @@ 15AE196819AAD35100C27E9E /* CCUtilMath.h in Headers */, B29A7E2019EE1B7700872B35 /* BoneData.h in Headers */, 503DD8F61926B0DB00CD74DD /* CCIMEDelegate.h in Headers */, + B6CAAFED1AF9A9E100B9B856 /* CCPhysics3DConstraint.h in Headers */, 1A570228180BCC1A0088DEC7 /* CCParticleExamples.h in Headers */, B665E4391AA80A6600DDB1C5 /* CCPUVortexAffector.h in Headers */, 1A57022C180BCC1A0088DEC7 /* CCParticleSystem.h in Headers */, + B6CAB26C1AF9AA1A00B9B856 /* btSphereBoxCollisionAlgorithm.h in Headers */, B665E4291AA80A6600DDB1C5 /* CCPUUtil.h in Headers */, 15AE1BAC19AADFDF00C27E9E /* UILayout.h in Headers */, 1A570230180BCC1A0088DEC7 /* CCParticleSystemQuad.h in Headers */, 382383F31A258FA7002C4610 /* idl.h in Headers */, 29394CF119B01DBA00D2DE1A /* UIWebView.h in Headers */, + B6CAB4EC1AF9AA1A00B9B856 /* TrbStateVec.h in Headers */, 15AE18B419AAD33D00C27E9E /* CCBSelectorResolver.h in Headers */, B24AA988195A675C007B4522 /* CCFastTMXLayer.h in Headers */, 15AE1AB919AAD40300C27E9E /* b2EdgeAndCircleContact.h in Headers */, 15AE1B7319AADA9A00C27E9E /* UIListView.h in Headers */, 15AE192A19AAD35100C27E9E /* TriggerMng.h in Headers */, 5034CA2C191D591100CE6051 /* ccShader_PositionTextureA8Color.vert in Headers */, + B6CAB2741AF9AA1A00B9B856 /* btSphereTriangleCollisionAlgorithm.h in Headers */, 50ABBE981925AB6F00A911A9 /* CCProtocols.h in Headers */, + B6CAB3801AF9AA1A00B9B856 /* btManifoldPoint.h in Headers */, 50CB247A19D9C5A100687767 /* AudioEngine-inl.h in Headers */, 52B47A321A5349A3004E4C60 /* HttpCookie.h in Headers */, 50ABBD431925AB0000A911A9 /* CCMathBase.h in Headers */, 15EFA214198A2BB5000C57D3 /* CCProtectedNode.h in Headers */, + B6CAB2261AF9AA1A00B9B856 /* btCollisionCreateFunc.h in Headers */, 15AE194419AAD35100C27E9E /* CCComBase.h in Headers */, 15AE1A3B19AAD3D500C27E9E /* b2BroadPhase.h in Headers */, 15AE195619AAD35100C27E9E /* CCDisplayManager.h in Headers */, 15AE1B8719AADA9A00C27E9E /* UIButton.h in Headers */, 38F526411A48363B000DB7F7 /* ArmatureNodeReader.h in Headers */, + B6CAB3981AF9AA1A00B9B856 /* btSubSimplexConvexCast.h in Headers */, 50ABBE441925AB6F00A911A9 /* CCDirector.h in Headers */, + B6CAB3321AF9AA1A00B9B856 /* btGImpactQuantizedBvh.h in Headers */, 5034CA4A191D591100CE6051 /* ccShader_Label_df.frag in Headers */, + B6CAB1E41AF9AA1A00B9B856 /* btBulletDynamicsCommon.h in Headers */, + B6CAB2301AF9AA1A00B9B856 /* btCollisionObjectWrapper.h in Headers */, + B6CAB3B61AF9AA1A00B9B856 /* btGearConstraint.h in Headers */, + B6CAB20E1AF9AA1A00B9B856 /* btQuantizedBvh.h in Headers */, B665E2591AA80A6500DDB1C5 /* CCPUDoAffectorEventHandlerTranslator.h in Headers */, B665E1F91AA80A6500DDB1C5 /* CCPUAffectorManager.h in Headers */, B665E2351AA80A6500DDB1C5 /* CCPUBoxEmitter.h in Headers */, + B6CAB36C1AF9AA1A00B9B856 /* btConvexPenetrationDepthSolver.h in Headers */, + B6CAB4281AF9AA1A00B9B856 /* btSolveProjectedGaussSeidel.h in Headers */, 15AE1B7519AADA9A00C27E9E /* UILoadingBar.h in Headers */, 15AE1BF219AAE01E00C27E9E /* CCControlPotentiometer.h in Headers */, 15AE1BEB19AAE01E00C27E9E /* CCControlButton.h in Headers */, + B6CAB1F81AF9AA1A00B9B856 /* btDbvt.h in Headers */, B665E35D1AA80A6500DDB1C5 /* CCPUOnRandomObserver.h in Headers */, 1A570281180BCC900088DEC7 /* CCSprite.h in Headers */, 1A570285180BCC900088DEC7 /* CCSpriteBatchNode.h in Headers */, @@ -7752,37 +10006,51 @@ 1A570289180BCC900088DEC7 /* CCSpriteFrame.h in Headers */, 15AE1B7F19AADA9A00C27E9E /* UIText.h in Headers */, B29A7E3419EE1B7700872B35 /* SlotData.h in Headers */, + B6CAAFF91AF9A9E100B9B856 /* CCPhysics3DShape.h in Headers */, B665E3D51AA80A6600DDB1C5 /* CCPUScriptLexer.h in Headers */, 50ABBE701925AB6F00A911A9 /* CCEventListenerKeyboard.h in Headers */, 15AE18B619AAD33D00C27E9E /* CCBSequence.h in Headers */, 15AE1A9819AAD40300C27E9E /* b2GrowableStack.h in Headers */, 1A57028D180BCC900088DEC7 /* CCSpriteFrameCache.h in Headers */, 1A570295180BCCAB0088DEC7 /* CCAnimation.h in Headers */, + B6CAB21E1AF9AA1A00B9B856 /* btBoxBoxCollisionAlgorithm.h in Headers */, + B6CAB50A1AF9AA1A00B9B856 /* btGrahamScan2dConvexHull.h in Headers */, B665E2D11AA80A6500DDB1C5 /* CCPUInterParticleCollider.h in Headers */, 50ABBDB81925AB4100A911A9 /* CCTexture2D.h in Headers */, + B6CAB2581AF9AA1A00B9B856 /* btGhostObject.h in Headers */, 15AE1AAB19AAD40300C27E9E /* b2World.h in Headers */, 15AE180F19AAD2F700C27E9E /* CCAnimate3D.h in Headers */, 50ABBE341925AB6F00A911A9 /* CCConfiguration.h in Headers */, B68778FF1A8CA82E00643ABF /* CCParticle3DEmitter.h in Headers */, 1A570299180BCCAB0088DEC7 /* CCAnimationCache.h in Headers */, + B6CAB42E1AF9AA1A00B9B856 /* btVehicleRaycaster.h in Headers */, B665E2B11AA80A6500DDB1C5 /* CCPUFlockCenteringAffectorTranslator.h in Headers */, + B6CAB2E81AF9AA1A00B9B856 /* btSphereShape.h in Headers */, 15AE1ABF19AAD40300C27E9E /* b2PolygonContact.h in Headers */, 50ABBEAA1925AB6F00A911A9 /* CCTouch.h in Headers */, 15AE1BAE19AADFDF00C27E9E /* UILayoutParameter.h in Headers */, 15AE18C819AAD33D00C27E9E /* CCMenuItemImageLoader.h in Headers */, + B6CAB3AC1AF9AA1A00B9B856 /* btContactConstraint.h in Headers */, B665E2491AA80A6500DDB1C5 /* CCPUCollisionAvoidanceAffectorTranslator.h in Headers */, + B6CAB4461AF9AA1A00B9B856 /* btParallelConstraintSolver.h in Headers */, 15AE18D119AAD33D00C27E9E /* CCNodeLoaderLibrary.h in Headers */, 15AE1AC319AAD40300C27E9E /* b2DistanceJoint.h in Headers */, + B6CAB5261AF9AA1A00B9B856 /* btQuickprof.h in Headers */, 50ABBE741925AB6F00A911A9 /* CCEventListenerMouse.h in Headers */, D0FD03581A3B51AA00825BB5 /* CCAllocatorMutex.h in Headers */, B29A7E1219EE1B7700872B35 /* EventData.h in Headers */, 1A5702CB180BCE370088DEC7 /* CCTextFieldTTF.h in Headers */, 1A5702ED180BCE750088DEC7 /* CCTileMapAtlas.h in Headers */, 15AE195E19AAD35100C27E9E /* CCSkin.h in Headers */, + B6CAB3CC1AF9AA1A00B9B856 /* btPoint2PointConstraint.h in Headers */, + B6CAB5081AF9AA1A00B9B856 /* btGeometryUtil.h in Headers */, 1A5702F1180BCE750088DEC7 /* CCTMXLayer.h in Headers */, 15FB20771AE7BF8600C31518 /* MarchingSquare.h in Headers */, + B6CAB4F81AF9AA1A00B9B856 /* btAlignedAllocator.h in Headers */, 15AE18AE19AAD33D00C27E9E /* CCBFileLoader.h in Headers */, + B6CAB2D41AF9AA1A00B9B856 /* btMultiSphereShape.h in Headers */, 15AE197819AAD35700C27E9E /* CCActionTimeline.h in Headers */, + B6CAAFF11AF9A9E100B9B856 /* CCPhysics3DDebugDrawer.h in Headers */, 15FB206D1AE7BE7400C31518 /* SpritePolygon.h in Headers */, 15AE1AA019AAD40300C27E9E /* b2Timer.h in Headers */, 5034CA44191D591100CE6051 /* ccShader_Label.vert in Headers */, @@ -7797,100 +10065,152 @@ 15AE1AC519AAD40300C27E9E /* b2FrictionJoint.h in Headers */, 15AE1B8D19AADA9A00C27E9E /* UIScale9Sprite.h in Headers */, 15AE18AC19AAD33D00C27E9E /* CCBAnimationManager.h in Headers */, + B6CAB2841AF9AA1A00B9B856 /* btBoxShape.h in Headers */, 292DB14219B4574100A80320 /* UIEditBoxImpl.h in Headers */, + B6CAB5321AF9AA1A00B9B856 /* btTransform.h in Headers */, 1A570303180BCE890088DEC7 /* CCParallaxNode.h in Headers */, 50ABBE2A1925AB6F00A911A9 /* CCAutoreleasePool.h in Headers */, + B6CAAFFD1AF9A9E100B9B856 /* CCPhysics3DWorld.h in Headers */, + 501216971AC47393009A4BEA /* CCPass.h in Headers */, 1A57030F180BCF190088DEC7 /* CCComponent.h in Headers */, B665E22D1AA80A6500DDB1C5 /* CCPUBoxCollider.h in Headers */, + B6CAB22E1AF9AA1A00B9B856 /* btCollisionObject.h in Headers */, 15AE1AD519AAD40300C27E9E /* b2WeldJoint.h in Headers */, 15AE18B019AAD33D00C27E9E /* CCBKeyframe.h in Headers */, 15AE18C419AAD33D00C27E9E /* CCLayerGradientLoader.h in Headers */, + B6CAB1EA1AF9AA1A00B9B856 /* btAxisSweep3.h in Headers */, B665E3511AA80A6500DDB1C5 /* CCPUOnPositionObserverTranslator.h in Headers */, + B6CAB3A21AF9AA1A00B9B856 /* btKinematicCharacterController.h in Headers */, 1A570313180BCF190088DEC7 /* CCComponentContainer.h in Headers */, + B6CAB5381AF9AA1A00B9B856 /* btVector3.h in Headers */, + B6CAB4DC1AF9AA1A00B9B856 /* SpuMinkowskiPenetrationDepthSolver.h in Headers */, B665E2F51AA80A6500DDB1C5 /* CCPULineEmitterTranslator.h in Headers */, 1A087AEB1860400400196EF5 /* edtaa3func.h in Headers */, B665E3751AA80A6500DDB1C5 /* CCPUParticleFollower.h in Headers */, + B6CAB4B01AF9AA1A00B9B856 /* SpuCollisionTaskProcess.h in Headers */, 15AE185D19AAD31200C27E9E /* CocosDenshion.h in Headers */, + B6CAB3661AF9AA1A00B9B856 /* btContinuousConvexCollision.h in Headers */, 15AE194319AAD35100C27E9E /* CCColliderDetector.h in Headers */, 382F7ADF1AB1292A002EBECF /* CCObjectExtensionData.h in Headers */, + B6CAB3A81AF9AA1A00B9B856 /* btConstraintSolver.h in Headers */, D0FD035C1A3B51AA00825BB5 /* CCAllocatorStrategyFixedBlock.h in Headers */, 15AE1BC419AADFFB00C27E9E /* ExtensionMacros.h in Headers */, 15AE185A19AAD31200C27E9E /* CDConfig.h in Headers */, B29A7DE819EE1B7700872B35 /* spine.h in Headers */, + B6CAB50E1AF9AA1A00B9B856 /* btIDebugDraw.h in Headers */, 1A57034E180BD09B0088DEC7 /* tinyxml2.h in Headers */, 15AE1BFE19AAE01E00C27E9E /* CCInvocation.h in Headers */, 15AE1A9E19AAD40300C27E9E /* b2StackAllocator.h in Headers */, 1A570357180BD0B00088DEC7 /* ioapi.h in Headers */, + B6CAB3AE1AF9AA1A00B9B856 /* btContactSolverInfo.h in Headers */, 50ABBD4B1925AB0000A911A9 /* Mat4.h in Headers */, B665E3891AA80A6500DDB1C5 /* CCPUPathFollowerTranslator.h in Headers */, + B6CAB53E1AF9AA1A00B9B856 /* cl_MiniCL_Defs.h in Headers */, + B6CAB22A1AF9AA1A00B9B856 /* btCollisionDispatcher.h in Headers */, + B6CAB0011AF9A9E100B9B856 /* CCPhysicsSprite3D.h in Headers */, 15AE1BBE19AADFF000C27E9E /* SocketIO.h in Headers */, B665E3351AA80A6500DDB1C5 /* CCPUOnEmissionObserver.h in Headers */, B665E3811AA80A6500DDB1C5 /* CCPUParticleSystem3DTranslator.h in Headers */, + B6CAB4D21AF9AA1A00B9B856 /* SpuConvexPenetrationDepthSolver.h in Headers */, B665E2151AA80A6500DDB1C5 /* CCPUBaseForceAffectorTranslator.h in Headers */, 1A01C69B18F57BE800EFE3A6 /* CCSet.h in Headers */, B665E4051AA80A6600DDB1C5 /* CCPUSphereColliderTranslator.h in Headers */, 50ABBED61925AB6F00A911A9 /* utlist.h in Headers */, 1A57035B180BD0B00088DEC7 /* unzip.h in Headers */, + B6CAB44A1AF9AA1A00B9B856 /* btThreadSupportInterface.h in Headers */, + B6CAB3FA1AF9AA1A00B9B856 /* btMultiBody.h in Headers */, 15AE1BA619AADFDF00C27E9E /* UIHBox.h in Headers */, + B6CAB2881AF9AA1A00B9B856 /* btBvhTriangleMeshShape.h in Headers */, 15AE1A9519AAD40300C27E9E /* b2BlockAllocator.h in Headers */, 5034CA48191D591100CE6051 /* ccShader_Label_normal.frag in Headers */, + B6CAB30A1AF9AA1A00B9B856 /* btTriangleMesh.h in Headers */, + B6CAB4241AF9AA1A00B9B856 /* btMLCPSolverInterface.h in Headers */, + B6CAB4421AF9AA1A00B9B856 /* btGpuUtilsSharedDefs.h in Headers */, 15AE183F19AAD2F700C27E9E /* CCSkeleton3D.h in Headers */, 50ABBD531925AB0000A911A9 /* Quaternion.h in Headers */, + 5012169D1AC473A3009A4BEA /* CCTechnique.h in Headers */, + B6CAB5281AF9AA1A00B9B856 /* btRandom.h in Headers */, 15AE19B119AAD39700C27E9E /* ScrollViewReader.h in Headers */, 503DD8E81926736A00CD74DD /* CCES2Renderer-ios.h in Headers */, B665E41D1AA80A6600DDB1C5 /* CCPUTextureRotator.h in Headers */, B665E34D1AA80A6500DDB1C5 /* CCPUOnPositionObserver.h in Headers */, + B6CAB4181AF9AA1A00B9B856 /* btMultiBodySolverConstraint.h in Headers */, + B6CAB3B21AF9AA1A00B9B856 /* btFixedConstraint.h in Headers */, 50ABBE6C1925AB6F00A911A9 /* CCEventListenerFocus.h in Headers */, 5034CA3E191D591100CE6051 /* ccShader_PositionColor.frag in Headers */, + B6CAB3761AF9AA1A00B9B856 /* btGjkEpa2.h in Headers */, 182C5CD91A98F30500C30D34 /* Sprite3DReader.h in Headers */, 50ABBE301925AB6F00A911A9 /* ccConfig.h in Headers */, 15AE195819AAD35100C27E9E /* CCInputDelegate.h in Headers */, + B6CAB3281AF9AA1A00B9B856 /* btGImpactBvh.h in Headers */, 50ABBDAC1925AB4100A911A9 /* CCRenderCommandPool.h in Headers */, + B6CAB24C1AF9AA1A00B9B856 /* btConvexPlaneCollisionAlgorithm.h in Headers */, B665E3CD1AA80A6600DDB1C5 /* CCPUScaleVelocityAffectorTranslator.h in Headers */, + B6CAB4321AF9AA1A00B9B856 /* btWheelInfo.h in Headers */, B665E3711AA80A6500DDB1C5 /* CCPUOnVelocityObserverTranslator.h in Headers */, 5034CA3C191D591100CE6051 /* ccShader_PositionColor.vert in Headers */, B665E3F51AA80A6600DDB1C5 /* CCPUSlaveEmitter.h in Headers */, 50ABC0181926664800A911A9 /* CCImage.h in Headers */, B665E2B91AA80A6500DDB1C5 /* CCPUForceFieldAffector.h in Headers */, + B6CAB4221AF9AA1A00B9B856 /* btMLCPSolver.h in Headers */, 15AE1A4E19AAD3D500C27E9E /* b2PolygonShape.h in Headers */, + B6CAB3481AF9AA1A00B9B856 /* gim_box_set.h in Headers */, 382384471A25915C002C4610 /* SpriteReader.h in Headers */, 50ABBE8E1925AB6F00A911A9 /* CCNS.h in Headers */, B665E3051AA80A6500DDB1C5 /* CCPUMeshSurfaceEmitter.h in Headers */, 15AE1AB519AAD40300C27E9E /* b2Contact.h in Headers */, B665E23D1AA80A6500DDB1C5 /* CCPUCircleEmitter.h in Headers */, 50ABBEA61925AB6F00A911A9 /* CCScriptSupport.h in Headers */, + B6CAB33C1AF9AA1A00B9B856 /* btTriangleShapeEx.h in Headers */, 46C02E0A18E91123004B7456 /* xxhash.h in Headers */, + B6CAB39E1AF9AA1A00B9B856 /* btCharacterControllerInterface.h in Headers */, 5034CA4C191D591100CE6051 /* ccShader_Label_df_glow.frag in Headers */, + B6CAB2441AF9AA1A00B9B856 /* btConvexConcaveCollisionAlgorithm.h in Headers */, 503DD8EB1926736A00CD74DD /* CCGL-ios.h in Headers */, B665E4091AA80A6600DDB1C5 /* CCPUSphereSurfaceEmitter.h in Headers */, + B6CAB2F01AF9AA1A00B9B856 /* btStridingMeshInterface.h in Headers */, 50ABBE3C1925AB6F00A911A9 /* CCData.h in Headers */, + B6CAB33E1AF9AA1A00B9B856 /* gim_array.h in Headers */, + B6CAB4AC1AF9AA1A00B9B856 /* SpuCollisionObjectWrapper.h in Headers */, + B6CAB2501AF9AA1A00B9B856 /* btDefaultCollisionConfiguration.h in Headers */, 503DD8FA1926B0DB00CD74DD /* CCIMEDispatcher.h in Headers */, + B6CAB3921AF9AA1A00B9B856 /* btRaycastCallback.h in Headers */, + B6CAB3721AF9AA1A00B9B856 /* btGjkConvexCast.h in Headers */, + B6CAB4FA1AF9AA1A00B9B856 /* btAlignedObjectArray.h in Headers */, B29A7DE619EE1B7700872B35 /* SkeletonAnimation.h in Headers */, B665E3591AA80A6500DDB1C5 /* CCPUOnQuotaObserverTranslator.h in Headers */, 50ABBEC81925AB6F00A911A9 /* etc1.h in Headers */, + B6CAB3D81AF9AA1A00B9B856 /* btSolve2LinearConstraint.h in Headers */, 50ABBDB01925AB4100A911A9 /* CCRenderer.h in Headers */, + B6CAB3421AF9AA1A00B9B856 /* gim_bitset.h in Headers */, B29594B71926D5EC003EEF37 /* CCMeshCommand.h in Headers */, 3E6176771960F89B00DE83F5 /* CCEventListenerController.h in Headers */, 50ABBD861925AB4100A911A9 /* CCBatchCommand.h in Headers */, 15AE18CA19AAD33D00C27E9E /* CCMenuItemLoader.h in Headers */, + B6CAB28E1AF9AA1A00B9B856 /* btCollisionMargin.h in Headers */, 50ABBE481925AB6F00A911A9 /* CCEvent.h in Headers */, 5027253B190BF1B900AAF4ED /* cocos2d.h in Headers */, 15AE1A9719AAD40300C27E9E /* b2Draw.h in Headers */, 3E6176691960F89B00DE83F5 /* CCController.h in Headers */, + B6CAB43E1AF9AA1A00B9B856 /* btGpuDefines.h in Headers */, 3823841D1A2590D2002C4610 /* ComAudioReader.h in Headers */, 3E6176781960F89B00DE83F5 /* CCGameController.h in Headers */, + B6CAB4C81AF9AA1A00B9B856 /* boxBoxDistance.h in Headers */, 15AE19BB19AAD39700C27E9E /* TextReader.h in Headers */, 50ABBE641925AB6F00A911A9 /* CCEventListenerAcceleration.h in Headers */, 15AE180B19AAD2F700C27E9E /* CCAABB.h in Headers */, 50ABBD921925AB4100A911A9 /* CCGLProgramCache.h in Headers */, + B6CAB30E1AF9AA1A00B9B856 /* btTriangleMeshShape.h in Headers */, 50ABBE961925AB6F00A911A9 /* CCProfiling.h in Headers */, 15AE19B519AAD39700C27E9E /* TextAtlasReader.h in Headers */, 15AE18D619AAD33D00C27E9E /* CCScale9SpriteLoader.h in Headers */, 15AE182B19AAD2F700C27E9E /* CCMeshSkin.h in Headers */, B665E2251AA80A6500DDB1C5 /* CCPUBehaviourTranslator.h in Headers */, B665E3651AA80A6500DDB1C5 /* CCPUOnTimeObserver.h in Headers */, + B6CAB1E61AF9AA1A00B9B856 /* Bullet-C-Api.h in Headers */, 15AE1B7D19AADA9A00C27E9E /* UISlider.h in Headers */, 503DD8E01926736A00CD74DD /* CCApplication-ios.h in Headers */, + B6CAB4021AF9AA1A00B9B856 /* btMultiBodyConstraintSolver.h in Headers */, B665E4111AA80A6600DDB1C5 /* CCPUTechniqueTranslator.h in Headers */, 15AE1B8319AADA9A00C27E9E /* UITextBMFont.h in Headers */, B29A7E2A19EE1B7700872B35 /* SkeletonData.h in Headers */, @@ -7902,6 +10222,7 @@ D0FD03601A3B51AA00825BB5 /* CCAllocatorStrategyPool.h in Headers */, 15AE198019AAD35700C27E9E /* CCTimeLine.h in Headers */, 38B8E2E419E671D2002D7CE7 /* UILayoutComponent.h in Headers */, + B6CAB2481AF9AA1A00B9B856 /* btConvexConvexAlgorithm.h in Headers */, B665E2CD1AA80A6500DDB1C5 /* CCPUGravityAffectorTranslator.h in Headers */, 50ABBD4F1925AB0000A911A9 /* MathUtil.h in Headers */, 1A01C69718F57BE800EFE3A6 /* CCInteger.h in Headers */, @@ -7909,6 +10230,7 @@ 15AE1C0619AAE01E00C27E9E /* CCTableViewCell.h in Headers */, B665E4251AA80A6600DDB1C5 /* CCPUTranslateManager.h in Headers */, 15AE19AB19AAD39700C27E9E /* ListViewReader.h in Headers */, + B6CAB4121AF9AA1A00B9B856 /* btMultiBodyLinkCollider.h in Headers */, 50ABBEBE1925AB6F00A911A9 /* ccUtils.h in Headers */, 15AE183719AAD2F700C27E9E /* CCObjLoader.h in Headers */, 15AE18CF19AAD33D00C27E9E /* CCNodeLoader.h in Headers */, @@ -7917,11 +10239,14 @@ 299CF1FE19A434BC00C378C1 /* ccRandom.h in Headers */, B665E3BD1AA80A6500DDB1C5 /* CCPURibbonTrailRender.h in Headers */, 50ABBDBC1925AB4100A911A9 /* CCTextureAtlas.h in Headers */, + B6CAAFE91AF9A9E100B9B856 /* CCPhysics3DComponent.h in Headers */, 15AE182319AAD2F700C27E9E /* CCBundleReader.h in Headers */, 182C5CB51A95964F00C30D34 /* Node3DReader.h in Headers */, 50ABBE541925AB6F00A911A9 /* CCEventDispatcher.h in Headers */, 1A12775A18DFCC4F0005F345 /* CCTweenFunction.h in Headers */, 15AE192819AAD35100C27E9E /* TriggerBase.h in Headers */, + B6CAB2401AF9AA1A00B9B856 /* btConvex2dConvex2dAlgorithm.h in Headers */, + B6CAB3441AF9AA1A00B9B856 /* gim_box_collision.h in Headers */, B665E3F11AA80A6600DDB1C5 /* CCPUSlaveBehaviourTranslator.h in Headers */, 15AE1BF419AAE01E00C27E9E /* CCControlSaturationBrightnessPicker.h in Headers */, 15AE1AD119AAD40300C27E9E /* b2RevoluteJoint.h in Headers */, @@ -7932,25 +10257,38 @@ B276EF601988D1D500CD400F /* CCVertexIndexData.h in Headers */, 50ABBD5F1925AB0000A911A9 /* Vec3.h in Headers */, 50ABBE821925AB6F00A911A9 /* CCEventType.h in Headers */, + B6CAB4101AF9AA1A00B9B856 /* btMultiBodyLink.h in Headers */, + B6CAB36A1AF9AA1A00B9B856 /* btConvexCast.h in Headers */, 15AE194C19AAD35100C27E9E /* CCComRender.h in Headers */, B665E2C11AA80A6500DDB1C5 /* CCPUGeometryRotator.h in Headers */, 1AAF5852180E40B9000584C8 /* LocalStorage.h in Headers */, 50CB247619D9C5A100687767 /* AudioCache.h in Headers */, + B6CAB2C61AF9AA1A00B9B856 /* btHeightfieldTerrainShape.h in Headers */, B29A7DDA19EE1B7700872B35 /* SkeletonRenderer.h in Headers */, 15AE194119AAD35100C27E9E /* CCBone.h in Headers */, D0FD035A1A3B51AA00825BB5 /* CCAllocatorStrategyDefault.h in Headers */, 50ABBD471925AB0000A911A9 /* CCVertex.h in Headers */, + B6CAB4D81AF9AA1A00B9B856 /* SpuLocalSupport.h in Headers */, + B6CAB2921AF9AA1A00B9B856 /* btCollisionShape.h in Headers */, + B6CAB2681AF9AA1A00B9B856 /* btSimulationIslandManager.h in Headers */, B665E3251AA80A6500DDB1C5 /* CCPUOnCollisionObserver.h in Headers */, + B6CAB3181AF9AA1A00B9B856 /* btClipPolygon.h in Headers */, + B6CAB3001AF9AA1A00B9B856 /* btTriangleIndexVertexArray.h in Headers */, + B6CAB3881AF9AA1A00B9B856 /* btPersistentManifold.h in Headers */, B68779031A8CA82E00643ABF /* CCParticle3DRender.h in Headers */, 15AE195A19AAD35100C27E9E /* CCProcessBase.h in Headers */, 15AE193D19AAD35100C27E9E /* CCArmatureDefine.h in Headers */, + B6CAB37A1AF9AA1A00B9B856 /* btGjkEpaPenetrationDepthSolver.h in Headers */, + B6CAB21A1AF9AA1A00B9B856 /* btBox2dBox2dCollisionAlgorithm.h in Headers */, 382384041A259005002C4610 /* CSParseBinary_generated.h in Headers */, + B6CAB5401AF9AA1A00B9B856 /* cl_platform.h in Headers */, 15AE1A4219AAD3D500C27E9E /* b2Distance.h in Headers */, 15AE195419AAD35100C27E9E /* CCDisplayFactory.h in Headers */, 1A9DCA2A180E6955007A3AD4 /* CCGLBufferedNode.h in Headers */, 1A01C69F18F57BE800EFE3A6 /* CCString.h in Headers */, 464AD6E8197EBB1400E502D8 /* pvr.h in Headers */, 15AE1AC119AAD40300C27E9E /* b2MotorJoint.h in Headers */, + B6CAB40A1AF9AA1A00B9B856 /* btMultiBodyJointLimitConstraint.h in Headers */, 15AE194819AAD35100C27E9E /* CCComAudio.h in Headers */, 1A01C69118F57BE800EFE3A6 /* CCDictionary.h in Headers */, B665E3211AA80A6500DDB1C5 /* CCPUOnClearObserverTranslator.h in Headers */, @@ -7958,12 +10296,21 @@ B24AA98C195A675C007B4522 /* CCFastTMXTiledMap.h in Headers */, B29A7DEC19EE1B7700872B35 /* MeshAttachment.h in Headers */, 50ABBEAE1925AB6F00A911A9 /* ccTypes.h in Headers */, + B6CAB50C1AF9AA1A00B9B856 /* btHashMap.h in Headers */, 15AE185819AAD31200C27E9E /* CDAudioManager.h in Headers */, + B6CAB3841AF9AA1A00B9B856 /* btMinkowskiPenetrationDepthSolver.h in Headers */, B665E38D1AA80A6500DDB1C5 /* CCPUPlane.h in Headers */, + B6CAB3501AF9AA1A00B9B856 /* gim_geom_types.h in Headers */, + B6CAB3941AF9AA1A00B9B856 /* btSimplexSolverInterface.h in Headers */, 15AE1BF819AAE01E00C27E9E /* CCControlStepper.h in Headers */, 50ABBE261925AB6F00A911A9 /* base64.h in Headers */, + B6CAB4E81AF9AA1A00B9B856 /* SpuSync.h in Headers */, + B6CAB2381AF9AA1A00B9B856 /* btCompoundCollisionAlgorithm.h in Headers */, 15AE1C1619AAE2C700C27E9E /* CCPhysicsDebugNode.h in Headers */, 15AE1BF619AAE01E00C27E9E /* CCControlSlider.h in Headers */, + B6CAB27C1AF9AA1A00B9B856 /* SphereTriangleDetector.h in Headers */, + B6CAB3D41AF9AA1A00B9B856 /* btSliderConstraint.h in Headers */, + B6CAB4381AF9AA1A00B9B856 /* btGpu3DGridBroadphaseSharedCode.h in Headers */, B665E2091AA80A6500DDB1C5 /* CCPUBaseCollider.h in Headers */, 1A01C68718F57BE800EFE3A6 /* CCArray.h in Headers */, B665E3DD1AA80A6600DDB1C5 /* CCPUScriptTranslator.h in Headers */, @@ -7979,14 +10326,23 @@ B665E2511AA80A6500DDB1C5 /* CCPUColorAffectorTranslator.h in Headers */, B29A7E1019EE1B7700872B35 /* SkeletonJson.h in Headers */, 15AE184B19AAD30500C27E9E /* Export.h in Headers */, + B6CAB2D01AF9AA1A00B9B856 /* btMultimaterialTriangleMeshShape.h in Headers */, + B6CAB3541AF9AA1A00B9B856 /* gim_hash_table.h in Headers */, + B6CAB2961AF9AA1A00B9B856 /* btCompoundShape.h in Headers */, 15AE196019AAD35100C27E9E /* CCSpriteFrameCacheHelper.h in Headers */, 50ABBE221925AB6F00A911A9 /* atitc.h in Headers */, B665E3E11AA80A6600DDB1C5 /* CCPUSimpleSpline.h in Headers */, + B6CAB3C81AF9AA1A00B9B856 /* btJacobianEntry.h in Headers */, 15AE1AB719AAD40300C27E9E /* b2ContactSolver.h in Headers */, B665E3451AA80A6500DDB1C5 /* CCPUOnExpireObserver.h in Headers */, 15AE193319AAD35100C27E9E /* CCActionNode.h in Headers */, + B6CAB1F01AF9AA1A00B9B856 /* btBroadphaseProxy.h in Headers */, + B6CAAFF51AF9A9E100B9B856 /* CCPhysics3DObject.h in Headers */, + B6CAB35E1AF9AA1A00B9B856 /* gim_radixsort.h in Headers */, 50ABBED21925AB6F00A911A9 /* TGAlib.h in Headers */, B665E2951AA80A6500DDB1C5 /* CCPUEmitter.h in Headers */, + B6CAB3BE1AF9AA1A00B9B856 /* btGeneric6DofSpringConstraint.h in Headers */, + B6CAB3521AF9AA1A00B9B856 /* gim_geometry.h in Headers */, 15AE1BED19AAE01E00C27E9E /* CCControlColourPicker.h in Headers */, 15AE195019AAD35100C27E9E /* CCDatas.h in Headers */, 15AE18B319AAD33D00C27E9E /* CCBReader.h in Headers */, @@ -7997,10 +10353,12 @@ B665E3FD1AA80A6600DDB1C5 /* CCPUSphere.h in Headers */, B68778FB1A8CA82E00643ABF /* CCParticle3DAffector.h in Headers */, B665E3B51AA80A6500DDB1C5 /* CCPURendererTranslator.h in Headers */, + 501216A31AC473AD009A4BEA /* CCMaterial.h in Headers */, B665E20D1AA80A6500DDB1C5 /* CCPUBaseColliderTranslator.h in Headers */, 1A01C68D18F57BE800EFE3A6 /* CCDeprecated.h in Headers */, B665E2E91AA80A6500DDB1C5 /* CCPULinearForceAffector.h in Headers */, 382384321A259112002C4610 /* ParticleReader.h in Headers */, + B6CAB52E1AF9AA1A00B9B856 /* btSerializer.h in Headers */, B665E28D1AA80A6500DDB1C5 /* CCPUDynamicAttribute.h in Headers */, B29A7E3619EE1B7700872B35 /* AnimationStateData.h in Headers */, 503DD8EA1926736A00CD74DD /* CCESRenderer-ios.h in Headers */, @@ -8009,6 +10367,7 @@ 15AE196419AAD35100C27E9E /* CCTransformHelp.h in Headers */, 15AE1AAF19AAD40300C27E9E /* b2ChainAndCircleContact.h in Headers */, B665E2991AA80A6500DDB1C5 /* CCPUEmitterManager.h in Headers */, + B6CAB34E1AF9AA1A00B9B856 /* gim_contact.h in Headers */, 15AE1B9719AADAA100C27E9E /* UIVideoPlayer.h in Headers */, 15AE18BE19AAD33D00C27E9E /* CCLabelBMFontLoader.h in Headers */, 50ABC00A1926664800A911A9 /* CCCommon.h in Headers */, @@ -8016,15 +10375,20 @@ 15FB209E1AE7C57D00C31518 /* sweep_context.h in Headers */, 50ABBE5C1925AB6F00A911A9 /* CCEventKeyboard.h in Headers */, B665E2191AA80A6500DDB1C5 /* CCPUBeamRender.h in Headers */, + B6CAB3F41AF9AA1A00B9B856 /* btSimpleDynamicsWorld.h in Headers */, 5E9F612D1A3FFE3D0038DE01 /* CCPlane.h in Headers */, B665E3391AA80A6500DDB1C5 /* CCPUOnEmissionObserverTranslator.h in Headers */, B665E4151AA80A6600DDB1C5 /* CCPUTextureAnimator.h in Headers */, 50ABC01C1926664800A911A9 /* CCSAXParser.h in Headers */, + B6CAB4EA1AF9AA1A00B9B856 /* TrbDynBody.h in Headers */, 503DD8F11926736A00CD74DD /* OpenGL_Internal-ios.h in Headers */, + B6CAB3EC1AF9AA1A00B9B856 /* btDynamicsWorld.h in Headers */, 38ACD1FF1A27111900C3093D /* WidgetCallBackHandlerProtocol.h in Headers */, B29A7DF619EE1B7700872B35 /* Skeleton.h in Headers */, + B6CAB3E01AF9AA1A00B9B856 /* btTypedConstraint.h in Headers */, 50ABBDAA1925AB4100A911A9 /* CCRenderCommand.h in Headers */, B29A7DF019EE1B7700872B35 /* SkeletonBounds.h in Headers */, + B6CAB3361AF9AA1A00B9B856 /* btGImpactShape.h in Headers */, 15AE1BE919AAE01E00C27E9E /* CCControl.h in Headers */, 15AE193719AAD35100C27E9E /* CCArmature.h in Headers */, B63990CF1A490AFE00B07923 /* CCAsyncTaskPool.h in Headers */, @@ -8034,8 +10398,11 @@ B665E2291AA80A6500DDB1C5 /* CCPUBillboardChain.h in Headers */, 50ABBE601925AB6F00A911A9 /* CCEventListener.h in Headers */, 4D76BE3D1A4AAF0A00102962 /* CCActionTimelineNode.h in Headers */, + B6CAB2CC1AF9AA1A00B9B856 /* btMinkowskiSumShape.h in Headers */, + B6CAB3561AF9AA1A00B9B856 /* gim_linear_math.h in Headers */, 50ABBEB21925AB6F00A911A9 /* CCUserDefault.h in Headers */, 15AE198B19AAD36A00C27E9E /* ButtonReader.h in Headers */, + B6CAB2FC1AF9AA1A00B9B856 /* btTriangleCallback.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -8111,6 +10478,7 @@ 15AE1A9019AAD40300C27E9E /* b2WeldJoint.cpp in Sources */, 50ABBE2B1925AB6F00A911A9 /* ccCArray.cpp in Sources */, 382383F41A258FA7002C4610 /* idl_gen_cpp.cpp in Sources */, + B6CAAFEA1AF9A9E100B9B856 /* CCPhysics3DConstraint.cpp in Sources */, B29A7E3B19EE1B7700872B35 /* Animation.c in Sources */, 15AE1BDE19AAE01E00C27E9E /* CCInvocation.cpp in Sources */, B665E2F21AA80A6500DDB1C5 /* CCPULineEmitterTranslator.cpp in Sources */, @@ -8118,15 +10486,18 @@ B29A7E0B19EE1B7700872B35 /* Atlas.c in Sources */, 15AE199419AAD39600C27E9E /* LayoutReader.cpp in Sources */, 1A01C68A18F57BE800EFE3A6 /* CCDeprecated.cpp in Sources */, + B6CAB2F51AF9AA1A00B9B856 /* btTriangleBuffer.cpp in Sources */, 1A1645B0191B726C008C7C7F /* ConvertUTF.c in Sources */, 15AE1BE219AAE01E00C27E9E /* CCScrollView.cpp in Sources */, 50ABBD581925AB0000A911A9 /* Vec2.cpp in Sources */, 15AE18E119AAD35000C27E9E /* TriggerMng.cpp in Sources */, + B6CAB2811AF9AA1A00B9B856 /* btBoxShape.cpp in Sources */, 50ABBE311925AB6F00A911A9 /* CCConfiguration.cpp in Sources */, B665E3821AA80A6500DDB1C5 /* CCPUPathFollower.cpp in Sources */, 1A01C6A418F58F7500EFE3A6 /* CCNotificationCenter.cpp in Sources */, 15AE1A5D19AAD40300C27E9E /* b2Body.cpp in Sources */, 15AE1BDA19AAE01E00C27E9E /* CCControlSwitch.cpp in Sources */, + B6CAB3B71AF9AA1A00B9B856 /* btGeneric6DofConstraint.cpp in Sources */, 46A170EA1807CECA005B8026 /* CCPhysicsJoint.cpp in Sources */, 15AE18DC19AAD35000C27E9E /* CocoLoader.cpp in Sources */, 15AE1B4D19AADA9900C27E9E /* UIListView.cpp in Sources */, @@ -8140,6 +10511,7 @@ 15AE198219AAD36400C27E9E /* WidgetReader.cpp in Sources */, B665E3EA1AA80A6600DDB1C5 /* CCPUSlaveBehaviour.cpp in Sources */, 46A170EF1807CECA005B8026 /* CCPhysicsWorld.cpp in Sources */, + B6CAB3BB1AF9AA1A00B9B856 /* btGeneric6DofSpringConstraint.cpp in Sources */, 15AE18E419AAD35000C27E9E /* CCActionFrame.cpp in Sources */, B665E21A1AA80A6500DDB1C5 /* CCPUBehaviour.cpp in Sources */, B665E29E1AA80A6500DDB1C5 /* CCPUEventHandler.cpp in Sources */, @@ -8148,31 +10520,43 @@ B665E1FA1AA80A6500DDB1C5 /* CCPUAffectorTranslator.cpp in Sources */, 50ABBE991925AB6F00A911A9 /* CCRef.cpp in Sources */, 15AE186319AAD31D00C27E9E /* CDAudioManager.m in Sources */, + B6CAB2411AF9AA1A00B9B856 /* btConvexConcaveCollisionAlgorithm.cpp in Sources */, ED9C6A9418599AD8000A5232 /* CCNodeGrid.cpp in Sources */, 15AE1A2C19AAD3D500C27E9E /* b2DynamicTree.cpp in Sources */, B665E36A1AA80A6500DDB1C5 /* CCPUOnVelocityObserver.cpp in Sources */, B665E3961AA80A6500DDB1C5 /* CCPUPointEmitter.cpp in Sources */, 15AE184019AAD2F700C27E9E /* CCSprite3D.cpp in Sources */, + B6CAB2E51AF9AA1A00B9B856 /* btSphereShape.cpp in Sources */, + B6CAB41F1AF9AA1A00B9B856 /* btMLCPSolver.cpp in Sources */, 46A170E61807CECA005B8026 /* CCPhysicsBody.cpp in Sources */, B665E40A1AA80A6600DDB1C5 /* CCPUSphereSurfaceEmitterTranslator.cpp in Sources */, 50ABBDA71925AB4100A911A9 /* CCRenderCommand.cpp in Sources */, B665E35E1AA80A6500DDB1C5 /* CCPUOnRandomObserverTranslator.cpp in Sources */, + B6CAB2931AF9AA1A00B9B856 /* btCompoundShape.cpp in Sources */, + B6CAB3A31AF9AA1A00B9B856 /* btConeTwistConstraint.cpp in Sources */, B665E24E1AA80A6500DDB1C5 /* CCPUColorAffectorTranslator.cpp in Sources */, + B6CAB1E71AF9AA1A00B9B856 /* btAxisSweep3.cpp in Sources */, + B6CAB2D91AF9AA1A00B9B856 /* btPolyhedralConvexShape.cpp in Sources */, B6D38B8E1AC3AFAC00043997 /* CCTextureCube.cpp in Sources */, 15AE1B9B19AADFDF00C27E9E /* UIRelativeBox.cpp in Sources */, B665E3E21AA80A6600DDB1C5 /* CCPUSineForceAffector.cpp in Sources */, 50ABBD501925AB0000A911A9 /* Quaternion.cpp in Sources */, + B6CAB2751AF9AA1A00B9B856 /* btUnionFind.cpp in Sources */, B665E36E1AA80A6500DDB1C5 /* CCPUOnVelocityObserverTranslator.cpp in Sources */, 15AE190119AAD35000C27E9E /* CCComController.cpp in Sources */, + B6CAB4071AF9AA1A00B9B856 /* btMultiBodyJointLimitConstraint.cpp in Sources */, + B6CAB38F1AF9AA1A00B9B856 /* btRaycastCallback.cpp in Sources */, 15AE1BE619AAE01E00C27E9E /* CCTableViewCell.cpp in Sources */, 50ABBEBB1925AB6F00A911A9 /* ccUtils.cpp in Sources */, 15AE186A19AAD31D00C27E9E /* CocosDenshion.m in Sources */, + B6CAB3F71AF9AA1A00B9B856 /* btMultiBody.cpp in Sources */, B665E3C21AA80A6600DDB1C5 /* CCPUScaleAffectorTranslator.cpp in Sources */, B665E34A1AA80A6500DDB1C5 /* CCPUOnPositionObserver.cpp in Sources */, 15AE198C19AAD36E00C27E9E /* CheckBoxReader.cpp in Sources */, B665E4261AA80A6600DDB1C5 /* CCPUUtil.cpp in Sources */, 15AE1B6319AADA9900C27E9E /* UICheckBox.cpp in Sources */, 15EFA211198A2BB5000C57D3 /* CCProtectedNode.cpp in Sources */, + B6CAB3771AF9AA1A00B9B856 /* btGjkEpaPenetrationDepthSolver.cpp in Sources */, 15FB208F1AE7C57D00C31518 /* advancing_front.cc in Sources */, 50ABBEB71925AB6F00A911A9 /* ccUTF8.cpp in Sources */, B665E2621AA80A6500DDB1C5 /* CCPUDoExpireEventHandler.cpp in Sources */, @@ -8190,25 +10574,34 @@ B665E3061AA80A6500DDB1C5 /* CCPUMeshSurfaceEmitterTranslator.cpp in Sources */, 15AE1A3019AAD3D500C27E9E /* b2ChainShape.cpp in Sources */, 50ABBE8B1925AB6F00A911A9 /* CCNS.cpp in Sources */, + B6CAB2651AF9AA1A00B9B856 /* btSimulationIslandManager.cpp in Sources */, 15AE1BD819AAE01E00C27E9E /* CCControlStepper.cpp in Sources */, + B6CAB3851AF9AA1A00B9B856 /* btPersistentManifold.cpp in Sources */, 46A170E81807CECA005B8026 /* CCPhysicsContact.cpp in Sources */, 1A570061180BC5A10088DEC7 /* CCAction.cpp in Sources */, + B6CAB4431AF9AA1A00B9B856 /* btParallelConstraintSolver.cpp in Sources */, 15AE1BDC19AAE01E00C27E9E /* CCControlUtils.cpp in Sources */, B29A7DE919EE1B7700872B35 /* EventData.c in Sources */, 50ABBEC51925AB6F00A911A9 /* etc1.cpp in Sources */, 50643BDE19BFCCA400EF68ED /* LocalStorage-android.cpp in Sources */, 15AE1B5B19AADA9900C27E9E /* UITextAtlas.cpp in Sources */, + B6CAB2F11AF9AA1A00B9B856 /* btTetrahedronShape.cpp in Sources */, B603F1A81AC8EA0900A9579C /* CCTerrain.cpp in Sources */, + B6CAB2691AF9AA1A00B9B856 /* btSphereBoxCollisionAlgorithm.cpp in Sources */, 1A570065180BC5A10088DEC7 /* CCActionCamera.cpp in Sources */, + B6CAAFF21AF9A9E100B9B856 /* CCPhysics3DObject.cpp in Sources */, + B6CAB23D1AF9AA1A00B9B856 /* btConvex2dConvex2dAlgorithm.cpp in Sources */, 50ABBEAB1925AB6F00A911A9 /* ccTypes.cpp in Sources */, B665E3AE1AA80A6500DDB1C5 /* CCPURender.cpp in Sources */, 15AE18A219AAD33D00C27E9E /* CCParticleSystemQuadLoader.cpp in Sources */, 15AE188C19AAD33D00C27E9E /* CCLabelBMFontLoader.cpp in Sources */, + B6CAAFE21AF9A9E100B9B856 /* CCPhysics3D.cpp in Sources */, DA8C62A219E52C6400000516 /* ioapi_mem.cpp in Sources */, B68779001A8CA82E00643ABF /* CCParticle3DRender.cpp in Sources */, 1A570069180BC5A10088DEC7 /* CCActionCatmullRom.cpp in Sources */, B257B44E1989D5E800D9A687 /* CCPrimitive.cpp in Sources */, 299CF1FB19A434BC00C378C1 /* ccRandom.cpp in Sources */, + B6CAB4D91AF9AA1A00B9B856 /* SpuMinkowskiPenetrationDepthSolver.cpp in Sources */, B665E3CE1AA80A6600DDB1C5 /* CCPUScriptCompiler.cpp in Sources */, 15AE18E819AAD35000C27E9E /* CCActionManagerEx.cpp in Sources */, B29A7DDB19EE1B7700872B35 /* Event.c in Sources */, @@ -8217,8 +10610,10 @@ 1A57006D180BC5A10088DEC7 /* CCActionEase.cpp in Sources */, 15AE1A5019AAD40300C27E9E /* b2BlockAllocator.cpp in Sources */, B665E20E1AA80A6500DDB1C5 /* CCPUBaseForceAffector.cpp in Sources */, + B6CAB25D1AF9AA1A00B9B856 /* btInternalEdgeUtility.cpp in Sources */, 15AE1A8219AAD40300C27E9E /* b2GearJoint.cpp in Sources */, 1A570071180BC5A10088DEC7 /* CCActionGrid.cpp in Sources */, + B6CAB2F91AF9AA1A00B9B856 /* btTriangleCallback.cpp in Sources */, 50CB247F19D9C5A100687767 /* AudioPlayer.mm in Sources */, 50ABBFFF1926664800A911A9 /* CCFileUtils-apple.mm in Sources */, 1A570075180BC5A10088DEC7 /* CCActionGrid3D.cpp in Sources */, @@ -8227,6 +10622,7 @@ 382384131A259092002C4610 /* NodeReaderProtocol.cpp in Sources */, B665E2C21AA80A6500DDB1C5 /* CCPUGeometryRotatorTranslator.cpp in Sources */, 15AE1A5F19AAD40300C27E9E /* b2ContactManager.cpp in Sources */, + B6CAB2451AF9AA1A00B9B856 /* btConvexConvexAlgorithm.cpp in Sources */, 15AE1B9D19AADFDF00C27E9E /* UIVBox.cpp in Sources */, B665E2B61AA80A6500DDB1C5 /* CCPUForceFieldAffector.cpp in Sources */, 1A570079180BC5A10088DEC7 /* CCActionInstant.cpp in Sources */, @@ -8244,7 +10640,9 @@ 1A570081180BC5A10088DEC7 /* CCActionManager.cpp in Sources */, 15AE1A6119AAD40300C27E9E /* b2Fixture.cpp in Sources */, 1A570085180BC5A10088DEC7 /* CCActionPageTurn3D.cpp in Sources */, + B6CAB2B71AF9AA1A00B9B856 /* btConvexTriangleMeshShape.cpp in Sources */, 382384441A25915C002C4610 /* SpriteReader.cpp in Sources */, + B6CAB3291AF9AA1A00B9B856 /* btGImpactCollisionAlgorithm.cpp in Sources */, 1A570089180BC5A10088DEC7 /* CCActionProgressTimer.cpp in Sources */, B665E3A61AA80A6500DDB1C5 /* CCPURandomiser.cpp in Sources */, B665E3CA1AA80A6600DDB1C5 /* CCPUScaleVelocityAffectorTranslator.cpp in Sources */, @@ -8254,9 +10652,12 @@ B665E2961AA80A6500DDB1C5 /* CCPUEmitterManager.cpp in Sources */, 1A570091180BC5A10088DEC7 /* CCActionTween.cpp in Sources */, 15AE188419AAD33D00C27E9E /* CCBSequence.cpp in Sources */, + B6CAB2171AF9AA1A00B9B856 /* btBox2dBox2dCollisionAlgorithm.cpp in Sources */, 50ABBEBF1925AB6F00A911A9 /* CCValue.cpp in Sources */, 1A570098180BC5C10088DEC7 /* CCAtlasNode.cpp in Sources */, 1A57009E180BC5D20088DEC7 /* CCNode.cpp in Sources */, + B6CAB3CD1AF9AA1A00B9B856 /* btSequentialImpulseConstraintSolver.cpp in Sources */, + B6CAB5191AF9AA1A00B9B856 /* btPolarDecomposition.cpp in Sources */, 50ED2BD919BE5D5D00A0AB90 /* CCEventListenerController.cpp in Sources */, B665E2321AA80A6500DDB1C5 /* CCPUBoxEmitter.cpp in Sources */, B257B460198A353E00D9A687 /* CCPrimitiveCommand.cpp in Sources */, @@ -8264,27 +10665,39 @@ 50ED2BDB19BE76D500A0AB90 /* UIVideoPlayer-ios.mm in Sources */, B665E32A1AA80A6500DDB1C5 /* CCPUOnCountObserver.cpp in Sources */, 15AE1B5F19AADA9900C27E9E /* UITextField.cpp in Sources */, + B6CAB29B1AF9AA1A00B9B856 /* btConeShape.cpp in Sources */, 15AE187C19AAD33D00C27E9E /* CCBFileLoader.cpp in Sources */, + B6CAB3B31AF9AA1A00B9B856 /* btGearConstraint.cpp in Sources */, + B6CAB4031AF9AA1A00B9B856 /* btMultiBodyDynamicsWorld.cpp in Sources */, B665E3F21AA80A6600DDB1C5 /* CCPUSlaveEmitter.cpp in Sources */, 50ABBE651925AB6F00A911A9 /* CCEventListenerCustom.cpp in Sources */, D0FD034B1A3B51AA00825BB5 /* CCAllocatorDiagnostics.cpp in Sources */, + B6CAB3E11AF9AA1A00B9B856 /* btUniversalConstraint.cpp in Sources */, 15AE189B19AAD33D00C27E9E /* CCNode+CCBRelativePositioning.cpp in Sources */, 15AE183819AAD2F700C27E9E /* CCRay.cpp in Sources */, 50ABBE391925AB6F00A911A9 /* CCData.cpp in Sources */, 1A57010E180BC8EE0088DEC7 /* CCDrawingPrimitives.cpp in Sources */, + B6CAB3D11AF9AA1A00B9B856 /* btSliderConstraint.cpp in Sources */, 50ABBED71925AB6F00A911A9 /* ZipUtils.cpp in Sources */, B665E3B61AA80A6500DDB1C5 /* CCPURibbonTrail.cpp in Sources */, + B6CAAFF61AF9A9E100B9B856 /* CCPhysics3DShape.cpp in Sources */, + B6CAB3071AF9AA1A00B9B856 /* btTriangleMesh.cpp in Sources */, B29A7E1319EE1B7700872B35 /* Bone.c in Sources */, B665E1F61AA80A6500DDB1C5 /* CCPUAffectorManager.cpp in Sources */, 292DB14919B4574100A80320 /* UIEditBoxImpl-ios.mm in Sources */, + B6CAB2511AF9AA1A00B9B856 /* btEmptyCollisionAlgorithm.cpp in Sources */, 15AE181019AAD2F700C27E9E /* CCAnimation3D.cpp in Sources */, 1A01C68418F57BE800EFE3A6 /* CCArray.cpp in Sources */, 1A570112180BC8EE0088DEC7 /* CCDrawNode.cpp in Sources */, + B6CAB4B11AF9AA1A00B9B856 /* SpuContactManifoldCollisionAlgorithm.cpp in Sources */, 15AE186D19AAD31D00C27E9E /* SimpleAudioEngine_objc.m in Sources */, + B6CAB2D11AF9AA1A00B9B856 /* btMultiSphereShape.cpp in Sources */, 1A57011B180BC90D0088DEC7 /* CCGrabber.cpp in Sources */, + B6CAB3951AF9AA1A00B9B856 /* btSubSimplexConvexCast.cpp in Sources */, B29A7E3719EE1B7700872B35 /* AnimationStateData.c in Sources */, 15AE182419AAD2F700C27E9E /* CCMesh.cpp in Sources */, 15AE190D19AAD35000C27E9E /* CCDisplayManager.cpp in Sources */, + B6CAB2271AF9AA1A00B9B856 /* btCollisionDispatcher.cpp in Sources */, 382383FA1A258FA7002C4610 /* idl_gen_go.cpp in Sources */, 382383FE1A258FA7002C4610 /* idl_parser.cpp in Sources */, 1A57011F180BC90D0088DEC7 /* CCGrid.cpp in Sources */, @@ -8298,17 +10711,21 @@ 38B8E2E119E671D2002D7CE7 /* UILayoutComponent.cpp in Sources */, B665E3F61AA80A6600DDB1C5 /* CCPUSlaveEmitterTranslator.cpp in Sources */, 1A57019D180BCB590088DEC7 /* CCFont.cpp in Sources */, + B6CAB2D51AF9AA1A00B9B856 /* btOptimizedBvh.cpp in Sources */, 50CB247B19D9C5A100687767 /* AudioEngine-inl.mm in Sources */, 1A5701A1180BCB590088DEC7 /* CCFontAtlas.cpp in Sources */, B29A7DFF19EE1B7700872B35 /* Json.c in Sources */, + B6CAB3111AF9AA1A00B9B856 /* btUniformScalingShape.cpp in Sources */, 15AE1A8619AAD40300C27E9E /* b2MouseJoint.cpp in Sources */, 1A5701A5180BCB590088DEC7 /* CCFontAtlasCache.cpp in Sources */, 15AE1A7A19AAD40300C27E9E /* b2PolygonContact.cpp in Sources */, 3823842F1A259112002C4610 /* ParticleReader.cpp in Sources */, 15AE191119AAD35000C27E9E /* CCProcessBase.cpp in Sources */, + B6CAB2B31AF9AA1A00B9B856 /* btConvexShape.cpp in Sources */, 15AE18EE19AAD35000C27E9E /* CCArmature.cpp in Sources */, 15AE1BCD19AAE01E00C27E9E /* CCControlColourPicker.cpp in Sources */, 1A5701B1180BCB590088DEC7 /* CCFontFNT.cpp in Sources */, + B6CAB4A51AF9AA1A00B9B856 /* SequentialThreadSupport.cpp in Sources */, 15AE181619AAD2F700C27E9E /* CCAttachNode.cpp in Sources */, B29A7DED19EE1B7700872B35 /* IkConstraint.c in Sources */, 18956BB21A9DFBFD006E9155 /* Particle3DReader.cpp in Sources */, @@ -8320,6 +10737,9 @@ B665E3121AA80A6500DDB1C5 /* CCPUObserverManager.cpp in Sources */, 292DB13D19B4574100A80320 /* UIEditBox.cpp in Sources */, 50ABBE551925AB6F00A911A9 /* CCEventFocus.cpp in Sources */, + B6CAB4C51AF9AA1A00B9B856 /* boxBoxDistance.cpp in Sources */, + B6CAB29F1AF9AA1A00B9B856 /* btConvex2dShape.cpp in Sources */, + B6CAB4331AF9AA1A00B9B856 /* btGpu3DGridBroadphase.cpp in Sources */, 15AE1A8819AAD40300C27E9E /* b2PrismaticJoint.cpp in Sources */, 182C5CB21A95964700C30D34 /* Node3DReader.cpp in Sources */, 50ABBE491925AB6F00A911A9 /* CCEventAcceleration.cpp in Sources */, @@ -8329,30 +10749,45 @@ B665E30A1AA80A6500DDB1C5 /* CCPUNoise.cpp in Sources */, 15AE182C19AAD2F700C27E9E /* CCMeshVertexIndexData.cpp in Sources */, 15AE1A8C19AAD40300C27E9E /* b2RevoluteJoint.cpp in Sources */, + B6CAB3AF1AF9AA1A00B9B856 /* btFixedConstraint.cpp in Sources */, + B6CAB5231AF9AA1A00B9B856 /* btQuickprof.cpp in Sources */, 50ABBD4C1925AB0000A911A9 /* MathUtil.cpp in Sources */, + B6CAB40B1AF9AA1A00B9B856 /* btMultiBodyJointMotor.cpp in Sources */, + B6CAB3D51AF9AA1A00B9B856 /* btSolve2LinearConstraint.cpp in Sources */, + B6CAB2591AF9AA1A00B9B856 /* btHashedSimplePairCache.cpp in Sources */, 382F7ADC1AB1292A002EBECF /* CCObjectExtensionData.cpp in Sources */, 15AE191719AAD35000C27E9E /* CCSpriteFrameCacheHelper.cpp in Sources */, B665E2E21AA80A6500DDB1C5 /* CCPULineAffectorTranslator.cpp in Sources */, + B6CAB2A31AF9AA1A00B9B856 /* btConvexHullShape.cpp in Sources */, 1A087AE81860400400196EF5 /* edtaa3func.cpp in Sources */, 50ABBD831925AB4100A911A9 /* CCBatchCommand.cpp in Sources */, B665E31E1AA80A6500DDB1C5 /* CCPUOnClearObserverTranslator.cpp in Sources */, B665E2FE1AA80A6500DDB1C5 /* CCPUMaterialTranslator.cpp in Sources */, + B6CAB27D1AF9AA1A00B9B856 /* btBox2dShape.cpp in Sources */, 15AE18FF19AAD35000C27E9E /* CCComAudio.cpp in Sources */, 1A5701C7180BCB5A0088DEC7 /* CCLabelTextFormatter.cpp in Sources */, + B6CAB20F1AF9AA1A00B9B856 /* btSimpleBroadphase.cpp in Sources */, B665E2C61AA80A6500DDB1C5 /* CCPUGravityAffector.cpp in Sources */, B665E3761AA80A6500DDB1C5 /* CCPUParticleFollowerTranslator.cpp in Sources */, 15AE18A819AAD33D00C27E9E /* CCSpriteLoader.cpp in Sources */, + B6CAB2E91AF9AA1A00B9B856 /* btStaticPlaneShape.cpp in Sources */, 1A5701CB180BCB5A0088DEC7 /* CCLabelTTF.cpp in Sources */, 50ABBE711925AB6F00A911A9 /* CCEventListenerMouse.cpp in Sources */, + B6CAB3C91AF9AA1A00B9B856 /* btPoint2PointConstraint.cpp in Sources */, 1A5701DE180BCB8C0088DEC7 /* CCLayer.cpp in Sources */, 15AE1B5919AADA9900C27E9E /* UIText.cpp in Sources */, 15B3707C19EE414C00ABE682 /* CCEventAssetsManagerEx.cpp in Sources */, 3EACC9A419F5014D00EB3C5E /* CCLight.cpp in Sources */, + B6CAB4C91AF9AA1A00B9B856 /* SpuCollisionShapes.cpp in Sources */, + B6CAB38B1AF9AA1A00B9B856 /* btPolyhedralContactClipping.cpp in Sources */, B665E42E1AA80A6600DDB1C5 /* CCPUVelocityMatchingAffectorTranslator.cpp in Sources */, 1A5701E2180BCB8C0088DEC7 /* CCScene.cpp in Sources */, + B6CAB5351AF9AA1A00B9B856 /* btVector3.cpp in Sources */, 15AE1B9919AADFDF00C27E9E /* UIHBox.cpp in Sources */, 15AE199C19AAD39600C27E9E /* ScrollViewReader.cpp in Sources */, + B6CAB2AB1AF9AA1A00B9B856 /* btConvexPointCloudShape.cpp in Sources */, B29A7E0519EE1B7700872B35 /* extension.c in Sources */, + B6CAB30B1AF9AA1A00B9B856 /* btTriangleMeshShape.cpp in Sources */, 15AE187E19AAD33D00C27E9E /* CCBKeyframe.cpp in Sources */, 1A12775C18DFCC590005F345 /* CCTweenFunction.cpp in Sources */, 1A5701E6180BCB8C0088DEC7 /* CCTransition.cpp in Sources */, @@ -8361,6 +10796,7 @@ 15AE1A6A19AAD40300C27E9E /* b2ChainAndCircleContact.cpp in Sources */, B665E38A1AA80A6500DDB1C5 /* CCPUPlane.cpp in Sources */, B665E2161AA80A6500DDB1C5 /* CCPUBeamRender.cpp in Sources */, + B6CAB4B71AF9AA1A00B9B856 /* SpuFakeDma.cpp in Sources */, B665E3361AA80A6500DDB1C5 /* CCPUOnEmissionObserverTranslator.cpp in Sources */, 15B3708819EE414C00ABE682 /* Manifest.cpp in Sources */, B665E27E1AA80A6500DDB1C5 /* CCPUDoScaleEventHandlerTranslator.cpp in Sources */, @@ -8372,6 +10808,7 @@ B665E2CE1AA80A6500DDB1C5 /* CCPUInterParticleCollider.cpp in Sources */, 50ABBDAD1925AB4100A911A9 /* CCRenderer.cpp in Sources */, 15AE199019AAD37200C27E9E /* ImageViewReader.cpp in Sources */, + B6CAB3DD1AF9AA1A00B9B856 /* btTypedConstraint.cpp in Sources */, B665E28A1AA80A6500DDB1C5 /* CCPUDynamicAttribute.cpp in Sources */, B665E2A21AA80A6500DDB1C5 /* CCPUEventHandlerManager.cpp in Sources */, B665E3EE1AA80A6600DDB1C5 /* CCPUSlaveBehaviourTranslator.cpp in Sources */, @@ -8380,18 +10817,23 @@ B29A7DE119EE1B7700872B35 /* MeshAttachment.c in Sources */, 15AE18F419AAD35000C27E9E /* CCArmatureDefine.cpp in Sources */, 15AE186619AAD31D00C27E9E /* CDOpenALSupport.m in Sources */, + 5012169A1AC473A3009A4BEA /* CCTechnique.cpp in Sources */, 1A5701F7180BCBAD0088DEC7 /* CCMenu.cpp in Sources */, B665E33E1AA80A6500DDB1C5 /* CCPUOnEventFlagObserverTranslator.cpp in Sources */, 1A1645B2191B726C008C7C7F /* ConvertUTFWrapper.cpp in Sources */, B665E3B21AA80A6500DDB1C5 /* CCPURendererTranslator.cpp in Sources */, 15AE1BC919AAE01E00C27E9E /* CCControl.cpp in Sources */, + B6CAB3BF1AF9AA1A00B9B856 /* btHinge2Constraint.cpp in Sources */, B29A7DD119EE1B7700872B35 /* Skin.c in Sources */, + B6CAB1F51AF9AA1A00B9B856 /* btDbvt.cpp in Sources */, B665E2D61AA80A6500DDB1C5 /* CCPUJetAffector.cpp in Sources */, 1A5701FB180BCBAD0088DEC7 /* CCMenuItem.cpp in Sources */, 1A570202180BCBD40088DEC7 /* CCClippingNode.cpp in Sources */, + B6CAB4FF1AF9AA1A00B9B856 /* btConvexHullComputer.cpp in Sources */, 1A570208180BCBDF0088DEC7 /* CCMotionStreak.cpp in Sources */, 15FB20971AE7C57D00C31518 /* sweep.cc in Sources */, 1A570210180BCBF40088DEC7 /* CCProgressTimer.cpp in Sources */, + 501216941AC47393009A4BEA /* CCPass.cpp in Sources */, 292DB15F19B461CA00A80320 /* ExtensionDeprecated.cpp in Sources */, 292DB14D19B4574100A80320 /* UIEditBoxImpl-mac.mm in Sources */, 50ABBDB51925AB4100A911A9 /* CCTexture2D.cpp in Sources */, @@ -8399,10 +10841,14 @@ 3EACC9A019F5014D00EB3C5E /* CCCamera.cpp in Sources */, 1A570214180BCBF40088DEC7 /* CCRenderTexture.cpp in Sources */, B665E3FE1AA80A6600DDB1C5 /* CCPUSphereCollider.cpp in Sources */, + B6CAB3591AF9AA1A00B9B856 /* gim_memory.cpp in Sources */, B665E25A1AA80A6500DDB1C5 /* CCPUDoEnableComponentEventHandler.cpp in Sources */, + B6CAB2BB1AF9AA1A00B9B856 /* btCylinderShape.cpp in Sources */, 15AE1BD019AAE01E00C27E9E /* CCControlHuePicker.cpp in Sources */, + B6CAAFFA1AF9A9E100B9B856 /* CCPhysics3DWorld.cpp in Sources */, 15AE18F219AAD35000C27E9E /* CCArmatureDataManager.cpp in Sources */, B665E2DE1AA80A6500DDB1C5 /* CCPULineAffector.cpp in Sources */, + B6CAB5471AF9AA1A00B9B856 /* MiniCLTaskScheduler.cpp in Sources */, 15AE1B6119AADA9900C27E9E /* UIButton.cpp in Sources */, 15AE1A5519AAD40300C27E9E /* b2Math.cpp in Sources */, B276EF651988D1D500CD400F /* CCVertexIndexBuffer.cpp in Sources */, @@ -8420,21 +10866,30 @@ 1A570282180BCC900088DEC7 /* CCSpriteBatchNode.cpp in Sources */, 1A570286180BCC900088DEC7 /* CCSpriteFrame.cpp in Sources */, B24AA989195A675C007B4522 /* CCFastTMXTiledMap.cpp in Sources */, + B6CAB4DF1AF9AA1A00B9B856 /* SpuSampleTask.cpp in Sources */, B29A7E2F19EE1B7700872B35 /* SkeletonAnimation.cpp in Sources */, B60C5BD419AC68B10056FBDE /* CCBillBoard.cpp in Sources */, 15AE199619AAD39600C27E9E /* ListViewReader.cpp in Sources */, + B6CAB52B1AF9AA1A00B9B856 /* btSerializer.cpp in Sources */, 50ABC0191926664800A911A9 /* CCSAXParser.cpp in Sources */, 15AE189219AAD33D00C27E9E /* CCLayerGradientLoader.cpp in Sources */, + B6CAB4471AF9AA1A00B9B856 /* btThreadSupportInterface.cpp in Sources */, 15FB206E1AE7BE7400C31518 /* SpritePolygonCache.cpp in Sources */, 15AE1B6A19AADA9900C27E9E /* UIDeprecated.cpp in Sources */, 15AE183C19AAD2F700C27E9E /* CCSkeleton3D.cpp in Sources */, + B6CAB36F1AF9AA1A00B9B856 /* btGjkConvexCast.cpp in Sources */, + B6CAB31B1AF9AA1A00B9B856 /* btContactProcessing.cpp in Sources */, 15AE1A2319AAD3D500C27E9E /* b2BroadPhase.cpp in Sources */, 382384211A2590DA002C4610 /* GameMapReader.cpp in Sources */, B29A7DF319EE1B7700872B35 /* AttachmentLoader.c in Sources */, + B6CAB3331AF9AA1A00B9B856 /* btGImpactShape.cpp in Sources */, 382383F01A258FA7002C4610 /* flatc.cpp in Sources */, B665E31A1AA80A6500DDB1C5 /* CCPUOnClearObserver.cpp in Sources */, 1A57028A180BCC900088DEC7 /* CCSpriteFrameCache.cpp in Sources */, 15AE18E619AAD35000C27E9E /* CCActionFrameEasing.cpp in Sources */, + B6CAB34B1AF9AA1A00B9B856 /* gim_contact.cpp in Sources */, + B6CAB4A91AF9AA1A00B9B856 /* SpuCollisionObjectWrapper.cpp in Sources */, + B6CAB2A71AF9AA1A00B9B856 /* btConvexInternalShape.cpp in Sources */, 38F5263E1A48363B000DB7F7 /* ArmatureNodeReader.cpp in Sources */, B665E34E1AA80A6500DDB1C5 /* CCPUOnPositionObserverTranslator.cpp in Sources */, B29A7DC919EE1B7700872B35 /* SlotData.c in Sources */, @@ -8445,29 +10900,37 @@ 1A570292180BCCAB0088DEC7 /* CCAnimation.cpp in Sources */, B665E3421AA80A6500DDB1C5 /* CCPUOnExpireObserver.cpp in Sources */, B665E2DA1AA80A6500DDB1C5 /* CCPUJetAffectorTranslator.cpp in Sources */, + B6CAB2791AF9AA1A00B9B856 /* SphereTriangleDetector.cpp in Sources */, 1A570296180BCCAB0088DEC7 /* CCAnimationCache.cpp in Sources */, B29A7E1B19EE1B7700872B35 /* SkeletonJson.c in Sources */, 50ABBE351925AB6F00A911A9 /* CCConsole.cpp in Sources */, B665E3FA1AA80A6600DDB1C5 /* CCPUSphere.cpp in Sources */, 50ABBEAF1925AB6F00A911A9 /* CCUserDefault.cpp in Sources */, 15AE1BCB19AAE01E00C27E9E /* CCControlButton.cpp in Sources */, + B6CAB3731AF9AA1A00B9B856 /* btGjkEpa2.cpp in Sources */, 50ABBE791925AB6F00A911A9 /* CCEventMouse.cpp in Sources */, 15AE1A2E19AAD3D500C27E9E /* b2TimeOfImpact.cpp in Sources */, + B6CAB2FD1AF9AA1A00B9B856 /* btTriangleIndexVertexArray.cpp in Sources */, 50ABC0111926664800A911A9 /* CCGLView.cpp in Sources */, 50ABBE3D1925AB6F00A911A9 /* CCDataVisitor.cpp in Sources */, B29A7DD519EE1B7700872B35 /* RegionAttachment.c in Sources */, 382384071A25900F002C4610 /* FlatBuffersSerialize.cpp in Sources */, B29A7E2519EE1B7700872B35 /* Attachment.c in Sources */, + B6CAB3631AF9AA1A00B9B856 /* btContinuousConvexCollision.cpp in Sources */, B665E3021AA80A6500DDB1C5 /* CCPUMeshSurfaceEmitter.cpp in Sources */, B665E3721AA80A6500DDB1C5 /* CCPUParticleFollower.cpp in Sources */, + B6CAB22B1AF9AA1A00B9B856 /* btCollisionObject.cpp in Sources */, 1A5702C8180BCE370088DEC7 /* CCTextFieldTTF.cpp in Sources */, B665E2861AA80A6500DDB1C5 /* CCPUDoStopSystemEventHandlerTranslator.cpp in Sources */, 15AE1B5519AADA9900C27E9E /* UIScrollView.cpp in Sources */, 15AE191919AAD35000C27E9E /* CCSSceneReader.cpp in Sources */, + B6CAB1FD1AF9AA1A00B9B856 /* btDispatcher.cpp in Sources */, + B6CAB2BF1AF9AA1A00B9B856 /* btEmptyShape.cpp in Sources */, 50ABBE7D1925AB6F00A911A9 /* CCEventTouch.cpp in Sources */, B665E22A1AA80A6500DDB1C5 /* CCPUBoxCollider.cpp in Sources */, 1A5702EA180BCE750088DEC7 /* CCTileMapAtlas.cpp in Sources */, 50ABBD971925AB4100A911A9 /* CCGLProgramStateCache.cpp in Sources */, + B6CAB5431AF9AA1A00B9B856 /* MiniCLTask.cpp in Sources */, 15AE182019AAD2F700C27E9E /* CCBundleReader.cpp in Sources */, B665E2421AA80A6500DDB1C5 /* CCPUCollisionAvoidanceAffector.cpp in Sources */, 15AE1AD819AAD41000C27E9E /* b2Rope.cpp in Sources */, @@ -8476,22 +10939,33 @@ B29A7DC719EE1B7700872B35 /* SkeletonRenderer.cpp in Sources */, 15AE1A7C19AAD40300C27E9E /* b2MotorJoint.cpp in Sources */, 15AE1A2619AAD3D500C27E9E /* b2CollideEdge.cpp in Sources */, + B6CAB1F11AF9AA1A00B9B856 /* btCollisionAlgorithm.cpp in Sources */, 1A5702EE180BCE750088DEC7 /* CCTMXLayer.cpp in Sources */, 15AE1BD619AAE01E00C27E9E /* CCControlSlider.cpp in Sources */, B665E3A21AA80A6500DDB1C5 /* CCPUPositionEmitterTranslator.cpp in Sources */, B665E39E1AA80A6500DDB1C5 /* CCPUPositionEmitter.cpp in Sources */, + B6CAB2011AF9AA1A00B9B856 /* btMultiSapBroadphase.cpp in Sources */, B665E41A1AA80A6600DDB1C5 /* CCPUTextureRotator.cpp in Sources */, B665E3C61AA80A6600DDB1C5 /* CCPUScaleVelocityAffector.cpp in Sources */, + B6CAB31F1AF9AA1A00B9B856 /* btGenericPoolAllocator.cpp in Sources */, + B6CAB3F11AF9AA1A00B9B856 /* btSimpleDynamicsWorld.cpp in Sources */, 50ABBE691925AB6F00A911A9 /* CCEventListenerFocus.cpp in Sources */, 15AE18EA19AAD35000C27E9E /* CCActionNode.cpp in Sources */, + B6CAB2391AF9AA1A00B9B856 /* btCompoundCompoundCollisionAlgorithm.cpp in Sources */, 15AE1A7819AAD40300C27E9E /* b2PolygonAndCircleContact.cpp in Sources */, 15AE1A3419AAD3D500C27E9E /* b2EdgeShape.cpp in Sources */, + B6CAB1F91AF9AA1A00B9B856 /* btDbvtBroadphase.cpp in Sources */, B665E32E1AA80A6500DDB1C5 /* CCPUOnCountObserverTranslator.cpp in Sources */, + B6CAB21B1AF9AA1A00B9B856 /* btBoxBoxCollisionAlgorithm.cpp in Sources */, B665E2AE1AA80A6500DDB1C5 /* CCPUFlockCenteringAffectorTranslator.cpp in Sources */, 15AE1BA319AADFDF00C27E9E /* UILayoutManager.cpp in Sources */, B230ED7119B417AE00364AA8 /* CCTrianglesCommand.cpp in Sources */, + B6CAB3991AF9AA1A00B9B856 /* btVoronoiSimplexSolver.cpp in Sources */, 1A5702F2180BCE750088DEC7 /* CCTMXObjectGroup.cpp in Sources */, + B6CAB3011AF9AA1A00B9B856 /* btTriangleIndexVertexMaterialArray.cpp in Sources */, 15AE1A5B19AAD40300C27E9E /* b2Timer.cpp in Sources */, + B6CAB2971AF9AA1A00B9B856 /* btConcaveShape.cpp in Sources */, + B6CAB4291AF9AA1A00B9B856 /* btRaycastVehicle.cpp in Sources */, 15AE189419AAD33D00C27E9E /* CCLayerLoader.cpp in Sources */, 826294351AAF004C00CB7CF7 /* HttpCookie.cpp in Sources */, 1A5702F6180BCE750088DEC7 /* CCTMXTiledMap.cpp in Sources */, @@ -8505,7 +10979,9 @@ 50ABBD5C1925AB0000A911A9 /* Vec3.cpp in Sources */, 1A570300180BCE890088DEC7 /* CCParallaxNode.cpp in Sources */, 15AE191D19AAD35000C27E9E /* CCTween.cpp in Sources */, + B6CAB2311AF9AA1A00B9B856 /* btCollisionWorld.cpp in Sources */, 15AE1A6C19AAD40300C27E9E /* b2ChainAndPolygonContact.cpp in Sources */, + B6CAB37B1AF9AA1A00B9B856 /* btGjkPairDetector.cpp in Sources */, 15AE1A2719AAD3D500C27E9E /* b2CollidePolygon.cpp in Sources */, 15AE199A19AAD39600C27E9E /* PageViewReader.cpp in Sources */, 1A57030C180BCF190088DEC7 /* CCComponent.cpp in Sources */, @@ -8513,25 +10989,41 @@ 15FB20741AE7BF8600C31518 /* MarchingSquare.cpp in Sources */, B665E2A61AA80A6500DDB1C5 /* CCPUEventHandlerTranslator.cpp in Sources */, 15AE1A5919AAD40300C27E9E /* b2StackAllocator.cpp in Sources */, + B6CAB20B1AF9AA1A00B9B856 /* btQuantizedBvh.cpp in Sources */, + B6CAB5411AF9AA1A00B9B856 /* MiniCL.cpp in Sources */, B29A7E3D19EE1B7700872B35 /* AnimationState.c in Sources */, B665E2E61AA80A6500DDB1C5 /* CCPULinearForceAffector.cpp in Sources */, 15AE192219AAD35000C27E9E /* DictionaryHelper.cpp in Sources */, + B6CAB4F51AF9AA1A00B9B856 /* btAlignedAllocator.cpp in Sources */, 15AE196C19AAD35700C27E9E /* CCActionTimeline.cpp in Sources */, + B6CAB2611AF9AA1A00B9B856 /* btManifoldResult.cpp in Sources */, B29A7E0719EE1B7700872B35 /* SkinnedMeshAttachment.c in Sources */, + B6CAB28F1AF9AA1A00B9B856 /* btCollisionShape.cpp in Sources */, + B6CAB39F1AF9AA1A00B9B856 /* btKinematicCharacterController.cpp in Sources */, + B6CAB2051AF9AA1A00B9B856 /* btOverlappingPairCache.cpp in Sources */, 1A570310180BCF190088DEC7 /* CCComponentContainer.cpp in Sources */, 15AE190719AAD35000C27E9E /* CCDatas.cpp in Sources */, 1A01C69C18F57BE800EFE3A6 /* CCString.cpp in Sources */, + B6CAB26D1AF9AA1A00B9B856 /* btSphereSphereCollisionAlgorithm.cpp in Sources */, + B6CAB3251AF9AA1A00B9B856 /* btGImpactBvh.cpp in Sources */, B665E2721AA80A6500DDB1C5 /* CCPUDoPlacementParticleEventHandler.cpp in Sources */, 50ABBD3C1925AB0000A911A9 /* CCGeometry.cpp in Sources */, + B6CAB3C31AF9AA1A00B9B856 /* btHingeConstraint.cpp in Sources */, 15FB206A1AE7BE7400C31518 /* SpritePolygon.cpp in Sources */, B29A7DDD19EE1B7700872B35 /* BoneData.c in Sources */, 15AE188A19AAD33D00C27E9E /* CCControlLoader.cpp in Sources */, + 5012168E1AC47380009A4BEA /* CCRenderState.cpp in Sources */, + B6CAB2491AF9AA1A00B9B856 /* btConvexPlaneCollisionAlgorithm.cpp in Sources */, B665E35A1AA80A6500DDB1C5 /* CCPUOnRandomObserver.cpp in Sources */, + B6CAB2891AF9AA1A00B9B856 /* btCapsuleShape.cpp in Sources */, + B6CAB42F1AF9AA1A00B9B856 /* btWheelInfo.cpp in Sources */, B29A7DFB19EE1B7700872B35 /* spine-cocos2dx.cpp in Sources */, + B6CAB3391AF9AA1A00B9B856 /* btTriangleShapeEx.cpp in Sources */, 50ABC0011926664800A911A9 /* CCLock-apple.cpp in Sources */, 15AE1A8019AAD40300C27E9E /* b2FrictionJoint.cpp in Sources */, 50ABBD931925AB4100A911A9 /* CCGLProgramState.cpp in Sources */, 15AE183419AAD2F700C27E9E /* CCObjLoader.cpp in Sources */, + B6CAB2551AF9AA1A00B9B856 /* btGhostObject.cpp in Sources */, B665E23A1AA80A6500DDB1C5 /* CCPUCircleEmitter.cpp in Sources */, 1A57034B180BD09B0088DEC7 /* tinyxml2.cpp in Sources */, 1A570354180BD0B00088DEC7 /* ioapi.cpp in Sources */, @@ -8543,17 +11035,24 @@ 50ABBEB31925AB6F00A911A9 /* CCUserDefault-apple.mm in Sources */, 50ABBEB51925AB6F00A911A9 /* CCUserDefault-android.cpp in Sources */, 5E9F61261A3FFE3D0038DE01 /* CCFrustum.cpp in Sources */, + B6CAB3FB1AF9AA1A00B9B856 /* btMultiBodyConstraint.cpp in Sources */, B665E4221AA80A6600DDB1C5 /* CCPUTranslateManager.cpp in Sources */, B665E38E1AA80A6500DDB1C5 /* CCPUPlaneCollider.cpp in Sources */, B665E2021AA80A6500DDB1C5 /* CCPUAlignAffectorTranslator.cpp in Sources */, B665E3661AA80A6500DDB1C5 /* CCPUOnTimeObserverTranslator.cpp in Sources */, B665E4361AA80A6600DDB1C5 /* CCPUVortexAffector.cpp in Sources */, + B6CAB4191AF9AA1A00B9B856 /* btDantzigLCP.cpp in Sources */, B665E3DE1AA80A6600DDB1C5 /* CCPUSimpleSpline.cpp in Sources */, B665E22E1AA80A6500DDB1C5 /* CCPUBoxColliderTranslator.cpp in Sources */, 29394CF619B01DBA00D2DE1A /* UIWebViewImpl-ios.mm in Sources */, + B6CAB3FF1AF9AA1A00B9B856 /* btMultiBodyConstraintSolver.cpp in Sources */, 382383FC1A258FA7002C4610 /* idl_gen_text.cpp in Sources */, 50ABBE831925AB6F00A911A9 /* ccFPSImages.c in Sources */, + B6CAB4CD1AF9AA1A00B9B856 /* SpuContactResult.cpp in Sources */, 15AE1B7019AADA9900C27E9E /* CocosGUI.cpp in Sources */, + B6CAB2AF1AF9AA1A00B9B856 /* btConvexPolyhedron.cpp in Sources */, + B6CAB4EF1AF9AA1A00B9B856 /* Win32ThreadSupport.cpp in Sources */, + B6CAB3E71AF9AA1A00B9B856 /* btDiscreteDynamicsWorld.cpp in Sources */, 50CB247719D9C5A100687767 /* AudioCache.mm in Sources */, B665E25E1AA80A6500DDB1C5 /* CCPUDoEnableComponentEventHandlerTranslator.cpp in Sources */, 15AE18FA19AAD35000C27E9E /* CCColliderDetector.cpp in Sources */, @@ -8568,12 +11067,17 @@ B665E2121AA80A6500DDB1C5 /* CCPUBaseForceAffectorTranslator.cpp in Sources */, 38ACD1FC1A27111900C3093D /* WidgetCallBackHandlerProtocol.cpp in Sources */, 15FB209B1AE7C57D00C31518 /* sweep_context.cc in Sources */, + B6CAAFEE1AF9A9E100B9B856 /* CCPhysics3DDebugDrawer.cpp in Sources */, + B6CAB5051AF9AA1A00B9B856 /* btGeometryUtil.cpp in Sources */, 15AE1A7619AAD40300C27E9E /* b2EdgeAndPolygonContact.cpp in Sources */, + B6CAB4BB1AF9AA1A00B9B856 /* SpuGatheringCollisionDispatcher.cpp in Sources */, 50ABBD8B1925AB4100A911A9 /* CCGLProgram.cpp in Sources */, 464AD6E5197EBB1400E502D8 /* pvr.cpp in Sources */, + B6CAB3F51AF9AA1A00B9B856 /* Bullet-C-API.cpp in Sources */, 50ABBDA31925AB4100A911A9 /* CCQuadCommand.cpp in Sources */, 15AE19A219AAD39600C27E9E /* TextBMFontReader.cpp in Sources */, 382384281A2590F9002C4610 /* NodeReader.cpp in Sources */, + B6CAB3671AF9AA1A00B9B856 /* btConvexCast.cpp in Sources */, 50ABC01D1926664800A911A9 /* CCThread.cpp in Sources */, 15AE180C19AAD2F700C27E9E /* CCAnimate3D.cpp in Sources */, 15AE183019AAD2F700C27E9E /* CCOBB.cpp in Sources */, @@ -8589,6 +11093,7 @@ 15AE199819AAD39600C27E9E /* LoadingBarReader.cpp in Sources */, 503DD8F71926B0DB00CD74DD /* CCIMEDispatcher.cpp in Sources */, 50ABBE751925AB6F00A911A9 /* CCEventListenerTouch.cpp in Sources */, + B6CAB2C31AF9AA1A00B9B856 /* btHeightfieldTerrainShape.cpp in Sources */, 15AE18F019AAD35000C27E9E /* CCArmatureAnimation.cpp in Sources */, 50ABBE511925AB6F00A911A9 /* CCEventDispatcher.cpp in Sources */, 50ABC0051926664800A911A9 /* CCThread-apple.mm in Sources */, @@ -8604,13 +11109,17 @@ 50ED2BE419BEAF7900A0AB90 /* UIEditBoxImpl-win32.cpp in Sources */, 50ABBE1F1925AB6F00A911A9 /* atitc.cpp in Sources */, 1A01C69818F57BE800EFE3A6 /* CCSet.cpp in Sources */, + B6CAB2351AF9AA1A00B9B856 /* btCompoundCollisionAlgorithm.cpp in Sources */, B29A7DF119EE1B7700872B35 /* AtlasAttachmentLoader.c in Sources */, + B6CAB3451AF9AA1A00B9B856 /* gim_box_set.cpp in Sources */, 1AAF584F180E40B9000584C8 /* LocalStorage.cpp in Sources */, 15AE1BD219AAE01E00C27E9E /* CCControlPotentiometer.cpp in Sources */, 50ABBEA31925AB6F00A911A9 /* CCScriptSupport.cpp in Sources */, + B6CAB2711AF9AA1A00B9B856 /* btSphereTriangleCollisionAlgorithm.cpp in Sources */, 38B8E2D519E66581002D7CE7 /* CSLoader.cpp in Sources */, 15AE190519AAD35000C27E9E /* CCDataReaderHelper.cpp in Sources */, 826294331AAF001C00CB7CF7 /* HttpAsynConnection.m in Sources */, + B6CAAFE61AF9A9E100B9B856 /* CCPhysics3DComponent.cpp in Sources */, B68778F81A8CA82E00643ABF /* CCParticle3DAffector.cpp in Sources */, 15AE19A019AAD39600C27E9E /* TextAtlasReader.cpp in Sources */, 15AE1A2A19AAD3D500C27E9E /* b2Distance.cpp in Sources */, @@ -8625,6 +11134,7 @@ DABC9FA919E7DFA900FA252C /* CCClippingRectangleNode.cpp in Sources */, 3E2F27A619CFBFE100E7C490 /* AudioEngine.cpp in Sources */, B665E2EE1AA80A6500DDB1C5 /* CCPULineEmitter.cpp in Sources */, + B6CAB2DD1AF9AA1A00B9B856 /* btScaledBvhTriangleMeshShape.cpp in Sources */, B665E4121AA80A6600DDB1C5 /* CCPUTextureAnimator.cpp in Sources */, B665E3D21AA80A6600DDB1C5 /* CCPUScriptLexer.cpp in Sources */, B665E4021AA80A6600DDB1C5 /* CCPUSphereColliderTranslator.cpp in Sources */, @@ -8633,6 +11143,7 @@ B665E39A1AA80A6500DDB1C5 /* CCPUPointEmitterTranslator.cpp in Sources */, 50ABBD9B1925AB4100A911A9 /* ccGLStateCache.cpp in Sources */, 15AE188119AAD33D00C27E9E /* CCBReader.cpp in Sources */, + 501216A01AC473AD009A4BEA /* CCMaterial.cpp in Sources */, 50ABBDB91925AB4100A911A9 /* CCTextureAtlas.cpp in Sources */, 15AE1BE419AAE01E00C27E9E /* CCTableView.cpp in Sources */, 15AE1A3219AAD3D500C27E9E /* b2CircleShape.cpp in Sources */, @@ -8643,6 +11154,7 @@ 15AE1B9F19AADFDF00C27E9E /* UILayout.cpp in Sources */, 50ABBECF1925AB6F00A911A9 /* TGAlib.cpp in Sources */, 15AE199E19AAD39600C27E9E /* SliderReader.cpp in Sources */, + B6CAB49F1AF9AA1A00B9B856 /* PosixThreadSupport.cpp in Sources */, 50ABBE451925AB6F00A911A9 /* CCEvent.cpp in Sources */, D0FD034F1A3B51AA00825BB5 /* CCAllocatorGlobal.cpp in Sources */, 50ABBE611925AB6F00A911A9 /* CCEventListenerAcceleration.cpp in Sources */, @@ -8650,6 +11162,7 @@ B665E3161AA80A6500DDB1C5 /* CCPUObserverTranslator.cpp in Sources */, 15AE1A8E19AAD40300C27E9E /* b2RopeJoint.cpp in Sources */, 50ABBD871925AB4100A911A9 /* CCCustomCommand.cpp in Sources */, + B6CAB2E11AF9AA1A00B9B856 /* btShapeHull.cpp in Sources */, 50ABBDBD1925AB4100A911A9 /* CCTextureCache.cpp in Sources */, 15AE188619AAD33D00C27E9E /* CCBSequenceProperty.cpp in Sources */, B665E43A1AA80A6600DDB1C5 /* CCPUVortexAffectorTranslator.cpp in Sources */, @@ -8660,6 +11173,7 @@ 15AE1A7E19AAD40300C27E9E /* b2DistanceJoint.cpp in Sources */, 15AE190919AAD35000C27E9E /* CCDecorativeDisplay.cpp in Sources */, B665E40E1AA80A6600DDB1C5 /* CCPUTechniqueTranslator.cpp in Sources */, + B6CAB4BF1AF9AA1A00B9B856 /* SpuLibspe2Support.cpp in Sources */, B665E21E1AA80A6500DDB1C5 /* CCPUBehaviourManager.cpp in Sources */, 15AE18E319AAD35000C27E9E /* TriggerObj.cpp in Sources */, 15AE1BA119AADFDF00C27E9E /* UILayoutParameter.cpp in Sources */, @@ -8668,6 +11182,8 @@ 50ABBE4D1925AB6F00A911A9 /* CCEventCustom.cpp in Sources */, 15AE1A6819AAD40300C27E9E /* b2WorldCallbacks.cpp in Sources */, B665E2D21AA80A6500DDB1C5 /* CCPUInterParticleColliderTranslator.cpp in Sources */, + B6CAB3811AF9AA1A00B9B856 /* btMinkowskiPenetrationDepthSolver.cpp in Sources */, + B6CAB4AD1AF9AA1A00B9B856 /* SpuCollisionTaskProcess.cpp in Sources */, 50ABBE9F1925AB6F00A911A9 /* CCScheduler.cpp in Sources */, 15AE1C1119AAE2C600C27E9E /* CCPhysicsDebugNode.cpp in Sources */, B665E2521AA80A6500DDB1C5 /* CCPUDoAffectorEventHandler.cpp in Sources */, @@ -8679,46 +11195,63 @@ 382384361A259126002C4610 /* ProjectNodeReader.cpp in Sources */, B665E37A1AA80A6500DDB1C5 /* CCPUParticleSystem3D.cpp in Sources */, 15AE1BB519AADFEF00C27E9E /* SocketIO.cpp in Sources */, + B6CAB4D31AF9AA1A00B9B856 /* SpuGatheringCollisionTask.cpp in Sources */, 15AE1B6519AADA9900C27E9E /* UIImageView.cpp in Sources */, B29A7E1519EE1B7700872B35 /* BoundingBoxAttachment.c in Sources */, + B6CAB4E31AF9AA1A00B9B856 /* SpuSampleTaskProcess.cpp in Sources */, 15AE1A2519AAD3D500C27E9E /* b2CollideCircle.cpp in Sources */, B665E3321AA80A6500DDB1C5 /* CCPUOnEmissionObserver.cpp in Sources */, 50ABBE5D1925AB6F00A911A9 /* CCEventListener.cpp in Sources */, + B6CAB4FB1AF9AA1A00B9B856 /* btConvexHull.cpp in Sources */, B29A7E2D19EE1B7700872B35 /* Slot.c in Sources */, 15AE182819AAD2F700C27E9E /* CCMeshSkin.cpp in Sources */, B665E42A1AA80A6600DDB1C5 /* CCPUVelocityMatchingAffector.cpp in Sources */, 15AE19A619AAD39600C27E9E /* TextReader.cpp in Sources */, 15AE198819AAD36A00C27E9E /* ButtonReader.cpp in Sources */, + B6CAB4131AF9AA1A00B9B856 /* btMultiBodyPoint2Point.cpp in Sources */, + B6CAB2C91AF9AA1A00B9B856 /* btMinkowskiSumShape.cpp in Sources */, 4D76BE3A1A4AAF0A00102962 /* CCActionTimelineNode.cpp in Sources */, B665E33A1AA80A6500DDB1C5 /* CCPUOnEventFlagObserver.cpp in Sources */, B665E2261AA80A6500DDB1C5 /* CCPUBillboardChain.cpp in Sources */, 15AE1A6319AAD40300C27E9E /* b2Island.cpp in Sources */, + B6CAB2851AF9AA1A00B9B856 /* btBvhTriangleMeshShape.cpp in Sources */, 15AE1A8419AAD40300C27E9E /* b2Joint.cpp in Sources */, 50ABBD601925AB0000A911A9 /* Vec4.cpp in Sources */, 50ABC05F1926664800A911A9 /* CCApplication-mac.mm in Sources */, B29A7E2119EE1B7700872B35 /* PolygonBatch.cpp in Sources */, 15AE1A9219AAD40300C27E9E /* b2WheelJoint.cpp in Sources */, B665E3261AA80A6500DDB1C5 /* CCPUOnCollisionObserverTranslator.cpp in Sources */, + B6CAB3ED1AF9AA1A00B9B856 /* btRigidBody.cpp in Sources */, + B6CAAFFE1AF9A9E100B9B856 /* CCPhysicsSprite3D.cpp in Sources */, + B6CAB1ED1AF9AA1A00B9B856 /* btBroadphaseProxy.cpp in Sources */, B29594B41926D5EC003EEF37 /* CCMeshCommand.cpp in Sources */, 15AE189619AAD33D00C27E9E /* CCMenuItemImageLoader.cpp in Sources */, B665E23E1AA80A6500DDB1C5 /* CCPUCircleEmitterTranslator.cpp in Sources */, 15AE1BB719AADFEF00C27E9E /* WebSocket.cpp in Sources */, + B6CAB21F1AF9AA1A00B9B856 /* btBoxBoxDetector.cpp in Sources */, B665E20A1AA80A6500DDB1C5 /* CCPUBaseColliderTranslator.cpp in Sources */, B665E3E61AA80A6600DDB1C5 /* CCPUSineForceAffectorTranslator.cpp in Sources */, + B6CAB32F1AF9AA1A00B9B856 /* btGImpactQuantizedBvh.cpp in Sources */, 15AE1B5119AADA9900C27E9E /* UIPageView.cpp in Sources */, + B6CAB35F1AF9AA1A00B9B856 /* gim_tri_collision.cpp in Sources */, 15AE18EC19AAD35000C27E9E /* CCActionObject.cpp in Sources */, B665E2821AA80A6500DDB1C5 /* CCPUDoStopSystemEventHandler.cpp in Sources */, 1A01C68E18F57BE800EFE3A6 /* CCDictionary.cpp in Sources */, 50ABBD381925AB0000A911A9 /* CCAffineTransform.cpp in Sources */, B665E2AA1AA80A6500DDB1C5 /* CCPUFlockCenteringAffector.cpp in Sources */, + B6CAB2CD1AF9AA1A00B9B856 /* btMultimaterialTriangleMeshShape.cpp in Sources */, 46C02E0718E91123004B7456 /* xxhash.c in Sources */, 15AE1B6B19AADA9900C27E9E /* UIWidget.cpp in Sources */, 50ABBE931925AB6F00A911A9 /* CCProfiling.cpp in Sources */, 15AE188819AAD33D00C27E9E /* CCControlButtonLoader.cpp in Sources */, B665E2561AA80A6500DDB1C5 /* CCPUDoAffectorEventHandlerTranslator.cpp in Sources */, + B6CAB2131AF9AA1A00B9B856 /* btActivatingCollisionAlgorithm.cpp in Sources */, 15AE18A419AAD33D00C27E9E /* CCScale9SpriteLoader.cpp in Sources */, + B6CAB2ED1AF9AA1A00B9B856 /* btStridingMeshInterface.cpp in Sources */, 182C5CD61A98F30500C30D34 /* Sprite3DReader.cpp in Sources */, 38D9629D1ACA9721007C6FAF /* CocoStudio.cpp in Sources */, + B6CAB24D1AF9AA1A00B9B856 /* btDefaultCollisionConfiguration.cpp in Sources */, + B6CAB3A91AF9AA1A00B9B856 /* btContactConstraint.cpp in Sources */, B665E3D61AA80A6600DDB1C5 /* CCPUScriptParser.cpp in Sources */, 15AE1B5719AADA9900C27E9E /* UISlider.cpp in Sources */, B665E2F61AA80A6500DDB1C5 /* CCPUListener.cpp in Sources */, @@ -8734,19 +11267,24 @@ 15AE1B9819AADAA100C27E9E /* UIVideoPlayer-ios.mm in Sources */, B665E38F1AA80A6500DDB1C5 /* CCPUPlaneCollider.cpp in Sources */, B665E21B1AA80A6500DDB1C5 /* CCPUBehaviour.cpp in Sources */, + B6CAB2CA1AF9AA1A00B9B856 /* btMinkowskiSumShape.cpp in Sources */, B665E38B1AA80A6500DDB1C5 /* CCPUPlane.cpp in Sources */, B665E2731AA80A6500DDB1C5 /* CCPUDoPlacementParticleEventHandler.cpp in Sources */, 15AE1C0519AAE01E00C27E9E /* CCTableViewCell.cpp in Sources */, + B6CAB4D41AF9AA1A00B9B856 /* SpuGatheringCollisionTask.cpp in Sources */, 15AE198A19AAD36A00C27E9E /* ButtonReader.cpp in Sources */, 15AE18D019AAD33D00C27E9E /* CCNodeLoaderLibrary.cpp in Sources */, 15AE192C19AAD35100C27E9E /* CCActionFrame.cpp in Sources */, + B6CAB2461AF9AA1A00B9B856 /* btConvexConvexAlgorithm.cpp in Sources */, 1A01C69918F57BE800EFE3A6 /* CCSet.cpp in Sources */, 1A01C69D18F57BE800EFE3A6 /* CCString.cpp in Sources */, 15FB20981AE7C57D00C31518 /* sweep.cc in Sources */, 15AE199219AAD37300C27E9E /* ImageViewReader.cpp in Sources */, + B6CAB3BC1AF9AA1A00B9B856 /* btGeneric6DofSpringConstraint.cpp in Sources */, B665E1F71AA80A6500DDB1C5 /* CCPUAffectorManager.cpp in Sources */, 2986667F18B1B246000E39CA /* CCTweenFunction.cpp in Sources */, 46A171051807CECB005B8026 /* CCPhysicsWorld.cpp in Sources */, + B6CAB2A81AF9AA1A00B9B856 /* btConvexInternalShape.cpp in Sources */, 50ABBDA01925AB4100A911A9 /* CCGroupCommand.cpp in Sources */, 46A171031807CECB005B8026 /* CCPhysicsShape.cpp in Sources */, B665E35B1AA80A6500DDB1C5 /* CCPUOnRandomObserver.cpp in Sources */, @@ -8754,15 +11292,20 @@ B665E3AB1AA80A6500DDB1C5 /* CCPURandomiserTranslator.cpp in Sources */, 1A01C6A518F58F7500EFE3A6 /* CCNotificationCenter.cpp in Sources */, 292DB14E19B4574100A80320 /* UIEditBoxImpl-mac.mm in Sources */, + B6CAB4BC1AF9AA1A00B9B856 /* SpuGatheringCollisionDispatcher.cpp in Sources */, + B6CAB3CA1AF9AA1A00B9B856 /* btPoint2PointConstraint.cpp in Sources */, B665E3A71AA80A6500DDB1C5 /* CCPURandomiser.cpp in Sources */, 15AE1BFB19AAE01E00C27E9E /* CCControlUtils.cpp in Sources */, B665E30F1AA80A6500DDB1C5 /* CCPUObserver.cpp in Sources */, + B6CAB4A01AF9AA1A00B9B856 /* PosixThreadSupport.cpp in Sources */, B230ED7219B417AE00364AA8 /* CCTrianglesCommand.cpp in Sources */, + B6CAB2821AF9AA1A00B9B856 /* btBoxShape.cpp in Sources */, 382383F91A258FA7002C4610 /* idl_gen_general.cpp in Sources */, 15AE1B9019AADA9A00C27E9E /* UIWidget.cpp in Sources */, ED9C6A9518599AD8000A5232 /* CCNodeGrid.cpp in Sources */, B665E2531AA80A6500DDB1C5 /* CCPUDoAffectorEventHandler.cpp in Sources */, B665E3F71AA80A6600DDB1C5 /* CCPUSlaveEmitterTranslator.cpp in Sources */, + B6CAB3C01AF9AA1A00B9B856 /* btHinge2Constraint.cpp in Sources */, 1A01C68F18F57BE800EFE3A6 /* CCDictionary.cpp in Sources */, B276EF621988D1D500CD400F /* CCVertexIndexData.cpp in Sources */, 50ABBE561925AB6F00A911A9 /* CCEventFocus.cpp in Sources */, @@ -8770,27 +11313,37 @@ 15AE183D19AAD2F700C27E9E /* CCSkeleton3D.cpp in Sources */, 503DD8E11926736A00CD74DD /* CCApplication-ios.mm in Sources */, 15AE1AAC19AAD40300C27E9E /* b2WorldCallbacks.cpp in Sources */, + B6CAB20C1AF9AA1A00B9B856 /* btQuantizedBvh.cpp in Sources */, + B6CAB3F21AF9AA1A00B9B856 /* btSimpleDynamicsWorld.cpp in Sources */, 15AE18C719AAD33D00C27E9E /* CCMenuItemImageLoader.cpp in Sources */, 50ABC01A1926664800A911A9 /* CCSAXParser.cpp in Sources */, B29A7E1C19EE1B7700872B35 /* SkeletonJson.c in Sources */, B2CC507C19776DD10041958E /* CCPhysicsJoint.cpp in Sources */, + B6CAB5241AF9AA1A00B9B856 /* btQuickprof.cpp in Sources */, 182C5CE61A9D725400C30D34 /* UserCameraReader.cpp in Sources */, 38B8E2E219E671D2002D7CE7 /* UILayoutComponent.cpp in Sources */, + B6CAB3D21AF9AA1A00B9B856 /* btSliderConstraint.cpp in Sources */, B2165EEA19921124000BE3E6 /* CCPrimitiveCommand.cpp in Sources */, B665E32B1AA80A6500DDB1C5 /* CCPUOnCountObserver.cpp in Sources */, 15AE185C19AAD31200C27E9E /* CDOpenALSupport.m in Sources */, + B6CAB3B01AF9AA1A00B9B856 /* btFixedConstraint.cpp in Sources */, 15AE186119AAD31200C27E9E /* SimpleAudioEngine_objc.m in Sources */, 15AE182519AAD2F700C27E9E /* CCMesh.cpp in Sources */, B665E4071AA80A6600DDB1C5 /* CCPUSphereSurfaceEmitter.cpp in Sources */, 503DD8EE1926736A00CD74DD /* CCImage-ios.mm in Sources */, + B6CAB2941AF9AA1A00B9B856 /* btCompoundShape.cpp in Sources */, + B6CAB39A1AF9AA1A00B9B856 /* btVoronoiSimplexSolver.cpp in Sources */, 46A170FC1807CECB005B8026 /* CCPhysicsBody.cpp in Sources */, 15AE1BEA19AAE01E00C27E9E /* CCControlButton.cpp in Sources */, 50ABBD941925AB4100A911A9 /* CCGLProgramState.cpp in Sources */, B665E3DF1AA80A6600DDB1C5 /* CCPUSimpleSpline.cpp in Sources */, + B6CAB4F61AF9AA1A00B9B856 /* btAlignedAllocator.cpp in Sources */, B257B44F1989D5E800D9A687 /* CCPrimitive.cpp in Sources */, 50ABBE281925AB6F00A911A9 /* CCAutoreleasePool.cpp in Sources */, 15AE18D519AAD33D00C27E9E /* CCScale9SpriteLoader.cpp in Sources */, 15AE192919AAD35100C27E9E /* TriggerMng.cpp in Sources */, + B6CAB21C1AF9AA1A00B9B856 /* btBoxBoxCollisionAlgorithm.cpp in Sources */, + B6CAB35A1AF9AA1A00B9B856 /* gim_memory.cpp in Sources */, B29A7E0C19EE1B7700872B35 /* Atlas.c in Sources */, 15AE185E19AAD31200C27E9E /* CocosDenshion.m in Sources */, B665E2071AA80A6500DDB1C5 /* CCPUBaseCollider.cpp in Sources */, @@ -8799,8 +11352,11 @@ 1A570066180BC5A10088DEC7 /* CCActionCamera.cpp in Sources */, B665E2D71AA80A6500DDB1C5 /* CCPUJetAffector.cpp in Sources */, B276EF661988D1D500CD400F /* CCVertexIndexBuffer.cpp in Sources */, + B6CAB3961AF9AA1A00B9B856 /* btSubSimplexConvexCast.cpp in Sources */, 15AE1C0119AAE01E00C27E9E /* CCScrollView.cpp in Sources */, + B6CAB2901AF9AA1A00B9B856 /* btCollisionShape.cpp in Sources */, 15B3708919EE414C00ABE682 /* Manifest.cpp in Sources */, + B6CAB2DA1AF9AA1A00B9B856 /* btPolyhedralConvexShape.cpp in Sources */, 15AE1A9B19AAD40300C27E9E /* b2Settings.cpp in Sources */, 1A57006A180BC5A10088DEC7 /* CCActionCatmullRom.cpp in Sources */, 15AE1BEF19AAE01E00C27E9E /* CCControlHuePicker.cpp in Sources */, @@ -8810,13 +11366,17 @@ 1A57006E180BC5A10088DEC7 /* CCActionEase.cpp in Sources */, 50ABBD8C1925AB4100A911A9 /* CCGLProgram.cpp in Sources */, B665E2671AA80A6500DDB1C5 /* CCPUDoExpireEventHandlerTranslator.cpp in Sources */, + B6CAB4AA1AF9AA1A00B9B856 /* SpuCollisionObjectWrapper.cpp in Sources */, + B6CAAFFF1AF9A9E100B9B856 /* CCPhysicsSprite3D.cpp in Sources */, 15AE196119AAD35100C27E9E /* CCSSceneReader.cpp in Sources */, 1A570072180BC5A10088DEC7 /* CCActionGrid.cpp in Sources */, 15AE1ABC19AAD40300C27E9E /* b2PolygonAndCircleContact.cpp in Sources */, + B6CAB3FC1AF9AA1A00B9B856 /* btMultiBodyConstraint.cpp in Sources */, B665E2EB1AA80A6500DDB1C5 /* CCPULinearForceAffectorTranslator.cpp in Sources */, B665E4271AA80A6600DDB1C5 /* CCPUUtil.cpp in Sources */, B665E2BF1AA80A6500DDB1C5 /* CCPUGeometryRotator.cpp in Sources */, 15AE1ADA19AAD41000C27E9E /* b2Rope.cpp in Sources */, + B6CAB2D61AF9AA1A00B9B856 /* btOptimizedBvh.cpp in Sources */, 52B47A301A5349A3004E4C60 /* HttpClient-apple.mm in Sources */, B29A7E1619EE1B7700872B35 /* BoundingBoxAttachment.c in Sources */, B665E2131AA80A6500DDB1C5 /* CCPUBaseForceAffectorTranslator.cpp in Sources */, @@ -8828,14 +11388,21 @@ 382383FF1A258FA7002C4610 /* idl_parser.cpp in Sources */, B665E28F1AA80A6500DDB1C5 /* CCPUDynamicAttributeTranslator.cpp in Sources */, B665E31B1AA80A6500DDB1C5 /* CCPUOnClearObserver.cpp in Sources */, + B6CAB2421AF9AA1A00B9B856 /* btConvexConcaveCollisionAlgorithm.cpp in Sources */, + B6CAB2661AF9AA1A00B9B856 /* btSimulationIslandManager.cpp in Sources */, + B6CAB4001AF9AA1A00B9B856 /* btMultiBodyConstraintSolver.cpp in Sources */, + B6CAB4E01AF9AA1A00B9B856 /* SpuSampleTask.cpp in Sources */, 15AE1B8419AADA9A00C27E9E /* UITextField.cpp in Sources */, 15AE198E19AAD36E00C27E9E /* CheckBoxReader.cpp in Sources */, + B6CAAFE31AF9A9E100B9B856 /* CCPhysics3D.cpp in Sources */, 50ABBE621925AB6F00A911A9 /* CCEventListenerAcceleration.cpp in Sources */, B665E2C71AA80A6500DDB1C5 /* CCPUGravityAffector.cpp in Sources */, B665E2E31AA80A6500DDB1C5 /* CCPULineAffectorTranslator.cpp in Sources */, 15AE1AB619AAD40300C27E9E /* b2ContactSolver.cpp in Sources */, 292DB13E19B4574100A80320 /* UIEditBox.cpp in Sources */, B29A7E0619EE1B7700872B35 /* extension.c in Sources */, + B6CAB3461AF9AA1A00B9B856 /* gim_box_set.cpp in Sources */, + B6CAB3701AF9AA1A00B9B856 /* btGjkConvexCast.cpp in Sources */, 3E6176681960F89B00DE83F5 /* CCController-iOS.mm in Sources */, 15AE18B219AAD33D00C27E9E /* CCBReader.cpp in Sources */, 15AE193C19AAD35100C27E9E /* CCArmatureDefine.cpp in Sources */, @@ -8843,33 +11410,42 @@ B29594B51926D5EC003EEF37 /* CCMeshCommand.cpp in Sources */, 15AE194B19AAD35100C27E9E /* CCComRender.cpp in Sources */, 382384451A25915C002C4610 /* SpriteReader.cpp in Sources */, + B6CAB2321AF9AA1A00B9B856 /* btCollisionWorld.cpp in Sources */, 15AE1ACA19AAD40300C27E9E /* b2MouseJoint.cpp in Sources */, 15AE19AC19AAD39700C27E9E /* LoadingBarReader.cpp in Sources */, 50ABBE7E1925AB6F00A911A9 /* CCEventTouch.cpp in Sources */, 15AE183119AAD2F700C27E9E /* CCOBB.cpp in Sources */, + B6CAB4FC1AF9AA1A00B9B856 /* btConvexHull.cpp in Sources */, B29A7DCA19EE1B7700872B35 /* SlotData.c in Sources */, 15AE18C519AAD33D00C27E9E /* CCLayerLoader.cpp in Sources */, 15AE1BF719AAE01E00C27E9E /* CCControlStepper.cpp in Sources */, 15AE1A3C19AAD3D500C27E9E /* b2CollideCircle.cpp in Sources */, + 501216951AC47393009A4BEA /* CCPass.cpp in Sources */, 50ABBE6E1925AB6F00A911A9 /* CCEventListenerKeyboard.cpp in Sources */, B665E2CB1AA80A6500DDB1C5 /* CCPUGravityAffectorTranslator.cpp in Sources */, 15AE18D719AAD33D00C27E9E /* CCScrollViewLoader.cpp in Sources */, 50CB247C19D9C5A100687767 /* AudioEngine-inl.mm in Sources */, 15AE1AC819AAD40300C27E9E /* b2Joint.cpp in Sources */, 50ABBE461925AB6F00A911A9 /* CCEvent.cpp in Sources */, + B6CAB3B81AF9AA1A00B9B856 /* btGeneric6DofConstraint.cpp in Sources */, 15FB20881AE7C57D00C31518 /* shapes.cc in Sources */, + B6CAB2FE1AF9AA1A00B9B856 /* btTriangleIndexVertexArray.cpp in Sources */, 50ABBEA01925AB6F00A911A9 /* CCScheduler.cpp in Sources */, 15AE1A4119AAD3D500C27E9E /* b2Distance.cpp in Sources */, 50ABBE4E1925AB6F00A911A9 /* CCEventCustom.cpp in Sources */, + B6CAB2761AF9AA1A00B9B856 /* btUnionFind.cpp in Sources */, 15AE1BF519AAE01E00C27E9E /* CCControlSlider.cpp in Sources */, 15AE181719AAD2F700C27E9E /* CCAttachNode.cpp in Sources */, B68779051A8CA82E00643ABF /* CCParticleSystem3D.cpp in Sources */, 15AE18B719AAD33D00C27E9E /* CCBSequenceProperty.cpp in Sources */, B29A7E3819EE1B7700872B35 /* AnimationStateData.c in Sources */, + B6CAB3261AF9AA1A00B9B856 /* btGImpactBvh.cpp in Sources */, 15AE18B919AAD33D00C27E9E /* CCControlButtonLoader.cpp in Sources */, + B6CAB4041AF9AA1A00B9B856 /* btMultiBodyDynamicsWorld.cpp in Sources */, 50ABBE761925AB6F00A911A9 /* CCEventListenerTouch.cpp in Sources */, 15AE1AD219AAD40300C27E9E /* b2RopeJoint.cpp in Sources */, B29A7DCC19EE1B7700872B35 /* Skeleton.c in Sources */, + B6CAB2B41AF9AA1A00B9B856 /* btConvexShape.cpp in Sources */, 15AE1A4919AAD3D500C27E9E /* b2CircleShape.cpp in Sources */, 15AE184119AAD2F700C27E9E /* CCSprite3D.cpp in Sources */, 50ABBE5A1925AB6F00A911A9 /* CCEventKeyboard.cpp in Sources */, @@ -8879,11 +11455,14 @@ 3EACC9A519F5014D00EB3C5E /* CCLight.cpp in Sources */, 15AE1B7A19AADA9A00C27E9E /* UIScrollView.cpp in Sources */, 1A570076180BC5A10088DEC7 /* CCActionGrid3D.cpp in Sources */, + B6CAB38C1AF9AA1A00B9B856 /* btPolyhedralContactClipping.cpp in Sources */, + B6CAB3A41AF9AA1A00B9B856 /* btConeTwistConstraint.cpp in Sources */, 15AE19B219AAD39700C27E9E /* SliderReader.cpp in Sources */, 382383F51A258FA7002C4610 /* idl_gen_cpp.cpp in Sources */, B665E3B71AA80A6500DDB1C5 /* CCPURibbonTrail.cpp in Sources */, B665E1F31AA80A6500DDB1C5 /* CCPUAffector.cpp in Sources */, 15AE1B7E19AADA9A00C27E9E /* UIText.cpp in Sources */, + B6CAB2FA1AF9AA1A00B9B856 /* btTriangleCallback.cpp in Sources */, 15AE1A3E19AAD3D500C27E9E /* b2CollidePolygon.cpp in Sources */, 15AE1AB219AAD40300C27E9E /* b2CircleContact.cpp in Sources */, B29A7E2619EE1B7700872B35 /* Attachment.c in Sources */, @@ -8895,8 +11474,10 @@ 1A57007A180BC5A10088DEC7 /* CCActionInstant.cpp in Sources */, 15AE1AC419AAD40300C27E9E /* b2FrictionJoint.cpp in Sources */, 15AE1BEC19AAE01E00C27E9E /* CCControlColourPicker.cpp in Sources */, + B6CAB2361AF9AA1A00B9B856 /* btCompoundCollisionAlgorithm.cpp in Sources */, 382383FD1A258FA7002C4610 /* idl_gen_text.cpp in Sources */, 3823841B1A2590D2002C4610 /* ComAudioReader.cpp in Sources */, + B6CAB2B01AF9AA1A00B9B856 /* btConvexPolyhedron.cpp in Sources */, 50ABBEC01925AB6F00A911A9 /* CCValue.cpp in Sources */, 50ABBD591925AB0000A911A9 /* Vec2.cpp in Sources */, B665E3CB1AA80A6600DDB1C5 /* CCPUScaleVelocityAffectorTranslator.cpp in Sources */, @@ -8906,9 +11487,11 @@ B665E3BB1AA80A6500DDB1C5 /* CCPURibbonTrailRender.cpp in Sources */, 50ABBE421925AB6F00A911A9 /* CCDirector.cpp in Sources */, 15AE1C0319AAE01E00C27E9E /* CCTableView.cpp in Sources */, + B6CAB5361AF9AA1A00B9B856 /* btVector3.cpp in Sources */, B665E39F1AA80A6500DDB1C5 /* CCPUPositionEmitter.cpp in Sources */, 1A57007E180BC5A10088DEC7 /* CCActionInterval.cpp in Sources */, 15AE1BF319AAE01E00C27E9E /* CCControlSaturationBrightnessPicker.cpp in Sources */, + B6CAB2521AF9AA1A00B9B856 /* btEmptyCollisionAlgorithm.cpp in Sources */, B665E2D31AA80A6500DDB1C5 /* CCPUInterParticleColliderTranslator.cpp in Sources */, B665E3331AA80A6500DDB1C5 /* CCPUOnEmissionObserver.cpp in Sources */, 1A570082180BC5A10088DEC7 /* CCActionManager.cpp in Sources */, @@ -8916,21 +11499,32 @@ 1A570086180BC5A10088DEC7 /* CCActionPageTurn3D.cpp in Sources */, 15AE1AB819AAD40300C27E9E /* b2EdgeAndCircleContact.cpp in Sources */, 1A57008A180BC5A10088DEC7 /* CCActionProgressTimer.cpp in Sources */, + B6CAB5001AF9AA1A00B9B856 /* btConvexHullComputer.cpp in Sources */, B665E3EF1AA80A6600DDB1C5 /* CCPUSlaveBehaviourTranslator.cpp in Sources */, 15AE18AF19AAD33D00C27E9E /* CCBKeyframe.cpp in Sources */, B29A7DE419EE1B7700872B35 /* SkeletonBounds.c in Sources */, + B6CAB4C01AF9AA1A00B9B856 /* SpuLibspe2Support.cpp in Sources */, + B6CAB2861AF9AA1A00B9B856 /* btBvhTriangleMeshShape.cpp in Sources */, 50643BDF19BFCCA400EF68ED /* LocalStorage-android.cpp in Sources */, 50ABBED81925AB6F00A911A9 /* ZipUtils.cpp in Sources */, 15AE1B9219AADA9A00C27E9E /* UIHelper.cpp in Sources */, + B6CAB5441AF9AA1A00B9B856 /* MiniCLTask.cpp in Sources */, + B6CAAFEF1AF9A9E100B9B856 /* CCPhysics3DDebugDrawer.cpp in Sources */, 15AE1AA119AAD40300C27E9E /* b2Body.cpp in Sources */, 15AE1ABA19AAD40300C27E9E /* b2EdgeAndPolygonContact.cpp in Sources */, 15AE181B19AAD2F700C27E9E /* CCBundle3D.cpp in Sources */, + B6CAB3341AF9AA1A00B9B856 /* btGImpactShape.cpp in Sources */, + B6CAB4C61AF9AA1A00B9B856 /* boxBoxDistance.cpp in Sources */, 1A57008E180BC5A10088DEC7 /* CCActionTiledGrid.cpp in Sources */, + B6CAB2A01AF9AA1A00B9B856 /* btConvex2dShape.cpp in Sources */, 1A570092180BC5A10088DEC7 /* CCActionTween.cpp in Sources */, 1A570099180BC5C10088DEC7 /* CCAtlasNode.cpp in Sources */, + B6CAB1F21AF9AA1A00B9B856 /* btCollisionAlgorithm.cpp in Sources */, + B6CAAFF31AF9A9E100B9B856 /* CCPhysics3DObject.cpp in Sources */, B665E2931AA80A6500DDB1C5 /* CCPUEmitter.cpp in Sources */, 50ABBD4D1925AB0000A911A9 /* MathUtil.cpp in Sources */, 50ABBE3E1925AB6F00A911A9 /* CCDataVisitor.cpp in Sources */, + B6CAB4B21AF9AA1A00B9B856 /* SpuContactManifoldCollisionAlgorithm.cpp in Sources */, 1A57009F180BC5D20088DEC7 /* CCNode.cpp in Sources */, 1A57010F180BC8EE0088DEC7 /* CCDrawingPrimitives.cpp in Sources */, B665E3F31AA80A6600DDB1C5 /* CCPUSlaveEmitter.cpp in Sources */, @@ -8940,32 +11534,41 @@ B29A7E0019EE1B7700872B35 /* Json.c in Sources */, 1A570120180BC90D0088DEC7 /* CCGrid.cpp in Sources */, 15AE181119AAD2F700C27E9E /* CCAnimation3D.cpp in Sources */, + B6CAB2201AF9AA1A00B9B856 /* btBoxBoxDetector.cpp in Sources */, 5E9F612B1A3FFE3D0038DE01 /* CCPlane.cpp in Sources */, 1A57019E180BCB590088DEC7 /* CCFont.cpp in Sources */, 15AE1ACC19AAD40300C27E9E /* b2PrismaticJoint.cpp in Sources */, 15AE195F19AAD35100C27E9E /* CCSpriteFrameCacheHelper.cpp in Sources */, 15AE193019AAD35100C27E9E /* CCActionManagerEx.cpp in Sources */, 15B3708119EE414C00ABE682 /* CCEventListenerAssetsManagerEx.cpp in Sources */, + B6CAB3F81AF9AA1A00B9B856 /* btMultiBody.cpp in Sources */, 503DD8E21926736A00CD74DD /* CCCommon-ios.mm in Sources */, 292DB14A19B4574100A80320 /* UIEditBoxImpl-ios.mm in Sources */, + B6CAB2561AF9AA1A00B9B856 /* btGhostObject.cpp in Sources */, 15AE1A9419AAD40300C27E9E /* b2BlockAllocator.cpp in Sources */, B29A7E3C19EE1B7700872B35 /* Animation.c in Sources */, 15AE1A4D19AAD3D500C27E9E /* b2PolygonShape.cpp in Sources */, + B6CAB3D61AF9AA1A00B9B856 /* btSolve2LinearConstraint.cpp in Sources */, + B6CAB30C1AF9AA1A00B9B856 /* btTriangleMeshShape.cpp in Sources */, 1A5701A2180BCB590088DEC7 /* CCFontAtlas.cpp in Sources */, 3E61781D1966A5A300DE83F5 /* CCController.cpp in Sources */, + B6CAB41A1AF9AA1A00B9B856 /* btDantzigLCP.cpp in Sources */, 50ABC00E1926664800A911A9 /* CCFileUtils.cpp in Sources */, 299CF1FC19A434BC00C378C1 /* ccRandom.cpp in Sources */, DA8C62A319E52C6400000516 /* ioapi_mem.cpp in Sources */, 382384371A259126002C4610 /* ProjectNodeReader.cpp in Sources */, 15AE18C919AAD33D00C27E9E /* CCMenuItemLoader.cpp in Sources */, + B6CAB28A1AF9AA1A00B9B856 /* btCapsuleShape.cpp in Sources */, B665E2831AA80A6500DDB1C5 /* CCPUDoStopSystemEventHandler.cpp in Sources */, 50ABBE241925AB6F00A911A9 /* base64.cpp in Sources */, B665E36F1AA80A6500DDB1C5 /* CCPUOnVelocityObserverTranslator.cpp in Sources */, 1A5701A6180BCB590088DEC7 /* CCFontAtlasCache.cpp in Sources */, 15AE192B19AAD35100C27E9E /* TriggerObj.cpp in Sources */, + B6CAAFEB1AF9A9E100B9B856 /* CCPhysics3DConstraint.cpp in Sources */, 4D76BE3B1A4AAF0A00102962 /* CCActionTimelineNode.cpp in Sources */, 15AE198519AAD36400C27E9E /* WidgetReader.cpp in Sources */, B665E36B1AA80A6500DDB1C5 /* CCPUOnVelocityObserver.cpp in Sources */, + B6CAB4E41AF9AA1A00B9B856 /* SpuSampleTaskProcess.cpp in Sources */, B665E3171AA80A6500DDB1C5 /* CCPUObserverTranslator.cpp in Sources */, 15AE1AAA19AAD40300C27E9E /* b2World.cpp in Sources */, B665E2031AA80A6500DDB1C5 /* CCPUAlignAffectorTranslator.cpp in Sources */, @@ -8978,30 +11581,42 @@ 292DB16019B461CA00A80320 /* ExtensionDeprecated.cpp in Sources */, 50ABBEAC1925AB6F00A911A9 /* ccTypes.cpp in Sources */, 15AE196A19AAD35100C27E9E /* DictionaryHelper.cpp in Sources */, + B6CAB3901AF9AA1A00B9B856 /* btRaycastCallback.cpp in Sources */, + B6CAB3CE1AF9AA1A00B9B856 /* btSequentialImpulseConstraintSolver.cpp in Sources */, B665E26B1AA80A6500DDB1C5 /* CCPUDoFreezeEventHandler.cpp in Sources */, 15AE1A3F19AAD3D500C27E9E /* b2Collision.cpp in Sources */, 1A5701BA180BCB5A0088DEC7 /* CCLabel.cpp in Sources */, 15AE18AD19AAD33D00C27E9E /* CCBFileLoader.cpp in Sources */, + B6CAB1F61AF9AA1A00B9B856 /* btDbvt.cpp in Sources */, 15AE18AB19AAD33D00C27E9E /* CCBAnimationManager.cpp in Sources */, 15AE1B7219AADA9A00C27E9E /* UIListView.cpp in Sources */, 1A5701BE180BCB5A0088DEC7 /* CCLabelAtlas.cpp in Sources */, + B6CAB2021AF9AA1A00B9B856 /* btMultiSapBroadphase.cpp in Sources */, 15FB20751AE7BF8600C31518 /* MarchingSquare.cpp in Sources */, 15AE1A3D19AAD3D500C27E9E /* b2CollideEdge.cpp in Sources */, 1A5701C2180BCB5A0088DEC7 /* CCLabelBMFont.cpp in Sources */, 1A087AE91860400400196EF5 /* edtaa3func.cpp in Sources */, B665E33F1AA80A6500DDB1C5 /* CCPUOnEventFlagObserverTranslator.cpp in Sources */, 15AE194219AAD35100C27E9E /* CCColliderDetector.cpp in Sources */, + B6CAB37C1AF9AA1A00B9B856 /* btGjkPairDetector.cpp in Sources */, 15AE1A9919AAD40300C27E9E /* b2Math.cpp in Sources */, + B6CAB2621AF9AA1A00B9B856 /* btManifoldResult.cpp in Sources */, B665E3771AA80A6500DDB1C5 /* CCPUParticleFollowerTranslator.cpp in Sources */, + B6CAB4CA1AF9AA1A00B9B856 /* SpuCollisionShapes.cpp in Sources */, 15AE1B7C19AADA9A00C27E9E /* UISlider.cpp in Sources */, + B6CAAFFB1AF9A9E100B9B856 /* CCPhysics3DWorld.cpp in Sources */, B665E3471AA80A6500DDB1C5 /* CCPUOnExpireObserverTranslator.cpp in Sources */, + B6CAB2A41AF9AA1A00B9B856 /* btConvexHullShape.cpp in Sources */, 15AE1AA519AAD40300C27E9E /* b2Fixture.cpp in Sources */, B29A7DE219EE1B7700872B35 /* MeshAttachment.c in Sources */, B6D38B8F1AC3AFAC00043997 /* CCTextureCube.cpp in Sources */, + B6CAB2C01AF9AA1A00B9B856 /* btEmptyShape.cpp in Sources */, 15AE1BAD19AADFDF00C27E9E /* UILayoutParameter.cpp in Sources */, 3823843E1A259140002C4610 /* SingleNodeReader.cpp in Sources */, + B6CAB2721AF9AA1A00B9B856 /* btSphereTriangleCollisionAlgorithm.cpp in Sources */, B29A7DDE19EE1B7700872B35 /* BoneData.c in Sources */, B665E28B1AA80A6500DDB1C5 /* CCPUDynamicAttribute.cpp in Sources */, + B6CAB5481AF9AA1A00B9B856 /* MiniCLTaskScheduler.cpp in Sources */, 15AE19AA19AAD39700C27E9E /* ListViewReader.cpp in Sources */, 1A5701C8180BCB5A0088DEC7 /* CCLabelTextFormatter.cpp in Sources */, 1A5701CC180BCB5A0088DEC7 /* CCLabelTTF.cpp in Sources */, @@ -9011,6 +11626,7 @@ B665E4171AA80A6600DDB1C5 /* CCPUTextureAnimatorTranslator.cpp in Sources */, 15FB20941AE7C57D00C31518 /* cdt.cc in Sources */, B665E34B1AA80A6500DDB1C5 /* CCPUOnPositionObserver.cpp in Sources */, + B6CAB42A1AF9AA1A00B9B856 /* btRaycastVehicle.cpp in Sources */, 15AE1AD619AAD40300C27E9E /* b2WheelJoint.cpp in Sources */, 299754F5193EC95400A54AC3 /* ObjectFactory.cpp in Sources */, 1A5701DF180BCB8C0088DEC7 /* CCLayer.cpp in Sources */, @@ -9023,6 +11639,7 @@ 18956BB31A9DFBFD006E9155 /* Particle3DReader.cpp in Sources */, 15AE184519AAD2F700C27E9E /* CCSprite3DMaterial.cpp in Sources */, 50ABBD9C1925AB4100A911A9 /* ccGLStateCache.cpp in Sources */, + B6CAB5061AF9AA1A00B9B856 /* btGeometryUtil.cpp in Sources */, B665E25F1AA80A6500DDB1C5 /* CCPUDoEnableComponentEventHandlerTranslator.cpp in Sources */, 1A5701E7180BCB8C0088DEC7 /* CCTransition.cpp in Sources */, 15AE1AC019AAD40300C27E9E /* b2MotorJoint.cpp in Sources */, @@ -9042,7 +11659,9 @@ 382384141A259092002C4610 /* NodeReaderProtocol.cpp in Sources */, 50ABBD511925AB0000A911A9 /* Quaternion.cpp in Sources */, 1A5701FC180BCBAD0088DEC7 /* CCMenuItem.cpp in Sources */, + B6CAB4201AF9AA1A00B9B856 /* btMLCPSolver.cpp in Sources */, B665E2A71AA80A6500DDB1C5 /* CCPUEventHandlerTranslator.cpp in Sources */, + B6CAB4341AF9AA1A00B9B856 /* btGpu3DGridBroadphase.cpp in Sources */, 15AE195119AAD35100C27E9E /* CCDecorativeDisplay.cpp in Sources */, 15AE19BA19AAD39700C27E9E /* TextReader.cpp in Sources */, 50ABBD491925AB0000A911A9 /* Mat4.cpp in Sources */, @@ -9055,8 +11674,10 @@ 15AE197719AAD35700C27E9E /* CCActionTimeline.cpp in Sources */, 15AE19B419AAD39700C27E9E /* TextAtlasReader.cpp in Sources */, B665E2A31AA80A6500DDB1C5 /* CCPUEventHandlerManager.cpp in Sources */, + B6CAB3601AF9AA1A00B9B856 /* gim_tri_collision.cpp in Sources */, 15AE194019AAD35100C27E9E /* CCBone.cpp in Sources */, 1A570215180BCBF40088DEC7 /* CCRenderTexture.cpp in Sources */, + B6CAB2EE1AF9AA1A00B9B856 /* btStridingMeshInterface.cpp in Sources */, 1A570222180BCC1A0088DEC7 /* CCParticleBatchNode.cpp in Sources */, 292DB15019B4574100A80320 /* UIEditBoxImpl-stub.cpp in Sources */, B665E25B1AA80A6500DDB1C5 /* CCPUDoEnableComponentEventHandler.cpp in Sources */, @@ -9064,7 +11685,9 @@ 15AE185F19AAD31200C27E9E /* SimpleAudioEngine.mm in Sources */, B29A7DC819EE1B7700872B35 /* SkeletonRenderer.cpp in Sources */, 15AE1BE819AAE01E00C27E9E /* CCControl.cpp in Sources */, + B6CAB4081AF9AA1A00B9B856 /* btMultiBodyJointLimitConstraint.cpp in Sources */, 1A570226180BCC1A0088DEC7 /* CCParticleExamples.cpp in Sources */, + B6CAB24A1AF9AA1A00B9B856 /* btConvexPlaneCollisionAlgorithm.cpp in Sources */, 15AE194919AAD35100C27E9E /* CCComController.cpp in Sources */, B603F1A91AC8EA0900A9579C /* CCTerrain.cpp in Sources */, B665E3CF1AA80A6600DDB1C5 /* CCPUScriptCompiler.cpp in Sources */, @@ -9073,6 +11696,7 @@ 3EACC9A119F5014D00EB3C5E /* CCCamera.cpp in Sources */, B665E3E71AA80A6600DDB1C5 /* CCPUSineForceAffectorTranslator.cpp in Sources */, 15AE1BBD19AADFF000C27E9E /* SocketIO.cpp in Sources */, + B6CAB1FA1AF9AA1A00B9B856 /* btDbvtBroadphase.cpp in Sources */, 15AE1A4319AAD3D500C27E9E /* b2DynamicTree.cpp in Sources */, 15AE1A3A19AAD3D500C27E9E /* b2BroadPhase.cpp in Sources */, B665E42B1AA80A6600DDB1C5 /* CCPUVelocityMatchingAffector.cpp in Sources */, @@ -9081,6 +11705,7 @@ 15AE1BFD19AAE01E00C27E9E /* CCInvocation.cpp in Sources */, B24AA98A195A675C007B4522 /* CCFastTMXTiledMap.cpp in Sources */, 38F5263F1A48363B000DB7F7 /* ArmatureNodeReader.cpp in Sources */, + B6CAB24E1AF9AA1A00B9B856 /* btDefaultCollisionConfiguration.cpp in Sources */, B665E2AB1AA80A6500DDB1C5 /* CCPUFlockCenteringAffector.cpp in Sources */, B665E3671AA80A6500DDB1C5 /* CCPUOnTimeObserverTranslator.cpp in Sources */, B665E27B1AA80A6500DDB1C5 /* CCPUDoScaleEventHandler.cpp in Sources */, @@ -9091,27 +11716,35 @@ B665E2C31AA80A6500DDB1C5 /* CCPUGeometryRotatorTranslator.cpp in Sources */, B29A7DF219EE1B7700872B35 /* AtlasAttachmentLoader.c in Sources */, 15AE1AC619AAD40300C27E9E /* b2GearJoint.cpp in Sources */, + B6CAB3301AF9AA1A00B9B856 /* btGImpactQuantizedBvh.cpp in Sources */, B24AA986195A675C007B4522 /* CCFastTMXLayer.cpp in Sources */, 1A57022E180BCC1A0088DEC7 /* CCParticleSystemQuad.cpp in Sources */, 50ABBD901925AB4100A911A9 /* CCGLProgramCache.cpp in Sources */, 15AE197F19AAD35700C27E9E /* CCTimeLine.cpp in Sources */, B29A7DD819EE1B7700872B35 /* SkeletonData.c in Sources */, + B6CAB2F61AF9AA1A00B9B856 /* btTriangleBuffer.cpp in Sources */, 1A57027F180BCC900088DEC7 /* CCSprite.cpp in Sources */, + B6CAB1FE1AF9AA1A00B9B856 /* btDispatcher.cpp in Sources */, B665E24F1AA80A6500DDB1C5 /* CCPUColorAffectorTranslator.cpp in Sources */, 15AE194719AAD35100C27E9E /* CCComAudio.cpp in Sources */, 15AE192719AAD35100C27E9E /* TriggerBase.cpp in Sources */, 15AE1B8819AADA9A00C27E9E /* UICheckBox.cpp in Sources */, 15AE1A4B19AAD3D500C27E9E /* b2EdgeShape.cpp in Sources */, + B6CAB3DE1AF9AA1A00B9B856 /* btTypedConstraint.cpp in Sources */, B665E3231AA80A6500DDB1C5 /* CCPUOnCollisionObserver.cpp in Sources */, B665E3271AA80A6500DDB1C5 /* CCPUOnCollisionObserverTranslator.cpp in Sources */, 15AE18B519AAD33D00C27E9E /* CCBSequence.cpp in Sources */, B665E3C31AA80A6600DDB1C5 /* CCPUScaleAffectorTranslator.cpp in Sources */, B665E2631AA80A6500DDB1C5 /* CCPUDoExpireEventHandler.cpp in Sources */, + B6CAB4441AF9AA1A00B9B856 /* btParallelConstraintSolver.cpp in Sources */, B29A7DD619EE1B7700872B35 /* RegionAttachment.c in Sources */, 1A570283180BCC900088DEC7 /* CCSpriteBatchNode.cpp in Sources */, + B6CAB23A1AF9AA1A00B9B856 /* btCompoundCompoundCollisionAlgorithm.cpp in Sources */, B665E2F71AA80A6500DDB1C5 /* CCPUListener.cpp in Sources */, 1A570287180BCC900088DEC7 /* CCSpriteFrame.cpp in Sources */, + B6CAB3AA1AF9AA1A00B9B856 /* btContactConstraint.cpp in Sources */, B665E2431AA80A6500DDB1C5 /* CCPUCollisionAvoidanceAffector.cpp in Sources */, + B6CAB23E1AF9AA1A00B9B856 /* btConvex2dConvex2dAlgorithm.cpp in Sources */, B665E3EB1AA80A6600DDB1C5 /* CCPUSlaveBehaviour.cpp in Sources */, B665E2771AA80A6500DDB1C5 /* CCPUDoPlacementParticleEventHandlerTranslator.cpp in Sources */, 15AE193E19AAD35100C27E9E /* CCBatchNode.cpp in Sources */, @@ -9131,12 +11764,14 @@ 50ABBE321925AB6F00A911A9 /* CCConfiguration.cpp in Sources */, 15AE1A9F19AAD40300C27E9E /* b2Timer.cpp in Sources */, 15AE1AD419AAD40300C27E9E /* b2WeldJoint.cpp in Sources */, + B6CAB2181AF9AA1A00B9B856 /* btBox2dBox2dCollisionAlgorithm.cpp in Sources */, 1A5702C9180BCE370088DEC7 /* CCTextFieldTTF.cpp in Sources */, 15AE1C1719AAE2C700C27E9E /* CCPhysicsSprite.cpp in Sources */, 1A5702EB180BCE750088DEC7 /* CCTileMapAtlas.cpp in Sources */, B665E4131AA80A6600DDB1C5 /* CCPUTextureAnimator.cpp in Sources */, 1A5702EF180BCE750088DEC7 /* CCTMXLayer.cpp in Sources */, 15AE1BA519AADFDF00C27E9E /* UIHBox.cpp in Sources */, + B6CAB3741AF9AA1A00B9B856 /* btGjkEpa2.cpp in Sources */, B665E3DB1AA80A6600DDB1C5 /* CCPUScriptTranslator.cpp in Sources */, B665E33B1AA80A6500DDB1C5 /* CCPUOnEventFlagObserver.cpp in Sources */, 1A5702F3180BCE750088DEC7 /* CCTMXObjectGroup.cpp in Sources */, @@ -9147,26 +11782,35 @@ 50ABBD3D1925AB0000A911A9 /* CCGeometry.cpp in Sources */, B665E30B1AA80A6500DDB1C5 /* CCPUNoise.cpp in Sources */, B665E26F1AA80A6500DDB1C5 /* CCPUDoFreezeEventHandlerTranslator.cpp in Sources */, + B6CAB51A1AF9AA1A00B9B856 /* btPolarDecomposition.cpp in Sources */, 15AE18D919AAD33D00C27E9E /* CCSpriteLoader.cpp in Sources */, 50ABBECC1925AB6F00A911A9 /* s3tc.cpp in Sources */, 15AE1B7819AADA9A00C27E9E /* UIRichText.cpp in Sources */, B29A7E3019EE1B7700872B35 /* SkeletonAnimation.cpp in Sources */, 15AE195D19AAD35100C27E9E /* CCSkin.cpp in Sources */, B665E2DB1AA80A6500DDB1C5 /* CCPUJetAffectorTranslator.cpp in Sources */, + B6CAB25A1AF9AA1A00B9B856 /* btHashedSimplePairCache.cpp in Sources */, + B6CAB2E61AF9AA1A00B9B856 /* btSphereShape.cpp in Sources */, + B6CAB2B81AF9AA1A00B9B856 /* btConvexTriangleMeshShape.cpp in Sources */, + B6CAB27A1AF9AA1A00B9B856 /* SphereTriangleDetector.cpp in Sources */, 1A5702F7180BCE750088DEC7 /* CCTMXTiledMap.cpp in Sources */, 50ABBEC61925AB6F00A911A9 /* etc1.cpp in Sources */, 50ABBE8C1925AB6F00A911A9 /* CCNS.cpp in Sources */, B29A7DE019EE1B7700872B35 /* IkConstraintData.c in Sources */, + B6CAB40C1AF9AA1A00B9B856 /* btMultiBodyJointMotor.cpp in Sources */, + B6CAB2D21AF9AA1A00B9B856 /* btMultiSphereShape.cpp in Sources */, B29A7DFC19EE1B7700872B35 /* spine-cocos2dx.cpp in Sources */, D0FD03501A3B51AA00825BB5 /* CCAllocatorGlobal.cpp in Sources */, B665E2231AA80A6500DDB1C5 /* CCPUBehaviourTranslator.cpp in Sources */, B665E3D71AA80A6600DDB1C5 /* CCPUScriptParser.cpp in Sources */, B665E2331AA80A6500DDB1C5 /* CCPUBoxEmitter.cpp in Sources */, 15AE1BA919AADFDF00C27E9E /* UIVBox.cpp in Sources */, + B6CAB3021AF9AA1A00B9B856 /* btTriangleIndexVertexMaterialArray.cpp in Sources */, 50ABBDAE1925AB4100A911A9 /* CCRenderer.cpp in Sources */, B665E3AF1AA80A6500DDB1C5 /* CCPURender.cpp in Sources */, 382383FB1A258FA7002C4610 /* idl_gen_go.cpp in Sources */, B665E2EF1AA80A6500DDB1C5 /* CCPULineEmitter.cpp in Sources */, + B6CAB2EA1AF9AA1A00B9B856 /* btStaticPlaneShape.cpp in Sources */, 38D9629E1ACA9721007C6FAF /* CocoStudio.cpp in Sources */, 50ABBDBA1925AB4100A911A9 /* CCTextureAtlas.cpp in Sources */, 1A5702FB180BCE750088DEC7 /* CCTMXXMLParser.cpp in Sources */, @@ -9174,8 +11818,10 @@ 1A570301180BCE890088DEC7 /* CCParallaxNode.cpp in Sources */, B665E1FF1AA80A6500DDB1C5 /* CCPUAlignAffector.cpp in Sources */, 15AE1A4519AAD3D500C27E9E /* b2TimeOfImpact.cpp in Sources */, + B6CAB3681AF9AA1A00B9B856 /* btConvexCast.cpp in Sources */, 1A57030D180BCF190088DEC7 /* CCComponent.cpp in Sources */, 15AE1B8F19AADA9A00C27E9E /* UIDeprecated.cpp in Sources */, + B6CAB2BC1AF9AA1A00B9B856 /* btCylinderShape.cpp in Sources */, 464AD6E6197EBB1400E502D8 /* pvr.cpp in Sources */, 5E9F61271A3FFE3D0038DE01 /* CCFrustum.cpp in Sources */, B665E22B1AA80A6500DDB1C5 /* CCPUBoxCollider.cpp in Sources */, @@ -9188,7 +11834,9 @@ 15AE195319AAD35100C27E9E /* CCDisplayFactory.cpp in Sources */, 182C5CD71A98F30500C30D34 /* Sprite3DReader.cpp in Sources */, 50ABC0061926664800A911A9 /* CCThread-apple.mm in Sources */, + B6CAB4B81AF9AA1A00B9B856 /* SpuFakeDma.cpp in Sources */, 50ABBEB61925AB6F00A911A9 /* CCUserDefault-android.cpp in Sources */, + B6CAB4481AF9AA1A00B9B856 /* btThreadSupportInterface.cpp in Sources */, 1A57034C180BD09B0088DEC7 /* tinyxml2.cpp in Sources */, 50ABBDB61925AB4100A911A9 /* CCTexture2D.cpp in Sources */, B665E2871AA80A6500DDB1C5 /* CCPUDoStopSystemEventHandlerTranslator.cpp in Sources */, @@ -9203,43 +11851,65 @@ 382384101A259092002C4610 /* NodeReaderDefine.cpp in Sources */, 15AE195B19AAD35100C27E9E /* CCSGUIReader.cpp in Sources */, 50ABBD881925AB4100A911A9 /* CCCustomCommand.cpp in Sources */, + B6CAB4301AF9AA1A00B9B856 /* btWheelInfo.cpp in Sources */, 15AE19B019AAD39700C27E9E /* ScrollViewReader.cpp in Sources */, 50ABBE941925AB6F00A911A9 /* CCProfiling.cpp in Sources */, + 5012169B1AC473A3009A4BEA /* CCTechnique.cpp in Sources */, 15AE182D19AAD2F700C27E9E /* CCMeshVertexIndexData.cpp in Sources */, 50ABBE5E1925AB6F00A911A9 /* CCEventListener.cpp in Sources */, + 5012168F1AC47380009A4BEA /* CCRenderState.cpp in Sources */, 15AE1BC719AAE00000C27E9E /* AssetsManager.cpp in Sources */, + B6CAB3861AF9AA1A00B9B856 /* btPersistentManifold.cpp in Sources */, 50ABBEA81925AB6F00A911A9 /* CCTouch.cpp in Sources */, B29A7DEE19EE1B7700872B35 /* IkConstraint.c in Sources */, + B6CAB3781AF9AA1A00B9B856 /* btGjkEpaPenetrationDepthSolver.cpp in Sources */, B665E37F1AA80A6500DDB1C5 /* CCPUParticleSystem3DTranslator.cpp in Sources */, 15AE1A9619AAD40300C27E9E /* b2Draw.cpp in Sources */, 503DD8E91926736A00CD74DD /* CCES2Renderer-ios.m in Sources */, 5027253D190BF1B900AAF4ED /* cocos2d.cpp in Sources */, B29A7E0819EE1B7700872B35 /* SkinnedMeshAttachment.c in Sources */, + B6CAB3F61AF9AA1A00B9B856 /* Bullet-C-API.cpp in Sources */, + B6CAB2AC1AF9AA1A00B9B856 /* btConvexPointCloudShape.cpp in Sources */, + B6CAB22C1AF9AA1A00B9B856 /* btCollisionObject.cpp in Sources */, 15AE183919AAD2F700C27E9E /* CCRay.cpp in Sources */, 15FB206B1AE7BE7400C31518 /* SpritePolygon.cpp in Sources */, 15AE1B8219AADA9A00C27E9E /* UITextBMFont.cpp in Sources */, + B6CAB29C1AF9AA1A00B9B856 /* btConeShape.cpp in Sources */, 50ABBE6A1925AB6F00A911A9 /* CCEventListenerFocus.cpp in Sources */, + B6CAB3201AF9AA1A00B9B856 /* btGenericPoolAllocator.cpp in Sources */, 50ABBE661925AB6F00A911A9 /* CCEventListenerCustom.cpp in Sources */, 503DD8F81926B0DB00CD74DD /* CCIMEDispatcher.cpp in Sources */, 50ABBDB21925AB4100A911A9 /* ccShaders.cpp in Sources */, 50ABBD451925AB0000A911A9 /* CCVertex.cpp in Sources */, 50ABBEB01925AB6F00A911A9 /* CCUserDefault.cpp in Sources */, + B6CAB3E21AF9AA1A00B9B856 /* btUniversalConstraint.cpp in Sources */, 50ABBE521925AB6F00A911A9 /* CCEventDispatcher.cpp in Sources */, + B6CAB3821AF9AA1A00B9B856 /* btMinkowskiPenetrationDepthSolver.cpp in Sources */, + B6CAB3641AF9AA1A00B9B856 /* btContinuousConvexCollision.cpp in Sources */, 52B47A2F1A5349A3004E4C60 /* HttpAsynConnection.m in Sources */, B665E23B1AA80A6500DDB1C5 /* CCPUCircleEmitter.cpp in Sources */, 15AE1B8019AADA9A00C27E9E /* UITextAtlas.cpp in Sources */, 15AE195919AAD35100C27E9E /* CCProcessBase.cpp in Sources */, B665E3FF1AA80A6600DDB1C5 /* CCPUSphereCollider.cpp in Sources */, 15AE18D319AAD33D00C27E9E /* CCParticleSystemQuadLoader.cpp in Sources */, + B6CAB4CE1AF9AA1A00B9B856 /* SpuContactResult.cpp in Sources */, + B6CAB3C41AF9AA1A00B9B856 /* btHingeConstraint.cpp in Sources */, + B6CAB52C1AF9AA1A00B9B856 /* btSerializer.cpp in Sources */, B665E2371AA80A6500DDB1C5 /* CCPUBoxEmitterTranslator.cpp in Sources */, 15AE196319AAD35100C27E9E /* CCTransformHelp.cpp in Sources */, + B6CAB34C1AF9AA1A00B9B856 /* gim_contact.cpp in Sources */, 15AE19A819AAD39700C27E9E /* LayoutReader.cpp in Sources */, 1A01C68B18F57BE800EFE3A6 /* CCDeprecated.cpp in Sources */, 15AE195719AAD35100C27E9E /* CCInputDelegate.cpp in Sources */, + B6CAB32A1AF9AA1A00B9B856 /* btGImpactCollisionAlgorithm.cpp in Sources */, 15AE1B8A19AADA9A00C27E9E /* UIImageView.cpp in Sources */, 50ABBD391925AB0000A911A9 /* CCAffineTransform.cpp in Sources */, + B6CAB5421AF9AA1A00B9B856 /* MiniCL.cpp in Sources */, + B6CAB4AE1AF9AA1A00B9B856 /* SpuCollisionTaskProcess.cpp in Sources */, B665E3831AA80A6500DDB1C5 /* CCPUPathFollower.cpp in Sources */, 15AE1C1519AAE2C700C27E9E /* CCPhysicsDebugNode.cpp in Sources */, + B6CAB31C1AF9AA1A00B9B856 /* btContactProcessing.cpp in Sources */, + B6CAB4141AF9AA1A00B9B856 /* btMultiBodyPoint2Point.cpp in Sources */, 50ABBD841925AB4100A911A9 /* CCBatchCommand.cpp in Sources */, B665E2171AA80A6500DDB1C5 /* CCPUBeamRender.cpp in Sources */, 50ABBDA81925AB4100A911A9 /* CCRenderCommand.cpp in Sources */, @@ -9250,7 +11920,10 @@ B665E20F1AA80A6500DDB1C5 /* CCPUBaseForceAffector.cpp in Sources */, 15AE1B7419AADA9A00C27E9E /* UILoadingBar.cpp in Sources */, 50ABBEA41925AB6F00A911A9 /* CCScriptSupport.cpp in Sources */, + B6CAB3E81AF9AA1A00B9B856 /* btDiscreteDynamicsWorld.cpp in Sources */, + 501216A11AC473AD009A4BEA /* CCMaterial.cpp in Sources */, B665E3971AA80A6500DDB1C5 /* CCPUPointEmitter.cpp in Sources */, + B6CAB1E81AF9AA1A00B9B856 /* btAxisSweep3.cpp in Sources */, B29A7DD219EE1B7700872B35 /* Skin.c in Sources */, 3E6176761960F89B00DE83F5 /* CCEventListenerController.cpp in Sources */, 15AE1AC219AAD40300C27E9E /* b2DistanceJoint.cpp in Sources */, @@ -9260,12 +11933,16 @@ 52B47A311A5349A3004E4C60 /* HttpCookie.cpp in Sources */, 15B3707919EE414C00ABE682 /* AssetsManagerEx.cpp in Sources */, 50ABBDA41925AB4100A911A9 /* CCQuadCommand.cpp in Sources */, + B6CAB2981AF9AA1A00B9B856 /* btConcaveShape.cpp in Sources */, 15AE18C319AAD33D00C27E9E /* CCLayerGradientLoader.cpp in Sources */, + B6CAB2CE1AF9AA1A00B9B856 /* btMultimaterialTriangleMeshShape.cpp in Sources */, 15AE197919AAD35700C27E9E /* CCActionTimelineCache.cpp in Sources */, 1AAF5850180E40B9000584C8 /* LocalStorage.cpp in Sources */, 50ED2BE519BEAF7900A0AB90 /* UIEditBoxImpl-win32.cpp in Sources */, 15AE192E19AAD35100C27E9E /* CCActionFrameEasing.cpp in Sources */, + B6CAB2281AF9AA1A00B9B856 /* btCollisionDispatcher.cpp in Sources */, B665E3531AA80A6500DDB1C5 /* CCPUOnQuotaObserver.cpp in Sources */, + B6CAB4DA1AF9AA1A00B9B856 /* SpuMinkowskiPenetrationDepthSolver.cpp in Sources */, B665E29F1AA80A6500DDB1C5 /* CCPUEventHandler.cpp in Sources */, 15AE195519AAD35100C27E9E /* CCDisplayManager.cpp in Sources */, B665E43B1AA80A6600DDB1C5 /* CCPUVortexAffectorTranslator.cpp in Sources */, @@ -9273,6 +11950,7 @@ 15AE1BA719AADFDF00C27E9E /* UIRelativeBox.cpp in Sources */, 15AE1ACE19AAD40300C27E9E /* b2PulleyJoint.cpp in Sources */, B665E2DF1AA80A6500DDB1C5 /* CCPULineAffector.cpp in Sources */, + B6CAB2E21AF9AA1A00B9B856 /* btShapeHull.cpp in Sources */, 1A9DCA28180E6955007A3AD4 /* CCGLBufferedNode.cpp in Sources */, 15AE1BF919AAE01E00C27E9E /* CCControlSwitch.cpp in Sources */, B665E3FB1AA80A6600DDB1C5 /* CCPUSphere.cpp in Sources */, @@ -9280,46 +11958,60 @@ B665E20B1AA80A6500DDB1C5 /* CCPUBaseColliderTranslator.cpp in Sources */, B665E3D31AA80A6600DDB1C5 /* CCPUScriptLexer.cpp in Sources */, 50ABBE201925AB6F00A911A9 /* atitc.cpp in Sources */, + B6CAB2101AF9AA1A00B9B856 /* btSimpleBroadphase.cpp in Sources */, B665E3131AA80A6500DDB1C5 /* CCPUObserverManager.cpp in Sources */, 50CB248019D9C5A100687767 /* AudioPlayer.mm in Sources */, 50ABBE9A1925AB6F00A911A9 /* CCRef.cpp in Sources */, 15AE18BF19AAD33D00C27E9E /* CCLabelTTFLoader.cpp in Sources */, + B6CAB27E1AF9AA1A00B9B856 /* btBox2dShape.cpp in Sources */, 15AE1B9519AADA9A00C27E9E /* CocosGUI.cpp in Sources */, B665E2BB1AA80A6500DDB1C5 /* CCPUForceFieldAffectorTranslator.cpp in Sources */, 15AE180919AAD2F700C27E9E /* CCAABB.cpp in Sources */, 15AE1AA719AAD40300C27E9E /* b2Island.cpp in Sources */, B665E23F1AA80A6500DDB1C5 /* CCPUCircleEmitterTranslator.cpp in Sources */, + B6CAB3A01AF9AA1A00B9B856 /* btKinematicCharacterController.cpp in Sources */, 3E6176741960F89B00DE83F5 /* CCEventController.cpp in Sources */, 182C5CB41A95964C00C30D34 /* Node3DReader.cpp in Sources */, B63990CD1A490AFE00B07923 /* CCAsyncTaskPool.cpp in Sources */, 50ABBE361925AB6F00A911A9 /* CCConsole.cpp in Sources */, B29A7E1419EE1B7700872B35 /* Bone.c in Sources */, + B6CAB4F01AF9AA1A00B9B856 /* Win32ThreadSupport.cpp in Sources */, B665E4371AA80A6600DDB1C5 /* CCPUVortexAffector.cpp in Sources */, B665E2F31AA80A6500DDB1C5 /* CCPULineEmitterTranslator.cpp in Sources */, B665E3731AA80A6500DDB1C5 /* CCPUParticleFollower.cpp in Sources */, B665E41F1AA80A6600DDB1C5 /* CCPUTextureRotatorTranslator.cpp in Sources */, 503DD8E51926736A00CD74DD /* CCDirectorCaller-ios.mm in Sources */, B665E2571AA80A6500DDB1C5 /* CCPUDoAffectorEventHandlerTranslator.cpp in Sources */, + B6CAAFF71AF9A9E100B9B856 /* CCPhysics3DShape.cpp in Sources */, 15AE194519AAD35100C27E9E /* CCComAttribute.cpp in Sources */, 15AE18CC19AAD33D00C27E9E /* CCNode+CCBRelativePositioning.cpp in Sources */, 50CB247819D9C5A100687767 /* AudioCache.mm in Sources */, B665E4231AA80A6600DDB1C5 /* CCPUTranslateManager.cpp in Sources */, + B6CAB3081AF9AA1A00B9B856 /* btTriangleMesh.cpp in Sources */, 50ABBD5D1925AB0000A911A9 /* Vec3.cpp in Sources */, + B6CAB2061AF9AA1A00B9B856 /* btOverlappingPairCache.cpp in Sources */, 38B8E2D619E66581002D7CE7 /* CSLoader.cpp in Sources */, B665E3B31AA80A6500DDB1C5 /* CCPURendererTranslator.cpp in Sources */, + B6CAAFE71AF9A9E100B9B856 /* CCPhysics3DComponent.cpp in Sources */, + B6CAB2141AF9AA1A00B9B856 /* btActivatingCollisionAlgorithm.cpp in Sources */, + B6CAB26A1AF9AA1A00B9B856 /* btSphereBoxCollisionAlgorithm.cpp in Sources */, 50ABC0121926664800A911A9 /* CCGLView.cpp in Sources */, + B6CAB3EE1AF9AA1A00B9B856 /* btRigidBody.cpp in Sources */, B665E3871AA80A6500DDB1C5 /* CCPUPathFollowerTranslator.cpp in Sources */, B665E27F1AA80A6500DDB1C5 /* CCPUDoScaleEventHandlerTranslator.cpp in Sources */, 50ABC0021926664800A911A9 /* CCLock-apple.cpp in Sources */, + B6CAB33A1AF9AA1A00B9B856 /* btTriangleShapeEx.cpp in Sources */, 50ABBEBC1925AB6F00A911A9 /* ccUtils.cpp in Sources */, 15AE1A4719AAD3D500C27E9E /* b2ChainShape.cpp in Sources */, 50ABBE721925AB6F00A911A9 /* CCEventListenerMouse.cpp in Sources */, + B6CAB3B41AF9AA1A00B9B856 /* btGearConstraint.cpp in Sources */, B665E41B1AA80A6600DDB1C5 /* CCPUTextureRotator.cpp in Sources */, B665E2971AA80A6500DDB1C5 /* CCPUEmitterManager.cpp in Sources */, 50ABC0001926664800A911A9 /* CCFileUtils-apple.mm in Sources */, 50ABBEB81925AB6F00A911A9 /* ccUTF8.cpp in Sources */, 15AE194F19AAD35100C27E9E /* CCDatas.cpp in Sources */, 50ABBE841925AB6F00A911A9 /* ccFPSImages.c in Sources */, + B6CAB2C41AF9AA1A00B9B856 /* btHeightfieldTerrainShape.cpp in Sources */, 50ABBE4A1925AB6F00A911A9 /* CCEventAcceleration.cpp in Sources */, 15AE1AA319AAD40300C27E9E /* b2ContactManager.cpp in Sources */, B665E3A31AA80A6500DDB1C5 /* CCPUPositionEmitterTranslator.cpp in Sources */, @@ -9330,6 +12022,7 @@ B665E31F1AA80A6500DDB1C5 /* CCPUOnClearObserverTranslator.cpp in Sources */, B665E4331AA80A6600DDB1C5 /* CCPUVertexEmitter.cpp in Sources */, B665E3C71AA80A6600DDB1C5 /* CCPUScaleVelocityAffector.cpp in Sources */, + B6CAB26E1AF9AA1A00B9B856 /* btSphereSphereCollisionAlgorithm.cpp in Sources */, 50ABBED01925AB6F00A911A9 /* TGAlib.cpp in Sources */, 1A01C68518F57BE800EFE3A6 /* CCArray.cpp in Sources */, B665E2AF1AA80A6500DDB1C5 /* CCPUFlockCenteringAffectorTranslator.cpp in Sources */, @@ -9339,16 +12032,22 @@ B29A7DDC19EE1B7700872B35 /* Event.c in Sources */, 50ABBEB41925AB6F00A911A9 /* CCUserDefault-apple.mm in Sources */, 1A1645B1191B726C008C7C7F /* ConvertUTF.c in Sources */, + B6CAB2F21AF9AA1A00B9B856 /* btTetrahedronShape.cpp in Sources */, B665E2FF1AA80A6500DDB1C5 /* CCPUMaterialTranslator.cpp in Sources */, 50ABBE3A1925AB6F00A911A9 /* CCData.cpp in Sources */, + B6CAB3121AF9AA1A00B9B856 /* btUniformScalingShape.cpp in Sources */, 1A1645B3191B726C008C7C7F /* ConvertUTFWrapper.cpp in Sources */, 15B3708519EE414C00ABE682 /* Downloader.cpp in Sources */, 1ABA68AF1888D700007D1BB4 /* CCFontCharMap.cpp in Sources */, + B6CAB2DE1AF9AA1A00B9B856 /* btScaledBvhTriangleMeshShape.cpp in Sources */, 15AE180D19AAD2F700C27E9E /* CCAnimate3D.cpp in Sources */, + B6CAB1EE1AF9AA1A00B9B856 /* btBroadphaseProxy.cpp in Sources */, 50ABBE7A1925AB6F00A911A9 /* CCEventMouse.cpp in Sources */, B665E3BF1AA80A6500DDB1C5 /* CCPUScaleAffector.cpp in Sources */, 15EFA212198A2BB5000C57D3 /* CCProtectedNode.cpp in Sources */, 50ABBD981925AB4100A911A9 /* CCGLProgramStateCache.cpp in Sources */, + B6CAB4A61AF9AA1A00B9B856 /* SequentialThreadSupport.cpp in Sources */, + B6CAB25E1AF9AA1A00B9B856 /* btInternalEdgeUtility.cpp in Sources */, B665E3631AA80A6500DDB1C5 /* CCPUOnTimeObserver.cpp in Sources */, 15AE1BBF19AADFF000C27E9E /* WebSocket.cpp in Sources */, ); @@ -9373,6 +12072,7 @@ "COCOS2D_DEBUG=1", USE_FILE32API, "CC_ENABLE_CHIPMUNK_INTEGRATION=1", + "CC_ENABLE_BULLET_INTEGRATION=1", ); GCC_SYMBOLS_PRIVATE_EXTERN = YES; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; @@ -9407,6 +12107,7 @@ "CC_ENABLE_CHIPMUNK_INTEGRATION=1", NDEBUG, USE_FILE32API, + "CC_ENABLE_BULLET_INTEGRATION=1", ); GCC_SYMBOLS_PRIVATE_EXTERN = YES; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; diff --git a/build/cocos2d_tests.xcodeproj/project.pbxproj b/build/cocos2d_tests.xcodeproj/project.pbxproj index 397a8d5bf9..0911ac3177 100644 --- a/build/cocos2d_tests.xcodeproj/project.pbxproj +++ b/build/cocos2d_tests.xcodeproj/project.pbxproj @@ -100,9 +100,7 @@ 15EFA68D198B3AD8000C57D3 /* libluacocos2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15EFA665198B33EE000C57D3 /* libluacocos2d iOS.a */; }; 182C5CBA1A95B2FD00C30D34 /* CocosStudio3DTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 182C5CB81A95B2FD00C30D34 /* CocosStudio3DTest.cpp */; }; 182C5CBB1A95B30500C30D34 /* CocosStudio3DTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 182C5CB81A95B2FD00C30D34 /* CocosStudio3DTest.cpp */; }; - 182C5CCD1A95D9BA00C30D34 /* src in Resources */ = {isa = PBXBuildFile; fileRef = 182C5CCC1A95D9BA00C30D34 /* src */; }; 182C5CCE1A95D9BA00C30D34 /* src in Resources */ = {isa = PBXBuildFile; fileRef = 182C5CCC1A95D9BA00C30D34 /* src */; }; - 182C5CCF1A95D9BA00C30D34 /* src in Resources */ = {isa = PBXBuildFile; fileRef = 182C5CCC1A95D9BA00C30D34 /* src */; }; 182C5CD01A95D9BA00C30D34 /* src in Resources */ = {isa = PBXBuildFile; fileRef = 182C5CCC1A95D9BA00C30D34 /* src */; }; 1A0EE2A218CDF6DA004CD58F /* libcocos2d Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB01807A4F9005B8026 /* libcocos2d Mac.a */; }; 1A0EE2A518CDF6DA004CD58F /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDCC747E17C455FD007B692C /* IOKit.framework */; }; @@ -784,6 +782,10 @@ 3EA0FB5E191B92F100B170C8 /* cocosvideo.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 3EA0FB5D191B92F100B170C8 /* cocosvideo.mp4 */; }; 3EA0FB66191B933000B170C8 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3EA0FB65191B933000B170C8 /* MediaPlayer.framework */; }; 3EA0FB72191C844400B170C8 /* UIVideoPlayerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EA0FB70191C844400B170C8 /* UIVideoPlayerTest.cpp */; }; + 5046AB4A1AF2A8D80060550B /* MaterialSystemTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5046AB481AF2A8D80060550B /* MaterialSystemTest.cpp */; }; + 5046AB4B1AF2A8D80060550B /* MaterialSystemTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5046AB481AF2A8D80060550B /* MaterialSystemTest.cpp */; }; + 5046AB5B1AF2C4180060550B /* Materials in Resources */ = {isa = PBXBuildFile; fileRef = 5046AB5A1AF2C4180060550B /* Materials */; }; + 5046AB5C1AF2C4180060550B /* Materials in Resources */ = {isa = PBXBuildFile; fileRef = 5046AB5A1AF2C4180060550B /* Materials */; }; 527B1F3019EF9819000A1F82 /* Default-667h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 527B1F2E19EF9819000A1F82 /* Default-667h@2x.png */; }; 527B1F3119EF9819000A1F82 /* Default-736h@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 527B1F2F19EF9819000A1F82 /* Default-736h@3x.png */; }; 527B1F3419EF9CF8000A1F82 /* Default-667h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 527B1F3219EF9CF8000A1F82 /* Default-667h@2x.png */; }; @@ -836,6 +838,8 @@ B63993321A49359F00B07923 /* Particle3D in Resources */ = {isa = PBXBuildFile; fileRef = B63993301A49359F00B07923 /* Particle3D */; }; B6C039D919C95D83007207DC /* LightTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6C039D719C95D83007207DC /* LightTest.cpp */; }; B6C039DA19C95D83007207DC /* LightTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6C039D719C95D83007207DC /* LightTest.cpp */; }; + B6CAB54E1AF9AA6C00B9B856 /* Physics3DTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB54C1AF9AA6C00B9B856 /* Physics3DTest.cpp */; }; + B6CAB54F1AF9AA6C00B9B856 /* Physics3DTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6CAB54C1AF9AA6C00B9B856 /* Physics3DTest.cpp */; }; C04F935A1941B05400E9FEAB /* TileMapTest2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C04F93581941B05400E9FEAB /* TileMapTest2.cpp */; }; C04F935B1941B05400E9FEAB /* TileMapTest2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C04F93581941B05400E9FEAB /* TileMapTest2.cpp */; }; C08689C118D370C90093E810 /* background.caf in Resources */ = {isa = PBXBuildFile; fileRef = C08689C018D370C90093E810 /* background.caf */; }; @@ -1735,6 +1739,9 @@ 3EA0FB70191C844400B170C8 /* UIVideoPlayerTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIVideoPlayerTest.cpp; sourceTree = ""; }; 3EA0FB71191C844400B170C8 /* UIVideoPlayerTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIVideoPlayerTest.h; sourceTree = ""; }; 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = cocos2d_libs.xcodeproj; sourceTree = ""; }; + 5046AB481AF2A8D80060550B /* MaterialSystemTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MaterialSystemTest.cpp; sourceTree = ""; }; + 5046AB491AF2A8D80060550B /* MaterialSystemTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MaterialSystemTest.h; sourceTree = ""; }; + 5046AB5A1AF2C4180060550B /* Materials */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Materials; path = "../tests/cpp-tests/Resources/Materials"; sourceTree = ""; }; 527B1F2E19EF9819000A1F82 /* Default-667h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-667h@2x.png"; sourceTree = ""; }; 527B1F2F19EF9819000A1F82 /* Default-736h@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-736h@3x.png"; sourceTree = ""; }; 527B1F3219EF9CF8000A1F82 /* Default-667h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-667h@2x.png"; sourceTree = ""; }; @@ -1780,6 +1787,8 @@ B63993301A49359F00B07923 /* Particle3D */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Particle3D; path = "../tests/cpp-tests/Resources/Particle3D"; sourceTree = ""; }; B6C039D719C95D83007207DC /* LightTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LightTest.cpp; path = LightTest/LightTest.cpp; sourceTree = ""; }; B6C039D819C95D83007207DC /* LightTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LightTest.h; path = LightTest/LightTest.h; sourceTree = ""; }; + B6CAB54C1AF9AA6C00B9B856 /* Physics3DTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Physics3DTest.cpp; path = Physics3DTest/Physics3DTest.cpp; sourceTree = ""; }; + B6CAB54D1AF9AA6C00B9B856 /* Physics3DTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Physics3DTest.h; path = Physics3DTest/Physics3DTest.h; sourceTree = ""; }; C04F93581941B05400E9FEAB /* TileMapTest2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TileMapTest2.cpp; sourceTree = ""; }; C04F93591941B05400E9FEAB /* TileMapTest2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TileMapTest2.h; sourceTree = ""; }; C08689C018D370C90093E810 /* background.caf */ = {isa = PBXFileReference; lastKnownFileType = file; name = background.caf; path = "../tests/cpp-tests/Resources/background.caf"; sourceTree = ""; }; @@ -2198,6 +2207,8 @@ 1AC3592418CECF0A00F37B72 /* Classes */ = { isa = PBXGroup; children = ( + B6CAB54B1AF9AA4B00B9B856 /* Physics3DTest */, + 5046AB471AF2A8D80060550B /* MaterialSystemTest */, 6886696E1AE8E8A000C2CFD9 /* SpritePolygonTest */, B603F1AC1AC8EA2E00A9579C /* TerrainTest */, 182C5CB71A95B28A00C30D34 /* CocosStudio3DTest */, @@ -3238,6 +3249,7 @@ 1AC35CA818CED83500F37B72 /* Resources */ = { isa = PBXGroup; children = ( + 5046AB5A1AF2C4180060550B /* Materials */, B603F1B31AC8FBFB00A9579C /* TerrainTest */, B63993301A49359F00B07923 /* Particle3D */, 15B3709219EE5D1000ABE682 /* Manifests */, @@ -3965,6 +3977,15 @@ name = Products; sourceTree = ""; }; + 5046AB471AF2A8D80060550B /* MaterialSystemTest */ = { + isa = PBXGroup; + children = ( + 5046AB481AF2A8D80060550B /* MaterialSystemTest.cpp */, + 5046AB491AF2A8D80060550B /* MaterialSystemTest.h */, + ); + path = MaterialSystemTest; + sourceTree = ""; + }; 6886696E1AE8E8A000C2CFD9 /* SpritePolygonTest */ = { isa = PBXGroup; children = ( @@ -4028,6 +4049,15 @@ name = LightTest; sourceTree = ""; }; + B6CAB54B1AF9AA4B00B9B856 /* Physics3DTest */ = { + isa = PBXGroup; + children = ( + B6CAB54C1AF9AA6C00B9B856 /* Physics3DTest.cpp */, + B6CAB54D1AF9AA6C00B9B856 /* Physics3DTest.h */, + ); + name = Physics3DTest; + sourceTree = ""; + }; D0FD03611A3B543700825BB5 /* AllocatorTest */ = { isa = PBXGroup; children = ( @@ -4515,7 +4545,6 @@ 1AC35CFE18CED84500F37B72 /* Particles in Resources */, 1AC35CF418CED84500F37B72 /* Images in Resources */, 1AC35CE018CED84500F37B72 /* configs in Resources */, - 182C5CCD1A95D9BA00C30D34 /* src in Resources */, 1AC35CE618CED84500F37B72 /* effect2.ogg in Resources */, 1AC35CFA18CED84500F37B72 /* Misc in Resources */, 38FA2E76194AECF800FF2BE4 /* ActionTimeline in Resources */, @@ -4532,6 +4561,7 @@ 1AC35CE218CED84500F37B72 /* effect1.raw in Resources */, 1AC35CF218CED84500F37B72 /* Hello.png in Resources */, 1AC35CA518CECF1E00F37B72 /* Icon.icns in Resources */, + 5046AB5B1AF2C4180060550B /* Materials in Resources */, B63993311A49359F00B07923 /* Particle3D in Resources */, 1AC35CEC18CED84500F37B72 /* fonts in Resources */, 1AC35CCA18CED84500F37B72 /* animations in Resources */, @@ -4604,7 +4634,7 @@ 1AC35CE118CED84500F37B72 /* configs in Resources */, 1AC35CE918CED84500F37B72 /* extensions in Resources */, 3E2BDAD219BEA3E20055CDCD /* audio in Resources */, - 182C5CCF1A95D9BA00C30D34 /* src in Resources */, + 5046AB5C1AF2C4180060550B /* Materials in Resources */, C08689C318D370C90093E810 /* background.caf in Resources */, 1AC35C9518CECF1400F37B72 /* Icon-72.png in Resources */, 15B3709419EE5D1000ABE682 /* Manifests in Resources */, @@ -4873,11 +4903,13 @@ 1AC35C2118CECF0C00F37B72 /* ParallaxTest.cpp in Sources */, 1AC35C6B18CECF0C00F37B72 /* ZwoptexTest.cpp in Sources */, 1AC35B7718CECF0C00F37B72 /* ComponentsTestScene.cpp in Sources */, + 5046AB4A1AF2A8D80060550B /* MaterialSystemTest.cpp in Sources */, B603F1AF1AC8EA4E00A9579C /* TerrainTest.cpp in Sources */, 29080DC7191B595E0066F8DF /* UISceneManager.cpp in Sources */, 1AC35C2F18CECF0C00F37B72 /* PerformanceParticleTest.cpp in Sources */, 1AC35B4918CECF0C00F37B72 /* Bug-914.cpp in Sources */, 1AC35B6318CECF0C00F37B72 /* EffectsAdvancedTest.cpp in Sources */, + B6CAB54E1AF9AA6C00B9B856 /* Physics3DTest.cpp in Sources */, B639932E1A490EC700B07923 /* Particle3DTest.cpp in Sources */, 1AC35C5F18CECF0C00F37B72 /* Paddle.cpp in Sources */, 1AC35BDB18CECF0C00F37B72 /* SceneEditorTest.cpp in Sources */, @@ -5047,6 +5079,7 @@ 1AC35BEC18CECF0C00F37B72 /* CCControlSliderTest.cpp in Sources */, 29080DB4191B595E0066F8DF /* UILayoutTest_Editor.cpp in Sources */, 1AC35C4E18CECF0C00F37B72 /* SpineTest.cpp in Sources */, + B6CAB54F1AF9AA6C00B9B856 /* Physics3DTest.cpp in Sources */, 1AC35C1E18CECF0C00F37B72 /* NewRendererTest.cpp in Sources */, 5EBEECB11995247000429821 /* DrawNode3D.cpp in Sources */, 1AC35B6818CECF0C00F37B72 /* AnimationsTestLayer.cpp in Sources */, @@ -5190,6 +5223,7 @@ 29080DB2191B595E0066F8DF /* UILayoutTest.cpp in Sources */, 1AC35B6A18CECF0C00F37B72 /* ButtonTestLayer.cpp in Sources */, 29080DB6191B595E0066F8DF /* UIListViewTest.cpp in Sources */, + 5046AB4B1AF2A8D80060550B /* MaterialSystemTest.cpp in Sources */, 1AC35B3018CECF0C00F37B72 /* Box2dView.cpp in Sources */, 29080DAE191B595E0066F8DF /* UIImageViewTest.cpp in Sources */, 1AC35C1018CECF0C00F37B72 /* LabelTest.cpp in Sources */, @@ -5908,6 +5942,7 @@ "COCOS2D_DEBUG=1", USE_FILE32API, "CC_ENABLE_CHIPMUNK_INTEGRATION=1", + "CC_ENABLE_BULLET_INTEGRATION=1", ); GCC_SYMBOLS_PRIVATE_EXTERN = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; @@ -5936,6 +5971,7 @@ NDEBUG, USE_FILE32API, "CC_ENABLE_CHIPMUNK_INTEGRATION=1", + "CC_ENABLE_BULLET_INTEGRATION=1", ); GCC_SYMBOLS_PRIVATE_EXTERN = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES; diff --git a/build/win32-msvc-2012-x86.cmd b/build/win32-msvc-2012-x86.cmd deleted file mode 100644 index 7331e5b6b4..0000000000 --- a/build/win32-msvc-2012-x86.cmd +++ /dev/null @@ -1,8 +0,0 @@ -@echo off -SETLOCAL - -:start -mkdir win32-msvc-vs2012-x86 -cd win32-msvc-vs2012-x86 -cmake -G "Visual Studio 11" ../.. -pause diff --git a/cocos/2d/CCActionEase.cpp b/cocos/2d/CCActionEase.cpp index 6541d74da3..46335fd0aa 100644 --- a/cocos/2d/CCActionEase.cpp +++ b/cocos/2d/CCActionEase.cpp @@ -90,6 +90,24 @@ ActionInterval* ActionEase::getInnerAction() // EaseRateAction // +EaseRateAction* EaseRateAction::create(ActionInterval* action, float rate) +{ + EaseRateAction *easeRateAction = new (std::nothrow) EaseRateAction(); + if (easeRateAction) + { + if (easeRateAction->initWithAction(action, rate)) + { + easeRateAction->autorelease(); + } + else + { + CC_SAFE_RELEASE_NULL(easeRateAction); + } + } + + return easeRateAction; +} + bool EaseRateAction::initWithAction(ActionInterval *action, float rate) { if (ActionEase::initWithAction(action)) diff --git a/cocos/2d/CCActionEase.h b/cocos/2d/CCActionEase.h index 7e08bc29e9..307a97d965 100644 --- a/cocos/2d/CCActionEase.h +++ b/cocos/2d/CCActionEase.h @@ -97,6 +97,14 @@ private: class CC_DLL EaseRateAction : public ActionEase { public: + /** + @brief Creates the action with the inner action and the rate parameter. + @param action A given ActionInterval + @param rate A given rate + @return An autoreleased EaseRateAction object. + **/ + static EaseRateAction* create(ActionInterval* action, float rate); + /** @brief Set the rate value for the ease rate action. @param rate The value will be set. diff --git a/cocos/2d/CCActionInterval.cpp b/cocos/2d/CCActionInterval.cpp index 569d831ae8..69835dc9d0 100644 --- a/cocos/2d/CCActionInterval.cpp +++ b/cocos/2d/CCActionInterval.cpp @@ -165,7 +165,7 @@ Sequence* Sequence::createWithTwoActions(FiniteTimeAction *actionOne, FiniteTime return sequence; } -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) Sequence* Sequence::variadicCreate(FiniteTimeAction *action1, ...) { va_list params; @@ -554,7 +554,7 @@ RepeatForever *RepeatForever::reverse() const // Spawn // -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) Spawn* Spawn::variadicCreate(FiniteTimeAction *action1, ...) { va_list params; @@ -2511,4 +2511,60 @@ void TargetedAction::setForcedTarget(Node* forcedTarget) } } +// ActionFloat + +ActionFloat* ActionFloat::create(float duration, float from, float to, ActionFloatCallback callback) +{ + auto ref = new (std::nothrow) ActionFloat(); + if (ref && ref->initWithDuration(duration, from, to, callback)) + { + ref->autorelease(); + return ref; + } + CC_SAFE_DELETE(ref); + return ref; +} + +bool ActionFloat::initWithDuration(float duration, float from, float to, ActionFloatCallback callback) +{ + if (ActionInterval::initWithDuration(duration)) + { + _from = from; + _to = to; + _callback = callback; + return true; + } + return false; +} + +ActionFloat* ActionFloat::clone() const +{ + auto a = new (std::nothrow) ActionFloat(); + a->initWithDuration(_duration, _from, _to, _callback); + a->autorelease(); + return a; +} + +void ActionFloat::startWithTarget(Node *target) +{ + ActionInterval::startWithTarget(target); + _delta = _to - _from; +} + +void ActionFloat::update(float delta) +{ + float value = _to - _delta * (1 - delta); + + if (_callback) + { + // report back value to caller + _callback(value); + } +} + +ActionFloat* ActionFloat::reverse() const +{ + return ActionFloat::create(_duration, _to, _from, _callback); +} + NS_CC_END diff --git a/cocos/2d/CCActionInterval.h b/cocos/2d/CCActionInterval.h index a489d56639..458263df04 100644 --- a/cocos/2d/CCActionInterval.h +++ b/cocos/2d/CCActionInterval.h @@ -124,8 +124,8 @@ public: * * @return An autoreleased Sequence object. */ -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) - // WP8 in VS2012 does not support nullptr in variable args lists and variadic templates are also not supported +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) + // VS2013 does not support nullptr in variable args lists and variadic templates are also not supported typedef FiniteTimeAction* M; static Sequence* create(M m1, std::nullptr_t listEnd) { return variadicCreate(m1, NULL); } static Sequence* create(M m1, M m2, std::nullptr_t listEnd) { return variadicCreate(m1, m2, NULL); } @@ -351,8 +351,8 @@ public: * * @return An autoreleased Spawn object. */ -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) - // WP8 in VS2012 does not support nullptr in variable args lists and variadic templates are also not supported. +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) + // VS2013 does not support nullptr in variable args lists and variadic templates are also not supported. typedef FiniteTimeAction* M; static Spawn* create(M m1, std::nullptr_t listEnd) { return variadicCreate(m1, NULL); } static Spawn* create(M m1, M m2, std::nullptr_t listEnd) { return variadicCreate(m1, m2, NULL); } @@ -1525,6 +1525,58 @@ private: CC_DISALLOW_COPY_AND_ASSIGN(TargetedAction); }; +/** + * @class ActionFloat + * @brief Action used to animate any value in range [from,to] over specified time interval + */ +class CC_DLL ActionFloat : public ActionInterval +{ +public: + /** + * Callback function used to report back result + */ + typedef std::function ActionFloatCallback; + + /** + * Creates FloatAction with specified duration, from value, to value and callback to report back + * results + * @param duration of the action + * @param from value to start from + * @param to value to be at the end of the action + * @param callback to report back result + * + * @return An autoreleased ActionFloat object + */ + static ActionFloat* create(float duration, float from, float to, ActionFloatCallback callback); + + /** + * Overrided ActionInterval methods + */ + void startWithTarget(Node* target) override; + void update(float delta) override; + ActionFloat* reverse() const override; + ActionFloat* clone() const override; + +CC_CONSTRUCTOR_ACCESS: + ActionFloat() {}; + virtual ~ActionFloat() {}; + + bool initWithDuration(float duration, float from, float to, ActionFloatCallback callback); + +protected: + /* From value */ + float _from; + /* To value */ + float _to; + /* delta time */ + float _delta; + + /* Callback to report back results */ + ActionFloatCallback _callback; +private: + CC_DISALLOW_COPY_AND_ASSIGN(ActionFloat); +}; + // end of actions group /// @} diff --git a/cocos/2d/CCCamera.cpp b/cocos/2d/CCCamera.cpp index c285848e2f..d72d2c8053 100644 --- a/cocos/2d/CCCamera.cpp +++ b/cocos/2d/CCCamera.cpp @@ -209,14 +209,6 @@ bool Camera::initPerspective(float fieldOfView, float aspectRatio, float nearPla _nearPlane = nearPlane; _farPlane = farPlane; Mat4::createPerspective(_fieldOfView, _aspectRatio, _nearPlane, _farPlane, &_projection); -#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 - //if needed, we need to add a rotation for Landscape orientations on Windows Phone 8 since it is always in Portrait Mode - GLView* view = Director::getInstance()->getOpenGLView(); - if(view != nullptr) - { - setAdditionalProjection(view->getOrientationMatrix()); - } -#endif _viewProjectionDirty = true; _frustumDirty = true; @@ -230,14 +222,6 @@ bool Camera::initOrthographic(float zoomX, float zoomY, float nearPlane, float f _nearPlane = nearPlane; _farPlane = farPlane; Mat4::createOrthographicOffCenter(0, _zoom[0], 0, _zoom[1], _nearPlane, _farPlane, &_projection); -#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 - //if needed, we need to add a rotation for Landscape orientations on Windows Phone 8 since it is always in Portrait Mode - GLView* view = Director::getInstance()->getOpenGLView(); - if(view != nullptr) - { - setAdditionalProjection(view->getOrientationMatrix()); - } -#endif _viewProjectionDirty = true; _frustumDirty = true; diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index edad8d9aad..66f7e35a85 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -32,6 +32,11 @@ #include "renderer/CCRenderer.h" #include "base/CCDirector.h" +#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) +#define CC_CLIPPING_NODE_OPENGLES 0 +#else +#define CC_CLIPPING_NODE_OPENGLES 1 +#endif NS_CC_BEGIN @@ -41,6 +46,7 @@ static GLint g_sStencilBits = -1; // where n is the number of bits of the stencil buffer. static GLint s_layer = -1; +#if CC_CLIPPING_NODE_OPENGLES static void setProgram(Node *n, GLProgram *p) { n->setGLProgram(p); @@ -50,6 +56,7 @@ static void setProgram(Node *n, GLProgram *p) setProgram(child, p); } } +#endif ClippingNode::ClippingNode() : _stencil(nullptr) @@ -257,8 +264,7 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32 renderer->addCommand(&_beforeVisitCmd); if (_alphaThreshold < 1) { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) -#else +#if CC_CLIPPING_NODE_OPENGLES // since glAlphaTest do not exists in OES, use a shader that writes // pixel only if greater than an alpha threshold GLProgram *program = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV); @@ -438,7 +444,7 @@ void ClippingNode::onBeforeVisit() // enable alpha test only if the alpha threshold < 1, // indeed if alpha threshold == 1, every pixel will be drawn anyways if (_alphaThreshold < 1) { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) +#if !CC_CLIPPING_NODE_OPENGLES // manually save the alpha test state _currentAlphaTestEnabled = glIsEnabled(GL_ALPHA_TEST); glGetIntegerv(GL_ALPHA_TEST_FUNC, (GLint *)&_currentAlphaTestFunc); @@ -449,8 +455,6 @@ void ClippingNode::onBeforeVisit() CHECK_GL_ERROR_DEBUG(); // pixel will be drawn only if greater than an alpha threshold glAlphaFunc(GL_GREATER, _alphaThreshold); -#else - #endif } @@ -462,15 +466,15 @@ void ClippingNode::onAfterDrawStencil() // restore alpha test state if (_alphaThreshold < 1) { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) +#if CC_CLIPPING_NODE_OPENGLES + // FIXME: we need to find a way to restore the shaders of the stencil node and its childs +#else // manually restore the alpha test state glAlphaFunc(_currentAlphaTestFunc, _currentAlphaTestRef); if (!_currentAlphaTestEnabled) { glDisable(GL_ALPHA_TEST); } -#else -// FIXME: we need to find a way to restore the shaders of the stencil node and its childs #endif } diff --git a/cocos/2d/CCComponentContainer.cpp b/cocos/2d/CCComponentContainer.cpp index 544b3d8077..0de3cd8cdc 100644 --- a/cocos/2d/CCComponentContainer.cpp +++ b/cocos/2d/CCComponentContainer.cpp @@ -156,4 +156,19 @@ bool ComponentContainer::isEmpty() const return (_components == nullptr || _components->empty()); } +void ComponentContainer::onEnter() +{ + for (auto iter = _components->begin(); iter != _components->end(); ++iter) + { + iter->second->onEnter(); + } +} +void ComponentContainer::onExit() +{ + for (auto iter = _components->begin(); iter != _components->end(); ++iter) + { + iter->second->onExit(); + } +} + NS_CC_END diff --git a/cocos/2d/CCComponentContainer.h b/cocos/2d/CCComponentContainer.h index a524384d40..357e082eb3 100644 --- a/cocos/2d/CCComponentContainer.h +++ b/cocos/2d/CCComponentContainer.h @@ -58,6 +58,10 @@ public: virtual bool remove(Component *com); virtual void removeAll(); virtual void visit(float delta); + + virtual void onEnter(); + virtual void onExit(); + public: bool isEmpty() const; diff --git a/cocos/2d/CCFontFreeType.cpp b/cocos/2d/CCFontFreeType.cpp index 446c24f0d3..074d9c4d1f 100644 --- a/cocos/2d/CCFontFreeType.cpp +++ b/cocos/2d/CCFontFreeType.cpp @@ -269,10 +269,11 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWid break; } - outRect.origin.x = _fontRef->glyph->metrics.horiBearingX >> 6; - outRect.origin.y = - (_fontRef->glyph->metrics.horiBearingY >> 6); - outRect.size.width = (_fontRef->glyph->metrics.width >> 6); - outRect.size.height = (_fontRef->glyph->metrics.height >> 6); + auto& metrics = _fontRef->glyph->metrics; + outRect.origin.x = metrics.horiBearingX >> 6; + outRect.origin.y = -(metrics.horiBearingY >> 6); + outRect.size.width = (metrics.width >> 6); + outRect.size.height = (metrics.height >> 6); xAdvance = (static_cast(_fontRef->glyph->metrics.horiAdvance >> 6)); @@ -294,35 +295,46 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWid break; } - auto outlineWidth = (bbox.xMax - bbox.xMin)>>6; - auto outlineHeight = (bbox.yMax - bbox.yMin)>>6; + long glyphMinX = outRect.origin.x; + long glyphMaxX = outRect.origin.x + outWidth; + long glyphMinY = -outHeight - outRect.origin.y; + long glyphMaxY = -outRect.origin.y; - auto blendWidth = outlineWidth > outWidth ? outlineWidth : outWidth; - auto blendHeight = outlineHeight > outHeight ? outlineHeight : outHeight; + auto outlineMinX = bbox.xMin >> 6; + auto outlineMaxX = bbox.xMax >> 6; + auto outlineMinY = bbox.yMin >> 6; + auto outlineMaxY = bbox.yMax >> 6; + auto outlineWidth = outlineMaxX - outlineMinX; + auto outlineHeight = outlineMaxY - outlineMinY; - long index,index2; + auto blendImageMinX = MIN(outlineMinX, glyphMinX); + auto blendImageMaxY = MAX(outlineMaxY, glyphMaxY); + auto blendWidth = MAX(outlineMaxX, glyphMaxX) - blendImageMinX; + auto blendHeight = blendImageMaxY - MIN(outlineMinY, glyphMinY); + + long index, index2; auto blendImage = new unsigned char[blendWidth * blendHeight * 2]; memset(blendImage, 0, blendWidth * blendHeight * 2); - auto px = (blendWidth - outlineWidth) / 2; - auto py = (blendHeight - outlineHeight) / 2; + auto px = outlineMinX - blendImageMinX; + auto py = blendImageMaxY - outlineMaxY; for (int x = 0; x < outlineWidth; ++x) { for (int y = 0; y < outlineHeight; ++y) { - index = px + x + ( (py + y) * blendWidth ); + index = px + x + ((py + y) * blendWidth); index2 = x + (y * outlineWidth); blendImage[2 * index] = outlineBitmap[index2]; } } - px = (blendWidth - outWidth) / 2; - py = (blendHeight - outHeight) / 2; + px = glyphMinX - blendImageMinX; + py = blendImageMaxY - glyphMaxY; for (int x = 0; x < outWidth; ++x) { for (int y = 0; y < outHeight; ++y) { - index = px + x + ( (y + py) * blendWidth ); + index = px + x + ((y + py) * blendWidth); index2 = x + (y * outWidth); blendImage[2 * index + 1] = copyBitmap[index2]; } diff --git a/cocos/2d/CCFontFreeType.h b/cocos/2d/CCFontFreeType.h index 8b65baab0e..d5ce6f4f8e 100644 --- a/cocos/2d/CCFontFreeType.h +++ b/cocos/2d/CCFontFreeType.h @@ -33,7 +33,7 @@ #include #include -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) #define generic GenericFromFreeTypeLibrary #define internal InternalFromFreeTypeLibrary #endif @@ -41,7 +41,7 @@ #include FT_FREETYPE_H #include FT_STROKER_H -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) #undef generic #undef internal #endif diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 9af6f28f23..e0c9295852 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -406,13 +406,7 @@ void Label::setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false * _commonLineHeight = _fontAtlas->getCommonLineHeight(); _contentDirty = true; } -#if CC_TARGET_PLATFORM != CC_PLATFORM_WP8 _useDistanceField = distanceFieldEnabled; -#else - // some older Windows Phones cannot run the ccShader_Label_df.frag program - // so we must disable distance field - _useDistanceField = false; -#endif _useA8Shader = useA8Shader; if (_currentLabelType != LabelType::TTF) @@ -591,10 +585,6 @@ void Label::alignText() return; } - for (const auto& batchNode:_batchNodes) - { - batchNode->getTextureAtlas()->removeAllQuads(); - } _fontAtlas->prepareLetterDefinitions(_currentUTF16String); auto& textures = _fontAtlas->getTextures(); if (textures.size() > _batchNodes.size()) @@ -615,31 +605,48 @@ void Label::alignText() if(_labelWidth > 0 || (_currNumLines > 1 && _hAlignment != TextHAlignment::LEFT)) LabelTextFormatter::alignText(this); - int strLen = static_cast(_currentUTF16String.length()); - Rect uvRect; - Sprite* letterSprite; - for(const auto &child : _children) { - int tag = child->getTag(); - if(tag >= strLen) - { - SpriteBatchNode::removeChild(child, true); - } - else if(tag >= 0) - { - letterSprite = dynamic_cast(child); - if (letterSprite) + if (!_children.empty()) + { + int strLen = static_cast(_currentUTF16String.length()); + Rect uvRect; + Sprite* letterSprite; + for (auto index = 0; index < _children.size();) { + auto child = _children.at(index); + int tag = child->getTag(); + if (tag >= strLen) { - uvRect.size.height = _lettersInfo[tag].def.height; - uvRect.size.width = _lettersInfo[tag].def.width; - uvRect.origin.x = _lettersInfo[tag].def.U; - uvRect.origin.y = _lettersInfo[tag].def.V; - - letterSprite->setTexture(textures.at(_lettersInfo[tag].def.textureID)); - letterSprite->setTextureRect(uvRect); + child->removeFromParentAndCleanup(true); + } + else if (tag >= 0) + { + letterSprite = dynamic_cast(child); + if (letterSprite) + { + auto& letterDef = _lettersInfo[tag].def; + uvRect.size.height = letterDef.height; + uvRect.size.width = letterDef.width; + uvRect.origin.x = letterDef.U; + uvRect.origin.y = letterDef.V; + + letterSprite->setBatchNode(_batchNodes[letterDef.textureID]); + letterSprite->setTextureRect(uvRect, false, uvRect.size); + letterSprite->setPosition(_lettersInfo[tag].position.x + letterDef.width/2, + _lettersInfo[tag].position.y - letterDef.height/2); + } + ++index; + } + else + { + ++index; } } } + for (const auto& batchNode : _batchNodes) + { + batchNode->getTextureAtlas()->removeAllQuads(); + } + updateQuads(); updateColor(); @@ -900,8 +907,11 @@ void Label::onDraw(const Mat4& transform, bool transformUpdated) { glprogram->setUniformLocationWith4f(_uniformTextColor, _shadowColor4F.r, _shadowColor4F.g, _shadowColor4F.b, _shadowColor4F.a); - glprogram->setUniformLocationWith4f(_uniformEffectColor, - _shadowColor4F.r, _shadowColor4F.g, _shadowColor4F.b, _shadowColor4F.a); + if (_currLabelEffect == LabelEffect::OUTLINE || _currLabelEffect == LabelEffect::GLOW) + { + glprogram->setUniformLocationWith4f(_uniformEffectColor, + _shadowColor4F.r, _shadowColor4F.g, _shadowColor4F.b, _shadowColor4F.a); + } getGLProgram()->setUniformsForBuiltins(_shadowTransform); for (const auto &child : _children) @@ -951,8 +961,7 @@ void Label::onDraw(const Mat4& transform, bool transformUpdated) for(const auto &child: _children) { - if(child->getTag() >= 0) - child->updateTransform(); + child->updateTransform(); } for (const auto& batchNode:_batchNodes) diff --git a/cocos/2d/CCLayer.cpp b/cocos/2d/CCLayer.cpp index 042f3a978a..72861dac23 100644 --- a/cocos/2d/CCLayer.cpp +++ b/cocos/2d/CCLayer.cpp @@ -845,7 +845,7 @@ LayerMultiplex::~LayerMultiplex() } } -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) LayerMultiplex * LayerMultiplex::createVariadic(Layer * layer, ...) { va_list args; diff --git a/cocos/2d/CCLayer.h b/cocos/2d/CCLayer.h index 9d053eea54..d437853543 100644 --- a/cocos/2d/CCLayer.h +++ b/cocos/2d/CCLayer.h @@ -596,8 +596,8 @@ public: * In lua:local create(...) * @endcode */ -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) - // WP8 in VS2012 does not support nullptr in variable args lists and variadic templates are also not supported +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) + // VS2013 does not support nullptr in variable args lists and variadic templates are also not supported typedef Layer* M; static LayerMultiplex* create(M m1, std::nullptr_t listEnd) { return createVariadic(m1, NULL); } static LayerMultiplex* create(M m1, M m2, std::nullptr_t listEnd) { return createVariadic(m1, m2, NULL); } diff --git a/cocos/2d/CCMenu.cpp b/cocos/2d/CCMenu.cpp index 881c56470c..617610bf51 100644 --- a/cocos/2d/CCMenu.cpp +++ b/cocos/2d/CCMenu.cpp @@ -57,7 +57,7 @@ Menu* Menu::create() return Menu::create(nullptr, nullptr); } -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) Menu * Menu::variadicCreate(MenuItem* item, ...) { va_list args; diff --git a/cocos/2d/CCMenu.h b/cocos/2d/CCMenu.h index 3159bc02b4..1f15f1bd72 100644 --- a/cocos/2d/CCMenu.h +++ b/cocos/2d/CCMenu.h @@ -63,8 +63,8 @@ public: */ static Menu* create(); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) - // WP8 in VS2012 does not support nullptr in variable args lists and variadic templates are also not supported. +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) + // VS2013 does not support nullptr in variable args lists and variadic templates are also not supported. typedef MenuItem* M; static Menu* create(M m1, std::nullptr_t listEnd) { return variadicCreate(m1, NULL); } static Menu* create(M m1, M m2, std::nullptr_t listEnd) { return variadicCreate(m1, m2, NULL); } diff --git a/cocos/2d/CCMenuItem.cpp b/cocos/2d/CCMenuItem.cpp index a9faaa8b6e..8bac6195ed 100644 --- a/cocos/2d/CCMenuItem.cpp +++ b/cocos/2d/CCMenuItem.cpp @@ -820,7 +820,7 @@ MenuItemToggle * MenuItemToggle::createWithTarget(Ref* target, SEL_MenuHandler s return ret; } -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) MenuItemToggle * MenuItemToggle::createWithCallbackVA(const ccMenuCallback &callback, MenuItem* item, ...) { va_list args; diff --git a/cocos/2d/CCMenuItem.h b/cocos/2d/CCMenuItem.h index 807661def1..718cb3786d 100644 --- a/cocos/2d/CCMenuItem.h +++ b/cocos/2d/CCMenuItem.h @@ -493,8 +493,8 @@ public: */ static MenuItemToggle * createWithCallback(const ccMenuCallback& callback, const Vector& menuItems); /** Creates a menu item from a list of items with a callable object. */ -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) - // WP8 in VS2012 does not support nullptr in variable args lists and variadic templates are also not supported. +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) + // VS2013 does not support nullptr in variable args lists and variadic templates are also not supported. typedef MenuItem* M; static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, NULL); } static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, NULL); } diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 4db40352ed..bb9115162f 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -44,6 +44,7 @@ THE SOFTWARE. #include "2d/CCComponentContainer.h" #include "renderer/CCGLProgram.h" #include "renderer/CCGLProgramState.h" +#include "renderer/CCMaterial.h" #include "math/TransformUtils.h" #include "deprecated/CCString.h" @@ -833,6 +834,7 @@ void Node::setGLProgramState(cocos2d::GLProgramState *glProgramState) } } + void Node::setGLProgram(GLProgram *glProgram) { if (_glProgramState == nullptr || (_glProgramState && _glProgramState->getGLProgram() != glProgram)) diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index c2e92a333d..5333bbb33f 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -52,6 +52,7 @@ class Renderer; class Director; class GLProgram; class GLProgramState; +class Material; #if CC_USE_PHYSICS class PhysicsBody; class PhysicsWorld; diff --git a/cocos/2d/CCParticleSystem.h b/cocos/2d/CCParticleSystem.h index 8bf569ff57..415966a554 100644 --- a/cocos/2d/CCParticleSystem.h +++ b/cocos/2d/CCParticleSystem.h @@ -130,7 +130,7 @@ emitter.startSpin = 0; */ -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) #ifdef RELATIVE #undef RELATIVE #endif diff --git a/cocos/2d/CCRenderTexture.cpp b/cocos/2d/CCRenderTexture.cpp index 06c7e7a11f..5b680d3b53 100644 --- a/cocos/2d/CCRenderTexture.cpp +++ b/cocos/2d/CCRenderTexture.cpp @@ -551,13 +551,6 @@ void RenderTexture::onBegin() if(!_keepMatrix) { director->setProjection(director->getProjection()); - -#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 - auto modifiedProjection = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); - modifiedProjection = GLViewImpl::sharedOpenGLView()->getReverseOrientationMatrix() * modifiedProjection; - director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION,modifiedProjection); -#endif - const Size& texSize = _texture->getContentSizeInPixels(); // Calculate the adjustment ratios based on the old and new projections @@ -569,14 +562,6 @@ void RenderTexture::onBegin() Mat4::createOrthographicOffCenter((float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1, 1, &orthoMatrix); director->multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix); } - else - { -#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 - auto modifiedProjection = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); - modifiedProjection = GLViewImpl::sharedOpenGLView()->getReverseOrientationMatrix() * modifiedProjection; - director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, modifiedProjection); -#endif - } //calculate viewport { diff --git a/cocos/2d/CCScene.cpp b/cocos/2d/CCScene.cpp index 33fe0dcf00..252c3952a8 100644 --- a/cocos/2d/CCScene.cpp +++ b/cocos/2d/CCScene.cpp @@ -37,6 +37,11 @@ THE SOFTWARE. #include "physics/CCPhysicsWorld.h" #endif +#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION +#include "physics3d/CCPhysics3DWorld.h" +#include "physics3d/CCPhysics3DComponent.h" +#endif + NS_CC_BEGIN Scene::Scene() @@ -44,6 +49,10 @@ Scene::Scene() : _physicsWorld(nullptr) #endif { +#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION + _physics3DWorld = nullptr; + _physics3dDebugCamera = nullptr; +#endif _ignoreAnchorPointForPosition = true; setAnchorPoint(Vec2(0.5f, 0.5f)); @@ -61,6 +70,10 @@ Scene::~Scene() { #if CC_USE_PHYSICS CC_SAFE_DELETE(_physicsWorld); +#endif +#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION + CC_SAFE_RELEASE(_physics3DWorld); + CC_SAFE_RELEASE(_physics3dDebugCamera); #endif Director::getInstance()->getEventDispatcher()->removeEventListener(_event); CC_SAFE_RELEASE(_event); @@ -155,10 +168,22 @@ void Scene::render(Renderer* renderer) camera->clearBackground(1.0); //visit the scene visit(renderer, transform, 0); + renderer->render(); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); } + +#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION + if (_physics3DWorld && _physics3DWorld->isDebugDrawEnabled()) + { + director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); + director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, _physics3dDebugCamera != nullptr ? _physics3dDebugCamera->getViewProjectionMatrix() : defaultCamera->getViewProjectionMatrix()); + _physics3DWorld->debugDraw(renderer); + renderer->render(); + director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); + } +#endif Camera::_visitingCamera = nullptr; } @@ -177,7 +202,16 @@ void Scene::removeAllChildren() } } -#if CC_USE_PHYSICS +#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION +void Scene::setPhysics3DDebugCamera(Camera* camera) +{ + CC_SAFE_RETAIN(camera); + CC_SAFE_RELEASE(_physics3dDebugCamera); + _physics3dDebugCamera = camera; +} +#endif + +#if (CC_USE_PHYSICS || (CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION)) void Scene::addChild(Node* child, int zOrder, int tag) { Node::addChild(child, zOrder, tag); @@ -214,7 +248,17 @@ bool Scene::initWithPhysics() CC_BREAK_IF( ! (director = Director::getInstance()) ); this->setContentSize(director->getWinSize()); +#if CC_USE_PHYSICS CC_BREAK_IF(! (_physicsWorld = PhysicsWorld::construct(*this))); +#endif + +#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION + Physics3DWorldDes info; + //TODO: FIX ME + //info.isDebugDrawEnabled = true; + CC_BREAK_IF(! (_physics3DWorld = Physics3DWorld::create(&info))); + _physics3DWorld->retain(); +#endif // success ret = true; @@ -224,6 +268,7 @@ bool Scene::initWithPhysics() void Scene::addChildToPhysicsWorld(Node* child) { +#if CC_USE_PHYSICS if (_physicsWorld) { std::function addToPhysicsWorldFunc = nullptr; @@ -244,6 +289,30 @@ void Scene::addChildToPhysicsWorld(Node* child) addToPhysicsWorldFunc(child); } +#endif + +#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION + if (_physics3DWorld) + { + std::function addToPhysicsWorldFunc = nullptr; + addToPhysicsWorldFunc = [this, &addToPhysicsWorldFunc](Node* node) -> void + { + static std::string comName = Physics3DComponent::getPhysics3DComponentName(); + auto com = static_cast(node->getComponent(comName)); + if (com) + { + com->addToPhysicsWorld(_physics3DWorld); + } + + auto& children = node->getChildren(); + for( const auto &n : children) { + addToPhysicsWorldFunc(n); + } + }; + + addToPhysicsWorldFunc(child); + } +#endif } #endif diff --git a/cocos/2d/CCScene.h b/cocos/2d/CCScene.h index ee2d2ef08c..0b3701f064 100644 --- a/cocos/2d/CCScene.h +++ b/cocos/2d/CCScene.h @@ -41,6 +41,9 @@ class EventCustom; #if CC_USE_PHYSICS class PhysicsWorld; #endif +#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION +class Physics3DWorld; +#endif /** * @addtogroup _2d * @{ @@ -136,15 +139,31 @@ protected: private: CC_DISALLOW_COPY_AND_ASSIGN(Scene); -#if CC_USE_PHYSICS +#if (CC_USE_PHYSICS || (CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION)) public: virtual void addChild(Node* child, int zOrder, int tag) override; virtual void addChild(Node* child, int zOrder, const std::string &name) override; + +#if CC_USE_PHYSICS /** Get the physics world of the scene. * @return The physics world of the scene. * @js NA */ inline PhysicsWorld* getPhysicsWorld() { return _physicsWorld; } +#endif + +#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION + /** Get the 3d physics world of the scene. + * @return The 3d physics world of the scene. + * @js NA + */ + inline Physics3DWorld* getPhysics3DWorld() { return _physics3DWorld; } + + /** + * Set Physics3D debug draw camera. + */ + void setPhysics3DDebugCamera(Camera* camera); +#endif /** Create a scene with physics. * @return An autoreleased Scene object with physics. @@ -158,8 +177,15 @@ CC_CONSTRUCTOR_ACCESS: protected: void addChildToPhysicsWorld(Node* child); +#if CC_USE_PHYSICS PhysicsWorld* _physicsWorld; -#endif // CC_USE_PHYSICS +#endif + +#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION + Physics3DWorld* _physics3DWorld; + Camera* _physics3dDebugCamera; // +#endif +#endif // (CC_USE_PHYSICS || CC_USE_3D_PHYSICS) }; // end of _2d group diff --git a/cocos/2d/CCTextFieldTTF.cpp b/cocos/2d/CCTextFieldTTF.cpp index 3e1378cf40..31bd5ba1e4 100644 --- a/cocos/2d/CCTextFieldTTF.cpp +++ b/cocos/2d/CCTextFieldTTF.cpp @@ -142,11 +142,7 @@ bool TextFieldTTF::attachWithIME() auto pGlView = Director::getInstance()->getOpenGLView(); if (pGlView) { -#if (CC_TARGET_PLATFORM != CC_PLATFORM_WP8 && CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) pGlView->setIMEKeyboardState(true); -#else - pGlView->setIMEKeyboardState(true, _inputText); -#endif } } return ret; @@ -161,11 +157,7 @@ bool TextFieldTTF::detachWithIME() auto glView = Director::getInstance()->getOpenGLView(); if (glView) { -#if (CC_TARGET_PLATFORM != CC_PLATFORM_WP8 && CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) glView->setIMEKeyboardState(false); -#else - glView->setIMEKeyboardState(false, ""); -#endif } } return ret; diff --git a/cocos/2d/MarchingSquare.cpp b/cocos/2d/MarchingSquare.cpp index ba4a479d92..773e51e7e8 100644 --- a/cocos/2d/MarchingSquare.cpp +++ b/cocos/2d/MarchingSquare.cpp @@ -61,7 +61,7 @@ unsigned int MarchingSquare::findFirstNoneTransparentPixel() return i; } } - throw "image is all transparent!"; + CCASSERT(false, "image is all transparent!"); } unsigned char MarchingSquare::getAlphaAt(const unsigned int i) @@ -235,10 +235,13 @@ void MarchingSquare::marchSquare(int startx, int starty) break; case 0: CCLOG("case 0 at x:%d, y:%d, coming from %d, %d", curx, cury, prevx, prevy); - throw "this shoudln't happen"; + CCASSERT(false, "this shoudln't happen"); + break; case 15: CCLOG("case 15 at x:%d, y:%d, coming from %d, %d", curx, cury, prevx, prevy); - throw "this shoudln't happen"; + CCASSERT(false, "this shoudln't happen"); + break; + } //little optimization // if previous direction is same as current direction, @@ -266,8 +269,7 @@ void MarchingSquare::marchSquare(int startx, int starty) prevx = stepx; prevy = stepy; problem = false; - if(count > totalPixel) - throw "oh no, marching square cannot find starting position"; + CCASSERT(count <= totalPixel, "oh no, marching square cannot find starting position"); } while(curx != startx || cury != starty); } diff --git a/cocos/2d/cocos2d_headers.props b/cocos/2d/cocos2d_headers.props index 2088c06b67..7a40862144 100644 --- a/cocos/2d/cocos2d_headers.props +++ b/cocos/2d/cocos2d_headers.props @@ -7,7 +7,7 @@ - $(EngineRoot)cocos\editor-support;$(EngineRoot)cocos;$(EngineRoot)cocos\platform;$(EngineRoot)cocos\platform\desktop;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES;$(EngineRoot)external\freetype2\include\win32\freetype2;$(EngineRoot)external\freetype2\include\win32\ + $(EngineRoot)cocos\editor-support;$(EngineRoot)cocos;$(EngineRoot)cocos\platform;$(EngineRoot)cocos\platform\desktop;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES;$(EngineRoot)external\freetype2\include\win32\freetype2;$(EngineRoot)external\freetype2\include\win32\;$(EngineRoot)external _VARIADIC_MAX=10;%(PreprocessorDefinitions) diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index 1523f85ef8..5b4f2c5f6d 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -20,18 +20,12 @@ DynamicLibrary Unicode - v100 - v110 - v110_xp v120 v120_xp DynamicLibrary Unicode - v100 - v110 - v110_xp v120 v120_xp @@ -50,7 +44,7 @@ - <_ProjectFileVersion>10.0.40219.1 + <_ProjectFileVersion>12.0.21005.1 $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ false @@ -78,7 +72,7 @@ Disabled $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(EngineRoot)external\box2d;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\win32;$(EngineRoot)external\jpeg\include\win32;$(EngineRoot)external\tiff\include\win32;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\win32;$(EngineRoot)external\win32-specific\OpenalSoft\include;$(EngineRoot)external\win32-specific\MP3Decoder\include;$(EngineRoot)external\win32-specific\OggDecoder\include;$(EngineRoot)external\win32-specific\icon\include;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\xxhash;$(EngineRoot)external\ConvertUTF;$(EngineRoot)external\curl\include\win32;$(EngineRoot)external\websockets\include\win32;$(EngineRoot)external\poly2tri\common;$(EngineRoot)external\poly2tri\sweep;$(EngineRoot)external\poly2tri;$(EngineRoot)external;$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories) - WIN32;_USRDLL;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;PROTOBUF_USE_DLLS;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) + WIN32;_USRDLL;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;PROTOBUF_USE_DLLS;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) false EnableFastChecks MultiThreadedDebugDLL @@ -119,7 +113,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\debug-lib\*.*" $(TargetDir)$(TargetName).lib MachineX86 cocos2d.def - sqlite3.lib;libcurl_imp.lib;websockets.lib;libmpg123.lib;libogg.lib;libvorbis.lib;libvorbisfile.lib;OpenAL32.lib;%(AdditionalDependencies) + sqlite3.lib;libcurl_imp.lib;websockets.lib;libmpg123.lib;libogg.lib;libvorbis.lib;libvorbisfile.lib;OpenAL32.lib;libbullet.lib;%(AdditionalDependencies) @@ -133,7 +127,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\debug-lib\*.*" $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\win32;$(EngineRoot)external\jpeg\include\win32;$(EngineRoot)external\tiff\include\win32;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\win32;$(EngineRoot)external\win32-specific\MP3Decoder\include;$(EngineRoot)external\win32-specific\OggDecoder\include;$(EngineRoot)external\win32-specific\OpenalSoft\include;$(EngineRoot)external\win32-specific\icon\include;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\xxhash;$(EngineRoot)external\ConvertUTF;$(EngineRoot)external\Box2d;$(EngineRoot)external\curl\include\win32;$(EngineRoot)external\websockets\include\win32\;$(EngineRoot)external\poly2tri\common;$(EngineRoot)external\poly2tri\sweep;$(EngineRoot)external\poly2tri;$(EngineRoot)external;$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories) - WIN32;_USRDLL;NDEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;PROTOBUF_USE_DLLS;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) + WIN32;_USRDLL;NDEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;PROTOBUF_USE_DLLS;LIBPROTOBUF_EXPORTS;%(PreprocessorDefinitions) MultiThreadedDLL @@ -166,7 +160,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - sqlite3.lib;libcurl_imp.lib;websockets.lib;libmpg123.lib;libogg.lib;libvorbis.lib;libvorbisfile.lib;OpenAL32.lib;%(AdditionalDependencies) + sqlite3.lib;libcurl_imp.lib;websockets.lib;libmpg123.lib;libogg.lib;libvorbis.lib;libvorbisfile.lib;OpenAL32.lib;libbullet.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).dll $(OutDir);%(AdditionalLibraryDirectories) LIBCMTD.lib;%(IgnoreSpecificDefaultLibraries) @@ -567,6 +561,14 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + + + + + + + + @@ -591,13 +593,17 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + + + + @@ -1142,6 +1148,14 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + + + + + + + + @@ -1173,14 +1187,18 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + + + + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index f87c0173a2..82368bef47 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -1,4 +1,4 @@ - + @@ -268,6 +268,9 @@ {c37eceeb-5702-4ff7-88de-94680a22266f} + + {e492faef-2169-4117-8d73-e0c66271fe25} + @@ -1827,6 +1830,42 @@ 2d + + physics3d + + + physics3d + + + physics3d + + + physics3d + + + physics3d + + + physics3d + + + physics3d + + + physics3d + + + renderer + + + renderer + + + renderer + + + renderer + @@ -3575,6 +3614,42 @@ 2d + + physics3d + + + physics3d + + + physics3d + + + physics3d + + + physics3d + + + physics3d + + + physics3d + + + physics3d + + + renderer + + + renderer + + + renderer + + + renderer + diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1.sln b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1.sln index 643e0e020e..ec7fcf7494 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1.sln +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1.sln @@ -2,7 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 VisualStudioVersion = 12.0.30723.0 -MinimumVisualStudioVersion = 10.0.40219.1 +MinimumVisualStudioVersion = 12.0.21005.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libcocos2d_8_1", "libcocos2d_8_1", "{CA9DBD4B-603D-494E-802A-1C36E3EA3F07}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d_8_1.Shared", "libcocos2d_8_1\libcocos2d_8_1.Shared\libcocos2d_8_1.Shared.vcxitems", "{5D6F020F-7E72-4494-90A0-2DF11D235DF9}" diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems index 711515d2b8..69cbaab259 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems @@ -488,14 +488,18 @@ + + + + @@ -1051,13 +1055,17 @@ + + + + diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters index 41cb197923..b2c30b3426 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters @@ -1773,6 +1773,18 @@ 2d + + renderer + + + renderer + + + renderer + + + renderer + @@ -3369,6 +3381,18 @@ 2d + + renderer + + + renderer + + + renderer + + + renderer + diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj index 38773c3e01..7a5ccc03d0 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj @@ -113,40 +113,40 @@ false false - libcocos2d_v3.6_Windows_8.1 + libcocos2d_v3.7_Windows_8.1 false false - libcocos2d_v3.6_Windows_8.1 + libcocos2d_v3.7_Windows_8.1 false false - libcocos2d_v3.6_Windows_8.1 + libcocos2d_v3.7_Windows_8.1 false false false - libcocos2d_v3.6_Windows_8.1 + libcocos2d_v3.7_Windows_8.1 false false false - libcocos2d_v3.6_Windows_8.1 + libcocos2d_v3.7_Windows_8.1 false false - libcocos2d_v3.6_Windows_8.1 + libcocos2d_v3.7_Windows_8.1 diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj index 2da2fbba14..9194a11930 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj @@ -85,23 +85,23 @@ false false - libcocos2d_v3.6_WindowsPhone_8.1 + libcocos2d_v3.7_WindowsPhone_8.1 false false - libcocos2d_v3.6_WindowsPhone_8.1 + libcocos2d_v3.7_WindowsPhone_8.1 false false - libcocos2d_v3.6_WindowsPhone_8.1 + libcocos2d_v3.7_WindowsPhone_8.1 false false false - libcocos2d_v3.6_WindowsPhone_8.1 + libcocos2d_v3.7_WindowsPhone_8.1 false diff --git a/cocos/3d/CCAnimationCurve.h b/cocos/3d/CCAnimationCurve.h index 5c0b7e4630..c6af3a2fb6 100644 --- a/cocos/3d/CCAnimationCurve.h +++ b/cocos/3d/CCAnimationCurve.h @@ -30,7 +30,7 @@ #include "base/CCRef.h" #include "math/CCMath.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) #undef NEAR #endif diff --git a/cocos/3d/CCMesh.cpp b/cocos/3d/CCMesh.cpp index c79db7b413..d75fcf85a9 100644 --- a/cocos/3d/CCMesh.cpp +++ b/cocos/3d/CCMesh.cpp @@ -26,24 +26,106 @@ #include "3d/CCMeshSkin.h" #include "3d/CCSkeleton3D.h" #include "3d/CCMeshVertexIndexData.h" +#include "2d/CCLight.h" +#include "2d/CCScene.h" #include "base/CCEventDispatcher.h" #include "base/CCDirector.h" +#include "base/CCConfiguration.h" #include "renderer/CCTextureCache.h" #include "renderer/CCGLProgramState.h" +#include "renderer/CCMaterial.h" +#include "renderer/CCTechnique.h" +#include "renderer/CCPass.h" +#include "renderer/CCRenderer.h" +#include "math/Mat4.h" using namespace std; NS_CC_BEGIN +// Helpers + +static const char *s_dirLightUniformColorName = "u_DirLightSourceColor"; +static std::vector s_dirLightUniformColorValues; +static const char *s_dirLightUniformDirName = "u_DirLightSourceDirection"; +static std::vector s_dirLightUniformDirValues; + +static const char *s_pointLightUniformColorName = "u_PointLightSourceColor"; +static std::vector s_pointLightUniformColorValues; +static const char *s_pointLightUniformPositionName = "u_PointLightSourcePosition"; +static std::vector s_pointLightUniformPositionValues; +static const char *s_pointLightUniformRangeInverseName = "u_PointLightSourceRangeInverse"; +static std::vector s_pointLightUniformRangeInverseValues; + +static const char *s_spotLightUniformColorName = "u_SpotLightSourceColor"; +static std::vector s_spotLightUniformColorValues; +static const char *s_spotLightUniformPositionName = "u_SpotLightSourcePosition"; +static std::vector s_spotLightUniformPositionValues; +static const char *s_spotLightUniformDirName = "u_SpotLightSourceDirection"; +static std::vector s_spotLightUniformDirValues; +static const char *s_spotLightUniformInnerAngleCosName = "u_SpotLightSourceInnerAngleCos"; +static std::vector s_spotLightUniformInnerAngleCosValues; +static const char *s_spotLightUniformOuterAngleCosName = "u_SpotLightSourceOuterAngleCos"; +static std::vector s_spotLightUniformOuterAngleCosValues; +static const char *s_spotLightUniformRangeInverseName = "u_SpotLightSourceRangeInverse"; +static std::vector s_spotLightUniformRangeInverseValues; + +static const char *s_ambientLightUniformColorName = "u_AmbientLightSourceColor"; + +// helpers +static void resetLightUniformValues() +{ + const auto& conf = Configuration::getInstance(); + int maxDirLight = conf->getMaxSupportDirLightInShader(); + int maxPointLight = conf->getMaxSupportPointLightInShader(); + int maxSpotLight = conf->getMaxSupportSpotLightInShader(); + + s_dirLightUniformColorValues.assign(maxDirLight, Vec3::ZERO); + s_dirLightUniformDirValues.assign(maxDirLight, Vec3::ZERO); + + s_pointLightUniformColorValues.assign(maxPointLight, Vec3::ZERO); + s_pointLightUniformPositionValues.assign(maxPointLight, Vec3::ZERO); + s_pointLightUniformRangeInverseValues.assign(maxPointLight, 0.0f); + + s_spotLightUniformColorValues.assign(maxSpotLight, Vec3::ZERO); + s_spotLightUniformPositionValues.assign(maxSpotLight, Vec3::ZERO); + s_spotLightUniformDirValues.assign(maxSpotLight, Vec3::ZERO); + s_spotLightUniformInnerAngleCosValues.assign(maxSpotLight, 0.0f); + s_spotLightUniformOuterAngleCosValues.assign(maxSpotLight, 0.0f); + s_spotLightUniformRangeInverseValues.assign(maxSpotLight, 0.0f); +} + +//Generate a dummy texture when the texture file is missing +static Texture2D * getDummyTexture() +{ + auto texture = Director::getInstance()->getTextureCache()->getTextureForKey("/dummyTexture"); + if(!texture) + { +#ifdef NDEBUG + unsigned char data[] ={0,0,0,0};//1*1 transparent picture +#else + unsigned char data[] ={255,0,0,255};//1*1 red picture +#endif + Image * image =new (std::nothrow) Image(); + image->initWithRawData(data,sizeof(data),1,1,sizeof(unsigned char)); + texture=Director::getInstance()->getTextureCache()->addImage(image,"/dummyTexture"); + image->release(); + } + return texture; +} + + Mesh::Mesh() : _texture(nullptr) , _skin(nullptr) , _visible(true) , _isTransparent(false) , _meshIndexData(nullptr) +, _material(nullptr) , _glProgramState(nullptr) , _blend(BlendFunc::ALPHA_NON_PREMULTIPLIED) , _visibleChanged(nullptr) +, _blendDirty(true) { } @@ -52,6 +134,7 @@ Mesh::~Mesh() CC_SAFE_RELEASE(_texture); CC_SAFE_RELEASE(_skin); CC_SAFE_RELEASE(_meshIndexData); + CC_SAFE_RELEASE(_material); CC_SAFE_RELEASE(_glProgramState); } @@ -172,6 +255,11 @@ void Mesh::setVisible(bool visible) } } +bool Mesh::isVisible() const +{ + return _visible; +} + void Mesh::setTexture(const std::string& texPath) { auto tex = Director::getInstance()->getTextureCache()->addImage(texPath); @@ -180,13 +268,93 @@ void Mesh::setTexture(const std::string& texPath) void Mesh::setTexture(Texture2D* tex) { + // Texture must be saved for future use + // it doesn't matter if the material is already set or not + // This functionality is added for compatibility issues if (tex != _texture) { CC_SAFE_RETAIN(tex); CC_SAFE_RELEASE(_texture); _texture = tex; - bindMeshCommand(); } + + if (_material) { + auto technique = _material->_currentTechnique; + for(auto& pass: technique->_passes) + { + pass->setTexture(tex); + } + } + + bindMeshCommand(); +} + +Texture2D* Mesh::getTexture() const +{ + return _texture; +} + +void Mesh::setMaterial(Material* material) +{ + if (_material != material) { + CC_SAFE_RELEASE(_material); + _material = material; + CC_SAFE_RETAIN(_material); + } +} + +Material* Mesh::getMaterial() const +{ + return _material; +} + +void Mesh::draw(Renderer* renderer, float globalZOrder, const Mat4& transform, uint32_t flags, unsigned int lightMask, const Vec4& color, bool forceDepthWrite) +{ + if (! isVisible()) + return; + + bool isTransparent = (_isTransparent || color.w < 1.f); + float globalZ = isTransparent ? 0 : globalZOrder; + if (isTransparent) + flags |= Node::FLAGS_RENDER_AS_3D; + + + _meshCommand.init(globalZ, + _material, + getVertexBuffer(), + getIndexBuffer(), + getPrimitiveType(), + getIndexFormat(), + getIndexCount(), + transform, + flags); + + + if (isTransparent && !forceDepthWrite) + _material->getStateBlock()->setDepthWrite(false); + else + _material->getStateBlock()->setDepthWrite(true); + + + _meshCommand.setSkipBatching(isTransparent); + + // set default uniforms for Mesh + // 'u_color' and others + const auto& scene = Director::getInstance()->getRunningScene(); + auto technique = _material->_currentTechnique; + for(auto& pass : technique->_passes) + { + auto programState = pass->getGLProgramState(); + programState->setUniformVec4("u_color", color); + + if (_skin) + programState->setUniformVec4v("u_matrixPalette", _skin->getMatrixPalette(), (GLsizei)_skin->getMatrixPaletteSize()); + + if (scene && scene->getLights().size() > 0) + setLightUniforms(programState, scene, color, lightMask); + } + + renderer->addCommand(&_meshCommand); } void Mesh::setSkin(MeshSkin* skin) @@ -214,13 +382,25 @@ void Mesh::setMeshIndexData(MeshIndexData* subMesh) void Mesh::setGLProgramState(GLProgramState* glProgramState) { - if (_glProgramState != glProgramState) - { - CC_SAFE_RETAIN(glProgramState); - CC_SAFE_RELEASE(_glProgramState); - _glProgramState = glProgramState; - bindMeshCommand(); - } + // XXX create dummy texture + auto material = Material::createWithGLStateProgram(glProgramState); + setMaterial(material); + + // Was the texture set before teh GLProgramState ? Set it + if (_texture) + setTexture(_texture); + + if (_blendDirty) + setBlendFunc(_blend); + + bindMeshCommand(); +} + +GLProgramState* Mesh::getGLProgramState() const +{ + return _material ? + _material->_currentTechnique->_passes.at(0)->getGLProgramState() + : nullptr; } void Mesh::calculateAABB() @@ -262,25 +442,183 @@ void Mesh::calculateAABB() void Mesh::bindMeshCommand() { - if (_glProgramState && _meshIndexData && _texture) + if (_material && _meshIndexData) { - GLuint texID = _texture ? _texture->getName() : 0; - _meshCommand.genMaterialID(texID, _glProgramState, _meshIndexData->getVertexBuffer()->getVBO(), _meshIndexData->getIndexBuffer()->getVBO(), _blend); - _meshCommand.setCullFaceEnabled(true); - _meshCommand.setDepthTestEnabled(true); + auto pass = _material->_currentTechnique->_passes.at(0); + auto glprogramstate = pass->getGLProgramState(); + auto texture = pass->getTexture(); + auto textureid = texture ? texture->getName() : 0; + // XXX +// auto blend = pass->getStateBlock()->getBlendFunc(); + auto blend = BlendFunc::ALPHA_PREMULTIPLIED; + + _meshCommand.genMaterialID(textureid, glprogramstate, _meshIndexData->getVertexBuffer()->getVBO(), _meshIndexData->getIndexBuffer()->getVBO(), blend); + _material->getStateBlock()->setCullFace(true); + _material->getStateBlock()->setDepthTest(true); + } +} + +void Mesh::setLightUniforms(GLProgramState* glProgramState, Scene* scene, const Vec4& color, unsigned int lightmask) +{ + CCASSERT(glProgramState, "Invalid glProgramstate"); + CCASSERT(scene, "Invalid scene"); + + const auto& conf = Configuration::getInstance(); + int maxDirLight = conf->getMaxSupportDirLightInShader(); + int maxPointLight = conf->getMaxSupportPointLightInShader(); + int maxSpotLight = conf->getMaxSupportSpotLightInShader(); + auto &lights = scene->getLights(); + + + if (glProgramState->getVertexAttribsFlags() & (1 << GLProgram::VERTEX_ATTRIB_NORMAL)) + { + resetLightUniformValues(); + + GLint enabledDirLightNum = 0; + GLint enabledPointLightNum = 0; + GLint enabledSpotLightNum = 0; + Vec3 ambientColor; + for (const auto& light : lights) + { + bool useLight = light->isEnabled() && ((unsigned int)light->getLightFlag() & lightmask); + if (useLight) + { + float intensity = light->getIntensity(); + switch (light->getLightType()) + { + case LightType::DIRECTIONAL: + { + if(enabledDirLightNum < maxDirLight) + { + auto dirLight = static_cast(light); + Vec3 dir = dirLight->getDirectionInWorld(); + dir.normalize(); + const Color3B &col = dirLight->getDisplayedColor(); + s_dirLightUniformColorValues[enabledDirLightNum].set(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity); + s_dirLightUniformDirValues[enabledDirLightNum] = dir; + ++enabledDirLightNum; + } + + } + break; + case LightType::POINT: + { + if(enabledPointLightNum < maxPointLight) + { + auto pointLight = static_cast(light); + Mat4 mat= pointLight->getNodeToWorldTransform(); + const Color3B &col = pointLight->getDisplayedColor(); + s_pointLightUniformColorValues[enabledPointLightNum].set(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity); + s_pointLightUniformPositionValues[enabledPointLightNum].set(mat.m[12], mat.m[13], mat.m[14]); + s_pointLightUniformRangeInverseValues[enabledPointLightNum] = 1.0f / pointLight->getRange(); + ++enabledPointLightNum; + } + } + break; + case LightType::SPOT: + { + if(enabledSpotLightNum < maxSpotLight) + { + auto spotLight = static_cast(light); + Vec3 dir = spotLight->getDirectionInWorld(); + dir.normalize(); + Mat4 mat= light->getNodeToWorldTransform(); + const Color3B &col = spotLight->getDisplayedColor(); + s_spotLightUniformColorValues[enabledSpotLightNum].set(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity); + s_spotLightUniformPositionValues[enabledSpotLightNum].set(mat.m[12], mat.m[13], mat.m[14]); + s_spotLightUniformDirValues[enabledSpotLightNum] = dir; + s_spotLightUniformInnerAngleCosValues[enabledSpotLightNum] = spotLight->getCosInnerAngle(); + s_spotLightUniformOuterAngleCosValues[enabledSpotLightNum] = spotLight->getCosOuterAngle(); + s_spotLightUniformRangeInverseValues[enabledSpotLightNum] = 1.0f / spotLight->getRange(); + ++enabledSpotLightNum; + } + } + break; + case LightType::AMBIENT: + { + auto ambLight = static_cast(light); + const Color3B &col = ambLight->getDisplayedColor(); + ambientColor.add(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity); + } + break; + default: + break; + } + } + } + + if (0 < maxDirLight) + { + glProgramState->setUniformVec3v(s_dirLightUniformColorName, &s_dirLightUniformColorValues[0], s_dirLightUniformColorValues.size()); + glProgramState->setUniformVec3v(s_dirLightUniformDirName, &s_dirLightUniformDirValues[0], s_dirLightUniformDirValues.size()); + } + + if (0 < maxPointLight) + { + glProgramState->setUniformVec3v(s_pointLightUniformColorName, &s_pointLightUniformColorValues[0], s_pointLightUniformColorValues.size()); + glProgramState->setUniformVec3v(s_pointLightUniformPositionName, &s_pointLightUniformPositionValues[0], s_pointLightUniformPositionValues.size()); + glProgramState->setUniformFloatv(s_pointLightUniformRangeInverseName, &s_pointLightUniformRangeInverseValues[0], s_pointLightUniformRangeInverseValues.size()); + } + + if (0 < maxSpotLight) + { + glProgramState->setUniformVec3v(s_spotLightUniformColorName, &s_spotLightUniformColorValues[0], s_spotLightUniformColorValues.size()); + glProgramState->setUniformVec3v(s_spotLightUniformPositionName, &s_spotLightUniformPositionValues[0], s_spotLightUniformPositionValues.size()); + glProgramState->setUniformVec3v(s_spotLightUniformDirName, &s_spotLightUniformDirValues[0], s_spotLightUniformDirValues.size()); + glProgramState->setUniformFloatv(s_spotLightUniformInnerAngleCosName, &s_spotLightUniformInnerAngleCosValues[0], s_spotLightUniformInnerAngleCosValues.size()); + glProgramState->setUniformFloatv(s_spotLightUniformOuterAngleCosName, &s_spotLightUniformOuterAngleCosValues[0], s_spotLightUniformOuterAngleCosValues.size()); + glProgramState->setUniformFloatv(s_spotLightUniformRangeInverseName, &s_spotLightUniformRangeInverseValues[0], s_spotLightUniformRangeInverseValues.size()); + } + + glProgramState->setUniformVec3(s_ambientLightUniformColorName, Vec3(ambientColor.x, ambientColor.y, ambientColor.z)); + } + else // normal does not exist + { + Vec3 ambient(0.0f, 0.0f, 0.0f); + bool hasAmbient = false; + for (const auto& light : lights) + { + if (light->getLightType() == LightType::AMBIENT) + { + bool useLight = light->isEnabled() && ((unsigned int)light->getLightFlag() & lightmask); + if (useLight) + { + hasAmbient = true; + const Color3B &col = light->getDisplayedColor(); + ambient.x += col.r * light->getIntensity(); + ambient.y += col.g * light->getIntensity(); + ambient.z += col.b * light->getIntensity(); + } + } + } + if (hasAmbient) + { + ambient.x /= 255.f; ambient.y /= 255.f; ambient.z /= 255.f; + } + glProgramState->setUniformVec4("u_color", Vec4(color.x * ambient.x, color.y * ambient.y, color.z * ambient.z, color.w)); } } void Mesh::setBlendFunc(const BlendFunc &blendFunc) { - if(_blend.src != blendFunc.src || _blend.dst != blendFunc.dst) + // Blend must be saved for future use + // it doesn't matter if the material is already set or not + // This functionality is added for compatibility issues + if(_blend != blendFunc) { + _blendDirty = true; _blend = blendFunc; + } + + if (_material) { + _material->getStateBlock()->setBlendFunc(blendFunc); bindMeshCommand(); } } -const BlendFunc &Mesh::getBlendFunc() const + +const BlendFunc& Mesh::getBlendFunc() const { +// return _material->_currentTechnique->_passes.at(0)->getBlendFunc(); return _blend; } @@ -303,5 +641,4 @@ GLuint Mesh::getIndexBuffer() const { return _meshIndexData->getIndexBuffer()->getVBO(); } - NS_CC_END diff --git a/cocos/3d/CCMesh.h b/cocos/3d/CCMesh.h index 5821fe0bec..9bc1afb95c 100644 --- a/cocos/3d/CCMesh.h +++ b/cocos/3d/CCMesh.h @@ -46,6 +46,10 @@ class MeshSkin; class MeshIndexData; class GLProgramState; class GLProgram; +class Material; +class Renderer; +class Scene; + /** * @brief Mesh: contains ref to index buffer, GLProgramState, texture, skin, blend function, aabb and so on */ @@ -92,11 +96,11 @@ public: /**texture getter and setter*/ void setTexture(const std::string& texPath); void setTexture(Texture2D* tex); - Texture2D* getTexture() const { return _texture; } + Texture2D* getTexture() const; /**visible getter and setter*/ void setVisible(bool visible); - bool isVisible() const { return _visible; } + bool isVisible() const; /** * skin getter @@ -117,7 +121,7 @@ public: * * @lua NA */ - GLProgramState* getGLProgramState() const { return _glProgramState; } + GLProgramState* getGLProgramState() const; /**name getter */ const std::string& getName() const { return _name; } @@ -153,21 +157,19 @@ public: /**get AABB*/ const AABB& getAABB() const { return _aabb; } -CC_CONSTRUCTOR_ACCESS: - - Mesh(); - virtual ~Mesh(); - - /** - * Get the default GL program. - */ - GLProgram* getDefaultGLProgram(bool textured); - - /** - * Set the default GL program. + /** Sets a new GLProgramState for the Mesh + * A new Material will be created for it */ void setGLProgramState(GLProgramState* glProgramState); - + + /** Sets a new Material to the Mesh */ + void setMaterial(Material* material); + + /** Returns the Material being used by the Mesh */ + Material* getMaterial() const; + + void draw(Renderer* renderer, float globalZ, const Mat4& transform, uint32_t flags, unsigned int lightMask, const Vec4& color, bool forceDepthWrite); + /** * Get the MeshCommand. */ @@ -186,22 +188,29 @@ CC_CONSTRUCTOR_ACCESS: */ void calculateAABB(); - /** - * Bind to the MeshCommand - */ - void bindMeshCommand(); + +CC_CONSTRUCTOR_ACCESS: + + Mesh(); + virtual ~Mesh(); + protected: - Texture2D* _texture; //texture that submesh is using - MeshSkin* _skin; //skin - bool _visible; // is the submesh visible - bool _isTransparent; // is this mesh transparent, it is a property of material in fact + void setLightUniforms(GLProgramState* glProgramState, Scene* scene, const Vec4& color, unsigned int lightmask); + void bindMeshCommand(); + + Texture2D* _texture; //texture that submesh is using + MeshSkin* _skin; //skin + bool _visible; // is the submesh visible + bool _isTransparent; // is this mesh transparent, it is a property of material in fact - std::string _name; - MeshIndexData* _meshIndexData; - GLProgramState* _glProgramState; - MeshCommand _meshCommand; - BlendFunc _blend; - AABB _aabb; + std::string _name; + MeshCommand _meshCommand; + MeshIndexData* _meshIndexData; + GLProgramState* _glProgramState; + BlendFunc _blend; + bool _blendDirty; + Material* _material; + AABB _aabb; std::function _visibleChanged; }; diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index 204cdd7f05..91531a147b 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -41,6 +41,9 @@ #include "renderer/CCRenderer.h" #include "renderer/CCGLProgramState.h" #include "renderer/CCGLProgramCache.h" +#include "renderer/CCMaterial.h" +#include "renderer/CCTechnique.h" +#include "renderer/CCPass.h" #include "deprecated/CCString.h" // For StringUtils::format @@ -63,8 +66,7 @@ Sprite3D* Sprite3D::create() Sprite3D* Sprite3D::create(const std::string &modelPath) { - if (modelPath.length() < 4) - CCASSERT(false, "invalid filename for Sprite3D"); + CCASSERT(modelPath.length() >= 4, "invalid filename for Sprite3D"); auto sprite = new (std::nothrow) Sprite3D(); if (sprite && sprite->initWithFile(modelPath)) @@ -201,7 +203,9 @@ bool Sprite3D::loadFromCache(const std::string& path) } for (ssize_t i = 0; i < _meshes.size(); i++) { - _meshes.at(i)->setGLProgramState(spritedata->glProgramStates.at(i)); + // cloning is needed in order to have one state per sprite + auto glstate = spritedata->glProgramStates.at(i); + _meshes.at(i)->setGLProgramState(glstate->clone()); } return true; } @@ -277,7 +281,7 @@ bool Sprite3D::initWithFile(const std::string &path) MeshDatas* meshdatas = new (std::nothrow) MeshDatas(); MaterialDatas* materialdatas = new (std::nothrow) MaterialDatas(); - NodeDatas* nodeDatas = new (std::nothrow) NodeDatas(); + NodeDatas* nodeDatas = new (std::nothrow) NodeDatas(); if (loadFromFile(path, nodeDatas, meshdatas, materialdatas)) { if (initFrom(*nodeDatas, *meshdatas, *materialdatas)) @@ -293,6 +297,7 @@ bool Sprite3D::initWithFile(const std::string &path) Sprite3DCache::getInstance()->addSprite3DData(path, data); CC_SAFE_DELETE(meshdatas); + _contentSize = getBoundingBox().size; return true; } } @@ -336,22 +341,22 @@ bool Sprite3D::initFrom(const NodeDatas& nodeDatas, const MeshDatas& meshdatas, return true; } -Sprite3D* Sprite3D::createSprite3DNode(NodeData* nodedata,ModelData* modeldata,const MaterialDatas& matrialdatas) +Sprite3D* Sprite3D::createSprite3DNode(NodeData* nodedata,ModelData* modeldata,const MaterialDatas& materialdatas) { auto sprite = new (std::nothrow) Sprite3D(); if (sprite) { sprite->setName(nodedata->id); auto mesh = Mesh::create(nodedata->id, getMeshIndexData(modeldata->subMeshId)); - if (modeldata->matrialId == "" && matrialdatas.materials.size()) + if (modeldata->matrialId == "" && materialdatas.materials.size()) { - const NTextureData* textureData = matrialdatas.materials[0].getTextureData(NTextureData::Usage::Diffuse); + const NTextureData* textureData = materialdatas.materials[0].getTextureData(NTextureData::Usage::Diffuse); if (!textureData->filename.empty()) mesh->setTexture(textureData->filename); } else { - const NMaterialData* materialData=matrialdatas.getMaterialData(modeldata->matrialId); + const NMaterialData* materialData=materialdatas.getMaterialData(modeldata->matrialId); if(materialData) { const NTextureData* textureData = materialData->getTextureData(NTextureData::Usage::Diffuse); @@ -391,13 +396,13 @@ Sprite3D* Sprite3D::createSprite3DNode(NodeData* nodedata,ModelData* modeldata,c } return sprite; } -void Sprite3D::createAttachSprite3DNode(NodeData* nodedata,const MaterialDatas& matrialdatas) +void Sprite3D::createAttachSprite3DNode(NodeData* nodedata,const MaterialDatas& materialdatas) { for(const auto& it : nodedata->modelNodeDatas) { if(it && getAttachNode(nodedata->id)) { - auto sprite = createSprite3DNode(nodedata,it,matrialdatas); + auto sprite = createSprite3DNode(nodedata,it,materialdatas); if (sprite) { getAttachNode(nodedata->id)->addChild(sprite); @@ -406,22 +411,45 @@ void Sprite3D::createAttachSprite3DNode(NodeData* nodedata,const MaterialDatas& } for(const auto& it : nodedata->children) { - createAttachSprite3DNode(it,matrialdatas); + createAttachSprite3DNode(it,materialdatas); } } + +void Sprite3D::setMaterial(Material *material) +{ + setMaterial(material, -1); +} + +void Sprite3D::setMaterial(Material *material, int meshIndex) +{ + CCASSERT(material, "Invalid Material"); + CCASSERT(meshIndex == -1 || (meshIndex >=0 && meshIndex < _meshes.size()), "Invalid meshIndex"); + + if (meshIndex == -1) + { + for(auto& mesh: _meshes) + { + mesh->setMaterial(material); + } + } + else + { + _meshes.at(meshIndex)->setMaterial(material); + } +} + void Sprite3D::genGLProgramState(bool useLight) { _shaderUsingLight = useLight; std::unordered_map glProgramestates; - for(auto& mesh : _meshVertexDatas) + for(auto& meshVertexData : _meshVertexDatas) { - bool textured = mesh->hasVertexAttrib(GLProgram::VERTEX_ATTRIB_TEX_COORD); - bool hasSkin = mesh->hasVertexAttrib(GLProgram::VERTEX_ATTRIB_BLEND_INDEX) - && mesh->hasVertexAttrib(GLProgram::VERTEX_ATTRIB_BLEND_WEIGHT); - bool hasNormal = mesh->hasVertexAttrib(GLProgram::VERTEX_ATTRIB_NORMAL); - - GLProgram* glProgram = nullptr; + bool textured = meshVertexData->hasVertexAttrib(GLProgram::VERTEX_ATTRIB_TEX_COORD); + bool hasSkin = meshVertexData->hasVertexAttrib(GLProgram::VERTEX_ATTRIB_BLEND_INDEX) + && meshVertexData->hasVertexAttrib(GLProgram::VERTEX_ATTRIB_BLEND_WEIGHT); + bool hasNormal = meshVertexData->hasVertexAttrib(GLProgram::VERTEX_ATTRIB_NORMAL); + const char* shader = nullptr; if(textured) { @@ -444,33 +472,40 @@ void Sprite3D::genGLProgramState(bool useLight) { shader = GLProgram::SHADER_3D_POSITION; } - if (shader) - glProgram = GLProgramCache::getInstance()->getGLProgram(shader); - - auto programstate = GLProgramState::create(glProgram); + + CCASSERT(shader, "Couldn't find shader for sprite"); + + auto glProgram = GLProgramCache::getInstance()->getGLProgram(shader); + auto glprogramstate = GLProgramState::create(glProgram); + long offset = 0; - auto attributeCount = mesh->getMeshVertexAttribCount(); + auto attributeCount = meshVertexData->getMeshVertexAttribCount(); for (auto k = 0; k < attributeCount; k++) { - auto meshattribute = mesh->getMeshVertexAttrib(k); - programstate->setVertexAttribPointer(s_attributeNames[meshattribute.vertexAttrib], + auto meshattribute = meshVertexData->getMeshVertexAttrib(k); + glprogramstate->setVertexAttribPointer(s_attributeNames[meshattribute.vertexAttrib], meshattribute.size, meshattribute.type, GL_FALSE, - mesh->getVertexBuffer()->getSizePerVertex(), + meshVertexData->getVertexBuffer()->getSizePerVertex(), (GLvoid*)offset); offset += meshattribute.attribSizeBytes; } - glProgramestates[mesh] = programstate; + glProgramestates[meshVertexData] = glprogramstate; } - for (auto& it : _meshes) { - auto glProgramState = glProgramestates[it->getMeshIndexData()->getMeshVertexData()]; - it->setGLProgramState(glProgramState); + for (auto& mesh : _meshes) { + auto glProgramState = glProgramestates[mesh->getMeshIndexData()->getMeshVertexData()]; + + // hack to prevent cloning the very first time + if (glProgramState->getReferenceCount() == 1) + mesh->setGLProgramState(glProgramState); + else + mesh->setGLProgramState(glProgramState->clone()); } } -void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& matrialdatas, bool singleSprite) +void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& materialdatas, bool singleSprite) { Node* node=nullptr; for(const auto& it : nodedata->modelNodeDatas) @@ -479,7 +514,7 @@ void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& m { if(it->bones.size() > 0 || singleSprite) { - if(singleSprite) + if(singleSprite && root!=nullptr) root->setName(nodedata->id); auto mesh = Mesh::create(nodedata->id, getMeshIndexData(it->subMeshId)); if(mesh) @@ -492,14 +527,14 @@ void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& m } mesh->_visibleChanged = std::bind(&Sprite3D::onAABBDirty, this); - if (it->matrialId == "" && matrialdatas.materials.size()) + if (it->matrialId == "" && materialdatas.materials.size()) { - const NTextureData* textureData = matrialdatas.materials[0].getTextureData(NTextureData::Usage::Diffuse); + const NTextureData* textureData = materialdatas.materials[0].getTextureData(NTextureData::Usage::Diffuse); mesh->setTexture(textureData->filename); } else { - const NMaterialData* materialData=matrialdatas.getMaterialData(it->matrialId); + const NMaterialData* materialData=materialdatas.getMaterialData(it->matrialId); if(materialData) { const NTextureData* textureData = materialData->getTextureData(NTextureData::Usage::Diffuse); @@ -508,7 +543,7 @@ void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& m auto tex = Director::getInstance()->getTextureCache()->addImage(textureData->filename); if(tex) { - Texture2D::TexParams texParams; + Texture2D::TexParams texParams; texParams.minFilter = GL_LINEAR; texParams.magFilter = GL_LINEAR; texParams.wrapS = textureData->wrapS; @@ -536,7 +571,7 @@ void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& m } else { - auto sprite = createSprite3DNode(nodedata,it,matrialdatas); + auto sprite = createSprite3DNode(nodedata,it,materialdatas); if (sprite) { if(root) @@ -574,7 +609,7 @@ void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& m } for(const auto& it : nodedata->children) { - createNode(it,node, matrialdatas, nodedata->children.size() == 1); + createNode(it,node, materialdatas, nodedata->children.size() == 1); } } @@ -646,25 +681,6 @@ void Sprite3D::removeAllAttachNode() _attachments.clear(); } -//Generate a dummy texture when the texture file is missing -static Texture2D * getDummyTexture() -{ - auto texture = Director::getInstance()->getTextureCache()->getTextureForKey("/dummyTexture"); - if(!texture) - { -#ifdef NDEBUG - unsigned char data[] ={0,0,0,0};//1*1 transparent picture -#else - unsigned char data[] ={255,0,0,255};//1*1 red picture -#endif - Image * image =new (std::nothrow) Image(); - image->initWithRawData(data,sizeof(data),1,1,sizeof(unsigned char)); - texture=Director::getInstance()->getTextureCache()->addImage(image,"/dummyTexture"); - image->release(); - } - return texture; -} - void Sprite3D::visit(cocos2d::Renderer *renderer, const cocos2d::Mat4 &parentTransform, uint32_t parentFlags) { // quick return if not visible. children won't be drawn. @@ -742,50 +758,16 @@ void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) genGLProgramState(usingLight); } - int i = 0; - for (auto& mesh : _meshes) { - if (!mesh->isVisible()) - { - i++; - continue; - } - auto programstate = mesh->getGLProgramState(); - auto& meshCommand = mesh->getMeshCommand(); + for (auto& mesh : _meshes) + { + mesh->draw(renderer, + _globalZOrder, + transform, + flags, + _lightMask, + Vec4(color.r, color.g, color.b, color.a), + _forceDepthWrite); - GLuint textureID = 0; - if(mesh->getTexture()) - { - textureID = mesh->getTexture()->getName(); - }else - { //let the mesh use a dummy texture instead of the missing or crashing texture file - auto texture = getDummyTexture(); - mesh->setTexture(texture); - textureID = texture->getName(); - } - - bool isTransparent = (mesh->_isTransparent || color.a < 1.f); - float globalZ = isTransparent ? 0 : _globalZOrder; - if (isTransparent) - flags |= Node::FLAGS_RENDER_AS_3D; - - meshCommand.init(globalZ, textureID, programstate, _blend, mesh->getVertexBuffer(), mesh->getIndexBuffer(), mesh->getPrimitiveType(), mesh->getIndexFormat(), mesh->getIndexCount(), transform, flags); - - meshCommand.setLightMask(_lightMask); - - auto skin = mesh->getSkin(); - if (skin) - { - meshCommand.setMatrixPaletteSize((int)skin->getMatrixPaletteSize()); - meshCommand.setMatrixPalette(skin->getMatrixPalette()); - } - //support tint and fade - meshCommand.setDisplayColor(Vec4(color.r, color.g, color.b, color.a)); - if (_forceDepthWrite) - { - meshCommand.setDepthWriteEnabled(true); - } - meshCommand.setTransparent(isTransparent); - renderer->addCommand(&meshCommand); } } @@ -807,9 +789,9 @@ void Sprite3D::setBlendFunc(const BlendFunc &blendFunc) if(_blend.src != blendFunc.src || _blend.dst != blendFunc.dst) { _blend = blendFunc; - for(auto& state : _meshes) + for(auto& mesh : _meshes) { - state->setBlendFunc(blendFunc); + mesh->setBlendFunc(blendFunc); } } } @@ -880,14 +862,16 @@ Rect Sprite3D::getBoundingBox() const void Sprite3D::setCullFace(GLenum cullFace) { for (auto& it : _meshes) { - it->getMeshCommand().setCullFace(cullFace); + it->getMaterial()->getStateBlock()->setCullFaceSide((RenderState::CullFaceSide)cullFace); +// it->getMeshCommand().setCullFace(cullFace); } } void Sprite3D::setCullFaceEnabled(bool enable) { for (auto& it : _meshes) { - it->getMeshCommand().setCullFaceEnabled(enable); + it->getMaterial()->getStateBlock()->setCullFace(enable); +// it->getMeshCommand().setCullFaceEnabled(enable); } } diff --git a/cocos/3d/CCSprite3D.h b/cocos/3d/CCSprite3D.h index 147b7c43f8..586e0cfff3 100644 --- a/cocos/3d/CCSprite3D.h +++ b/cocos/3d/CCSprite3D.h @@ -177,6 +177,18 @@ public: /**draw*/ virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; + /** Adds a new material to the sprite. + The Material will be applied to all the meshes that belong to the sprite. + Internally it will call `setMaterial(material,-1)` + */ + void setMaterial(Material* material); + + /** Adds a new material to a particular mesh of the sprite. + meshIndex is the mesh that will be applied to. + if meshIndex == -1, then it will be applied to all the meshes that belong to the sprite. + */ + void setMaterial(Material* material, int meshIndex); + CC_CONSTRUCTOR_ACCESS: Sprite3D(); @@ -210,7 +222,7 @@ CC_CONSTRUCTOR_ACCESS: /**get MeshIndexData by Id*/ MeshIndexData* getMeshIndexData(const std::string& indexId) const; - void addMesh(Mesh* mesh); + void addMesh(Mesh* mesh); void onAABBDirty() { _aabbDirty = true; } diff --git a/cocos/3d/CCTerrain.cpp b/cocos/3d/CCTerrain.cpp index 3686b5d83d..8293ff2ef7 100644 --- a/cocos/3d/CCTerrain.cpp +++ b/cocos/3d/CCTerrain.cpp @@ -262,7 +262,7 @@ bool Terrain::initHeightMap(const char * heightMap) Terrain::Terrain() { _alphaMap = nullptr; -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) auto _backToForegroundListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom*) { @@ -482,7 +482,7 @@ Terrain::~Terrain() glDeleteBuffers(1,&(_chunkLodIndicesSkirtSet[i]._chunkIndices._indices)); } -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundListener); #endif } @@ -604,6 +604,20 @@ Terrain::QuadTree * Terrain::getQuadTree() return _quadRoot; } + +std::vector Terrain::getHeightData() const +{ + std::vector data; + data.resize(_imageWidth * _imageHeight); + for (int i = 0; i < _imageHeight; i++) { + for (int j = 0; j < _imageWidth; j++) { + int idx = i * _imageWidth + j; + data[idx] = (_vertices[idx]._position.y); + } + } + return data; +} + void Terrain::setAlphaMap(cocos2d::Texture2D * newAlphaMapTexture) { _alphaMap->release(); @@ -1495,4 +1509,5 @@ Terrain::DetailMap::DetailMap() _detailMapSrc = ""; _detailMapSize = 35; } + NS_CC_END diff --git a/cocos/3d/CCTerrain.h b/cocos/3d/CCTerrain.h index c19685dd21..c348ecb22b 100644 --- a/cocos/3d/CCTerrain.h +++ b/cocos/3d/CCTerrain.h @@ -384,6 +384,17 @@ public: QuadTree * getQuadTree(); void reload(); + + /** + * get the terrain's size + */ + Size getTerrainSize() const { return Size(_imageWidth, _imageHeight); } + + /** + * get the terrain's height data + */ + std::vector getHeightData() const; + protected: Terrain(); @@ -458,7 +469,7 @@ protected: GLint _alphaMapLocation; GLint _alphaIsHasAlphaMapLocation; GLint _detailMapSizeLocation[4]; -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) EventListenerCustom* _backToForegroundListener; #endif }; diff --git a/cocos/3d/CMakeLists.txt b/cocos/3d/CMakeLists.txt index b150f2c08e..6d7df05657 100644 --- a/cocos/3d/CMakeLists.txt +++ b/cocos/3d/CMakeLists.txt @@ -9,6 +9,7 @@ set(COCOS_3D_SRC 3d/CCAnimate3D.cpp 3d/CCAnimation3D.cpp 3d/CCAttachNode.cpp + 3d/CCBillBoard.cpp 3d/CCBundle3D.cpp 3d/CCBundleReader.cpp 3d/CCFrustum.cpp @@ -20,11 +21,10 @@ set(COCOS_3D_SRC 3d/CCPlane.cpp 3d/CCRay.cpp 3d/CCSkeleton3D.cpp + 3d/CCSkybox.cpp 3d/CCSprite3D.cpp 3d/CCSprite3DMaterial.cpp - 3d/CCBillBoard.cpp - 3d/CCSkybox.cpp - 3d/CCTextureCube.cpp 3d/CCTerrain.cpp + 3d/CCTextureCube.cpp ) diff --git a/cocos/Android.mk b/cocos/Android.mk index 41b9335d57..ce6a61eba0 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -37,6 +37,8 @@ cocos2d.cpp \ 2d/CCComponentContainer.cpp \ 2d/CCDrawNode.cpp \ 2d/CCDrawingPrimitives.cpp \ +2d/CCFastTMXLayer.cpp \ +2d/CCFastTMXTiledMap.cpp \ 2d/CCFont.cpp \ 2d/CCFontAtlas.cpp \ 2d/CCFontAtlasCache.cpp \ @@ -71,14 +73,9 @@ cocos2d.cpp \ 2d/CCSpriteBatchNode.cpp \ 2d/CCSpriteFrame.cpp \ 2d/CCSpriteFrameCache.cpp \ -2d/MarchingSquare.cpp \ -2d/SpritePolygon.cpp \ -2d/SpritePolygonCache.cpp \ 2d/CCTMXLayer.cpp \ -2d/CCFastTMXLayer.cpp \ 2d/CCTMXObjectGroup.cpp \ 2d/CCTMXTiledMap.cpp \ -2d/CCFastTMXTiledMap.cpp \ 2d/CCTMXXMLParser.cpp \ 2d/CCTextFieldTTF.cpp \ 2d/CCTileMapAtlas.cpp \ @@ -86,17 +83,20 @@ cocos2d.cpp \ 2d/CCTransitionPageTurn.cpp \ 2d/CCTransitionProgress.cpp \ 2d/CCTweenFunction.cpp \ +2d/MarchingSquare.cpp \ +2d/SpritePolygon.cpp \ +2d/SpritePolygonCache.cpp \ 3d/CCFrustum.cpp \ 3d/CCPlane.cpp \ -platform/CCGLView.cpp \ platform/CCFileUtils.cpp \ +platform/CCGLView.cpp \ +platform/CCImage.cpp \ platform/CCSAXParser.cpp \ platform/CCThread.cpp \ -platform/CCImage.cpp \ +$(MATHNEONFILE) \ math/CCAffineTransform.cpp \ math/CCGeometry.cpp \ math/CCVertex.cpp \ -$(MATHNEONFILE) \ math/Mat4.cpp \ math/Quaternion.cpp \ math/TransformUtils.cpp \ @@ -107,19 +107,21 @@ base/CCAsyncTaskPool.cpp \ base/CCAutoreleasePool.cpp \ base/CCConfiguration.cpp \ base/CCConsole.cpp \ +base/CCController-android.cpp \ +base/CCController.cpp \ base/CCData.cpp \ base/CCDataVisitor.cpp \ base/CCDirector.cpp \ base/CCEvent.cpp \ base/CCEventAcceleration.cpp \ +base/CCEventController.cpp \ base/CCEventCustom.cpp \ base/CCEventDispatcher.cpp \ base/CCEventFocus.cpp \ base/CCEventKeyboard.cpp \ -base/CCEventController.cpp \ base/CCEventListener.cpp \ -base/CCEventListenerController.cpp \ base/CCEventListenerAcceleration.cpp \ +base/CCEventListenerController.cpp \ base/CCEventListenerCustom.cpp \ base/CCEventListenerFocus.cpp \ base/CCEventListenerKeyboard.cpp \ @@ -130,32 +132,30 @@ base/CCEventTouch.cpp \ base/CCIMEDispatcher.cpp \ base/CCNS.cpp \ base/CCProfiling.cpp \ -base/ccRandom.cpp \ base/CCRef.cpp \ base/CCScheduler.cpp \ base/CCScriptSupport.cpp \ base/CCTouch.cpp \ -base/CCUserDefault.cpp \ base/CCUserDefault-android.cpp \ +base/CCUserDefault.cpp \ base/CCValue.cpp \ +base/ObjectFactory.cpp \ base/TGAlib.cpp \ base/ZipUtils.cpp \ +base/allocator/CCAllocatorDiagnostics.cpp \ +base/allocator/CCAllocatorGlobal.cpp \ +base/allocator/CCAllocatorGlobalNewDelete.cpp \ base/atitc.cpp \ base/base64.cpp \ base/ccCArray.cpp \ base/ccFPSImages.c \ +base/ccRandom.cpp \ base/ccTypes.cpp \ base/ccUTF8.cpp \ base/ccUtils.cpp \ base/etc1.cpp \ base/pvr.cpp \ base/s3tc.cpp \ -base/CCController.cpp \ -base/CCController-android.cpp \ -base/allocator/CCAllocatorDiagnostics.cpp \ -base/allocator/CCAllocatorGlobal.cpp \ -base/allocator/CCAllocatorGlobalNewDelete.cpp \ -base/ObjectFactory.cpp \ renderer/CCBatchCommand.cpp \ renderer/CCCustomCommand.cpp \ renderer/CCGLProgram.cpp \ @@ -163,31 +163,43 @@ renderer/CCGLProgramCache.cpp \ renderer/CCGLProgramState.cpp \ renderer/CCGLProgramStateCache.cpp \ renderer/CCGroupCommand.cpp \ -renderer/CCQuadCommand.cpp \ +renderer/CCMaterial.cpp \ renderer/CCMeshCommand.cpp \ +renderer/CCPass.cpp \ +renderer/CCPrimitive.cpp \ +renderer/CCPrimitiveCommand.cpp \ +renderer/CCQuadCommand.cpp \ renderer/CCRenderCommand.cpp \ +renderer/CCRenderState.cpp \ renderer/CCRenderer.cpp \ +renderer/CCTechnique.cpp \ renderer/CCTexture2D.cpp \ renderer/CCTextureAtlas.cpp \ renderer/CCTextureCache.cpp \ -renderer/ccGLStateCache.cpp \ -renderer/ccShaders.cpp \ +renderer/CCTrianglesCommand.cpp \ renderer/CCVertexIndexBuffer.cpp \ renderer/CCVertexIndexData.cpp \ -renderer/CCPrimitive.cpp \ -renderer/CCPrimitiveCommand.cpp \ -renderer/CCTrianglesCommand.cpp \ +renderer/ccGLStateCache.cpp \ +renderer/ccShaders.cpp \ deprecated/CCArray.cpp \ +deprecated/CCDeprecated.cpp \ +deprecated/CCDictionary.cpp \ +deprecated/CCNotificationCenter.cpp \ deprecated/CCSet.cpp \ deprecated/CCString.cpp \ -deprecated/CCDictionary.cpp \ -deprecated/CCDeprecated.cpp \ -deprecated/CCNotificationCenter.cpp \ physics/CCPhysicsBody.cpp \ physics/CCPhysicsContact.cpp \ physics/CCPhysicsJoint.cpp \ physics/CCPhysicsShape.cpp \ physics/CCPhysicsWorld.cpp \ +physics3d/CCPhysics3D.cpp \ +physics3d/CCPhysics3DWorld.cpp \ +physics3d/CCPhysics3DComponent.cpp \ +physics3d/CCPhysics3DDebugDrawer.cpp \ +physics3d/CCPhysics3DObject.cpp \ +physics3d/CCPhysics3DShape.cpp \ +physics3d/CCPhysicsSprite3D.cpp \ +physics3d/CCPhysics3DConstraint.cpp \ ../external/ConvertUTF/ConvertUTFWrapper.cpp \ ../external/ConvertUTF/ConvertUTF.c \ ../external/tinyxml2/tinyxml2.cpp \ @@ -219,7 +231,6 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../external/poly2tri/sweep LOCAL_C_INCLUDES := $(LOCAL_PATH) \ - $(LOCAL_PATH)/. \ $(LOCAL_PATH)/platform \ $(LOCAL_PATH)/../external \ $(LOCAL_PATH)/../external/tinyxml2 \ @@ -269,6 +280,7 @@ LOCAL_STATIC_LIBRARIES += cocos3d_static LOCAL_STATIC_LIBRARIES += spine_static LOCAL_STATIC_LIBRARIES += cocos_network_static LOCAL_STATIC_LIBRARIES += audioengine_static +LOCAL_STATIC_LIBRARIES += bullet_static include $(BUILD_STATIC_LIBRARY) #============================================================== @@ -289,6 +301,7 @@ $(call import-module,network) $(call import-module,ui) $(call import-module,extensions) $(call import-module,Box2D) +$(call import-module,bullet) $(call import-module,curl/prebuilt/android) $(call import-module,websockets/prebuilt/android) $(call import-module,flatbuffers) diff --git a/cocos/CMakeLists.txt b/cocos/CMakeLists.txt index b7dd840667..3a4e88b453 100644 --- a/cocos/CMakeLists.txt +++ b/cocos/CMakeLists.txt @@ -35,6 +35,7 @@ include(2d/CMakeLists.txt) include(3d/CMakeLists.txt) include(platform/CMakeLists.txt) include(physics/CMakeLists.txt) +include(physics3d/CMakeLists.txt) include(math/CMakeLists.txt) include(renderer/CMakeLists.txt) include(base/CMakeLists.txt) @@ -67,6 +68,7 @@ set(COCOS_SRC cocos2d.cpp ${COCOS_3D_SRC} ${COCOS_PLATFORM_SRC} ${COCOS_PHYSICS_SRC} + ${COCOS_PHYSICS3D_SRC} ${COCOS_MATH_SRC} ${COCOS_RENDERER_SRC} ${COCOS_BASE_SRC} @@ -150,6 +152,10 @@ if(USE_BOX2D) cocos_use_pkg(cocos2d Box2D) endif() +if(USE_BULLET) + cocos_use_pkg(cocos2d BULLET) +endif() + set_target_properties(cocos2d PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" diff --git a/cocos/audio/android/ccdandroidUtils.cpp b/cocos/audio/android/ccdandroidUtils.cpp index f167bbe1c6..9dbb3fe8ac 100644 --- a/cocos/audio/android/ccdandroidUtils.cpp +++ b/cocos/audio/android/ccdandroidUtils.cpp @@ -23,11 +23,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "ccdandroidUtils.h" -#include "cocos2d.h" #include #include #include "jni/JniHelper.h" +#include "platform/CCFileUtils.h" + USING_NS_CC; diff --git a/cocos/audio/win32/AudioCache.cpp b/cocos/audio/win32/AudioCache.cpp index caa838c764..4f9698e1fe 100644 --- a/cocos/audio/win32/AudioCache.cpp +++ b/cocos/audio/win32/AudioCache.cpp @@ -29,6 +29,7 @@ #include #include #include "base/CCConsole.h" +#include "platform/CCFileUtils.h" #include "mpg123.h" #include "vorbis/codec.h" #include "vorbis/vorbisfile.h" @@ -96,8 +97,9 @@ void AudioCache::readDataTask() case FileFormat::OGG: { vf = new OggVorbis_File; - if (ov_fopen(_fileFullPath.c_str(), vf)){ - log("Input does not appear to be an Ogg bitstream.\n"); + int openCode; + if (openCode = ov_fopen(FileUtils::getInstance()->getSuitableFOpen(_fileFullPath).c_str(), vf)){ + log("Input does not appear to be an Ogg bitstream: %s. Code: 0x%x\n", _fileFullPath.c_str(), openCode); goto ExitThread; } diff --git a/cocos/audio/win32/AudioPlayer.cpp b/cocos/audio/win32/AudioPlayer.cpp index 58d75ab74e..e7225e5f04 100644 --- a/cocos/audio/win32/AudioPlayer.cpp +++ b/cocos/audio/win32/AudioPlayer.cpp @@ -27,6 +27,7 @@ #include "AudioPlayer.h" #include "AudioCache.h" #include "base/CCConsole.h" +#include "platform/CCFileUtils.h" #include "mpg123.h" #include "vorbis/codec.h" #include "vorbis/vorbisfile.h" @@ -162,8 +163,9 @@ void AudioPlayer::rotateBufferThread(int offsetFrame) case AudioCache::FileFormat::OGG: { vorbisFile = new OggVorbis_File; - if (ov_fopen(_audioCache->_fileFullPath.c_str(), vorbisFile)){ - log("Input does not appear to be an Ogg bitstream.\n"); + int openCode; + if (openCode = ov_fopen(FileUtils::getInstance()->getSuitableFOpen(_audioCache->_fileFullPath).c_str(), vorbisFile)){ + log("Input does not appear to be an Ogg bitstream: %s. Code: 0x%x\n", _audioCache->_fileFullPath.c_str(), openCode); goto ExitBufferThread; } if (offsetFrame != 0) { diff --git a/cocos/base/CCConsole.cpp b/cocos/base/CCConsole.cpp index dfdab8199f..b72d301d4e 100644 --- a/cocos/base/CCConsole.cpp +++ b/cocos/base/CCConsole.cpp @@ -43,7 +43,7 @@ #include "platform/win32/inet_pton_mingw.h" #endif #define bzero(a, b) memset(a, 0, b); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) #include "inet_ntop_winrt.h" #include "inet_pton_winrt.h" #include "CCWinRTUtils.h" @@ -71,7 +71,7 @@ NS_CC_BEGIN extern const char* cocos2dVersion(void); -//TODO: these general utils should be in a seperate class +//TODO: these general utils should be in a separate class // // Trimming functions were taken from: http://stackoverflow.com/a/217605 // @@ -243,7 +243,7 @@ static void _log(const char *format, va_list args) #if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID __android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", "%s", buf); -#elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 +#elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT WCHAR wszBuf[MAX_LOG_LENGTH] = {0}; MultiByteToWideChar(CP_UTF8, 0, buf, -1, wszBuf, sizeof(wszBuf)); OutputDebugStringW(wszBuf); @@ -330,7 +330,6 @@ Console::Console() { _commands[commands[i].name] = commands[i]; } - _writablePath = FileUtils::getInstance()->getWritablePath(); } Console::~Console() @@ -352,7 +351,7 @@ bool Console::listenOnTCP(int port) hints.ai_family = AF_INET; // AF_UNSPEC: Do we need IPv6 ? hints.ai_socktype = SOCK_STREAM; -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) WSADATA wsaData; n = WSAStartup(MAKEWORD(2, 2),&wsaData); @@ -394,7 +393,7 @@ bool Console::listenOnTCP(int port) break; /* success */ /* bind error, close and try next one */ -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) closesocket(listenfd); #else close(listenfd); @@ -481,7 +480,7 @@ void Console::commandExit(int fd, const std::string &args) { FD_CLR(fd, &_read_set); _fds.erase(std::remove(_fds.begin(), _fds.end(), fd), _fds.end()); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) closesocket(fd); #else close(fd); @@ -870,9 +869,10 @@ void Console::commandUpload(int fd) } *ptr = 0; - std::string filepath = _writablePath + std::string(buf); + static std::string writablePath = FileUtils::getInstance()->getWritablePath(); + std::string filepath = writablePath + std::string(buf); - FILE* fp = fopen(filepath.c_str(), "wb"); + FILE* fp = fopen(FileUtils::getInstance()->getSuitableFOpen(filepath).c_str(), "wb"); if(!fp) { const char err[] = "can't create file!\n"; @@ -1124,7 +1124,7 @@ void Console::loop() //receive a SIGPIPE, which will cause linux system shutdown the sending process. //Add this ioctl code to check if the socket has been closed by peer. -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) u_long n = 0; ioctlsocket(fd, FIONREAD, &n); #else @@ -1169,14 +1169,14 @@ void Console::loop() // clean up: ignore stdin, stdout and stderr for(const auto &fd: _fds ) { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) closesocket(fd); #else close(fd); #endif } -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) closesocket(_listenfd); WSACleanup(); #else diff --git a/cocos/base/CCConsole.h b/cocos/base/CCConsole.h index 2ab3fc93b3..b61e52f594 100644 --- a/cocos/base/CCConsole.h +++ b/cocos/base/CCConsole.h @@ -140,8 +140,6 @@ protected: bool _running; bool _endThread; - std::string _writablePath; - std::map _commands; // strings generated by cocos2d sent to the remote console diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index c8788d2eea..b9dfcaf99a 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -47,6 +47,7 @@ THE SOFTWARE. #include "renderer/CCTextureCache.h" #include "renderer/ccGLStateCache.h" #include "renderer/CCRenderer.h" +#include "renderer/CCRenderState.h" #include "2d/CCCamera.h" #include "base/CCUserDefault.h" #include "base/ccFPSImages.h" @@ -69,6 +70,10 @@ THE SOFTWARE. #include "physics/CCPhysicsWorld.h" #endif +#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION +#include "physics3d/CCPhysics3DWorld.h" +#endif + /** Position of the FPS @@ -170,6 +175,7 @@ bool Director::init(void) initMatrixStack(); _renderer = new (std::nothrow) Renderer; + RenderState::initialize(); return true; } @@ -291,6 +297,13 @@ void Director::drawScene() { physicsWorld->update(_deltaTime, false); } +#endif +#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION + auto physics3DWorld = _runningScene->getPhysics3DWorld(); + if (physics3DWorld) + { + physics3DWorld->stepSimulate(_deltaTime); + } #endif //clear draw stats _renderer->clearDrawStats(); @@ -604,12 +617,7 @@ void Director::setProjection(Projection projection) case Projection::_2D: { loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); -#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 - if(getOpenGLView() != nullptr) - { - multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, getOpenGLView()->getOrientationMatrix()); - } -#endif + Mat4 orthoMatrix; Mat4::createOrthographicOffCenter(0, size.width, 0, size.height, -1024, 1024, &orthoMatrix); multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix); @@ -624,15 +632,7 @@ void Director::setProjection(Projection projection) Mat4 matrixPerspective, matrixLookup; loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); - -#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 - //if needed, we need to add a rotation for Landscape orientations on Windows Phone 8 since it is always in Portrait Mode - GLView* view = getOpenGLView(); - if(getOpenGLView() != nullptr) - { - multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, getOpenGLView()->getOrientationMatrix()); - } -#endif + // issue #1334 Mat4::createPerspective(60, (GLfloat)size.width/size.height, 10, zeye+size.height/2, &matrixPerspective); @@ -716,12 +716,6 @@ static void GLToClipTransform(Mat4 *transformOut) CCASSERT(nullptr != director, "Director is null when seting matrix stack"); auto projection = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); - -#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 - //if needed, we need to undo the rotation for Landscape orientation in order to get the correct positions - projection = Director::getInstance()->getOpenGLView()->getReverseOrientationMatrix() * projection; -#endif - auto modelview = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); *transformOut = projection * modelview; } @@ -1000,6 +994,8 @@ void Director::reset() UserDefault::destroyInstance(); GL::invalidateStateCache(); + + RenderState::finalize(); destroyTextureCache(); } diff --git a/cocos/base/CCUserDefault.cpp b/cocos/base/CCUserDefault.cpp index 2c39813417..fb72126cf1 100644 --- a/cocos/base/CCUserDefault.cpp +++ b/cocos/base/CCUserDefault.cpp @@ -132,7 +132,7 @@ static void setValueForKey(const char* pKey, const char* pValue) // save file and free doc if (doc) { - doc->SaveFile(UserDefault::getInstance()->getXMLFilePath().c_str()); + doc->SaveFile(FileUtils::getInstance()->getSuitableFOpen(UserDefault::getInstance()->getXMLFilePath()).c_str()); delete doc; } } @@ -484,7 +484,7 @@ bool UserDefault::createXMLFile() return false; } pDoc->LinkEndChild(pRootEle); - bRet = tinyxml2::XML_SUCCESS == pDoc->SaveFile(_filePath.c_str()); + bRet = tinyxml2::XML_SUCCESS == pDoc->SaveFile(FileUtils::getInstance()->getSuitableFOpen(_filePath).c_str()); if(pDoc) { diff --git a/cocos/base/CCUserDefault.h b/cocos/base/CCUserDefault.h index 052dbee5d7..740fbb127f 100644 --- a/cocos/base/CCUserDefault.h +++ b/cocos/base/CCUserDefault.h @@ -245,7 +245,7 @@ public: protected: UserDefault(); - ~UserDefault(); + virtual ~UserDefault(); private: diff --git a/cocos/base/ZipUtils.h b/cocos/base/ZipUtils.h index 310a51ffdb..42ce40c251 100644 --- a/cocos/base/ZipUtils.h +++ b/cocos/base/ZipUtils.h @@ -34,7 +34,7 @@ THE SOFTWARE. #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include "platform/android/CCFileUtils-android.h" -#elif(CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#elif(CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) // for import ssize_t on win32 platform #include "platform/CCStdC.h" #endif diff --git a/cocos/base/allocator/CCAllocatorGlobalNewDelete.cpp b/cocos/base/allocator/CCAllocatorGlobalNewDelete.cpp index 72098a1375..0a5104cd52 100644 --- a/cocos/base/allocator/CCAllocatorGlobalNewDelete.cpp +++ b/cocos/base/allocator/CCAllocatorGlobalNewDelete.cpp @@ -28,6 +28,8 @@ #include #include +#include + USING_NS_CC_ALLOCATOR; #if CC_ENABLE_ALLOCATOR @@ -43,21 +45,27 @@ namespace void* operator new[] (std::size_t size) { void* ptr = global.allocate(size); -#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID - if (nullptr == ptr) - throw std::bad_alloc(); -#endif - return ptr; + assert(ptr && "No memory"); + + // dissabling exceptions since cocos2d-x doesn't use them +//#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID +// if (nullptr == ptr) +// throw std::bad_alloc(); +//#endif + return ptr; } // @brief overrides global operator new void* operator new(std::size_t size) { void* ptr = global.allocate(size); -#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID - if (nullptr == ptr) - throw std::bad_alloc(); -#endif + assert(ptr && "No memory"); + + // dissabling exceptions since cocos2d-x doesn't use them +//#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID +// if (nullptr == ptr) +// throw std::bad_alloc(); +//#endif return ptr; } diff --git a/cocos/base/allocator/CCAllocatorMutex.h b/cocos/base/allocator/CCAllocatorMutex.h index 778549f872..48e52ce1a4 100644 --- a/cocos/base/allocator/CCAllocatorMutex.h +++ b/cocos/base/allocator/CCAllocatorMutex.h @@ -41,7 +41,7 @@ pthread_mutex_lock(&m); #define MUTEX_UNLOCK(m) \ pthread_mutex_unlock(&m); -#elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT +#elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT #include "windows.h" #define MUTEX HANDLE #if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 @@ -49,7 +49,7 @@ m = CreateMutex(0, FALSE, 0) #define MUTEX_LOCK(m) \ WaitForSingleObject(m, INFINITE) -#elif CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT +#elif CC_TARGET_PLATFORM == CC_PLATFORM_WINRT #define MUTEX_INIT(m) \ m = CreateMutexEx(NULL,FALSE,0,NULL); #define MUTEX_LOCK(m) \ diff --git a/cocos/base/ccConfig.h b/cocos/base/ccConfig.h index 87f59cf931..aa494ba416 100644 --- a/cocos/base/ccConfig.h +++ b/cocos/base/ccConfig.h @@ -252,6 +252,13 @@ THE SOFTWARE. #define CC_USE_PHYSICS 1 #endif +/** Use 3d physics integration API. */ +#ifndef CC_USE_3D_PHYSICS +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) +#define CC_USE_3D_PHYSICS 1 +#endif +#endif + /** Use culling or not. */ #ifndef CC_USE_CULLING #define CC_USE_CULLING 1 @@ -278,7 +285,7 @@ THE SOFTWARE. /** Support webp or not. If your application don't use webp format picture, you can undefine this macro to save package size. */ #ifndef CC_USE_WEBP -#if (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) && (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) #define CC_USE_WEBP 1 #endif #endif // CC_USE_WEBP @@ -305,7 +312,7 @@ THE SOFTWARE. * protected by default. */ #ifndef CC_CONSTRUCTOR_ACCESS -#define CC_CONSTRUCTOR_ACCESS protected +#define CC_CONSTRUCTOR_ACCESS public #endif /** @def CC_ENABLE_ALLOCATOR diff --git a/cocos/base/ccUtils.cpp b/cocos/base/ccUtils.cpp index 5ae5d66d92..d57011c301 100644 --- a/cocos/base/ccUtils.cpp +++ b/cocos/base/ccUtils.cpp @@ -74,16 +74,7 @@ void onCaptureScreen(const std::function& afterC } glPixelStorei(GL_PACK_ALIGNMENT, 1); - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) - // The frame buffer is always created with portrait orientation on WP8. - // So if the current device orientation is landscape, we need to rotate the frame buffer. - auto renderTargetSize = glView->getRenerTargetSize(); - CCASSERT(width * height == static_cast(renderTargetSize.width * renderTargetSize.height), "The frame size is not matched"); - glReadPixels(0, 0, (int)renderTargetSize.width, (int)renderTargetSize.height, GL_RGBA, GL_UNSIGNED_BYTE, buffer.get()); -#else glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer.get()); -#endif std::shared_ptr flippedBuffer(new GLubyte[width * height * 4], [](GLubyte* p) { CC_SAFE_DELETE_ARRAY(p); }); if (!flippedBuffer) @@ -91,32 +82,10 @@ void onCaptureScreen(const std::function& afterC break; } -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) - if (width == static_cast(renderTargetSize.width)) - { - // The current device orientation is portrait. - for (int row = 0; row < height; ++row) - { - memcpy(flippedBuffer.get() + (height - row - 1) * width * 4, buffer.get() + row * width * 4, width * 4); - } - } - else - { - // The current device orientation is landscape. - for (int row = 0; row < width; ++row) - { - for (int col = 0; col < height; ++col) - { - *(int*)(flippedBuffer.get() + (height - col - 1) * width * 4 + row * 4) = *(int*)(buffer.get() + row * height * 4 + col * 4); - } - } - } -#else for (int row = 0; row < height; ++row) { memcpy(flippedBuffer.get() + (height - row - 1) * width * 4, buffer.get() + row * width * 4, width * 4); } -#endif std::shared_ptr image(new Image); if (image) diff --git a/cocos/cocos2d.cpp b/cocos/cocos2d.cpp index 7088ec8589..d785c1b4d5 100644 --- a/cocos/cocos2d.cpp +++ b/cocos/cocos2d.cpp @@ -31,7 +31,7 @@ NS_CC_BEGIN CC_DLL const char* cocos2dVersion() { - return "cocos2d-x 3.6"; + return "cocos2d-x 3.7-pre"; } NS_CC_END diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index 2888e7b54b..fb967bd7cf 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -29,8 +29,8 @@ THE SOFTWARE. #define __COCOS2D_H__ // 0x00 HI ME LO -// 00 03 03 00 -#define COCOS2D_VERSION 0x00030600 +// 00 03 07 00 +#define COCOS2D_VERSION 0x00030700 // // all cocos2d include files @@ -61,6 +61,7 @@ THE SOFTWARE. #include "base/CCIMEDelegate.h" #include "base/CCIMEDispatcher.h" #include "base/ccUtils.h" +#include "base/CCAsyncTaskPool.h" // EventDispatcher #include "base/CCEventType.h" @@ -163,6 +164,10 @@ THE SOFTWARE. #include "renderer/CCPrimitive.h" #include "renderer/CCPrimitiveCommand.h" #include "renderer/CCTrianglesCommand.h" +#include "renderer/CCMaterial.h" +#include "renderer/CCTechnique.h" +#include "renderer/CCPass.h" +#include "renderer/CCRenderState.h" // physics #include "physics/CCPhysicsBody.h" @@ -230,14 +235,6 @@ THE SOFTWARE. #include "platform/winrt/CCStdC.h" #endif // CC_TARGET_PLATFORM == CC_PLATFORM_WINRT -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) - #include "platform/winrt/CCApplication.h" - #include "platform/wp8/CCGLViewImpl-wp8.h" - #include "platform/winrt/CCGL.h" - #include "platform/winrt/CCStdC.h" - #include "platform/winrt/CCPrecompiledShaders.h" -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WP8 - // script_support #include "base/CCScriptSupport.h" diff --git a/cocos/editor-support/cocosbuilder/CCBReader.h b/cocos/editor-support/cocosbuilder/CCBReader.h index d89b153c76..925fdfef94 100644 --- a/cocos/editor-support/cocosbuilder/CCBReader.h +++ b/cocos/editor-support/cocosbuilder/CCBReader.h @@ -131,11 +131,6 @@ public: MULTIPLY_RESOLUTION, }; -#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 -#ifdef ABSOLUTE -#undef ABSOLUTE -#endif -#endif enum class SizeType { ABSOLUTE, diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp index 463da82deb..e102894f8e 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp @@ -38,8 +38,8 @@ NS_TIMELINE_BEGIN Frame::Frame() : _frameIndex(0) , _tween(true) - , _tweenType(tweenfunc::TweenType::Linear) , _enterWhenPassed(false) + , _tweenType(tweenfunc::TweenType::Linear) , _timeline(nullptr) , _node(nullptr) { @@ -282,7 +282,7 @@ void SkewFrame::onEnter(Frame *nextFrame, int currentFrameIndex) void SkewFrame::onApply(float percent) { - if (nullptr != _node && _betweenSkewX != 0 || _betweenSkewY != 0) + if ((nullptr != _node && _betweenSkewX != 0) || _betweenSkewY != 0) { float skewx = _skewX + percent * _betweenSkewX; float skewy = _skewY + percent * _betweenSkewY; @@ -342,7 +342,7 @@ void RotationSkewFrame::onEnter(Frame *nextFrame, int currentFrameIndex) void RotationSkewFrame::onApply(float percent) { - if (nullptr != _node && _betweenSkewX != 0 || _betweenSkewY != 0) + if ((nullptr != _node && _betweenSkewX != 0) || _betweenSkewY != 0) { float skewx = _skewX + percent * _betweenSkewX; float skewy = _skewY + percent * _betweenSkewY; @@ -460,7 +460,7 @@ void ScaleFrame::onEnter(Frame *nextFrame, int currentFrameIndex) void ScaleFrame::onApply(float percent) { - if (nullptr != _node && _betweenScaleX != 0 || _betweenScaleY != 0) + if ((nullptr != _node && _betweenScaleX != 0) || _betweenScaleY != 0) { float scaleX = _scaleX + _betweenScaleX * percent; float scaleY = _scaleY + _betweenScaleY * percent; @@ -606,32 +606,20 @@ void InnerActionFrame::onEnter(Frame *nextFrame, int currentFrameIndex) void InnerActionFrame::setStartFrameIndex(int frameIndex) { - if(_enterWithName) - { - CCLOG(" cannot set start when enter frame with name. setEnterWithName false firstly!"); - throw std::exception(); - } + CCASSERT(_enterWithName, " cannot setStartFrameIndex when enterWithName is set"); _startFrameIndex = frameIndex; } void InnerActionFrame::setEndFrameIndex(int frameIndex) { - if(_enterWithName) - { - CCLOG(" cannot set end when enter frame with name. setEnterWithName false firstly!"); - throw std::exception(); - } + CCASSERT(_enterWithName, " cannot setEndFrameIndex when enterWithName is set"); _endFrameIndex = frameIndex; } void InnerActionFrame::setAnimationName(const std::string& animationName) { - if(!_enterWithName) - { - CCLOG(" cannot set aniamtioname when enter frame with index. setEnterWithName true firstly!"); - throw std::exception(); - } + CCASSERT(!_enterWithName, " cannot set aniamtioname when enter frame with index. setEnterWithName true firstly!"); _animationName = animationName; } @@ -694,7 +682,7 @@ void ColorFrame::onEnter(Frame *nextFrame, int currentFrameIndex) void ColorFrame::onApply(float percent) { - if (nullptr != _node && _betweenRed != 0 || _betweenGreen != 0 || _betweenBlue != 0) + if ((nullptr != _node && _betweenRed != 0) || _betweenGreen != 0 || _betweenBlue != 0) { Color3B color; color.r = _color.r+ _betweenRed * percent; diff --git a/cocos/editor-support/cocostudio/CCComAudio.cpp b/cocos/editor-support/cocostudio/CCComAudio.cpp index fccc541c87..f6412ef667 100644 --- a/cocos/editor-support/cocostudio/CCComAudio.cpp +++ b/cocos/editor-support/cocostudio/CCComAudio.cpp @@ -128,7 +128,7 @@ bool ComAudio::serialize(void* r) } if (strcmp(className, "CCBackgroundAudio") == 0) { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) std::string::size_type pos = filePath.find(".mp3"); if (pos == filePath.npos) { diff --git a/cocos/editor-support/spine/Slot.h b/cocos/editor-support/spine/Slot.h index 21ac760613..93cf570523 100644 --- a/cocos/editor-support/spine/Slot.h +++ b/cocos/editor-support/spine/Slot.h @@ -53,7 +53,7 @@ typedef struct spSlot { spSlot() : data(0), bone(0), - r(0), b(0), g(0), a(0), + r(0), g(0), b(0), a(0), attachment(0), attachmentVerticesCapacity(0), attachmentVerticesCount(0), diff --git a/cocos/editor-support/spine/proj.win32/libSpine.vcxproj b/cocos/editor-support/spine/proj.win32/libSpine.vcxproj old mode 100755 new mode 100644 index fe1ae21064..8e7a8941c0 --- a/cocos/editor-support/spine/proj.win32/libSpine.vcxproj +++ b/cocos/editor-support/spine/proj.win32/libSpine.vcxproj @@ -83,9 +83,6 @@ StaticLibrary true - v100 - v110 - v110_xp v120 v120_xp Unicode @@ -93,9 +90,6 @@ StaticLibrary false - v100 - v110 - v110_xp v120 v120_xp true diff --git a/cocos/network/HttpRequest.h b/cocos/network/HttpRequest.h index 034e0e4037..b076bc9cbc 100644 --- a/cocos/network/HttpRequest.h +++ b/cocos/network/HttpRequest.h @@ -55,7 +55,7 @@ typedef void (cocos2d::Ref::*SEL_HttpResponse)(HttpClient* client, HttpResponse* * @lua NA */ -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) #ifdef DELETE #undef DELETE #endif diff --git a/cocos/physics/CCPhysicsContact.cpp b/cocos/physics/CCPhysicsContact.cpp index 35c57316b8..55833a38e9 100644 --- a/cocos/physics/CCPhysicsContact.cpp +++ b/cocos/physics/CCPhysicsContact.cpp @@ -178,7 +178,7 @@ EventListenerPhysicsContact::EventListenerPhysicsContact() : onContactBegin(nullptr) , onContactPreSolve(nullptr) , onContactPostSolve(nullptr) -, onContactSeperate(nullptr) +, onContactSeparate(nullptr) { } @@ -243,12 +243,12 @@ void EventListenerPhysicsContact::onEvent(EventCustom* event) } break; } - case PhysicsContact::EventCode::SEPERATE: + case PhysicsContact::EventCode::SEPARATE: { - if (onContactSeperate != nullptr + if (onContactSeparate != nullptr && hitTest(contact->getShapeA(), contact->getShapeB())) { - onContactSeperate(*contact); + onContactSeparate(*contact); } break; } @@ -286,7 +286,7 @@ bool EventListenerPhysicsContact::hitTest(PhysicsShape* shapeA, PhysicsShape* sh bool EventListenerPhysicsContact::checkAvailable() { if (onContactBegin == nullptr && onContactPreSolve == nullptr - && onContactPostSolve == nullptr && onContactSeperate == nullptr) + && onContactPostSolve == nullptr && onContactSeparate == nullptr) { CCASSERT(false, "Invalid PhysicsContactListener."); return false; @@ -304,7 +304,7 @@ EventListenerPhysicsContact* EventListenerPhysicsContact::clone() obj->onContactBegin = onContactBegin; obj->onContactPreSolve = onContactPreSolve; obj->onContactPostSolve = onContactPostSolve; - obj->onContactSeperate = onContactSeperate; + obj->onContactSeparate = onContactSeparate; return obj; } @@ -362,7 +362,7 @@ EventListenerPhysicsContactWithBodies* EventListenerPhysicsContactWithBodies::cl obj->onContactBegin = onContactBegin; obj->onContactPreSolve = onContactPreSolve; obj->onContactPostSolve = onContactPostSolve; - obj->onContactSeperate = onContactSeperate; + obj->onContactSeparate = onContactSeparate; return obj; } @@ -417,7 +417,7 @@ EventListenerPhysicsContactWithShapes* EventListenerPhysicsContactWithShapes::cl obj->onContactBegin = onContactBegin; obj->onContactPreSolve = onContactPreSolve; obj->onContactPostSolve = onContactPostSolve; - obj->onContactSeperate = onContactSeperate; + obj->onContactSeparate = onContactSeparate; return obj; } @@ -469,7 +469,7 @@ EventListenerPhysicsContactWithGroup* EventListenerPhysicsContactWithGroup::clon obj->onContactBegin = onContactBegin; obj->onContactPreSolve = onContactPreSolve; obj->onContactPostSolve = onContactPostSolve; - obj->onContactSeperate = onContactSeperate; + obj->onContactSeparate = onContactSeparate; return obj; } diff --git a/cocos/physics/CCPhysicsContact.h b/cocos/physics/CCPhysicsContact.h index cee52dfc75..2c0ece62eb 100644 --- a/cocos/physics/CCPhysicsContact.h +++ b/cocos/physics/CCPhysicsContact.h @@ -74,7 +74,7 @@ public: BEGIN, PRESOLVE, POSTSOLVE, - SEPERATE + SEPARATE }; /** Get contact shape A. */ @@ -98,7 +98,7 @@ public: /** * @brief Set data to contact. - * You must manage the memory yourself, Generally you can set data at contact begin, and distory it at contact seperate. + * You must manage the memory yourself, Generally you can set data at contact begin, and distory it at contact separate. * * @lua NA */ @@ -235,9 +235,9 @@ public: std::function onContactPostSolve; /** * @brief It will called at two shapes separated, and only call it once. - * onContactBegin and onContactSeperate will called in pairs. + * onContactBegin and onContactSeparate will called in pairs. */ - std::function onContactSeperate; + std::function onContactSeparate; protected: bool init(); diff --git a/cocos/physics/CCPhysicsShape.cpp b/cocos/physics/CCPhysicsShape.cpp index c768a8d6b6..538778e7d1 100644 --- a/cocos/physics/CCPhysicsShape.cpp +++ b/cocos/physics/CCPhysicsShape.cpp @@ -46,6 +46,7 @@ PhysicsShape::PhysicsShape() , _area(0.0f) , _mass(0.0f) , _moment(0.0f) +, _sensor(false) , _scaleX(1.0f) , _scaleY(1.0f) , _newScaleX(1.0f) @@ -250,6 +251,17 @@ void PhysicsShape::setFriction(float friction) } } +void PhysicsShape::setSensor(bool sensor) +{ + if (sensor != _sensor) + { + for (cpShape* shape : _cpShapes) + { + cpShapeSetSensor(shape, sensor); + } + _sensor = sensor; + } +} void PhysicsShape::recenterPoints(Vec2* points, int count, const Vec2& center) { diff --git a/cocos/physics/CCPhysicsShape.h b/cocos/physics/CCPhysicsShape.h index ac535e8e7a..425467e5e9 100644 --- a/cocos/physics/CCPhysicsShape.h +++ b/cocos/physics/CCPhysicsShape.h @@ -212,6 +212,8 @@ public: * @param material A PhysicsMaterial object. */ void setMaterial(const PhysicsMaterial& material); + inline bool isSensor() const { return _sensor; } + void setSensor(bool sensor); /** * Calculate the default moment value. @@ -346,6 +348,7 @@ protected: float _area; float _mass; float _moment; + bool _sensor; float _scaleX; float _scaleY; float _newScaleX; diff --git a/cocos/physics/CCPhysicsWorld.cpp b/cocos/physics/CCPhysicsWorld.cpp index 64ad7e4795..167763d435 100644 --- a/cocos/physics/CCPhysicsWorld.cpp +++ b/cocos/physics/CCPhysicsWorld.cpp @@ -320,7 +320,7 @@ void PhysicsWorld::collisionSeparateCallback(PhysicsContact& contact) return; } - contact.setEventCode(PhysicsContact::EventCode::SEPERATE); + contact.setEventCode(PhysicsContact::EventCode::SEPARATE); contact.setWorld(this); _scene->getEventDispatcher()->dispatchEvent(&contact); } @@ -879,10 +879,10 @@ PhysicsWorld::PhysicsWorld() , _updateTime(0.0f) , _substeps(1) , _cpSpace(nullptr) +, _updateBodyTransform(false) , _scene(nullptr) , _autoStep(true) , _debugDraw(nullptr) -, _updateBodyTransform(false) , _debugDrawMask(DEBUGDRAW_NONE) { diff --git a/cocos/physics3d/CCPhysics3D.cpp b/cocos/physics3d/CCPhysics3D.cpp new file mode 100644 index 0000000000..02018b2081 --- /dev/null +++ b/cocos/physics3d/CCPhysics3D.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** + Copyright (c) 2015 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 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 "CCPhysics3D.h" + +#if CC_USE_3D_PHYSICS + +#if (CC_ENABLE_BULLET_INTEGRATION) + + + +NS_CC_BEGIN + +CC_DLL const char* physics3dVersion() +{ +#if CC_ENABLE_BULLET_INTEGRATION + return "bullet2.82"; +#endif +} + +NS_CC_END + + +cocos2d::Vec3 convertbtVector3ToVec3( const btVector3 &btVec3 ) +{ + return cocos2d::Vec3(btVec3.x(), btVec3.y(), btVec3.z()); +} + +btVector3 convertVec3TobtVector3( const cocos2d::Vec3 &vec3 ) +{ + return btVector3(vec3.x, vec3.y, vec3.z); +} + +cocos2d::Mat4 convertbtTransformToMat4( const btTransform &btTrans ) +{ + cocos2d::Mat4 mat; + auto rot = btTrans.getBasis(); + auto row = rot.getRow(0); + mat.m[0] = row.getX(); + mat.m[4] = row.getY(); + mat.m[8] = row.getZ(); + row = rot.getRow(1); + mat.m[1] = row.getX(); + mat.m[5] = row.getY(); + mat.m[9] = row.getZ(); + row = rot.getRow(2); + mat.m[2] = row.getX(); + mat.m[6] = row.getY(); + mat.m[10] = row.getZ(); + + row = btTrans.getOrigin(); + mat.m[12] = row.getX(); + mat.m[13] = row.getY(); + mat.m[14] = row.getZ(); + return mat; +} + +btTransform convertMat4TobtTransform( const cocos2d::Mat4 &mat4 ) +{ + btTransform btTrans; + btTrans.setFromOpenGLMatrix(mat4.m); + return btTrans; +} + +cocos2d::Quaternion convertbtQuatToQuat( const btQuaternion &btQuat ) +{ + return cocos2d::Quaternion(btQuat.x(), btQuat.y(), btQuat.z(), btQuat.w()); +} + +btQuaternion convertQuatTobtQuat( const cocos2d::Quaternion &quat ) +{ + return btQuaternion(quat.x, quat.y, quat.z, quat.w); +} + +#endif // CC_ENABLE_BULLET_INTEGRATION + +#endif //CC_USE_3D_PHYSICS diff --git a/cocos/physics3d/CCPhysics3D.h b/cocos/physics3d/CCPhysics3D.h new file mode 100644 index 0000000000..7519ee8e70 --- /dev/null +++ b/cocos/physics3d/CCPhysics3D.h @@ -0,0 +1,69 @@ +/**************************************************************************** + Copyright (c) 2015 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 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 __PHYSICS_3D_H__ +#define __PHYSICS_3D_H__ + +#include "base/ccConfig.h" +#include "math/CCMath.h" + +#if CC_USE_3D_PHYSICS + +#include "CCPhysics3DShape.h" +#include "CCPhysicsSprite3D.h" +#include "CCPhysics3DWorld.h" +#include "CCPhysics3DDebugDrawer.h" +#include "CCPhysics3DObject.h" +#include "CCPhysics3DComponent.h" +#include "CCPhysics3DConstraint.h" + +NS_CC_BEGIN + +CC_DLL const char* physics3dVersion(); + +NS_CC_END + +#if (CC_ENABLE_BULLET_INTEGRATION) + +//include bullet header files +#include "bullet/LinearMath/btTransform.h" +#include "bullet/LinearMath/btVector3.h" +#include "bullet/LinearMath/btQuaternion.h" + +#include "bullet/btBulletCollisionCommon.h" +#include "bullet/btBulletDynamicsCommon.h" + +//convert between cocos and bullet +cocos2d::Vec3 convertbtVector3ToVec3(const btVector3 &btVec3); +btVector3 convertVec3TobtVector3(const cocos2d::Vec3 &vec3); +cocos2d::Mat4 convertbtTransformToMat4(const btTransform &btTrans); +btTransform convertMat4TobtTransform(const cocos2d::Mat4 &mat4); +cocos2d::Quaternion convertbtQuatToQuat(const btQuaternion &btQuat); +btQuaternion convertQuatTobtQuat(const cocos2d::Quaternion &quat); + +#endif // CC_ENABLE_BULLET_INTEGRATION + +#endif //CC_USE_3D_PHYSICS + +#endif // __PHYSICS_3D_H__ diff --git a/cocos/physics3d/CCPhysics3DComponent.cpp b/cocos/physics3d/CCPhysics3DComponent.cpp new file mode 100644 index 0000000000..c7bb88795f --- /dev/null +++ b/cocos/physics3d/CCPhysics3DComponent.cpp @@ -0,0 +1,244 @@ + /**************************************************************************** + Copyright (c) 2015 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 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 "CCPhysics3D.h" +#include "2d/CCNode.h" +#include "2d/CCScene.h" + +#if CC_USE_3D_PHYSICS + +#if (CC_ENABLE_BULLET_INTEGRATION) + +NS_CC_BEGIN + +Physics3DComponent::~Physics3DComponent() +{ + CC_SAFE_RELEASE(_physics3DObj); +} + +std::string& Physics3DComponent::getPhysics3DComponentName() +{ + static std::string comName = "___Physics3DComponent___"; + return comName; +} + +bool Physics3DComponent::init() +{ + setName(getPhysics3DComponentName()); + return Component::init(); +} + +Physics3DComponent* Physics3DComponent::create(Physics3DObject* physicsObj, const cocos2d::Vec3& translateInPhysics, const cocos2d::Quaternion& rotInPhsyics) +{ + auto ret = new (std::nothrow) Physics3DComponent(); + if (ret && ret->init()) + { + ret->setPhysics3DObject(physicsObj); + ret->setTransformInPhysics(translateInPhysics, rotInPhsyics); + ret->autorelease(); + return ret; + } + CC_SAFE_DELETE(ret); + return nullptr; +} + +void Physics3DComponent::setPhysics3DObject(Physics3DObject* physicsObj) +{ + CC_SAFE_RETAIN(physicsObj); + CC_SAFE_RELEASE(_physics3DObj); + _physics3DObj = physicsObj; +} + +Physics3DComponent::Physics3DComponent() +: _physics3DObj(nullptr) +, _syncFlag(Physics3DComponent::PhysicsSyncFlag::NODE_AND_NODE) +{ + +} + +void Physics3DComponent::setEnabled(bool b) +{ + bool oldBool = b; + Component::setEnabled(b); + if (_physics3DObj && oldBool != _enabled) + { + _enabled ? _physics3DObj->getPhysicsWorld()->addPhysics3DObject(_physics3DObj) : _physics3DObj->getPhysicsWorld()->removePhysics3DObject(_physics3DObj); + } +} + +void Physics3DComponent::addToPhysicsWorld(Physics3DWorld* world) +{ + //add component to physics world + if (_physics3DObj) + { + _physics3DObj->setPhysicsWorld(world); + world->addPhysics3DObject(_physics3DObj); + auto& components = world->_physicsComponents; + auto it = std::find(components.begin(), components.end(), this); + if (it == components.end()) + { + auto parent = _owner->getParent(); + while (parent) { + for (int i = 0; i < components.size(); i++) { + if (parent == components[i]->getOwner()) + { + //insert it here + components.insert(components.begin() + i, this); + return; + } + } + parent = parent->getParent(); + } + + components.insert(components.begin(), this); + } + } +} + +void Physics3DComponent::onEnter() +{ + Component::onEnter(); + + if (_physics3DObj->getPhysicsWorld() == nullptr && _owner) + { + auto scene = _owner->getScene(); + if (scene) + addToPhysicsWorld(scene->getPhysics3DWorld()); + } +} + +void Physics3DComponent::onExit() +{ + Component::onExit(); + setEnabled(false); + + //remove component from physics world + if (_physics3DObj) + { + auto& components = _physics3DObj->getPhysicsWorld()->_physicsComponents; + auto it = std::find(components.begin(), components.end(), this); + if (it != components.end()) + components.erase(it); + } +} + +void Physics3DComponent::preSimulate() +{ + if (((int)_syncFlag & (int)Physics3DComponent::PhysicsSyncFlag::NODE_TO_PHYSICS) && _physics3DObj && _owner) + { + syncToNode(); + } +} + +void Physics3DComponent::postSimulate() +{ + if (((int)_syncFlag & (int)Physics3DComponent::PhysicsSyncFlag::PHYSICS_TO_NODE) && _physics3DObj && _owner) + { + syncToPhysics(); + } +} + +void Physics3DComponent::setTransformInPhysics(const cocos2d::Vec3& translateInPhysics, const cocos2d::Quaternion& rotInPhsyics) +{ + Mat4::createRotation(rotInPhsyics, &_transformInPhysics); + _transformInPhysics.m[12] = translateInPhysics.x; + _transformInPhysics.m[13] = translateInPhysics.y; + _transformInPhysics.m[14] = translateInPhysics.z; + + _invTransformInPhysics = _transformInPhysics.getInversed(); +} + +void Physics3DComponent::setSyncFlag(PhysicsSyncFlag syncFlag) +{ + _syncFlag = syncFlag; +} + +void Physics3DComponent::syncToPhysics() +{ + if (_physics3DObj->getObjType() == Physics3DObject::PhysicsObjType::RIGID_BODY) + { + Mat4 parentMat; + if (_owner->getParent()) + parentMat = _owner->getParent()->getNodeToWorldTransform(); + + auto mat = parentMat.getInversed() * _physics3DObj->getWorldTransform(); + //remove scale, no scale support for physics + float oneOverLen = 1.f / sqrtf(mat.m[0] * mat.m[0] + mat.m[1] * mat.m[1] + mat.m[2] * mat.m[2]); + mat.m[0] *= oneOverLen; + mat.m[1] *= oneOverLen; + mat.m[2] *= oneOverLen; + oneOverLen = 1.f / sqrtf(mat.m[4] * mat.m[4] + mat.m[5] * mat.m[5] + mat.m[6] * mat.m[6]); + mat.m[4] *= oneOverLen; + mat.m[5] *= oneOverLen; + mat.m[6] *= oneOverLen; + oneOverLen = 1.f / sqrtf(mat.m[8] * mat.m[8] + mat.m[9] * mat.m[9] + mat.m[10] * mat.m[10]); + mat.m[8] *= oneOverLen; + mat.m[9] *= oneOverLen; + mat.m[10] *= oneOverLen; + + mat *= _transformInPhysics; + static Vec3 scale, translation; + static Quaternion quat; + mat.decompose(&scale, &quat, &translation); + _owner->setPosition3D(translation); + quat.normalize(); + _owner->setRotationQuat(quat); + } +} + +void Physics3DComponent::syncToNode() +{ + if (_physics3DObj->getObjType() == Physics3DObject::PhysicsObjType::RIGID_BODY) + { + auto mat = _owner->getNodeToWorldTransform(); + //remove scale, no scale support for physics + float oneOverLen = 1.f / sqrtf(mat.m[0] * mat.m[0] + mat.m[1] * mat.m[1] + mat.m[2] * mat.m[2]); + mat.m[0] *= oneOverLen; + mat.m[1] *= oneOverLen; + mat.m[2] *= oneOverLen; + oneOverLen = 1.f / sqrtf(mat.m[4] * mat.m[4] + mat.m[5] * mat.m[5] + mat.m[6] * mat.m[6]); + mat.m[4] *= oneOverLen; + mat.m[5] *= oneOverLen; + mat.m[6] *= oneOverLen; + oneOverLen = 1.f / sqrtf(mat.m[8] * mat.m[8] + mat.m[9] * mat.m[9] + mat.m[10] * mat.m[10]); + mat.m[8] *= oneOverLen; + mat.m[9] *= oneOverLen; + mat.m[10] *= oneOverLen; + + mat *= _invTransformInPhysics; + if (_physics3DObj->getObjType() == Physics3DObject::PhysicsObjType::RIGID_BODY) + { + auto body = static_cast(_physics3DObj)->getRigidBody(); + auto motionState = body->getMotionState(); + motionState->setWorldTransform(convertMat4TobtTransform(mat)); + body->setMotionState(motionState); + } + } +} + +NS_CC_END + +#endif // CC_ENABLE_BULLET_INTEGRATION + +#endif //CC_USE_3D_PHYSICS diff --git a/cocos/physics3d/CCPhysics3DComponent.h b/cocos/physics3d/CCPhysics3DComponent.h new file mode 100644 index 0000000000..1c036c8225 --- /dev/null +++ b/cocos/physics3d/CCPhysics3DComponent.h @@ -0,0 +1,145 @@ +/**************************************************************************** + Copyright (c) 2015 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 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 __PHYSICS_3D_COMPONENT_H__ +#define __PHYSICS_3D_COMPONENT_H__ + +#include "base/ccConfig.h" +#include "math/CCMath.h" + +#include "2d/CCComponent.h" + +#if CC_USE_3D_PHYSICS + +#if (CC_ENABLE_BULLET_INTEGRATION) + +NS_CC_BEGIN + +/** + * @addtogroup _3d + * @{ + */ + +class Physics3DObject; +class Physics3DWorld; + +/** @brief Physics3DComponent: A component with 3D physics, you can add a rigid body to it, and then add this component to a node, the node will move and rotate with this rigid body */ +class CC_DLL Physics3DComponent : public cocos2d::Component +{ + friend class Physics3DWorld; +public: + enum class PhysicsSyncFlag + { + NONE = 0, + NODE_TO_PHYSICS = 1, //align node transform to the physics + PHYSICS_TO_NODE = 2, // align physics transform to the node + NODE_AND_NODE = NODE_TO_PHYSICS | PHYSICS_TO_NODE, //pre simulation, align the physics object to the node and align the node transform according to physics object after simulation + }; + + CREATE_FUNC(Physics3DComponent); + virtual ~Physics3DComponent(); + virtual bool init() override; + + /** + * create Physics3DComponent + * @param physicsObj pointer to a Physics object contain in the component + * @param translateInPhysics offset that the owner node in the physics object's space + * @param rotInPhsyics offset rotation that the owner node in the physics object's space + * @return created Physics3DComponent + */ + static Physics3DComponent* create(Physics3DObject* physicsObj, const cocos2d::Vec3& translateInPhysics = cocos2d::Vec3::ZERO, const cocos2d::Quaternion& rotInPhsyics = cocos2d::Quaternion::ZERO); + + /** + * set Physics object to the component + */ + void setPhysics3DObject(Physics3DObject* physicsObj); + + /** + * get physics object + */ + Physics3DObject* getPhysics3DObject() const { return _physics3DObj; } + + /** + * get the component name, it is used to find whether it is Physics3DComponent + */ + static std::string& getPhysics3DComponentName(); + + /** + * set it enable or not + */ + virtual void setEnabled(bool b) override; + + + virtual void onEnter() override; + virtual void onExit() override; + + /** + * add this component to physics world, called by scene + */ + void addToPhysicsWorld(Physics3DWorld* world); + + /** + * The node's transform in physics object space + */ + void setTransformInPhysics(const cocos2d::Vec3& translateInPhysics, const cocos2d::Quaternion& rotInPhsyics); + + /** + * synchronization between node and physics is time consuming, you can skip some synchronization using this function + */ + void setSyncFlag(PhysicsSyncFlag syncFlag); + + /** + * align node and physics according to physics object + */ + void syncToPhysics(); + + /** + * align node and physics according to node + */ + void syncToNode(); + +CC_CONSTRUCTOR_ACCESS: + Physics3DComponent(); + +protected: + void preSimulate(); + + void postSimulate(); + + cocos2d::Mat4 _transformInPhysics; //transform in physics space + cocos2d::Mat4 _invTransformInPhysics; + + Physics3DObject* _physics3DObj; + PhysicsSyncFlag _syncFlag; +}; + +// end of 3d group +/// @} +NS_CC_END + +#endif // CC_ENABLE_BULLET_INTEGRATION + +#endif //CC_USE_3D_PHYSICS + +#endif // __PHYSICS_3D_COMPONENT_H__ diff --git a/cocos/physics3d/CCPhysics3DConstraint.cpp b/cocos/physics3d/CCPhysics3DConstraint.cpp new file mode 100644 index 0000000000..90e8b43898 --- /dev/null +++ b/cocos/physics3d/CCPhysics3DConstraint.cpp @@ -0,0 +1,840 @@ +/**************************************************************************** + Copyright (c) 2015 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 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 "CCPhysics3D.h" + +#if CC_USE_3D_PHYSICS + +#if (CC_ENABLE_BULLET_INTEGRATION) + +NS_CC_BEGIN + +Physics3DConstraint::Physics3DConstraint() +: _bodyA(nullptr) +, _bodyB(nullptr) +, _constraint(nullptr) +, _type(Physics3DConstraint::ConstraintType::UNKNOWN) +, _userData(nullptr) +{ + +} + +Physics3DConstraint::~Physics3DConstraint() +{ + CC_SAFE_RELEASE(_bodyA); + CC_SAFE_RELEASE(_bodyB); + CC_SAFE_DELETE(_constraint); +} + +float Physics3DConstraint::getBreakingImpulse() const +{ + return _constraint->getBreakingImpulseThreshold(); +} + +void Physics3DConstraint::setBreakingImpulse(float impulse) +{ + _constraint->setBreakingImpulseThreshold(impulse); +} + +bool Physics3DConstraint::isEnabled() const +{ + return _constraint->isEnabled(); +} + +void Physics3DConstraint::setEnabled(bool enabled) +{ + return _constraint->setEnabled(enabled); +} + +int Physics3DConstraint::getOverrideNumSolverIterations() const +{ + return _constraint->getOverrideNumSolverIterations(); +} + +///override the number of constraint solver iterations used to solve this constraint +///-1 will use the default number of iterations, as specified in SolverInfo.m_numIterations +void Physics3DConstraint::setOverrideNumSolverIterations(int overideNumIterations) +{ + _constraint->setOverrideNumSolverIterations(overideNumIterations); +} + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +Physics3DPointToPointConstraint* Physics3DPointToPointConstraint::create(Physics3DRigidBody* rbA, const cocos2d::Vec3& pivotPointInA) +{ + auto ret = new (std::nothrow) Physics3DPointToPointConstraint(); + if (ret && ret->init(rbA, pivotPointInA)) + { + ret->autorelease(); + return ret; + } + + CC_SAFE_DELETE(ret); + return ret; +} + + +Physics3DPointToPointConstraint* Physics3DPointToPointConstraint::create(Physics3DRigidBody* rbA, Physics3DRigidBody* rbB, const cocos2d::Vec3& pivotPointInA, const cocos2d::Vec3& pivotPointInB) +{ + auto ret = new (std::nothrow) Physics3DPointToPointConstraint(); + if (ret && ret->init(rbA, rbB, pivotPointInA, pivotPointInB)) + { + ret->autorelease(); + return ret; + } + + CC_SAFE_DELETE(ret); + return ret; +} + +bool Physics3DPointToPointConstraint::init(Physics3DRigidBody* rbA, const cocos2d::Vec3& pivotPointInA) +{ + + _constraint = new btPoint2PointConstraint(*rbA->getRigidBody(), convertVec3TobtVector3(pivotPointInA)); + _bodyA = rbA; + _bodyA->retain(); + + return true; +} + +bool Physics3DPointToPointConstraint::init(Physics3DRigidBody* rbA, Physics3DRigidBody* rbB, const cocos2d::Vec3& pivotPointInA, const cocos2d::Vec3& pivotPointInB) +{ + _constraint = new btPoint2PointConstraint(*rbA->getRigidBody(), *rbB->getRigidBody(), convertVec3TobtVector3(pivotPointInA), convertVec3TobtVector3(pivotPointInB)); + _bodyA = rbA; + _bodyB = rbB; + _bodyA->retain(); + _bodyB->retain(); + + return true; +} + +void Physics3DPointToPointConstraint::setPivotPointInA(const cocos2d::Vec3& pivotA) +{ + auto point = convertVec3TobtVector3(pivotA); + static_cast(_constraint)->setPivotA(point); +} + +void Physics3DPointToPointConstraint::setPivotPointInB(const cocos2d::Vec3&& pivotB) +{ + auto point = convertVec3TobtVector3(pivotB); + static_cast(_constraint)->setPivotB(point); +} + +cocos2d::Vec3 Physics3DPointToPointConstraint::getPivotPointInA() const +{ + const auto& point = static_cast(_constraint)->getPivotInA(); + return convertbtVector3ToVec3(point); +} + +cocos2d::Vec3 Physics3DPointToPointConstraint::getPivotPointInB() const +{ + const auto& point = static_cast(_constraint)->getPivotInB(); + return convertbtVector3ToVec3(point); +} + +Physics3DPointToPointConstraint::Physics3DPointToPointConstraint() +{ + _type = Physics3DConstraint::ConstraintType::POINT_TO_POINT; +} + +Physics3DPointToPointConstraint::~Physics3DPointToPointConstraint() +{ + +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +Physics3DHingeConstraint* Physics3DHingeConstraint::create(Physics3DRigidBody* rbA, const cocos2d::Mat4& rbAFrame, bool useReferenceFrameA) +{ + auto ret = new (std::nothrow) Physics3DHingeConstraint(); + ret->_constraint = new btHingeConstraint(*rbA->getRigidBody(), convertMat4TobtTransform(rbAFrame), useReferenceFrameA); + ret->_bodyA = rbA; + rbA->retain(); + + ret->autorelease(); + return ret; +} + +Physics3DHingeConstraint* Physics3DHingeConstraint::create(Physics3DRigidBody* rbA, const cocos2d::Vec3& pivotInA, const cocos2d::Vec3& axisInA, bool useReferenceFrameA) +{ + auto ret = new (std::nothrow) Physics3DHingeConstraint(); + ret->_constraint = new btHingeConstraint(*rbA->getRigidBody(), convertVec3TobtVector3(pivotInA), convertVec3TobtVector3(axisInA), useReferenceFrameA); + ret->_bodyA = rbA; + rbA->retain(); + + ret->autorelease(); + return ret; +} + +Physics3DHingeConstraint* Physics3DHingeConstraint::create(Physics3DRigidBody* rbA, Physics3DRigidBody* rbB, const cocos2d::Vec3& pivotInA,const cocos2d::Vec3& pivotInB, cocos2d::Vec3& axisInA, cocos2d::Vec3& axisInB, bool useReferenceFrameA) +{ + auto ret = new (std::nothrow) Physics3DHingeConstraint(); + ret->_constraint = new btHingeConstraint(*rbA->getRigidBody(), *rbB->getRigidBody(), convertVec3TobtVector3(pivotInA), convertVec3TobtVector3(pivotInB), convertVec3TobtVector3(axisInA), convertVec3TobtVector3(axisInB), useReferenceFrameA); + ret->_bodyA = rbA; + rbA->retain(); + ret->_bodyB = rbB; + rbB->retain(); + + ret->autorelease(); + return ret; +} + +Physics3DHingeConstraint* Physics3DHingeConstraint::create(Physics3DRigidBody* rbA, Physics3DRigidBody* rbB, const cocos2d::Mat4& rbAFrame, const cocos2d::Mat4& rbBFrame, bool useReferenceFrameA) +{ + auto ret = new (std::nothrow) Physics3DHingeConstraint(); + ret->_constraint = new btHingeConstraint(*rbA->getRigidBody(), *rbB->getRigidBody(), convertMat4TobtTransform(rbAFrame), convertMat4TobtTransform(rbBFrame), useReferenceFrameA); + ret->_bodyA = rbA; + rbA->retain(); + ret->_bodyB = rbB; + rbB->retain(); + + ret->autorelease(); + return ret; +} + +cocos2d::Mat4 Physics3DHingeConstraint::getFrameOffsetA() const +{ + const auto& transform = static_cast(_constraint)->getFrameOffsetA(); + return convertbtTransformToMat4(transform); +} + +cocos2d::Mat4 Physics3DHingeConstraint::getFrameOffsetB() const +{ + const auto& transform = static_cast(_constraint)->getFrameOffsetB(); + return convertbtTransformToMat4(transform); +} + +void Physics3DHingeConstraint::setFrames(const cocos2d::Mat4& frameA, const cocos2d::Mat4& frameB) +{ + auto transformA = convertMat4TobtTransform(frameA); + auto transformB = convertMat4TobtTransform(frameB); + static_cast(_constraint)->setFrames(transformA, transformB); +} + +void Physics3DHingeConstraint::setAngularOnly(bool angularOnly) +{ + static_cast(_constraint)->setAngularOnly(angularOnly); +} + +void Physics3DHingeConstraint::enableAngularMotor(bool enableMotor, float targetVelocity, float maxMotorImpulse) +{ + static_cast(_constraint)->enableAngularMotor(enableMotor, targetVelocity, maxMotorImpulse); +} + +void Physics3DHingeConstraint::enableMotor(bool enableMotor) +{ + static_cast(_constraint)->enableMotor(enableMotor); +} +void Physics3DHingeConstraint::setMaxMotorImpulse(float maxMotorImpulse) +{ + static_cast(_constraint)->setMaxMotorImpulse(maxMotorImpulse); +} +void Physics3DHingeConstraint::setMotorTarget(const cocos2d::Quaternion& qAinB, float dt) +{ + static_cast(_constraint)->setMotorTarget(convertQuatTobtQuat(qAinB), dt); +} +void Physics3DHingeConstraint::setMotorTarget(float targetAngle, float dt) +{ + static_cast(_constraint)->setMotorTarget(targetAngle, dt); +} + + +void Physics3DHingeConstraint::setLimit(float low, float high, float softness, float biasFactor, float relaxationFactor) +{ + static_cast(_constraint)->setLimit(low, high, softness, biasFactor, relaxationFactor); +} + +void Physics3DHingeConstraint::setAxis(const cocos2d::Vec3& axisInA) +{ + auto axis = convertVec3TobtVector3(axisInA); + static_cast(_constraint)->setAxis(axis); +} + +float Physics3DHingeConstraint::getLowerLimit() const +{ + return static_cast(_constraint)->getLowerLimit(); +} + +float Physics3DHingeConstraint::getUpperLimit() const +{ + return static_cast(_constraint)->getUpperLimit(); +} + +float Physics3DHingeConstraint::getHingeAngle() +{ + return static_cast(_constraint)->getHingeAngle(); +} + +float Physics3DHingeConstraint::getHingeAngle(const cocos2d::Mat4& transA, const cocos2d::Mat4& transB) +{ + auto btTransA = convertMat4TobtTransform(transA); + auto btTransB = convertMat4TobtTransform(transB); + return static_cast(_constraint)->getHingeAngle(btTransA, btTransB); +} + +cocos2d::Mat4 Physics3DHingeConstraint::getAFrame() +{ + const auto& trans = static_cast(_constraint)->getAFrame(); + return convertbtTransformToMat4(trans); +} +cocos2d::Mat4 Physics3DHingeConstraint::getBFrame() +{ + const auto& trans = static_cast(_constraint)->getBFrame(); + return convertbtTransformToMat4(trans); +} + +bool Physics3DHingeConstraint::getAngularOnly() +{ + return static_cast(_constraint)->getAngularOnly(); +} +bool Physics3DHingeConstraint::getEnableAngularMotor() +{ + return static_cast(_constraint)->getEnableAngularMotor(); +} +float Physics3DHingeConstraint::getMotorTargetVelosity() +{ + return static_cast(_constraint)->getMotorTargetVelosity(); +} +float Physics3DHingeConstraint::getMaxMotorImpulse() +{ + return static_cast(_constraint)->getMaxMotorImpulse(); +} + +bool Physics3DHingeConstraint::getUseFrameOffset() +{ + return static_cast(_constraint)->getUseFrameOffset(); +} +void Physics3DHingeConstraint::setUseFrameOffset(bool frameOffsetOnOff) +{ + static_cast(_constraint)->setUseFrameOffset(frameOffsetOnOff); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +Physics3DSliderConstraint* Physics3DSliderConstraint::create(Physics3DRigidBody* rbA, Physics3DRigidBody* rbB, const cocos2d::Mat4& frameInA, const cocos2d::Mat4& frameInB ,bool useLinearReferenceFrameA) +{ + auto ret = new (std::nothrow) Physics3DSliderConstraint(); + ret->_bodyA = rbA; + ret->_bodyB = rbB; + rbA->retain(); + rbB->retain(); + + auto transformA = convertMat4TobtTransform(frameInA); + auto transformB = convertMat4TobtTransform(frameInB); + ret->_constraint = new btSliderConstraint(*rbA->getRigidBody(), *rbB->getRigidBody(), transformA, transformB, useLinearReferenceFrameA); + ret->autorelease(); + return ret; +} + +cocos2d::Mat4 Physics3DSliderConstraint::getFrameOffsetA() const +{ + const auto& frameOff = static_cast(_constraint)->getFrameOffsetA(); + return convertbtTransformToMat4(frameOff); +} +cocos2d::Mat4 Physics3DSliderConstraint::getFrameOffsetB() const +{ + const auto& frameOff = static_cast(_constraint)->getFrameOffsetB(); + return convertbtTransformToMat4(frameOff); +} +float Physics3DSliderConstraint::getLowerLinLimit() +{ + return static_cast(_constraint)->getLowerLinLimit(); +} +void Physics3DSliderConstraint::setLowerLinLimit(float lowerLimit) +{ + static_cast(_constraint)->setLowerLinLimit(lowerLimit); +} +float Physics3DSliderConstraint::getUpperLinLimit() +{ + return static_cast(_constraint)->getUpperLinLimit(); +} +void Physics3DSliderConstraint::setUpperLinLimit(float upperLimit) +{ + static_cast(_constraint)->setUpperLinLimit(upperLimit); +} +float Physics3DSliderConstraint::getLowerAngLimit() +{ + return static_cast(_constraint)->getLowerAngLimit(); +} +void Physics3DSliderConstraint::setLowerAngLimit(float lowerLimit) +{ + static_cast(_constraint)->setLowerAngLimit(lowerLimit); +} +float Physics3DSliderConstraint::getUpperAngLimit() +{ + return static_cast(_constraint)->getUpperAngLimit(); +} +void Physics3DSliderConstraint::setUpperAngLimit(float upperLimit) +{ + static_cast(_constraint)->setUpperAngLimit(upperLimit); +} +bool Physics3DSliderConstraint::getUseLinearReferenceFrameA() +{ + return static_cast(_constraint)->getUseLinearReferenceFrameA(); +} +float Physics3DSliderConstraint::getSoftnessDirLin() +{ + return static_cast(_constraint)->getSoftnessDirLin(); +} +float Physics3DSliderConstraint::getRestitutionDirLin() +{ + return static_cast(_constraint)->getRestitutionDirLin(); +} +float Physics3DSliderConstraint::getDampingDirLin() +{ + return static_cast(_constraint)->getDampingDirLin(); +} +float Physics3DSliderConstraint::getSoftnessDirAng() +{ + return static_cast(_constraint)->getSoftnessDirAng(); +} +float Physics3DSliderConstraint::getRestitutionDirAng() +{ + return static_cast(_constraint)->getRestitutionDirAng(); +} +float Physics3DSliderConstraint::getDampingDirAng() +{ + return static_cast(_constraint)->getDampingDirAng(); +} +float Physics3DSliderConstraint::getSoftnessLimLin() +{ + return static_cast(_constraint)->getSoftnessLimLin(); +} +float Physics3DSliderConstraint::getRestitutionLimLin() +{ + return static_cast(_constraint)->getRestitutionLimLin(); +} +float Physics3DSliderConstraint::getDampingLimLin() +{ + return static_cast(_constraint)->getDampingLimAng(); +} +float Physics3DSliderConstraint::getSoftnessLimAng() +{ + return static_cast(_constraint)->getSoftnessLimAng(); +} +float Physics3DSliderConstraint::getRestitutionLimAng() +{ + return static_cast(_constraint)->getRestitutionLimAng(); +} +float Physics3DSliderConstraint::getDampingLimAng() +{ + return static_cast(_constraint)->getDampingLimAng(); +} +float Physics3DSliderConstraint::getSoftnessOrthoLin() +{ + return static_cast(_constraint)->getSoftnessOrthoLin(); +} +float Physics3DSliderConstraint::getRestitutionOrthoLin() +{ + return static_cast(_constraint)->getRestitutionOrthoAng(); +} +float Physics3DSliderConstraint::getDampingOrthoLin() +{ + return static_cast(_constraint)->getDampingOrthoLin(); +} +float Physics3DSliderConstraint::getSoftnessOrthoAng() +{ + return static_cast(_constraint)->getSoftnessOrthoAng(); +} +float Physics3DSliderConstraint::getRestitutionOrthoAng() +{ + return static_cast(_constraint)->getRestitutionOrthoAng(); +} +float Physics3DSliderConstraint::getDampingOrthoAng() +{ + return static_cast(_constraint)->getDampingOrthoAng(); +} +void Physics3DSliderConstraint::setSoftnessDirLin(float softnessDirLin) +{ + static_cast(_constraint)->setSoftnessDirLin(softnessDirLin); +} +void Physics3DSliderConstraint::setRestitutionDirLin(float restitutionDirLin) +{ + static_cast(_constraint)->setRestitutionDirLin(restitutionDirLin); +} +void Physics3DSliderConstraint::setDampingDirLin(float dampingDirLin) +{ + static_cast(_constraint)->setDampingDirLin(dampingDirLin); +} +void Physics3DSliderConstraint::setSoftnessDirAng(float softnessDirAng) +{ + static_cast(_constraint)->setSoftnessDirAng(softnessDirAng); +} +void Physics3DSliderConstraint::setRestitutionDirAng(float restitutionDirAng) +{ + static_cast(_constraint)->setRestitutionDirAng(restitutionDirAng); +} +void Physics3DSliderConstraint::setDampingDirAng(float dampingDirAng) +{ + static_cast(_constraint)->setDampingDirAng(dampingDirAng); +} +void Physics3DSliderConstraint::setSoftnessLimLin(float softnessLimLin) +{ + static_cast(_constraint)->setSoftnessLimLin(softnessLimLin); +} +void Physics3DSliderConstraint::setRestitutionLimLin(float restitutionLimLin) +{ + static_cast(_constraint)->setRestitutionDirLin(restitutionLimLin); +} +void Physics3DSliderConstraint::setDampingLimLin(float dampingLimLin) +{ + static_cast(_constraint)->setDampingLimLin(dampingLimLin); +} +void Physics3DSliderConstraint::setSoftnessLimAng(float softnessLimAng) +{ + static_cast(_constraint)->setSoftnessLimAng(softnessLimAng); +} +void Physics3DSliderConstraint::setRestitutionLimAng(float restitutionLimAng) +{ + static_cast(_constraint)->setRestitutionLimAng(restitutionLimAng); +} +void Physics3DSliderConstraint::setDampingLimAng(float dampingLimAng) +{ + static_cast(_constraint)->setDampingLimAng(dampingLimAng); +} +void Physics3DSliderConstraint::setSoftnessOrthoLin(float softnessOrthoLin) +{ + static_cast(_constraint)->setSoftnessOrthoLin(softnessOrthoLin); +} +void Physics3DSliderConstraint::setRestitutionOrthoLin(float restitutionOrthoLin) +{ + static_cast(_constraint)->setRestitutionOrthoLin(restitutionOrthoLin); +} +void Physics3DSliderConstraint::setDampingOrthoLin(float dampingOrthoLin) +{ + static_cast(_constraint)->setDampingLimLin(dampingOrthoLin); +} +void Physics3DSliderConstraint::setSoftnessOrthoAng(float softnessOrthoAng) +{ + static_cast(_constraint)->setSoftnessOrthoAng(softnessOrthoAng); +} +void Physics3DSliderConstraint::setRestitutionOrthoAng(float restitutionOrthoAng) +{ + static_cast(_constraint)->setRestitutionOrthoAng(restitutionOrthoAng); +} +void Physics3DSliderConstraint::setDampingOrthoAng(float dampingOrthoAng) +{ + static_cast(_constraint)->setDampingOrthoAng(dampingOrthoAng); +} +void Physics3DSliderConstraint::setPoweredLinMotor(bool onOff) +{ + static_cast(_constraint)->setPoweredLinMotor(onOff); +} +bool Physics3DSliderConstraint::getPoweredLinMotor() +{ + return static_cast(_constraint)->getPoweredLinMotor(); +} +void Physics3DSliderConstraint::setTargetLinMotorVelocity(float targetLinMotorVelocity) +{ + static_cast(_constraint)->setTargetLinMotorVelocity(targetLinMotorVelocity); +} +float Physics3DSliderConstraint::getTargetLinMotorVelocity() +{ + return static_cast(_constraint)->getTargetLinMotorVelocity(); +} +void Physics3DSliderConstraint::setMaxLinMotorForce(float maxLinMotorForce) +{ + static_cast(_constraint)->setMaxLinMotorForce(maxLinMotorForce); +} +float Physics3DSliderConstraint::getMaxLinMotorForce() +{ + return static_cast(_constraint)->getMaxLinMotorForce(); +} +void Physics3DSliderConstraint::setPoweredAngMotor(bool onOff) +{ + static_cast(_constraint)->setPoweredAngMotor(onOff); +} +bool Physics3DSliderConstraint::getPoweredAngMotor() +{ + return static_cast(_constraint)->getPoweredAngMotor(); +} +void Physics3DSliderConstraint::setTargetAngMotorVelocity(float targetAngMotorVelocity) +{ + return static_cast(_constraint)->setTargetAngMotorVelocity(targetAngMotorVelocity); +} +float Physics3DSliderConstraint::getTargetAngMotorVelocity() +{ + return static_cast(_constraint)->getTargetAngMotorVelocity(); +} +void Physics3DSliderConstraint::setMaxAngMotorForce(float maxAngMotorForce) +{ + return static_cast(_constraint)->setMaxAngMotorForce(maxAngMotorForce); +} +float Physics3DSliderConstraint::getMaxAngMotorForce() +{ + return static_cast(_constraint)->getMaxAngMotorForce(); +} + +float Physics3DSliderConstraint::getLinearPos() const +{ + return static_cast(_constraint)->getLinearPos(); +} +float Physics3DSliderConstraint::getAngularPos() const +{ + return static_cast(_constraint)->getAngularPos(); +} + +// access for UseFrameOffset +bool Physics3DSliderConstraint::getUseFrameOffset() +{ + return static_cast(_constraint)->getUseFrameOffset(); +} +void Physics3DSliderConstraint::setUseFrameOffset(bool frameOffsetOnOff) +{ + static_cast(_constraint)->setUseFrameOffset(frameOffsetOnOff); +} + +void Physics3DSliderConstraint::setFrames(const cocos2d::Mat4& frameA, const cocos2d::Mat4& frameB) +{ + auto btFrameA = convertMat4TobtTransform(frameA); + auto btFrameB = convertMat4TobtTransform(frameB); + static_cast(_constraint)->setFrames(btFrameA, btFrameB); +} + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +Physics3DConeTwistConstraint* Physics3DConeTwistConstraint::create(Physics3DRigidBody* rbA, const cocos2d::Mat4& frameA) +{ + auto ret = new (std::nothrow) Physics3DConeTwistConstraint(); + ret->_bodyA = rbA; + rbA->retain(); + + auto btFrame = convertMat4TobtTransform(frameA); + ret->_constraint = new btConeTwistConstraint(*rbA->getRigidBody(), btFrame); + + ret->autorelease(); + return ret; +} +Physics3DConeTwistConstraint* Physics3DConeTwistConstraint::create(Physics3DRigidBody* rbA, Physics3DRigidBody* rbB, const cocos2d::Mat4& frameA, const cocos2d::Mat4& frameB) +{ + auto ret = new (std::nothrow) Physics3DConeTwistConstraint(); + ret->_bodyA = rbA; + ret->_bodyB = rbB; + rbA->retain(); + rbB->retain(); + + auto btFrameA = convertMat4TobtTransform(frameA); + auto btFrameB = convertMat4TobtTransform(frameB); + + ret->_constraint = new btConeTwistConstraint(*rbA->getRigidBody(), *rbB->getRigidBody(), btFrameA, btFrameB); + + ret->autorelease(); + return ret; +} + +void Physics3DConeTwistConstraint::setLimit(float swingSpan1,float swingSpan2,float twistSpan, float softness, float biasFactor, float relaxationFactor) +{ + static_cast(_constraint)->setLimit(swingSpan1, swingSpan2, twistSpan, softness, biasFactor, relaxationFactor); +} + +cocos2d::Mat4 Physics3DConeTwistConstraint::getAFrame() +{ + const auto& frame = static_cast(_constraint)->getAFrame(); + return convertbtTransformToMat4(frame); +} +cocos2d::Mat4 Physics3DConeTwistConstraint::getBFrame() +{ + const auto& frame = static_cast(_constraint)->getBFrame(); + return convertbtTransformToMat4(frame); +} + +float Physics3DConeTwistConstraint::getSwingSpan1() +{ + return static_cast(_constraint)->getSwingSpan1(); +} +float Physics3DConeTwistConstraint::getSwingSpan2() +{ + return static_cast(_constraint)->getSwingSpan2(); +} +float Physics3DConeTwistConstraint::getTwistSpan() +{ + return static_cast(_constraint)->getTwistSpan(); +} +float Physics3DConeTwistConstraint::getTwistAngle() +{ + return static_cast(_constraint)->getTwistAngle(); +} + +void Physics3DConeTwistConstraint::setDamping(float damping) +{ + static_cast(_constraint)->setDamping(damping); +} + +void Physics3DConeTwistConstraint::enableMotor(bool b) +{ + static_cast(_constraint)->enableMotor(b); +} +void Physics3DConeTwistConstraint::setMaxMotorImpulse(float maxMotorImpulse) +{ + static_cast(_constraint)->setMaxMotorImpulse(maxMotorImpulse); +} +void Physics3DConeTwistConstraint::setMaxMotorImpulseNormalized(float maxMotorImpulse) +{ + static_cast(_constraint)->setMaxMotorImpulseNormalized(maxMotorImpulse); +} + +float Physics3DConeTwistConstraint::getFixThresh() +{ + return static_cast(_constraint)->getFixThresh(); +} +void Physics3DConeTwistConstraint::setFixThresh(float fixThresh) +{ + static_cast(_constraint)->setFixThresh(fixThresh); +} + +void Physics3DConeTwistConstraint::setMotorTarget(const btQuaternion &q) +{ + static_cast(_constraint)->setMotorTarget(q); +} + +// same as above, but q is the desired rotation of frameA wrt frameB in constraint space +void Physics3DConeTwistConstraint::setMotorTargetInConstraintSpace(const btQuaternion &q) +{ + static_cast(_constraint)->setMotorTargetInConstraintSpace(q); +} + +cocos2d::Vec3 Physics3DConeTwistConstraint::GetPointForAngle(float fAngleInRadians, float fLength) const +{ + const auto& point = static_cast(_constraint)->GetPointForAngle(fAngleInRadians, fLength); + return convertbtVector3ToVec3(point); +} + +void Physics3DConeTwistConstraint::setFrames(const cocos2d::Mat4& frameA, const cocos2d::Mat4& frameB) +{ + const auto& btFrameA = convertMat4TobtTransform(frameA); + const auto& btFrameB = convertMat4TobtTransform(frameB); + + static_cast(_constraint)->setFrames(btFrameA, btFrameB); +} + +cocos2d::Mat4 Physics3DConeTwistConstraint::getFrameOffsetA() const +{ + const auto& trans = static_cast(_constraint)->getFrameOffsetA(); + return convertbtTransformToMat4(trans); +} + +cocos2d::Mat4 Physics3DConeTwistConstraint::getFrameOffsetB() const +{ + const auto& trans = static_cast(_constraint)->getFrameOffsetB(); + return convertbtTransformToMat4(trans); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +Physics3D6DofConstraint* Physics3D6DofConstraint::create(Physics3DRigidBody* rbB, const cocos2d::Mat4& frameInB, bool useLinearReferenceFrameB) +{ + auto ret = new Physics3D6DofConstraint(); + ret->_bodyB = rbB; + rbB->retain(); + + auto frameB = convertMat4TobtTransform(frameInB); + ret->_constraint = new btGeneric6DofConstraint(*rbB->getRigidBody(), frameB, useLinearReferenceFrameB); + + ret->autorelease(); + return ret; +} + +Physics3D6DofConstraint* Physics3D6DofConstraint::create(Physics3DRigidBody* rbA, Physics3DRigidBody* rbB, const cocos2d::Mat4& frameInA, const cocos2d::Mat4& frameInB, bool useLinearReferenceFrameA) +{ + auto ret = new Physics3D6DofConstraint(); + ret->_bodyA = rbA; + ret->_bodyB = rbB; + rbA->retain(); + rbB->retain(); + + auto frameA = convertMat4TobtTransform(frameInA); + auto frameB = convertMat4TobtTransform(frameInB); + ret->_constraint = new btGeneric6DofConstraint(*rbA->getRigidBody(), *rbB->getRigidBody(), frameA, frameB, useLinearReferenceFrameA); + + ret->autorelease(); + return ret; +} + +void Physics3D6DofConstraint::setLinearLowerLimit(const cocos2d::Vec3& linearLower) +{ + auto lower = convertVec3TobtVector3(linearLower); + static_cast(_constraint)->setLinearLowerLimit(lower); +} + +cocos2d::Vec3 Physics3D6DofConstraint::getLinearLowerLimit() +{ + btVector3 lower; + static_cast(_constraint)->getLinearLowerLimit(lower); + return convertbtVector3ToVec3(lower); +} + +void Physics3D6DofConstraint::setLinearUpperLimit(const cocos2d::Vec3& linearUpper) +{ + auto upper = convertVec3TobtVector3(linearUpper); + static_cast(_constraint)->setLinearUpperLimit(upper); +} + +cocos2d::Vec3 Physics3D6DofConstraint::getLinearUpperLimit() +{ + btVector3 upper; + static_cast(_constraint)->getLinearUpperLimit(upper); + return convertbtVector3ToVec3(upper); +} + +void Physics3D6DofConstraint::setAngularLowerLimit(const cocos2d::Vec3& angularLower) +{ + auto lower = convertVec3TobtVector3(angularLower); + static_cast(_constraint)->setAngularLowerLimit(lower); +} + +cocos2d::Vec3 Physics3D6DofConstraint::getAngularLowerLimit() +{ + btVector3 lower; + static_cast(_constraint)->getAngularLowerLimit(lower); + return convertbtVector3ToVec3(lower); +} + +void Physics3D6DofConstraint::setAngularUpperLimit(const cocos2d::Vec3& angularUpper) +{ + auto upper = convertVec3TobtVector3(angularUpper); + static_cast(_constraint)->setAngularUpperLimit(upper); +} + +cocos2d::Vec3 Physics3D6DofConstraint::getAngularUpperLimit() +{ + btVector3 upper; + static_cast(_constraint)->getAngularUpperLimit(upper); + return convertbtVector3ToVec3(upper); +} + +bool Physics3D6DofConstraint::isLimited(int limitIndex) +{ + return static_cast(_constraint)->isLimited(limitIndex); +} + +bool Physics3D6DofConstraint::getUseFrameOffset() +{ + return static_cast(_constraint)->getUseFrameOffset(); +} +void Physics3D6DofConstraint::setUseFrameOffset(bool frameOffsetOnOff) +{ + static_cast(_constraint)->setUseFrameOffset(frameOffsetOnOff); +} + +NS_CC_END + +#endif // CC_ENABLE_BULLET_INTEGRATION + +#endif //CC_USE_3D_PHYSICS diff --git a/cocos/physics3d/CCPhysics3DConstraint.h b/cocos/physics3d/CCPhysics3DConstraint.h new file mode 100644 index 0000000000..244715ba75 --- /dev/null +++ b/cocos/physics3d/CCPhysics3DConstraint.h @@ -0,0 +1,592 @@ +/**************************************************************************** + Copyright (c) 2015 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 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 __PHYSICS_3D_CONSTRAINT_H__ +#define __PHYSICS_3D_CONSTRAINT_H__ + +#include "math/CCMath.h" +#include "base/CCRef.h" +#include "base/ccConfig.h" + +#if CC_USE_3D_PHYSICS + +#if (CC_ENABLE_BULLET_INTEGRATION) + +class btTypedConstraint; + +NS_CC_BEGIN + +/** + * @addtogroup _3d + * @{ + */ + +class Physics3DRigidBody; + +/** @brief Physics3DConstraint: Constraint affects the movement of physics object, it usually connet one or two physics object. There are some types of physics constraints. */ +class CC_DLL Physics3DConstraint : public Ref +{ +public: + enum class ConstraintType + { + UNKNOWN, + POINT_TO_POINT, + HINGE, + SLIDER, + CONE_TWIST, + SIX_DOF, + }; + /** + * get the impulse that break the constraint + */ + float getBreakingImpulse() const; + + /** + * set the impulse that break the constraint + */ + void setBreakingImpulse(float impulse); + + /** + * is it enabled + */ + bool isEnabled() const; + + /** + * set enable or not + */ + void setEnabled(bool enabled); + + /** + * get rigid body a + */ + Physics3DRigidBody* getBodyA() const { return _bodyA; } + + /** + * get rigid body b + */ + Physics3DRigidBody* getBodyB() const { return _bodyB; } + + /** + * get constraint type + */ + ConstraintType getConstraintType() const { return _type; } + + /** + * get user data + */ + void setUserData(void* userData) { _userData = userData; } + + /** + * get user data + */ + void* getUserData() const { return _userData; } + + /** + * get override number of solver iterations + */ + int getOverrideNumSolverIterations() const; + + ///override the number of constraint solver iterations used to solve this constraint + ///-1 will use the default number of iterations, as specified in SolverInfo.m_numIterations + void setOverrideNumSolverIterations(int overideNumIterations); + +#if (CC_ENABLE_BULLET_INTEGRATION) + btTypedConstraint* getbtContraint() { return _constraint; } +#endif + +protected: + + Physics3DConstraint(); + virtual ~Physics3DConstraint(); + + btTypedConstraint* _constraint; + + Physics3DRigidBody* _bodyA; + Physics3DRigidBody* _bodyB; + + ConstraintType _type; + void* _userData; +}; + +/** + * Point to point constraint limits the translation so that the local pivot points of 2 rigidbodies match in worldspace. + */ +class CC_DLL Physics3DPointToPointConstraint : public Physics3DConstraint +{ +public: + /** + * create point to point constraint, limits the translation of local pivot point of rigid body A + * @param rbA The rigid body going to be fixed + * @param pivotPointInA local pivot point in A's local space + * @return created constraint + */ + static Physics3DPointToPointConstraint* create(Physics3DRigidBody* rbA, const cocos2d::Vec3& pivotPointInA); + + /** + * create point to point constraint, make the local pivot points of 2 rigid bodies match in worldspace. + * @param rbA The rigid body A going to be fixed + * @param rbB The rigid body B going to be fixed + * @param pivotPointInA local pivot point in A's local space + * @param pivotPointInB local pivot point in B's local space + * @return created constraint + */ + static Physics3DPointToPointConstraint* create(Physics3DRigidBody* rbA, Physics3DRigidBody* rbB, const cocos2d::Vec3& pivotPointInA, const cocos2d::Vec3& pivotPointInB); + + /** + * set pivot point in A's local space + */ + void setPivotPointInA(const cocos2d::Vec3& pivotA); + + /** + * set pivot point in B's local space + */ + void setPivotPointInB(const cocos2d::Vec3&& pivotB); + + /** + * get pivot point in A's local space + */ + cocos2d::Vec3 getPivotPointInA() const; + + /** + * get pivot point in B's local space + */ + cocos2d::Vec3 getPivotPointInB() const; + +CC_CONSTRUCTOR_ACCESS: + Physics3DPointToPointConstraint(); + virtual ~Physics3DPointToPointConstraint(); + +protected: + bool init(Physics3DRigidBody* rbA, const cocos2d::Vec3& pivotPointInA); + bool init(Physics3DRigidBody* rbA, Physics3DRigidBody* rbB, const cocos2d::Vec3& pivotPointInA, const cocos2d::Vec3& pivotPointInB); + +}; + +/** + * Hinge constraint restricts two additional angular degrees of freedom, so the body can only rotate around one axis, the hinge axis. This can be useful to represent doors or wheels rotating around one axis. + * hinge constraint between two rigidbodies each with a pivotpoint that descibes the axis location in local space + */ +class CC_DLL Physics3DHingeConstraint : public Physics3DConstraint +{ +public: + /** + * create hinge constraint + * @param rbA rigid body A + * @param rbAFrame rigid body A's frame + * @param useReferenceFrameA use frame A as reference + */ + static Physics3DHingeConstraint* create(Physics3DRigidBody* rbA, const cocos2d::Mat4& rbAFrame, bool useReferenceFrameA = false); + + /** + * create hinge constraint + * @param rbA rigid body A + * @param pivotInA pivot in rigid body A's local space + * @param axisInA axis in rigid body A's local space + * @param useReferenceFrameA use frame A as reference + */ + static Physics3DHingeConstraint* create(Physics3DRigidBody* rbA, const cocos2d::Vec3& pivotInA, const cocos2d::Vec3& axisInA, bool useReferenceFrameA = false); + + /** + * create hinge constraint + * @param rbA rigid body A + * @param rbB rigid body B + * @param pivotInA pivot point in A's local space + * @param pivotInB pivot point in B's local space + * @param axisInA axis in A's local space + * @param axisInB axis in B's local space + * @param useReferenceFrameA use frame A as reference + */ + static Physics3DHingeConstraint* create(Physics3DRigidBody* rbA, Physics3DRigidBody* rbB, const cocos2d::Vec3& pivotInA,const cocos2d::Vec3& pivotInB, cocos2d::Vec3& axisInA, cocos2d::Vec3& axisInB, bool useReferenceFrameA = false); + + /** + * create hinge constraint + * @param rbA rigid body A + * @param rbB rigid body B + * @param rbAFrame rigid body A's frame + * @param rbBFrame rigid body B's frame + * @param useReferenceFrameA use frame A as reference + */ + static Physics3DHingeConstraint* create(Physics3DRigidBody* rbA, Physics3DRigidBody* rbB, const cocos2d::Mat4& rbAFrame, const cocos2d::Mat4& rbBFrame, bool useReferenceFrameA = false); + + /** + * get rigid body A's frame offset + */ + cocos2d::Mat4 getFrameOffsetA() const; + + /** + * get rigid body B's frame offset + */ + cocos2d::Mat4 getFrameOffsetB() const; + + /** + * set frames for rigid body A and B + */ + void setFrames(const cocos2d::Mat4& frameA, const cocos2d::Mat4& frameB); + + /** + * set angular only + */ + void setAngularOnly(bool angularOnly); + + /** enable angular motor */ + void enableAngularMotor(bool enableMotor, float targetVelocity, float maxMotorImpulse); + + // extra motor API, including ability to set a target rotation (as opposed to angular velocity) + // note: setMotorTarget sets angular velocity under the hood, so you must call it every tick to + // maintain a given angular target. + void enableMotor(bool enableMotor); + /** set max motor impulse */ + void setMaxMotorImpulse(float maxMotorImpulse); + /** + * set motor target + */ + void setMotorTarget(const cocos2d::Quaternion& qAinB, float dt); + /** set motor target */ + void setMotorTarget(float targetAngle, float dt); + + /** set limit */ + void setLimit(float low, float high, float _softness = 0.9f, float _biasFactor = 0.3f, float _relaxationFactor = 1.0f); + /**set axis*/ + void setAxis(const cocos2d::Vec3& axisInA); + /**get lower limit*/ + float getLowerLimit() const; + /**get upper limit*/ + float getUpperLimit() const; + /**get hinge angle*/ + float getHingeAngle(); + /**get hinge angle*/ + float getHingeAngle(const cocos2d::Mat4& transA, const cocos2d::Mat4& transB); + + /**get A's frame */ + cocos2d::Mat4 getAFrame(); + /**get B's frame*/ + cocos2d::Mat4 getBFrame(); + /**get angular only*/ + bool getAngularOnly(); + /**get enable angular motor*/ + bool getEnableAngularMotor(); + /**get motor target velosity*/ + float getMotorTargetVelosity(); + /**get max motor impulse*/ + float getMaxMotorImpulse(); + + /** access for UseFrameOffset*/ + bool getUseFrameOffset(); + /**set use frame offset*/ + void setUseFrameOffset(bool frameOffsetOnOff); + +CC_CONSTRUCTOR_ACCESS: + Physics3DHingeConstraint() + { + _type = ConstraintType::HINGE; + } + virtual ~Physics3DHingeConstraint(){} +}; + +/** + * It allows the body to rotate around x axis and translate along this axis. + * softness, restitution and damping for different cases + * DirLin - moving inside linear limits + * LimLin - hitting linear limit + * DirAng - moving inside angular limits + * LimAng - hitting angular limit + * OrthoLin, OrthoAng - against constraint axis + */ +class CC_DLL Physics3DSliderConstraint : public Physics3DConstraint +{ +public: + /** + * create slider constraint + * @param rbA rigid body A + * @param rbB rigid body B + * @param frameInA frame in A's local space + * @param frameInB frame in B's local space + * @param useLinearReferenceFrameA use fixed frame A for linear limits + */ + static Physics3DSliderConstraint* create(Physics3DRigidBody* rbA, Physics3DRigidBody* rbB, const cocos2d::Mat4& frameInA, const cocos2d::Mat4& frameInB ,bool useLinearReferenceFrameA); + + /**get A's frame offset*/ + cocos2d::Mat4 getFrameOffsetA() const; + /**get B's frame offset*/ + cocos2d::Mat4 getFrameOffsetB() const; + /**get lower linear limit*/ + float getLowerLinLimit(); + /**set lower linear limit*/ + void setLowerLinLimit(float lowerLimit); + /**get upper linear limit*/ + float getUpperLinLimit(); + /**set upper linear limit*/ + void setUpperLinLimit(float upperLimit); + /**get lower angular limit*/ + float getLowerAngLimit(); + /**set lower angualr limit*/ + void setLowerAngLimit(float lowerLimit); + /**get upper anglular limit*/ + float getUpperAngLimit(); + /**set upper anglular limit*/ + void setUpperAngLimit(float upperLimit); + /**use A's frame as linear refference*/ + bool getUseLinearReferenceFrameA(); + + float getSoftnessDirLin(); + float getRestitutionDirLin(); + float getDampingDirLin(); + float getSoftnessDirAng(); + float getRestitutionDirAng(); + float getDampingDirAng(); + float getSoftnessLimLin(); + float getRestitutionLimLin(); + float getDampingLimLin(); + float getSoftnessLimAng(); + float getRestitutionLimAng(); + float getDampingLimAng(); + float getSoftnessOrthoLin(); + float getRestitutionOrthoLin(); + float getDampingOrthoLin(); + float getSoftnessOrthoAng(); + float getRestitutionOrthoAng(); + float getDampingOrthoAng(); + void setSoftnessDirLin(float softnessDirLin); + void setRestitutionDirLin(float restitutionDirLin); + void setDampingDirLin(float dampingDirLin); + void setSoftnessDirAng(float softnessDirAng); + void setRestitutionDirAng(float restitutionDirAng); + void setDampingDirAng(float dampingDirAng); + void setSoftnessLimLin(float softnessLimLin); + void setRestitutionLimLin(float restitutionLimLin); + void setDampingLimLin(float dampingLimLin); + void setSoftnessLimAng(float softnessLimAng); + void setRestitutionLimAng(float restitutionLimAng); + void setDampingLimAng(float dampingLimAng); + void setSoftnessOrthoLin(float softnessOrthoLin); + void setRestitutionOrthoLin(float restitutionOrthoLin); + void setDampingOrthoLin(float dampingOrthoLin); + void setSoftnessOrthoAng(float softnessOrthoAng); + void setRestitutionOrthoAng(float restitutionOrthoAng); + void setDampingOrthoAng(float dampingOrthoAng); + void setPoweredLinMotor(bool onOff); + bool getPoweredLinMotor(); + void setTargetLinMotorVelocity(float targetLinMotorVelocity); + float getTargetLinMotorVelocity(); + void setMaxLinMotorForce(float maxLinMotorForce); + float getMaxLinMotorForce(); + void setPoweredAngMotor(bool onOff); + bool getPoweredAngMotor(); + void setTargetAngMotorVelocity(float targetAngMotorVelocity); + float getTargetAngMotorVelocity(); + void setMaxAngMotorForce(float maxAngMotorForce); + float getMaxAngMotorForce(); + + float getLinearPos() const; + float getAngularPos() const; + + /** access for UseFrameOffset*/ + bool getUseFrameOffset(); + /**set use frame offset*/ + void setUseFrameOffset(bool frameOffsetOnOff); + + /**set frames for rigid body A and B*/ + void setFrames(const cocos2d::Mat4& frameA, const cocos2d::Mat4& frameB); + +CC_CONSTRUCTOR_ACCESS: + Physics3DSliderConstraint() + { + _type = ConstraintType::SLIDER; + } + virtual ~Physics3DSliderConstraint(){} +}; + +/** + * It is a special point to point constraint that adds cone and twist axis limits. The x-axis serves as twist axis. + */ +class CC_DLL Physics3DConeTwistConstraint : public Physics3DConstraint +{ +public: + /** + * create cone twist constraint + * rbA rigid body A + * frameA A's local frame + */ + static Physics3DConeTwistConstraint* create(Physics3DRigidBody* rbA, const cocos2d::Mat4& frameA); + /** + * create cone twist constraint + * rbA rigid body A + * rbB rigid body B + * frameA rigid body A's local frame + * frameB rigid body B's local frame + */ + static Physics3DConeTwistConstraint* create(Physics3DRigidBody* rbA, Physics3DRigidBody* rbB, const cocos2d::Mat4& frameA, const cocos2d::Mat4& frameB); + + /** + * set limits + * @param swingSpan1 swing span1 + * @param swingSpan2 swing span2 + * @param twistSpan twist span + * @param softness 0->1, recommend ~0.8->1. Describes % of limits where movement is free. Beyond this softness %, the limit is gradually enforced until the "hard" (1.0) limit is reached. + * @param biasFactor 0->1?, recommend 0.3 +/-0.3 or so. Strength with which constraint resists zeroth order (angular, not angular velocity) limit violation. + * @param relaxationFactor 0->1, recommend to stay near 1. the lower the value, the less the constraint will fight velocities which violate the angular limits. + */ + void setLimit(float swingSpan1,float swingSpan2,float twistSpan, float softness = 1.f, float biasFactor = 0.3f, float relaxationFactor = 1.0f); + + /**get A's frame*/ + cocos2d::Mat4 getAFrame(); + /**get B's frame*/ + cocos2d::Mat4 getBFrame(); + + /**get swing span1*/ + float getSwingSpan1(); + /**get swing span2*/ + float getSwingSpan2(); + /**get twist span*/ + float getTwistSpan(); + /**get twist angle*/ + float getTwistAngle(); + + /**set damping*/ + void setDamping(float damping); + + /**enable motor*/ + void enableMotor(bool b); + /**set max motor impulse*/ + void setMaxMotorImpulse(float maxMotorImpulse); + /**set max motor impulse normalize*/ + void setMaxMotorImpulseNormalized(float maxMotorImpulse); + /**get fix thresh*/ + float getFixThresh(); + /**set fix thresh*/ + void setFixThresh(float fixThresh); + + /** + * setMotorTarget + * @param q the desired rotation of bodyA wrt bodyB. Note: if q violates the joint limits, the internal target is clamped to avoid conflicting impulses (very bad for stability), also don't forget to enableMotor() + */ + void setMotorTarget(const btQuaternion &q); + + /** setMotorTarget, q is the desired rotation of frameA wrt frameB in constraint space*/ + void setMotorTargetInConstraintSpace(const btQuaternion &q); + + /**get point for angle*/ + cocos2d::Vec3 GetPointForAngle(float fAngleInRadians, float fLength) const; + + /**set A and B's frame*/ + virtual void setFrames(const cocos2d::Mat4& frameA, const cocos2d::Mat4& frameB); + + /**get A's frame offset*/ + cocos2d::Mat4 getFrameOffsetA() const; + + /**get B's frame offset*/ + cocos2d::Mat4 getFrameOffsetB() const; + +CC_CONSTRUCTOR_ACCESS: + Physics3DConeTwistConstraint() + { + _type = ConstraintType::CONE_TWIST; + } + virtual ~Physics3DConeTwistConstraint(){} +}; + +/** + * This generic constraint can emulate a variety of standard constraints, by configuring each of the 6 degrees of freedom (dof). + * The first 3 dof axis are linear axis, which represent translation of rigidbodies, and the latter 3 dof axis represent the angular motion. + * Each axis can be either locked, free or limited. All axis are locked by default. + * For each axis: + * Lowerlimit == Upperlimit -> axis is locked. + * Lowerlimit > Upperlimit -> axis is free + * Lowerlimit < Upperlimit -> axis it limited in that range + */ +class CC_DLL Physics3D6DofConstraint : public Physics3DConstraint +{ +public: + /** + * create 6 dof constraint + * @param rbA rigid body A + * @param rbB rigid body B + * @param frameInA frame in A's local space + * @param frameInB frame in B's local space + * @param useLinearReferenceFrameA use fixed frame A for linear limits + */ + static Physics3D6DofConstraint* create(Physics3DRigidBody* rbA, Physics3DRigidBody* rbB, const cocos2d::Mat4& frameInA, const cocos2d::Mat4& frameInB, bool useLinearReferenceFrameA); + + /** + * create 6 dof constraint + * @param rbB rigid body B + * @param frameInB frame in B's local space + * @param useLinearReferenceFrameB use fixed frame B for linear limits + */ + static Physics3D6DofConstraint* create(Physics3DRigidBody* rbB, const cocos2d::Mat4& frameInB, bool useLinearReferenceFrameB); + + /**set linear lower limit*/ + void setLinearLowerLimit(const cocos2d::Vec3& linearLower); + + /**get linear lower limit*/ + cocos2d::Vec3 getLinearLowerLimit(); + + /**set linear upper limit*/ + void setLinearUpperLimit(const cocos2d::Vec3& linearUpper); + + /**get linear upper limit*/ + cocos2d::Vec3 getLinearUpperLimit(); + + /**set angular lower limit*/ + void setAngularLowerLimit(const cocos2d::Vec3& angularLower); + + /**get angular lower limit*/ + cocos2d::Vec3 getAngularLowerLimit(); + + /**set angular upper limit*/ + void setAngularUpperLimit(const cocos2d::Vec3& angularUpper); + + /**get angular upper limit*/ + cocos2d::Vec3 getAngularUpperLimit(); + + /** + * is limited? + * @param limitIndex first 3 are linear, next 3 are angular + */ + bool isLimited(int limitIndex); + + /** access for UseFrameOffset*/ + bool getUseFrameOffset(); + /**set use frame offset*/ + void setUseFrameOffset(bool frameOffsetOnOff); + + +CC_CONSTRUCTOR_ACCESS: + Physics3D6DofConstraint() + { + _type = ConstraintType::SIX_DOF; + } + virtual ~Physics3D6DofConstraint(){} +}; + +// end of 3d group +/// @} + +NS_CC_END + +#endif // CC_ENABLE_BULLET_INTEGRATION + +#endif // CC_USE_3D_PHYSICS + +#endif // __PHYSICS_3D_CONSTRAINT_H__ diff --git a/cocos/physics3d/CCPhysics3DDebugDrawer.cpp b/cocos/physics3d/CCPhysics3DDebugDrawer.cpp new file mode 100644 index 0000000000..b7b1eb4e8e --- /dev/null +++ b/cocos/physics3d/CCPhysics3DDebugDrawer.cpp @@ -0,0 +1,203 @@ +/**************************************************************************** + Copyright (c) 2015 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 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 "CCPhysics3D.h" +#include "base/CCConfiguration.h" +#include "base/ccMacros.h" +#include "base/CCDirector.h" +#include "renderer/CCGLProgram.h" +#include "renderer/CCRenderer.h" +#include "renderer/ccGLStateCache.h" +#include "renderer/CCGLProgramCache.h" + +#if CC_USE_3D_PHYSICS + +#if (CC_ENABLE_BULLET_INTEGRATION) + +NS_CC_BEGIN + +void Physics3DDebugDrawer::drawLine( const btVector3& from,const btVector3& to,const btVector3& color ) +{ + int count = 2; + ensureCapacity(count); + + Vec3 col = convertbtVector3ToVec3(color); + + V3F_V4F *lines = (V3F_V4F *)(_buffer + _bufferCount); + lines[0].vertex = convertbtVector3ToVec3(from); + lines[0].color = Vec4(col.x, col.y, col.z, 1.0f); + lines[1].vertex = convertbtVector3ToVec3(to); + lines[1].color = Vec4(col.x, col.y, col.z, 1.0f); + + _bufferCount += count; + _dirty = true; +} + +void Physics3DDebugDrawer::drawContactPoint( const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color ) +{ + drawLine(PointOnB, PointOnB + normalOnB * distance, color); +} + +void Physics3DDebugDrawer::reportErrorWarning( const char* warningString ) +{ + CCLOG("%s", warningString); +} + +void Physics3DDebugDrawer::draw3dText( const btVector3& location,const char* textString ) +{ + +} + +void Physics3DDebugDrawer::setDebugMode( int debugMode ) +{ + _debugMode = debugMode; +} + +int Physics3DDebugDrawer::getDebugMode() const +{ + return _debugMode; +} + +void Physics3DDebugDrawer::draw( Renderer *renderer) +{ + _customCommand.init(0, Mat4::IDENTITY, 0); + _customCommand.func = CC_CALLBACK_0(Physics3DDebugDrawer::drawImplementation, this, Mat4::IDENTITY, 0); + renderer->addCommand(&_customCommand); +} + +Physics3DDebugDrawer::Physics3DDebugDrawer() + : _vao(0) + , _vbo(0) + , _bufferCapacity(0) + , _bufferCount(0) + , _buffer(nullptr) + , _blendFunc(BlendFunc::DISABLE) + , _dirty(true) + , _debugMode(DBG_DrawWireframe | DBG_DrawConstraints | DBG_DrawConstraintLimits) +{ + init(); +} + +Physics3DDebugDrawer::~Physics3DDebugDrawer() +{ + free(_buffer); + + if (_vao) + { + glDeleteVertexArrays(1, &_vao); + _vao = 0; + } + if (_vbo) + { + glDeleteBuffers(1, &_vbo); + _vbo = 0; + } +} + +void Physics3DDebugDrawer::ensureCapacity( int count ) +{ + CCASSERT(count>=0, "capacity must be >= 0"); + + if(_bufferCount + count > _bufferCapacity) + { + _bufferCapacity += MAX(_bufferCapacity, count); + _buffer = (V3F_V4F*)realloc(_buffer, _bufferCapacity*sizeof(V3F_V4F)); + } +} + +void Physics3DDebugDrawer::drawImplementation( const Mat4 &transform, uint32_t flags ) +{ + _program->use(); + _program->setUniformsForBuiltins(transform); + glEnable(GL_DEPTH_TEST); + GL::blendFunc(_blendFunc.src, _blendFunc.dst); + + if (_dirty) + { + glBindBuffer(GL_ARRAY_BUFFER, _vbo); + glBufferData(GL_ARRAY_BUFFER, sizeof(V3F_V4F) * _bufferCapacity, _buffer, GL_STREAM_DRAW); + _dirty = false; + } + if (Configuration::getInstance()->supportsShareableVAO()) + { + GL::bindVAO(_vao); + } + else + { + GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_COLOR); + + glBindBuffer(GL_ARRAY_BUFFER, _vbo); + // vertex + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(V3F_V4F), (GLvoid *)offsetof(V3F_V4F, vertex)); + // color + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(V3F_V4F), (GLvoid *)offsetof(V3F_V4F, color)); + } + + glDrawArrays(GL_LINES, 0, _bufferCount); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,_bufferCount); + glDisable(GL_DEPTH_TEST); +} + +void Physics3DDebugDrawer::init() +{ + _program = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_COLOR); + + ensureCapacity(512); + + if (Configuration::getInstance()->supportsShareableVAO()) + { + glGenVertexArrays(1, &_vao); + GL::bindVAO(_vao); + } + + glGenBuffers(1, &_vbo); + glBindBuffer(GL_ARRAY_BUFFER, _vbo); + glBufferData(GL_ARRAY_BUFFER, sizeof(V3F_V4F)* _bufferCapacity, _buffer, GL_STREAM_DRAW); + + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(V3F_V4F), (GLvoid *)offsetof(V3F_V4F, vertex)); + + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(V3F_V4F), (GLvoid *)offsetof(V3F_V4F, color)); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + + if (Configuration::getInstance()->supportsShareableVAO()) + { + GL::bindVAO(0); + } +} + +void Physics3DDebugDrawer::clear() +{ + _bufferCount = 0; +} + +NS_CC_END + +#endif // CC_ENABLE_BULLET_INTEGRATION + +#endif //CC_USE_3D_PHYSICS diff --git a/cocos/physics3d/CCPhysics3DDebugDrawer.h b/cocos/physics3d/CCPhysics3DDebugDrawer.h new file mode 100644 index 0000000000..fcae14b648 --- /dev/null +++ b/cocos/physics3d/CCPhysics3DDebugDrawer.h @@ -0,0 +1,108 @@ +/**************************************************************************** + Copyright (c) 2015 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 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 __PHYSICS_3D_VIEWER_H__ +#define __PHYSICS_3D_VIEWER_H__ + +#include "math/CCMath.h" +#include "base/CCRef.h" +#include "base/ccTypes.h" +#include "base/ccConfig.h" +#include "renderer/CCCustomCommand.h" + +#if CC_USE_3D_PHYSICS + +#if (CC_ENABLE_BULLET_INTEGRATION) +#include "renderer/CCCustomCommand.h" +#include "bullet/LinearMath/btIDebugDraw.h" + +NS_CC_BEGIN + +/** + * @addtogroup _3d + * @{ + */ + +class GLProgram; +class Renderer; + +/** @brief Physics3DDebugDrawer: debug draw the physics object, used by Physics3DWorld */ +class Physics3DDebugDrawer : public btIDebugDraw +{ +public: + + Physics3DDebugDrawer(); + virtual ~Physics3DDebugDrawer(); + + void draw(cocos2d::Renderer *renderer); + + // override function + virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color) override; + virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color) override; + virtual void reportErrorWarning(const char* warningString) override; + virtual void draw3dText(const btVector3& location,const char* textString) override; + virtual void setDebugMode(int debugMode) override; + virtual int getDebugMode() const override; + + void clear(); + +protected: + + void init(); + void ensureCapacity(int count); + void drawImplementation(const cocos2d::Mat4 &transform, uint32_t flags); + +protected: + + struct V3F_V4F + { + cocos2d::Vec3 vertex; + cocos2d::Vec4 color; + }; + + GLuint _vao; + GLuint _vbo; + + int _bufferCapacity; + GLsizei _bufferCount; + V3F_V4F* _buffer; + + cocos2d::BlendFunc _blendFunc; + cocos2d::CustomCommand _customCommand; + cocos2d::GLProgram *_program; + + bool _dirty; + int _debugMode; +}; + +// end of 3d group +/// @} + +NS_CC_END + +#endif // CC_ENABLE_BULLET_INTEGRATION + +#endif // CC_USE_3D_PHYSICS + +#endif // __PHYSICS_3D_VIEWER_H__ diff --git a/cocos/physics3d/CCPhysics3DObject.cpp b/cocos/physics3d/CCPhysics3DObject.cpp new file mode 100644 index 0000000000..7fe4c26135 --- /dev/null +++ b/cocos/physics3d/CCPhysics3DObject.cpp @@ -0,0 +1,377 @@ +/**************************************************************************** + Copyright (c) 2015 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 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 "CCPhysics3D.h" +#include "base/ccUTF8.h" + +#if CC_USE_3D_PHYSICS + +#if (CC_ENABLE_BULLET_INTEGRATION) + +#include "bullet/btBulletCollisionCommon.h" +#include "bullet/btBulletDynamicsCommon.h" + +NS_CC_BEGIN + +Physics3DRigidBody::Physics3DRigidBody() +: _btRigidBody(nullptr) +, _physics3DShape(nullptr) +{ + +} + +Physics3DRigidBody::~Physics3DRigidBody() +{ + if (_physicsWorld) + { + for(auto constraint : _constraintList) + { + _physicsWorld->removePhysics3DConstraint(constraint); + } + _constraintList.clear(); + } + auto ms = _btRigidBody->getMotionState(); + CC_SAFE_DELETE(ms); + CC_SAFE_DELETE(_btRigidBody); + CC_SAFE_RELEASE(_physics3DShape); +} + +Physics3DRigidBody* Physics3DRigidBody::create(Physics3DRigidBodyDes* info) +{ + auto ret = new (std::nothrow) Physics3DRigidBody(); + if (ret->init(info)) + { + ret->autorelease(); + return ret; + } + + CC_SAFE_DELETE(ret); + return ret; +} + +bool Physics3DRigidBody::init(Physics3DRigidBodyDes* info) +{ + if (info->shape == nullptr) + return false; + + btScalar mass = info->mass; + auto shape = info->shape->getbtShape(); + auto localInertia = convertVec3TobtVector3(info->localInertia); + if (mass != 0.f) + { + shape->calculateLocalInertia(mass,localInertia); + } + + auto transform = convertMat4TobtTransform(info->originalTransform); + btDefaultMotionState* myMotionState = new btDefaultMotionState(transform); + btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,shape,localInertia); + _btRigidBody = new btRigidBody(rbInfo); + _type = Physics3DObject::PhysicsObjType::RIGID_BODY; + _physics3DShape = info->shape; + _physics3DShape->retain(); + if (info->disableSleep) + _btRigidBody->setActivationState(DISABLE_DEACTIVATION); + return true; +} + +void Physics3DRigidBody::setActive(bool active) +{ + if (_btRigidBody) + { + _btRigidBody->setActivationState(active ? ACTIVE_TAG : WANTS_DEACTIVATION); + } +} + +void Physics3DRigidBody::applyForce( const cocos2d::Vec3& force, const cocos2d::Vec3& rel_pos ) +{ + _btRigidBody->applyForce(convertVec3TobtVector3(force), convertVec3TobtVector3(rel_pos)); +} + +void Physics3DRigidBody::setLinearVelocity( const cocos2d::Vec3& lin_vel ) +{ + _btRigidBody->setLinearVelocity(convertVec3TobtVector3(lin_vel)); +} + +void Physics3DRigidBody::applyCentralForce( const cocos2d::Vec3& force ) +{ + _btRigidBody->applyCentralForce(convertVec3TobtVector3(force)); +} + +void Physics3DRigidBody::applyCentralImpulse( const cocos2d::Vec3& impulse ) +{ + _btRigidBody->applyCentralImpulse(convertVec3TobtVector3(impulse)); +} + +void Physics3DRigidBody::applyTorque( const cocos2d::Vec3& torque ) +{ + _btRigidBody->applyTorque(convertVec3TobtVector3(torque)); +} + +void Physics3DRigidBody::applyTorqueImpulse( const cocos2d::Vec3& torque ) +{ + _btRigidBody->applyTorqueImpulse(convertVec3TobtVector3(torque)); +} + +void Physics3DRigidBody::applyImpulse( const cocos2d::Vec3& impulse, const cocos2d::Vec3& rel_pos ) +{ + _btRigidBody->applyImpulse(convertVec3TobtVector3(impulse), convertVec3TobtVector3(rel_pos)); +} + +void Physics3DRigidBody::applyDamping( float timeStep ) +{ + _btRigidBody->applyDamping(timeStep); +} + +cocos2d::Vec3 Physics3DRigidBody::getLinearVelocity() const +{ + return convertbtVector3ToVec3(_btRigidBody->getLinearVelocity()); +} + +void Physics3DRigidBody::setLinearFactor( const cocos2d::Vec3& linearFactor ) +{ + _btRigidBody->setLinearFactor(convertVec3TobtVector3(linearFactor)); +} + +cocos2d::Vec3 Physics3DRigidBody::getLinearFactor() const +{ + return convertbtVector3ToVec3(_btRigidBody->getLinearFactor()); +} + +void Physics3DRigidBody::setAngularFactor( const cocos2d::Vec3& angFac ) +{ + _btRigidBody->setAngularFactor(convertVec3TobtVector3(angFac)); +} + +void Physics3DRigidBody::setAngularFactor( float angFac ) +{ + _btRigidBody->setAngularFactor(angFac); +} + +cocos2d::Vec3 Physics3DRigidBody::getAngularFactor() const +{ + return convertbtVector3ToVec3(_btRigidBody->getAngularFactor()); +} + +void Physics3DRigidBody::setAngularVelocity( const cocos2d::Vec3& ang_vel ) +{ + _btRigidBody->setAngularVelocity(convertVec3TobtVector3(ang_vel)); +} + +cocos2d::Vec3 Physics3DRigidBody::getAngularVelocity() const +{ + return convertbtVector3ToVec3(_btRigidBody->getAngularVelocity()); +} + +void Physics3DRigidBody::setCenterOfMassTransform( const cocos2d::Mat4& xform ) +{ + _btRigidBody->setCenterOfMassTransform(convertMat4TobtTransform(xform)); +} + +cocos2d::Mat4 Physics3DRigidBody::getCenterOfMassTransform() const +{ + return convertbtTransformToMat4(_btRigidBody->getCenterOfMassTransform()); +} + +void Physics3DRigidBody::setDamping( float lin_damping, float ang_damping ) +{ + _btRigidBody->setDamping(lin_damping, ang_damping); +} + +float Physics3DRigidBody::getLinearDamping() const +{ + return _btRigidBody->getLinearDamping(); +} + +float Physics3DRigidBody::getAngularDamping() const +{ + return _btRigidBody->getAngularDamping(); +} + +void Physics3DRigidBody::setGravity( const cocos2d::Vec3& acceleration ) +{ + _btRigidBody->setGravity(convertVec3TobtVector3(acceleration)); +} + +cocos2d::Vec3 Physics3DRigidBody::getGravity() const +{ + return convertbtVector3ToVec3(_btRigidBody->getGravity()); +} + +void Physics3DRigidBody::setInvInertiaDiagLocal( const cocos2d::Vec3& diagInvInertia ) +{ + _btRigidBody->setInvInertiaDiagLocal(convertVec3TobtVector3(diagInvInertia)); +} + +cocos2d::Vec3 Physics3DRigidBody::getInvInertiaDiagLocal() const +{ + return convertbtVector3ToVec3(_btRigidBody->getInvInertiaDiagLocal()); +} + +void Physics3DRigidBody::setMassProps( float mass, const cocos2d::Vec3& inertia ) +{ + _btRigidBody->setMassProps(mass, convertVec3TobtVector3(inertia)); +} + +float Physics3DRigidBody::getInvMass() const +{ + return _btRigidBody->getInvMass(); +} + +cocos2d::Vec3 Physics3DRigidBody::getTotalForce() const +{ + return convertbtVector3ToVec3(_btRigidBody->getTotalForce()); +} + +cocos2d::Vec3 Physics3DRigidBody::getTotalTorque() const +{ + return convertbtVector3ToVec3(_btRigidBody->getTotalTorque()); +} + +void Physics3DRigidBody::setRestitution( float rest ) +{ + _btRigidBody->setRestitution(rest); +} + +float Physics3DRigidBody::getRestitution() const +{ + return _btRigidBody->getRestitution(); +} + +void Physics3DRigidBody::setFriction( float frict ) +{ + _btRigidBody->setFriction(frict); +} + +float Physics3DRigidBody::getFriction() const +{ + return _btRigidBody->getFriction(); +} + +void Physics3DRigidBody::setRollingFriction( float frict ) +{ + _btRigidBody->setRollingFriction(frict); +} + +float Physics3DRigidBody::getRollingFriction() const +{ + return _btRigidBody->getRollingFriction(); +} + +void Physics3DRigidBody::setHitFraction( float hitFraction ) +{ + _btRigidBody->setHitFraction(hitFraction); +} + +float Physics3DRigidBody::getHitFraction() const +{ + return _btRigidBody->getHitFraction(); +} + +void Physics3DRigidBody::setCcdMotionThreshold( float ccdMotionThreshold ) +{ + _btRigidBody->setCcdMotionThreshold(ccdMotionThreshold); +} + +float Physics3DRigidBody::getCcdMotionThreshold() const +{ + return _btRigidBody->getCcdMotionThreshold(); +} + +void Physics3DRigidBody::setCcdSweptSphereRadius( float radius ) +{ + _btRigidBody->setCcdSweptSphereRadius(radius); +} + +float Physics3DRigidBody::getCcdSweptSphereRadius() const +{ + return _btRigidBody->getCcdSweptSphereRadius(); +} + +void Physics3DRigidBody::addConstraint( Physics3DConstraint *constraint ) +{ + auto iter = std::find(_constraintList.begin(), _constraintList.end(), constraint); + if (iter == _constraintList.end()){ + _constraintList.push_back(constraint); + constraint->retain(); + } +} + +void Physics3DRigidBody::removeConstraint( Physics3DConstraint *constraint ) +{ + auto iter = std::find(_constraintList.begin(), _constraintList.end(), constraint); + if (iter != _constraintList.end()){ + constraint->release(); + _constraintList.erase(iter); + } +} + +void Physics3DRigidBody::removeConstraint( unsigned int idx ) +{ + CCASSERT(idx < _constraintList.size(), "idx < _constraintList.size()"); + removeConstraint(_constraintList[idx]); +} + +Physics3DConstraint* Physics3DRigidBody::getConstraint( unsigned int idx ) const +{ + CCASSERT(idx < _constraintList.size(), "idx < _constraintList.size()"); + return _constraintList[idx]; +} + +unsigned int Physics3DRigidBody::getConstraintCount() const +{ + return (unsigned int)_constraintList.size(); +} + +cocos2d::Mat4 Physics3DRigidBody::getWorldTransform() const +{ + const auto& transform = _btRigidBody->getWorldTransform(); + return convertbtTransformToMat4(transform); +} + +void Physics3DRigidBody::setKinematic(bool kinematic) +{ + if (kinematic) + { + _btRigidBody->setCollisionFlags(_btRigidBody->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + _btRigidBody->setActivationState(DISABLE_DEACTIVATION); + } + else + { + _btRigidBody->setCollisionFlags(_btRigidBody->getCollisionFlags() & ~btCollisionObject::CF_KINEMATIC_OBJECT); + _btRigidBody->setActivationState(ACTIVE_TAG); + } +} + +bool Physics3DRigidBody::isKinematic() const +{ + if (_btRigidBody) + return _btRigidBody->isKinematicObject(); + return false; +} + +NS_CC_END + +#endif // CC_ENABLE_BULLET_INTEGRATION + +#endif // CC_USE_3D_PHYSICS diff --git a/cocos/physics3d/CCPhysics3DObject.h b/cocos/physics3d/CCPhysics3DObject.h new file mode 100644 index 0000000000..a26d209b21 --- /dev/null +++ b/cocos/physics3d/CCPhysics3DObject.h @@ -0,0 +1,370 @@ +/**************************************************************************** + Copyright (c) 2015 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 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 __PHYSICS_3D_OBJECT_H__ +#define __PHYSICS_3D_OBJECT_H__ + +#include "math/CCMath.h" +#include "base/CCRef.h" +#include "base/ccConfig.h" + +#include + +#if CC_USE_3D_PHYSICS + +#if (CC_ENABLE_BULLET_INTEGRATION) + +class btCollisionShape; +class btRigidBody; +class btPersistentManifold; + +NS_CC_BEGIN +/** + * @addtogroup _3d + * @{ + */ + +class Physics3DShape; +class Physics3DWorld; +class Physics3DConstraint; +class Physics3DObject; +/** + * @brief The collision information of Physics3DObject. + */ +struct CC_DLL Physics3DCollisionInfo +{ + struct CollisionPoint + { + Vec3 localPositionOnA; + Vec3 worldPositionOnA; + Vec3 localPositionOnB; + Vec3 worldPositionOnB; + Vec3 worldNormalOnB; + }; + + Physics3DObject *objA; + Physics3DObject *objB; + std::vector collisionPointList; +}; +/** + * @brief Inherit from Ref, base class + */ +class CC_DLL Physics3DObject : public Ref +{ +public: + typedef std::function CollisionCallbackFunc; + + enum class PhysicsObjType + { + UNKNOWN = 0, + RIGID_BODY, + }; + + /** Get the Physics3DObject Type. */ + virtual PhysicsObjType getObjType() const { return _type; } + + /** Set the user data. */ + void setUserData(void* userData) { _userData = userData; } + + /** Get the user data. */ + void* getUserData() const { return _userData; } + + /** Internal method. Set the pointer of Physics3DWorld. */ + void setPhysicsWorld(Physics3DWorld* world) { _physicsWorld = world; }; + + /** Get the pointer of Physics3DWorld. */ + Physics3DWorld* getPhysicsWorld() const { return _physicsWorld; } + + /** Get the world matrix of Physics3DObject. */ + virtual cocos2d::Mat4 getWorldTransform() const = 0; + + /** Set the collision callback function. */ + void setCollisionCallback(const CollisionCallbackFunc &func) { _collisionCallbackFunc = func; }; + + /** Get the collision callback function. */ + const CollisionCallbackFunc& getCollisionCallback() const { return _collisionCallbackFunc; } + + /** Check has collision callback function. */ + bool needCollisionCallback() { return _collisionCallbackFunc != nullptr; }; + + /** Set the mask of Physics3DObject. */ + void setMask(unsigned int mask) { _mask = mask; }; + + /** Get the mask of Physics3DObject. */ + unsigned int getMask() const { return _mask; }; + +CC_CONSTRUCTOR_ACCESS: + Physics3DObject() + : _type(PhysicsObjType::UNKNOWN) + , _userData(nullptr) + , _isEnabled(true) + , _physicsWorld(nullptr) + , _mask(-1) + { + + } + virtual ~Physics3DObject(){} + + +protected: + bool _isEnabled; + PhysicsObjType _type; + void* _userData; + Physics3DWorld* _physicsWorld; + CollisionCallbackFunc _collisionCallbackFunc; + unsigned int _mask; +}; + +/** + * @brief The description of Physics3DRigidBody. + */ +struct CC_DLL Physics3DRigidBodyDes +{ + float mass; //Note: mass equals zero means static, default 0 + cocos2d::Vec3 localInertia; //default (0, 0, 0) + Physics3DShape* shape; + cocos2d::Mat4 originalTransform; + bool disableSleep; //it is always active if disabled + + Physics3DRigidBodyDes() + : mass(0.f) + , localInertia(0.f, 0.f, 0.f) + , shape(nullptr) + , disableSleep(false) + { + + } +}; + +/** + * @brief Inherit from Physics3DObject, the main class for rigid body objects + */ +class CC_DLL Physics3DRigidBody : public Physics3DObject +{ + friend class Physics3DWorld; +public: + + /** + * Creates a Physics3DRigidBody with Physics3DRigidBody. + * + * @return An autoreleased Physics3DRigidBody object. + */ + static Physics3DRigidBody* create(Physics3DRigidBodyDes* info); + + /** Get the pointer of btRigidBody. */ + btRigidBody* getRigidBody() const { return _btRigidBody; } + + /** + * Apply a force. + * + * @param force the value of the force + * @param rel_pos the position of the force + */ + void applyForce(const cocos2d::Vec3& force, const cocos2d::Vec3& rel_pos); + + /** + * Apply a central force. + * + * @param force the value of the force + */ + void applyCentralForce(const cocos2d::Vec3& force); + + /** + * Apply a central impulse. + * + * @param impulse the value of the impulse + */ + void applyCentralImpulse(const cocos2d::Vec3& impulse); + + /** + * Apply a torque. + * + * @param torque the value of the torque + */ + void applyTorque(const cocos2d::Vec3& torque); + + /** + * Apply a torque impulse. + * + * @param torque the value of the torque + */ + void applyTorqueImpulse(const cocos2d::Vec3& torque); + + /** + * Apply a impulse. + * + * @param impulse the value of the impulse + * @param rel_pos the position of the impulse + */ + void applyImpulse(const cocos2d::Vec3& impulse, const cocos2d::Vec3& rel_pos); + + /** Damps the velocity, using the given linearDamping and angularDamping. */ + void applyDamping(float timeStep); + + /** Set the linear velocity. */ + void setLinearVelocity(const cocos2d::Vec3& lin_vel); + + /** Get the linear velocity. */ + cocos2d::Vec3 getLinearVelocity() const; + + /** Set the linear factor. */ + void setLinearFactor(const cocos2d::Vec3& linearFactor); + + /** Get the linear factor. */ + cocos2d::Vec3 getLinearFactor() const; + + /** Set the angular factor. */ + void setAngularFactor(const cocos2d::Vec3& angFac); + + /** Set the angular factor, use unified factor. */ + void setAngularFactor(float angFac); + + /** Get the angular factor. */ + cocos2d::Vec3 getAngularFactor() const; + + /** Set the angular velocity. */ + void setAngularVelocity(const cocos2d::Vec3& ang_vel); + + /** Get the angular velocity. */ + cocos2d::Vec3 getAngularVelocity() const; + + /** Set the center of mass. */ + void setCenterOfMassTransform(const cocos2d::Mat4& xform); + + /** Get the center of mass. */ + cocos2d::Mat4 getCenterOfMassTransform() const; + + /** Set linear damping and angular damping. */ + void setDamping(float lin_damping, float ang_damping); + + /** Get linear damping. */ + float getLinearDamping() const; + + /** Get angular damping. */ + float getAngularDamping() const; + + /** Set the acceleration. */ + void setGravity(const cocos2d::Vec3& acceleration); + + /** Get the acceleration. */ + cocos2d::Vec3 getGravity() const; + + /** Set the inverse of local inertia. */ + void setInvInertiaDiagLocal(const cocos2d::Vec3& diagInvInertia); + + /** Get the inverse of local inertia. */ + cocos2d::Vec3 getInvInertiaDiagLocal() const; + + /** Set mass and inertia. */ + void setMassProps(float mass, const cocos2d::Vec3& inertia); + + /** Get inverse of mass. */ + float getInvMass() const; + + /** Get total force. */ + cocos2d::Vec3 getTotalForce() const; + + /** Get total torque. */ + cocos2d::Vec3 getTotalTorque() const; + + /** Set restitution. */ + void setRestitution(float rest); + + /** Get restitution. */ + float getRestitution() const; + + /** Set friction. */ + void setFriction(float frict); + + /** Get friction. */ + float getFriction() const; + + /** Set rolling friction. */ + void setRollingFriction(float frict); + + /** Get rolling friction. */ + float getRollingFriction() const; + + /** Set hit friction. */ + void setHitFraction(float hitFraction); + + /** Get hit friction. */ + float getHitFraction() const; + + /** Set motion threshold, don't do continuous collision detection if the motion (in one step) is less then ccdMotionThreshold */ + void setCcdMotionThreshold(float ccdMotionThreshold); + + /** Get motion threshold. */ + float getCcdMotionThreshold() const; + + /** Set swept sphere radius. */ + void setCcdSweptSphereRadius(float radius); + + /** Get swept sphere radius. */ + float getCcdSweptSphereRadius() const; + + /** Set kinematic object. */ + void setKinematic(bool kinematic); + + /** Check rigid body is kinematic object. */ + bool isKinematic() const; + + /** override. */ + virtual cocos2d::Mat4 getWorldTransform() const override; + + /** Get constraint by index. */ + Physics3DConstraint* getConstraint(unsigned int idx) const; + + /** Get the total number of constraints. */ + unsigned int getConstraintCount() const; + + /** Active or inactive. */ + void setActive(bool active); + +CC_CONSTRUCTOR_ACCESS: + Physics3DRigidBody(); + virtual ~Physics3DRigidBody(); + + bool init(Physics3DRigidBodyDes* info); + + void addConstraint(Physics3DConstraint *constraint); + void removeConstraint(Physics3DConstraint *constraint); + void removeConstraint(unsigned int idx); + +protected: + btRigidBody* _btRigidBody; + Physics3DShape *_physics3DShape; + std::vector _constraintList; +}; + +// end of 3d group +/// @} + +NS_CC_END + +#endif // CC_ENABLE_BULLET_INTEGRATION + +#endif //CC_USE_3D_PHYSICS + +#endif // __PHYSICS_3D_OBJECT_H__ diff --git a/cocos/physics3d/CCPhysics3DShape.cpp b/cocos/physics3d/CCPhysics3DShape.cpp new file mode 100644 index 0000000000..4ceee16dc9 --- /dev/null +++ b/cocos/physics3d/CCPhysics3DShape.cpp @@ -0,0 +1,208 @@ +/**************************************************************************** + Copyright (c) 2015 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 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 "CCPhysics3D.h" + +#if CC_USE_3D_PHYSICS + +#if (CC_ENABLE_BULLET_INTEGRATION) +#include "bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h" + +NS_CC_BEGIN + +Physics3DShape::ShapeType Physics3DShape::getShapeType() const +{ + return _shapeType; +} + +Physics3DShape::Physics3DShape() +: _shapeType(ShapeType::UNKNOWN) +{ +#if (CC_ENABLE_BULLET_INTEGRATION) + _btShape = nullptr; + _heightfieldData = nullptr; +#endif +} +Physics3DShape::~Physics3DShape() +{ +#if (CC_ENABLE_BULLET_INTEGRATION) + CC_SAFE_DELETE(_btShape); + CC_SAFE_DELETE_ARRAY(_heightfieldData); + for (auto iter : _compoundChildShapes){ + CC_SAFE_RELEASE(iter); + } + _compoundChildShapes.clear(); +#endif +} + +Physics3DShape* Physics3DShape::createBox(const cocos2d::Vec3& extent) +{ + auto shape = new (std::nothrow) Physics3DShape(); + shape->initBox(extent); + shape->autorelease(); + return shape; +} + +Physics3DShape* Physics3DShape::createSphere(float radius) +{ + auto shape = new (std::nothrow) Physics3DShape(); + shape->initSphere(radius); + shape->autorelease(); + return shape; +} + +Physics3DShape* Physics3DShape::createCylinder(float radius, float height) +{ + auto shape = new (std::nothrow) Physics3DShape(); + shape->initCylinder(radius, height); + shape->autorelease(); + return shape; +} + +Physics3DShape* Physics3DShape::createCapsule(float radius, float height) +{ + auto shape = new (std::nothrow) Physics3DShape(); + shape->initCapsule(radius, height); + shape->autorelease(); + return shape; +} + +Physics3DShape* Physics3DShape::createConvexHull( const cocos2d::Vec3 *points, int numPoints ) +{ + auto shape = new (std::nothrow) Physics3DShape(); + shape->initConvexHull(points, numPoints); + shape->autorelease(); + return shape; +} + +Physics3DShape* Physics3DShape::createMesh( const cocos2d::Vec3 *triangles, int numTriangles ) +{ + auto shape = new (std::nothrow) Physics3DShape(); + shape->initMesh(triangles, numTriangles); + shape->autorelease(); + return shape; +} + +Physics3DShape* Physics3DShape::createHeightfield( int heightStickWidth,int heightStickLength + , const void* heightfieldData, float heightScale + , float minHeight, float maxHeight + , bool useFloatDatam, bool flipQuadEdges + , bool useDiamondSubdivision) +{ + auto shape = new (std::nothrow) Physics3DShape(); + shape->initHeightfield(heightStickWidth, heightStickLength, heightfieldData, heightScale, minHeight, maxHeight, useFloatDatam, flipQuadEdges, useDiamondSubdivision); + shape->autorelease(); + return shape; +} + +Physics3DShape* Physics3DShape::createCompoundShape( const std::vector> &shapes ) +{ + auto shape = new (std::nothrow) Physics3DShape(); + shape->initCompoundShape(shapes); + shape->autorelease(); + return shape; +} + +bool Physics3DShape::initBox(const cocos2d::Vec3& ext) +{ + _shapeType = ShapeType::BOX; + _btShape = new btBoxShape(convertVec3TobtVector3(ext * 0.5f)); + return true; +} +bool Physics3DShape::initSphere(float radius) +{ + _shapeType = ShapeType::SPHERE; + _btShape = new btSphereShape(radius); + return true; +} +bool Physics3DShape::initCylinder(float radius, float height) +{ + _shapeType = ShapeType::CYLINDER; + _btShape = new btCylinderShape(convertVec3TobtVector3(cocos2d::Vec3(radius, height, radius) * 0.5f)); + return true; +} +bool Physics3DShape::initCapsule(float radius, float height) +{ + _shapeType = ShapeType::CAPSULE; + _btShape = new btCapsuleShape(radius, height); + return true; +} + +bool Physics3DShape::initConvexHull( const cocos2d::Vec3 *points, int numPoints ) +{ + _shapeType = ShapeType::CONVEX; + _btShape = new btConvexHullShape((btScalar *)points, numPoints, sizeof(cocos2d::Vec3)); + return true; +} + +bool Physics3DShape::initMesh( const cocos2d::Vec3 *triangles, int numTriangles ) +{ + _shapeType = ShapeType::MESH; + auto mesh = new btTriangleMesh(false); + for (int i = 0; i < numTriangles * 3; i += 3){ + mesh->addTriangle(convertVec3TobtVector3(triangles[i]), convertVec3TobtVector3(triangles[i + 1]), convertVec3TobtVector3(triangles[i + 2])); + } + _btShape = new btBvhTriangleMeshShape(mesh, true); + return true; +} + +bool Physics3DShape::initHeightfield( int heightStickWidth,int heightStickLength + , const void* heightfieldData, float heightScale + , float minHeight, float maxHeight + , bool useFloatDatam, bool flipQuadEdges + , bool useDiamondSubdivision) +{ + _shapeType = ShapeType::HEIGHT_FIELD; + PHY_ScalarType type = PHY_UCHAR; + unsigned int dataSizeInByte = heightStickWidth * heightStickLength; + if (useFloatDatam){ + type = PHY_FLOAT; + dataSizeInByte *= sizeof(float); + } + _heightfieldData = new unsigned char[dataSizeInByte]; + memcpy(_heightfieldData, heightfieldData, dataSizeInByte); + auto heightfield = new btHeightfieldTerrainShape(heightStickWidth, heightStickLength, _heightfieldData, heightScale, minHeight, maxHeight, 1, type, flipQuadEdges); + heightfield->setUseDiamondSubdivision(useDiamondSubdivision); + _btShape = heightfield; + return true; +} + +bool Physics3DShape::initCompoundShape( const std::vector> &shapes ) +{ + _shapeType = ShapeType::COMPOUND; + auto compound = new btCompoundShape; + for (auto iter : shapes){ + compound->addChildShape(convertMat4TobtTransform(iter.second), iter.first->getbtShape()); + CC_SAFE_RETAIN(iter.first); + _compoundChildShapes.push_back(iter.first); + } + _btShape = compound; + return true; +} + +NS_CC_END + +#endif // CC_ENABLE_BULLET_INTEGRATION + +#endif // CC_USE_3D_PHYSICS diff --git a/cocos/physics3d/CCPhysics3DShape.h b/cocos/physics3d/CCPhysics3DShape.h new file mode 100644 index 0000000000..086be0a276 --- /dev/null +++ b/cocos/physics3d/CCPhysics3DShape.h @@ -0,0 +1,169 @@ +/**************************************************************************** + Copyright (c) 2015 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 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 __PHYSICS_3D_SHAPE_H__ +#define __PHYSICS_3D_SHAPE_H__ + +#include "base/CCRef.h" +#include "base/ccConfig.h" +#include "math/CCMath.h" + +#if CC_USE_3D_PHYSICS + +#if (CC_ENABLE_BULLET_INTEGRATION) + +class btCollisionShape; + +NS_CC_BEGIN +/** + * @addtogroup _3d + * @{ + */ + +/** + * @brief Create a physical shape(box, sphere, cylinder, capsule, convexhull, mesh and heightfield) + */ +class CC_DLL Physics3DShape : public Ref +{ +public: + enum class ShapeType + { + UNKNOWN = 0, + BOX, + SPHERE, + CYLINDER, + CAPSULE, + CONVEX, + MESH, + HEIGHT_FIELD, + COMPOUND + }; + + /** + * get shape type + */ + virtual ShapeType getShapeType() const; + + /** + * create box shape + * @param extent The extent of sphere. + */ + static Physics3DShape* createBox(const cocos2d::Vec3& extent); + + /** + * create sphere shape + * @param radius The radius of sphere. + */ + static Physics3DShape* createSphere(float radius); + + /** + * create cylinder shape + * @param radius The radius of cylinder. + * @param height The height. + */ + static Physics3DShape* createCylinder(float radius, float height); + + /** + * create capsule shape + * @param radius The radius of casule. + * @param height The height (cylinder part). + */ + static Physics3DShape* createCapsule(float radius, float height); + + /** + * create convex hull + * @param points The vertices of convex hull + * @param numPoints The number of vertices. + */ + static Physics3DShape* createConvexHull(const cocos2d::Vec3 *points, int numPoints); + + /** + * create mesh + * @param triangles The pointer of triangle list + * @param numTriangles The number of triangles. + */ + static Physics3DShape* createMesh(const cocos2d::Vec3 *triangles, int numTriangles); + + /** + * create heightfield + * @param heightStickWidth The Width of heightfield + * @param heightStickLength The Length of heightfield. + * @param heightfieldData The Data of heightfield. + * @param minHeight The minHeight of heightfield. + * @param maxHeight The maxHeight of heightfield. + * @param flipQuadEdges if flip QuadEdges + */ + static Physics3DShape* createHeightfield(int heightStickWidth,int heightStickLength + , const void* heightfieldData, float heightScale + , float minHeight, float maxHeight + , bool useFloatDatam, bool flipQuadEdges, bool useDiamondSubdivision = false); + + /** + * create Compound Shape + * @param shapes The list of child shape + */ + static Physics3DShape* createCompoundShape(const std::vector> &shapes); + + +#if CC_ENABLE_BULLET_INTEGRATION + btCollisionShape* getbtShape() const { return _btShape; } +#endif + +protected: + Physics3DShape(); + ~Physics3DShape(); + + bool initBox(const cocos2d::Vec3& ext); + bool initSphere(float radius); + bool initCylinder(float radius, float height); + bool initCapsule(float radius, float height); + bool initConvexHull(const cocos2d::Vec3 *points, int numPoints); + bool initMesh(const cocos2d::Vec3 *triangles, int numTriangles); + bool initHeightfield(int heightStickWidth,int heightStickLength + , const void* heightfieldData, float heightScale + , float minHeight, float maxHeight + , bool useFloatDatam, bool flipQuadEdges + , bool useDiamondSubdivision); + bool initCompoundShape(const std::vector> &shapes); + + + ShapeType _shapeType; //shape type + +#if (CC_ENABLE_BULLET_INTEGRATION) + btCollisionShape* _btShape; + unsigned char *_heightfieldData; + std::vector _compoundChildShapes; +#endif +}; + +// end of 3d group +/// @} + +NS_CC_END + +#endif // CC_ENABLE_BULLET_INTEGRATION + +#endif //CC_USE_3D_PHYSICS + +#endif // __PHYSICS_3D_SHAPE_H__ diff --git a/cocos/physics3d/CCPhysics3DWorld.cpp b/cocos/physics3d/CCPhysics3DWorld.cpp new file mode 100644 index 0000000000..f3cd4f35d9 --- /dev/null +++ b/cocos/physics3d/CCPhysics3DWorld.cpp @@ -0,0 +1,331 @@ +/**************************************************************************** + Copyright (c) 2015 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 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 "CCPhysics3D.h" +#include "renderer/CCRenderer.h" + +#if CC_USE_3D_PHYSICS + +#if (CC_ENABLE_BULLET_INTEGRATION) + +NS_CC_BEGIN + +Physics3DWorld::Physics3DWorld() +: _btPhyiscsWorld(nullptr) +, _collisionConfiguration(nullptr) +, _dispatcher(nullptr) +, _broadphase(nullptr) +, _solver(nullptr) +, _debugDrawer(nullptr) +, _needCollisionChecking(false) +, _collisionCheckingFlag(false) +{ + +} +Physics3DWorld::~Physics3DWorld() +{ + removeAllPhysics3DConstraints(); + removeAllPhysics3DObjects(); + + CC_SAFE_DELETE(_collisionConfiguration); + CC_SAFE_DELETE(_dispatcher); + CC_SAFE_DELETE(_broadphase); + CC_SAFE_DELETE(_solver); + CC_SAFE_DELETE(_btPhyiscsWorld); + CC_SAFE_DELETE(_debugDrawer); + for (auto it : _physicsComponents) + it->setPhysics3DObject(nullptr); + _physicsComponents.clear(); +} + +Physics3DWorld* Physics3DWorld::create(Physics3DWorldDes* info) +{ + auto world = new (std::nothrow) Physics3DWorld(); + world->init(info); + world->autorelease(); + return world; +} + +bool Physics3DWorld::init(Physics3DWorldDes* info) +{ + ///collision configuration contains default setup for memory, collision setup + _collisionConfiguration = new (std::nothrow) btDefaultCollisionConfiguration(); + //_collisionConfiguration->setConvexConvexMultipointIterations(); + + ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded) + _dispatcher = new (std::nothrow) btCollisionDispatcher(_collisionConfiguration); + + _broadphase = new (std::nothrow) btDbvtBroadphase(); + + ///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded) + btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver(); + _solver = sol; + + _btPhyiscsWorld = new btDiscreteDynamicsWorld(_dispatcher,_broadphase,_solver,_collisionConfiguration); + _btPhyiscsWorld->setGravity(convertVec3TobtVector3(info->gravity)); + if (info->isDebugDrawEnabled) + { + _debugDrawer = new (std::nothrow) Physics3DDebugDrawer(); + _btPhyiscsWorld->setDebugDrawer(_debugDrawer); + } + + return true; +} + +void Physics3DWorld::setDebugDrawEnable(bool enableDebugDraw) +{ + if (enableDebugDraw && _btPhyiscsWorld->getDebugDrawer() == nullptr) + { + _debugDrawer = new (std::nothrow) Physics3DDebugDrawer(); + } + enableDebugDraw ? _btPhyiscsWorld->setDebugDrawer(_debugDrawer) : _btPhyiscsWorld->setDebugDrawer(nullptr); +} + +bool Physics3DWorld::isDebugDrawEnabled() const +{ + return _btPhyiscsWorld->getDebugDrawer() != nullptr; +} + +void Physics3DWorld::addPhysics3DObject(Physics3DObject* physicsObj) +{ + auto it = std::find(_objects.begin(), _objects.end(), physicsObj); + if (it == _objects.end()) + { + _objects.push_back(physicsObj); + physicsObj->retain(); + if (physicsObj->getObjType() == Physics3DObject::PhysicsObjType::RIGID_BODY) + { + _btPhyiscsWorld->addRigidBody(static_cast(physicsObj)->getRigidBody()); + } + _collisionCheckingFlag = true; + } +} + +void Physics3DWorld::removePhysics3DObject(Physics3DObject* physicsObj) +{ + auto it = std::find(_objects.begin(), _objects.end(), physicsObj); + if (it != _objects.end()) + { + if (physicsObj->getObjType() == Physics3DObject::PhysicsObjType::RIGID_BODY) + { + _btPhyiscsWorld->removeRigidBody(static_cast(physicsObj)->getRigidBody()); + } + physicsObj->release(); + _objects.erase(it); + _collisionCheckingFlag = true; + } +} + +void Physics3DWorld::removeAllPhysics3DObjects() +{ + for (auto it : _objects) { + if (it->getObjType() == Physics3DObject::PhysicsObjType::RIGID_BODY) + { + _btPhyiscsWorld->removeRigidBody(static_cast(it)->getRigidBody()); + } + it->release(); + } + _objects.clear(); + _collisionCheckingFlag = true; +} + +void Physics3DWorld::addPhysics3DConstraint(Physics3DConstraint* constraint, bool disableCollisionsBetweenLinkedObjs) +{ + auto body = constraint->getBodyA(); + if (body) + body->addConstraint(constraint); + + body = constraint->getBodyB(); + if (body) + { + body->addConstraint(constraint); + } + _btPhyiscsWorld->addConstraint(constraint->getbtContraint(), disableCollisionsBetweenLinkedObjs); +} + +void Physics3DWorld::removePhysics3DConstraint(Physics3DConstraint* constraint) +{ + _btPhyiscsWorld->removeConstraint(constraint->getbtContraint()); + + auto bodyA = constraint->getBodyA(); + auto bodyB = constraint->getBodyB(); + if (bodyA) + bodyA->removeConstraint(constraint); + if (bodyB) + bodyB->removeConstraint(constraint); +} + +void Physics3DWorld::removeAllPhysics3DConstraints() +{ + for(auto it : _objects) + { + auto type = it->getObjType(); + if (type == Physics3DObject::PhysicsObjType::RIGID_BODY) + { + auto& constraints = static_cast(it)->_constraintList; + for (auto constraint : constraints) { + _btPhyiscsWorld->removeConstraint(constraint->getbtContraint()); + constraint->release(); + } + constraints.clear(); + } + } + +} + +void Physics3DWorld::stepSimulate(float dt) +{ + if (_btPhyiscsWorld) + { + //should sync kinematic node before simulation + for (auto it : _physicsComponents) + { + it->preSimulate(); + } + _btPhyiscsWorld->stepSimulation(dt, 3); + //sync dynamic node after simulation + for (auto it : _physicsComponents) + { + it->postSimulate(); + } + if (needCollisionChecking()) + collisionChecking(); + } +} + +void Physics3DWorld::debugDraw(Renderer* renderer) +{ + if (_debugDrawer) + { + _debugDrawer->clear(); + _btPhyiscsWorld->debugDrawWorld(); + _debugDrawer->draw(renderer); + } +} + +bool Physics3DWorld::rayCast(const cocos2d::Vec3& startPos, const cocos2d::Vec3& endPos, Physics3DWorld::HitResult* result) +{ + auto btStart = convertVec3TobtVector3(startPos); + auto btEnd = convertVec3TobtVector3(endPos); + btCollisionWorld::ClosestRayResultCallback btResult(btStart, btEnd); + _btPhyiscsWorld->rayTest(btStart, btEnd, btResult); + if (btResult.hasHit()) + { + result->hitObj = getPhysicsObject(btResult.m_collisionObject); + result->hitPosition = convertbtVector3ToVec3(btResult.m_hitPointWorld); + result->hitNormal = convertbtVector3ToVec3(btResult.m_hitNormalWorld); + return true; + } + result->hitObj = nullptr; + return false; +} + +bool Physics3DWorld::sweepShape(Physics3DShape* shape, const cocos2d::Mat4& startTransform, const cocos2d::Mat4& endTransform, Physics3DWorld::HitResult* result) +{ + CC_ASSERT(shape->getShapeType() != Physics3DShape::ShapeType::HEIGHT_FIELD && shape->getShapeType() != Physics3DShape::ShapeType::MESH); + auto btStart = convertMat4TobtTransform(startTransform); + auto btEnd = convertMat4TobtTransform(endTransform); + btCollisionWorld::ClosestConvexResultCallback btResult(btStart.getOrigin(), btEnd.getOrigin()); + _btPhyiscsWorld->convexSweepTest((btConvexShape*)shape->getbtShape(), btStart, btEnd, btResult); + if (btResult.hasHit()) + { + result->hitObj = getPhysicsObject(btResult.m_hitCollisionObject); + result->hitPosition = convertbtVector3ToVec3(btResult.m_hitPointWorld); + result->hitNormal = convertbtVector3ToVec3(btResult.m_hitNormalWorld); + return true; + } + result->hitObj = nullptr; + return false; +} + +Physics3DObject* Physics3DWorld::getPhysicsObject(const btCollisionObject* btObj) +{ + for(auto it : _objects) + { + if (it->getObjType() == Physics3DObject::PhysicsObjType::RIGID_BODY) + { + if (static_cast(it)->getRigidBody() == btObj) + return it; + } + } + return nullptr; +} + +void Physics3DWorld::collisionChecking() +{ + int numManifolds = _dispatcher->getNumManifolds(); + for (int i = 0; i < numManifolds; ++i){ + btPersistentManifold * contactManifold = _dispatcher->getManifoldByIndexInternal(i); + int numContacts = contactManifold->getNumContacts(); + if (0 < numContacts){ + const btCollisionObject* obA = static_cast(contactManifold->getBody0()); + const btCollisionObject* obB = static_cast(contactManifold->getBody1()); + Physics3DObject *poA = getPhysicsObject(obA); + Physics3DObject *poB = getPhysicsObject(obB); + if (poA->needCollisionCallback() || poB->needCollisionCallback()){ + Physics3DCollisionInfo ci; + ci.objA = poA; + ci.objB = poB; + for (int c = 0; c < numContacts; ++c){ + btManifoldPoint& pt = contactManifold->getContactPoint(c); + Physics3DCollisionInfo::CollisionPoint cp = { + convertbtVector3ToVec3(pt.m_localPointA), convertbtVector3ToVec3(pt.m_positionWorldOnA) + , convertbtVector3ToVec3(pt.m_localPointB), convertbtVector3ToVec3(pt.m_positionWorldOnB) + , convertbtVector3ToVec3(pt.m_normalWorldOnB) + }; + ci.collisionPointList.push_back(cp); + } + + if (poA->needCollisionCallback()){ + poA->getCollisionCallback()(ci); + } + if (poB->needCollisionCallback()){ + poB->getCollisionCallback()(ci); + } + } + } + } +} + +bool Physics3DWorld::needCollisionChecking() +{ + if (_collisionCheckingFlag){ + _needCollisionChecking = false; + for(auto it : _objects) + { + if (it->getCollisionCallback() != nullptr){ + _needCollisionChecking = true; + break; + } + } + _collisionCheckingFlag = false; + } + return _needCollisionChecking; +} + +NS_CC_END + +#endif // CC_ENABLE_BULLET_INTEGRATION + +#endif //CC_USE_3D_PHYSICS diff --git a/cocos/physics3d/CCPhysics3DWorld.h b/cocos/physics3d/CCPhysics3DWorld.h new file mode 100644 index 0000000000..b238de3ebf --- /dev/null +++ b/cocos/physics3d/CCPhysics3DWorld.h @@ -0,0 +1,173 @@ +/**************************************************************************** + Copyright (c) 2015 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 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 __PHYSICS_3D_WORLD_H__ +#define __PHYSICS_3D_WORLD_H__ + +#include "math/CCMath.h" +#include "base/CCRef.h" +#include "base/ccConfig.h" + +#if CC_USE_3D_PHYSICS + +#if (CC_ENABLE_BULLET_INTEGRATION) + +class btDynamicsWorld; +class btDefaultCollisionConfiguration; +class btCollisionDispatcher; +class btDbvtBroadphase; +class btSequentialImpulseConstraintSolver; +class btRigidBody; +class btCollisionObject; + +NS_CC_BEGIN +/** + * @addtogroup _3d + * @{ + */ + +class Physics3DObject; +class Physics3DConstraint; +class Physics3DDebugDrawer; +class Physics3DComponent; +class Physics3DShape; +class Renderer; + +/** + * @brief The description of Physics3DWorld. + */ +struct CC_DLL Physics3DWorldDes +{ + bool isDebugDrawEnabled; //using physics debug draw?, false by default + cocos2d::Vec3 gravity;//gravity, (0, -9.8, 0) + Physics3DWorldDes() + { + isDebugDrawEnabled = false; + gravity = cocos2d::Vec3(0.f, -9.8f, 0.f); + } +}; + +/** + * @brief The physics information container, include Physics3DObjects, Physics3DConstraints, collision information and so on. + */ +class CC_DLL Physics3DWorld : public Ref +{ + friend class Physics3DComponent; +public: + + struct HitResult + { + cocos2d::Vec3 hitPosition; + cocos2d::Vec3 hitNormal; + Physics3DObject* hitObj; + }; + + /** + * Creates a Physics3DWorld with Physics3DWorldDes. + * + * @return An autoreleased Physics3DWorld object. + */ + static Physics3DWorld* create(Physics3DWorldDes* info); + + /** Add a Physics3DObject. */ + void addPhysics3DObject(Physics3DObject* physicsObj); + + /** Remove a Physics3DObject. */ + void removePhysics3DObject(Physics3DObject* physicsObj); + + /** Remove all Physics3DObjects. */ + void removeAllPhysics3DObjects(); + + /** Add a Physics3DConstraint. */ + void addPhysics3DConstraint(Physics3DConstraint* constraint, bool disableCollisionsBetweenLinkedObjs = true); + + /** Remove a Physics3DConstraint. */ + void removePhysics3DConstraint(Physics3DConstraint* constraint); + + /** Remove all Physics3DConstraint. */ + void removeAllPhysics3DConstraints(); + + /** Simulate one frame. */ + void stepSimulate(float dt); + + /** Enable or disable debug drawing. */ + void setDebugDrawEnable(bool enableDebugDraw); + + /** Check debug drawing is enabled. */ + bool isDebugDrawEnabled() const; + + /** Internal method, the updater of debug drawing, need called each frame. */ + void debugDraw(cocos2d::Renderer* renderer); + + /** Get the list of Physics3DObjects. */ + const std::vector& getPhysicsObjects() const { return _objects; } + + /** + * Ray cast method + * @param startPos The start position of ray. + * @param endPos The end position of ray. + * @param result the result of ray cast. + */ + bool rayCast(const cocos2d::Vec3& startPos, const cocos2d::Vec3& endPos, HitResult* result); + + /** Performs a swept shape cast on all objects in the Physics3DWorld. */ + bool sweepShape(Physics3DShape* shape, const cocos2d::Mat4& startTransform, const cocos2d::Mat4& endTransform, HitResult* result); + +CC_CONSTRUCTOR_ACCESS: + + Physics3DWorld(); + virtual ~Physics3DWorld(); + + bool init(Physics3DWorldDes* info); + + Physics3DObject* getPhysicsObject(const btCollisionObject* btObj); + + void collisionChecking(); + bool needCollisionChecking(); + +protected: + std::vector _objects; + std::vector _physicsComponents; //physics3d components + bool _needCollisionChecking; + bool _collisionCheckingFlag; + +#if (CC_ENABLE_BULLET_INTEGRATION) + btDynamicsWorld* _btPhyiscsWorld; + btDefaultCollisionConfiguration* _collisionConfiguration; + btCollisionDispatcher* _dispatcher; + btDbvtBroadphase* _broadphase; + btSequentialImpulseConstraintSolver* _solver; + Physics3DDebugDrawer* _debugDrawer; +#endif // CC_ENABLE_BULLET_INTEGRATION +}; + +// end of 3d group +/// @} +NS_CC_END + +#endif + +#endif //CC_USE_3D_PHYSICS + +#endif // __PHYSICS_3D_WORLD_H__ diff --git a/cocos/physics3d/CCPhysicsSprite3D.cpp b/cocos/physics3d/CCPhysicsSprite3D.cpp new file mode 100644 index 0000000000..e9f2a94d0b --- /dev/null +++ b/cocos/physics3d/CCPhysicsSprite3D.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** + Copyright (c) 2015 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 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 "CCPhysics3D.h" + +#if CC_USE_3D_PHYSICS + +#if (CC_ENABLE_BULLET_INTEGRATION) + +NS_CC_BEGIN + +PhysicsSprite3D* PhysicsSprite3D::create(const std::string &modelPath, Physics3DRigidBodyDes* rigidDes, const cocos2d::Vec3& translateInPhysics, const cocos2d::Quaternion& rotInPhsyics) +{ + auto ret = new PhysicsSprite3D(); + if (ret && ret->initWithFile(modelPath)) + { + auto obj = Physics3DRigidBody::create(rigidDes); + ret->_physicsComponent = Physics3DComponent::create(obj); + ret->addComponent(ret->_physicsComponent); + ret->_contentSize = ret->getBoundingBox().size; + ret->autorelease(); + return ret; + } + CC_SAFE_DELETE(ret); + return ret; +} + +Physics3DObject* PhysicsSprite3D::getPhysicsObj() const +{ + return _physicsComponent->getPhysics3DObject(); +} + +void PhysicsSprite3D::setSyncFlag(Physics3DComponent::PhysicsSyncFlag syncFlag) +{ + if (_physicsComponent) + _physicsComponent->setSyncFlag(syncFlag); +} + +void PhysicsSprite3D::syncToPhysics() +{ + if (_physicsComponent) + _physicsComponent->syncToPhysics(); +} + +void PhysicsSprite3D::syncToNode() +{ + if (_physicsComponent) + _physicsComponent->syncToNode(); +} + +PhysicsSprite3D::PhysicsSprite3D() +: _physicsComponent(nullptr) +{ + +} +PhysicsSprite3D::~PhysicsSprite3D() +{ + +} + +NS_CC_END + +#endif // CC_ENABLE_BULLET_INTEGRATION + +#endif // CC_USE_3D_PHYSICS diff --git a/cocos/physics3d/CCPhysicsSprite3D.h b/cocos/physics3d/CCPhysicsSprite3D.h new file mode 100644 index 0000000000..e67ff584ea --- /dev/null +++ b/cocos/physics3d/CCPhysicsSprite3D.h @@ -0,0 +1,81 @@ +/**************************************************************************** + Copyright (c) 2015 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 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 __PHYSICS_SPRITE_3D_H__ +#define __PHYSICS_SPRITE_3D_H__ + +#include "base/ccConfig.h" +#include "3d/CCSprite3D.h" +#include "CCPhysics3DObject.h" +#include "CCPhysics3DComponent.h" + +#if CC_USE_3D_PHYSICS + +#if (CC_ENABLE_BULLET_INTEGRATION) + +NS_CC_BEGIN +/** + * @addtogroup _3d + * @{ + */ + + /** + * @brief Convenient class to create a rigid body with Sprite3D + */ +class CC_DLL PhysicsSprite3D : public cocos2d::Sprite3D +{ +public: + + /** creates a PhysicsSprite3D*/ + static PhysicsSprite3D* create(const std::string &modelPath, Physics3DRigidBodyDes* rigidDes, const cocos2d::Vec3& translateInPhysics = cocos2d::Vec3::ZERO, const cocos2d::Quaternion& rotInPhsyics = cocos2d::Quaternion::ZERO); + + /** Get the Physics3DObject. */ + Physics3DObject* getPhysicsObj() const; + + /** Set synchronization flag, see Physics3DComponent. */ + void setSyncFlag(Physics3DComponent::PhysicsSyncFlag syncFlag); + + /** Physics synchronize rendering. */ + void syncToPhysics(); + + /** Rendering synchronize physics. */ + void syncToNode(); + +CC_CONSTRUCTOR_ACCESS: + PhysicsSprite3D(); + virtual ~PhysicsSprite3D(); + +protected: + Physics3DComponent* _physicsComponent; +}; + +// end of 3d group +/// @} +NS_CC_END + +#endif // CC_ENABLE_BULLET_INTEGRATION + +#endif // CC_USE_3D_PHYSICS + +#endif // __PHYSICS_SPRITE_3D_H__ diff --git a/cocos/physics3d/CMakeLists.txt b/cocos/physics3d/CMakeLists.txt new file mode 100644 index 0000000000..6e685d725e --- /dev/null +++ b/cocos/physics3d/CMakeLists.txt @@ -0,0 +1,12 @@ + +set(COCOS_PHYSICS3D_SRC + + physics3d/CCPhysics3D.cpp + physics3d/CCPhysics3DComponent.cpp + physics3d/CCPhysics3DConstraint.cpp + physics3d/CCPhysics3DDebugDrawer.cpp + physics3d/CCPhysics3DObject.cpp + physics3d/CCPhysics3DShape.cpp + physics3d/CCPhysics3DWorld.cpp + physics3d/CCPhysicsSprite3D.cpp +) diff --git a/cocos/platform/CCApplication.h b/cocos/platform/CCApplication.h index 56bee474fd..27e3d499c0 100644 --- a/cocos/platform/CCApplication.h +++ b/cocos/platform/CCApplication.h @@ -37,7 +37,7 @@ THE SOFTWARE. #include "platform/android/CCApplication-android.h" #elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 #include "platform/win32/CCApplication-win32.h" -#elif CC_TARGET_PLATFORM == CC_PLATFORM_WP8 +#elif CC_TARGET_PLATFORM == CC_PLATFORM_WINRT #include "platform/winrt/CCApplication.h" #elif CC_TARGET_PLATFORM == CC_PLATFORM_LINUX #include "platform/linux/CCApplication-linux.h" diff --git a/cocos/platform/CCFileUtils.cpp b/cocos/platform/CCFileUtils.cpp index 687065359d..7dd095f1cf 100644 --- a/cocos/platform/CCFileUtils.cpp +++ b/cocos/platform/CCFileUtils.cpp @@ -41,7 +41,7 @@ THE SOFTWARE. #endif #include -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_WP8) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) #include #endif @@ -49,7 +49,7 @@ THE SOFTWARE. #include #endif -#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) && (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) && (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) #include #include #include @@ -403,7 +403,7 @@ bool FileUtils::writeToFile(ValueMap& dict, const std::string &fullPath) } rootEle->LinkEndChild(innerDict); - bool ret = tinyxml2::XML_SUCCESS == doc->SaveFile(fullPath.c_str()); + bool ret = tinyxml2::XML_SUCCESS == doc->SaveFile(getSuitableFOpen(fullPath).c_str()); delete doc; return ret; @@ -566,7 +566,7 @@ static Data getData(const std::string& filename, bool forString) { // Read the file from hardware std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename); - FILE *fp = fopen(fullPath.c_str(), mode); + FILE *fp = fopen(FileUtils::getInstance()->getSuitableFOpen(fullPath).c_str(), mode); CC_BREAK_IF(!fp); fseek(fp,0,SEEK_END); size = ftell(fp); @@ -629,7 +629,7 @@ unsigned char* FileUtils::getFileData(const std::string& filename, const char* m { // read the file from hardware const std::string fullPath = fullPathForFilename(filename); - FILE *fp = fopen(fullPath.c_str(), mode); + FILE *fp = fopen(getSuitableFOpen(fullPath).c_str(), mode); CC_BREAK_IF(!fp); fseek(fp,0,SEEK_END); @@ -982,7 +982,7 @@ bool FileUtils::isAbsolutePath(const std::string& path) const bool FileUtils::isDirectoryExistInternal(const std::string& dirPath) const { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) WIN32_FILE_ATTRIBUTE_DATA wfad; std::wstring wdirPath(dirPath.begin(), dirPath.end()); if (GetFileAttributesEx(wdirPath.c_str(), GetFileExInfoStandard, &wfad)) @@ -1078,7 +1078,7 @@ bool FileUtils::createDirectory(const std::string& path) } -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) WIN32_FILE_ATTRIBUTE_DATA wfad; std::wstring wpath(path.begin(), path.end()); if (!(GetFileAttributesEx(wpath.c_str(), GetFileExInfoStandard, &wfad))) @@ -1172,7 +1172,7 @@ bool FileUtils::removeDirectory(const std::string& path) // Remove downloaded files -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) std::wstring wpath = std::wstring(path.begin(), path.end()); std::wstring files = wpath + L"*.*"; WIN32_FIND_DATA wfd; @@ -1236,7 +1236,7 @@ bool FileUtils::removeFile(const std::string &path) { // Remove downloaded file -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) std::wstring wpath(path.begin(), path.end()); if (DeleteFile(wpath.c_str())) { @@ -1276,7 +1276,7 @@ bool FileUtils::renameFile(const std::string &path, const std::string &oldname, std::string newPath = path + name; // Rename a file -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_WP8) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) std::regex pat("\\/"); std::string _old = std::regex_replace(oldPath, pat, "\\"); std::string _new = std::regex_replace(newPath, pat, "\\"); @@ -1364,5 +1364,67 @@ bool FileUtils::isPopupNotify() const return s_popupNotify; } +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +static std::wstring StringUtf8ToWideChar(const std::string& strUtf8) +{ + std::wstring ret; + if (!strUtf8.empty()) + { + int nNum = MultiByteToWideChar(CP_UTF8, 0, strUtf8.c_str(), -1, nullptr, 0); + if (nNum) + { + WCHAR* wideCharString = new WCHAR[nNum + 1]; + wideCharString[0] = 0; + + nNum = MultiByteToWideChar(CP_UTF8, 0, strUtf8.c_str(), -1, wideCharString, nNum + 1); + + ret = wideCharString; + delete[] wideCharString; + } + else + { + CCLOG("Wrong convert to WideChar code:0x%x", GetLastError()); + } + } + return ret; +} + +static std::string UTF8StringToMultiByte(const std::string& strUtf8) +{ + std::string ret; + if (!strUtf8.empty()) + { + std::wstring strWideChar = StringUtf8ToWideChar(strUtf8); + int nNum = WideCharToMultiByte(CP_ACP, 0, strWideChar.c_str(), -1, nullptr, 0, nullptr, FALSE); + if (nNum) + { + char* ansiString = new char[nNum + 1]; + ansiString[0] = 0; + + nNum = WideCharToMultiByte(CP_ACP, 0, strWideChar.c_str(), -1, ansiString, nNum + 1, nullptr, FALSE); + + ret = ansiString; + delete[] ansiString; + } + else + { + CCLOG("Wrong convert to Ansi code:0x%x", GetLastError()); + } + } + + return ret; +} + +std::string FileUtils::getSuitableFOpen(const std::string& filenameUtf8) const +{ + return UTF8StringToMultiByte(filenameUtf8); +} +#else +std::string FileUtils::getSuitableFOpen(const std::string& filenameUtf8) const +{ + return filenameUtf8; +} +#endif + NS_CC_END diff --git a/cocos/platform/CCFileUtils.h b/cocos/platform/CCFileUtils.h index 62474c2a62..01505475f4 100644 --- a/cocos/platform/CCFileUtils.h +++ b/cocos/platform/CCFileUtils.h @@ -330,6 +330,15 @@ public: // This method is used internally. virtual bool writeToFile(ValueMap& dict, const std::string& fullPath); + /** + * Windows fopen can't support UTF-8 filename + * Need convert all parameters fopen and other 3rd-party libs + * + * @param filename std::string name file for convertation from utf-8 + * @return std::string ansi filename in current locale + */ + virtual std::string getSuitableFOpen(const std::string& filenameUtf8) const; + // Converts the contents of a file to a ValueVector. // This method is used internally. virtual ValueVector getValueVectorFromFile(const std::string& filename); diff --git a/cocos/platform/CCGL.h b/cocos/platform/CCGL.h index e42f7128f4..9c754d2659 100644 --- a/cocos/platform/CCGL.h +++ b/cocos/platform/CCGL.h @@ -37,7 +37,7 @@ THE SOFTWARE. #include "platform/android/CCGL-android.h" #elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 #include "platform/win32/CCGL-win32.h" -#elif CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT +#elif CC_TARGET_PLATFORM == CC_PLATFORM_WINRT #include "platform/winrt/CCGL.h" #elif CC_TARGET_PLATFORM == CC_PLATFORM_LINUX #include "platform/linux/CCGL-linux.h" diff --git a/cocos/platform/CCGLView.h b/cocos/platform/CCGLView.h index 39f725d4ca..38f331f249 100644 --- a/cocos/platform/CCGLView.h +++ b/cocos/platform/CCGLView.h @@ -120,10 +120,6 @@ public: * @param open Open or close IME keyboard. */ virtual void setIMEKeyboardState(bool open) = 0; - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) - virtual void setIMEKeyboardState(bool open, std::string str) = 0; -#endif /** When the window is closed, it will return false if the platforms is Ios or Android. * If the platforms is windows or Mac,it will return true. @@ -215,11 +211,6 @@ public: virtual void* getEAGLView() const { return nullptr; } #endif /* (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) */ -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) - virtual Size getRenerTargetSize() const = 0; - virtual const Mat4& getOrientationMatrix() const = 0; - virtual const Mat4& getReverseOrientationMatrix() const = 0; -#endif /** * Get the visible area size of opengl viewport. * diff --git a/cocos/platform/CCImage.cpp b/cocos/platform/CCImage.cpp index 83264e7438..bbd756f53c 100644 --- a/cocos/platform/CCImage.cpp +++ b/cocos/platform/CCImage.cpp @@ -2138,7 +2138,7 @@ bool Image::initWithWebpData(const unsigned char * data, ssize_t dataLen) #if CC_USE_WEBP bool ret = false; -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) CCLOG("WEBP image format not supported on WinRT or WP8"); #else do @@ -2173,7 +2173,7 @@ bool Image::initWithWebpData(const unsigned char * data, ssize_t dataLen) ret = true; } while (0); -#endif // (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#endif // (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) return ret; #else CCLOG("webp is not enabled, please enable it in ccConfig.h"); @@ -2265,7 +2265,7 @@ bool Image::saveImageToPNG(const std::string& filePath, bool isToRGB) png_colorp palette; png_bytep *row_pointers; - fp = fopen(filePath.c_str(), "wb"); + fp = fopen(FileUtils::getInstance()->getSuitableFOpen(filePath).c_str(), "wb"); CC_BREAK_IF(nullptr == fp); png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); @@ -2421,7 +2421,7 @@ bool Image::saveImageToJPG(const std::string& filePath) /* Now we can initialize the JPEG compression object. */ jpeg_create_compress(&cinfo); - CC_BREAK_IF((outfile = fopen(filePath.c_str(), "wb")) == nullptr); + CC_BREAK_IF((outfile = fopen(FileUtils::getInstance()->getSuitableFOpen(filePath).c_str(), "wb")) == nullptr); jpeg_stdio_dest(&cinfo, outfile); diff --git a/cocos/platform/CCPlatformConfig.h b/cocos/platform/CCPlatformConfig.h index caceecb548..6531f0e54e 100644 --- a/cocos/platform/CCPlatformConfig.h +++ b/cocos/platform/CCPlatformConfig.h @@ -51,8 +51,7 @@ THE SOFTWARE. #define CC_PLATFORM_EMSCRIPTEN 10 #define CC_PLATFORM_TIZEN 11 #define CC_PLATFORM_QT5 12 -#define CC_PLATFORM_WP8 13 -#define CC_PLATFORM_WINRT 14 +#define CC_PLATFORM_WINRT 13 // Determine target platform by compile environment macro. #define CC_TARGET_PLATFORM CC_PLATFORM_UNKNOWN @@ -129,19 +128,12 @@ THE SOFTWARE. #define CC_TARGET_PLATFORM CC_PLATFORM_QT5 #endif -// WinRT (Windows Store App) +// WinRT (Windows 8.1 Store/Phone App) #if defined(WINRT) #undef CC_TARGET_PLATFORM #define CC_TARGET_PLATFORM CC_PLATFORM_WINRT #endif -// WP8 (Windows Phone 8 App) -#if defined(WP8) - #undef CC_TARGET_PLATFORM - #define CC_TARGET_PLATFORM CC_PLATFORM_WP8 -#endif - - ////////////////////////////////////////////////////////////////////////// // post configure ////////////////////////////////////////////////////////////////////////// diff --git a/cocos/platform/CCPlatformDefine.h b/cocos/platform/CCPlatformDefine.h index a336e99a38..786714eb0c 100644 --- a/cocos/platform/CCPlatformDefine.h +++ b/cocos/platform/CCPlatformDefine.h @@ -37,7 +37,7 @@ THE SOFTWARE. #include "platform/android/CCPlatformDefine-android.h" #elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 #include "platform/win32/CCPlatformDefine-win32.h" -#elif CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT +#elif CC_TARGET_PLATFORM == CC_PLATFORM_WINRT #include "platform/winrt/CCPlatformDefine-winrt.h" #elif CC_TARGET_PLATFORM == CC_PLATFORM_LINUX #include "platform/linux/CCPlatformDefine-linux.h" diff --git a/cocos/platform/CCPlatformMacros.h b/cocos/platform/CCPlatformMacros.h index f150a1a490..48ecbeab1f 100644 --- a/cocos/platform/CCPlatformMacros.h +++ b/cocos/platform/CCPlatformMacros.h @@ -85,7 +85,7 @@ CC_DEPRECATED_ATTRIBUTE static __TYPE__* node() \ * * @since v0.99.5 */ -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) #define CC_ENABLE_CACHE_TEXTURE_DATA 1 #else #define CC_ENABLE_CACHE_TEXTURE_DATA 0 diff --git a/cocos/platform/CCStdC.h b/cocos/platform/CCStdC.h index e821fa1a3a..f22fddff4b 100644 --- a/cocos/platform/CCStdC.h +++ b/cocos/platform/CCStdC.h @@ -36,7 +36,7 @@ THE SOFTWARE. #include "platform/android/CCStdC-android.h" #elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 #include "platform/win32/CCStdC-win32.h" -#elif CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT +#elif CC_TARGET_PLATFORM == CC_PLATFORM_WINRT #include "platform/winrt/CCStdC.h" #elif CC_TARGET_PLATFORM == CC_PLATFORM_LINUX #include "platform/linux/CCStdC-linux.h" diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxJavascriptJavaBridge.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxJavascriptJavaBridge.java new file mode 100644 index 0000000000..996bda03c2 --- /dev/null +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxJavascriptJavaBridge.java @@ -0,0 +1,27 @@ +/* + * 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. + */ + +package org.cocos2dx.lib; + +public class Cocos2dxJavascriptJavaBridge { + public static native int evalString(String value); +} diff --git a/cocos/platform/android/javaactivity-android.cpp b/cocos/platform/android/javaactivity-android.cpp index 488fe4dd01..5f710fd765 100644 --- a/cocos/platform/android/javaactivity-android.cpp +++ b/cocos/platform/android/javaactivity-android.cpp @@ -49,14 +49,14 @@ using namespace cocos2d; extern "C" { -jint JNI_OnLoad(JavaVM *vm, void *reserved) +JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) { JniHelper::setJavaVM(vm); return JNI_VERSION_1_4; } -void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h) +JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h) { auto director = cocos2d::Director::getInstance(); auto glview = director->getOpenGLView(); @@ -83,7 +83,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } } -jintArray Java_org_cocos2dx_lib_Cocos2dxActivity_getGLContextAttrs(JNIEnv* env, jobject thiz) +JNIEXPORT jintArray Java_org_cocos2dx_lib_Cocos2dxActivity_getGLContextAttrs(JNIEnv* env, jobject thiz) { cocos_android_app_init(env, thiz); cocos2d::Application::getInstance()->initGLContextAttrs(); @@ -99,7 +99,7 @@ jintArray Java_org_cocos2dx_lib_Cocos2dxActivity_getGLContextAttrs(JNIEnv* env, return glContextAttrsJava; } -void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnSurfaceChanged(JNIEnv* env, jobject thiz, jint w, jint h) +JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnSurfaceChanged(JNIEnv* env, jobject thiz, jint w, jint h) { cocos2d::Application::getInstance()->applicationScreenSizeChanged(w, h); } diff --git a/cocos/platform/android/jni/CocosPlayClient.cpp b/cocos/platform/android/jni/CocosPlayClient.cpp index c9d934412f..13ecdf03bd 100644 --- a/cocos/platform/android/jni/CocosPlayClient.cpp +++ b/cocos/platform/android/jni/CocosPlayClient.cpp @@ -22,11 +22,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CocosPlayClient.h" -#include "cocos2d.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include +#include +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include "jni/JniHelper.h" #include "platform/CCCommon.h" +#include "platform/CCFileUtils.h" using namespace cocos2d; diff --git a/cocos/platform/win32/CCFileUtils-win32.cpp b/cocos/platform/win32/CCFileUtils-win32.cpp index 7ed1ed8c1f..c14c748563 100644 --- a/cocos/platform/win32/CCFileUtils-win32.cpp +++ b/cocos/platform/win32/CCFileUtils-win32.cpp @@ -132,6 +132,51 @@ bool FileUtilsWin32::isAbsolutePath(const std::string& strPath) const return false; } +// Because windows is case insensitive, so we should check the file names. +static bool checkFileName(const std::string& fullPath, const std::string& filename) +{ + std::string tmpPath=convertPathFormatToUnixStyle(fullPath); + size_t len = tmpPath.length(); + size_t nl = filename.length(); + std::string realName; + + while (tmpPath.length() >= len - nl && tmpPath.length()>2) + { + //CCLOG("%s", tmpPath.c_str()); + WIN32_FIND_DATAA data; + HANDLE h = FindFirstFileA(tmpPath.c_str(), &data); + FindClose(h); + if (h != INVALID_HANDLE_VALUE) + { + int fl = strlen(data.cFileName); + if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + { + realName = "/" + realName; + } + realName = data.cFileName + realName; + if (0 != strcmp(&tmpPath.c_str()[tmpPath.length() - fl], data.cFileName)) + { + std::string msg = "File path error: \""; + msg.append(filename).append("\" the real name is: ").append(realName); + + CCLOG("%s", msg.c_str()); + return false; + } + + } + else + { + break; + } + + do + { + tmpPath = tmpPath.substr(0, tmpPath.rfind("/")); + } while (tmpPath.back() == '.'); + } + return true; +} + static Data getData(const std::string& filename, bool forString) { if (filename.empty()) @@ -147,6 +192,9 @@ static Data getData(const std::string& filename, bool forString) // read the file from hardware std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename); + // check if the filename uses correct case characters + CC_BREAK_IF(!checkFileName(fullPath, filename)); + WCHAR wszBuf[CC_MAX_PATH] = {0}; MultiByteToWideChar(CP_UTF8, 0, fullPath.c_str(), -1, wszBuf, sizeof(wszBuf)/sizeof(wszBuf[0])); @@ -229,6 +277,9 @@ unsigned char* FileUtilsWin32::getFileData(const std::string& filename, const ch // read the file from hardware std::string fullPath = fullPathForFilename(filename); + // check if the filename uses correct case characters + CC_BREAK_IF(!checkFileName(fullPath, filename)); + WCHAR wszBuf[CC_MAX_PATH] = {0}; MultiByteToWideChar(CP_UTF8, 0, fullPath.c_str(), -1, wszBuf, sizeof(wszBuf)/sizeof(wszBuf[0])); diff --git a/cocos/platform/winrt/CCApplication.h b/cocos/platform/winrt/CCApplication.h index f97c4896f3..bd08715aa9 100644 --- a/cocos/platform/winrt/CCApplication.h +++ b/cocos/platform/winrt/CCApplication.h @@ -26,7 +26,7 @@ THE SOFTWARE. #define __CC_APPLICATION_WINRT_H__ #include "platform/CCPlatformConfig.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) #include "platform/CCStdC.h" #include "platform/CCCommon.h" @@ -111,6 +111,6 @@ protected: NS_CC_END -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WP8 +#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WINRT #endif // __CC_APPLICATION_WINRT_H__ diff --git a/cocos/platform/winrt/CCCommon.cpp b/cocos/platform/winrt/CCCommon.cpp index f38615b3ab..8e6a59267c 100644 --- a/cocos/platform/winrt/CCCommon.cpp +++ b/cocos/platform/winrt/CCCommon.cpp @@ -26,10 +26,6 @@ THE SOFTWARE. #include "platform/CCStdC.h" #include "CCWinRTUtils.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || defined(WP8_SHADER_COMPILER) -#include "platform/wp8/CCGLViewImpl-wp8.h" -#endif - #if defined(VLD_DEBUG_MEMORY) #include #endif diff --git a/cocos/platform/winrt/CCDevice.cpp b/cocos/platform/winrt/CCDevice.cpp index 08360881dc..40b889cbce 100644 --- a/cocos/platform/winrt/CCDevice.cpp +++ b/cocos/platform/winrt/CCDevice.cpp @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ #include "platform/CCPlatformConfig.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) #include "cocos2d.h" #include "platform/CCDevice.h" @@ -42,14 +42,7 @@ CCFreeTypeFont sFT; int Device::getDPI() { -#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 - static const float dipsPerInch = 96.0f; - return floor(DisplayProperties::LogicalDpi / dipsPerInch + 0.5f); // Round to nearest integer. -#elif defined WP8_SHADER_COMPILER - return 0; -#else return cocos2d::GLViewImpl::sharedOpenGLView()->GetDPI(); -#endif } static Accelerometer^ sAccelerometer = nullptr; @@ -211,4 +204,4 @@ void Device::setKeepScreenOn(bool value) NS_CC_END -#endif // (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) +#endif // (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) diff --git a/cocos/platform/winrt/CCFileUtilsWinRT.cpp b/cocos/platform/winrt/CCFileUtilsWinRT.cpp index e2468df9a2..1ceea45d1c 100644 --- a/cocos/platform/winrt/CCFileUtilsWinRT.cpp +++ b/cocos/platform/winrt/CCFileUtilsWinRT.cpp @@ -111,9 +111,9 @@ bool CCFileUtilsWinRT::isFileExistInternal(const std::string& strFilePath) const strPath.insert(0, _defaultResRootPath); } - const char* path = strPath.c_str(); + strPath = getSuitableFOpen(strPath); - if (path && strlen(path) && (pf = fopen(path, "rb"))) + if (!strPath.empty() && (pf = fopen(strPath.c_str(), "rb"))) { ret = true; fclose(pf); @@ -121,7 +121,6 @@ bool CCFileUtilsWinRT::isFileExistInternal(const std::string& strFilePath) const return ret; } - bool CCFileUtilsWinRT::isAbsolutePath(const std::string& strPath) const { if ( strPath.length() > 2 @@ -181,8 +180,6 @@ static Data getData(const std::string& filename, bool forString) return ret; } - - std::string CCFileUtilsWinRT::getStringFromFile(const std::string& filename) { Data data = getData(filename, true); @@ -194,8 +191,6 @@ std::string CCFileUtilsWinRT::getStringFromFile(const std::string& filename) return ret; } - - string CCFileUtilsWinRT::getWritablePath() const { auto localFolderPath = Windows::Storage::ApplicationData::Current->LocalFolder->Path; diff --git a/cocos/platform/winrt/CCFreeTypeFont.cpp b/cocos/platform/winrt/CCFreeTypeFont.cpp index cb6e020ac8..6ce6ffac45 100644 --- a/cocos/platform/winrt/CCFreeTypeFont.cpp +++ b/cocos/platform/winrt/CCFreeTypeFont.cpp @@ -25,9 +25,7 @@ #include "base/CCDirector.h" #include "platform/CCFileUtils.h" -#if (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) #include -#endif #include #include #include @@ -618,9 +616,6 @@ unsigned char* CCFreeTypeFont::loadFont(const char *pFontName, ssize_t *size) unsigned char* CCFreeTypeFont::loadSystemFont(const char *pFontName, ssize_t *size) { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) - return nullptr; -#else std::string aName(pFontName); unsigned char* pBuffer = nullptr; HRESULT hr = S_OK; @@ -752,7 +747,6 @@ unsigned char* CCFreeTypeFont::loadSystemFont(const char *pFontName, ssize_t *si } return pBuffer; -#endif } NS_CC_END diff --git a/cocos/platform/winrt/CCGLViewImpl-winrt.cpp b/cocos/platform/winrt/CCGLViewImpl-winrt.cpp index bb7ae1e7ff..f590d5ce9d 100644 --- a/cocos/platform/winrt/CCGLViewImpl-winrt.cpp +++ b/cocos/platform/winrt/CCGLViewImpl-winrt.cpp @@ -157,7 +157,7 @@ bool GLViewImpl::ShowMessageBox(Platform::String^ title, Platform::String^ messa return false; } -void GLViewImpl::setIMEKeyboardState(bool bOpen, std::string str) +void GLViewImpl::setIMEKeyboardState(bool bOpen, const std::string& str) { if(bOpen) { diff --git a/cocos/platform/winrt/CCGLViewImpl-winrt.h b/cocos/platform/winrt/CCGLViewImpl-winrt.h index 6a82918f46..8d21f82ae3 100644 --- a/cocos/platform/winrt/CCGLViewImpl-winrt.h +++ b/cocos/platform/winrt/CCGLViewImpl-winrt.h @@ -59,7 +59,7 @@ public: Size getRenerTargetSize() const { return Size(m_width, m_height); } virtual void setIMEKeyboardState(bool bOpen); - virtual void setIMEKeyboardState(bool bOpen, std::string str); + virtual void setIMEKeyboardState(bool bOpen, const std::string& str); virtual bool Create(float width, float height, float dpi, Windows::Graphics::Display::DisplayOrientations orientation); diff --git a/cocos/platform/winrt/CCPrecompiledShaders.cpp b/cocos/platform/winrt/CCPrecompiledShaders.cpp index 472c8f248a..c835e7ee93 100644 --- a/cocos/platform/winrt/CCPrecompiledShaders.cpp +++ b/cocos/platform/winrt/CCPrecompiledShaders.cpp @@ -27,13 +27,6 @@ THE SOFTWARE. #include "renderer/CCGLProgram.h" #include "sha1.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) -#include "platform/winrt/shaders/precompiledshaders.h" -#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) -#include "platform/wp8/shaders/precompiledshaders.h" -#endif - - using namespace Windows::Graphics::Display; using namespace Windows::Storage; using namespace Platform; diff --git a/cocos/platform/winrt/CCStdC.h b/cocos/platform/winrt/CCStdC.h index ebb6375854..5299b25893 100644 --- a/cocos/platform/winrt/CCStdC.h +++ b/cocos/platform/winrt/CCStdC.h @@ -27,7 +27,7 @@ THE SOFTWARE. #define __CC_STD_C_H__ #include "platform/CCPlatformConfig.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 +#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT #include "platform/CCPlatformMacros.h" @@ -108,7 +108,7 @@ struct timezone int CC_DLL gettimeofday(struct timeval *, struct timezone *); -#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 +#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WINRT #endif // __CC_STD_C_H__ diff --git a/cocos/platform/winrt/CCWinRTUtils.cpp b/cocos/platform/winrt/CCWinRTUtils.cpp index 853d20f9a2..0e4c113f11 100644 --- a/cocos/platform/winrt/CCWinRTUtils.cpp +++ b/cocos/platform/winrt/CCWinRTUtils.cpp @@ -32,10 +32,8 @@ THE SOFTWARE. #include #include -#if CC_TARGET_PLATFORM != CC_PLATFORM_WP8 using namespace Windows::UI::Xaml; using namespace Windows::UI::Xaml::Controls; -#endif NS_CC_BEGIN @@ -106,7 +104,6 @@ Platform::String^ PlatformStringFromString(const std::string& s) return ref new Platform::String(ws.data(), ws.length()); } -#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 // Method to convert a length in device-independent pixels (DIPs) to a length in physical pixels. float ConvertDipsToPixels(float dips) { @@ -118,7 +115,6 @@ float getScaledDPIValue(float v) { auto dipFactor = DisplayProperties::LogicalDpi / 96.0f; return v * dipFactor; } -#endif void CC_DLL CCLogIPAddresses() @@ -158,7 +154,6 @@ std::string CC_DLL getDeviceIPAddresses() return result.str(); } -#if CC_TARGET_PLATFORM != CC_PLATFORM_WP8 Platform::Object^ findXamlElement(Platform::Object^ parent, Platform::String^ name) { if (parent == nullptr || name == nullptr || name->Length() == 0) @@ -253,43 +248,6 @@ bool replaceXamlElement(Platform::Object^ parent, Platform::Object^ add, Platfor return true; } -#endif - - - - - - - - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) - -// Function that reads from a binary file asynchronously. -Concurrency::task^> ReadDataAsync(Platform::String^ filename) -{ - using namespace Windows::Storage; - using namespace Concurrency; - - auto folder = Windows::ApplicationModel::Package::Current->InstalledLocation; - - return create_task(folder->GetFileAsync(filename)).then([] (StorageFile^ file) - { - return file->OpenReadAsync(); - }).then([] (Streams::IRandomAccessStreamWithContentType^ stream) - { - unsigned int bufferSize = static_cast(stream->Size); - auto fileBuffer = ref new Streams::Buffer(bufferSize); - return stream->ReadAsync(fileBuffer, bufferSize, Streams::InputStreamOptions::None); - }).then([] (Streams::IBuffer^ fileBuffer) -> Platform::Array^ - { - auto fileData = ref new Platform::Array(fileBuffer->Length); - Streams::DataReader::FromBuffer(fileBuffer)->ReadBytes(fileData); - return fileData; - }); -} -#else - - // Function that reads from a binary file asynchronously. Concurrency::task^> ReadDataAsync(Platform::String^ path) @@ -310,8 +268,4 @@ Concurrency::task^> ReadDataAsync(Platform::String^ path) } - -#endif - - NS_CC_END diff --git a/cocos/platform/winrt/CCWinRTUtils.h b/cocos/platform/winrt/CCWinRTUtils.h index 19a229a233..986fb0dc90 100644 --- a/cocos/platform/winrt/CCWinRTUtils.h +++ b/cocos/platform/winrt/CCWinRTUtils.h @@ -40,21 +40,13 @@ NS_CC_BEGIN std::wstring CC_DLL CCUtf8ToUnicode(const char * pszUtf8Str, unsigned len = -1); std::string CC_DLL CCUnicodeToUtf8(const wchar_t* pwszStr); -#if CC_TARGET_PLATFORM != CC_PLATFORM_WP8 Platform::Object^ findXamlElement(Platform::Object^ parent, Platform::String^ name); bool removeXamlElement(Platform::Object^ parent, Platform::Object^ element); bool replaceXamlElement(Platform::Object^ parent, Platform::Object^ add, Platform::Object^ remove); -#endif std::string PlatformStringToString(Platform::String^ s); Platform::String^ PlatformStringFromString(const std::string& s); -#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 -// Method to convert a length in device-independent pixels (DIPs) to a length in physical pixels. -float ConvertDipsToPixels(float dips); -float getScaledDPIValue(float v); -#endif - Concurrency::task^> ReadDataAsync(Platform::String^ path); void CC_DLL CCLogIPAddresses(); diff --git a/cocos/platform/winrt/InputEvent.cpp b/cocos/platform/winrt/InputEvent.cpp index 4a443d3dca..9343c80f5d 100644 --- a/cocos/platform/winrt/InputEvent.cpp +++ b/cocos/platform/winrt/InputEvent.cpp @@ -25,13 +25,7 @@ THE SOFTWARE. #include "InputEvent.h" #include "CCWinRTUtils.h" - -#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 -#include "CCGLViewImpl-wp8.h" -#else #include "CCGLViewImpl-winrt.h" -#endif - #include "base/CCEventAcceleration.h" NS_CC_BEGIN diff --git a/cocos/renderer/CCGLProgram.cpp b/cocos/renderer/CCGLProgram.cpp index c153a30101..224bf27536 100644 --- a/cocos/renderer/CCGLProgram.cpp +++ b/cocos/renderer/CCGLProgram.cpp @@ -39,9 +39,24 @@ THE SOFTWARE. #include "deprecated/CCString.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || defined(WP8_SHADER_COMPILER) -#include "CCPrecompiledShaders.h" -#endif +// helper functions + +static void replaceDefines(const std::string& compileTimeDefines, std::string& out) +{ + // Replace semicolons with '#define ... \n' + if (compileTimeDefines.size() > 0) + { + size_t pos; + out = compileTimeDefines; + out.insert(0, "#define "); + while ((pos = out.find(';')) != std::string::npos) + { + out.replace(pos, 1, "\n#define "); + } + out += "\n"; + } +} + NS_CC_BEGIN @@ -104,10 +119,32 @@ const char* GLProgram::ATTRIBUTE_NAME_NORMAL = "a_normal"; const char* GLProgram::ATTRIBUTE_NAME_BLEND_WEIGHT = "a_blendWeight"; const char* GLProgram::ATTRIBUTE_NAME_BLEND_INDEX = "a_blendIndex"; +static const char * COCOS2D_SHADER_UNIFORMS = + "uniform mat4 CC_PMatrix;\n" + "uniform mat4 CC_MVMatrix;\n" + "uniform mat4 CC_MVPMatrix;\n" + "uniform mat3 CC_NormalMatrix;\n" + "uniform vec4 CC_Time;\n" + "uniform vec4 CC_SinTime;\n" + "uniform vec4 CC_CosTime;\n" + "uniform vec4 CC_Random01;\n" + "uniform sampler2D CC_Texture0;\n" + "uniform sampler2D CC_Texture1;\n" + "uniform sampler2D CC_Texture2;\n" + "uniform sampler2D CC_Texture3;\n" + "//CC INCLUDES END\n\n"; + +static const std::string EMPTY_DEFINE; + GLProgram* GLProgram::createWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray) +{ + return createWithByteArrays(vShaderByteArray, fShaderByteArray, EMPTY_DEFINE); +} + +GLProgram* GLProgram::createWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray, const std::string& compileTimeDefines) { auto ret = new (std::nothrow) GLProgram(); - if(ret && ret->initWithByteArrays(vShaderByteArray, fShaderByteArray)) { + if(ret && ret->initWithByteArrays(vShaderByteArray, fShaderByteArray, compileTimeDefines)) { ret->link(); ret->updateUniforms(); ret->autorelease(); @@ -118,10 +155,16 @@ GLProgram* GLProgram::createWithByteArrays(const GLchar* vShaderByteArray, const return nullptr; } + GLProgram* GLProgram::createWithFilenames(const std::string& vShaderFilename, const std::string& fShaderFilename) +{ + return createWithFilenames(vShaderFilename, fShaderFilename, EMPTY_DEFINE); +} + +GLProgram* GLProgram::createWithFilenames(const std::string& vShaderFilename, const std::string& fShaderFilename, const std::string& compileTimeDefines) { auto ret = new (std::nothrow) GLProgram(); - if(ret && ret->initWithFilenames(vShaderFilename, fShaderFilename)) { + if(ret && ret->initWithFilenames(vShaderFilename, fShaderFilename, compileTimeDefines)) { ret->link(); ret->updateUniforms(); ret->autorelease(); @@ -132,6 +175,7 @@ GLProgram* GLProgram::createWithFilenames(const std::string& vShaderFilename, co return nullptr; } + GLProgram::GLProgram() : _program(0) , _vertShader(0) @@ -173,26 +217,24 @@ GLProgram::~GLProgram() bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray) { + return initWithByteArrays(vShaderByteArray, fShaderByteArray, EMPTY_DEFINE); +} -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) - GLboolean hasCompiler = false; - glGetBooleanv(GL_SHADER_COMPILER, &hasCompiler); - _hasShaderCompiler = (hasCompiler == GL_TRUE); - - if(!_hasShaderCompiler) - { - return initWithPrecompiledProgramByteArray(vShaderByteArray,fShaderByteArray); - } -#endif - +bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray, const std::string& compileTimeDefines) +{ _program = glCreateProgram(); CHECK_GL_ERROR_DEBUG(); + // convert defines here. If we do it in "compileShader" we will do it it twice. + // a cache for the defines could be useful, but seems like overkill at this point + std::string replacedDefines = ""; + replaceDefines(compileTimeDefines, replacedDefines); + _vertShader = _fragShader = 0; if (vShaderByteArray) { - if (!compileShader(&_vertShader, GL_VERTEX_SHADER, vShaderByteArray)) + if (!compileShader(&_vertShader, GL_VERTEX_SHADER, vShaderByteArray, replacedDefines)) { CCLOG("cocos2d: ERROR: Failed to compile vertex shader"); return false; @@ -202,7 +244,7 @@ bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar* // Create and compile fragment shader if (fShaderByteArray) { - if (!compileShader(&_fragShader, GL_FRAGMENT_SHADER, fShaderByteArray)) + if (!compileShader(&_fragShader, GL_FRAGMENT_SHADER, fShaderByteArray, replacedDefines)) { CCLOG("cocos2d: ERROR: Failed to compile fragment shader"); return false; @@ -224,55 +266,21 @@ bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar* CHECK_GL_ERROR_DEBUG(); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || defined(WP8_SHADER_COMPILER) - _shaderId = CCPrecompiledShaders::getInstance()->addShaders(vShaderByteArray, fShaderByteArray); -#endif - return true; } -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) -GLProgram* GLProgram::createWithPrecompiledProgramByteArray(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray) +bool GLProgram::initWithFilenames(const std::string& vShaderFilename, const std::string& fShaderFilename) { - auto ret = new (std::nothrow) GLProgram(); - if(ret && ret->initWithPrecompiledProgramByteArray(vShaderByteArray, fShaderByteArray)) { - ret->link(); - ret->updateUniforms(); - ret->autorelease(); - return ret; - } - - CC_SAFE_DELETE(ret); - return nullptr; + return initWithFilenames(vShaderFilename, fShaderFilename, EMPTY_DEFINE); } -bool GLProgram::initWithPrecompiledProgramByteArray(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray) -{ - bool haveProgram = false; - - _program = glCreateProgram(); - CHECK_GL_ERROR_DEBUG(); - - _vertShader = _fragShader = 0; - - haveProgram = CCPrecompiledShaders::getInstance()->loadProgram(_program, vShaderByteArray, fShaderByteArray); - - CHECK_GL_ERROR_DEBUG(); - _hashForUniforms.clear(); - - CHECK_GL_ERROR_DEBUG(); - - return haveProgram; -} -#endif - -bool GLProgram::initWithFilenames(const std::string &vShaderFilename, const std::string &fShaderFilename) +bool GLProgram::initWithFilenames(const std::string& vShaderFilename, const std::string& fShaderFilename, const std::string& compileTimeDefines) { auto fileUtils = FileUtils::getInstance(); std::string vertexSource = fileUtils->getStringFromFile(FileUtils::getInstance()->fullPathForFilename(vShaderFilename)); std::string fragmentSource = fileUtils->getStringFromFile(FileUtils::getInstance()->fullPathForFilename(fShaderFilename)); - return initWithByteArrays(vertexSource.c_str(), fragmentSource.c_str()); + return initWithByteArrays(vertexSource.c_str(), fragmentSource.c_str(), compileTimeDefines); } void GLProgram::bindPredefinedVertexAttribs() @@ -421,6 +429,11 @@ std::string GLProgram::getDescription() const } bool GLProgram::compileShader(GLuint * shader, GLenum type, const GLchar* source) +{ + return compileShader(shader, type, source, ""); +} + +bool GLProgram::compileShader(GLuint* shader, GLenum type, const GLchar* source, const std::string& convertedDefines) { GLint status; @@ -435,21 +448,9 @@ bool GLProgram::compileShader(GLuint * shader, GLenum type, const GLchar* source #elif (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32 && CC_TARGET_PLATFORM != CC_PLATFORM_LINUX && CC_TARGET_PLATFORM != CC_PLATFORM_MAC) (type == GL_VERTEX_SHADER ? "precision highp float;\n precision highp int;\n" : "precision mediump float;\n precision mediump int;\n"), #endif - "uniform mat4 CC_PMatrix;\n" - "uniform mat4 CC_MVMatrix;\n" - "uniform mat4 CC_MVPMatrix;\n" - "uniform mat3 CC_NormalMatrix;\n" - "uniform vec4 CC_Time;\n" - "uniform vec4 CC_SinTime;\n" - "uniform vec4 CC_CosTime;\n" - "uniform vec4 CC_Random01;\n" - "uniform sampler2D CC_Texture0;\n" - "uniform sampler2D CC_Texture1;\n" - "uniform sampler2D CC_Texture2;\n" - "uniform sampler2D CC_Texture3;\n" - "//CC INCLUDES END\n\n", - source, - }; + COCOS2D_SHADER_UNIFORMS, + convertedDefines.c_str(), + source}; *shader = glCreateShader(type); glShaderSource(*shader, sizeof(sources)/sizeof(*sources), sources, nullptr); @@ -543,18 +544,6 @@ bool GLProgram::link() { CCASSERT(_program != 0, "Cannot link invalid program"); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) - if(!_hasShaderCompiler) - { - // precompiled shader program is already linked - - //bindPredefinedVertexAttribs(); - parseVertexAttribs(); - parseUniforms(); - return true; - } -#endif - GLint status = GL_TRUE; bindPredefinedVertexAttribs(); @@ -576,7 +565,7 @@ bool GLProgram::link() _vertShader = _fragShader = 0; -#if DEBUG || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if DEBUG || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) glGetProgramiv(_program, GL_LINK_STATUS, &status); if (status == GL_FALSE) @@ -587,13 +576,6 @@ bool GLProgram::link() } #endif -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || defined(WP8_SHADER_COMPILER) - if (status == GL_TRUE) - { - CCPrecompiledShaders::getInstance()->addProgram(_program, _shaderId); - } -#endif - return (status == GL_TRUE); } @@ -705,7 +687,7 @@ void GLProgram::setUniformLocationWith1i(GLint location, GLint i1) { bool updated = updateUniformLocation(location, &i1, sizeof(i1)*1); - if( updated ) + if (updated) { glUniform1i( (GLint)location, i1); } @@ -716,7 +698,7 @@ void GLProgram::setUniformLocationWith2i(GLint location, GLint i1, GLint i2) GLint ints[2] = {i1,i2}; bool updated = updateUniformLocation(location, ints, sizeof(ints)); - if( updated ) + if (updated) { glUniform2i( (GLint)location, i1, i2); } @@ -727,7 +709,7 @@ void GLProgram::setUniformLocationWith3i(GLint location, GLint i1, GLint i2, GLi GLint ints[3] = {i1,i2,i3}; bool updated = updateUniformLocation(location, ints, sizeof(ints)); - if( updated ) + if (updated) { glUniform3i( (GLint)location, i1, i2, i3); } @@ -738,7 +720,7 @@ void GLProgram::setUniformLocationWith4i(GLint location, GLint i1, GLint i2, GLi GLint ints[4] = {i1,i2,i3,i4}; bool updated = updateUniformLocation(location, ints, sizeof(ints)); - if( updated ) + if (updated) { glUniform4i( (GLint)location, i1, i2, i3, i4); } @@ -748,7 +730,7 @@ void GLProgram::setUniformLocationWith2iv(GLint location, GLint* ints, unsigned { bool updated = updateUniformLocation(location, ints, sizeof(int)*2*numberOfArrays); - if( updated ) + if (updated) { glUniform2iv( (GLint)location, (GLsizei)numberOfArrays, ints ); } @@ -758,7 +740,7 @@ void GLProgram::setUniformLocationWith3iv(GLint location, GLint* ints, unsigned { bool updated = updateUniformLocation(location, ints, sizeof(int)*3*numberOfArrays); - if( updated ) + if (updated) { glUniform3iv( (GLint)location, (GLsizei)numberOfArrays, ints ); } @@ -768,7 +750,7 @@ void GLProgram::setUniformLocationWith4iv(GLint location, GLint* ints, unsigned { bool updated = updateUniformLocation(location, ints, sizeof(int)*4*numberOfArrays); - if( updated ) + if (updated) { glUniform4iv( (GLint)location, (GLsizei)numberOfArrays, ints ); } @@ -778,7 +760,7 @@ void GLProgram::setUniformLocationWith1f(GLint location, GLfloat f1) { bool updated = updateUniformLocation(location, &f1, sizeof(f1)*1); - if( updated ) + if (updated) { glUniform1f( (GLint)location, f1); } @@ -789,7 +771,7 @@ void GLProgram::setUniformLocationWith2f(GLint location, GLfloat f1, GLfloat f2) GLfloat floats[2] = {f1,f2}; bool updated = updateUniformLocation(location, floats, sizeof(floats)); - if( updated ) + if (updated) { glUniform2f( (GLint)location, f1, f2); } @@ -800,7 +782,7 @@ void GLProgram::setUniformLocationWith3f(GLint location, GLfloat f1, GLfloat f2, GLfloat floats[3] = {f1,f2,f3}; bool updated = updateUniformLocation(location, floats, sizeof(floats)); - if( updated ) + if (updated) { glUniform3f( (GLint)location, f1, f2, f3); } @@ -811,7 +793,7 @@ void GLProgram::setUniformLocationWith4f(GLint location, GLfloat f1, GLfloat f2, GLfloat floats[4] = {f1,f2,f3,f4}; bool updated = updateUniformLocation(location, floats, sizeof(floats)); - if( updated ) + if (updated) { glUniform4f( (GLint)location, f1, f2, f3,f4); } @@ -822,7 +804,7 @@ void GLProgram::setUniformLocationWith1fv( GLint location, const GLfloat* floats { bool updated = updateUniformLocation(location, floats, sizeof(float)*numberOfArrays); - if( updated ) + if (updated) { glUniform1fv( (GLint)location, (GLsizei)numberOfArrays, floats ); } @@ -832,7 +814,7 @@ void GLProgram::setUniformLocationWith2fv(GLint location, const GLfloat* floats, { bool updated = updateUniformLocation(location, floats, sizeof(float)*2*numberOfArrays); - if( updated ) + if (updated) { glUniform2fv( (GLint)location, (GLsizei)numberOfArrays, floats ); } @@ -842,7 +824,7 @@ void GLProgram::setUniformLocationWith3fv(GLint location, const GLfloat* floats, { bool updated = updateUniformLocation(location, floats, sizeof(float)*3*numberOfArrays); - if( updated ) + if (updated) { glUniform3fv( (GLint)location, (GLsizei)numberOfArrays, floats ); } @@ -852,7 +834,7 @@ void GLProgram::setUniformLocationWith4fv(GLint location, const GLfloat* floats, { bool updated = updateUniformLocation(location, floats, sizeof(float)*4*numberOfArrays); - if( updated ) + if (updated) { glUniform4fv( (GLint)location, (GLsizei)numberOfArrays, floats ); } @@ -861,7 +843,7 @@ void GLProgram::setUniformLocationWith4fv(GLint location, const GLfloat* floats, void GLProgram::setUniformLocationWithMatrix2fv(GLint location, const GLfloat* matrixArray, unsigned int numberOfMatrices) { bool updated = updateUniformLocation(location, matrixArray, sizeof(float)*4*numberOfMatrices); - if( updated ) + if (updated) { glUniformMatrix2fv( (GLint)location, (GLsizei)numberOfMatrices, GL_FALSE, matrixArray); } @@ -870,7 +852,7 @@ void GLProgram::setUniformLocationWithMatrix2fv(GLint location, const GLfloat* m void GLProgram::setUniformLocationWithMatrix3fv(GLint location, const GLfloat* matrixArray, unsigned int numberOfMatrices) { bool updated = updateUniformLocation(location, matrixArray, sizeof(float)*9*numberOfMatrices); - if( updated ) + if (updated) { glUniformMatrix3fv( (GLint)location, (GLsizei)numberOfMatrices, GL_FALSE, matrixArray); } @@ -881,7 +863,7 @@ void GLProgram::setUniformLocationWithMatrix4fv(GLint location, const GLfloat* m { bool updated = updateUniformLocation(location, matrixArray, sizeof(float)*16*numberOfMatrices); - if( updated ) + if (updated) { glUniformMatrix4fv( (GLint)location, (GLsizei)numberOfMatrices, GL_FALSE, matrixArray); } @@ -896,13 +878,13 @@ void GLProgram::setUniformsForBuiltins(const Mat4 &matrixMV) { auto& matrixP = _director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); - if(_flags.usesP) + if (_flags.usesP) setUniformLocationWithMatrix4fv(_builtInUniforms[UNIFORM_P_MATRIX], matrixP.m, 1); - if(_flags.usesMV) + if (_flags.usesMV) setUniformLocationWithMatrix4fv(_builtInUniforms[UNIFORM_MV_MATRIX], matrixMV.m, 1); - if(_flags.usesMVP) { + if (_flags.usesMVP) { Mat4 matrixMVP = matrixP * matrixMV; setUniformLocationWithMatrix4fv(_builtInUniforms[UNIFORM_MVP_MATRIX], matrixMVP.m, 1); } @@ -920,7 +902,7 @@ void GLProgram::setUniformsForBuiltins(const Mat4 &matrixMV) setUniformLocationWithMatrix3fv(_builtInUniforms[UNIFORM_NORMAL_MATRIX], normalMat, 1); } - if(_flags.usesTime) { + if (_flags.usesTime) { // This doesn't give the most accurate global time value. // Cocos2D doesn't store a high precision time value, so this will have to do. // Getting Mach time per frame per shader using time could be extremely expensive. @@ -931,7 +913,7 @@ void GLProgram::setUniformsForBuiltins(const Mat4 &matrixMV) setUniformLocationWith4f(_builtInUniforms[GLProgram::UNIFORM_COS_TIME], time/8.0, time/4.0, time/2.0, cosf(time)); } - if(_flags.usesRandom) + if (_flags.usesRandom) setUniformLocationWith4f(_builtInUniforms[GLProgram::UNIFORM_RANDOM01], CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1()); } @@ -954,3 +936,4 @@ void GLProgram::reset() } NS_CC_END + diff --git a/cocos/renderer/CCGLProgram.h b/cocos/renderer/CCGLProgram.h index 78716ab2d6..643260e9a3 100644 --- a/cocos/renderer/CCGLProgram.h +++ b/cocos/renderer/CCGLProgram.h @@ -31,6 +31,7 @@ THE SOFTWARE. #define __CCGLPROGRAM_H__ #include +#include #include "base/ccMacros.h" #include "base/CCRef.h" @@ -165,10 +166,6 @@ public: static const char* SHADER_NAME_POSITION_COLOR_TEXASPOINTSIZE; /**Built in shader for 2d. Support Position, Color vertex attribute, without multiply vertex by MVP matrix.*/ static const char* SHADER_NAME_POSITION_COLOR_NO_MVP; -#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || defined(WP8_SHADER_COMPILER) - /**Built in shader for 2d. Support Position, Color vertex attribute, without multiply vertex by MVP matrix and have a grey scale fragment shader.*/ - static const char* SHADER_NAME_POSITION_COLOR_NO_MVP_GRAYåSCALE; -#endif /**Built in shader for 2d. Support Position, Texture vertex attribute.*/ static const char* SHADER_NAME_POSITION_TEXTURE; /**Built in shader for 2d. Support Position, Texture vertex attribute. with a specified uniform as color*/ @@ -309,13 +306,6 @@ public: /**Destructor.*/ virtual ~GLProgram(); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) - /** @{Initializes the CCGLProgram with precompiled shader program. */ - static GLProgram* createWithPrecompiledProgramByteArray(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray); - bool initWithPrecompiledProgramByteArray(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray); - /**@}*/ -#endif - /** @{ Create or Initializes the GLProgram with a vertex and fragment with bytes array. * @js initWithString. @@ -323,6 +313,9 @@ public: */ static GLProgram* createWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray); bool initWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray); + static GLProgram* createWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray, const std::string& compileTimeDefines); + bool initWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray, const std::string& compileTimeDefines); + /** @} */ @@ -333,6 +326,9 @@ public: */ static GLProgram* createWithFilenames(const std::string& vShaderFilename, const std::string& fShaderFilename); bool initWithFilenames(const std::string& vShaderFilename, const std::string& fShaderFilename); + + static GLProgram* createWithFilenames(const std::string& vShaderFilename, const std::string& fShaderFilename, const std::string& compileTimeDefines); + bool initWithFilenames(const std::string& vShaderFilename, const std::string& fShaderFilename, const std::string& compileTimeDefines); /** @} */ @@ -491,6 +487,7 @@ protected: /**Parse user defined uniform automatically.*/ void parseUniforms(); /**Compile the shader sources.*/ + bool compileShader(GLuint * shader, GLenum type, const GLchar* source, const std::string& convertedDefines); bool compileShader(GLuint * shader, GLenum type, const GLchar* source); /**OpenGL handle for program.*/ @@ -504,11 +501,6 @@ protected: /**Indicate whether it has a offline shader compiler or not.*/ bool _hasShaderCompiler; -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || defined(WP8_SHADER_COMPILER) - /**Shader ID in precompiled shaders on Windows phone.*/ - std::string _shaderId; -#endif - struct flag_struct { unsigned int usesTime:1; unsigned int usesNormal:1; diff --git a/cocos/renderer/CCGLProgramCache.cpp b/cocos/renderer/CCGLProgramCache.cpp index 6f5404e8da..ebd22fdde5 100644 --- a/cocos/renderer/CCGLProgramCache.cpp +++ b/cocos/renderer/CCGLProgramCache.cpp @@ -32,10 +32,6 @@ THE SOFTWARE. #include "base/ccMacros.h" #include "base/CCConfiguration.h" -#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || defined(WP8_SHADER_COMPILER) -#include "ui/shaders/UIShaders.h" -#endif - NS_CC_BEGIN enum { @@ -200,7 +196,6 @@ void GLProgramCache::loadDefaultGLPrograms() loadDefaultGLProgram(p, kShaderType_PositionLengthTexureColor); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR, p) ); -#if CC_TARGET_PLATFORM != CC_PLATFORM_WP8 p = new (std::nothrow) GLProgram(); loadDefaultGLProgram(p, kShaderType_LabelDistanceFieldNormal); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL, p) ); @@ -208,7 +203,6 @@ void GLProgramCache::loadDefaultGLPrograms() p = new (std::nothrow) GLProgram(); loadDefaultGLProgram(p, kShaderType_LabelDistanceFieldGlow); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_GLOW, p) ); -#endif p = new (std::nothrow) GLProgram(); loadDefaultGLProgram(p, kShaderType_UIGrayScale); @@ -343,7 +337,6 @@ void GLProgramCache::reloadDefaultGLPrograms() p->reset(); loadDefaultGLProgram(p, kShaderType_PositionLengthTexureColor); -#if CC_TARGET_PLATFORM != CC_PLATFORM_WP8 p = getGLProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL); p->reset(); loadDefaultGLProgram(p, kShaderType_LabelDistanceFieldNormal); @@ -351,7 +344,6 @@ void GLProgramCache::reloadDefaultGLPrograms() p = getGLProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_GLOW); p->reset(); loadDefaultGLProgram(p, kShaderType_LabelDistanceFieldGlow); -#endif p = getGLProgram(GLProgram::SHADER_NAME_LABEL_NORMAL); p->reset(); @@ -446,14 +438,12 @@ void GLProgramCache::loadDefaultGLProgram(GLProgram *p, int type) case kShaderType_PositionLengthTexureColor: p->initWithByteArrays(ccPositionColorLengthTexture_vert, ccPositionColorLengthTexture_frag); break; -#if CC_TARGET_PLATFORM != CC_PLATFORM_WP8 case kShaderType_LabelDistanceFieldNormal: p->initWithByteArrays(ccLabel_vert, ccLabelDistanceFieldNormal_frag); break; case kShaderType_LabelDistanceFieldGlow: p->initWithByteArrays(ccLabel_vert, ccLabelDistanceFieldGlow_frag); break; -#endif case kShaderType_UIGrayScale: p->initWithByteArrays(ccPositionTextureColor_noMVP_vert, ccPositionTexture_GrayScale_frag); diff --git a/cocos/renderer/CCGLProgramState.cpp b/cocos/renderer/CCGLProgramState.cpp index 34b94140d2..8a4b5cd5ad 100644 --- a/cocos/renderer/CCGLProgramState.cpp +++ b/cocos/renderer/CCGLProgramState.cpp @@ -50,29 +50,54 @@ NS_CC_BEGIN UniformValue::UniformValue() : _uniform(nullptr) , _glprogram(nullptr) -, _useCallback(false) +, _type(Type::VALUE) { } UniformValue::UniformValue(Uniform *uniform, GLProgram* glprogram) : _uniform(uniform) , _glprogram(glprogram) -, _useCallback(false) +, _type(Type::VALUE) { } UniformValue::~UniformValue() { - if (_useCallback) + if (_type == Type::CALLBACK_FN) delete _value.callback; } void UniformValue::apply() { - if(_useCallback) { + if (_type == Type::CALLBACK_FN) + { (*_value.callback)(_glprogram, _uniform); } - else + else if (_type == Type::POINTER) + { + switch (_uniform->type) { + case GL_FLOAT: + _glprogram->setUniformLocationWith1fv(_uniform->location, _value.floatv.pointer, _value.floatv.size); + break; + + case GL_FLOAT_VEC2: + _glprogram->setUniformLocationWith2fv(_uniform->location, _value.v2f.pointer, _value.v2f.size); + break; + + case GL_FLOAT_VEC3: + _glprogram->setUniformLocationWith3fv(_uniform->location, _value.v3f.pointer, _value.v3f.size); + break; + + case GL_FLOAT_VEC4: + _glprogram->setUniformLocationWith4fv(_uniform->location, _value.v4f.pointer, _value.v4f.size); + break; + + default: + CCASSERT(false, "Unsupported type"); + break; + } + } + else /* _type == VALUE */ { switch (_uniform->type) { case GL_SAMPLER_2D: @@ -122,20 +147,13 @@ void UniformValue::setCallback(const std::function & // TODO: memory will leak if the user does: // value->setCallback(); // value->setFloat(); - if (_useCallback) + if (_type == Type::CALLBACK_FN) delete _value.callback; _value.callback = new std::function(); *_value.callback = callback; - _useCallback = true; -} - -void UniformValue::setFloat(float value) -{ - CCASSERT (_uniform->type == GL_FLOAT, ""); - _value.floatValue = value; - _useCallback = false; + _type = Type::CALLBACK_FN; } void UniformValue::setTexture(GLuint textureId, GLuint textureUnit) @@ -143,41 +161,82 @@ void UniformValue::setTexture(GLuint textureId, GLuint textureUnit) //CCASSERT(_uniform->type == GL_SAMPLER_2D, "Wrong type. expecting GL_SAMPLER_2D"); _value.tex.textureId = textureId; _value.tex.textureUnit = textureUnit; - _useCallback = false; + _type = Type::VALUE; } void UniformValue::setInt(int value) { CCASSERT(_uniform->type == GL_INT, "Wrong type: expecting GL_INT"); _value.intValue = value; - _useCallback = false; + _type = Type::VALUE; +} + +void UniformValue::setFloat(float value) +{ + CCASSERT(_uniform->type == GL_FLOAT, "Wrong type: expecting GL_FLOAT"); + _value.floatValue = value; + _type = Type::VALUE; +} + +void UniformValue::setFloatv(const float* pointer, ssize_t size) +{ + CCASSERT(_uniform->type == GL_FLOAT, "Wrong type: expecting GL_FLOAT"); + _value.floatv.pointer = (const float*)pointer; + _value.floatv.size = (GLsizei)size; + _type = Type::POINTER; } void UniformValue::setVec2(const Vec2& value) { - CCASSERT (_uniform->type == GL_FLOAT_VEC2, ""); + CCASSERT(_uniform->type == GL_FLOAT_VEC2, "Wrong type: expecting GL_FLOAT_VEC2"); memcpy(_value.v2Value, &value, sizeof(_value.v2Value)); - _useCallback = false; + _type = Type::VALUE; +} + +void UniformValue::setVec2v(const Vec2* pointer, ssize_t size) +{ + CCASSERT(_uniform->type == GL_FLOAT_VEC2, "Wrong type: expecting GL_FLOAT_VEC2"); + _value.v2f.pointer = (const float*)pointer; + _value.v2f.size = (GLsizei)size; + _type = Type::POINTER; } void UniformValue::setVec3(const Vec3& value) { - CCASSERT (_uniform->type == GL_FLOAT_VEC3, ""); + CCASSERT(_uniform->type == GL_FLOAT_VEC3, "Wrong type: expecting GL_FLOAT_VEC3"); memcpy(_value.v3Value, &value, sizeof(_value.v3Value)); - _useCallback = false; + _type = Type::VALUE; + +} + +void UniformValue::setVec3v(const Vec3* pointer, ssize_t size) +{ + CCASSERT(_uniform->type == GL_FLOAT_VEC3, "Wrong type: expecting GL_FLOAT_VEC3"); + _value.v3f.pointer = (const float*)pointer; + _value.v3f.size = (GLsizei)size; + _type = Type::POINTER; + } void UniformValue::setVec4(const Vec4& value) { - CCASSERT (_uniform->type == GL_FLOAT_VEC4, ""); + CCASSERT (_uniform->type == GL_FLOAT_VEC4, "Wrong type: expecting GL_FLOAT_VEC4"); memcpy(_value.v4Value, &value, sizeof(_value.v4Value)); - _useCallback = false; + _type = Type::VALUE; +} + +void UniformValue::setVec4v(const Vec4* pointer, ssize_t size) +{ + CCASSERT (_uniform->type == GL_FLOAT_VEC4, "Wrong type: expecting GL_FLOAT_VEC4"); + _value.v4f.pointer = (const float*)pointer; + _value.v4f.size = (GLsizei)size; + _type = Type::POINTER; } void UniformValue::setMat4(const Mat4& value) { CCASSERT(_uniform->type == GL_FLOAT_MAT4, ""); memcpy(_value.matrixValue, &value, sizeof(_value.matrixValue)); - _useCallback = false; + _type = Type::VALUE; } // @@ -278,13 +337,28 @@ GLProgramState* GLProgramState::getOrCreateWithGLProgram(GLProgram *glprogram) return ret; } +GLProgramState* GLProgramState::getOrCreateWithShaders(const std::string& vertexShader, const std::string& fragShader, const std::string& compileTimeDefines) +{ + auto glprogramcache = GLProgramCache::getInstance(); + const std::string key = vertexShader + "+" + fragShader + "+" + compileTimeDefines; + auto glprogram = glprogramcache->getGLProgram(key); + + if (!glprogram) { + glprogram = GLProgram::createWithFilenames(vertexShader, fragShader, compileTimeDefines); + glprogramcache->addGLProgram(glprogram, key); + } + + return create(glprogram); +} + + GLProgramState::GLProgramState() : _uniformAttributeValueDirty(true) , _textureUnitIndex(1) , _vertexAttribsFlags(0) , _glprogram(nullptr) { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) /** listen the event that renderer was recreated on Android/WP8 */ CCLOG("create rendererRecreatedListener for GLProgramState"); _backToForegroundlistener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, @@ -299,13 +373,38 @@ GLProgramState::GLProgramState() GLProgramState::~GLProgramState() { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundlistener); #endif CC_SAFE_RELEASE(_glprogram); } +GLProgramState* GLProgramState::clone() const +{ + auto glprogramstate = new (std::nothrow) GLProgramState(); + + // copy everything manually, instead of calling init since this is faster + + glprogramstate->_glprogram = this->_glprogram; + CC_SAFE_RETAIN(glprogramstate->_glprogram); + + glprogramstate->_attributes = this->_attributes; + glprogramstate->_vertexAttribsFlags = this->_vertexAttribsFlags; + + // copy uniforms + glprogramstate->_uniformsByName = this->_uniformsByName; + glprogramstate->_uniforms = this->_uniforms; + glprogramstate->_uniformAttributeValueDirty = this->_uniformAttributeValueDirty; + + // copy textures + glprogramstate->_textureUnitIndex = this->_textureUnitIndex; + glprogramstate->_boundTextureUnits = this->_boundTextureUnits; + + glprogramstate->autorelease(); + return glprogramstate; +} + bool GLProgramState::init(GLProgram* glprogram) { CCASSERT(glprogram, "invalid shader"); @@ -376,6 +475,7 @@ void GLProgramState::applyGLProgram(const Mat4& modelView) _glprogram->use(); _glprogram->setUniformsForBuiltins(modelView); } + void GLProgramState::applyAttributes(bool applyAttribFlags) { // Don't set attributes if they weren't set @@ -411,6 +511,16 @@ void GLProgramState::setGLProgram(GLProgram *glprogram) } } +uint32_t GLProgramState::getVertexAttribsFlags() const +{ + return _vertexAttribsFlags; +} + +ssize_t GLProgramState::getVertexAttribCount() const +{ + return _attributes.size(); +} + UniformValue* GLProgramState::getUniformValue(GLint uniformLocation) { updateUniformsAndAttributes(); @@ -522,6 +632,24 @@ void GLProgramState::setUniformInt(GLint uniformLocation, int value) } +void GLProgramState::setUniformFloatv(const std::string &uniformName, const float* pointer, ssize_t size) +{ + auto v = getUniformValue(uniformName); + if (v) + v->setFloatv(pointer, size); + else + CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str()); +} + +void GLProgramState::setUniformFloatv(GLint uniformLocation, const float* pointer, ssize_t size) +{ + auto v = getUniformValue(uniformLocation); + if (v) + v->setFloatv(pointer, size); + else + CCLOG("cocos2d: warning: Uniform at location not found: %i", uniformLocation); +} + void GLProgramState::setUniformVec2(const std::string &uniformName, const Vec2& value) { auto v = getUniformValue(uniformName); @@ -540,6 +668,24 @@ void GLProgramState::setUniformVec2(GLint uniformLocation, const Vec2& value) CCLOG("cocos2d: warning: Uniform at location not found: %i", uniformLocation); } +void GLProgramState::setUniformVec2v(const std::string &uniformName, const Vec2* pointer, ssize_t size) +{ + auto v = getUniformValue(uniformName); + if (v) + v->setVec2v(pointer, size); + else + CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str()); +} + +void GLProgramState::setUniformVec2v(GLint uniformLocation, const Vec2* pointer, ssize_t size) +{ + auto v = getUniformValue(uniformLocation); + if (v) + v->setVec2v(pointer, size); + else + CCLOG("cocos2d: warning: Uniform at location not found: %i", uniformLocation); +} + void GLProgramState::setUniformVec3(const std::string &uniformName, const Vec3& value) { auto v = getUniformValue(uniformName); @@ -558,6 +704,24 @@ void GLProgramState::setUniformVec3(GLint uniformLocation, const Vec3& value) CCLOG("cocos2d: warning: Uniform at location not found: %i", uniformLocation); } +void GLProgramState::setUniformVec3v(const std::string &uniformName, const Vec3* pointer, ssize_t size) +{ + auto v = getUniformValue(uniformName); + if (v) + v->setVec3v(pointer, size); + else + CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str()); +} + +void GLProgramState::setUniformVec3v(GLint uniformLocation, const Vec3* pointer, ssize_t size) +{ + auto v = getUniformValue(uniformLocation); + if (v) + v->setVec3v(pointer, size); + else + CCLOG("cocos2d: warning: Uniform at location not found: %i", uniformLocation); +} + void GLProgramState::setUniformVec4(const std::string &uniformName, const Vec4& value) { auto v = getUniformValue(uniformName); @@ -576,6 +740,25 @@ void GLProgramState::setUniformVec4(GLint uniformLocation, const Vec4& value) CCLOG("cocos2d: warning: Uniform at location not found: %i", uniformLocation); } +void GLProgramState::setUniformVec4v(const std::string &uniformName, const Vec4* value, ssize_t size) +{ + auto v = getUniformValue(uniformName); + if (v) + v->setVec4v(value, size); + else + CCLOG("cocos2d: warning: Uniform not found: %s", uniformName.c_str()); +} + +void GLProgramState::setUniformVec4v(GLint uniformLocation, const Vec4* value, ssize_t size) +{ + auto v = getUniformValue(uniformLocation); + if (v) + v->setVec4v(value, size); + else + CCLOG("cocos2d: warning: Uniform at location not found: %i", uniformLocation); +} + + void GLProgramState::setUniformMat4(const std::string &uniformName, const Mat4& value) { auto v = getUniformValue(uniformName); diff --git a/cocos/renderer/CCGLProgramState.h b/cocos/renderer/CCGLProgramState.h index 42b0a32b79..10514ff23d 100644 --- a/cocos/renderer/CCGLProgramState.h +++ b/cocos/renderer/CCGLProgramState.h @@ -77,9 +77,13 @@ public: */ void setFloat(float value); void setInt(int value); + void setFloatv(const float* pointer, ssize_t size); void setVec2(const Vec2& value); + void setVec2v(const Vec2* pointer, ssize_t size); void setVec3(const Vec3& value); + void setVec3v(const Vec3* pointer, ssize_t size); void setVec4(const Vec4& value); + void setVec4v(const Vec4* pointer, ssize_t size); void setMat4(const Mat4& value); /** @} @@ -101,12 +105,20 @@ public: void apply(); protected: + + enum class Type { + VALUE, + POINTER, + CALLBACK_FN // CALLBACK is already defined in windows, can't use it. + }; + /**Weak reference to Uniform.*/ Uniform* _uniform; /**Weak reference to GLprogram.*/ GLProgram* _glprogram; - /**Whether or not callback is used.*/ - bool _useCallback; + /** What kind of type is the Uniform */ + Type _type; + /** @name Uniform Value Uniform @{ @@ -122,6 +134,22 @@ protected: GLuint textureId; GLuint textureUnit; } tex; + struct { + const float* pointer; + GLsizei size; + } floatv; + struct { + const float* pointer; + GLsizei size; + } v2f; + struct { + const float* pointer; + GLsizei size; + } v3f; + struct { + const float* pointer; + GLsizei size; + } v4f; std::function *callback; U() { memset( this, 0, sizeof(*this) ); } @@ -205,7 +233,7 @@ protected: A GLProgram can be used by thousands of Nodes, but if different uniform values are going to be used, then each node will need its own GLProgramState */ -class CC_DLL GLProgramState : public Ref +class CC_DLL GLProgramState : public Ref, public Clonable { friend class GLProgramStateCache; public: @@ -219,6 +247,12 @@ public: /** gets-or-creates an instance of GLProgramState for a given GLProgramName */ static GLProgramState* getOrCreateWithGLProgramName(const std::string &glProgramName ); + /** gets-or-creates an instance of GLProgramState for given shaders */ + static GLProgramState* getOrCreateWithShaders(const std::string& vertexShader, const std::string& fragShader, const std::string& compileTimeDefines); + + /** Returns a new copy of the GLProgramState. The GLProgram is reused */ + GLProgramState* clone() const; + /** Apply GLProgram, attributes and uniforms. @param modelView The applied modelView matrix to shader. @@ -248,9 +282,9 @@ public: /**@}*/ /** Get the flag of vertex attribs used by OR operation.*/ - uint32_t getVertexAttribsFlags() const { return _vertexAttribsFlags; } + uint32_t getVertexAttribsFlags() const; /**Get the number of vertex attributes.*/ - ssize_t getVertexAttribCount() const { return _attributes.size(); } + ssize_t getVertexAttribCount() const; /**@{ Set the vertex attribute value. */ @@ -266,9 +300,13 @@ public: */ void setUniformInt(const std::string &uniformName, int value); void setUniformFloat(const std::string &uniformName, float value); + void setUniformFloatv(const std::string &uniformName, const float* pointer, ssize_t size); void setUniformVec2(const std::string &uniformName, const Vec2& value); + void setUniformVec2v(const std::string &uniformName, const Vec2* pointer, ssize_t size); void setUniformVec3(const std::string &uniformName, const Vec3& value); + void setUniformVec3v(const std::string &uniformName, const Vec3* pointer, ssize_t size); void setUniformVec4(const std::string &uniformName, const Vec4& value); + void setUniformVec4v(const std::string &uniformName, const Vec4* pointer, ssize_t size); void setUniformMat4(const std::string &uniformName, const Mat4& value); void setUniformCallback(const std::string &uniformName, const std::function &callback); void setUniformTexture(const std::string &uniformName, Texture2D *texture); @@ -280,9 +318,13 @@ public: */ void setUniformInt(GLint uniformLocation, int value); void setUniformFloat(GLint uniformLocation, float value); + void setUniformFloatv(GLint uniformLocation, const float* pointer, ssize_t size); void setUniformVec2(GLint uniformLocation, const Vec2& value); + void setUniformVec2v(GLint uniformLocation, const Vec2* pointer, ssize_t size); void setUniformVec3(GLint uniformLocation, const Vec3& value); + void setUniformVec3v(GLint uniformLocation, const Vec3* pointer, ssize_t size); void setUniformVec4(GLint uniformLocation, const Vec4& value); + void setUniformVec4v(GLint uniformLocation, const Vec4* pointer, ssize_t size); void setUniformMat4(GLint uniformLocation, const Mat4& value); void setUniformCallback(GLint uniformLocation, const std::function &callback); void setUniformTexture(GLint uniformLocation, Texture2D *texture); @@ -309,7 +351,7 @@ protected: uint32_t _vertexAttribsFlags; GLProgram *_glprogram; -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) EventListenerCustom* _backToForegroundlistener; #endif }; diff --git a/cocos/renderer/CCMaterial.cpp b/cocos/renderer/CCMaterial.cpp new file mode 100644 index 0000000000..57bb9f8ed8 --- /dev/null +++ b/cocos/renderer/CCMaterial.cpp @@ -0,0 +1,513 @@ +/**************************************************************************** + Copyright (c) 2015 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 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. + + Ideas taken from: + - GamePlay3D: http://gameplay3d.org/ + - OGRE3D: http://www.ogre3d.org/ + - Qt3D: http://qt-project.org/ + ****************************************************************************/ + +#include "renderer/CCMaterial.h" +#include "renderer/CCTechnique.h" +#include "renderer/CCPass.h" +#include "renderer/CCTextureCache.h" +#include "renderer/CCTexture2D.h" +#include "renderer/CCGLProgram.h" +#include "renderer/CCGLProgramState.h" + +#include "base/CCDirector.h" +#include "platform/CCFileUtils.h" + +#include "json/document.h" + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#define strcasecmp _stricmp +#endif + +static const float MATERIAL_FORMAT_VERSION = 1.0; +static const char* MATERIAL_TYPE = "material"; + +// Helpers declaration +static const char* getOptionalString(const rapidjson::GenericValue >& json, const char* key, const char* defaultValue); +static bool isValidUniform(const char* name); + +NS_CC_BEGIN + +Material* Material::createWithFilename(const std::string& filepath) +{ + auto validfilename = FileUtils::getInstance()->fullPathForFilename(filepath); + if (validfilename.size() > 0) { + auto mat = new (std::nothrow) Material(); + if (mat && mat->initWithFile(validfilename)) + { + mat->autorelease(); + return mat; + } + } + + return nullptr; +} + +Material* Material::createWithGLStateProgram(GLProgramState* programState) +{ + CCASSERT(programState, "Invalid GL Program State"); + + auto mat = new (std::nothrow) Material(); + if (mat && mat->initWithGLProgramState(programState)) + { + mat->autorelease(); + return mat; + + } + return nullptr; +} + +bool Material::initWithGLProgramState(cocos2d::GLProgramState *state) +{ + auto technique = Technique::createWithGLProgramState(this, state); + if (technique) { + _techniques.pushBack(technique); + + // weak pointer + _currentTechnique = technique; + + return true; + } + return false; +} + +bool Material::initWithFile(const std::string& validfilename) +{ + Data data = FileUtils::getInstance()->getDataFromFile(validfilename); + char* bytes = (char*)data.getBytes(); + bytes[data.getSize()-1]='\0'; + + rapidjson::Document document; + document.ParseInsitu<0>(bytes); + + if (document.HasParseError()) + { + CCLOG("GetParseError %s\n", document.GetParseError()); + return false; + } + + CCASSERT(document.IsObject(), "Invalid JSON file"); + + if (! parseMetadata(document)) { + CCLOG("Error parsing Material metadata"); + return false; + } + + parseProperties(document); + return true; +} + +void Material::setTarget(cocos2d::Node *target) +{ + _target = target; +} + +bool Material::parseMetadata(const rapidjson::Document& jsonDocument) +{ + bool broken = false; + + const auto& metadata = jsonDocument["metadata"]; + if (metadata.IsObject()) + { + auto version = metadata["version"].GetDouble(); + broken |= std::floor(version) != std::floor(MATERIAL_FORMAT_VERSION); + + auto type = metadata["type"].GetString(); + broken |= strcmp(type, MATERIAL_TYPE) != 0; + } + + return !broken; +} + +bool Material::parseProperties(const rapidjson::Document& jsonDocument) +{ + auto name = jsonDocument["name"].GetString(); + setName(name); + + auto& techniquesJSON = jsonDocument["techniques"]; + CCASSERT(techniquesJSON.IsArray(), "Invalid Techniques"); + + for (rapidjson::SizeType i = 0; i < techniquesJSON.Size(); i++) { + auto& techniqueJSON = techniquesJSON[i]; + parseTechnique(techniqueJSON); + } + + return true; +} + +bool Material::parseTechnique(const rapidjson::GenericValue >& techniqueJSON) +{ + CCASSERT(techniqueJSON.IsObject(), "Invalid type for Technique. It must be an object"); + + auto technique = Technique::create(this); + _techniques.pushBack(technique); + + // first one is the default one + if (!_currentTechnique) + _currentTechnique = technique; + + // name + if (techniqueJSON.HasMember("name")) + technique->setName(techniqueJSON["name"].GetString()); + + // passes + auto& passesJSON = techniqueJSON["passes"]; + CCASSERT(passesJSON.IsArray(), "Invalid type for 'passes'"); + + for (rapidjson::SizeType i = 0; i < passesJSON.Size(); i++) { + auto& passJSON = passesJSON[i]; + parsePass(technique, passJSON); + } + + return true; +} + +bool Material::parsePass(Technique* technique, const rapidjson::GenericValue >& passJSON) +{ + auto pass = Pass::create(technique); + technique->addPass(pass); + + // Textures + if (passJSON.HasMember("textures")) { + auto& texturesJSON = passJSON["textures"]; + CCASSERT(texturesJSON.IsArray(), "Invalid type for 'textures'"); + + for (rapidjson::SizeType i = 0; i < texturesJSON.Size(); i++) { + auto& textureJSON = texturesJSON[i]; + parseTexture(pass, textureJSON); + } + } + + // Render State + if (passJSON.HasMember("renderState")) { + parseRenderState(pass, passJSON["renderState"]); + } + + // Shaders + if (passJSON.HasMember("shader")) { + parseShader(pass, passJSON["shader"]); + } + + return true; +} + +bool Material::parseTexture(Pass* pass, const rapidjson::GenericValue >& textureJSON) +{ + CCASSERT(textureJSON.IsObject(), "Invalid type for Texture. It must be an object"); + + // required + auto filename = textureJSON["path"].GetString(); + + auto texture = Director::getInstance()->getTextureCache()->addImage(filename); + if (!texture) { + CCLOG("Invalid filepath"); + return false; + } + + // optionals + + { + Texture2D::TexParams texParams; + + // mipmap + bool usemipmap = false; + const char* mipmap = getOptionalString(textureJSON, "mipmap", "false"); + if (mipmap && strcasecmp(mipmap, "true")==0) { + texture->generateMipmap(); + usemipmap = true; + } + + // valid options: REPEAT, CLAMP + const char* wrapS = getOptionalString(textureJSON, "wrapS", "CLAMP_TO_EDGE"); + if (strcasecmp(wrapS, "REPEAT")==0) + texParams.wrapS = GL_REPEAT; + else if(strcasecmp(wrapS, "CLAMP_TO_EDGE")==0) + texParams.wrapS = GL_CLAMP_TO_EDGE; + else + CCLOG("Invalid wrapS: %s", wrapS); + + + // valid options: REPEAT, CLAMP + const char* wrapT = getOptionalString(textureJSON, "wrapT", "CLAMP_TO_EDGE"); + if (strcasecmp(wrapT, "REPEAT")==0) + texParams.wrapT = GL_REPEAT; + else if(strcasecmp(wrapT, "CLAMP_TO_EDGE")==0) + texParams.wrapT = GL_CLAMP_TO_EDGE; + else + CCLOG("Invalid wrapT: %s", wrapT); + + + // valid options: NEAREST, LINEAR, NEAREST_MIPMAP_NEAREST, LINEAR_MIPMAP_NEAREST, NEAREST_MIPMAP_LINEAR, LINEAR_MIPMAP_LINEAR + const char* minFilter = getOptionalString(textureJSON, "minFilter", mipmap ? "LINEAR_MIPMAP_NEAREST" : "LINEAR"); + if (strcasecmp(minFilter, "NEAREST")==0) + texParams.minFilter = GL_NEAREST; + else if(strcasecmp(minFilter, "LINEAR")==0) + texParams.minFilter = GL_LINEAR; + else if(strcasecmp(minFilter, "NEAREST_MIPMAP_NEAREST")==0) + texParams.minFilter = GL_NEAREST_MIPMAP_NEAREST; + else if(strcasecmp(minFilter, "LINEAR_MIPMAP_NEAREST")==0) + texParams.minFilter = GL_LINEAR_MIPMAP_NEAREST; + else if(strcasecmp(minFilter, "NEAREST_MIPMAP_LINEAR")==0) + texParams.minFilter = GL_NEAREST_MIPMAP_LINEAR; + else if(strcasecmp(minFilter, "LINEAR_MIPMAP_LINEAR")==0) + texParams.minFilter = GL_LINEAR_MIPMAP_LINEAR; + else + CCLOG("Invalid minFilter: %s", minFilter); + + // valid options: NEAREST, LINEAR + const char* magFilter = getOptionalString(textureJSON, "magFilter", "LINEAR"); + if (strcasecmp(magFilter, "NEAREST")==0) + texParams.magFilter = GL_NEAREST; + else if(strcasecmp(magFilter, "LINEAR")==0) + texParams.magFilter = GL_LINEAR; + else + CCLOG("Invalid magFilter: %s", magFilter); + + texture->setTexParameters(texParams); + } + + pass->_textures.pushBack(texture); + return true; +} + +bool Material::parseShader(Pass* pass, const rapidjson::GenericValue >& shaderJSON) +{ + + CCASSERT(shaderJSON.IsObject(), "Invalid type for 'shader'. It must be an object"); + + // vertexShader + const char* vertShader = getOptionalString(shaderJSON, "vertexShader", nullptr); + + // fragmentShader + const char* fragShader = getOptionalString(shaderJSON, "fragmentShader", nullptr); + + // compileTimeDefines + const char* compileTimeDefines = getOptionalString(shaderJSON, "defines", ""); + + if (vertShader && fragShader) + { + auto glProgramState = GLProgramState::getOrCreateWithShaders(vertShader, fragShader, compileTimeDefines); + pass->setGLProgramState(glProgramState); + + // Parse uniforms only if the GLProgramState was created + for( auto it = shaderJSON.MemberonBegin(); it != shaderJSON.MemberonEnd(); it++) + { + // skip "defines", "vertexShader", "fragmentShader" + if (isValidUniform(it->name.GetString())) + parseUniform(glProgramState, it); + } + +// glProgramState->updateUniformsAndAttributes(); + } + + return true; +} + +bool Material::parseUniform(GLProgramState* programState, const rapidjson::Value::ConstMemberIterator& iterator) +{ + const char* key = iterator->name.GetString(); + auto& value = iterator->value; + + if (value.IsNumber()) { + float v = value.GetDouble(); + programState->setUniformFloat(key, v); + } + else if (value.IsArray()) { + + int size = value.Size(); + switch (size) { + case 1: + { + rapidjson::SizeType idx = 0; + float v = value[idx].GetDouble(); + programState->setUniformFloat(key, v); + break; + } + case 2: + { + Vec2 vect = parseUniformVec2(value); + programState->setUniformVec2(key, vect); + break; + } + case 3: + { + Vec3 vect = parseUniformVec3(value); + programState->setUniformVec3(key, vect); + break; + } + case 4: + { + Vec4 vect = parseUniformVec4(value); + programState->setUniformVec4(key, vect); + break; + } + case 16: + { + Mat4 mat = parseUniformMat4(value); + programState->setUniformMat4(key, mat); + break; + } + default: + break; + } + + } + return true; +} + +Vec2 Material::parseUniformVec2(const rapidjson::GenericValue >& value) +{ + Vec2 ret; + rapidjson::SizeType idx = 0; + ret.x = value[idx++].GetDouble(); + ret.y = value[idx++].GetDouble(); + return ret; +} + +Vec3 Material::parseUniformVec3(const rapidjson::GenericValue >& value) +{ + Vec3 ret; + rapidjson::SizeType idx = 0; + ret.x = value[idx++].GetDouble(); + ret.y = value[idx++].GetDouble(); + ret.z = value[idx++].GetDouble(); + return ret; +} + +Vec4 Material::parseUniformVec4(const rapidjson::GenericValue >& value) +{ + Vec4 ret; + rapidjson::SizeType idx = 0; + ret.x = value[idx++].GetDouble(); + ret.y = value[idx++].GetDouble(); + ret.z = value[idx++].GetDouble(); + ret.w = value[idx++].GetDouble(); + return ret; +} + +Mat4 Material::parseUniformMat4(const rapidjson::GenericValue >& value) +{ + Mat4 ret; + + for(rapidjson::SizeType i= 0; i<16; i++) + ret.m[i] = value[i].GetDouble(); + + return ret; +} + +bool Material::parseRenderState(Pass* pass, const rapidjson::GenericValue >& renderState) +{ + auto state = pass->getStateBlock(); + + // Parse uniforms only if the GLProgramState was created + for( auto it = renderState.MemberonBegin(); it != renderState.MemberonEnd(); it++) + { + // Render state only can have "strings" or numbers as values. No objects or lists + state->setState(it->name.GetString(), it->value.GetString()); + } + + return true; +} + +void Material::setName(const std::string&name) +{ + _name = name; +} + +std::string Material::getName() const +{ + return _name; +} + +Material::Material() +: _name("") +, _target(nullptr) +, _currentTechnique(nullptr) +{ +} + +Material::~Material() +{ +} + +Technique* Material::getTechnique() const +{ + return _currentTechnique; +} +Technique* Material::getTechniqueByName(const std::string& name) +{ + for(const auto& technique : _techniques) { + CCLOG("technique name: %s", technique->getName().c_str()); + if (technique->getName().compare(name)==0) + return technique; + } + return nullptr; +} + +Technique* Material::getTechniqueByIndex(ssize_t index) +{ + CC_ASSERT(index>=0 && index<_techniques.size() && "Invalid size"); + + return _techniques.at(index); +} + +void Material::addTechnique(Technique* technique) +{ + _techniques.pushBack(technique); +} + +void Material::setTechnique(const std::string& techniqueName) +{ + auto technique = getTechniqueByName(techniqueName); + if (technique) + _currentTechnique = technique; +} + +ssize_t Material::getTechniqueCount() const +{ + return _techniques.size(); +} + +NS_CC_END + +// Helpers implementation +static bool isValidUniform(const char* name) +{ + return !(strcmp(name, "defines")==0 || + strcmp(name, "vertexShader")==0 || + strcmp(name, "fragmentShader")==0); +} + +static const char* getOptionalString(const rapidjson::GenericValue >& json, const char* key, const char* defaultValue) +{ + if (json.HasMember(key)) { + return json[key].GetString(); + } + return defaultValue; +} + diff --git a/cocos/renderer/CCMaterial.h b/cocos/renderer/CCMaterial.h new file mode 100644 index 0000000000..c029878908 --- /dev/null +++ b/cocos/renderer/CCMaterial.h @@ -0,0 +1,140 @@ +/**************************************************************************** + Copyright (c) 2015 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 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. + + Ideas taken from: + - GamePlay3D: http://gameplay3d.org/ + - OGRE3D: http://www.ogre3d.org/ + - Qt3D: http://qt-project.org/ + ****************************************************************************/ + +#ifndef __cocos2d_libs__CCMaterial__ +#define __cocos2d_libs__CCMaterial__ + +#include +#include "json/document.h" + +#include "renderer/CCRenderState.h" +#include "renderer/CCTechnique.h" +#include "base/CCRef.h" +#include "base/CCVector.h" +#include "math/Vec2.h" +#include "math/Vec3.h" +#include "math/Vec4.h" +#include "math/Mat4.h" +#include "platform/CCPlatformMacros.h" + + +NS_CC_BEGIN + +class Technique; +class Pass; +class GLProgramState; +class Node; + +/// Material +class CC_DLL Material : public RenderState +{ + friend class Node; + friend class Technique; + friend class Pass; + friend class MeshCommand; + friend class Renderer; + friend class Mesh; + +public: + /** Creates a Material with a JSON file containing the definition of the material. + */ + static Material* createWithFilename(const std::string& path); + + /** Creates a Material with a GLProgramState. + It will only contain one Technique and one Pass. + Added in order to support legacy code. + */ + static Material* createWithGLStateProgram(GLProgramState* programState); + + /// returns the material name + std::string getName() const; + /// sets the material name + void setName(const std::string& name); + + /** Returns a Technique by its name. + returns `nullptr` if the Technique can't be found. + */ + Technique* getTechniqueByName(const std::string& name); + + /** Returns a Technique by index. + returns `nullptr` if the index is invalid. + */ + Technique* getTechniqueByIndex(ssize_t index); + + /** Adds a Technique into the Material */ + void addTechnique(Technique* technique); + + /** Sets the current technique */ + void setTechnique(const std::string& techniqueName); + + /** Returns the number of Techniques in the Material. */ + ssize_t getTechniqueCount() const; + + /** Returns the Technique used by the Material */ + Technique* getTechnique() const; + +protected: + Material(); + ~Material(); + bool initWithGLProgramState(GLProgramState* state); + bool initWithFile(const std::string& file); + + void setTarget(Node* target); + + bool parseMetadata(const rapidjson::Document& json); + bool parseProperties(const rapidjson::Document& json); + bool parseTechnique(const rapidjson::GenericValue >& techniqueJSON); + bool parsePass(Technique* technique, const rapidjson::GenericValue >& passJSON); + bool parseTexture(Pass* pass, const rapidjson::GenericValue >& textureJSON); + bool parseShader(Pass* pass, const rapidjson::GenericValue >& shaderJSON); + bool parseUniform(GLProgramState* programState, const rapidjson::Value::ConstMemberIterator& iterator); + Vec2 parseUniformVec2(const rapidjson::GenericValue >& uniformJSON); + Vec3 parseUniformVec3(const rapidjson::GenericValue >& uniformJSON); + Vec4 parseUniformVec4(const rapidjson::GenericValue >& uniformJSON); + Mat4 parseUniformMat4(const rapidjson::GenericValue >& uniformJSON); + bool parseRenderState(Pass* pass, const rapidjson::GenericValue >& renderState); + + + // material name + std::string _name; + + // array of techniques + Vector _techniques; + + // weak pointer since it is being help by _techniques + Technique* _currentTechnique; + + // weak reference + Node* _target; +}; + +NS_CC_END + + +#endif /* defined(__cocos2d_libs__CCMaterial__) */ diff --git a/cocos/renderer/CCMeshCommand.cpp b/cocos/renderer/CCMeshCommand.cpp index 3905c2233a..d239798300 100644 --- a/cocos/renderer/CCMeshCommand.cpp +++ b/cocos/renderer/CCMeshCommand.cpp @@ -38,37 +38,13 @@ #include "renderer/CCTextureAtlas.h" #include "renderer/CCTexture2D.h" #include "renderer/ccGLStateCache.h" +#include "renderer/CCTechnique.h" +#include "renderer/CCMaterial.h" +#include "renderer/CCPass.h" #include "xxhash.h" NS_CC_BEGIN -static const char *s_dirLightUniformColorName = "u_DirLightSourceColor"; -static std::vector s_dirLightUniformColorValues; -static const char *s_dirLightUniformDirName = "u_DirLightSourceDirection"; -static std::vector s_dirLightUniformDirValues; - -static const char *s_pointLightUniformColorName = "u_PointLightSourceColor"; -static std::vector s_pointLightUniformColorValues; -static const char *s_pointLightUniformPositionName = "u_PointLightSourcePosition"; -static std::vector s_pointLightUniformPositionValues; -static const char *s_pointLightUniformRangeInverseName = "u_PointLightSourceRangeInverse"; -static std::vector s_pointLightUniformRangeInverseValues; - -static const char *s_spotLightUniformColorName = "u_SpotLightSourceColor"; -static std::vector s_spotLightUniformColorValues; -static const char *s_spotLightUniformPositionName = "u_SpotLightSourcePosition"; -static std::vector s_spotLightUniformPositionValues; -static const char *s_spotLightUniformDirName = "u_SpotLightSourceDirection"; -static std::vector s_spotLightUniformDirValues; -static const char *s_spotLightUniformInnerAngleCosName = "u_SpotLightSourceInnerAngleCos"; -static std::vector s_spotLightUniformInnerAngleCosValues; -static const char *s_spotLightUniformOuterAngleCosName = "u_SpotLightSourceOuterAngleCos"; -static std::vector s_spotLightUniformOuterAngleCosValues; -static const char *s_spotLightUniformRangeInverseName = "u_SpotLightSourceRangeInverse"; -static std::vector s_spotLightUniformRangeInverseValues; - -static const char *s_ambientLightUniformColorName = "u_AmbientLightSourceColor"; - MeshCommand::MeshCommand() : _textureID(0) @@ -87,16 +63,57 @@ MeshCommand::MeshCommand() , _renderStateCullFaceEnabled(false) , _renderStateDepthTest(false) , _renderStateDepthWrite(GL_FALSE) -, _lightMask(-1) +, _material(nullptr) { _type = RenderCommand::Type::MESH_COMMAND; -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) // listen the event that renderer was recreated on Android/WP8 _rendererRecreatedListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, CC_CALLBACK_1(MeshCommand::listenRendererRecreated, this)); Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_rendererRecreatedListener, -1); #endif } +void MeshCommand::init(float globalZOrder, + Material* material, + GLuint vertexBuffer, + GLuint indexBuffer, + GLenum primitive, + GLenum indexFormat, + ssize_t indexCount, + const cocos2d::Mat4 &mv, + uint32_t flags) +{ + CCASSERT(material, "material cannot be nill"); + + RenderCommand::init(globalZOrder, mv, flags); + + _globalOrder = globalZOrder; + _material = material; + + _vertexBuffer = vertexBuffer; + _indexBuffer = indexBuffer; + _primitive = primitive; + _indexFormat = indexFormat; + _indexCount = indexCount; + _mv.set(mv); + + _is3D = true; +} + +void MeshCommand::init(float globalOrder, + GLuint textureID, + GLProgramState* glProgramState, + BlendFunc blendType, + GLuint vertexBuffer, + GLuint indexBuffer, + GLenum primitive, + GLenum indexFormat, + ssize_t indexCount, + const Mat4 &mv) +{ + init(globalOrder, textureID, glProgramState, blendType, vertexBuffer, indexBuffer, primitive, indexFormat, indexCount, mv, 0); +} + void MeshCommand::init(float globalZOrder, GLuint textureID, cocos2d::GLProgramState *glProgramState, @@ -128,48 +145,60 @@ void MeshCommand::init(float globalZOrder, _is3D = true; } -void MeshCommand::init(float globalOrder, - GLuint textureID, - GLProgramState* glProgramState, - BlendFunc blendType, - GLuint vertexBuffer, - GLuint indexBuffer, - GLenum primitive, - GLenum indexFormat, - ssize_t indexCount, - const Mat4 &mv) -{ - init(globalOrder, textureID, glProgramState, blendType, vertexBuffer, indexBuffer, primitive, indexFormat, indexCount, mv, 0); -} - void MeshCommand::setCullFaceEnabled(bool enable) { + CCASSERT(!_material, "If using material, you should call material->setCullFace()"); + _cullFaceEnabled = enable; } void MeshCommand::setCullFace(GLenum cullFace) { + CCASSERT(!_material, "If using material, you should call material->setCullFaceSide()"); + _cullFace = cullFace; } void MeshCommand::setDepthTestEnabled(bool enable) { + CCASSERT(!_material, "If using material, you should call material->setDepthTest()"); + _depthTestEnabled = enable; } void MeshCommand::setDepthWriteEnabled(bool enable) { + CCASSERT(!_material, "If using material, you should call material->setDepthWrite()"); + _forceDepthWrite = enable; _depthWriteEnabled = enable; } void MeshCommand::setDisplayColor(const Vec4& color) { + CCASSERT(!_material, "If using material, you should set the color as a uniform: use u_color"); + _displayColor = color; } +void MeshCommand::setMatrixPalette(const Vec4* matrixPalette) +{ + CCASSERT(!_material, "If using material, you should set the color as a uniform: use u_matrixPalette"); + + _matrixPalette = matrixPalette; +} + +void MeshCommand::setMatrixPaletteSize(int size) +{ + CCASSERT(!_material, "If using material, you should set the color as a uniform: use u_matrixPalette with its size"); + + _matrixPaletteSize = size; +} + void MeshCommand::setTransparent(bool value) { + CCASSERT(!_material, "If using material, you shouldn't call setTransparent."); + _isTransparent = value; //Skip batching for transparent mesh _skipBatching = value; @@ -187,16 +216,21 @@ void MeshCommand::setTransparent(bool value) MeshCommand::~MeshCommand() { releaseVAO(); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) Director::getInstance()->getEventDispatcher()->removeEventListener(_rendererRecreatedListener); #endif } void MeshCommand::applyRenderState() { + CCASSERT(!_material, "Must not be called when using materials"); + + // blend and texture + GL::bindTexture2D(_textureID); + GL::blendFunc(_blendType.src, _blendType.dst); + + // cull face _renderStateCullFaceEnabled = glIsEnabled(GL_CULL_FACE) != GL_FALSE; - _renderStateDepthTest = glIsEnabled(GL_DEPTH_TEST) != GL_FALSE; - glGetBooleanv(GL_DEPTH_WRITEMASK, &_renderStateDepthWrite); GLint cullface; glGetIntegerv(GL_CULL_FACE_MODE, &cullface); _renderStateCullFace = (GLenum)cullface; @@ -210,12 +244,16 @@ void MeshCommand::applyRenderState() { glCullFace(_cullFace); } - + + // depth + _renderStateDepthTest = (glIsEnabled(GL_DEPTH_TEST) != GL_FALSE); + glGetBooleanv(GL_DEPTH_WRITEMASK, &_renderStateDepthWrite); + if (_depthTestEnabled != _renderStateDepthTest) { _depthTestEnabled ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST); } - + if (_depthWriteEnabled != _renderStateDepthWrite) { glDepthMask(_depthWriteEnabled); @@ -224,28 +262,32 @@ void MeshCommand::applyRenderState() void MeshCommand::restoreRenderState() { + CCASSERT(!_material, "Must not be called when using Material"); + + // cull if (_cullFaceEnabled != _renderStateCullFaceEnabled) { _renderStateCullFaceEnabled ? glEnable(GL_CULL_FACE) : glDisable(GL_CULL_FACE); } - + if (_cullFace != _renderStateCullFace) { glCullFace(_renderStateCullFace); } - + + // depth if (_depthTestEnabled != _renderStateDepthTest) { _renderStateDepthTest ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST); } - + if (_depthWriteEnabled != _renderStateDepthWrite) { glDepthMask(_renderStateDepthWrite); } } -void MeshCommand::genMaterialID(GLuint texID, void* glProgramState, GLuint vertexBuffer, GLuint indexBuffer, const BlendFunc& blend) +void MeshCommand::genMaterialID(GLuint texID, void* glProgramState, GLuint vertexBuffer, GLuint indexBuffer, BlendFunc blend) { int intArray[7] = {0}; intArray[0] = (int)texID; @@ -257,17 +299,13 @@ void MeshCommand::genMaterialID(GLuint texID, void* glProgramState, GLuint verte _materialID = XXH32((const void*)intArray, sizeof(intArray), 0); } -void MeshCommand::MatrixPalleteCallBack( GLProgram* glProgram, Uniform* uniform) +uint32_t MeshCommand::getMaterialID() const { - glUniform4fv( uniform->location, (GLsizei)_matrixPaletteSize, (const float*)_matrixPalette ); + return _materialID; } void MeshCommand::preBatchDraw() { - // Set material - GL::bindTexture2D(_textureID); - GL::blendFunc(_blendType.src, _blendType.dst); - if (Configuration::getInstance()->supportsShareableVAO() && _vao == 0) buildVAO(); if (_vao) @@ -277,39 +315,49 @@ void MeshCommand::preBatchDraw() else { glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer); - _glProgramState->applyAttributes(); + + // FIXME: Assumes that all the passes in the Material share the same Vertex Attribs + GLProgramState* programState = _material + ? _material->_currentTechnique->_passes.at(0)->getGLProgramState() + : _glProgramState; + programState->applyAttributes(); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer); } } + void MeshCommand::batchDraw() { - // set render state - applyRenderState(); - - _glProgramState->setUniformVec4("u_color", _displayColor); - - if (_matrixPaletteSize && _matrixPalette) + if (_material) { - _glProgramState->setUniformCallback("u_matrixPalette", CC_CALLBACK_2(MeshCommand::MatrixPalleteCallBack, this)); - - } - - _glProgramState->applyGLProgram(_mv); - _glProgramState->applyUniforms(); + for(const auto& pass: _material->_currentTechnique->_passes) + { + // don't bind attributes, since they were + // already bound in preBatchDraw + pass->bind(_mv, false); - const auto& scene = Director::getInstance()->getRunningScene(); - if (scene && scene->getLights().size() > 0) - setLightUniforms(); - - // Draw - glDrawElements(_primitive, (GLsizei)_indexCount, _indexFormat, 0); - - CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _indexCount); + glDrawElements(_primitive, (GLsizei)_indexCount, _indexFormat, 0); + CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _indexCount); + + pass->unbind(); + } + } + else + { + _glProgramState->applyGLProgram(_mv); + + // set render state + applyRenderState(); + + // Draw + glDrawElements(_primitive, (GLsizei)_indexCount, _indexFormat, 0); + CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _indexCount); + + //restore render state + restoreRenderState(); + } } void MeshCommand::postBatchDraw() { - //restore render state - restoreRenderState(); if (_vao) { GL::bindVAO(0); @@ -323,54 +371,63 @@ void MeshCommand::postBatchDraw() void MeshCommand::execute() { - // set render state - applyRenderState(); - // Set material - GL::bindTexture2D(_textureID); - GL::blendFunc(_blendType.src, _blendType.dst); - + // Draw without VAO glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer); - _glProgramState->setUniformVec4("u_color", _displayColor); - - if (_matrixPaletteSize && _matrixPalette) - { - _glProgramState->setUniformCallback("u_matrixPalette", CC_CALLBACK_2(MeshCommand::MatrixPalleteCallBack, this)); - - } - - _glProgramState->apply(_mv); - - const auto& scene = Director::getInstance()->getRunningScene(); - if (scene && scene->getLights().size() > 0) - setLightUniforms(); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer); - - // Draw - glDrawElements(_primitive, (GLsizei)_indexCount, _indexFormat, 0); - - CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _indexCount); - - //restore render state - restoreRenderState(); + + if (_material) + { + for(const auto& pass: _material->_currentTechnique->_passes) + { + // don't bind attributes, since they were + // already bound in preBatchDraw + pass->bind(_mv, true); + + glDrawElements(_primitive, (GLsizei)_indexCount, _indexFormat, 0); + CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _indexCount); + + pass->unbind(); + } + } + else + { + // set render state + _glProgramState->apply(_mv); + + applyRenderState(); + + // Draw + glDrawElements(_primitive, (GLsizei)_indexCount, _indexFormat, 0); + + CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _indexCount); + + //restore render state + restoreRenderState(); + } + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); } void MeshCommand::buildVAO() { + // FIXME: Assumes that all the passes in the Material share the same Vertex Attribs + GLProgramState* programState = (_material != nullptr) + ? _material->_currentTechnique->_passes.at(0)->getGLProgramState() + : _glProgramState; + releaseVAO(); glGenVertexArrays(1, &_vao); GL::bindVAO(_vao); glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer); - auto flags = _glProgramState->getVertexAttribsFlags(); + auto flags = programState->getVertexAttribsFlags(); for (int i = 0; flags > 0; i++) { int flag = 1 << i; if (flag & flags) glEnableVertexAttribArray(i); flags &= ~flag; } - _glProgramState->applyAttributes(false); + programState->applyAttributes(false); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer); @@ -388,169 +445,7 @@ void MeshCommand::releaseVAO() } } - -void MeshCommand::setLightUniforms() -{ - Director *director = Director::getInstance(); - auto scene = director->getRunningScene(); - const auto& conf = Configuration::getInstance(); - int maxDirLight = conf->getMaxSupportDirLightInShader(); - int maxPointLight = conf->getMaxSupportPointLightInShader(); - int maxSpotLight = conf->getMaxSupportSpotLightInShader(); - auto &lights = scene->getLights(); - auto glProgram = _glProgramState->getGLProgram(); - if (_glProgramState->getVertexAttribsFlags() & (1 << GLProgram::VERTEX_ATTRIB_NORMAL)) - { - resetLightUniformValues(); - - GLint enabledDirLightNum = 0; - GLint enabledPointLightNum = 0; - GLint enabledSpotLightNum = 0; - Vec3 ambientColor; - for (const auto& light : lights) - { - bool useLight = light->isEnabled() && ((unsigned int)light->getLightFlag() & _lightMask); - if (useLight) - { - float intensity = light->getIntensity(); - switch (light->getLightType()) - { - case LightType::DIRECTIONAL: - { - if(enabledDirLightNum < maxDirLight) - { - auto dirLight = static_cast(light); - Vec3 dir = dirLight->getDirectionInWorld(); - dir.normalize(); - const Color3B &col = dirLight->getDisplayedColor(); - s_dirLightUniformColorValues[enabledDirLightNum].set(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity); - s_dirLightUniformDirValues[enabledDirLightNum] = dir; - ++enabledDirLightNum; - } - - } - break; - case LightType::POINT: - { - if(enabledPointLightNum < maxPointLight) - { - auto pointLight = static_cast(light); - Mat4 mat= pointLight->getNodeToWorldTransform(); - const Color3B &col = pointLight->getDisplayedColor(); - s_pointLightUniformColorValues[enabledPointLightNum].set(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity); - s_pointLightUniformPositionValues[enabledPointLightNum].set(mat.m[12], mat.m[13], mat.m[14]); - s_pointLightUniformRangeInverseValues[enabledPointLightNum] = 1.0f / pointLight->getRange(); - ++enabledPointLightNum; - } - } - break; - case LightType::SPOT: - { - if(enabledSpotLightNum < maxSpotLight) - { - auto spotLight = static_cast(light); - Vec3 dir = spotLight->getDirectionInWorld(); - dir.normalize(); - Mat4 mat= light->getNodeToWorldTransform(); - const Color3B &col = spotLight->getDisplayedColor(); - s_spotLightUniformColorValues[enabledSpotLightNum].set(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity); - s_spotLightUniformPositionValues[enabledSpotLightNum].set(mat.m[12], mat.m[13], mat.m[14]); - s_spotLightUniformDirValues[enabledSpotLightNum] = dir; - s_spotLightUniformInnerAngleCosValues[enabledSpotLightNum] = spotLight->getCosInnerAngle(); - s_spotLightUniformOuterAngleCosValues[enabledSpotLightNum] = spotLight->getCosOuterAngle(); - s_spotLightUniformRangeInverseValues[enabledSpotLightNum] = 1.0f / spotLight->getRange(); - ++enabledSpotLightNum; - } - } - break; - case LightType::AMBIENT: - { - auto ambLight = static_cast(light); - const Color3B &col = ambLight->getDisplayedColor(); - ambientColor.add(col.r / 255.0f * intensity, col.g / 255.0f * intensity, col.b / 255.0f * intensity); - } - break; - default: - break; - } - } - } - - if (0 < maxDirLight) - { - glProgram->setUniformLocationWith3fv((GLint)glProgram->getUniformLocationForName(s_dirLightUniformColorName), (GLfloat*)(&s_dirLightUniformColorValues[0]), (unsigned int)s_dirLightUniformColorValues.size()); - glProgram->setUniformLocationWith3fv((GLint)glProgram->getUniformLocationForName(s_dirLightUniformDirName), (GLfloat*)(&s_dirLightUniformDirValues[0]), (unsigned int)s_dirLightUniformDirValues.size()); - } - - if (0 < maxPointLight) - { - glProgram->setUniformLocationWith3fv((GLint)glProgram->getUniformLocationForName(s_pointLightUniformColorName), (GLfloat*)(&s_pointLightUniformColorValues[0]), (unsigned int)s_pointLightUniformColorValues.size()); - glProgram->setUniformLocationWith3fv((GLint)glProgram->getUniformLocationForName(s_pointLightUniformPositionName), (GLfloat*)(&s_pointLightUniformPositionValues[0]), (unsigned int)s_pointLightUniformPositionValues.size()); - glProgram->setUniformLocationWith1fv((GLint)glProgram->getUniformLocationForName(s_pointLightUniformRangeInverseName), (GLfloat*)(&s_pointLightUniformRangeInverseValues[0]), (unsigned int)s_pointLightUniformRangeInverseValues.size()); - } - - if (0 < maxSpotLight) - { - glProgram->setUniformLocationWith3fv((GLint)glProgram->getUniformLocationForName(s_spotLightUniformColorName), (GLfloat*)(&s_spotLightUniformColorValues[0]), (unsigned int)s_spotLightUniformColorValues.size()); - glProgram->setUniformLocationWith3fv((GLint)glProgram->getUniformLocationForName(s_spotLightUniformPositionName), (GLfloat*)(&s_spotLightUniformPositionValues[0]), (unsigned int)s_spotLightUniformPositionValues.size()); - glProgram->setUniformLocationWith3fv((GLint)glProgram->getUniformLocationForName(s_spotLightUniformDirName), (GLfloat*)(&s_spotLightUniformDirValues[0]), (unsigned int)s_spotLightUniformDirValues.size()); - glProgram->setUniformLocationWith1fv((GLint)glProgram->getUniformLocationForName(s_spotLightUniformInnerAngleCosName), (GLfloat*)(&s_spotLightUniformInnerAngleCosValues[0]), (unsigned int)s_spotLightUniformInnerAngleCosValues.size()); - glProgram->setUniformLocationWith1fv((GLint)glProgram->getUniformLocationForName(s_spotLightUniformOuterAngleCosName), (GLfloat*)(&s_spotLightUniformOuterAngleCosValues[0]), (unsigned int)s_spotLightUniformOuterAngleCosValues.size()); - glProgram->setUniformLocationWith1fv((GLint)glProgram->getUniformLocationForName(s_spotLightUniformRangeInverseName), (GLfloat*)(&s_spotLightUniformRangeInverseValues[0]), (unsigned int)s_spotLightUniformRangeInverseValues.size()); - } - - glProgram->setUniformLocationWith3f(glProgram->getUniformLocationForName(s_ambientLightUniformColorName), ambientColor.x, ambientColor.y, ambientColor.z); - } - else // normal does not exist - { - Vec3 ambient(0.0f, 0.0f, 0.0f); - bool hasAmbient = false; - for (const auto& light : lights) - { - if (light->getLightType() == LightType::AMBIENT) - { - bool useLight = light->isEnabled() && ((unsigned int)light->getLightFlag() & _lightMask); - if (useLight) - { - hasAmbient = true; - const Color3B &col = light->getDisplayedColor(); - ambient.x += col.r * light->getIntensity(); - ambient.y += col.g * light->getIntensity(); - ambient.z += col.b * light->getIntensity(); - } - } - } - if (hasAmbient) - { - ambient.x /= 255.f; ambient.y /= 255.f; ambient.z /= 255.f; - } - glProgram->setUniformLocationWith4f(glProgram->getUniformLocationForName("u_color"), _displayColor.x * ambient.x, _displayColor.y * ambient.y, _displayColor.z * ambient.z, _displayColor.w); - } -} - -void MeshCommand::resetLightUniformValues() -{ - const auto& conf = Configuration::getInstance(); - int maxDirLight = conf->getMaxSupportDirLightInShader(); - int maxPointLight = conf->getMaxSupportPointLightInShader(); - int maxSpotLight = conf->getMaxSupportSpotLightInShader(); - - s_dirLightUniformColorValues.assign(maxDirLight, Vec3::ZERO); - s_dirLightUniformDirValues.assign(maxDirLight, Vec3::ZERO); - - s_pointLightUniformColorValues.assign(maxPointLight, Vec3::ZERO); - s_pointLightUniformPositionValues.assign(maxPointLight, Vec3::ZERO); - s_pointLightUniformRangeInverseValues.assign(maxPointLight, 0.0f); - - s_spotLightUniformColorValues.assign(maxSpotLight, Vec3::ZERO); - s_spotLightUniformPositionValues.assign(maxSpotLight, Vec3::ZERO); - s_spotLightUniformDirValues.assign(maxSpotLight, Vec3::ZERO); - s_spotLightUniformInnerAngleCosValues.assign(maxSpotLight, 0.0f); - s_spotLightUniformOuterAngleCosValues.assign(maxSpotLight, 0.0f); - s_spotLightUniformRangeInverseValues.assign(maxSpotLight, 0.0f); -} - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) void MeshCommand::listenRendererRecreated(EventCustom* event) { _vao = 0; diff --git a/cocos/renderer/CCMeshCommand.h b/cocos/renderer/CCMeshCommand.h index 6af1aab033..729adc2abb 100644 --- a/cocos/renderer/CCMeshCommand.h +++ b/cocos/renderer/CCMeshCommand.h @@ -37,6 +37,7 @@ class GLProgram; struct Uniform; class EventListenerCustom; class EventCustom; +class Material; //it is a common mesh class CC_DLL MeshCommand : public RenderCommand @@ -45,7 +46,9 @@ public: MeshCommand(); ~MeshCommand(); - + + void init(float globalZOrder, Material* material, GLuint vertexBuffer, GLuint indexBuffer, GLenum primitive, GLenum indexFormat, ssize_t indexCount, const Mat4 &mv, uint32_t flags); + void init(float globalZOrder, GLuint textureID, GLProgramState* glProgramState, BlendFunc blendType, GLuint vertexBuffer, GLuint indexBuffer, GLenum primitive, GLenum indexFormat, ssize_t indexCount, const Mat4 &mv, uint32_t flags); CC_DEPRECATED_ATTRIBUTE void init(float globalZOrder, GLuint textureID, GLProgramState* glProgramState, BlendFunc blendType, GLuint vertexBuffer, GLuint indexBuffer, GLenum primitive, GLenum indexType, ssize_t indexCount, const Mat4 &mv); @@ -60,11 +63,11 @@ public: void setDisplayColor(const Vec4& color); - void setMatrixPalette(const Vec4* matrixPalette) { _matrixPalette = matrixPalette; } + void setMatrixPalette(const Vec4* matrixPalette); - void setMatrixPaletteSize(int size) { _matrixPaletteSize = size; } + void setMatrixPaletteSize(int size); - void setLightMask(unsigned int lightmask) { _lightMask = lightmask; } + void setLightMask(unsigned int lightmask); void setTransparent(bool value); @@ -75,11 +78,11 @@ public: void batchDraw(); void postBatchDraw(); - void genMaterialID(GLuint texID, void* glProgramState, GLuint vertexBuffer, GLuint indexBuffer, const BlendFunc& blend); + void genMaterialID(GLuint texID, void* glProgramState, GLuint vertexBuffer, GLuint indexBuffer, BlendFunc blend); - uint32_t getMaterialID() const { return _materialID; } + uint32_t getMaterialID() const; -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) void listenRendererRecreated(EventCustom* event); #endif @@ -88,23 +91,13 @@ protected: void buildVAO(); void releaseVAO(); - // apply renderstate + // apply renderstate, not used when using material void applyRenderState(); - - void setLightUniforms(); - - //restore to all false void restoreRenderState(); - - void MatrixPalleteCallBack( GLProgram* glProgram, Uniform* uniform); - - void resetLightUniformValues(); GLuint _textureID; GLProgramState* _glProgramState; BlendFunc _blendType; - - GLuint _textrueID; Vec4 _displayColor; // in order to support tint and fade in fade out @@ -137,9 +130,10 @@ protected: // ModelView transform Mat4 _mv; - unsigned int _lightMask; + // weak ref + Material* _material; -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) EventListenerCustom* _rendererRecreatedListener; #endif }; diff --git a/cocos/renderer/CCPass.cpp b/cocos/renderer/CCPass.cpp new file mode 100644 index 0000000000..7e8aa626d4 --- /dev/null +++ b/cocos/renderer/CCPass.cpp @@ -0,0 +1,155 @@ +/**************************************************************************** + Copyright (c) 2015 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 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. + + Ideas taken from: + - GamePlay3D: http://gameplay3d.org/ + - OGRE3D: http://www.ogre3d.org/ + - Qt3D: http://qt-project.org/ + ****************************************************************************/ + +#include "CCPass.h" +#include "renderer/CCGLProgramState.h" +#include "renderer/CCGLProgram.h" +#include "renderer/CCTexture2D.h" +#include "renderer/ccGLStateCache.h" +#include "renderer/CCTechnique.h" +#include "renderer/CCMaterial.h" + +#include "base/ccTypes.h" +#include "2d/CCNode.h" + +#include + +NS_CC_BEGIN + + +Pass* Pass::create(Technique* technique) +{ + auto pass = new (std::nothrow) Pass(); + if (pass && pass->init(technique)) + { + pass->autorelease(); + return pass; + } + return nullptr; +} + +Pass* Pass::createWithGLProgramState(Technique* technique, GLProgramState* programState) +{ + auto pass = new (std::nothrow) Pass(); + if (pass && pass->initWithGLProgramState(technique, programState)) + { + pass->autorelease(); + return pass; + } + return nullptr; +} + +bool Pass::init(Technique* technique) +{ + _parent = technique; + return true; +} + +bool Pass::initWithGLProgramState(Technique* technique, GLProgramState *glProgramState) +{ + _parent = technique; + _glProgramState = glProgramState; + CC_SAFE_RETAIN(_glProgramState); + return true; +} + +Pass::Pass() +: _glProgramState(nullptr) +{ +} + +Pass::~Pass() +{ + CC_SAFE_RELEASE(_glProgramState); +} + +GLProgramState* Pass::getGLProgramState() const +{ + return _glProgramState; +} + +void Pass::setGLProgramState(GLProgramState* glProgramState) +{ + if ( _glProgramState != glProgramState) { + CC_SAFE_RELEASE(_glProgramState); + _glProgramState = glProgramState; + CC_SAFE_RETAIN(_glProgramState); + + _hashDirty = true; + } +} + +uint32_t Pass::getHash() const +{ + if (_hashDirty || _state->isDirty()) { + uint32_t glProgram = (uint32_t)_glProgramState->getGLProgram()->getProgram(); + uint32_t textureid = (uint32_t)_textures.at(0)->getName(); + uint32_t stateblockid = _state->getHash(); + + _hash = glProgram ^ textureid ^ stateblockid; + +// _hash = XXH32((const void*)intArray, sizeof(intArray), 0); + _hashDirty = false; + } + + return _hash; +} + +void Pass::bind(const Mat4& modelView) +{ + bind(modelView, true); +} + +void Pass::bind(const Mat4& modelView, bool bindAttributes) +{ + auto glprogramstate = _glProgramState ? _glProgramState : getTarget()->getGLProgramState(); + + glprogramstate->applyGLProgram(modelView); + if (bindAttributes) + glprogramstate->applyAttributes(); + glprogramstate->applyUniforms(); + + //set render state + RenderState::bind(this); +} + +Node* Pass::getTarget() const +{ + CCASSERT(_parent && _parent->_parent, "Pass must have a Technique and Material"); + + Material *material = static_cast(_parent->_parent); + return material->_target; +} + +void Pass::unbind() +{ + RenderState::StateBlock::restore(0); +} + +NS_CC_END diff --git a/cocos/renderer/CCPass.h b/cocos/renderer/CCPass.h new file mode 100644 index 0000000000..f41116c852 --- /dev/null +++ b/cocos/renderer/CCPass.h @@ -0,0 +1,87 @@ +/**************************************************************************** + Copyright (c) 2015 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 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. + + Ideas taken from: + - GamePlay3D: http://gameplay3d.org/ + - OGRE3D: http://www.ogre3d.org/ + - Qt3D: http://qt-project.org/ + ****************************************************************************/ + +#ifndef __cocos2d_libs__CCPass__ +#define __cocos2d_libs__CCPass__ + +#include + +#include "platform/CCPlatformMacros.h" +#include "renderer/CCRenderState.h" + +NS_CC_BEGIN + +class GLProgramState; +class Technique; +class Node; + +class CC_DLL Pass : public RenderState +{ + friend class Material; + +public: + /** Creates a Pass with a GLProgramState. + */ + static Pass* createWithGLProgramState(Technique* parent, GLProgramState* programState); + + static Pass* create(Technique* parent); + + /** Returns the GLProgramState */ + GLProgramState* getGLProgramState() const; + + /** Binds the GLProgramState and the RenderState. + This method must be called before call the actuall draw call. + */ + void bind(const Mat4& modelView); + void bind(const Mat4& modelView, bool bindAttributes); + + /** Unbinds the Pass. + This method must be called AFTER calling the actuall draw call + */ + void unbind(); + + uint32_t getHash() const; + +protected: + Pass(); + ~Pass(); + bool init(Technique* parent); + bool initWithGLProgramState(Technique* parent, GLProgramState *glProgramState); + + void setGLProgramState(GLProgramState* glProgramState); + Node* getTarget() const; + + GLProgramState* _glProgramState; +}; + +NS_CC_END + + + +#endif /* defined(__cocos2d_libs__CCPass__) */ diff --git a/cocos/renderer/CCQuadCommand.cpp b/cocos/renderer/CCQuadCommand.cpp index a2ef022ea7..3e1cd2138f 100644 --- a/cocos/renderer/CCQuadCommand.cpp +++ b/cocos/renderer/CCQuadCommand.cpp @@ -27,8 +27,12 @@ #include "renderer/ccGLStateCache.h" #include "renderer/CCGLProgram.h" +#include "renderer/CCMaterial.h" +#include "renderer/CCTechnique.h" +#include "renderer/CCRenderer.h" +#include "renderer/CCPass.h" + #include "xxhash.h" -#include "CCRenderer.h" NS_CC_BEGIN @@ -78,18 +82,20 @@ QuadCommand::~QuadCommand() void QuadCommand::generateMaterialID() { - - if(_glProgramState->getUniformCount() > 0) - { - _materialID = Renderer::MATERIAL_ID_DO_NOT_BATCH; - } - else + _skipBatching = false; + + if(_glProgramState->getUniformCount() == 0) { int glProgram = (int)_glProgramState->getGLProgram()->getProgram(); int intArray[4] = { glProgram, (int)_textureID, (int)_blendType.src, (int)_blendType.dst}; - + _materialID = XXH32((const void*)intArray, sizeof(intArray), 0); } + else + { + _materialID = Renderer::MATERIAL_ID_DO_NOT_BATCH; + _skipBatching = true; + } } void QuadCommand::useMaterial() const @@ -100,7 +106,8 @@ void QuadCommand::useMaterial() const //set blend mode GL::blendFunc(_blendType.src, _blendType.dst); - _glProgramState->apply(_mv); + _glProgramState->applyGLProgram(_mv); + _glProgramState->applyUniforms(); } NS_CC_END \ No newline at end of file diff --git a/cocos/renderer/CCQuadCommand.h b/cocos/renderer/CCQuadCommand.h index bfd35376db..4e0c839a41 100644 --- a/cocos/renderer/CCQuadCommand.h +++ b/cocos/renderer/CCQuadCommand.h @@ -60,6 +60,7 @@ public: */ void init(float globalOrder, GLuint textureID, GLProgramState* shader, const BlendFunc& blendType, V3F_C4B_T2F_Quad* quads, ssize_t quadCount, const Mat4& mv, uint32_t flags); + /**Deprecated function, the params is similar as the upper init function, with flags equals 0.*/ CC_DEPRECATED_ATTRIBUTE void init(float globalOrder, GLuint textureID, GLProgramState* shader, const BlendFunc& blendType, V3F_C4B_T2F_Quad* quads, ssize_t quadCount, const Mat4& mv); diff --git a/cocos/renderer/CCRenderCommand.h b/cocos/renderer/CCRenderCommand.h index 5bc94c5931..6d84546222 100644 --- a/cocos/renderer/CCRenderCommand.h +++ b/cocos/renderer/CCRenderCommand.h @@ -86,7 +86,7 @@ public: /** Set transparent flag. */ inline void setTransparent(bool isTransparent) { _isTransparent = isTransparent; } /** - Get skip batching status, if a rendering is skip batching, it will be forced to be rendering seperately. + Get skip batching status, if a rendering is skip batching, it will be forced to be rendering separately. */ inline bool isSkipBatching() const { return _skipBatching; } /**Set skip batching.*/ @@ -117,7 +117,7 @@ protected: /** QuadCommand and TrianglesCommand could be auto batched if there material ID is the same, however, if - a command is skip batching, it would be forced to draw in a seperate function call, and break the batch. + a command is skip batching, it would be forced to draw in a separate function call, and break the batch. */ bool _skipBatching; diff --git a/cocos/renderer/CCRenderState.cpp b/cocos/renderer/CCRenderState.cpp new file mode 100644 index 0000000000..530b3fd8e5 --- /dev/null +++ b/cocos/renderer/CCRenderState.cpp @@ -0,0 +1,887 @@ +/**************************************************************************** + Copyright (c) 2015 Chukong Technologies Inc. + Copyright (c) 2014 GamePlay3D team + + http://www.cocos2d-x.org + + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Ideas taken from: + - GamePlay3D: http://gameplay3d.org/ + - OGRE3D: http://www.ogre3d.org/ + - Qt3D: http://qt-project.org/ + + ****************************************************************************/ + +#include "CCRenderState.h" + +#include + +#include "renderer/CCTexture2D.h" +#include "renderer/CCPass.h" +#include "renderer/ccGLStateCache.h" + + +NS_CC_BEGIN + +RenderState::StateBlock* RenderState::StateBlock::_defaultState = nullptr; + +// Render state override bits +enum +{ + RS_BLEND = (1 << 0), + RS_BLEND_FUNC = (1 << 1), + RS_CULL_FACE = (1 << 2), + RS_DEPTH_TEST = (1 << 3), + RS_DEPTH_WRITE = (1 << 4), + RS_DEPTH_FUNC = (1 << 5), + RS_CULL_FACE_SIDE = (1 << 6), + RS_STENCIL_TEST = (1 << 7), + RS_STENCIL_WRITE = (1 << 8), + RS_STENCIL_FUNC = (1 << 9), + RS_STENCIL_OP = (1 << 10), + RS_FRONT_FACE = (1 << 11), + + RS_ALL_ONES = 0xFFFFFFFF, +}; + + +RenderState::RenderState() +: _textures() +, _hash(0) +, _hashDirty(true) +, _parent(nullptr) +{ + _state = StateBlock::create(); + CC_SAFE_RETAIN(_state); +} + +RenderState::~RenderState() +{ + CC_SAFE_RELEASE(_state); +} + +void RenderState::initialize() +{ + if (StateBlock::_defaultState == NULL) + { + StateBlock::_defaultState = StateBlock::create(); + CC_SAFE_RETAIN(StateBlock::_defaultState); + } +} + +void RenderState::finalize() +{ + CC_SAFE_RELEASE(StateBlock::_defaultState); +} + +bool RenderState::init(RenderState* parent) +{ + CCASSERT(!_parent, "Cannot reinitialize Render State"); + CCASSERT(parent, "parent must be non-null"); + + // Weak reference + _parent = parent; + return true; +} + +std::string RenderState::getName() const +{ + return _name; +} + + +const Vector& RenderState::getTextures() const +{ + return _textures; +} + +void RenderState::setTexture(Texture2D* texture) +{ + if (_textures.size() > 0) + _textures.replace(0, texture); + else + _textures.pushBack(texture); +} + +Texture2D* RenderState::getTexture() const +{ + if (_textures.size() > 0) + return _textures.at(0); + return nullptr; +} + +void RenderState::bind(Pass* pass) +{ + CC_ASSERT(pass); + + if (_textures.size() > 0) + GL::bindTexture2D(_textures.at(0)->getName()); + + // Get the combined modified state bits for our RenderState hierarchy. + long stateOverrideBits = _state ? _state->_bits : 0; + RenderState* rs = _parent; + while (rs) + { + if (rs->_state) + { + stateOverrideBits |= rs->_state->_bits; + } + rs = rs->_parent; + } + + // Restore renderer state to its default, except for explicitly specified states + StateBlock::restore(stateOverrideBits); + + // Apply renderer state for the entire hierarchy, top-down. + rs = NULL; + while ((rs = getTopmost(rs))) + { + if (rs->_state) + { + rs->_state->bindNoRestore(); + } + } +} + +RenderState* RenderState::getTopmost(RenderState* below) +{ + RenderState* rs = this; + if (rs == below) + { + // Nothing below ourself. + return NULL; + } + + while (rs) + { + if (rs->_parent == below || rs->_parent == NULL) + { + // Stop traversing up here. + return rs; + } + rs = rs->_parent; + } + + return NULL; +} + +RenderState::StateBlock* RenderState::getStateBlock() const +{ + return _state; +} + +// +// StateBlock +// +RenderState::StateBlock* RenderState::StateBlock::create() +{ + auto state = new (std::nothrow) RenderState::StateBlock(); + if (state) + { + state->autorelease(); + } + + return state; +} + +// +// The defaults are based on GamePlay3D defaults, with the following chagnes +// _depthWriteEnabled is FALSE +// _depthTestEnabled is TRUE +// _blendEnabled is TRUE +RenderState::StateBlock::StateBlock() +: _cullFaceEnabled(false) +, _depthTestEnabled(true), _depthWriteEnabled(false), _depthFunction(RenderState::DEPTH_LESS) +, _blendEnabled(true), _blendSrc(RenderState::BLEND_ONE), _blendDst(RenderState::BLEND_ZERO) +, _cullFaceSide(CULL_FACE_SIDE_BACK), _frontFace(FRONT_FACE_CCW) +, _stencilTestEnabled(false), _stencilWrite(RS_ALL_ONES) +, _stencilFunction(RenderState::STENCIL_ALWAYS), _stencilFunctionRef(0), _stencilFunctionMask(RS_ALL_ONES) +, _stencilOpSfail(RenderState::STENCIL_OP_KEEP), _stencilOpDpfail(RenderState::STENCIL_OP_KEEP), _stencilOpDppass(RenderState::STENCIL_OP_KEEP) +, _bits(0L) +{ +} + +RenderState::StateBlock::~StateBlock() +{ +} + +void RenderState::StateBlock::bind() +{ + // When the public bind() is called with no RenderState object passed in, + // we assume we are being called to bind the state of a single StateBlock, + // irrespective of whether it belongs to a hierarchy of RenderStates. + // Therefore, we call restore() here with only this StateBlock's override + // bits to restore state before applying the new state. + StateBlock::restore(_bits); + + bindNoRestore(); +} + +void RenderState::StateBlock::bindNoRestore() +{ + CC_ASSERT(_defaultState); + + // Update any state that differs from _defaultState and flip _defaultState bits + if ((_bits & RS_BLEND) && (_blendEnabled != _defaultState->_blendEnabled)) + { + if (_blendEnabled) + glEnable(GL_BLEND); + else + glDisable(GL_BLEND); + _defaultState->_blendEnabled = _blendEnabled; + } + if ((_bits & RS_BLEND_FUNC) && (_blendSrc != _defaultState->_blendSrc || _blendDst != _defaultState->_blendDst)) + { + GL::blendFunc((GLenum)_blendSrc, (GLenum)_blendDst); + _defaultState->_blendSrc = _blendSrc; + _defaultState->_blendDst = _blendDst; + } + if ((_bits & RS_CULL_FACE) && (_cullFaceEnabled != _defaultState->_cullFaceEnabled)) + { + if (_cullFaceEnabled) + glEnable(GL_CULL_FACE); + else + glDisable(GL_CULL_FACE); + _defaultState->_cullFaceEnabled = _cullFaceEnabled; + } + if ((_bits & RS_CULL_FACE_SIDE) && (_cullFaceSide != _defaultState->_cullFaceSide)) + { + glCullFace((GLenum)_cullFaceSide); + _defaultState->_cullFaceSide = _cullFaceSide; + } + if ((_bits & RS_FRONT_FACE) && (_frontFace != _defaultState->_frontFace)) + { + glFrontFace((GLenum)_frontFace); + _defaultState->_frontFace = _frontFace; + } + if ((_bits & RS_DEPTH_TEST) && (_depthTestEnabled != _defaultState->_depthTestEnabled)) + { + if (_depthTestEnabled) + glEnable(GL_DEPTH_TEST); + else + glDisable(GL_DEPTH_TEST); + _defaultState->_depthTestEnabled = _depthTestEnabled; + } + if ((_bits & RS_DEPTH_WRITE) && (_depthWriteEnabled != _defaultState->_depthWriteEnabled)) + { + glDepthMask(_depthWriteEnabled ? GL_TRUE : GL_FALSE); + _defaultState->_depthWriteEnabled = _depthWriteEnabled; + } + if ((_bits & RS_DEPTH_FUNC) && (_depthFunction != _defaultState->_depthFunction)) + { + glDepthFunc((GLenum)_depthFunction); + _defaultState->_depthFunction = _depthFunction; + } + if ((_bits & RS_STENCIL_TEST) && (_stencilTestEnabled != _defaultState->_stencilTestEnabled)) + { + if (_stencilTestEnabled) + glEnable(GL_STENCIL_TEST); + else + glDisable(GL_STENCIL_TEST); + _defaultState->_stencilTestEnabled = _stencilTestEnabled; + } + if ((_bits & RS_STENCIL_WRITE) && (_stencilWrite != _defaultState->_stencilWrite)) + { + glStencilMask(_stencilWrite); + _defaultState->_stencilWrite = _stencilWrite; + } + if ((_bits & RS_STENCIL_FUNC) && (_stencilFunction != _defaultState->_stencilFunction || + _stencilFunctionRef != _defaultState->_stencilFunctionRef || + _stencilFunctionMask != _defaultState->_stencilFunctionMask)) + { + glStencilFunc((GLenum)_stencilFunction, _stencilFunctionRef, _stencilFunctionMask); + _defaultState->_stencilFunction = _stencilFunction; + _defaultState->_stencilFunctionRef = _stencilFunctionRef; + _defaultState->_stencilFunctionMask = _stencilFunctionMask; + } + if ((_bits & RS_STENCIL_OP) && (_stencilOpSfail != _defaultState->_stencilOpSfail || + _stencilOpDpfail != _defaultState->_stencilOpDpfail || + _stencilOpDppass != _defaultState->_stencilOpDppass)) + { + glStencilOp((GLenum)_stencilOpSfail, (GLenum)_stencilOpDpfail, (GLenum)_stencilOpDppass); + _defaultState->_stencilOpSfail = _stencilOpSfail; + _defaultState->_stencilOpDpfail = _stencilOpDpfail; + _defaultState->_stencilOpDppass = _stencilOpDppass; + } + + _defaultState->_bits |= _bits; +} + +void RenderState::StateBlock::restore(long stateOverrideBits) +{ + CC_ASSERT(_defaultState); + + // If there is no state to restore (i.e. no non-default state), do nothing. + if (_defaultState->_bits == 0) + { + return; + } + + // Restore any state that is not overridden and is not default + if (!(stateOverrideBits & RS_BLEND) && (_defaultState->_bits & RS_BLEND)) + { + glEnable(GL_BLEND); + _defaultState->_bits &= ~RS_BLEND; + _defaultState->_blendEnabled = true; + } + if (!(stateOverrideBits & RS_BLEND_FUNC) && (_defaultState->_bits & RS_BLEND_FUNC)) + { + GL::blendFunc(GL_ONE, GL_ZERO); + _defaultState->_bits &= ~RS_BLEND_FUNC; + _defaultState->_blendSrc = RenderState::BLEND_ONE; + _defaultState->_blendDst = RenderState::BLEND_ZERO; + } + if (!(stateOverrideBits & RS_CULL_FACE) && (_defaultState->_bits & RS_CULL_FACE)) + { + glDisable(GL_CULL_FACE); + _defaultState->_bits &= ~RS_CULL_FACE; + _defaultState->_cullFaceEnabled = false; + } + if (!(stateOverrideBits & RS_CULL_FACE_SIDE) && (_defaultState->_bits & RS_CULL_FACE_SIDE)) + { + glCullFace((GLenum)GL_BACK); + _defaultState->_bits &= ~RS_CULL_FACE_SIDE; + _defaultState->_cullFaceSide = RenderState::CULL_FACE_SIDE_BACK; + } + if (!(stateOverrideBits & RS_FRONT_FACE) && (_defaultState->_bits & RS_FRONT_FACE)) + { + glFrontFace((GLenum)GL_CCW); + _defaultState->_bits &= ~RS_FRONT_FACE; + _defaultState->_frontFace = RenderState::FRONT_FACE_CCW; + } + if (!(stateOverrideBits & RS_DEPTH_TEST) && (_defaultState->_bits & RS_DEPTH_TEST)) + { + glEnable(GL_DEPTH_TEST); + _defaultState->_bits &= ~RS_DEPTH_TEST; + _defaultState->_depthTestEnabled = true; + } + if (!(stateOverrideBits & RS_DEPTH_WRITE) && (_defaultState->_bits & RS_DEPTH_WRITE)) + { + glDepthMask(GL_FALSE); + _defaultState->_bits &= ~RS_DEPTH_WRITE; + _defaultState->_depthWriteEnabled = false; + } + if (!(stateOverrideBits & RS_DEPTH_FUNC) && (_defaultState->_bits & RS_DEPTH_FUNC)) + { + glDepthFunc((GLenum)GL_LESS); + _defaultState->_bits &= ~RS_DEPTH_FUNC; + _defaultState->_depthFunction = RenderState::DEPTH_LESS; + } + if (!(stateOverrideBits & RS_STENCIL_TEST) && (_defaultState->_bits & RS_STENCIL_TEST)) + { + glDisable(GL_STENCIL_TEST); + _defaultState->_bits &= ~RS_STENCIL_TEST; + _defaultState->_stencilTestEnabled = false; + } + if (!(stateOverrideBits & RS_STENCIL_WRITE) && (_defaultState->_bits & RS_STENCIL_WRITE)) + { + glStencilMask(RS_ALL_ONES); + _defaultState->_bits &= ~RS_STENCIL_WRITE; + _defaultState->_stencilWrite = RS_ALL_ONES; + } + if (!(stateOverrideBits & RS_STENCIL_FUNC) && (_defaultState->_bits & RS_STENCIL_FUNC)) + { + glStencilFunc((GLenum)RenderState::STENCIL_ALWAYS, 0, RS_ALL_ONES); + _defaultState->_bits &= ~RS_STENCIL_FUNC; + _defaultState->_stencilFunction = RenderState::STENCIL_ALWAYS; + _defaultState->_stencilFunctionRef = 0; + _defaultState->_stencilFunctionMask = RS_ALL_ONES; + } + if (!(stateOverrideBits & RS_STENCIL_OP) && (_defaultState->_bits & RS_STENCIL_OP)) + { + glStencilOp((GLenum)RenderState::STENCIL_OP_KEEP, (GLenum)RenderState::STENCIL_OP_KEEP, (GLenum)RenderState::STENCIL_OP_KEEP); + _defaultState->_bits &= ~RS_STENCIL_OP; + _defaultState->_stencilOpSfail = RenderState::STENCIL_OP_KEEP; + _defaultState->_stencilOpDpfail = RenderState::STENCIL_OP_KEEP; + _defaultState->_stencilOpDppass = RenderState::STENCIL_OP_KEEP; + } +} + +static bool parseBoolean(const std::string& value) +{ + return (value.compare("true")==0); +} + +static int parseInt(const std::string& value) +{ + // Android NDK 10 doesn't support std::stoi a/ std::stoul +#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID + return std::stoi(value); +#else + return atoi(value.c_str()); +#endif +} + +static unsigned int parseUInt(const std::string& value) +{ + // Android NDK 10 doesn't support std::stoi a/ std::stoul +#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID + return (unsigned int)std::stoul(value); +#else + return (unsigned int)atoi(value.c_str()); +#endif + +} + +static RenderState::Blend parseBlend(const std::string& value) +{ + // Convert the string to uppercase for comparison. + std::string upper(value); + std::transform(upper.begin(), upper.end(), upper.begin(), (int(*)(int))toupper); + if (upper == "ZERO") + return RenderState::BLEND_ZERO; + else if (upper == "ONE") + return RenderState::BLEND_ONE; + else if (upper == "SRC_COLOR") + return RenderState::BLEND_SRC_COLOR; + else if (upper == "ONE_MINUS_SRC_COLOR") + return RenderState::BLEND_ONE_MINUS_SRC_COLOR; + else if (upper == "DST_COLOR") + return RenderState::BLEND_DST_COLOR; + else if (upper == "ONE_MINUS_DST_COLOR") + return RenderState::BLEND_ONE_MINUS_DST_COLOR; + else if (upper == "SRC_ALPHA") + return RenderState::BLEND_SRC_ALPHA; + else if (upper == "ONE_MINUS_SRC_ALPHA") + return RenderState::BLEND_ONE_MINUS_SRC_ALPHA; + else if (upper == "DST_ALPHA") + return RenderState::BLEND_DST_ALPHA; + else if (upper == "ONE_MINUS_DST_ALPHA") + return RenderState::BLEND_ONE_MINUS_DST_ALPHA; + else if (upper == "CONSTANT_ALPHA") + return RenderState::BLEND_CONSTANT_ALPHA; + else if (upper == "ONE_MINUS_CONSTANT_ALPHA") + return RenderState::BLEND_ONE_MINUS_CONSTANT_ALPHA; + else if (upper == "SRC_ALPHA_SATURATE") + return RenderState::BLEND_SRC_ALPHA_SATURATE; + else + { + CCLOG("Unsupported blend value (%s). (Will default to BLEND_ONE if errors are treated as warnings)", value.c_str()); + return RenderState::BLEND_ONE; + } +} + +static RenderState::DepthFunction parseDepthFunc(const std::string& value) +{ + // Convert string to uppercase for comparison + std::string upper(value); + std::transform(upper.begin(), upper.end(), upper.begin(), (int(*)(int))toupper); + if (upper == "NEVER") + return RenderState::DEPTH_NEVER; + else if (upper == "LESS") + return RenderState::DEPTH_LESS; + else if (upper == "EQUAL") + return RenderState::DEPTH_EQUAL; + else if (upper == "LEQUAL") + return RenderState::DEPTH_LEQUAL; + else if (upper == "GREATER") + return RenderState::DEPTH_GREATER; + else if (upper == "NOTEQUAL") + return RenderState::DEPTH_NOTEQUAL; + else if (upper == "GEQUAL") + return RenderState::DEPTH_GEQUAL; + else if (upper == "ALWAYS") + return RenderState::DEPTH_ALWAYS; + else + { + CCLOG("Unsupported depth function value (%s). Will default to DEPTH_LESS if errors are treated as warnings)", value.c_str()); + return RenderState::DEPTH_LESS; + } +} + +static RenderState::CullFaceSide parseCullFaceSide(const std::string& value) +{ + // Convert string to uppercase for comparison + std::string upper(value); + std::transform(upper.begin(), upper.end(), upper.begin(), (int(*)(int))toupper); + if (upper == "BACK") + return RenderState::CULL_FACE_SIDE_BACK; + else if (upper == "FRONT") + return RenderState::CULL_FACE_SIDE_FRONT; + else if (upper == "FRONT_AND_BACK") + return RenderState::CULL_FACE_SIDE_FRONT_AND_BACK; + else + { + CCLOG("Unsupported cull face side value (%s). Will default to BACK if errors are treated as warnings.", value.c_str()); + return RenderState::CULL_FACE_SIDE_BACK; + } +} + +static RenderState::FrontFace parseFrontFace(const std::string& value) +{ + // Convert string to uppercase for comparison + std::string upper(value); + std::transform(upper.begin(), upper.end(), upper.begin(), (int(*)(int))toupper); + if (upper == "CCW") + return RenderState::FRONT_FACE_CCW; + else if (upper == "CW") + return RenderState::FRONT_FACE_CW; + else + { + CCLOG("Unsupported front face side value (%s). Will default to CCW if errors are treated as warnings.", value.c_str()); + return RenderState::FRONT_FACE_CCW; + } +} + +static RenderState::StencilFunction parseStencilFunc(const std::string& value) +{ + // Convert string to uppercase for comparison + std::string upper(value); + std::transform(upper.begin(), upper.end(), upper.begin(), (int(*)(int))toupper); + if (upper == "NEVER") + return RenderState::STENCIL_NEVER; + else if (upper == "LESS") + return RenderState::STENCIL_LESS; + else if (upper == "EQUAL") + return RenderState::STENCIL_EQUAL; + else if (upper == "LEQUAL") + return RenderState::STENCIL_LEQUAL; + else if (upper == "GREATER") + return RenderState::STENCIL_GREATER; + else if (upper == "NOTEQUAL") + return RenderState::STENCIL_NOTEQUAL; + else if (upper == "GEQUAL") + return RenderState::STENCIL_GEQUAL; + else if (upper == "ALWAYS") + return RenderState::STENCIL_ALWAYS; + else + { + CCLOG("Unsupported stencil function value (%s). Will default to STENCIL_ALWAYS if errors are treated as warnings)", value.c_str()); + return RenderState::STENCIL_ALWAYS; + } +} + +static RenderState::StencilOperation parseStencilOp(const std::string& value) +{ + // Convert string to uppercase for comparison + std::string upper(value); + std::transform(upper.begin(), upper.end(), upper.begin(), (int(*)(int))toupper); + if (upper == "KEEP") + return RenderState::STENCIL_OP_KEEP; + else if (upper == "ZERO") + return RenderState::STENCIL_OP_ZERO; + else if (upper == "REPLACE") + return RenderState::STENCIL_OP_REPLACE; + else if (upper == "INCR") + return RenderState::STENCIL_OP_INCR; + else if (upper == "DECR") + return RenderState::STENCIL_OP_DECR; + else if (upper == "INVERT") + return RenderState::STENCIL_OP_INVERT; + else if (upper == "INCR_WRAP") + return RenderState::STENCIL_OP_INCR_WRAP; + else if (upper == "DECR_WRAP") + return RenderState::STENCIL_OP_DECR_WRAP; + else + { + CCLOG("Unsupported stencil operation value (%s). Will default to STENCIL_OP_KEEP if errors are treated as warnings)", value.c_str()); + return RenderState::STENCIL_OP_KEEP; + } +} + +void RenderState::StateBlock::setState(const std::string& name, const std::string& value) +{ + if (name.compare("blend") == 0) + { + setBlend(parseBoolean(value)); + } + else if (name.compare("blendSrc") == 0) + { + setBlendSrc(parseBlend(value)); + } + else if (name.compare("blendDst") == 0) + { + setBlendDst(parseBlend(value)); + } + else if (name.compare("cullFace") == 0) + { + setCullFace(parseBoolean(value)); + } + else if (name.compare("cullFaceSide") == 0) + { + setCullFaceSide(parseCullFaceSide(value)); + } + else if (name.compare("frontFace") == 0) + { + setFrontFace(parseFrontFace(value)); + } + else if (name.compare("depthTest") == 0) + { + setDepthTest(parseBoolean(value)); + } + else if (name.compare("depthWrite") == 0) + { + setDepthWrite(parseBoolean(value)); + } + else if (name.compare("depthFunc") == 0) + { + setDepthFunction(parseDepthFunc(value)); + } + else if (name.compare("stencilTest") == 0) + { + setStencilTest(parseBoolean(value)); + } + else if (name.compare("stencilWrite") == 0) + { + setStencilWrite(parseUInt(value)); + } + else if (name.compare("stencilFunc") == 0) + { + setStencilFunction(parseStencilFunc(value), _stencilFunctionRef, _stencilFunctionMask); + } + else if (name.compare("stencilFuncRef") == 0) + { + setStencilFunction(_stencilFunction, parseInt(value), _stencilFunctionMask); + } + else if (name.compare("stencilFuncMask") == 0) + { + setStencilFunction(_stencilFunction, _stencilFunctionRef, parseUInt(value)); + } + else if (name.compare("stencilOpSfail") == 0) + { + setStencilOperation(parseStencilOp(value), _stencilOpDpfail, _stencilOpDppass); + } + else if (name.compare("stencilOpDpfail") == 0) + { + setStencilOperation(_stencilOpSfail, parseStencilOp(value), _stencilOpDppass); + } + else if (name.compare("stencilOpDppass") == 0) + { + setStencilOperation(_stencilOpSfail, _stencilOpDpfail, parseStencilOp(value)); + } + else + { + CCLOG("Unsupported render state string '%s'.", name.c_str()); + } +} + +bool RenderState::StateBlock::isDirty() const +{ + // XXX + return true; +} + +uint32_t RenderState::StateBlock::getHash() const +{ + // XXX + return 0x12345678; +} + +void RenderState::StateBlock::setBlend(bool enabled) +{ + _blendEnabled = enabled; + if (enabled) + { + _bits &= ~RS_BLEND; + } + else + { + _bits |= RS_BLEND; + } +} + +void RenderState::StateBlock::setBlendFunc(const BlendFunc& blendFunc) +{ + if (blendFunc == BlendFunc::DISABLE) + { + setBlendSrc(BLEND_ONE); + setBlendDst(BLEND_ZERO); + } + else if (blendFunc == BlendFunc::ALPHA_PREMULTIPLIED) + { + setBlendSrc(BLEND_ONE); + setBlendDst(BLEND_ONE_MINUS_SRC_ALPHA); + } + else if (blendFunc == BlendFunc::ALPHA_NON_PREMULTIPLIED) + { + setBlendSrc(BLEND_SRC_ALPHA); + setBlendDst(BLEND_ONE_MINUS_SRC_ALPHA); + } + else if (blendFunc == BlendFunc::ADDITIVE) + { + setBlendSrc(BLEND_SRC_ALPHA); + setBlendDst(BLEND_ONE); + } +} + +void RenderState::StateBlock::setBlendSrc(Blend blend) +{ + _blendSrc = blend; + if (_blendSrc == BLEND_ONE && _blendDst == BLEND_ZERO) + { + // Default blend func + _bits &= ~RS_BLEND_FUNC; + } + else + { + _bits |= RS_BLEND_FUNC; + } +} + +void RenderState::StateBlock::setBlendDst(Blend blend) +{ + _blendDst = blend; + if (_blendSrc == BLEND_ONE && _blendDst == BLEND_ZERO) + { + // Default blend func + _bits &= ~RS_BLEND_FUNC; + } + else + { + _bits |= RS_BLEND_FUNC; + } +} + +void RenderState::StateBlock::setCullFace(bool enabled) +{ + _cullFaceEnabled = enabled; + if (!enabled) + { + _bits &= ~RS_CULL_FACE; + } + else + { + _bits |= RS_CULL_FACE; + } +} + +void RenderState::StateBlock::setCullFaceSide(CullFaceSide side) +{ + _cullFaceSide = side; + if (_cullFaceSide == CULL_FACE_SIDE_BACK) + { + // Default cull side + _bits &= ~RS_CULL_FACE_SIDE; + } + else + { + _bits |= RS_CULL_FACE_SIDE; + } +} + +void RenderState::StateBlock::setFrontFace(FrontFace winding) +{ + _frontFace = winding; + if (_frontFace == FRONT_FACE_CCW) + { + // Default front face + _bits &= ~RS_FRONT_FACE; + } + else + { + _bits |= RS_FRONT_FACE; + } +} + +void RenderState::StateBlock::setDepthTest(bool enabled) +{ + _depthTestEnabled = enabled; + if (enabled) + { + _bits &= ~RS_DEPTH_TEST; + } + else + { + _bits |= RS_DEPTH_TEST; + } +} + +void RenderState::StateBlock::setDepthWrite(bool enabled) +{ + _depthWriteEnabled = enabled; + if (!enabled) + { + _bits &= ~RS_DEPTH_WRITE; + } + else + { + _bits |= RS_DEPTH_WRITE; + } +} + +void RenderState::StateBlock::setDepthFunction(DepthFunction func) +{ + _depthFunction = func; + if (_depthFunction == DEPTH_LESS) + { + // Default depth function + _bits &= ~RS_DEPTH_FUNC; + } + else + { + _bits |= RS_DEPTH_FUNC; + } +} + +void RenderState::StateBlock::setStencilTest(bool enabled) +{ + _stencilTestEnabled = enabled; + if (!enabled) + { + _bits &= ~RS_STENCIL_TEST; + } + else + { + _bits |= RS_STENCIL_TEST; + } +} + +void RenderState::StateBlock::setStencilWrite(unsigned int mask) +{ + _stencilWrite = mask; + if (mask == RS_ALL_ONES) + { + // Default stencil write + _bits &= ~RS_STENCIL_WRITE; + } + else + { + _bits |= RS_STENCIL_WRITE; + } +} + +void RenderState::StateBlock::setStencilFunction(StencilFunction func, int ref, unsigned int mask) +{ + _stencilFunction = func; + _stencilFunctionRef = ref; + _stencilFunctionMask = mask; + if (func == STENCIL_ALWAYS && ref == 0 && mask == RS_ALL_ONES) + { + // Default stencil function + _bits &= ~RS_STENCIL_FUNC; + } + else + { + _bits |= RS_STENCIL_FUNC; + } +} + +void RenderState::StateBlock::setStencilOperation(StencilOperation sfail, StencilOperation dpfail, StencilOperation dppass) +{ + _stencilOpSfail = sfail; + _stencilOpDpfail = dpfail; + _stencilOpDppass = dppass; + if (sfail == STENCIL_OP_KEEP && dpfail == STENCIL_OP_KEEP && dppass == STENCIL_OP_KEEP) + { + // Default stencil operation + _bits &= ~RS_STENCIL_OP; + } + else + { + _bits |= RS_STENCIL_OP; + } +} + +NS_CC_END \ No newline at end of file diff --git a/cocos/renderer/CCRenderState.h b/cocos/renderer/CCRenderState.h new file mode 100644 index 0000000000..48f7680591 --- /dev/null +++ b/cocos/renderer/CCRenderState.h @@ -0,0 +1,418 @@ +/**************************************************************************** + Copyright (c) 2015 Chukong Technologies Inc. + Copyright (c) 2014 GamePlay3D team + + http://www.cocos2d-x.org + + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Ideas taken from: + - GamePlay3D: http://gameplay3d.org/ + - OGRE3D: http://www.ogre3d.org/ + - Qt3D: http://qt-project.org/ + + ****************************************************************************/ + +#ifndef __cocos2d_libs__CCRenderState__ +#define __cocos2d_libs__CCRenderState__ + +#include +#include +#include + +#include "renderer/CCTexture2D.h" +#include "platform/CCPlatformMacros.h" +#include "base/CCRef.h" +#include "base/ccTypes.h" +#include "base/CCVector.h" + +NS_CC_BEGIN + +class Texture2D; +class Pass; + +/** + * Defines the rendering state of the graphics device. + */ +class CC_DLL RenderState : public Ref +{ + friend class Material; + friend class Technique; + friend class Pass; + +public: + /** + * Static initializer that is called during game startup. + */ + static void initialize(); + + /** + * Static finalizer that is called during game shutdown. + */ + static void finalize(); + + std::string getName() const; + + + const Vector& getTextures() const; + + /** Replaces the texture that is at the front of _textures array. + Added to be backwards compatible. + */ + void setTexture(Texture2D* texture); + + /** Returns the texture that is at the front of the _textures array. + Added to be backwards compatible. + */ + Texture2D* getTexture() const; + + /** + * Binds the render state for this RenderState and any of its parents, top-down, + * for the given pass. + */ + void bind(Pass* pass); + + /** + * Returns the topmost RenderState in the hierarchy below the given RenderState. + */ + RenderState* getTopmost(RenderState* below); + + enum Blend + { + BLEND_ZERO = GL_ZERO, + BLEND_ONE = GL_ONE, + BLEND_SRC_COLOR = GL_SRC_COLOR, + BLEND_ONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR, + BLEND_DST_COLOR = GL_DST_COLOR, + BLEND_ONE_MINUS_DST_COLOR = GL_ONE_MINUS_DST_COLOR, + BLEND_SRC_ALPHA = GL_SRC_ALPHA, + BLEND_ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA, + BLEND_DST_ALPHA = GL_DST_ALPHA, + BLEND_ONE_MINUS_DST_ALPHA = GL_ONE_MINUS_DST_ALPHA, + BLEND_CONSTANT_ALPHA = GL_CONSTANT_ALPHA, + BLEND_ONE_MINUS_CONSTANT_ALPHA = GL_ONE_MINUS_CONSTANT_ALPHA, + BLEND_SRC_ALPHA_SATURATE = GL_SRC_ALPHA_SATURATE + }; + + /** + * Defines the supported depth compare functions. + * + * Depth compare functions specify the comparison that takes place between the + * incoming pixel's depth value and the depth value already in the depth buffer. + * If the compare function passes, the new pixel will be drawn. + * + * The intial depth compare function is DEPTH_LESS. + */ + enum DepthFunction + { + DEPTH_NEVER = GL_NEVER, + DEPTH_LESS = GL_LESS, + DEPTH_EQUAL = GL_EQUAL, + DEPTH_LEQUAL = GL_LEQUAL, + DEPTH_GREATER = GL_GREATER, + DEPTH_NOTEQUAL = GL_NOTEQUAL, + DEPTH_GEQUAL = GL_GEQUAL, + DEPTH_ALWAYS = GL_ALWAYS + }; + + /** + * Defines culling criteria for front-facing, back-facing and both-side + * facets. + */ + enum CullFaceSide + { + CULL_FACE_SIDE_BACK = GL_BACK, + CULL_FACE_SIDE_FRONT = GL_FRONT, + CULL_FACE_SIDE_FRONT_AND_BACK = GL_FRONT_AND_BACK + }; + + /** + * Defines the winding of vertices in faces that are considered front facing. + * + * The initial front face mode is set to FRONT_FACE_CCW. + */ + enum FrontFace + { + FRONT_FACE_CW = GL_CW, + FRONT_FACE_CCW = GL_CCW + }; + + /** + * Defines the supported stencil compare functions. + * + * Stencil compare functions determine if a new pixel will be drawn. + * + * The initial stencil compare function is STENCIL_ALWAYS. + */ + enum StencilFunction + { + STENCIL_NEVER = GL_NEVER, + STENCIL_ALWAYS = GL_ALWAYS, + STENCIL_LESS = GL_LESS, + STENCIL_LEQUAL = GL_LEQUAL, + STENCIL_EQUAL = GL_EQUAL, + STENCIL_GREATER = GL_GREATER, + STENCIL_GEQUAL = GL_GEQUAL, + STENCIL_NOTEQUAL = GL_NOTEQUAL + }; + + /** + * Defines the supported stencil operations to perform. + * + * Stencil operations determine what should happen to the pixel if the + * stencil test fails, passes, or passes but fails the depth test. + * + * The initial stencil operation is STENCIL_OP_KEEP. + */ + enum StencilOperation + { + STENCIL_OP_KEEP = GL_KEEP, + STENCIL_OP_ZERO = GL_ZERO, + STENCIL_OP_REPLACE = GL_REPLACE, + STENCIL_OP_INCR = GL_INCR, + STENCIL_OP_DECR = GL_DECR, + STENCIL_OP_INVERT = GL_INVERT, + STENCIL_OP_INCR_WRAP = GL_INCR_WRAP, + STENCIL_OP_DECR_WRAP = GL_DECR_WRAP + }; + + /** + * Defines a block of fixed-function render states that can be applied to a + * RenderState object. + */ + class StateBlock : public Ref + { + friend class RenderState; + friend class Pass; + friend class RenderQueue; + friend class Renderer; + + public: + /** + * Creates a new StateBlock with default render state settings. + */ + static StateBlock* create(); + + /** + * Binds the state in this StateBlock to the renderer. + * + * This method handles both setting and restoring of render states to ensure that + * only the state explicitly defined by this StateBlock is applied to the renderer. + */ + void bind(); + + /** + * Explicitly sets the source and destination used in the blend function for this render state. + * + * Note that the blend function is only applied when blending is enabled. + * + * @param blendFunc Specifies how the blending factors are computed. + */ + void setBlendFunc(const BlendFunc& blendFunc); + + /** + * Toggles blending. + * + * @param enabled true to enable, false to disable. + */ + void setBlend(bool enabled); + + /** + * Explicitly sets the source used in the blend function for this render state. + * + * Note that the blend function is only applied when blending is enabled. + * + * @param blend Specifies how the source blending factors are computed. + */ + void setBlendSrc(Blend blend); + + /** + * Explicitly sets the source used in the blend function for this render state. + * + * Note that the blend function is only applied when blending is enabled. + * + * @param blend Specifies how the destination blending factors are computed. + */ + void setBlendDst(Blend blend); + + /** + * Explicitly enables or disables backface culling. + * + * @param enabled true to enable, false to disable. + */ + void setCullFace(bool enabled); + + /** + * Sets the side of the facets to cull. + * + * When not explicitly set, the default is to cull back-facing facets. + * + * @param side The side to cull. + */ + void setCullFaceSide(CullFaceSide side); + + /** + * Sets the winding for front facing polygons. + * + * By default, counter-clockwise wound polygons are considered front facing. + * + * @param winding The winding for front facing polygons. + */ + void setFrontFace(FrontFace winding); + + /** + * Toggles depth testing. + * + * By default, depth testing is disabled. + * + * @param enabled true to enable, false to disable. + */ + void setDepthTest(bool enabled); + + /** + * Toggles depth writing. + * + * @param enabled true to enable, false to disable. + */ + void setDepthWrite(bool enabled); + + /** + * Sets the depth function to use when depth testing is enabled. + * + * When not explicitly set and when depth testing is enabled, the default + * depth function is DEPTH_LESS. + * + * @param func The depth function. + */ + void setDepthFunction(DepthFunction func); + + /** + * Toggles stencil testing. + * + * By default, stencil testing is disabled. + * + * @param enabled true to enable, false to disable. + */ + void setStencilTest(bool enabled); + + /** + * Sets the stencil writing mask. + * + * By default, the stencil writing mask is all 1's. + * + * @param mask Bit mask controlling writing to individual stencil planes. + */ + void setStencilWrite(unsigned int mask); + + /** + * Sets the stencil function. + * + * By default, the function is set to STENCIL_ALWAYS, the reference value is 0, and the mask is all 1's. + * + * @param func The stencil function. + * @param ref The stencil reference value. + * @param mask The stencil mask. + */ + void setStencilFunction(StencilFunction func, int ref, unsigned int mask); + + /** + * Sets the stencil operation. + * + * By default, stencil fail, stencil pass/depth fail, and stencil and depth pass are set to STENCIL_OP_KEEP. + * + * @param sfail The stencil operation if the stencil test fails. + * @param dpfail The stencil operation if the stencil test passes, but the depth test fails. + * @param dppass The stencil operation if both the stencil test and depth test pass. + */ + void setStencilOperation(StencilOperation sfail, StencilOperation dpfail, StencilOperation dppass); + + /** + * Sets a render state from the given name and value strings. + * + * This method attempts to interpret the passed in strings as render state + * name and value. This is normally used when loading render states from + * material files. + * + * @param name Name of the render state to set. + * @param value Value of the specified render state. + */ + void setState(const std::string& name, const std::string& value); + + uint32_t getHash() const; + bool isDirty() const; + + protected: + StateBlock(); + ~StateBlock(); + + void bindNoRestore(); + static void restore(long stateOverrideBits); + static void enableDepthWrite(); + + bool _cullFaceEnabled; + bool _depthTestEnabled; + bool _depthWriteEnabled; + DepthFunction _depthFunction; + bool _blendEnabled; + Blend _blendSrc; + Blend _blendDst; + CullFaceSide _cullFaceSide; + FrontFace _frontFace; + bool _stencilTestEnabled; + unsigned int _stencilWrite; + StencilFunction _stencilFunction; + int _stencilFunctionRef; + unsigned int _stencilFunctionMask; + StencilOperation _stencilOpSfail; + StencilOperation _stencilOpDpfail; + StencilOperation _stencilOpDppass; + + long _bits; + + static StateBlock* _defaultState; + + mutable uint32_t _hash; + mutable bool _hashDirty; + }; + + void setStateBlock(StateBlock* state); + StateBlock* getStateBlock() const; + +protected: + RenderState(); + ~RenderState(); + bool init(RenderState* parent); + + mutable uint32_t _hash; + mutable bool _hashDirty; + + /** + * The StateBlock of fixed-function render states that can be applied to the RenderState. + */ + mutable StateBlock* _state; + + /** + * The RenderState's parent. Weak Reference + */ + RenderState* _parent; + + // name, for filtering + std::string _name; + + Vector _textures; +}; + +NS_CC_END + +#endif /* defined(__cocos2d_libs__CCRenderState__) */ diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index 4e231e18cd..90799f9c0b 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -32,9 +32,14 @@ #include "renderer/CCCustomCommand.h" #include "renderer/CCGroupCommand.h" #include "renderer/CCPrimitiveCommand.h" -#include "renderer/CCGLProgramCache.h" -#include "renderer/ccGLStateCache.h" #include "renderer/CCMeshCommand.h" +#include "renderer/CCGLProgramCache.h" +#include "renderer/CCMaterial.h" +#include "renderer/CCTechnique.h" +#include "renderer/CCPass.h" +#include "renderer/CCRenderState.h" +#include "renderer/ccGLStateCache.h" + #include "base/CCConfiguration.h" #include "base/CCDirector.h" #include "base/CCEventDispatcher.h" @@ -161,24 +166,29 @@ void RenderQueue::restoreRenderState() if (_isCullEnabled) { glEnable(GL_CULL_FACE); + RenderState::StateBlock::_defaultState->setCullFace(true); } else { glDisable(GL_CULL_FACE); + RenderState::StateBlock::_defaultState->setCullFace(false); } if (_isDepthEnabled) { glEnable(GL_DEPTH_TEST); + RenderState::StateBlock::_defaultState->setDepthTest(true); } else { glDisable(GL_DEPTH_TEST); + RenderState::StateBlock::_defaultState->setDepthTest(false); } glDepthMask(_isDepthWrite); - + RenderState::StateBlock::_defaultState->setDepthWrite(_isDepthEnabled); + CHECK_GL_ERROR_DEBUG(); } @@ -530,11 +540,15 @@ void Renderer::visitRenderQueue(RenderQueue& queue) { glEnable(GL_DEPTH_TEST); glDepthMask(true); + RenderState::StateBlock::_defaultState->setDepthTest(true); + RenderState::StateBlock::_defaultState->setDepthWrite(true); } else { glDisable(GL_DEPTH_TEST); glDepthMask(false); + RenderState::StateBlock::_defaultState->setDepthTest(false); + RenderState::StateBlock::_defaultState->setDepthWrite(false); } for (auto it = zNegQueue.cbegin(); it != zNegQueue.cend(); ++it) { @@ -550,9 +564,12 @@ void Renderer::visitRenderQueue(RenderQueue& queue) if (opaqueQueue.size() > 0) { //Clear depth to achieve layered rendering - glDepthMask(true); glEnable(GL_DEPTH_TEST); - + glDepthMask(true); + RenderState::StateBlock::_defaultState->setDepthTest(true); + RenderState::StateBlock::_defaultState->setDepthWrite(true); + + for (auto it = opaqueQueue.cbegin(); it != opaqueQueue.cend(); ++it) { processRenderCommand(*it); @@ -568,7 +585,11 @@ void Renderer::visitRenderQueue(RenderQueue& queue) { glEnable(GL_DEPTH_TEST); glDepthMask(false); - + + RenderState::StateBlock::_defaultState->setDepthTest(true); + RenderState::StateBlock::_defaultState->setDepthWrite(false); + + for (auto it = transQueue.cbegin(); it != transQueue.cend(); ++it) { processRenderCommand(*it); @@ -586,11 +607,19 @@ void Renderer::visitRenderQueue(RenderQueue& queue) { glEnable(GL_DEPTH_TEST); glDepthMask(true); + + RenderState::StateBlock::_defaultState->setDepthTest(true); + RenderState::StateBlock::_defaultState->setDepthWrite(true); + } else { glDisable(GL_DEPTH_TEST); glDepthMask(false); + + RenderState::StateBlock::_defaultState->setDepthTest(false); + RenderState::StateBlock::_defaultState->setDepthWrite(false); + } for (auto it = zZeroQueue.cbegin(); it != zZeroQueue.cend(); ++it) { @@ -666,6 +695,8 @@ void Renderer::clear() glDepthMask(true); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glDepthMask(false); + + RenderState::StateBlock::_defaultState->setDepthWrite(false); } void Renderer::setDepthTest(bool enable) @@ -675,13 +706,19 @@ void Renderer::setDepthTest(bool enable) glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); + + RenderState::StateBlock::_defaultState->setDepthTest(true); + RenderState::StateBlock::_defaultState->setDepthFunction(RenderState::DEPTH_LEQUAL); + // glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); } else { glDisable(GL_DEPTH_TEST); + + RenderState::StateBlock::_defaultState->setDepthTest(false); } - + _isDepthTestFor2D = enable; CHECK_GL_ERROR_DEBUG(); } @@ -834,7 +871,7 @@ void Renderer::drawBatchedQuads() { //TODO: we can improve the draw performance by insert material switching command before hand. - int indexToDraw = 0; + ssize_t indexToDraw = 0; int startIndex = 0; //Upload buffer to VBO @@ -851,10 +888,10 @@ void Renderer::drawBatchedQuads() glBindBuffer(GL_ARRAY_BUFFER, _quadbuffersVBO[0]); // option 1: subdata - // glBufferSubData(GL_ARRAY_BUFFER, sizeof(_quads[0])*start, sizeof(_quads[0]) * n , &_quads[start] ); + // glBufferSubData(GL_ARRAY_BUFFER, sizeof(_quads[0])*start, sizeof(_quads[0]) * n , &_quads[start] ); // option 2: data - // glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * (n-start), &quads_[start], GL_DYNAMIC_DRAW); + // glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * (n-start), &quads_[start], GL_DYNAMIC_DRAW); // option 3: orphaning + glMapBuffer glBufferData(GL_ARRAY_BUFFER, sizeof(_quadVerts[0]) * _numberQuads * 4, nullptr, GL_DYNAMIC_DRAW); @@ -886,14 +923,19 @@ void Renderer::drawBatchedQuads() glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _quadbuffersVBO[1]); } - - //Start drawing verties in batch + + + // FIXME: The logic of this code is confusing, and error prone + // Needs refactoring + + //Start drawing vertices in batch for(const auto& cmd : _batchQuadCommands) { + bool commandQueued = true; auto newMaterialID = cmd->getMaterialID(); if(_lastMaterialID != newMaterialID || newMaterialID == MATERIAL_ID_DO_NOT_BATCH) { - //Draw quads + // flush buffer if(indexToDraw > 0) { glDrawElements(GL_TRIANGLES, (GLsizei) indexToDraw, GL_UNSIGNED_SHORT, (GLvoid*) (startIndex*sizeof(_indices[0])) ); @@ -905,11 +947,15 @@ void Renderer::drawBatchedQuads() } //Use new material - cmd->useMaterial(); _lastMaterialID = newMaterialID; + + cmd->useMaterial(); + } + + if (commandQueued) + { + indexToDraw += cmd->getQuadCount() * 6; } - - indexToDraw += cmd->getQuadCount() * 6; } //Draw any remaining quad diff --git a/cocos/renderer/CCTechnique.cpp b/cocos/renderer/CCTechnique.cpp new file mode 100644 index 0000000000..e006780058 --- /dev/null +++ b/cocos/renderer/CCTechnique.cpp @@ -0,0 +1,103 @@ +/**************************************************************************** + Copyright (c) 2015 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 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. + + Ideas taken from: + - GamePlay3D: http://gameplay3d.org/ + - OGRE3D: http://www.ogre3d.org/ + - Qt3D: http://qt-project.org/ + ****************************************************************************/ + +#include "renderer/CCTechnique.h" +#include "renderer/CCGLProgramState.h" +#include "renderer/CCMaterial.h" +#include "renderer/CCPass.h" + +NS_CC_BEGIN + +Technique* Technique::createWithGLProgramState(Material* parent, GLProgramState* state) +{ + auto technique = new (std::nothrow) Technique(); + if (technique && technique->init(parent)) + { + auto pass = Pass::createWithGLProgramState(technique, state); + technique->addPass(pass); + + technique->autorelease(); + return technique; + } + return nullptr; +} + +Technique* Technique::create(Material* material) +{ + auto technique = new (std::nothrow) Technique(); + if (technique && technique->init(material)) + { + technique->autorelease(); + return technique; + } + return nullptr; +} + +Technique::Technique() +: _name("") +{ +} + +Technique::~Technique() +{ +} + +bool Technique::init(Material* parent) +{ + _parent = parent; + return true; +} + +void Technique::addPass(Pass *pass) +{ + _passes.pushBack(pass); +} + +std::string Technique::getName() const +{ + return _name; +} + +void Technique::setName(const std::string &name) +{ + _name = name; +} + +Pass* Technique::getPassByIndex(ssize_t index) const +{ + CC_ASSERT(index>=0 && index<_passes.size() && "Invalid index"); + return _passes.at(index); +} + +ssize_t Technique::getPassCount() const +{ + return _passes.size(); +} + +NS_CC_END \ No newline at end of file diff --git a/cocos/renderer/CCTechnique.h b/cocos/renderer/CCTechnique.h new file mode 100644 index 0000000000..5c7f0b8aee --- /dev/null +++ b/cocos/renderer/CCTechnique.h @@ -0,0 +1,89 @@ +/**************************************************************************** + Copyright (c) 2015 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 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. + + Ideas taken from: + - GamePlay3D: http://gameplay3d.org/ + - OGRE3D: http://www.ogre3d.org/ + - Qt3D: http://qt-project.org/ + ****************************************************************************/ + +#ifndef __cocos2d_libs__CCTechnique__ +#define __cocos2d_libs__CCTechnique__ + +#include +#include "renderer/CCRenderState.h" +#include "renderer/CCPass.h" +#include "base/CCRef.h" +#include "platform/CCPlatformMacros.h" +#include "base/CCVector.h" + +NS_CC_BEGIN + +class Pass; +class GLProgramState; +class Material; + +/// Technique +class CC_DLL Technique : public RenderState +{ + friend class Material; + friend class Renderer; + friend class Pass; + friend class MeshCommand; + friend class Mesh; + +public: + /** Creates a new Technique with a GLProgramState. + Method added to support legacy code + */ + static Technique* createWithGLProgramState(Material* parent, GLProgramState* state); + static Technique* create(Material* parent); + + /** Adds a new pass to the Technique. + Order matters. First added, first rendered + */ + void addPass(Pass* pass); + + /** Returns the name of the Technique */ + std::string getName() const; + + /** Returns the Pass at given index */ + Pass* getPassByIndex(ssize_t index) const; + + /** Returns the number of Passes in the Technique */ + ssize_t getPassCount() const; + +protected: + Technique(); + ~Technique(); + bool init(Material* parent); + + void setName(const std::string& name); + + std::string _name; + Vector _passes; +}; + +NS_CC_END + +#endif /* defined(__cocos2d_libs__CCTechnique__) */ diff --git a/cocos/renderer/CCVertexIndexBuffer.cpp b/cocos/renderer/CCVertexIndexBuffer.cpp index c24efdd5e2..2fa659b72e 100644 --- a/cocos/renderer/CCVertexIndexBuffer.cpp +++ b/cocos/renderer/CCVertexIndexBuffer.cpp @@ -30,13 +30,13 @@ NS_CC_BEGIN -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) bool VertexBuffer::_enableShadowCopy = true; #else bool VertexBuffer::_enableShadowCopy = false; #endif -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) bool IndexBuffer::_enableShadowCopy = true; #else bool IndexBuffer::_enableShadowCopy = false; @@ -62,7 +62,7 @@ VertexBuffer::VertexBuffer() , _vertexNumber(0) { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) auto callBack = [this](EventCustom* event) { this->recreateVBO(); @@ -80,7 +80,7 @@ VertexBuffer::~VertexBuffer() glDeleteBuffers(1, &_vbo); _vbo = 0; } -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) Director::getInstance()->getEventDispatcher()->removeEventListener(_recreateVBOEventListener); #endif } @@ -190,7 +190,7 @@ IndexBuffer::IndexBuffer() , _indexNumber(0) , _recreateVBOEventListener(nullptr) { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) auto callBack = [this](EventCustom* event) { this->recreateVBO(); @@ -207,7 +207,7 @@ IndexBuffer::~IndexBuffer() glDeleteBuffers(1, &_vbo); _vbo = 0; } -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) Director::getInstance()->getEventDispatcher()->removeEventListener(_recreateVBOEventListener); #endif } diff --git a/cocos/renderer/CMakeLists.txt b/cocos/renderer/CMakeLists.txt index 3a92d52408..2aec0ae3ee 100644 --- a/cocos/renderer/CMakeLists.txt +++ b/cocos/renderer/CMakeLists.txt @@ -1,6 +1,5 @@ set(COCOS_RENDERER_SRC - renderer/CCBatchCommand.cpp renderer/CCCustomCommand.cpp renderer/CCGLProgram.cpp @@ -8,12 +7,16 @@ set(COCOS_RENDERER_SRC renderer/CCGLProgramState.cpp renderer/CCGLProgramStateCache.cpp renderer/CCGroupCommand.cpp + renderer/CCMaterial.cpp renderer/CCMeshCommand.cpp + renderer/CCPass.cpp renderer/CCPrimitive.cpp renderer/CCPrimitiveCommand.cpp renderer/CCQuadCommand.cpp renderer/CCRenderCommand.cpp + renderer/CCRenderState.cpp renderer/CCRenderer.cpp + renderer/CCTechnique.cpp renderer/CCTexture2D.cpp renderer/CCTextureAtlas.cpp renderer/CCTextureCache.cpp @@ -22,5 +25,4 @@ set(COCOS_RENDERER_SRC renderer/CCVertexIndexData.cpp renderer/ccGLStateCache.cpp renderer/ccShaders.cpp - ) diff --git a/cocos/scripting/js-bindings/.gitignore b/cocos/scripting/js-bindings/.gitignore new file mode 100644 index 0000000000..90d90dc6e6 --- /dev/null +++ b/cocos/scripting/js-bindings/.gitignore @@ -0,0 +1,76 @@ +# Ignore thumbnails created by windows +Thumbs.db + +# Ignore files build by Visual Studio +*.obj +*.exe +*.pdb +*.aps +*.vcproj.*.user +*.vcxproj.user +*.vspscc +*_i.c +*.i +*.icf +*_p.c +*.ncb +*.suo +*.tlb +*.tlh +*.bak +*.cache +*.ilk +*.log +[Bb]in +[Dd]ebug/ +[Dd]ebug.win32/ +*.sbr +*.sdf +obj/ +[Rr]elease/ +[Rr]elease.win32/ +_ReSharper*/ +[Tt]est[Rr]esult* +ipch/ +*.opensdf +Generated Files +AppPackages + +# Ignore files build by ndk and eclipse +libs/ +bin/ +obj/ +gen/ +assets/ +local.properties + +# Ignore files build by airplay and marmalade +build_*_xcode/ +build_*_vc10/ + +# Ignore files build by Xcode +*.mode*v* +*.pbxuser +*.xcbkptlist +*.xcworkspacedata +*.xcuserstate +*.xccheckout +xcschememanagement.plist +.DS_Store +._.* +xcuserdata/ +DerivedData/ +proj.ios_mac/build/ + +# Ignore vim swaps +*.swp +*.swo + +# Cmake files +CMakeCache.txt +CMakeFiles +Makefile +cmake_install.cmake +CMakeLists.txt.user + +*.jsc diff --git a/cocos/scripting/js-bindings/CMakeLists.txt b/cocos/scripting/js-bindings/CMakeLists.txt new file mode 100644 index 0000000000..bb4ecca32f --- /dev/null +++ b/cocos/scripting/js-bindings/CMakeLists.txt @@ -0,0 +1,110 @@ +#/**************************************************************************** +# Copyright (c) 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 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. +# ****************************************************************************/ + +set(cocos_root ../../..) + +#platform +if(WIN32) # Win32 + set(PLATFORM_FOLDER win32) +elseif(APPLE)# osx or ios + set(PLATFORM_FOLDER mac) +else() # Assume Linux + set(PLATFORM_FOLDER linux) +endif() + +set(JSBINDING_SRC + auto/jsb_cocos2dx_auto.cpp + auto/jsb_cocos2dx_builder_auto.cpp + auto/jsb_cocos2dx_extension_auto.cpp + auto/jsb_cocos2dx_spine_auto.cpp + auto/jsb_cocos2dx_studio_auto.cpp + auto/jsb_cocos2dx_ui_auto.cpp + auto/jsb_cocos2dx_3d_auto.cpp + auto/jsb_cocos2dx_3d_extension_auto.cpp + manual/ScriptingCore.cpp + manual/cocos2d_specifics.cpp + manual/js_manual_conversions.cpp + manual/js_bindings_core.cpp + manual/js_bindings_opengl.cpp + manual/jsb_opengl_functions.cpp + manual/jsb_opengl_manual.cpp + manual/jsb_opengl_registration.cpp + manual/jsb_event_dispatcher_manual.cpp + manual/chipmunk/js_bindings_chipmunk_manual.cpp + manual/chipmunk/js_bindings_chipmunk_functions.cpp + manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp + manual/chipmunk/js_bindings_chipmunk_registration.cpp + manual/cocosbuilder/js_bindings_ccbreader.cpp + manual/cocostudio/jsb_cocos2dx_studio_manual.cpp + manual/cocostudio/jsb_cocos2dx_studio_conversions.cpp + manual/extension/jsb_cocos2dx_extension_manual.cpp + manual/localstorage/js_bindings_system_functions.cpp + manual/localstorage/js_bindings_system_registration.cpp + manual/network/XMLHTTPRequest.cpp + manual/network/jsb_websocket.cpp + manual/network/jsb_socketio.cpp + manual/spine/jsb_cocos2dx_spine_manual.cpp + manual/ui/jsb_cocos2dx_ui_manual.cpp + manual/3d/jsb_cocos2dx_3d_manual.cpp + ${cocos_root}/cocos/storage/local-storage/LocalStorage.cpp +) + +include_directories( + auto + manual + manual/cocostudio + manual/spine + ${cocos_root}/external/spidermonkey/include/${PLATFORM_FOLDER} + ${cocos_root}/cocos/base + ${cocos_root}/cocos/2d + ${cocos_root}/cocos/ui + ${cocos_root}/cocos/audio/include + ${cocos_root}/cocos/storage + ${cocos_root}/cocos/network + ${cocos_root}/cocos/platform + ${cocos_root}/extensions + ${cocos_root}/external + ${cocos_root}/cocos/editor-support + ${cocos_root}/cocos/editor-support/spine + ${cocos_root}/cocos/editor-support/cocosbuilder + ${cocos_root}/cocos/editor-support/cocostudio + ${cocos_root}/external/chipmunk/include/chipmunk +) + +add_library(jscocos2d STATIC + ${JSBINDING_SRC} +) + +target_link_libraries(jscocos2d + sqlite3 + js_static + xxhash +) + +set_target_properties(jscocos2d + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" +) + diff --git a/cocos/scripting/js-bindings/README.md b/cocos/scripting/js-bindings/README.md new file mode 100644 index 0000000000..ce2547548c --- /dev/null +++ b/cocos/scripting/js-bindings/README.md @@ -0,0 +1,3 @@ +# js-bindings + +This repo is used for js bindings. diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js new file mode 100644 index 0000000000..ccba962350 --- /dev/null +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js @@ -0,0 +1,1520 @@ +/** + * @module cocos2dx_3d + */ +var jsb = jsb || {}; + +/** + * @class Animation3D + */ +jsb.Animation3D = { + +/** + * @method initWithFile + * @param {String} arg0 + * @param {String} arg1 + * @return {bool} + */ +initWithFile : function ( +str, +str +) +{ + return false; +}, + +/** + * @method init + * @param {cc.Animation3DData} arg0 + * @return {bool} + */ +init : function ( +animation3ddata +) +{ + return false; +}, + +/** + * @method getBoneCurveByName + * @param {String} arg0 + * @return {cc.Animation3D::Curve} + */ +getBoneCurveByName : function ( +str +) +{ + return cc.Animation3D::Curve; +}, + +/** + * @method getDuration + * @return {float} + */ +getDuration : function ( +) +{ + return 0; +}, + +/** + * @method create + * @param {String} arg0 + * @param {String} arg1 + * @return {cc.Animation3D} + */ +create : function ( +str, +str +) +{ + return cc.Animation3D; +}, + +/** + * @method Animation3D + * @constructor + */ +Animation3D : function ( +) +{ +}, + +}; + +/** + * @class Animate3D + */ +jsb.Animate3D = { + +/** + * @method getSpeed + * @return {float} + */ +getSpeed : function ( +) +{ + return 0; +}, + +/** + * @method setQuality + * @param {cc.Animate3DQuality} arg0 + */ +setQuality : function ( +animate3dquality +) +{ +}, + +/** + * @method setWeight + * @param {float} arg0 + */ +setWeight : function ( +float +) +{ +}, + +/** + * @method removeFromMap + */ +removeFromMap : function ( +) +{ +}, + +/** + * @method initWithFrames + * @param {cc.Animation3D} arg0 + * @param {int} arg1 + * @param {int} arg2 + * @param {float} arg3 + * @return {bool} + */ +initWithFrames : function ( +animation3d, +int, +int, +float +) +{ + return false; +}, + +/** + * @method getOriginInterval + * @return {float} + */ +getOriginInterval : function ( +) +{ + return 0; +}, + +/** + * @method setSpeed + * @param {float} arg0 + */ +setSpeed : function ( +float +) +{ +}, + +/** + * @method init +* @param {cc.Animation3D|cc.Animation3D} animation3d +* @param {float} float +* @param {float} float +* @return {bool|bool} +*/ +init : function( +animation3d, +float, +float +) +{ + return false; +}, + +/** + * @method setOriginInterval + * @param {float} arg0 + */ +setOriginInterval : function ( +float +) +{ +}, + +/** + * @method getWeight + * @return {float} + */ +getWeight : function ( +) +{ + return 0; +}, + +/** + * @method getQuality + * @return {cc.Animate3DQuality} + */ +getQuality : function ( +) +{ + return 0; +}, + +/** + * @method create +* @param {cc.Animation3D|cc.Animation3D} animation3d +* @param {float} float +* @param {float} float +* @return {cc.Animate3D|cc.Animate3D} +*/ +create : function( +animation3d, +float, +float +) +{ + return cc.Animate3D; +}, + +/** + * @method getTransitionTime + * @return {float} + */ +getTransitionTime : function ( +) +{ + return 0; +}, + +/** + * @method createWithFrames + * @param {cc.Animation3D} arg0 + * @param {int} arg1 + * @param {int} arg2 + * @param {float} arg3 + * @return {cc.Animate3D} + */ +createWithFrames : function ( +animation3d, +int, +int, +float +) +{ + return cc.Animate3D; +}, + +/** + * @method setTransitionTime + * @param {float} arg0 + */ +setTransitionTime : function ( +float +) +{ +}, + +/** + * @method Animate3D + * @constructor + */ +Animate3D : function ( +) +{ +}, + +}; + +/** + * @class Skeleton3D + */ +jsb.Skeleton3D = { + +/** + * @method removeAllBones + */ +removeAllBones : function ( +) +{ +}, + +/** + * @method addBone + * @param {cc.Bone3D} arg0 + */ +addBone : function ( +bone3d +) +{ +}, + +/** + * @method getBoneByName + * @param {String} arg0 + * @return {cc.Bone3D} + */ +getBoneByName : function ( +str +) +{ + return cc.Bone3D; +}, + +/** + * @method getRootBone + * @param {int} arg0 + * @return {cc.Bone3D} + */ +getRootBone : function ( +int +) +{ + return cc.Bone3D; +}, + +/** + * @method updateBoneMatrix + */ +updateBoneMatrix : function ( +) +{ +}, + +/** + * @method getBoneByIndex + * @param {unsigned int} arg0 + * @return {cc.Bone3D} + */ +getBoneByIndex : function ( +int +) +{ + return cc.Bone3D; +}, + +/** + * @method getRootCount + * @return {long} + */ +getRootCount : function ( +) +{ + return 0; +}, + +/** + * @method getBoneIndex + * @param {cc.Bone3D} arg0 + * @return {int} + */ +getBoneIndex : function ( +bone3d +) +{ + return 0; +}, + +/** + * @method getBoneCount + * @return {long} + */ +getBoneCount : function ( +) +{ + return 0; +}, + +/** + * @method Skeleton3D + * @constructor + */ +Skeleton3D : function ( +) +{ +}, + +}; + +/** + * @class Sprite3D + */ +jsb.Sprite3D = { + +/** + * @method setCullFaceEnabled + * @param {bool} arg0 + */ +setCullFaceEnabled : function ( +bool +) +{ +}, + +/** + * @method setTexture +* @param {cc.Texture2D|String} texture2d +*/ +setTexture : function( +str +) +{ +}, + +/** + * @method getLightMask + * @return {unsigned int} + */ +getLightMask : function ( +) +{ + return 0; +}, + +/** + * @method createAttachSprite3DNode + * @param {cc.NodeData} arg0 + * @param {cc.MaterialDatas} arg1 + */ +createAttachSprite3DNode : function ( +nodedata, +materialdatas +) +{ +}, + +/** + * @method loadFromFile + * @param {String} arg0 + * @param {cc.NodeDatas} arg1 + * @param {cc.MeshDatas} arg2 + * @param {cc.MaterialDatas} arg3 + * @return {bool} + */ +loadFromFile : function ( +str, +nodedatas, +meshdatas, +materialdatas +) +{ + return false; +}, + +/** + * @method setCullFace + * @param {unsigned int} arg0 + */ +setCullFace : function ( +int +) +{ +}, + +/** + * @method addMesh + * @param {cc.Mesh} arg0 + */ +addMesh : function ( +mesh +) +{ +}, + +/** + * @method removeAllAttachNode + */ +removeAllAttachNode : function ( +) +{ +}, + +/** + * @method setMaterial +* @param {cc.Material|cc.Material} material +* @param {int} int +*/ +setMaterial : function( +material, +int +) +{ +}, + +/** + * @method genGLProgramState + */ +genGLProgramState : function ( +) +{ +}, + +/** + * @method getMesh + * @return {cc.Mesh} + */ +getMesh : function ( +) +{ + return cc.Mesh; +}, + +/** + * @method createSprite3DNode + * @param {cc.NodeData} arg0 + * @param {cc.ModelData} arg1 + * @param {cc.MaterialDatas} arg2 + * @return {cc.Sprite3D} + */ +createSprite3DNode : function ( +nodedata, +modeldata, +materialdatas +) +{ + return cc.Sprite3D; +}, + +/** + * @method getMeshCount + * @return {long} + */ +getMeshCount : function ( +) +{ + return 0; +}, + +/** + * @method onAABBDirty + */ +onAABBDirty : function ( +) +{ +}, + +/** + * @method getMeshByIndex + * @param {int} arg0 + * @return {cc.Mesh} + */ +getMeshByIndex : function ( +int +) +{ + return cc.Mesh; +}, + +/** + * @method createNode + * @param {cc.NodeData} arg0 + * @param {cc.Node} arg1 + * @param {cc.MaterialDatas} arg2 + * @param {bool} arg3 + */ +createNode : function ( +nodedata, +node, +materialdatas, +bool +) +{ +}, + +/** + * @method isForceDepthWrite + * @return {bool} + */ +isForceDepthWrite : function ( +) +{ + return false; +}, + +/** + * @method getBlendFunc + * @return {cc.BlendFunc} + */ +getBlendFunc : function ( +) +{ + return cc.BlendFunc; +}, + +/** + * @method getMeshIndexData + * @param {String} arg0 + * @return {cc.MeshIndexData} + */ +getMeshIndexData : function ( +str +) +{ + return cc.MeshIndexData; +}, + +/** + * @method removeAttachNode + * @param {String} arg0 + */ +removeAttachNode : function ( +str +) +{ +}, + +/** + * @method setLightMask + * @param {unsigned int} arg0 + */ +setLightMask : function ( +int +) +{ +}, + +/** + * @method afterAsyncLoad + * @param {void} arg0 + */ +afterAsyncLoad : function ( +void +) +{ +}, + +/** + * @method loadFromCache + * @param {String} arg0 + * @return {bool} + */ +loadFromCache : function ( +str +) +{ + return false; +}, + +/** + * @method initFrom + * @param {cc.NodeDatas} arg0 + * @param {cc.MeshDatas} arg1 + * @param {cc.MaterialDatas} arg2 + * @return {bool} + */ +initFrom : function ( +nodedatas, +meshdatas, +materialdatas +) +{ + return false; +}, + +/** + * @method getAttachNode + * @param {String} arg0 + * @return {cc.AttachNode} + */ +getAttachNode : function ( +str +) +{ + return cc.AttachNode; +}, + +/** + * @method initWithFile + * @param {String} arg0 + * @return {bool} + */ +initWithFile : function ( +str +) +{ + return false; +}, + +/** + * @method setBlendFunc + * @param {cc.BlendFunc} arg0 + */ +setBlendFunc : function ( +blendfunc +) +{ +}, + +/** + * @method getSkeleton + * @return {cc.Skeleton3D} + */ +getSkeleton : function ( +) +{ + return cc.Skeleton3D; +}, + +/** + * @method setForceDepthWrite + * @param {bool} arg0 + */ +setForceDepthWrite : function ( +bool +) +{ +}, + +/** + * @method getMeshByName + * @param {String} arg0 + * @return {cc.Mesh} + */ +getMeshByName : function ( +str +) +{ + return cc.Mesh; +}, + +/** + * @method create +* @param {String|String} str +* @param {String} str +* @return {cc.Sprite3D|cc.Sprite3D|cc.Sprite3D} +*/ +create : function( +str, +str +) +{ + return cc.Sprite3D; +}, + +/** + * @method Sprite3D + * @constructor + */ +Sprite3D : function ( +) +{ +}, + +}; + +/** + * @class Sprite3DCache + */ +jsb.Sprite3DCache = { + +/** + * @method removeSprite3DData + * @param {String} arg0 + */ +removeSprite3DData : function ( +str +) +{ +}, + +/** + * @method removeAllSprite3DData + */ +removeAllSprite3DData : function ( +) +{ +}, + +/** + * @method destroyInstance + */ +destroyInstance : function ( +) +{ +}, + +/** + * @method getInstance + * @return {cc.Sprite3DCache} + */ +getInstance : function ( +) +{ + return cc.Sprite3DCache; +}, + +}; + +/** + * @class Mesh + */ +jsb.Mesh = { + +/** + * @method setTexture +* @param {cc.Texture2D|String} texture2d +*/ +setTexture : function( +str +) +{ +}, + +/** + * @method getTexture + * @return {cc.Texture2D} + */ +getTexture : function ( +) +{ + return cc.Texture2D; +}, + +/** + * @method getSkin + * @return {cc.MeshSkin} + */ +getSkin : function ( +) +{ + return cc.MeshSkin; +}, + +/** + * @method getMaterial + * @return {cc.Material} + */ +getMaterial : function ( +) +{ + return cc.Material; +}, + +/** + * @method getVertexSizeInBytes + * @return {int} + */ +getVertexSizeInBytes : function ( +) +{ + return 0; +}, + +/** + * @method setMaterial + * @param {cc.Material} arg0 + */ +setMaterial : function ( +material +) +{ +}, + +/** + * @method getName + * @return {String} + */ +getName : function ( +) +{ + return ; +}, + +/** + * @method getIndexFormat + * @return {unsigned int} + */ +getIndexFormat : function ( +) +{ + return 0; +}, + +/** + * @method getGLProgramState + * @return {cc.GLProgramState} + */ +getGLProgramState : function ( +) +{ + return cc.GLProgramState; +}, + +/** + * @method getVertexBuffer + * @return {unsigned int} + */ +getVertexBuffer : function ( +) +{ + return 0; +}, + +/** + * @method calculateAABB + */ +calculateAABB : function ( +) +{ +}, + +/** + * @method hasVertexAttrib + * @param {int} arg0 + * @return {bool} + */ +hasVertexAttrib : function ( +int +) +{ + return false; +}, + +/** + * @method getBlendFunc + * @return {cc.BlendFunc} + */ +getBlendFunc : function ( +) +{ + return cc.BlendFunc; +}, + +/** + * @method getMeshIndexData + * @return {cc.MeshIndexData} + */ +getMeshIndexData : function ( +) +{ + return cc.MeshIndexData; +}, + +/** + * @method setName + * @param {String} arg0 + */ +setName : function ( +str +) +{ +}, + +/** + * @method getIndexCount + * @return {long} + */ +getIndexCount : function ( +) +{ + return 0; +}, + +/** + * @method setMeshIndexData + * @param {cc.MeshIndexData} arg0 + */ +setMeshIndexData : function ( +meshindexdata +) +{ +}, + +/** + * @method getMeshVertexAttribCount + * @return {long} + */ +getMeshVertexAttribCount : function ( +) +{ + return 0; +}, + +/** + * @method setBlendFunc + * @param {cc.BlendFunc} arg0 + */ +setBlendFunc : function ( +blendfunc +) +{ +}, + +/** + * @method getPrimitiveType + * @return {unsigned int} + */ +getPrimitiveType : function ( +) +{ + return 0; +}, + +/** + * @method setSkin + * @param {cc.MeshSkin} arg0 + */ +setSkin : function ( +meshskin +) +{ +}, + +/** + * @method isVisible + * @return {bool} + */ +isVisible : function ( +) +{ + return false; +}, + +/** + * @method getIndexBuffer + * @return {unsigned int} + */ +getIndexBuffer : function ( +) +{ + return 0; +}, + +/** + * @method setGLProgramState + * @param {cc.GLProgramState} arg0 + */ +setGLProgramState : function ( +glprogramstate +) +{ +}, + +/** + * @method setVisible + * @param {bool} arg0 + */ +setVisible : function ( +bool +) +{ +}, + +/** + * @method Mesh + * @constructor + */ +Mesh : function ( +) +{ +}, + +}; + +/** + * @class AttachNode + */ +jsb.AttachNode = { + +/** + * @method create + * @param {cc.Bone3D} arg0 + * @return {cc.AttachNode} + */ +create : function ( +bone3d +) +{ + return cc.AttachNode; +}, + +/** + * @method AttachNode + * @constructor + */ +AttachNode : function ( +) +{ +}, + +}; + +/** + * @class BillBoard + */ +jsb.BillBoard = { + +/** + * @method getMode + * @return {cc.BillBoard::Mode} + */ +getMode : function ( +) +{ + return 0; +}, + +/** + * @method setMode + * @param {cc.BillBoard::Mode} arg0 + */ +setMode : function ( +mode +) +{ +}, + +/** + * @method create +* @param {String|cc.BillBoard::Mode|String} str +* @param {cc.BillBoard::Mode|rect_object} mode +* @param {cc.BillBoard::Mode} mode +* @return {cc.BillBoard|cc.BillBoard|cc.BillBoard} +*/ +create : function( +str, +rect, +mode +) +{ + return cc.BillBoard; +}, + +/** + * @method createWithTexture + * @param {cc.Texture2D} arg0 + * @param {cc.BillBoard::Mode} arg1 + * @return {cc.BillBoard} + */ +createWithTexture : function ( +texture2d, +mode +) +{ + return cc.BillBoard; +}, + +/** + * @method BillBoard + * @constructor + */ +BillBoard : function ( +) +{ +}, + +}; + +/** + * @class TextureCube + */ +jsb.TextureCube = { + +/** + * @method reloadTexture + * @return {bool} + */ +reloadTexture : function ( +) +{ + return false; +}, + +/** + * @method create + * @param {String} arg0 + * @param {String} arg1 + * @param {String} arg2 + * @param {String} arg3 + * @param {String} arg4 + * @param {String} arg5 + * @return {cc.TextureCube} + */ +create : function ( +str, +str, +str, +str, +str, +str +) +{ + return cc.TextureCube; +}, + +/** + * @method TextureCube + * @constructor + */ +TextureCube : function ( +) +{ +}, + +}; + +/** + * @class Skybox + */ +jsb.Skybox = { + +/** + * @method reload + */ +reload : function ( +) +{ +}, + +/** + * @method init +* @param {String} str +* @param {String} str +* @param {String} str +* @param {String} str +* @param {String} str +* @param {String} str +* @return {bool|bool} +*/ +init : function( +str, +str, +str, +str, +str, +str +) +{ + return false; +}, + +/** + * @method setTexture + * @param {cc.TextureCube} arg0 + */ +setTexture : function ( +texturecube +) +{ +}, + +/** + * @method create +* @param {String} str +* @param {String} str +* @param {String} str +* @param {String} str +* @param {String} str +* @param {String} str +* @return {cc.Skybox|cc.Skybox} +*/ +create : function( +str, +str, +str, +str, +str, +str +) +{ + return cc.Skybox; +}, + +/** + * @method Skybox + * @constructor + */ +Skybox : function ( +) +{ +}, + +}; + +/** + * @class Terrain + */ +jsb.Terrain = { + +/** + * @method initHeightMap + * @param {char} arg0 + * @return {bool} + */ +initHeightMap : function ( +char +) +{ + return false; +}, + +/** + * @method setMaxDetailMapAmount + * @param {int} arg0 + */ +setMaxDetailMapAmount : function ( +int +) +{ +}, + +/** + * @method setDrawWire + * @param {bool} arg0 + */ +setDrawWire : function ( +bool +) +{ +}, + +/** + * @method setIsEnableFrustumCull + * @param {bool} arg0 + */ +setIsEnableFrustumCull : function ( +bool +) +{ +}, + +/** + * @method getHeightData + * @return {Array} + */ +getHeightData : function ( +) +{ + return new Array(); +}, + +/** + * @method setDetailMap + * @param {unsigned int} arg0 + * @param {cc.Terrain::DetailMap} arg1 + */ +setDetailMap : function ( +int, +map +) +{ +}, + +/** + * @method resetHeightMap + * @param {char} arg0 + */ +resetHeightMap : function ( +char +) +{ +}, + +/** + * @method setAlphaMap + * @param {cc.Texture2D} arg0 + */ +setAlphaMap : function ( +texture2d +) +{ +}, + +/** + * @method setSkirtHeightRatio + * @param {float} arg0 + */ +setSkirtHeightRatio : function ( +float +) +{ +}, + +/** + * @method convertToTerrainSpace + * @param {vec2_object} arg0 + * @return {vec2_object} + */ +convertToTerrainSpace : function ( +vec2 +) +{ + return cc.Vec2; +}, + +/** + * @method initTextures + * @return {bool} + */ +initTextures : function ( +) +{ + return false; +}, + +/** + * @method initProperties + * @return {bool} + */ +initProperties : function ( +) +{ + return false; +}, + +/** + * @method getHeight +* @param {vec2_object|float} vec2 +* @param {vec3_object|float} vec3 +* @param {vec3_object} vec3 +* @return {float|float} +*/ +getHeight : function( +float, +float, +vec3 +) +{ + return 0; +}, + +/** + * @method setLODDistance + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + */ +setLODDistance : function ( +float, +float, +float +) +{ +}, + +/** + * @method getTerrainSize + * @return {size_object} + */ +getTerrainSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method getIntersectionPoint + * @param {cc.Ray} arg0 + * @return {vec3_object} + */ +getIntersectionPoint : function ( +ray +) +{ + return cc.Vec3; +}, + +/** + * @method getNormal + * @param {int} arg0 + * @param {int} arg1 + * @return {vec3_object} + */ +getNormal : function ( +int, +int +) +{ + return cc.Vec3; +}, + +/** + * @method reload + */ +reload : function ( +) +{ +}, + +/** + * @method getImageHeight + * @param {int} arg0 + * @param {int} arg1 + * @return {float} + */ +getImageHeight : function ( +int, +int +) +{ + return 0; +}, + +/** + * @method getMaxHeight + * @return {float} + */ +getMaxHeight : function ( +) +{ + return 0; +}, + +/** + * @method getMinHeight + * @return {float} + */ +getMinHeight : function ( +) +{ + return 0; +}, + +}; diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_extension_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_extension_auto_api.js new file mode 100644 index 0000000000..2a5567ec3b --- /dev/null +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_extension_auto_api.js @@ -0,0 +1,510 @@ +/** + * @module cocos2dx_3d_extension + */ +var jsb = jsb || {}; + +/** + * @class ParticleSystem3D + */ +jsb.ParticleSystem3D = { + +/** + * @method resumeParticleSystem + */ +resumeParticleSystem : function ( +) +{ +}, + +/** + * @method startParticleSystem + */ +startParticleSystem : function ( +) +{ +}, + +/** + * @method isEnabled + * @return {bool} + */ +isEnabled : function ( +) +{ + return false; +}, + +/** + * @method isKeepLocal + * @return {bool} + */ +isKeepLocal : function ( +) +{ + return false; +}, + +/** + * @method setEnabled + * @param {bool} arg0 + */ +setEnabled : function ( +bool +) +{ +}, + +/** + * @method getParticleQuota + * @return {unsigned int} + */ +getParticleQuota : function ( +) +{ + return 0; +}, + +/** + * @method getBlendFunc + * @return {cc.BlendFunc} + */ +getBlendFunc : function ( +) +{ + return cc.BlendFunc; +}, + +/** + * @method pauseParticleSystem + */ +pauseParticleSystem : function ( +) +{ +}, + +/** + * @method getState + * @return {cc.ParticleSystem3D::State} + */ +getState : function ( +) +{ + return 0; +}, + +/** + * @method getAliveParticleCount + * @return {int} + */ +getAliveParticleCount : function ( +) +{ + return 0; +}, + +/** + * @method setParticleQuota + * @param {unsigned int} arg0 + */ +setParticleQuota : function ( +int +) +{ +}, + +/** + * @method setBlendFunc + * @param {cc.BlendFunc} arg0 + */ +setBlendFunc : function ( +blendfunc +) +{ +}, + +/** + * @method stopParticleSystem + */ +stopParticleSystem : function ( +) +{ +}, + +/** + * @method setKeepLocal + * @param {bool} arg0 + */ +setKeepLocal : function ( +bool +) +{ +}, + +/** + * @method ParticleSystem3D + * @constructor + */ +ParticleSystem3D : function ( +) +{ +}, + +}; + +/** + * @class PUParticleSystem3D + */ +jsb.PUParticleSystem3D = { + +/** + * @method initWithFilePath + * @param {String} arg0 + * @return {bool} + */ +initWithFilePath : function ( +str +) +{ + return false; +}, + +/** + * @method getParticleSystemScaleVelocity + * @return {float} + */ +getParticleSystemScaleVelocity : function ( +) +{ + return 0; +}, + +/** + * @method setEmittedSystemQuota + * @param {unsigned int} arg0 + */ +setEmittedSystemQuota : function ( +int +) +{ +}, + +/** + * @method getDefaultDepth + * @return {float} + */ +getDefaultDepth : function ( +) +{ + return 0; +}, + +/** + * @method getEmittedSystemQuota + * @return {unsigned int} + */ +getEmittedSystemQuota : function ( +) +{ + return 0; +}, + +/** + * @method initWithFilePathAndMaterialPath + * @param {String} arg0 + * @param {String} arg1 + * @return {bool} + */ +initWithFilePathAndMaterialPath : function ( +str, +str +) +{ + return false; +}, + +/** + * @method clearAllParticles + */ +clearAllParticles : function ( +) +{ +}, + +/** + * @method getMaterialName + * @return {String} + */ +getMaterialName : function ( +) +{ + return ; +}, + +/** + * @method calulateRotationOffset + */ +calulateRotationOffset : function ( +) +{ +}, + +/** + * @method getMaxVelocity + * @return {float} + */ +getMaxVelocity : function ( +) +{ + return 0; +}, + +/** + * @method forceUpdate + * @param {float} arg0 + */ +forceUpdate : function ( +float +) +{ +}, + +/** + * @method getTimeElapsedSinceStart + * @return {float} + */ +getTimeElapsedSinceStart : function ( +) +{ + return 0; +}, + +/** + * @method getEmittedEmitterQuota + * @return {unsigned int} + */ +getEmittedEmitterQuota : function ( +) +{ + return 0; +}, + +/** + * @method isMarkedForEmission + * @return {bool} + */ +isMarkedForEmission : function ( +) +{ + return false; +}, + +/** + * @method getDefaultWidth + * @return {float} + */ +getDefaultWidth : function ( +) +{ + return 0; +}, + +/** + * @method setEmittedEmitterQuota + * @param {unsigned int} arg0 + */ +setEmittedEmitterQuota : function ( +int +) +{ +}, + +/** + * @method setMarkedForEmission + * @param {bool} arg0 + */ +setMarkedForEmission : function ( +bool +) +{ +}, + +/** + * @method clone + * @return {cc.PUParticleSystem3D} + */ +clone : function ( +) +{ + return cc.PUParticleSystem3D; +}, + +/** + * @method setDefaultWidth + * @param {float} arg0 + */ +setDefaultWidth : function ( +float +) +{ +}, + +/** + * @method copyAttributesTo + * @param {cc.PUParticleSystem3D} arg0 + */ +copyAttributesTo : function ( +puparticlesystem3d +) +{ +}, + +/** + * @method setMaterialName + * @param {String} arg0 + */ +setMaterialName : function ( +str +) +{ +}, + +/** + * @method getParentParticleSystem + * @return {cc.PUParticleSystem3D} + */ +getParentParticleSystem : function ( +) +{ + return cc.PUParticleSystem3D; +}, + +/** + * @method setMaxVelocity + * @param {float} arg0 + */ +setMaxVelocity : function ( +float +) +{ +}, + +/** + * @method getDefaultHeight + * @return {float} + */ +getDefaultHeight : function ( +) +{ + return 0; +}, + +/** + * @method getDerivedPosition + * @return {vec3_object} + */ +getDerivedPosition : function ( +) +{ + return cc.Vec3; +}, + +/** + * @method rotationOffset + * @param {vec3_object} arg0 + */ +rotationOffset : function ( +vec3 +) +{ +}, + +/** + * @method getDerivedOrientation + * @return {cc.Quaternion} + */ +getDerivedOrientation : function ( +) +{ + return cc.Quaternion; +}, + +/** + * @method removeAllEmitter + */ +removeAllEmitter : function ( +) +{ +}, + +/** + * @method setParticleSystemScaleVelocity + * @param {float} arg0 + */ +setParticleSystemScaleVelocity : function ( +float +) +{ +}, + +/** + * @method getDerivedScale + * @return {vec3_object} + */ +getDerivedScale : function ( +) +{ + return cc.Vec3; +}, + +/** + * @method setDefaultHeight + * @param {float} arg0 + */ +setDefaultHeight : function ( +float +) +{ +}, + +/** + * @method removeAllListener + */ +removeAllListener : function ( +) +{ +}, + +/** + * @method setDefaultDepth + * @param {float} arg0 + */ +setDefaultDepth : function ( +float +) +{ +}, + +/** + * @method create +* @param {String|String} str +* @param {String} str +* @return {cc.PUParticleSystem3D|cc.PUParticleSystem3D|cc.PUParticleSystem3D} +*/ +create : function( +str, +str +) +{ + return cc.PUParticleSystem3D; +}, + +/** + * @method PUParticleSystem3D + * @constructor + */ +PUParticleSystem3D : function ( +) +{ +}, + +}; diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js new file mode 100644 index 0000000000..02f3e0a73c --- /dev/null +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js @@ -0,0 +1,21698 @@ +/** + * @module cocos2dx + */ +var cc = cc || {}; + +/** + * @class Action + */ +cc.Action = { + +/** + * @method startWithTarget + * @param {cc.Node} arg0 + */ +startWithTarget : function ( +node +) +{ +}, + +/** + * @method setOriginalTarget + * @param {cc.Node} arg0 + */ +setOriginalTarget : function ( +node +) +{ +}, + +/** + * @method clone + * @return {cc.Action} + */ +clone : function ( +) +{ + return cc.Action; +}, + +/** + * @method getOriginalTarget + * @return {cc.Node} + */ +getOriginalTarget : function ( +) +{ + return cc.Node; +}, + +/** + * @method stop + */ +stop : function ( +) +{ +}, + +/** + * @method update + * @param {float} arg0 + */ +update : function ( +float +) +{ +}, + +/** + * @method getTarget + * @return {cc.Node} + */ +getTarget : function ( +) +{ + return cc.Node; +}, + +/** + * @method step + * @param {float} arg0 + */ +step : function ( +float +) +{ +}, + +/** + * @method setTag + * @param {int} arg0 + */ +setTag : function ( +int +) +{ +}, + +/** + * @method getTag + * @return {int} + */ +getTag : function ( +) +{ + return 0; +}, + +/** + * @method setTarget + * @param {cc.Node} arg0 + */ +setTarget : function ( +node +) +{ +}, + +/** + * @method isDone + * @return {bool} + */ +isDone : function ( +) +{ + return false; +}, + +/** + * @method reverse + * @return {cc.Action} + */ +reverse : function ( +) +{ + return cc.Action; +}, + +}; + +/** + * @class FiniteTimeAction + */ +cc.FiniteTimeAction = { + +/** + * @method setDuration + * @param {float} arg0 + */ +setDuration : function ( +float +) +{ +}, + +/** + * @method getDuration + * @return {float} + */ +getDuration : function ( +) +{ + return 0; +}, + +}; + +/** + * @class Speed + */ +cc.Speed = { + +/** + * @method setInnerAction + * @param {cc.ActionInterval} arg0 + */ +setInnerAction : function ( +actioninterval +) +{ +}, + +/** + * @method getSpeed + * @return {float} + */ +getSpeed : function ( +) +{ + return 0; +}, + +/** + * @method setSpeed + * @param {float} arg0 + */ +setSpeed : function ( +float +) +{ +}, + +/** + * @method initWithAction + * @param {cc.ActionInterval} arg0 + * @param {float} arg1 + * @return {bool} + */ +initWithAction : function ( +actioninterval, +float +) +{ + return false; +}, + +/** + * @method getInnerAction + * @return {cc.ActionInterval} + */ +getInnerAction : function ( +) +{ + return cc.ActionInterval; +}, + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @param {float} arg1 + * @return {cc.Speed} + */ +create : function ( +actioninterval, +float +) +{ + return cc.Speed; +}, + +/** + * @method Speed + * @constructor + */ +Speed : function ( +) +{ +}, + +}; + +/** + * @class Follow + */ +cc.Follow = { + +/** + * @method setBoundarySet + * @param {bool} arg0 + */ +setBoundarySet : function ( +bool +) +{ +}, + +/** + * @method initWithTarget + * @param {cc.Node} arg0 + * @param {rect_object} arg1 + * @return {bool} + */ +initWithTarget : function ( +node, +rect +) +{ + return false; +}, + +/** + * @method isBoundarySet + * @return {bool} + */ +isBoundarySet : function ( +) +{ + return false; +}, + +/** + * @method create + * @param {cc.Node} arg0 + * @param {rect_object} arg1 + * @return {cc.Follow} + */ +create : function ( +node, +rect +) +{ + return cc.Follow; +}, + +/** + * @method Follow + * @constructor + */ +Follow : function ( +) +{ +}, + +}; + +/** + * @class Texture2D + */ +cc.Texture2D = { + +/** + * @method getGLProgram + * @return {cc.GLProgram} + */ +getGLProgram : function ( +) +{ + return cc.GLProgram; +}, + +/** + * @method getMaxT + * @return {float} + */ +getMaxT : function ( +) +{ + return 0; +}, + +/** + * @method getStringForFormat + * @return {char} + */ +getStringForFormat : function ( +) +{ + return 0; +}, + +/** + * @method initWithImage +* @param {cc.Image|cc.Image} image +* @param {cc.Texture2D::PixelFormat} pixelformat +* @return {bool|bool} +*/ +initWithImage : function( +image, +pixelformat +) +{ + return false; +}, + +/** + * @method setGLProgram + * @param {cc.GLProgram} arg0 + */ +setGLProgram : function ( +glprogram +) +{ +}, + +/** + * @method getMaxS + * @return {float} + */ +getMaxS : function ( +) +{ + return 0; +}, + +/** + * @method releaseGLTexture + */ +releaseGLTexture : function ( +) +{ +}, + +/** + * @method hasPremultipliedAlpha + * @return {bool} + */ +hasPremultipliedAlpha : function ( +) +{ + return false; +}, + +/** + * @method initWithMipmaps + * @param {cc._MipmapInfo} arg0 + * @param {int} arg1 + * @param {cc.Texture2D::PixelFormat} arg2 + * @param {int} arg3 + * @param {int} arg4 + * @return {bool} + */ +initWithMipmaps : function ( +map, +int, +pixelformat, +int, +int +) +{ + return false; +}, + +/** + * @method getPixelsHigh + * @return {int} + */ +getPixelsHigh : function ( +) +{ + return 0; +}, + +/** + * @method getBitsPerPixelForFormat +* @param {cc.Texture2D::PixelFormat} pixelformat +* @return {unsigned int|unsigned int} +*/ +getBitsPerPixelForFormat : function( +pixelformat +) +{ + return 0; +}, + +/** + * @method getName + * @return {unsigned int} + */ +getName : function ( +) +{ + return 0; +}, + +/** + * @method initWithString +* @param {char|char} char +* @param {cc.FontDefinition|String} fontdefinition +* @param {float} float +* @param {size_object} size +* @param {cc.TextHAlignment} texthalignment +* @param {cc.TextVAlignment} textvalignment +* @return {bool|bool} +*/ +initWithString : function( +char, +str, +float, +size, +texthalignment, +textvalignment +) +{ + return false; +}, + +/** + * @method setMaxT + * @param {float} arg0 + */ +setMaxT : function ( +float +) +{ +}, + +/** + * @method drawInRect + * @param {rect_object} arg0 + */ +drawInRect : function ( +rect +) +{ +}, + +/** + * @method getContentSize + * @return {size_object} + */ +getContentSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method setAliasTexParameters + */ +setAliasTexParameters : function ( +) +{ +}, + +/** + * @method setAntiAliasTexParameters + */ +setAntiAliasTexParameters : function ( +) +{ +}, + +/** + * @method generateMipmap + */ +generateMipmap : function ( +) +{ +}, + +/** + * @method getDescription + * @return {String} + */ +getDescription : function ( +) +{ + return ; +}, + +/** + * @method getPixelFormat + * @return {cc.Texture2D::PixelFormat} + */ +getPixelFormat : function ( +) +{ + return 0; +}, + +/** + * @method getContentSizeInPixels + * @return {size_object} + */ +getContentSizeInPixels : function ( +) +{ + return cc.Size; +}, + +/** + * @method getPixelsWide + * @return {int} + */ +getPixelsWide : function ( +) +{ + return 0; +}, + +/** + * @method drawAtPoint + * @param {vec2_object} arg0 + */ +drawAtPoint : function ( +vec2 +) +{ +}, + +/** + * @method hasMipmaps + * @return {bool} + */ +hasMipmaps : function ( +) +{ + return false; +}, + +/** + * @method setMaxS + * @param {float} arg0 + */ +setMaxS : function ( +float +) +{ +}, + +/** + * @method setDefaultAlphaPixelFormat + * @param {cc.Texture2D::PixelFormat} arg0 + */ +setDefaultAlphaPixelFormat : function ( +pixelformat +) +{ +}, + +/** + * @method getDefaultAlphaPixelFormat + * @return {cc.Texture2D::PixelFormat} + */ +getDefaultAlphaPixelFormat : function ( +) +{ + return 0; +}, + +/** + * @method Texture2D + * @constructor + */ +Texture2D : function ( +) +{ +}, + +}; + +/** + * @class Touch + */ +cc.Touch = { + +/** + * @method getPreviousLocationInView + * @return {vec2_object} + */ +getPreviousLocationInView : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getLocation + * @return {vec2_object} + */ +getLocation : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getDelta + * @return {vec2_object} + */ +getDelta : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getStartLocationInView + * @return {vec2_object} + */ +getStartLocationInView : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getStartLocation + * @return {vec2_object} + */ +getStartLocation : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getID + * @return {int} + */ +getID : function ( +) +{ + return 0; +}, + +/** + * @method setTouchInfo + * @param {int} arg0 + * @param {float} arg1 + * @param {float} arg2 + */ +setTouchInfo : function ( +int, +float, +float +) +{ +}, + +/** + * @method getLocationInView + * @return {vec2_object} + */ +getLocationInView : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getPreviousLocation + * @return {vec2_object} + */ +getPreviousLocation : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method Touch + * @constructor + */ +Touch : function ( +) +{ +}, + +}; + +/** + * @class Event + */ +cc.Event = { + +/** + * @method isStopped + * @return {bool} + */ +isStopped : function ( +) +{ + return false; +}, + +/** + * @method getType + * @return {cc.Event::Type} + */ +getType : function ( +) +{ + return 0; +}, + +/** + * @method getCurrentTarget + * @return {cc.Node} + */ +getCurrentTarget : function ( +) +{ + return cc.Node; +}, + +/** + * @method stopPropagation + */ +stopPropagation : function ( +) +{ +}, + +/** + * @method Event + * @constructor + * @param {cc.Event::Type} arg0 + */ +Event : function ( +type +) +{ +}, + +}; + +/** + * @class EventTouch + */ +cc.EventTouch = { + +/** + * @method getEventCode + * @return {cc.EventTouch::EventCode} + */ +getEventCode : function ( +) +{ + return 0; +}, + +/** + * @method setEventCode + * @param {cc.EventTouch::EventCode} arg0 + */ +setEventCode : function ( +eventcode +) +{ +}, + +/** + * @method EventTouch + * @constructor + */ +EventTouch : function ( +) +{ +}, + +}; + +/** + * @class Node + */ +cc.Node = { + +/** + * @method addChild +* @param {cc.Node|cc.Node|cc.Node|cc.Node} node +* @param {int|int|int} int +* @param {int|String} int +*/ +addChild : function( +node, +int, +str +) +{ +}, + +/** + * @method removeComponent +* @param {cc.Component|String} component +* @return {bool|bool} +*/ +removeComponent : function( +str +) +{ + return false; +}, + +/** + * @method setPhysicsBody + * @param {cc.PhysicsBody} arg0 + */ +setPhysicsBody : function ( +physicsbody +) +{ +}, + +/** + * @method getGLProgram + * @return {cc.GLProgram} + */ +getGLProgram : function ( +) +{ + return cc.GLProgram; +}, + +/** + * @method updateTransformFromPhysics + * @param {mat4_object} arg0 + * @param {unsigned int} arg1 + */ +updateTransformFromPhysics : function ( +mat4, +int +) +{ +}, + +/** + * @method getDescription + * @return {String} + */ +getDescription : function ( +) +{ + return ; +}, + +/** + * @method setOpacityModifyRGB + * @param {bool} arg0 + */ +setOpacityModifyRGB : function ( +bool +) +{ +}, + +/** + * @method setCascadeOpacityEnabled + * @param {bool} arg0 + */ +setCascadeOpacityEnabled : function ( +bool +) +{ +}, + +/** + * @method getChildren +* @return {Array|Array} +*/ +getChildren : function( +) +{ + return new Array(); +}, + +/** + * @method setOnExitCallback + * @param {function} arg0 + */ +setOnExitCallback : function ( +func +) +{ +}, + +/** + * @method isIgnoreAnchorPointForPosition + * @return {bool} + */ +isIgnoreAnchorPointForPosition : function ( +) +{ + return false; +}, + +/** + * @method getChildByName + * @param {String} arg0 + * @return {cc.Node} + */ +getChildByName : function ( +str +) +{ + return cc.Node; +}, + +/** + * @method updateDisplayedOpacity + * @param {unsigned char} arg0 + */ +updateDisplayedOpacity : function ( +char +) +{ +}, + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method getCameraMask + * @return {unsigned short} + */ +getCameraMask : function ( +) +{ + return 0; +}, + +/** + * @method setRotation + * @param {float} arg0 + */ +setRotation : function ( +float +) +{ +}, + +/** + * @method setScaleZ + * @param {float} arg0 + */ +setScaleZ : function ( +float +) +{ +}, + +/** + * @method setScaleY + * @param {float} arg0 + */ +setScaleY : function ( +float +) +{ +}, + +/** + * @method setScaleX + * @param {float} arg0 + */ +setScaleX : function ( +float +) +{ +}, + +/** + * @method getColor + * @return {color3b_object} + */ +getColor : function ( +) +{ + return cc.Color3B; +}, + +/** + * @method setonEnterTransitionDidFinishCallback + * @param {function} arg0 + */ +setonEnterTransitionDidFinishCallback : function ( +func +) +{ +}, + +/** + * @method removeFromPhysicsWorld + */ +removeFromPhysicsWorld : function ( +) +{ +}, + +/** + * @method removeAllComponents + */ +removeAllComponents : function ( +) +{ +}, + +/** + * @method getOpacity + * @return {unsigned char} + */ +getOpacity : function ( +) +{ + return 0; +}, + +/** + * @method setCameraMask + * @param {unsigned short} arg0 + * @param {bool} arg1 + */ +setCameraMask : function ( +short, +bool +) +{ +}, + +/** + * @method getTag + * @return {int} + */ +getTag : function ( +) +{ + return 0; +}, + +/** + * @method getonEnterTransitionDidFinishCallback + * @return {function} + */ +getonEnterTransitionDidFinishCallback : function ( +) +{ + return std::function; +}, + +/** + * @method isOpacityModifyRGB + * @return {bool} + */ +isOpacityModifyRGB : function ( +) +{ + return false; +}, + +/** + * @method getNodeToWorldAffineTransform + * @return {cc.AffineTransform} + */ +getNodeToWorldAffineTransform : function ( +) +{ + return cc.AffineTransform; +}, + +/** + * @method getPosition3D + * @return {vec3_object} + */ +getPosition3D : function ( +) +{ + return cc.Vec3; +}, + +/** + * @method removeChild + * @param {cc.Node} arg0 + * @param {bool} arg1 + */ +removeChild : function ( +node, +bool +) +{ +}, + +/** + * @method getScene + * @return {cc.Scene} + */ +getScene : function ( +) +{ + return cc.Scene; +}, + +/** + * @method getEventDispatcher + * @return {cc.EventDispatcher} + */ +getEventDispatcher : function ( +) +{ + return cc.EventDispatcher; +}, + +/** + * @method setSkewX + * @param {float} arg0 + */ +setSkewX : function ( +float +) +{ +}, + +/** + * @method setGLProgramState + * @param {cc.GLProgramState} arg0 + */ +setGLProgramState : function ( +glprogramstate +) +{ +}, + +/** + * @method setOnEnterCallback + * @param {function} arg0 + */ +setOnEnterCallback : function ( +func +) +{ +}, + +/** + * @method setNormalizedPosition + * @param {vec2_object} arg0 + */ +setNormalizedPosition : function ( +vec2 +) +{ +}, + +/** + * @method setonExitTransitionDidStartCallback + * @param {function} arg0 + */ +setonExitTransitionDidStartCallback : function ( +func +) +{ +}, + +/** + * @method convertTouchToNodeSpace + * @param {cc.Touch} arg0 + * @return {vec2_object} + */ +convertTouchToNodeSpace : function ( +touch +) +{ + return cc.Vec2; +}, + +/** + * @method removeAllChildrenWithCleanup +* @param {bool} bool +*/ +removeAllChildrenWithCleanup : function( +bool +) +{ +}, + +/** + * @method getRotationSkewX + * @return {float} + */ +getRotationSkewX : function ( +) +{ + return 0; +}, + +/** + * @method getRotationSkewY + * @return {float} + */ +getRotationSkewY : function ( +) +{ + return 0; +}, + +/** + * @method getNodeToWorldTransform + * @return {mat4_object} + */ +getNodeToWorldTransform : function ( +) +{ + return cc.Mat4; +}, + +/** + * @method isCascadeOpacityEnabled + * @return {bool} + */ +isCascadeOpacityEnabled : function ( +) +{ + return false; +}, + +/** + * @method setParent + * @param {cc.Node} arg0 + */ +setParent : function ( +node +) +{ +}, + +/** + * @method getName + * @return {String} + */ +getName : function ( +) +{ + return ; +}, + +/** + * @method getRotation3D + * @return {vec3_object} + */ +getRotation3D : function ( +) +{ + return cc.Vec3; +}, + +/** + * @method getNodeToParentAffineTransform + * @return {cc.AffineTransform} + */ +getNodeToParentAffineTransform : function ( +) +{ + return cc.AffineTransform; +}, + +/** + * @method convertTouchToNodeSpaceAR + * @param {cc.Touch} arg0 + * @return {vec2_object} + */ +convertTouchToNodeSpaceAR : function ( +touch +) +{ + return cc.Vec2; +}, + +/** + * @method getOnEnterCallback + * @return {function} + */ +getOnEnterCallback : function ( +) +{ + return std::function; +}, + +/** + * @method getPhysicsBody + * @return {cc.PhysicsBody} + */ +getPhysicsBody : function ( +) +{ + return cc.PhysicsBody; +}, + +/** + * @method stopActionByTag + * @param {int} arg0 + */ +stopActionByTag : function ( +int +) +{ +}, + +/** + * @method reorderChild + * @param {cc.Node} arg0 + * @param {int} arg1 + */ +reorderChild : function ( +node, +int +) +{ +}, + +/** + * @method ignoreAnchorPointForPosition + * @param {bool} arg0 + */ +ignoreAnchorPointForPosition : function ( +bool +) +{ +}, + +/** + * @method setSkewY + * @param {float} arg0 + */ +setSkewY : function ( +float +) +{ +}, + +/** + * @method setRotation3D + * @param {vec3_object} arg0 + */ +setRotation3D : function ( +vec3 +) +{ +}, + +/** + * @method setPositionX + * @param {float} arg0 + */ +setPositionX : function ( +float +) +{ +}, + +/** + * @method setNodeToParentTransform + * @param {mat4_object} arg0 + */ +setNodeToParentTransform : function ( +mat4 +) +{ +}, + +/** + * @method getAnchorPoint + * @return {vec2_object} + */ +getAnchorPoint : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getNumberOfRunningActions + * @return {long} + */ +getNumberOfRunningActions : function ( +) +{ + return 0; +}, + +/** + * @method updateTransform + */ +updateTransform : function ( +) +{ +}, + +/** + * @method isVisible + * @return {bool} + */ +isVisible : function ( +) +{ + return false; +}, + +/** + * @method getChildrenCount + * @return {long} + */ +getChildrenCount : function ( +) +{ + return 0; +}, + +/** + * @method getNodeToParentTransform + * @return {mat4_object} + */ +getNodeToParentTransform : function ( +) +{ + return cc.Mat4; +}, + +/** + * @method convertToNodeSpaceAR + * @param {vec2_object} arg0 + * @return {vec2_object} + */ +convertToNodeSpaceAR : function ( +vec2 +) +{ + return cc.Vec2; +}, + +/** + * @method addComponent + * @param {cc.Component} arg0 + * @return {bool} + */ +addComponent : function ( +component +) +{ + return false; +}, + +/** + * @method runAction + * @param {cc.Action} arg0 + * @return {cc.Action} + */ +runAction : function ( +action +) +{ + return cc.Action; +}, + +/** + * @method visit +* @param {cc.Renderer} renderer +* @param {mat4_object} mat4 +* @param {unsigned int} int +*/ +visit : function( +renderer, +mat4, +int +) +{ +}, + +/** + * @method setGLProgram + * @param {cc.GLProgram} arg0 + */ +setGLProgram : function ( +glprogram +) +{ +}, + +/** + * @method getRotation + * @return {float} + */ +getRotation : function ( +) +{ + return 0; +}, + +/** + * @method getAnchorPointInPoints + * @return {vec2_object} + */ +getAnchorPointInPoints : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getRotationQuat + * @return {cc.Quaternion} + */ +getRotationQuat : function ( +) +{ + return cc.Quaternion; +}, + +/** + * @method removeChildByName + * @param {String} arg0 + * @param {bool} arg1 + */ +removeChildByName : function ( +str, +bool +) +{ +}, + +/** + * @method setPositionZ + * @param {float} arg0 + */ +setPositionZ : function ( +float +) +{ +}, + +/** + * @method getGLProgramState + * @return {cc.GLProgramState} + */ +getGLProgramState : function ( +) +{ + return cc.GLProgramState; +}, + +/** + * @method setScheduler + * @param {cc.Scheduler} arg0 + */ +setScheduler : function ( +scheduler +) +{ +}, + +/** + * @method stopAllActions + */ +stopAllActions : function ( +) +{ +}, + +/** + * @method getSkewX + * @return {float} + */ +getSkewX : function ( +) +{ + return 0; +}, + +/** + * @method getSkewY + * @return {float} + */ +getSkewY : function ( +) +{ + return 0; +}, + +/** + * @method isScheduled + * @param {String} arg0 + * @return {bool} + */ +isScheduled : function ( +str +) +{ + return false; +}, + +/** + * @method getDisplayedColor + * @return {color3b_object} + */ +getDisplayedColor : function ( +) +{ + return cc.Color3B; +}, + +/** + * @method getActionByTag + * @param {int} arg0 + * @return {cc.Action} + */ +getActionByTag : function ( +int +) +{ + return cc.Action; +}, + +/** + * @method setRotationSkewX + * @param {float} arg0 + */ +setRotationSkewX : function ( +float +) +{ +}, + +/** + * @method setRotationSkewY + * @param {float} arg0 + */ +setRotationSkewY : function ( +float +) +{ +}, + +/** + * @method setName + * @param {String} arg0 + */ +setName : function ( +str +) +{ +}, + +/** + * @method updatePhysicsBodyTransform + * @param {mat4_object} arg0 + * @param {unsigned int} arg1 + * @param {float} arg2 + * @param {float} arg3 + */ +updatePhysicsBodyTransform : function ( +mat4, +int, +float, +float +) +{ +}, + +/** + * @method getDisplayedOpacity + * @return {unsigned char} + */ +getDisplayedOpacity : function ( +) +{ + return 0; +}, + +/** + * @method getLocalZOrder + * @return {int} + */ +getLocalZOrder : function ( +) +{ + return 0; +}, + +/** + * @method getScheduler +* @return {cc.Scheduler|cc.Scheduler} +*/ +getScheduler : function( +) +{ + return cc.Scheduler; +}, + +/** + * @method getOrderOfArrival + * @return {int} + */ +getOrderOfArrival : function ( +) +{ + return 0; +}, + +/** + * @method setActionManager + * @param {cc.ActionManager} arg0 + */ +setActionManager : function ( +actionmanager +) +{ +}, + +/** + * @method getPosition +* @param {float} float +* @param {float} float +* @return {vec2_object} +*/ +getPosition : function( +float, +float +) +{ +}, + +/** + * @method isRunning + * @return {bool} + */ +isRunning : function ( +) +{ + return false; +}, + +/** + * @method getParent +* @return {cc.Node|cc.Node} +*/ +getParent : function( +) +{ + return cc.Node; +}, + +/** + * @method getWorldToNodeTransform + * @return {mat4_object} + */ +getWorldToNodeTransform : function ( +) +{ + return cc.Mat4; +}, + +/** + * @method getPositionY + * @return {float} + */ +getPositionY : function ( +) +{ + return 0; +}, + +/** + * @method getPositionX + * @return {float} + */ +getPositionX : function ( +) +{ + return 0; +}, + +/** + * @method removeChildByTag + * @param {int} arg0 + * @param {bool} arg1 + */ +removeChildByTag : function ( +int, +bool +) +{ +}, + +/** + * @method setPositionY + * @param {float} arg0 + */ +setPositionY : function ( +float +) +{ +}, + +/** + * @method updateDisplayedColor + * @param {color3b_object} arg0 + */ +updateDisplayedColor : function ( +color3b +) +{ +}, + +/** + * @method setVisible + * @param {bool} arg0 + */ +setVisible : function ( +bool +) +{ +}, + +/** + * @method getParentToNodeAffineTransform + * @return {cc.AffineTransform} + */ +getParentToNodeAffineTransform : function ( +) +{ + return cc.AffineTransform; +}, + +/** + * @method getPositionZ + * @return {float} + */ +getPositionZ : function ( +) +{ + return 0; +}, + +/** + * @method setGlobalZOrder + * @param {float} arg0 + */ +setGlobalZOrder : function ( +float +) +{ +}, + +/** + * @method setScale +* @param {float|float} float +* @param {float} float +*/ +setScale : function( +float, +float +) +{ +}, + +/** + * @method getOnExitCallback + * @return {function} + */ +getOnExitCallback : function ( +) +{ + return std::function; +}, + +/** + * @method getChildByTag + * @param {int} arg0 + * @return {cc.Node} + */ +getChildByTag : function ( +int +) +{ + return cc.Node; +}, + +/** + * @method setOrderOfArrival + * @param {int} arg0 + */ +setOrderOfArrival : function ( +int +) +{ +}, + +/** + * @method getScaleZ + * @return {float} + */ +getScaleZ : function ( +) +{ + return 0; +}, + +/** + * @method getScaleY + * @return {float} + */ +getScaleY : function ( +) +{ + return 0; +}, + +/** + * @method getScaleX + * @return {float} + */ +getScaleX : function ( +) +{ + return 0; +}, + +/** + * @method setLocalZOrder + * @param {int} arg0 + */ +setLocalZOrder : function ( +int +) +{ +}, + +/** + * @method setCascadeColorEnabled + * @param {bool} arg0 + */ +setCascadeColorEnabled : function ( +bool +) +{ +}, + +/** + * @method setOpacity + * @param {unsigned char} arg0 + */ +setOpacity : function ( +char +) +{ +}, + +/** + * @method cleanup + */ +cleanup : function ( +) +{ +}, + +/** + * @method getComponent + * @param {String} arg0 + * @return {cc.Component} + */ +getComponent : function ( +str +) +{ + return cc.Component; +}, + +/** + * @method getContentSize + * @return {size_object} + */ +getContentSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method stopAllActionsByTag + * @param {int} arg0 + */ +stopAllActionsByTag : function ( +int +) +{ +}, + +/** + * @method getBoundingBox + * @return {rect_object} + */ +getBoundingBox : function ( +) +{ + return cc.Rect; +}, + +/** + * @method setEventDispatcher + * @param {cc.EventDispatcher} arg0 + */ +setEventDispatcher : function ( +eventdispatcher +) +{ +}, + +/** + * @method getGlobalZOrder + * @return {float} + */ +getGlobalZOrder : function ( +) +{ + return 0; +}, + +/** + * @method draw +* @param {cc.Renderer} renderer +* @param {mat4_object} mat4 +* @param {unsigned int} int +*/ +draw : function( +renderer, +mat4, +int +) +{ +}, + +/** + * @method setUserObject + * @param {cc.Ref} arg0 + */ +setUserObject : function ( +ref +) +{ +}, + +/** + * @method enumerateChildren + * @param {String} arg0 + * @param {function} arg1 + */ +enumerateChildren : function ( +str, +func +) +{ +}, + +/** + * @method getonExitTransitionDidStartCallback + * @return {function} + */ +getonExitTransitionDidStartCallback : function ( +) +{ + return std::function; +}, + +/** + * @method removeFromParentAndCleanup +* @param {bool} bool +*/ +removeFromParentAndCleanup : function( +bool +) +{ +}, + +/** + * @method setPosition3D + * @param {vec3_object} arg0 + */ +setPosition3D : function ( +vec3 +) +{ +}, + +/** + * @method update + * @param {float} arg0 + */ +update : function ( +float +) +{ +}, + +/** + * @method sortAllChildren + */ +sortAllChildren : function ( +) +{ +}, + +/** + * @method getWorldToNodeAffineTransform + * @return {cc.AffineTransform} + */ +getWorldToNodeAffineTransform : function ( +) +{ + return cc.AffineTransform; +}, + +/** + * @method getScale + * @return {float} + */ +getScale : function ( +) +{ + return 0; +}, + +/** + * @method getNormalizedPosition + * @return {vec2_object} + */ +getNormalizedPosition : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getParentToNodeTransform + * @return {mat4_object} + */ +getParentToNodeTransform : function ( +) +{ + return cc.Mat4; +}, + +/** + * @method convertToNodeSpace + * @param {vec2_object} arg0 + * @return {vec2_object} + */ +convertToNodeSpace : function ( +vec2 +) +{ + return cc.Vec2; +}, + +/** + * @method setTag + * @param {int} arg0 + */ +setTag : function ( +int +) +{ +}, + +/** + * @method isCascadeColorEnabled + * @return {bool} + */ +isCascadeColorEnabled : function ( +) +{ + return false; +}, + +/** + * @method setRotationQuat + * @param {cc.Quaternion} arg0 + */ +setRotationQuat : function ( +quaternion +) +{ +}, + +/** + * @method stopAction + * @param {cc.Action} arg0 + */ +stopAction : function ( +action +) +{ +}, + +/** + * @method getActionManager +* @return {cc.ActionManager|cc.ActionManager} +*/ +getActionManager : function( +) +{ + return cc.ActionManager; +}, + +/** + * @method create + * @return {cc.Node} + */ +create : function ( +) +{ + return cc.Node; +}, + +/** + * @method Node + * @constructor + */ +Node : function ( +) +{ +}, + +}; + +/** + * @class __NodeRGBA + */ +cc.NodeRGBA = { + +/** + * @method __NodeRGBA + * @constructor + */ +__NodeRGBA : function ( +) +{ +}, + +}; + +/** + * @class SpriteFrame + */ +cc.SpriteFrame = { + +/** + * @method clone + * @return {cc.SpriteFrame} + */ +clone : function ( +) +{ + return cc.SpriteFrame; +}, + +/** + * @method setRotated + * @param {bool} arg0 + */ +setRotated : function ( +bool +) +{ +}, + +/** + * @method setTexture + * @param {cc.Texture2D} arg0 + */ +setTexture : function ( +texture2d +) +{ +}, + +/** + * @method getOffset + * @return {vec2_object} + */ +getOffset : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method setRectInPixels + * @param {rect_object} arg0 + */ +setRectInPixels : function ( +rect +) +{ +}, + +/** + * @method getTexture + * @return {cc.Texture2D} + */ +getTexture : function ( +) +{ + return cc.Texture2D; +}, + +/** + * @method getRect + * @return {rect_object} + */ +getRect : function ( +) +{ + return cc.Rect; +}, + +/** + * @method setOffsetInPixels + * @param {vec2_object} arg0 + */ +setOffsetInPixels : function ( +vec2 +) +{ +}, + +/** + * @method getRectInPixels + * @return {rect_object} + */ +getRectInPixels : function ( +) +{ + return cc.Rect; +}, + +/** + * @method setOriginalSize + * @param {size_object} arg0 + */ +setOriginalSize : function ( +size +) +{ +}, + +/** + * @method getOriginalSizeInPixels + * @return {size_object} + */ +getOriginalSizeInPixels : function ( +) +{ + return cc.Size; +}, + +/** + * @method setOriginalSizeInPixels + * @param {size_object} arg0 + */ +setOriginalSizeInPixels : function ( +size +) +{ +}, + +/** + * @method setOffset + * @param {vec2_object} arg0 + */ +setOffset : function ( +vec2 +) +{ +}, + +/** + * @method initWithTexture +* @param {cc.Texture2D|cc.Texture2D} texture2d +* @param {rect_object|rect_object} rect +* @param {bool} bool +* @param {vec2_object} vec2 +* @param {size_object} size +* @return {bool|bool} +*/ +initWithTexture : function( +texture2d, +rect, +bool, +vec2, +size +) +{ + return false; +}, + +/** + * @method isRotated + * @return {bool} + */ +isRotated : function ( +) +{ + return false; +}, + +/** + * @method initWithTextureFilename +* @param {String|String} str +* @param {rect_object|rect_object} rect +* @param {bool} bool +* @param {vec2_object} vec2 +* @param {size_object} size +* @return {bool|bool} +*/ +initWithTextureFilename : function( +str, +rect, +bool, +vec2, +size +) +{ + return false; +}, + +/** + * @method setRect + * @param {rect_object} arg0 + */ +setRect : function ( +rect +) +{ +}, + +/** + * @method getOffsetInPixels + * @return {vec2_object} + */ +getOffsetInPixels : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getOriginalSize + * @return {size_object} + */ +getOriginalSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method create +* @param {String|String} str +* @param {rect_object|rect_object} rect +* @param {bool} bool +* @param {vec2_object} vec2 +* @param {size_object} size +* @return {cc.SpriteFrame|cc.SpriteFrame} +*/ +create : function( +str, +rect, +bool, +vec2, +size +) +{ + return cc.SpriteFrame; +}, + +/** + * @method createWithTexture +* @param {cc.Texture2D|cc.Texture2D} texture2d +* @param {rect_object|rect_object} rect +* @param {bool} bool +* @param {vec2_object} vec2 +* @param {size_object} size +* @return {cc.SpriteFrame|cc.SpriteFrame} +*/ +createWithTexture : function( +texture2d, +rect, +bool, +vec2, +size +) +{ + return cc.SpriteFrame; +}, + +/** + * @method SpriteFrame + * @constructor + */ +SpriteFrame : function ( +) +{ +}, + +}; + +/** + * @class AnimationFrame + */ +cc.AnimationFrame = { + +/** + * @method setSpriteFrame + * @param {cc.SpriteFrame} arg0 + */ +setSpriteFrame : function ( +spriteframe +) +{ +}, + +/** + * @method getUserInfo +* @return {map_object|map_object} +*/ +getUserInfo : function( +) +{ + return map_object; +}, + +/** + * @method setDelayUnits + * @param {float} arg0 + */ +setDelayUnits : function ( +float +) +{ +}, + +/** + * @method clone + * @return {cc.AnimationFrame} + */ +clone : function ( +) +{ + return cc.AnimationFrame; +}, + +/** + * @method getSpriteFrame + * @return {cc.SpriteFrame} + */ +getSpriteFrame : function ( +) +{ + return cc.SpriteFrame; +}, + +/** + * @method getDelayUnits + * @return {float} + */ +getDelayUnits : function ( +) +{ + return 0; +}, + +/** + * @method setUserInfo + * @param {map_object} arg0 + */ +setUserInfo : function ( +map +) +{ +}, + +/** + * @method initWithSpriteFrame + * @param {cc.SpriteFrame} arg0 + * @param {float} arg1 + * @param {map_object} arg2 + * @return {bool} + */ +initWithSpriteFrame : function ( +spriteframe, +float, +map +) +{ + return false; +}, + +/** + * @method create + * @param {cc.SpriteFrame} arg0 + * @param {float} arg1 + * @param {map_object} arg2 + * @return {cc.AnimationFrame} + */ +create : function ( +spriteframe, +float, +map +) +{ + return cc.AnimationFrame; +}, + +/** + * @method AnimationFrame + * @constructor + */ +AnimationFrame : function ( +) +{ +}, + +}; + +/** + * @class Animation + */ +cc.Animation = { + +/** + * @method getLoops + * @return {unsigned int} + */ +getLoops : function ( +) +{ + return 0; +}, + +/** + * @method addSpriteFrame + * @param {cc.SpriteFrame} arg0 + */ +addSpriteFrame : function ( +spriteframe +) +{ +}, + +/** + * @method setRestoreOriginalFrame + * @param {bool} arg0 + */ +setRestoreOriginalFrame : function ( +bool +) +{ +}, + +/** + * @method clone + * @return {cc.Animation} + */ +clone : function ( +) +{ + return cc.Animation; +}, + +/** + * @method getDuration + * @return {float} + */ +getDuration : function ( +) +{ + return 0; +}, + +/** + * @method initWithAnimationFrames + * @param {Array} arg0 + * @param {float} arg1 + * @param {unsigned int} arg2 + * @return {bool} + */ +initWithAnimationFrames : function ( +array, +float, +int +) +{ + return false; +}, + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method setFrames + * @param {Array} arg0 + */ +setFrames : function ( +array +) +{ +}, + +/** + * @method getFrames + * @return {Array} + */ +getFrames : function ( +) +{ + return new Array(); +}, + +/** + * @method setLoops + * @param {unsigned int} arg0 + */ +setLoops : function ( +int +) +{ +}, + +/** + * @method setDelayPerUnit + * @param {float} arg0 + */ +setDelayPerUnit : function ( +float +) +{ +}, + +/** + * @method addSpriteFrameWithFile + * @param {String} arg0 + */ +addSpriteFrameWithFile : function ( +str +) +{ +}, + +/** + * @method getTotalDelayUnits + * @return {float} + */ +getTotalDelayUnits : function ( +) +{ + return 0; +}, + +/** + * @method getDelayPerUnit + * @return {float} + */ +getDelayPerUnit : function ( +) +{ + return 0; +}, + +/** + * @method initWithSpriteFrames + * @param {Array} arg0 + * @param {float} arg1 + * @param {unsigned int} arg2 + * @return {bool} + */ +initWithSpriteFrames : function ( +array, +float, +int +) +{ + return false; +}, + +/** + * @method getRestoreOriginalFrame + * @return {bool} + */ +getRestoreOriginalFrame : function ( +) +{ + return false; +}, + +/** + * @method addSpriteFrameWithTexture + * @param {cc.Texture2D} arg0 + * @param {rect_object} arg1 + */ +addSpriteFrameWithTexture : function ( +texture2d, +rect +) +{ +}, + +/** + * @method create +* @param {Array} array +* @param {float} float +* @param {unsigned int} int +* @return {cc.Animation|cc.Animation} +*/ +create : function( +array, +float, +int +) +{ + return cc.Animation; +}, + +/** + * @method createWithSpriteFrames + * @param {Array} arg0 + * @param {float} arg1 + * @param {unsigned int} arg2 + * @return {cc.Animation} + */ +createWithSpriteFrames : function ( +array, +float, +int +) +{ + return cc.Animation; +}, + +/** + * @method Animation + * @constructor + */ +Animation : function ( +) +{ +}, + +}; + +/** + * @class ActionInterval + */ +cc.ActionInterval = { + +/** + * @method getAmplitudeRate + * @return {float} + */ +getAmplitudeRate : function ( +) +{ + return 0; +}, + +/** + * @method initWithDuration + * @param {float} arg0 + * @return {bool} + */ +initWithDuration : function ( +float +) +{ + return false; +}, + +/** + * @method setAmplitudeRate + * @param {float} arg0 + */ +setAmplitudeRate : function ( +float +) +{ +}, + +/** + * @method getElapsed + * @return {float} + */ +getElapsed : function ( +) +{ + return 0; +}, + +}; + +/** + * @class Sequence + */ +cc.Sequence = { + +/** + * @method initWithTwoActions + * @param {cc.FiniteTimeAction} arg0 + * @param {cc.FiniteTimeAction} arg1 + * @return {bool} + */ +initWithTwoActions : function ( +finitetimeaction, +finitetimeaction +) +{ + return false; +}, + +/** + * @method Sequence + * @constructor + */ +Sequence : function ( +) +{ +}, + +}; + +/** + * @class Repeat + */ +cc.Repeat = { + +/** + * @method setInnerAction + * @param {cc.FiniteTimeAction} arg0 + */ +setInnerAction : function ( +finitetimeaction +) +{ +}, + +/** + * @method initWithAction + * @param {cc.FiniteTimeAction} arg0 + * @param {unsigned int} arg1 + * @return {bool} + */ +initWithAction : function ( +finitetimeaction, +int +) +{ + return false; +}, + +/** + * @method getInnerAction + * @return {cc.FiniteTimeAction} + */ +getInnerAction : function ( +) +{ + return cc.FiniteTimeAction; +}, + +/** + * @method create + * @param {cc.FiniteTimeAction} arg0 + * @param {unsigned int} arg1 + * @return {cc.Repeat} + */ +create : function ( +finitetimeaction, +int +) +{ + return cc.Repeat; +}, + +/** + * @method Repeat + * @constructor + */ +Repeat : function ( +) +{ +}, + +}; + +/** + * @class RepeatForever + */ +cc.RepeatForever = { + +/** + * @method setInnerAction + * @param {cc.ActionInterval} arg0 + */ +setInnerAction : function ( +actioninterval +) +{ +}, + +/** + * @method initWithAction + * @param {cc.ActionInterval} arg0 + * @return {bool} + */ +initWithAction : function ( +actioninterval +) +{ + return false; +}, + +/** + * @method getInnerAction + * @return {cc.ActionInterval} + */ +getInnerAction : function ( +) +{ + return cc.ActionInterval; +}, + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.RepeatForever} + */ +create : function ( +actioninterval +) +{ + return cc.RepeatForever; +}, + +/** + * @method RepeatForever + * @constructor + */ +RepeatForever : function ( +) +{ +}, + +}; + +/** + * @class Spawn + */ +cc.Spawn = { + +/** + * @method initWithTwoActions + * @param {cc.FiniteTimeAction} arg0 + * @param {cc.FiniteTimeAction} arg1 + * @return {bool} + */ +initWithTwoActions : function ( +finitetimeaction, +finitetimeaction +) +{ + return false; +}, + +/** + * @method Spawn + * @constructor + */ +Spawn : function ( +) +{ +}, + +}; + +/** + * @class RotateTo + */ +cc.RotateTo = { + +/** + * @method initWithDuration +* @param {float|float} float +* @param {vec3_object|float} vec3 +* @param {float} float +* @return {bool|bool} +*/ +initWithDuration : function( +float, +float, +float +) +{ + return false; +}, + +/** + * @method create +* @param {float|float|float} float +* @param {float|float|vec3_object} float +* @param {float} float +* @return {cc.RotateTo|cc.RotateTo|cc.RotateTo} +*/ +create : function( +float, +float, +float +) +{ + return cc.RotateTo; +}, + +/** + * @method RotateTo + * @constructor + */ +RotateTo : function ( +) +{ +}, + +}; + +/** + * @class RotateBy + */ +cc.RotateBy = { + +/** + * @method initWithDuration +* @param {float|float|float} float +* @param {float|float|vec3_object} float +* @param {float} float +* @return {bool|bool|bool} +*/ +initWithDuration : function( +float, +float, +float +) +{ + return false; +}, + +/** + * @method create +* @param {float|float|float} float +* @param {float|float|vec3_object} float +* @param {float} float +* @return {cc.RotateBy|cc.RotateBy|cc.RotateBy} +*/ +create : function( +float, +float, +float +) +{ + return cc.RotateBy; +}, + +/** + * @method RotateBy + * @constructor + */ +RotateBy : function ( +) +{ +}, + +}; + +/** + * @class MoveBy + */ +cc.MoveBy = { + +/** + * @method initWithDuration +* @param {float|float} float +* @param {vec3_object|vec2_object} vec3 +* @return {bool|bool} +*/ +initWithDuration : function( +float, +vec2 +) +{ + return false; +}, + +/** + * @method create +* @param {float|float} float +* @param {vec3_object|vec2_object} vec3 +* @return {cc.MoveBy|cc.MoveBy} +*/ +create : function( +float, +vec2 +) +{ + return cc.MoveBy; +}, + +/** + * @method MoveBy + * @constructor + */ +MoveBy : function ( +) +{ +}, + +}; + +/** + * @class MoveTo + */ +cc.MoveTo = { + +/** + * @method initWithDuration +* @param {float|float} float +* @param {vec3_object|vec2_object} vec3 +* @return {bool|bool} +*/ +initWithDuration : function( +float, +vec2 +) +{ + return false; +}, + +/** + * @method create +* @param {float|float} float +* @param {vec3_object|vec2_object} vec3 +* @return {cc.MoveTo|cc.MoveTo} +*/ +create : function( +float, +vec2 +) +{ + return cc.MoveTo; +}, + +/** + * @method MoveTo + * @constructor + */ +MoveTo : function ( +) +{ +}, + +}; + +/** + * @class SkewTo + */ +cc.SkewTo = { + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @return {bool} + */ +initWithDuration : function ( +float, +float, +float +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @return {cc.SkewTo} + */ +create : function ( +float, +float, +float +) +{ + return cc.SkewTo; +}, + +/** + * @method SkewTo + * @constructor + */ +SkewTo : function ( +) +{ +}, + +}; + +/** + * @class SkewBy + */ +cc.SkewBy = { + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @return {bool} + */ +initWithDuration : function ( +float, +float, +float +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @return {cc.SkewBy} + */ +create : function ( +float, +float, +float +) +{ + return cc.SkewBy; +}, + +/** + * @method SkewBy + * @constructor + */ +SkewBy : function ( +) +{ +}, + +}; + +/** + * @class JumpBy + */ +cc.JumpBy = { + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {vec2_object} arg1 + * @param {float} arg2 + * @param {int} arg3 + * @return {bool} + */ +initWithDuration : function ( +float, +vec2, +float, +int +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @param {vec2_object} arg1 + * @param {float} arg2 + * @param {int} arg3 + * @return {cc.JumpBy} + */ +create : function ( +float, +vec2, +float, +int +) +{ + return cc.JumpBy; +}, + +/** + * @method JumpBy + * @constructor + */ +JumpBy : function ( +) +{ +}, + +}; + +/** + * @class JumpTo + */ +cc.JumpTo = { + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {vec2_object} arg1 + * @param {float} arg2 + * @param {int} arg3 + * @return {bool} + */ +initWithDuration : function ( +float, +vec2, +float, +int +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @param {vec2_object} arg1 + * @param {float} arg2 + * @param {int} arg3 + * @return {cc.JumpTo} + */ +create : function ( +float, +vec2, +float, +int +) +{ + return cc.JumpTo; +}, + +/** + * @method JumpTo + * @constructor + */ +JumpTo : function ( +) +{ +}, + +}; + +/** + * @class BezierBy + */ +cc.BezierBy = { + +/** + * @method BezierBy + * @constructor + */ +BezierBy : function ( +) +{ +}, + +}; + +/** + * @class BezierTo + */ +cc.BezierTo = { + +/** + * @method BezierTo + * @constructor + */ +BezierTo : function ( +) +{ +}, + +}; + +/** + * @class ScaleTo + */ +cc.ScaleTo = { + +/** + * @method initWithDuration +* @param {float|float|float} float +* @param {float|float|float} float +* @param {float|float} float +* @param {float} float +* @return {bool|bool|bool} +*/ +initWithDuration : function( +float, +float, +float, +float +) +{ + return false; +}, + +/** + * @method create +* @param {float|float|float} float +* @param {float|float|float} float +* @param {float|float} float +* @param {float} float +* @return {cc.ScaleTo|cc.ScaleTo|cc.ScaleTo} +*/ +create : function( +float, +float, +float, +float +) +{ + return cc.ScaleTo; +}, + +/** + * @method ScaleTo + * @constructor + */ +ScaleTo : function ( +) +{ +}, + +}; + +/** + * @class ScaleBy + */ +cc.ScaleBy = { + +/** + * @method create +* @param {float|float|float} float +* @param {float|float|float} float +* @param {float|float} float +* @param {float} float +* @return {cc.ScaleBy|cc.ScaleBy|cc.ScaleBy} +*/ +create : function( +float, +float, +float, +float +) +{ + return cc.ScaleBy; +}, + +/** + * @method ScaleBy + * @constructor + */ +ScaleBy : function ( +) +{ +}, + +}; + +/** + * @class Blink + */ +cc.Blink = { + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {int} arg1 + * @return {bool} + */ +initWithDuration : function ( +float, +int +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @param {int} arg1 + * @return {cc.Blink} + */ +create : function ( +float, +int +) +{ + return cc.Blink; +}, + +/** + * @method Blink + * @constructor + */ +Blink : function ( +) +{ +}, + +}; + +/** + * @class FadeTo + */ +cc.FadeTo = { + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {unsigned char} arg1 + * @return {bool} + */ +initWithDuration : function ( +float, +char +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @param {unsigned char} arg1 + * @return {cc.FadeTo} + */ +create : function ( +float, +char +) +{ + return cc.FadeTo; +}, + +/** + * @method FadeTo + * @constructor + */ +FadeTo : function ( +) +{ +}, + +}; + +/** + * @class FadeIn + */ +cc.FadeIn = { + +/** + * @method setReverseAction + * @param {cc.FadeTo} arg0 + */ +setReverseAction : function ( +fadeto +) +{ +}, + +/** + * @method create + * @param {float} arg0 + * @return {cc.FadeIn} + */ +create : function ( +float +) +{ + return cc.FadeIn; +}, + +/** + * @method FadeIn + * @constructor + */ +FadeIn : function ( +) +{ +}, + +}; + +/** + * @class FadeOut + */ +cc.FadeOut = { + +/** + * @method setReverseAction + * @param {cc.FadeTo} arg0 + */ +setReverseAction : function ( +fadeto +) +{ +}, + +/** + * @method create + * @param {float} arg0 + * @return {cc.FadeOut} + */ +create : function ( +float +) +{ + return cc.FadeOut; +}, + +/** + * @method FadeOut + * @constructor + */ +FadeOut : function ( +) +{ +}, + +}; + +/** + * @class TintTo + */ +cc.TintTo = { + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {unsigned char} arg1 + * @param {unsigned char} arg2 + * @param {unsigned char} arg3 + * @return {bool} + */ +initWithDuration : function ( +float, +char, +char, +char +) +{ + return false; +}, + +/** + * @method create +* @param {float|float} float +* @param {color3b_object|unsigned char} color3b +* @param {unsigned char} char +* @param {unsigned char} char +* @return {cc.TintTo|cc.TintTo} +*/ +create : function( +float, +char, +char, +char +) +{ + return cc.TintTo; +}, + +/** + * @method TintTo + * @constructor + */ +TintTo : function ( +) +{ +}, + +}; + +/** + * @class TintBy + */ +cc.TintBy = { + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {short} arg1 + * @param {short} arg2 + * @param {short} arg3 + * @return {bool} + */ +initWithDuration : function ( +float, +short, +short, +short +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @param {short} arg1 + * @param {short} arg2 + * @param {short} arg3 + * @return {cc.TintBy} + */ +create : function ( +float, +short, +short, +short +) +{ + return cc.TintBy; +}, + +/** + * @method TintBy + * @constructor + */ +TintBy : function ( +) +{ +}, + +}; + +/** + * @class DelayTime + */ +cc.DelayTime = { + +/** + * @method create + * @param {float} arg0 + * @return {cc.DelayTime} + */ +create : function ( +float +) +{ + return cc.DelayTime; +}, + +/** + * @method DelayTime + * @constructor + */ +DelayTime : function ( +) +{ +}, + +}; + +/** + * @class ReverseTime + */ +cc.ReverseTime = { + +/** + * @method initWithAction + * @param {cc.FiniteTimeAction} arg0 + * @return {bool} + */ +initWithAction : function ( +finitetimeaction +) +{ + return false; +}, + +/** + * @method create + * @param {cc.FiniteTimeAction} arg0 + * @return {cc.ReverseTime} + */ +create : function ( +finitetimeaction +) +{ + return cc.ReverseTime; +}, + +/** + * @method ReverseTime + * @constructor + */ +ReverseTime : function ( +) +{ +}, + +}; + +/** + * @class Animate + */ +cc.Animate = { + +/** + * @method getAnimation +* @return {cc.Animation|cc.Animation} +*/ +getAnimation : function( +) +{ + return cc.Animation; +}, + +/** + * @method initWithAnimation + * @param {cc.Animation} arg0 + * @return {bool} + */ +initWithAnimation : function ( +animation +) +{ + return false; +}, + +/** + * @method setAnimation + * @param {cc.Animation} arg0 + */ +setAnimation : function ( +animation +) +{ +}, + +/** + * @method create + * @param {cc.Animation} arg0 + * @return {cc.Animate} + */ +create : function ( +animation +) +{ + return cc.Animate; +}, + +/** + * @method Animate + * @constructor + */ +Animate : function ( +) +{ +}, + +}; + +/** + * @class TargetedAction + */ +cc.TargetedAction = { + +/** + * @method getForcedTarget +* @return {cc.Node|cc.Node} +*/ +getForcedTarget : function( +) +{ + return cc.Node; +}, + +/** + * @method initWithTarget + * @param {cc.Node} arg0 + * @param {cc.FiniteTimeAction} arg1 + * @return {bool} + */ +initWithTarget : function ( +node, +finitetimeaction +) +{ + return false; +}, + +/** + * @method setForcedTarget + * @param {cc.Node} arg0 + */ +setForcedTarget : function ( +node +) +{ +}, + +/** + * @method create + * @param {cc.Node} arg0 + * @param {cc.FiniteTimeAction} arg1 + * @return {cc.TargetedAction} + */ +create : function ( +node, +finitetimeaction +) +{ + return cc.TargetedAction; +}, + +/** + * @method TargetedAction + * @constructor + */ +TargetedAction : function ( +) +{ +}, + +}; + +/** + * @class ActionFloat + */ +cc.ActionFloat = { + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @param {function} arg3 + * @return {bool} + */ +initWithDuration : function ( +float, +float, +float, +func +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @param {function} arg3 + * @return {cc.ActionFloat} + */ +create : function ( +float, +float, +float, +func +) +{ + return cc.ActionFloat; +}, + +/** + * @method ActionFloat + * @constructor + */ +ActionFloat : function ( +) +{ +}, + +}; + +/** + * @class Configuration + */ +cc.Configuration = { + +/** + * @method supportsPVRTC + * @return {bool} + */ +supportsPVRTC : function ( +) +{ + return false; +}, + +/** + * @method getMaxModelviewStackDepth + * @return {int} + */ +getMaxModelviewStackDepth : function ( +) +{ + return 0; +}, + +/** + * @method supportsShareableVAO + * @return {bool} + */ +supportsShareableVAO : function ( +) +{ + return false; +}, + +/** + * @method supportsBGRA8888 + * @return {bool} + */ +supportsBGRA8888 : function ( +) +{ + return false; +}, + +/** + * @method checkForGLExtension + * @param {String} arg0 + * @return {bool} + */ +checkForGLExtension : function ( +str +) +{ + return false; +}, + +/** + * @method supportsATITC + * @return {bool} + */ +supportsATITC : function ( +) +{ + return false; +}, + +/** + * @method supportsNPOT + * @return {bool} + */ +supportsNPOT : function ( +) +{ + return false; +}, + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method getAnimate3DQuality + * @return {cc.Animate3DQuality} + */ +getAnimate3DQuality : function ( +) +{ + return 0; +}, + +/** + * @method getMaxSupportPointLightInShader + * @return {int} + */ +getMaxSupportPointLightInShader : function ( +) +{ + return 0; +}, + +/** + * @method getMaxTextureSize + * @return {int} + */ +getMaxTextureSize : function ( +) +{ + return 0; +}, + +/** + * @method setValue + * @param {String} arg0 + * @param {cc.Value} arg1 + */ +setValue : function ( +str, +value +) +{ +}, + +/** + * @method getMaxSupportSpotLightInShader + * @return {int} + */ +getMaxSupportSpotLightInShader : function ( +) +{ + return 0; +}, + +/** + * @method supportsETC + * @return {bool} + */ +supportsETC : function ( +) +{ + return false; +}, + +/** + * @method getMaxSupportDirLightInShader + * @return {int} + */ +getMaxSupportDirLightInShader : function ( +) +{ + return 0; +}, + +/** + * @method loadConfigFile + * @param {String} arg0 + */ +loadConfigFile : function ( +str +) +{ +}, + +/** + * @method supportsDiscardFramebuffer + * @return {bool} + */ +supportsDiscardFramebuffer : function ( +) +{ + return false; +}, + +/** + * @method supportsS3TC + * @return {bool} + */ +supportsS3TC : function ( +) +{ + return false; +}, + +/** + * @method getInfo + * @return {String} + */ +getInfo : function ( +) +{ + return ; +}, + +/** + * @method getMaxTextureUnits + * @return {int} + */ +getMaxTextureUnits : function ( +) +{ + return 0; +}, + +/** + * @method getValue + * @param {String} arg0 + * @param {cc.Value} arg1 + * @return {cc.Value} + */ +getValue : function ( +str, +value +) +{ + return cc.Value; +}, + +/** + * @method gatherGPUInfo + */ +gatherGPUInfo : function ( +) +{ +}, + +/** + * @method destroyInstance + */ +destroyInstance : function ( +) +{ +}, + +/** + * @method getInstance + * @return {cc.Configuration} + */ +getInstance : function ( +) +{ + return cc.Configuration; +}, + +}; + +/** + * @class Scene + */ +cc.Scene = { + +/** + * @method setCameraOrderDirty + */ +setCameraOrderDirty : function ( +) +{ +}, + +/** + * @method render + * @param {cc.Renderer} arg0 + */ +render : function ( +renderer +) +{ +}, + +/** + * @method onProjectionChanged + * @param {cc.EventCustom} arg0 + */ +onProjectionChanged : function ( +eventcustom +) +{ +}, + +/** + * @method initWithSize + * @param {size_object} arg0 + * @return {bool} + */ +initWithSize : function ( +size +) +{ + return false; +}, + +/** + * @method getDefaultCamera + * @return {cc.Camera} + */ +getDefaultCamera : function ( +) +{ + return cc.Camera; +}, + +/** + * @method createWithSize + * @param {size_object} arg0 + * @return {cc.Scene} + */ +createWithSize : function ( +size +) +{ + return cc.Scene; +}, + +/** + * @method create + * @return {cc.Scene} + */ +create : function ( +) +{ + return cc.Scene; +}, + +/** + * @method Scene + * @constructor + */ +Scene : function ( +) +{ +}, + +}; + +/** + * @class GLView + */ +cc.GLView = { + +/** + * @method setFrameSize + * @param {float} arg0 + * @param {float} arg1 + */ +setFrameSize : function ( +float, +float +) +{ +}, + +/** + * @method getViewPortRect + * @return {rect_object} + */ +getViewPortRect : function ( +) +{ + return cc.Rect; +}, + +/** + * @method setContentScaleFactor + * @param {float} arg0 + * @return {bool} + */ +setContentScaleFactor : function ( +float +) +{ + return false; +}, + +/** + * @method getContentScaleFactor + * @return {float} + */ +getContentScaleFactor : function ( +) +{ + return 0; +}, + +/** + * @method setIMEKeyboardState + * @param {bool} arg0 + */ +setIMEKeyboardState : function ( +bool +) +{ +}, + +/** + * @method setScissorInPoints + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @param {float} arg3 + */ +setScissorInPoints : function ( +float, +float, +float, +float +) +{ +}, + +/** + * @method getViewName + * @return {String} + */ +getViewName : function ( +) +{ + return ; +}, + +/** + * @method isOpenGLReady + * @return {bool} + */ +isOpenGLReady : function ( +) +{ + return false; +}, + +/** + * @method setCursorVisible + * @param {bool} arg0 + */ +setCursorVisible : function ( +bool +) +{ +}, + +/** + * @method getScaleY + * @return {float} + */ +getScaleY : function ( +) +{ + return 0; +}, + +/** + * @method getScaleX + * @return {float} + */ +getScaleX : function ( +) +{ + return 0; +}, + +/** + * @method getVisibleOrigin + * @return {vec2_object} + */ +getVisibleOrigin : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getFrameSize + * @return {size_object} + */ +getFrameSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method setFrameZoomFactor + * @param {float} arg0 + */ +setFrameZoomFactor : function ( +float +) +{ +}, + +/** + * @method getFrameZoomFactor + * @return {float} + */ +getFrameZoomFactor : function ( +) +{ + return 0; +}, + +/** + * @method getDesignResolutionSize + * @return {size_object} + */ +getDesignResolutionSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method windowShouldClose + * @return {bool} + */ +windowShouldClose : function ( +) +{ + return false; +}, + +/** + * @method setDesignResolutionSize + * @param {float} arg0 + * @param {float} arg1 + * @param {ResolutionPolicy} arg2 + */ +setDesignResolutionSize : function ( +float, +float, +resolutionpolicy +) +{ +}, + +/** + * @method getResolutionPolicy + * @return {ResolutionPolicy} + */ +getResolutionPolicy : function ( +) +{ + return ResolutionPolicy; +}, + +/** + * @method isRetinaDisplay + * @return {bool} + */ +isRetinaDisplay : function ( +) +{ + return false; +}, + +/** + * @method setViewPortInPoints + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @param {float} arg3 + */ +setViewPortInPoints : function ( +float, +float, +float, +float +) +{ +}, + +/** + * @method getScissorRect + * @return {rect_object} + */ +getScissorRect : function ( +) +{ + return cc.Rect; +}, + +/** + * @method getRetinaFactor + * @return {int} + */ +getRetinaFactor : function ( +) +{ + return 0; +}, + +/** + * @method setViewName + * @param {String} arg0 + */ +setViewName : function ( +str +) +{ +}, + +/** + * @method getVisibleRect + * @return {rect_object} + */ +getVisibleRect : function ( +) +{ + return cc.Rect; +}, + +/** + * @method getVisibleSize + * @return {size_object} + */ +getVisibleSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method isScissorEnabled + * @return {bool} + */ +isScissorEnabled : function ( +) +{ + return false; +}, + +/** + * @method pollEvents + */ +pollEvents : function ( +) +{ +}, + +/** + * @method setGLContextAttrs + * @param {GLContextAttrs} arg0 + */ +setGLContextAttrs : function ( +glcontextattrs +) +{ +}, + +/** + * @method getGLContextAttrs + * @return {GLContextAttrs} + */ +getGLContextAttrs : function ( +) +{ + return GLContextAttrs; +}, + +}; + +/** + * @class Director + */ +cc.Director = { + +/** + * @method pause + */ +pause : function ( +) +{ +}, + +/** + * @method setEventDispatcher + * @param {cc.EventDispatcher} arg0 + */ +setEventDispatcher : function ( +eventdispatcher +) +{ +}, + +/** + * @method setContentScaleFactor + * @param {float} arg0 + */ +setContentScaleFactor : function ( +float +) +{ +}, + +/** + * @method getContentScaleFactor + * @return {float} + */ +getContentScaleFactor : function ( +) +{ + return 0; +}, + +/** + * @method getWinSizeInPixels + * @return {size_object} + */ +getWinSizeInPixels : function ( +) +{ + return cc.Size; +}, + +/** + * @method getDeltaTime + * @return {float} + */ +getDeltaTime : function ( +) +{ + return 0; +}, + +/** + * @method setGLDefaultValues + */ +setGLDefaultValues : function ( +) +{ +}, + +/** + * @method setActionManager + * @param {cc.ActionManager} arg0 + */ +setActionManager : function ( +actionmanager +) +{ +}, + +/** + * @method setAlphaBlending + * @param {bool} arg0 + */ +setAlphaBlending : function ( +bool +) +{ +}, + +/** + * @method popToRootScene + */ +popToRootScene : function ( +) +{ +}, + +/** + * @method loadMatrix + * @param {cc.MATRIX_STACK_TYPE} arg0 + * @param {mat4_object} arg1 + */ +loadMatrix : function ( +matrix_stack_type, +mat4 +) +{ +}, + +/** + * @method getNotificationNode + * @return {cc.Node} + */ +getNotificationNode : function ( +) +{ + return cc.Node; +}, + +/** + * @method getWinSize + * @return {size_object} + */ +getWinSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method end + */ +end : function ( +) +{ +}, + +/** + * @method getTextureCache + * @return {cc.TextureCache} + */ +getTextureCache : function ( +) +{ + return cc.TextureCache; +}, + +/** + * @method isSendCleanupToScene + * @return {bool} + */ +isSendCleanupToScene : function ( +) +{ + return false; +}, + +/** + * @method getVisibleOrigin + * @return {vec2_object} + */ +getVisibleOrigin : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method mainLoop + */ +mainLoop : function ( +) +{ +}, + +/** + * @method setDepthTest + * @param {bool} arg0 + */ +setDepthTest : function ( +bool +) +{ +}, + +/** + * @method getFrameRate + * @return {float} + */ +getFrameRate : function ( +) +{ + return 0; +}, + +/** + * @method getSecondsPerFrame + * @return {float} + */ +getSecondsPerFrame : function ( +) +{ + return 0; +}, + +/** + * @method resetMatrixStack + */ +resetMatrixStack : function ( +) +{ +}, + +/** + * @method convertToUI + * @param {vec2_object} arg0 + * @return {vec2_object} + */ +convertToUI : function ( +vec2 +) +{ + return cc.Vec2; +}, + +/** + * @method pushMatrix + * @param {cc.MATRIX_STACK_TYPE} arg0 + */ +pushMatrix : function ( +matrix_stack_type +) +{ +}, + +/** + * @method setDefaultValues + */ +setDefaultValues : function ( +) +{ +}, + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method setScheduler + * @param {cc.Scheduler} arg0 + */ +setScheduler : function ( +scheduler +) +{ +}, + +/** + * @method getMatrix + * @param {cc.MATRIX_STACK_TYPE} arg0 + * @return {mat4_object} + */ +getMatrix : function ( +matrix_stack_type +) +{ + return cc.Mat4; +}, + +/** + * @method startAnimation + */ +startAnimation : function ( +) +{ +}, + +/** + * @method getOpenGLView + * @return {cc.GLView} + */ +getOpenGLView : function ( +) +{ + return cc.GLView; +}, + +/** + * @method getRunningScene + * @return {cc.Scene} + */ +getRunningScene : function ( +) +{ + return cc.Scene; +}, + +/** + * @method setViewport + */ +setViewport : function ( +) +{ +}, + +/** + * @method stopAnimation + */ +stopAnimation : function ( +) +{ +}, + +/** + * @method popToSceneStackLevel + * @param {int} arg0 + */ +popToSceneStackLevel : function ( +int +) +{ +}, + +/** + * @method resume + */ +resume : function ( +) +{ +}, + +/** + * @method isNextDeltaTimeZero + * @return {bool} + */ +isNextDeltaTimeZero : function ( +) +{ + return false; +}, + +/** + * @method setClearColor + * @param {color4f_object} arg0 + */ +setClearColor : function ( +color4f +) +{ +}, + +/** + * @method setOpenGLView + * @param {cc.GLView} arg0 + */ +setOpenGLView : function ( +glview +) +{ +}, + +/** + * @method convertToGL + * @param {vec2_object} arg0 + * @return {vec2_object} + */ +convertToGL : function ( +vec2 +) +{ + return cc.Vec2; +}, + +/** + * @method purgeCachedData + */ +purgeCachedData : function ( +) +{ +}, + +/** + * @method getTotalFrames + * @return {unsigned int} + */ +getTotalFrames : function ( +) +{ + return 0; +}, + +/** + * @method runWithScene + * @param {cc.Scene} arg0 + */ +runWithScene : function ( +scene +) +{ +}, + +/** + * @method setNotificationNode + * @param {cc.Node} arg0 + */ +setNotificationNode : function ( +node +) +{ +}, + +/** + * @method drawScene + */ +drawScene : function ( +) +{ +}, + +/** + * @method restart + */ +restart : function ( +) +{ +}, + +/** + * @method popScene + */ +popScene : function ( +) +{ +}, + +/** + * @method loadIdentityMatrix + * @param {cc.MATRIX_STACK_TYPE} arg0 + */ +loadIdentityMatrix : function ( +matrix_stack_type +) +{ +}, + +/** + * @method isDisplayStats + * @return {bool} + */ +isDisplayStats : function ( +) +{ + return false; +}, + +/** + * @method setProjection + * @param {cc.Director::Projection} arg0 + */ +setProjection : function ( +projection +) +{ +}, + +/** + * @method multiplyMatrix + * @param {cc.MATRIX_STACK_TYPE} arg0 + * @param {mat4_object} arg1 + */ +multiplyMatrix : function ( +matrix_stack_type, +mat4 +) +{ +}, + +/** + * @method getZEye + * @return {float} + */ +getZEye : function ( +) +{ + return 0; +}, + +/** + * @method setNextDeltaTimeZero + * @param {bool} arg0 + */ +setNextDeltaTimeZero : function ( +bool +) +{ +}, + +/** + * @method popMatrix + * @param {cc.MATRIX_STACK_TYPE} arg0 + */ +popMatrix : function ( +matrix_stack_type +) +{ +}, + +/** + * @method getVisibleSize + * @return {size_object} + */ +getVisibleSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method getScheduler + * @return {cc.Scheduler} + */ +getScheduler : function ( +) +{ + return cc.Scheduler; +}, + +/** + * @method pushScene + * @param {cc.Scene} arg0 + */ +pushScene : function ( +scene +) +{ +}, + +/** + * @method getAnimationInterval + * @return {double} + */ +getAnimationInterval : function ( +) +{ + return 0; +}, + +/** + * @method isPaused + * @return {bool} + */ +isPaused : function ( +) +{ + return false; +}, + +/** + * @method setDisplayStats + * @param {bool} arg0 + */ +setDisplayStats : function ( +bool +) +{ +}, + +/** + * @method getEventDispatcher + * @return {cc.EventDispatcher} + */ +getEventDispatcher : function ( +) +{ + return cc.EventDispatcher; +}, + +/** + * @method replaceScene + * @param {cc.Scene} arg0 + */ +replaceScene : function ( +scene +) +{ +}, + +/** + * @method setAnimationInterval + * @param {double} arg0 + */ +setAnimationInterval : function ( +double +) +{ +}, + +/** + * @method getActionManager + * @return {cc.ActionManager} + */ +getActionManager : function ( +) +{ + return cc.ActionManager; +}, + +/** + * @method getInstance + * @return {cc.Director} + */ +getInstance : function ( +) +{ + return cc.Director; +}, + +}; + +/** + * @class Scheduler + */ +cc.Scheduler = { + +/** + * @method setTimeScale + * @param {float} arg0 + */ +setTimeScale : function ( +float +) +{ +}, + +/** + * @method unscheduleAllWithMinPriority + * @param {int} arg0 + */ +unscheduleAllWithMinPriority : function ( +int +) +{ +}, + +/** + * @method update + * @param {float} arg0 + */ +update : function ( +float +) +{ +}, + +/** + * @method unscheduleScriptEntry + * @param {unsigned int} arg0 + */ +unscheduleScriptEntry : function ( +int +) +{ +}, + +/** + * @method performFunctionInCocosThread + * @param {function} arg0 + */ +performFunctionInCocosThread : function ( +func +) +{ +}, + +/** + * @method unscheduleAll + */ +unscheduleAll : function ( +) +{ +}, + +/** + * @method getTimeScale + * @return {float} + */ +getTimeScale : function ( +) +{ + return 0; +}, + +/** + * @method Scheduler + * @constructor + */ +Scheduler : function ( +) +{ +}, + +}; + +/** + * @class FileUtils + */ +cc.FileUtils = { + +/** + * @method fullPathForFilename + * @param {String} arg0 + * @return {String} + */ +fullPathForFilename : function ( +str +) +{ + return ; +}, + +/** + * @method getStringFromFile + * @param {String} arg0 + * @return {String} + */ +getStringFromFile : function ( +str +) +{ + return ; +}, + +/** + * @method removeFile + * @param {String} arg0 + * @return {bool} + */ +removeFile : function ( +str +) +{ + return false; +}, + +/** + * @method isAbsolutePath + * @param {String} arg0 + * @return {bool} + */ +isAbsolutePath : function ( +str +) +{ + return false; +}, + +/** + * @method renameFile + * @param {String} arg0 + * @param {String} arg1 + * @param {String} arg2 + * @return {bool} + */ +renameFile : function ( +str, +str, +str +) +{ + return false; +}, + +/** + * @method loadFilenameLookupDictionaryFromFile + * @param {String} arg0 + */ +loadFilenameLookupDictionaryFromFile : function ( +str +) +{ +}, + +/** + * @method isPopupNotify + * @return {bool} + */ +isPopupNotify : function ( +) +{ + return false; +}, + +/** + * @method getValueVectorFromFile + * @param {String} arg0 + * @return {Array} + */ +getValueVectorFromFile : function ( +str +) +{ + return new Array(); +}, + +/** + * @method getSearchPaths + * @return {Array} + */ +getSearchPaths : function ( +) +{ + return new Array(); +}, + +/** + * @method writeToFile + * @param {map_object} arg0 + * @param {String} arg1 + * @return {bool} + */ +writeToFile : function ( +map, +str +) +{ + return false; +}, + +/** + * @method getValueMapFromFile + * @param {String} arg0 + * @return {map_object} + */ +getValueMapFromFile : function ( +str +) +{ + return map_object; +}, + +/** + * @method getValueMapFromData + * @param {char} arg0 + * @param {int} arg1 + * @return {map_object} + */ +getValueMapFromData : function ( +char, +int +) +{ + return map_object; +}, + +/** + * @method removeDirectory + * @param {String} arg0 + * @return {bool} + */ +removeDirectory : function ( +str +) +{ + return false; +}, + +/** + * @method setSearchPaths + * @param {Array} arg0 + */ +setSearchPaths : function ( +array +) +{ +}, + +/** + * @method getFileSize + * @param {String} arg0 + * @return {long} + */ +getFileSize : function ( +str +) +{ + return 0; +}, + +/** + * @method setSearchResolutionsOrder + * @param {Array} arg0 + */ +setSearchResolutionsOrder : function ( +array +) +{ +}, + +/** + * @method addSearchResolutionsOrder + * @param {String} arg0 + * @param {bool} arg1 + */ +addSearchResolutionsOrder : function ( +str, +bool +) +{ +}, + +/** + * @method addSearchPath + * @param {String} arg0 + * @param {bool} arg1 + */ +addSearchPath : function ( +str, +bool +) +{ +}, + +/** + * @method isFileExist + * @param {String} arg0 + * @return {bool} + */ +isFileExist : function ( +str +) +{ + return false; +}, + +/** + * @method purgeCachedEntries + */ +purgeCachedEntries : function ( +) +{ +}, + +/** + * @method fullPathFromRelativeFile + * @param {String} arg0 + * @param {String} arg1 + * @return {String} + */ +fullPathFromRelativeFile : function ( +str, +str +) +{ + return ; +}, + +/** + * @method getSuitableFOpen + * @param {String} arg0 + * @return {String} + */ +getSuitableFOpen : function ( +str +) +{ + return ; +}, + +/** + * @method setWritablePath + * @param {String} arg0 + */ +setWritablePath : function ( +str +) +{ +}, + +/** + * @method setPopupNotify + * @param {bool} arg0 + */ +setPopupNotify : function ( +bool +) +{ +}, + +/** + * @method isDirectoryExist + * @param {String} arg0 + * @return {bool} + */ +isDirectoryExist : function ( +str +) +{ + return false; +}, + +/** + * @method setDefaultResourceRootPath + * @param {String} arg0 + */ +setDefaultResourceRootPath : function ( +str +) +{ +}, + +/** + * @method getSearchResolutionsOrder + * @return {Array} + */ +getSearchResolutionsOrder : function ( +) +{ + return new Array(); +}, + +/** + * @method createDirectory + * @param {String} arg0 + * @return {bool} + */ +createDirectory : function ( +str +) +{ + return false; +}, + +/** + * @method getWritablePath + * @return {String} + */ +getWritablePath : function ( +) +{ + return ; +}, + +/** + * @method setDelegate + * @param {cc.FileUtils} arg0 + */ +setDelegate : function ( +fileutils +) +{ +}, + +/** + * @method getInstance + * @return {cc.FileUtils} + */ +getInstance : function ( +) +{ + return cc.FileUtils; +}, + +}; + +/** + * @class AsyncTaskPool + */ +cc.AsyncTaskPool = { + +/** + * @method stopTasks + * @param {cc.AsyncTaskPool::TaskType} arg0 + */ +stopTasks : function ( +tasktype +) +{ +}, + +/** + * @method destoryInstance + */ +destoryInstance : function ( +) +{ +}, + +/** + * @method getInstance + * @return {cc.AsyncTaskPool} + */ +getInstance : function ( +) +{ + return cc.AsyncTaskPool; +}, + +}; + +/** + * @class EventListener + */ +cc.EventListener = { + +/** + * @method setEnabled + * @param {bool} arg0 + */ +setEnabled : function ( +bool +) +{ +}, + +/** + * @method isEnabled + * @return {bool} + */ +isEnabled : function ( +) +{ + return false; +}, + +/** + * @method clone + * @return {cc.EventListener} + */ +clone : function ( +) +{ + return cc.EventListener; +}, + +/** + * @method checkAvailable + * @return {bool} + */ +checkAvailable : function ( +) +{ + return false; +}, + +}; + +/** + * @class EventDispatcher + */ +cc.EventDispatcher = { + +/** + * @method setEnabled + * @param {bool} arg0 + */ +setEnabled : function ( +bool +) +{ +}, + +/** + * @method removeAllEventListeners + */ +removeAllEventListeners : function ( +) +{ +}, + +/** + * @method addEventListenerWithSceneGraphPriority + * @param {cc.EventListener} arg0 + * @param {cc.Node} arg1 + */ +addEventListenerWithSceneGraphPriority : function ( +eventlistener, +node +) +{ +}, + +/** + * @method addCustomEventListener + * @param {String} arg0 + * @param {function} arg1 + * @return {cc.EventListenerCustom} + */ +addCustomEventListener : function ( +str, +func +) +{ + return cc.EventListenerCustom; +}, + +/** + * @method addEventListenerWithFixedPriority + * @param {cc.EventListener} arg0 + * @param {int} arg1 + */ +addEventListenerWithFixedPriority : function ( +eventlistener, +int +) +{ +}, + +/** + * @method removeEventListenersForTarget +* @param {cc.Node|cc.EventListener::Type} node +* @param {bool} bool +*/ +removeEventListenersForTarget : function( +node, +bool +) +{ +}, + +/** + * @method resumeEventListenersForTarget + * @param {cc.Node} arg0 + * @param {bool} arg1 + */ +resumeEventListenersForTarget : function ( +node, +bool +) +{ +}, + +/** + * @method setPriority + * @param {cc.EventListener} arg0 + * @param {int} arg1 + */ +setPriority : function ( +eventlistener, +int +) +{ +}, + +/** + * @method dispatchEvent + * @param {cc.Event} arg0 + */ +dispatchEvent : function ( +event +) +{ +}, + +/** + * @method pauseEventListenersForTarget + * @param {cc.Node} arg0 + * @param {bool} arg1 + */ +pauseEventListenersForTarget : function ( +node, +bool +) +{ +}, + +/** + * @method removeCustomEventListeners + * @param {String} arg0 + */ +removeCustomEventListeners : function ( +str +) +{ +}, + +/** + * @method removeEventListener + * @param {cc.EventListener} arg0 + */ +removeEventListener : function ( +eventlistener +) +{ +}, + +/** + * @method isEnabled + * @return {bool} + */ +isEnabled : function ( +) +{ + return false; +}, + +/** + * @method EventDispatcher + * @constructor + */ +EventDispatcher : function ( +) +{ +}, + +}; + +/** + * @class EventListenerTouchOneByOne + */ +cc.EventListenerTouchOneByOne = { + +/** + * @method isSwallowTouches + * @return {bool} + */ +isSwallowTouches : function ( +) +{ + return false; +}, + +/** + * @method setSwallowTouches + * @param {bool} arg0 + */ +setSwallowTouches : function ( +bool +) +{ +}, + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method EventListenerTouchOneByOne + * @constructor + */ +EventListenerTouchOneByOne : function ( +) +{ +}, + +}; + +/** + * @class EventListenerTouchAllAtOnce + */ +cc.EventListenerTouchAllAtOnce = { + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method EventListenerTouchAllAtOnce + * @constructor + */ +EventListenerTouchAllAtOnce : function ( +) +{ +}, + +}; + +/** + * @class EventListenerKeyboard + */ +cc.EventListenerKeyboard = { + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method EventListenerKeyboard + * @constructor + */ +EventListenerKeyboard : function ( +) +{ +}, + +}; + +/** + * @class EventMouse + */ +cc.EventMouse = { + +/** + * @method getMouseButton + * @return {int} + */ +getMouseButton : function ( +) +{ + return 0; +}, + +/** + * @method getLocation + * @return {vec2_object} + */ +getLocation : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method setMouseButton + * @param {int} arg0 + */ +setMouseButton : function ( +int +) +{ +}, + +/** + * @method setScrollData + * @param {float} arg0 + * @param {float} arg1 + */ +setScrollData : function ( +float, +float +) +{ +}, + +/** + * @method getPreviousLocationInView + * @return {vec2_object} + */ +getPreviousLocationInView : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getDelta + * @return {vec2_object} + */ +getDelta : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getStartLocation + * @return {vec2_object} + */ +getStartLocation : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getCursorY + * @return {float} + */ +getCursorY : function ( +) +{ + return 0; +}, + +/** + * @method getCursorX + * @return {float} + */ +getCursorX : function ( +) +{ + return 0; +}, + +/** + * @method getLocationInView + * @return {vec2_object} + */ +getLocationInView : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getScrollY + * @return {float} + */ +getScrollY : function ( +) +{ + return 0; +}, + +/** + * @method setCursorPosition + * @param {float} arg0 + * @param {float} arg1 + */ +setCursorPosition : function ( +float, +float +) +{ +}, + +/** + * @method getScrollX + * @return {float} + */ +getScrollX : function ( +) +{ + return 0; +}, + +/** + * @method getPreviousLocation + * @return {vec2_object} + */ +getPreviousLocation : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getStartLocationInView + * @return {vec2_object} + */ +getStartLocationInView : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method EventMouse + * @constructor + * @param {cc.EventMouse::MouseEventType} arg0 + */ +EventMouse : function ( +mouseeventtype +) +{ +}, + +}; + +/** + * @class EventListenerMouse + */ +cc.EventListenerMouse = { + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method EventListenerMouse + * @constructor + */ +EventListenerMouse : function ( +) +{ +}, + +}; + +/** + * @class EventAcceleration + */ +cc.EventAcceleration = { + +/** + * @method EventAcceleration + * @constructor + * @param {cc.Acceleration} arg0 + */ +EventAcceleration : function ( +acceleration +) +{ +}, + +}; + +/** + * @class EventListenerAcceleration + */ +cc.EventListenerAcceleration = { + +/** + * @method init + * @param {function} arg0 + * @return {bool} + */ +init : function ( +func +) +{ + return false; +}, + +/** + * @method create + * @param {function} arg0 + * @return {cc.EventListenerAcceleration} + */ +create : function ( +func +) +{ + return cc.EventListenerAcceleration; +}, + +/** + * @method EventListenerAcceleration + * @constructor + */ +EventListenerAcceleration : function ( +) +{ +}, + +}; + +/** + * @class EventCustom + */ +cc.EventCustom = { + +/** + * @method getEventName + * @return {String} + */ +getEventName : function ( +) +{ + return ; +}, + +/** + * @method EventCustom + * @constructor + * @param {String} arg0 + */ +EventCustom : function ( +str +) +{ +}, + +}; + +/** + * @class EventListenerCustom + */ +cc.EventListenerCustom = { + +/** + * @method create + * @param {String} arg0 + * @param {function} arg1 + * @return {cc.EventListenerCustom} + */ +create : function ( +str, +func +) +{ + return cc.EventListenerCustom; +}, + +/** + * @method EventListenerCustom + * @constructor + */ +EventListenerCustom : function ( +) +{ +}, + +}; + +/** + * @class EventFocus + */ +cc.EventFocus = { + +/** + * @method EventFocus + * @constructor + * @param {ccui.Widget} arg0 + * @param {ccui.Widget} arg1 + */ +EventFocus : function ( +widget, +widget +) +{ +}, + +}; + +/** + * @class EventListenerFocus + */ +cc.EventListenerFocus = { + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method EventListenerFocus + * @constructor + */ +EventListenerFocus : function ( +) +{ +}, + +}; + +/** + * @class ActionCamera + */ +cc.ActionCamera = { + +/** + * @method setEye +* @param {float|vec3_object} float +* @param {float} float +* @param {float} float +*/ +setEye : function( +float, +float, +float +) +{ +}, + +/** + * @method getEye + * @return {vec3_object} + */ +getEye : function ( +) +{ + return cc.Vec3; +}, + +/** + * @method setUp + * @param {vec3_object} arg0 + */ +setUp : function ( +vec3 +) +{ +}, + +/** + * @method getCenter + * @return {vec3_object} + */ +getCenter : function ( +) +{ + return cc.Vec3; +}, + +/** + * @method setCenter + * @param {vec3_object} arg0 + */ +setCenter : function ( +vec3 +) +{ +}, + +/** + * @method getUp + * @return {vec3_object} + */ +getUp : function ( +) +{ + return cc.Vec3; +}, + +/** + * @method ActionCamera + * @constructor + */ +ActionCamera : function ( +) +{ +}, + +}; + +/** + * @class OrbitCamera + */ +cc.OrbitCamera = { + +/** + * @method sphericalRadius + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + */ +sphericalRadius : function ( +float, +float, +float +) +{ +}, + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @param {float} arg3 + * @param {float} arg4 + * @param {float} arg5 + * @param {float} arg6 + * @return {bool} + */ +initWithDuration : function ( +float, +float, +float, +float, +float, +float, +float +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @param {float} arg3 + * @param {float} arg4 + * @param {float} arg5 + * @param {float} arg6 + * @return {cc.OrbitCamera} + */ +create : function ( +float, +float, +float, +float, +float, +float, +float +) +{ + return cc.OrbitCamera; +}, + +/** + * @method OrbitCamera + * @constructor + */ +OrbitCamera : function ( +) +{ +}, + +}; + +/** + * @class ActionManager + */ +cc.ActionManager = { + +/** + * @method getActionByTag + * @param {int} arg0 + * @param {cc.Node} arg1 + * @return {cc.Action} + */ +getActionByTag : function ( +int, +node +) +{ + return cc.Action; +}, + +/** + * @method removeActionByTag + * @param {int} arg0 + * @param {cc.Node} arg1 + */ +removeActionByTag : function ( +int, +node +) +{ +}, + +/** + * @method removeAllActions + */ +removeAllActions : function ( +) +{ +}, + +/** + * @method addAction + * @param {cc.Action} arg0 + * @param {cc.Node} arg1 + * @param {bool} arg2 + */ +addAction : function ( +action, +node, +bool +) +{ +}, + +/** + * @method resumeTarget + * @param {cc.Node} arg0 + */ +resumeTarget : function ( +node +) +{ +}, + +/** + * @method update + * @param {float} arg0 + */ +update : function ( +float +) +{ +}, + +/** + * @method pauseTarget + * @param {cc.Node} arg0 + */ +pauseTarget : function ( +node +) +{ +}, + +/** + * @method getNumberOfRunningActionsInTarget + * @param {cc.Node} arg0 + * @return {long} + */ +getNumberOfRunningActionsInTarget : function ( +node +) +{ + return 0; +}, + +/** + * @method removeAllActionsFromTarget + * @param {cc.Node} arg0 + */ +removeAllActionsFromTarget : function ( +node +) +{ +}, + +/** + * @method resumeTargets + * @param {Array} arg0 + */ +resumeTargets : function ( +array +) +{ +}, + +/** + * @method removeAction + * @param {cc.Action} arg0 + */ +removeAction : function ( +action +) +{ +}, + +/** + * @method removeAllActionsByTag + * @param {int} arg0 + * @param {cc.Node} arg1 + */ +removeAllActionsByTag : function ( +int, +node +) +{ +}, + +/** + * @method pauseAllRunningActions + * @return {Array} + */ +pauseAllRunningActions : function ( +) +{ + return new Array(); +}, + +/** + * @method ActionManager + * @constructor + */ +ActionManager : function ( +) +{ +}, + +}; + +/** + * @class ActionEase + */ +cc.ActionEase = { + +/** + * @method initWithAction + * @param {cc.ActionInterval} arg0 + * @return {bool} + */ +initWithAction : function ( +actioninterval +) +{ + return false; +}, + +/** + * @method getInnerAction + * @return {cc.ActionInterval} + */ +getInnerAction : function ( +) +{ + return cc.ActionInterval; +}, + +}; + +/** + * @class EaseRateAction + */ +cc.EaseRateAction = { + +/** + * @method setRate + * @param {float} arg0 + */ +setRate : function ( +float +) +{ +}, + +/** + * @method initWithAction + * @param {cc.ActionInterval} arg0 + * @param {float} arg1 + * @return {bool} + */ +initWithAction : function ( +actioninterval, +float +) +{ + return false; +}, + +/** + * @method getRate + * @return {float} + */ +getRate : function ( +) +{ + return 0; +}, + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @param {float} arg1 + * @return {cc.EaseRateAction} + */ +create : function ( +actioninterval, +float +) +{ + return cc.EaseRateAction; +}, + +}; + +/** + * @class EaseIn + */ +cc.EaseIn = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @param {float} arg1 + * @return {cc.EaseIn} + */ +create : function ( +actioninterval, +float +) +{ + return cc.EaseIn; +}, + +/** + * @method EaseIn + * @constructor + */ +EaseIn : function ( +) +{ +}, + +}; + +/** + * @class EaseOut + */ +cc.EaseOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @param {float} arg1 + * @return {cc.EaseOut} + */ +create : function ( +actioninterval, +float +) +{ + return cc.EaseOut; +}, + +/** + * @method EaseOut + * @constructor + */ +EaseOut : function ( +) +{ +}, + +}; + +/** + * @class EaseInOut + */ +cc.EaseInOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @param {float} arg1 + * @return {cc.EaseInOut} + */ +create : function ( +actioninterval, +float +) +{ + return cc.EaseInOut; +}, + +/** + * @method EaseInOut + * @constructor + */ +EaseInOut : function ( +) +{ +}, + +}; + +/** + * @class EaseExponentialIn + */ +cc.EaseExponentialIn = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseExponentialIn} + */ +create : function ( +actioninterval +) +{ + return cc.EaseExponentialIn; +}, + +/** + * @method EaseExponentialIn + * @constructor + */ +EaseExponentialIn : function ( +) +{ +}, + +}; + +/** + * @class EaseExponentialOut + */ +cc.EaseExponentialOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseExponentialOut} + */ +create : function ( +actioninterval +) +{ + return cc.EaseExponentialOut; +}, + +/** + * @method EaseExponentialOut + * @constructor + */ +EaseExponentialOut : function ( +) +{ +}, + +}; + +/** + * @class EaseExponentialInOut + */ +cc.EaseExponentialInOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseExponentialInOut} + */ +create : function ( +actioninterval +) +{ + return cc.EaseExponentialInOut; +}, + +/** + * @method EaseExponentialInOut + * @constructor + */ +EaseExponentialInOut : function ( +) +{ +}, + +}; + +/** + * @class EaseSineIn + */ +cc.EaseSineIn = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseSineIn} + */ +create : function ( +actioninterval +) +{ + return cc.EaseSineIn; +}, + +/** + * @method EaseSineIn + * @constructor + */ +EaseSineIn : function ( +) +{ +}, + +}; + +/** + * @class EaseSineOut + */ +cc.EaseSineOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseSineOut} + */ +create : function ( +actioninterval +) +{ + return cc.EaseSineOut; +}, + +/** + * @method EaseSineOut + * @constructor + */ +EaseSineOut : function ( +) +{ +}, + +}; + +/** + * @class EaseSineInOut + */ +cc.EaseSineInOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseSineInOut} + */ +create : function ( +actioninterval +) +{ + return cc.EaseSineInOut; +}, + +/** + * @method EaseSineInOut + * @constructor + */ +EaseSineInOut : function ( +) +{ +}, + +}; + +/** + * @class EaseElastic + */ +cc.EaseElastic = { + +/** + * @method setPeriod + * @param {float} arg0 + */ +setPeriod : function ( +float +) +{ +}, + +/** + * @method initWithAction + * @param {cc.ActionInterval} arg0 + * @param {float} arg1 + * @return {bool} + */ +initWithAction : function ( +actioninterval, +float +) +{ + return false; +}, + +/** + * @method getPeriod + * @return {float} + */ +getPeriod : function ( +) +{ + return 0; +}, + +}; + +/** + * @class EaseElasticIn + */ +cc.EaseElasticIn = { + +/** + * @method create +* @param {cc.ActionInterval|cc.ActionInterval} actioninterval +* @param {float} float +* @return {cc.EaseElasticIn|cc.EaseElasticIn} +*/ +create : function( +actioninterval, +float +) +{ + return cc.EaseElasticIn; +}, + +/** + * @method EaseElasticIn + * @constructor + */ +EaseElasticIn : function ( +) +{ +}, + +}; + +/** + * @class EaseElasticOut + */ +cc.EaseElasticOut = { + +/** + * @method create +* @param {cc.ActionInterval|cc.ActionInterval} actioninterval +* @param {float} float +* @return {cc.EaseElasticOut|cc.EaseElasticOut} +*/ +create : function( +actioninterval, +float +) +{ + return cc.EaseElasticOut; +}, + +/** + * @method EaseElasticOut + * @constructor + */ +EaseElasticOut : function ( +) +{ +}, + +}; + +/** + * @class EaseElasticInOut + */ +cc.EaseElasticInOut = { + +/** + * @method create +* @param {cc.ActionInterval|cc.ActionInterval} actioninterval +* @param {float} float +* @return {cc.EaseElasticInOut|cc.EaseElasticInOut} +*/ +create : function( +actioninterval, +float +) +{ + return cc.EaseElasticInOut; +}, + +/** + * @method EaseElasticInOut + * @constructor + */ +EaseElasticInOut : function ( +) +{ +}, + +}; + +/** + * @class EaseBounce + */ +cc.EaseBounce = { + +}; + +/** + * @class EaseBounceIn + */ +cc.EaseBounceIn = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseBounceIn} + */ +create : function ( +actioninterval +) +{ + return cc.EaseBounceIn; +}, + +/** + * @method EaseBounceIn + * @constructor + */ +EaseBounceIn : function ( +) +{ +}, + +}; + +/** + * @class EaseBounceOut + */ +cc.EaseBounceOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseBounceOut} + */ +create : function ( +actioninterval +) +{ + return cc.EaseBounceOut; +}, + +/** + * @method EaseBounceOut + * @constructor + */ +EaseBounceOut : function ( +) +{ +}, + +}; + +/** + * @class EaseBounceInOut + */ +cc.EaseBounceInOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseBounceInOut} + */ +create : function ( +actioninterval +) +{ + return cc.EaseBounceInOut; +}, + +/** + * @method EaseBounceInOut + * @constructor + */ +EaseBounceInOut : function ( +) +{ +}, + +}; + +/** + * @class EaseBackIn + */ +cc.EaseBackIn = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseBackIn} + */ +create : function ( +actioninterval +) +{ + return cc.EaseBackIn; +}, + +/** + * @method EaseBackIn + * @constructor + */ +EaseBackIn : function ( +) +{ +}, + +}; + +/** + * @class EaseBackOut + */ +cc.EaseBackOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseBackOut} + */ +create : function ( +actioninterval +) +{ + return cc.EaseBackOut; +}, + +/** + * @method EaseBackOut + * @constructor + */ +EaseBackOut : function ( +) +{ +}, + +}; + +/** + * @class EaseBackInOut + */ +cc.EaseBackInOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseBackInOut} + */ +create : function ( +actioninterval +) +{ + return cc.EaseBackInOut; +}, + +/** + * @method EaseBackInOut + * @constructor + */ +EaseBackInOut : function ( +) +{ +}, + +}; + +/** + * @class EaseBezierAction + */ +cc.EaseBezierAction = { + +/** + * @method setBezierParamer + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @param {float} arg3 + */ +setBezierParamer : function ( +float, +float, +float, +float +) +{ +}, + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseBezierAction} + */ +create : function ( +actioninterval +) +{ + return cc.EaseBezierAction; +}, + +/** + * @method EaseBezierAction + * @constructor + */ +EaseBezierAction : function ( +) +{ +}, + +}; + +/** + * @class EaseQuadraticActionIn + */ +cc.EaseQuadraticActionIn = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseQuadraticActionIn} + */ +create : function ( +actioninterval +) +{ + return cc.EaseQuadraticActionIn; +}, + +/** + * @method EaseQuadraticActionIn + * @constructor + */ +EaseQuadraticActionIn : function ( +) +{ +}, + +}; + +/** + * @class EaseQuadraticActionOut + */ +cc.EaseQuadraticActionOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseQuadraticActionOut} + */ +create : function ( +actioninterval +) +{ + return cc.EaseQuadraticActionOut; +}, + +/** + * @method EaseQuadraticActionOut + * @constructor + */ +EaseQuadraticActionOut : function ( +) +{ +}, + +}; + +/** + * @class EaseQuadraticActionInOut + */ +cc.EaseQuadraticActionInOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseQuadraticActionInOut} + */ +create : function ( +actioninterval +) +{ + return cc.EaseQuadraticActionInOut; +}, + +/** + * @method EaseQuadraticActionInOut + * @constructor + */ +EaseQuadraticActionInOut : function ( +) +{ +}, + +}; + +/** + * @class EaseQuarticActionIn + */ +cc.EaseQuarticActionIn = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseQuarticActionIn} + */ +create : function ( +actioninterval +) +{ + return cc.EaseQuarticActionIn; +}, + +/** + * @method EaseQuarticActionIn + * @constructor + */ +EaseQuarticActionIn : function ( +) +{ +}, + +}; + +/** + * @class EaseQuarticActionOut + */ +cc.EaseQuarticActionOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseQuarticActionOut} + */ +create : function ( +actioninterval +) +{ + return cc.EaseQuarticActionOut; +}, + +/** + * @method EaseQuarticActionOut + * @constructor + */ +EaseQuarticActionOut : function ( +) +{ +}, + +}; + +/** + * @class EaseQuarticActionInOut + */ +cc.EaseQuarticActionInOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseQuarticActionInOut} + */ +create : function ( +actioninterval +) +{ + return cc.EaseQuarticActionInOut; +}, + +/** + * @method EaseQuarticActionInOut + * @constructor + */ +EaseQuarticActionInOut : function ( +) +{ +}, + +}; + +/** + * @class EaseQuinticActionIn + */ +cc.EaseQuinticActionIn = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseQuinticActionIn} + */ +create : function ( +actioninterval +) +{ + return cc.EaseQuinticActionIn; +}, + +/** + * @method EaseQuinticActionIn + * @constructor + */ +EaseQuinticActionIn : function ( +) +{ +}, + +}; + +/** + * @class EaseQuinticActionOut + */ +cc.EaseQuinticActionOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseQuinticActionOut} + */ +create : function ( +actioninterval +) +{ + return cc.EaseQuinticActionOut; +}, + +/** + * @method EaseQuinticActionOut + * @constructor + */ +EaseQuinticActionOut : function ( +) +{ +}, + +}; + +/** + * @class EaseQuinticActionInOut + */ +cc.EaseQuinticActionInOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseQuinticActionInOut} + */ +create : function ( +actioninterval +) +{ + return cc.EaseQuinticActionInOut; +}, + +/** + * @method EaseQuinticActionInOut + * @constructor + */ +EaseQuinticActionInOut : function ( +) +{ +}, + +}; + +/** + * @class EaseCircleActionIn + */ +cc.EaseCircleActionIn = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseCircleActionIn} + */ +create : function ( +actioninterval +) +{ + return cc.EaseCircleActionIn; +}, + +/** + * @method EaseCircleActionIn + * @constructor + */ +EaseCircleActionIn : function ( +) +{ +}, + +}; + +/** + * @class EaseCircleActionOut + */ +cc.EaseCircleActionOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseCircleActionOut} + */ +create : function ( +actioninterval +) +{ + return cc.EaseCircleActionOut; +}, + +/** + * @method EaseCircleActionOut + * @constructor + */ +EaseCircleActionOut : function ( +) +{ +}, + +}; + +/** + * @class EaseCircleActionInOut + */ +cc.EaseCircleActionInOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseCircleActionInOut} + */ +create : function ( +actioninterval +) +{ + return cc.EaseCircleActionInOut; +}, + +/** + * @method EaseCircleActionInOut + * @constructor + */ +EaseCircleActionInOut : function ( +) +{ +}, + +}; + +/** + * @class EaseCubicActionIn + */ +cc.EaseCubicActionIn = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseCubicActionIn} + */ +create : function ( +actioninterval +) +{ + return cc.EaseCubicActionIn; +}, + +/** + * @method EaseCubicActionIn + * @constructor + */ +EaseCubicActionIn : function ( +) +{ +}, + +}; + +/** + * @class EaseCubicActionOut + */ +cc.EaseCubicActionOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseCubicActionOut} + */ +create : function ( +actioninterval +) +{ + return cc.EaseCubicActionOut; +}, + +/** + * @method EaseCubicActionOut + * @constructor + */ +EaseCubicActionOut : function ( +) +{ +}, + +}; + +/** + * @class EaseCubicActionInOut + */ +cc.EaseCubicActionInOut = { + +/** + * @method create + * @param {cc.ActionInterval} arg0 + * @return {cc.EaseCubicActionInOut} + */ +create : function ( +actioninterval +) +{ + return cc.EaseCubicActionInOut; +}, + +/** + * @method EaseCubicActionInOut + * @constructor + */ +EaseCubicActionInOut : function ( +) +{ +}, + +}; + +/** + * @class ActionInstant + */ +cc.ActionInstant = { + +}; + +/** + * @class Show + */ +cc.Show = { + +/** + * @method create + * @return {cc.Show} + */ +create : function ( +) +{ + return cc.Show; +}, + +/** + * @method Show + * @constructor + */ +Show : function ( +) +{ +}, + +}; + +/** + * @class Hide + */ +cc.Hide = { + +/** + * @method create + * @return {cc.Hide} + */ +create : function ( +) +{ + return cc.Hide; +}, + +/** + * @method Hide + * @constructor + */ +Hide : function ( +) +{ +}, + +}; + +/** + * @class ToggleVisibility + */ +cc.ToggleVisibility = { + +/** + * @method create + * @return {cc.ToggleVisibility} + */ +create : function ( +) +{ + return cc.ToggleVisibility; +}, + +/** + * @method ToggleVisibility + * @constructor + */ +ToggleVisibility : function ( +) +{ +}, + +}; + +/** + * @class RemoveSelf + */ +cc.RemoveSelf = { + +/** + * @method init + * @param {bool} arg0 + * @return {bool} + */ +init : function ( +bool +) +{ + return false; +}, + +/** + * @method create + * @return {cc.RemoveSelf} + */ +create : function ( +) +{ + return cc.RemoveSelf; +}, + +/** + * @method RemoveSelf + * @constructor + */ +RemoveSelf : function ( +) +{ +}, + +}; + +/** + * @class FlipX + */ +cc.FlipX = { + +/** + * @method initWithFlipX + * @param {bool} arg0 + * @return {bool} + */ +initWithFlipX : function ( +bool +) +{ + return false; +}, + +/** + * @method create + * @param {bool} arg0 + * @return {cc.FlipX} + */ +create : function ( +bool +) +{ + return cc.FlipX; +}, + +/** + * @method FlipX + * @constructor + */ +FlipX : function ( +) +{ +}, + +}; + +/** + * @class FlipY + */ +cc.FlipY = { + +/** + * @method initWithFlipY + * @param {bool} arg0 + * @return {bool} + */ +initWithFlipY : function ( +bool +) +{ + return false; +}, + +/** + * @method create + * @param {bool} arg0 + * @return {cc.FlipY} + */ +create : function ( +bool +) +{ + return cc.FlipY; +}, + +/** + * @method FlipY + * @constructor + */ +FlipY : function ( +) +{ +}, + +}; + +/** + * @class Place + */ +cc.Place = { + +/** + * @method initWithPosition + * @param {vec2_object} arg0 + * @return {bool} + */ +initWithPosition : function ( +vec2 +) +{ + return false; +}, + +/** + * @method create + * @param {vec2_object} arg0 + * @return {cc.Place} + */ +create : function ( +vec2 +) +{ + return cc.Place; +}, + +/** + * @method Place + * @constructor + */ +Place : function ( +) +{ +}, + +}; + +/** + * @class CallFunc + */ +cc._CallFunc = { + +/** + * @method execute + */ +execute : function ( +) +{ +}, + +/** + * @method CallFunc + * @constructor + */ +CallFunc : function ( +) +{ +}, + +}; + +/** + * @class CallFuncN + */ +cc.CallFunc = { + +/** + * @method CallFuncN + * @constructor + */ +CallFuncN : function ( +) +{ +}, + +}; + +/** + * @class GridAction + */ +cc.GridAction = { + +/** + * @method getGrid + * @return {cc.GridBase} + */ +getGrid : function ( +) +{ + return cc.GridBase; +}, + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {size_object} arg1 + * @return {bool} + */ +initWithDuration : function ( +float, +size +) +{ + return false; +}, + +}; + +/** + * @class Grid3DAction + */ +cc.Grid3DAction = { + +}; + +/** + * @class TiledGrid3DAction + */ +cc.TiledGrid3DAction = { + +}; + +/** + * @class StopGrid + */ +cc.StopGrid = { + +/** + * @method create + * @return {cc.StopGrid} + */ +create : function ( +) +{ + return cc.StopGrid; +}, + +/** + * @method StopGrid + * @constructor + */ +StopGrid : function ( +) +{ +}, + +}; + +/** + * @class ReuseGrid + */ +cc.ReuseGrid = { + +/** + * @method initWithTimes + * @param {int} arg0 + * @return {bool} + */ +initWithTimes : function ( +int +) +{ + return false; +}, + +/** + * @method create + * @param {int} arg0 + * @return {cc.ReuseGrid} + */ +create : function ( +int +) +{ + return cc.ReuseGrid; +}, + +/** + * @method ReuseGrid + * @constructor + */ +ReuseGrid : function ( +) +{ +}, + +}; + +/** + * @class Waves3D + */ +cc.Waves3D = { + +/** + * @method setAmplitudeRate + * @param {float} arg0 + */ +setAmplitudeRate : function ( +float +) +{ +}, + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {size_object} arg1 + * @param {unsigned int} arg2 + * @param {float} arg3 + * @return {bool} + */ +initWithDuration : function ( +float, +size, +int, +float +) +{ + return false; +}, + +/** + * @method getAmplitude + * @return {float} + */ +getAmplitude : function ( +) +{ + return 0; +}, + +/** + * @method getAmplitudeRate + * @return {float} + */ +getAmplitudeRate : function ( +) +{ + return 0; +}, + +/** + * @method setAmplitude + * @param {float} arg0 + */ +setAmplitude : function ( +float +) +{ +}, + +/** + * @method create + * @param {float} arg0 + * @param {size_object} arg1 + * @param {unsigned int} arg2 + * @param {float} arg3 + * @return {cc.Waves3D} + */ +create : function ( +float, +size, +int, +float +) +{ + return cc.Waves3D; +}, + +/** + * @method Waves3D + * @constructor + */ +Waves3D : function ( +) +{ +}, + +}; + +/** + * @class FlipX3D + */ +cc.FlipX3D = { + +/** + * @method initWithSize + * @param {size_object} arg0 + * @param {float} arg1 + * @return {bool} + */ +initWithSize : function ( +size, +float +) +{ + return false; +}, + +/** + * @method initWithDuration + * @param {float} arg0 + * @return {bool} + */ +initWithDuration : function ( +float +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @return {cc.FlipX3D} + */ +create : function ( +float +) +{ + return cc.FlipX3D; +}, + +/** + * @method FlipX3D + * @constructor + */ +FlipX3D : function ( +) +{ +}, + +}; + +/** + * @class FlipY3D + */ +cc.FlipY3D = { + +/** + * @method create + * @param {float} arg0 + * @return {cc.FlipY3D} + */ +create : function ( +float +) +{ + return cc.FlipY3D; +}, + +/** + * @method FlipY3D + * @constructor + */ +FlipY3D : function ( +) +{ +}, + +}; + +/** + * @class Lens3D + */ +cc.Lens3D = { + +/** + * @method setConcave + * @param {bool} arg0 + */ +setConcave : function ( +bool +) +{ +}, + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {size_object} arg1 + * @param {vec2_object} arg2 + * @param {float} arg3 + * @return {bool} + */ +initWithDuration : function ( +float, +size, +vec2, +float +) +{ + return false; +}, + +/** + * @method setLensEffect + * @param {float} arg0 + */ +setLensEffect : function ( +float +) +{ +}, + +/** + * @method getLensEffect + * @return {float} + */ +getLensEffect : function ( +) +{ + return 0; +}, + +/** + * @method setPosition + * @param {vec2_object} arg0 + */ +setPosition : function ( +vec2 +) +{ +}, + +/** + * @method getPosition + * @return {vec2_object} + */ +getPosition : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method create + * @param {float} arg0 + * @param {size_object} arg1 + * @param {vec2_object} arg2 + * @param {float} arg3 + * @return {cc.Lens3D} + */ +create : function ( +float, +size, +vec2, +float +) +{ + return cc.Lens3D; +}, + +/** + * @method Lens3D + * @constructor + */ +Lens3D : function ( +) +{ +}, + +}; + +/** + * @class Ripple3D + */ +cc.Ripple3D = { + +/** + * @method setAmplitudeRate + * @param {float} arg0 + */ +setAmplitudeRate : function ( +float +) +{ +}, + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {size_object} arg1 + * @param {vec2_object} arg2 + * @param {float} arg3 + * @param {unsigned int} arg4 + * @param {float} arg5 + * @return {bool} + */ +initWithDuration : function ( +float, +size, +vec2, +float, +int, +float +) +{ + return false; +}, + +/** + * @method getAmplitudeRate + * @return {float} + */ +getAmplitudeRate : function ( +) +{ + return 0; +}, + +/** + * @method setAmplitude + * @param {float} arg0 + */ +setAmplitude : function ( +float +) +{ +}, + +/** + * @method getAmplitude + * @return {float} + */ +getAmplitude : function ( +) +{ + return 0; +}, + +/** + * @method setPosition + * @param {vec2_object} arg0 + */ +setPosition : function ( +vec2 +) +{ +}, + +/** + * @method getPosition + * @return {vec2_object} + */ +getPosition : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method create + * @param {float} arg0 + * @param {size_object} arg1 + * @param {vec2_object} arg2 + * @param {float} arg3 + * @param {unsigned int} arg4 + * @param {float} arg5 + * @return {cc.Ripple3D} + */ +create : function ( +float, +size, +vec2, +float, +int, +float +) +{ + return cc.Ripple3D; +}, + +/** + * @method Ripple3D + * @constructor + */ +Ripple3D : function ( +) +{ +}, + +}; + +/** + * @class Shaky3D + */ +cc.Shaky3D = { + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {size_object} arg1 + * @param {int} arg2 + * @param {bool} arg3 + * @return {bool} + */ +initWithDuration : function ( +float, +size, +int, +bool +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @param {size_object} arg1 + * @param {int} arg2 + * @param {bool} arg3 + * @return {cc.Shaky3D} + */ +create : function ( +float, +size, +int, +bool +) +{ + return cc.Shaky3D; +}, + +/** + * @method Shaky3D + * @constructor + */ +Shaky3D : function ( +) +{ +}, + +}; + +/** + * @class Liquid + */ +cc.Liquid = { + +/** + * @method setAmplitudeRate + * @param {float} arg0 + */ +setAmplitudeRate : function ( +float +) +{ +}, + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {size_object} arg1 + * @param {unsigned int} arg2 + * @param {float} arg3 + * @return {bool} + */ +initWithDuration : function ( +float, +size, +int, +float +) +{ + return false; +}, + +/** + * @method getAmplitude + * @return {float} + */ +getAmplitude : function ( +) +{ + return 0; +}, + +/** + * @method getAmplitudeRate + * @return {float} + */ +getAmplitudeRate : function ( +) +{ + return 0; +}, + +/** + * @method setAmplitude + * @param {float} arg0 + */ +setAmplitude : function ( +float +) +{ +}, + +/** + * @method create + * @param {float} arg0 + * @param {size_object} arg1 + * @param {unsigned int} arg2 + * @param {float} arg3 + * @return {cc.Liquid} + */ +create : function ( +float, +size, +int, +float +) +{ + return cc.Liquid; +}, + +/** + * @method Liquid + * @constructor + */ +Liquid : function ( +) +{ +}, + +}; + +/** + * @class Waves + */ +cc.Waves = { + +/** + * @method setAmplitudeRate + * @param {float} arg0 + */ +setAmplitudeRate : function ( +float +) +{ +}, + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {size_object} arg1 + * @param {unsigned int} arg2 + * @param {float} arg3 + * @param {bool} arg4 + * @param {bool} arg5 + * @return {bool} + */ +initWithDuration : function ( +float, +size, +int, +float, +bool, +bool +) +{ + return false; +}, + +/** + * @method getAmplitude + * @return {float} + */ +getAmplitude : function ( +) +{ + return 0; +}, + +/** + * @method getAmplitudeRate + * @return {float} + */ +getAmplitudeRate : function ( +) +{ + return 0; +}, + +/** + * @method setAmplitude + * @param {float} arg0 + */ +setAmplitude : function ( +float +) +{ +}, + +/** + * @method create + * @param {float} arg0 + * @param {size_object} arg1 + * @param {unsigned int} arg2 + * @param {float} arg3 + * @param {bool} arg4 + * @param {bool} arg5 + * @return {cc.Waves} + */ +create : function ( +float, +size, +int, +float, +bool, +bool +) +{ + return cc.Waves; +}, + +/** + * @method Waves + * @constructor + */ +Waves : function ( +) +{ +}, + +}; + +/** + * @class Twirl + */ +cc.Twirl = { + +/** + * @method setAmplitudeRate + * @param {float} arg0 + */ +setAmplitudeRate : function ( +float +) +{ +}, + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {size_object} arg1 + * @param {vec2_object} arg2 + * @param {unsigned int} arg3 + * @param {float} arg4 + * @return {bool} + */ +initWithDuration : function ( +float, +size, +vec2, +int, +float +) +{ + return false; +}, + +/** + * @method getAmplitudeRate + * @return {float} + */ +getAmplitudeRate : function ( +) +{ + return 0; +}, + +/** + * @method setAmplitude + * @param {float} arg0 + */ +setAmplitude : function ( +float +) +{ +}, + +/** + * @method getAmplitude + * @return {float} + */ +getAmplitude : function ( +) +{ + return 0; +}, + +/** + * @method setPosition + * @param {vec2_object} arg0 + */ +setPosition : function ( +vec2 +) +{ +}, + +/** + * @method getPosition + * @return {vec2_object} + */ +getPosition : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method create + * @param {float} arg0 + * @param {size_object} arg1 + * @param {vec2_object} arg2 + * @param {unsigned int} arg3 + * @param {float} arg4 + * @return {cc.Twirl} + */ +create : function ( +float, +size, +vec2, +int, +float +) +{ + return cc.Twirl; +}, + +/** + * @method Twirl + * @constructor + */ +Twirl : function ( +) +{ +}, + +}; + +/** + * @class PageTurn3D + */ +cc.PageTurn3D = { + +/** + * @method create + * @param {float} arg0 + * @param {size_object} arg1 + * @return {cc.PageTurn3D} + */ +create : function ( +float, +size +) +{ + return cc.PageTurn3D; +}, + +}; + +/** + * @class ProgressTo + */ +cc.ProgressTo = { + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {float} arg1 + * @return {bool} + */ +initWithDuration : function ( +float, +float +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @param {float} arg1 + * @return {cc.ProgressTo} + */ +create : function ( +float, +float +) +{ + return cc.ProgressTo; +}, + +/** + * @method ProgressTo + * @constructor + */ +ProgressTo : function ( +) +{ +}, + +}; + +/** + * @class ProgressFromTo + */ +cc.ProgressFromTo = { + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @return {bool} + */ +initWithDuration : function ( +float, +float, +float +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @return {cc.ProgressFromTo} + */ +create : function ( +float, +float, +float +) +{ + return cc.ProgressFromTo; +}, + +/** + * @method ProgressFromTo + * @constructor + */ +ProgressFromTo : function ( +) +{ +}, + +}; + +/** + * @class ShakyTiles3D + */ +cc.ShakyTiles3D = { + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {size_object} arg1 + * @param {int} arg2 + * @param {bool} arg3 + * @return {bool} + */ +initWithDuration : function ( +float, +size, +int, +bool +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @param {size_object} arg1 + * @param {int} arg2 + * @param {bool} arg3 + * @return {cc.ShakyTiles3D} + */ +create : function ( +float, +size, +int, +bool +) +{ + return cc.ShakyTiles3D; +}, + +/** + * @method ShakyTiles3D + * @constructor + */ +ShakyTiles3D : function ( +) +{ +}, + +}; + +/** + * @class ShatteredTiles3D + */ +cc.ShatteredTiles3D = { + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {size_object} arg1 + * @param {int} arg2 + * @param {bool} arg3 + * @return {bool} + */ +initWithDuration : function ( +float, +size, +int, +bool +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @param {size_object} arg1 + * @param {int} arg2 + * @param {bool} arg3 + * @return {cc.ShatteredTiles3D} + */ +create : function ( +float, +size, +int, +bool +) +{ + return cc.ShatteredTiles3D; +}, + +/** + * @method ShatteredTiles3D + * @constructor + */ +ShatteredTiles3D : function ( +) +{ +}, + +}; + +/** + * @class ShuffleTiles + */ +cc.ShuffleTiles = { + +/** + * @method placeTile + * @param {vec2_object} arg0 + * @param {cc.Tile} arg1 + */ +placeTile : function ( +vec2, +tile +) +{ +}, + +/** + * @method shuffle + * @param {unsigned int} arg0 + * @param {unsigned int} arg1 + */ +shuffle : function ( +int, +int +) +{ +}, + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {size_object} arg1 + * @param {unsigned int} arg2 + * @return {bool} + */ +initWithDuration : function ( +float, +size, +int +) +{ + return false; +}, + +/** + * @method getDelta + * @param {size_object} arg0 + * @return {size_object} + */ +getDelta : function ( +size +) +{ + return cc.Size; +}, + +/** + * @method create + * @param {float} arg0 + * @param {size_object} arg1 + * @param {unsigned int} arg2 + * @return {cc.ShuffleTiles} + */ +create : function ( +float, +size, +int +) +{ + return cc.ShuffleTiles; +}, + +/** + * @method ShuffleTiles + * @constructor + */ +ShuffleTiles : function ( +) +{ +}, + +}; + +/** + * @class FadeOutTRTiles + */ +cc.FadeOutTRTiles = { + +/** + * @method turnOnTile + * @param {vec2_object} arg0 + */ +turnOnTile : function ( +vec2 +) +{ +}, + +/** + * @method turnOffTile + * @param {vec2_object} arg0 + */ +turnOffTile : function ( +vec2 +) +{ +}, + +/** + * @method transformTile + * @param {vec2_object} arg0 + * @param {float} arg1 + */ +transformTile : function ( +vec2, +float +) +{ +}, + +/** + * @method testFunc + * @param {size_object} arg0 + * @param {float} arg1 + * @return {float} + */ +testFunc : function ( +size, +float +) +{ + return 0; +}, + +/** + * @method create + * @param {float} arg0 + * @param {size_object} arg1 + * @return {cc.FadeOutTRTiles} + */ +create : function ( +float, +size +) +{ + return cc.FadeOutTRTiles; +}, + +/** + * @method FadeOutTRTiles + * @constructor + */ +FadeOutTRTiles : function ( +) +{ +}, + +}; + +/** + * @class FadeOutBLTiles + */ +cc.FadeOutBLTiles = { + +/** + * @method create + * @param {float} arg0 + * @param {size_object} arg1 + * @return {cc.FadeOutBLTiles} + */ +create : function ( +float, +size +) +{ + return cc.FadeOutBLTiles; +}, + +/** + * @method FadeOutBLTiles + * @constructor + */ +FadeOutBLTiles : function ( +) +{ +}, + +}; + +/** + * @class FadeOutUpTiles + */ +cc.FadeOutUpTiles = { + +/** + * @method create + * @param {float} arg0 + * @param {size_object} arg1 + * @return {cc.FadeOutUpTiles} + */ +create : function ( +float, +size +) +{ + return cc.FadeOutUpTiles; +}, + +/** + * @method FadeOutUpTiles + * @constructor + */ +FadeOutUpTiles : function ( +) +{ +}, + +}; + +/** + * @class FadeOutDownTiles + */ +cc.FadeOutDownTiles = { + +/** + * @method create + * @param {float} arg0 + * @param {size_object} arg1 + * @return {cc.FadeOutDownTiles} + */ +create : function ( +float, +size +) +{ + return cc.FadeOutDownTiles; +}, + +/** + * @method FadeOutDownTiles + * @constructor + */ +FadeOutDownTiles : function ( +) +{ +}, + +}; + +/** + * @class TurnOffTiles + */ +cc.TurnOffTiles = { + +/** + * @method turnOnTile + * @param {vec2_object} arg0 + */ +turnOnTile : function ( +vec2 +) +{ +}, + +/** + * @method turnOffTile + * @param {vec2_object} arg0 + */ +turnOffTile : function ( +vec2 +) +{ +}, + +/** + * @method shuffle + * @param {unsigned int} arg0 + * @param {unsigned int} arg1 + */ +shuffle : function ( +int, +int +) +{ +}, + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {size_object} arg1 + * @param {unsigned int} arg2 + * @return {bool} + */ +initWithDuration : function ( +float, +size, +int +) +{ + return false; +}, + +/** + * @method create +* @param {float|float} float +* @param {size_object|size_object} size +* @param {unsigned int} int +* @return {cc.TurnOffTiles|cc.TurnOffTiles} +*/ +create : function( +float, +size, +int +) +{ + return cc.TurnOffTiles; +}, + +/** + * @method TurnOffTiles + * @constructor + */ +TurnOffTiles : function ( +) +{ +}, + +}; + +/** + * @class WavesTiles3D + */ +cc.WavesTiles3D = { + +/** + * @method setAmplitudeRate + * @param {float} arg0 + */ +setAmplitudeRate : function ( +float +) +{ +}, + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {size_object} arg1 + * @param {unsigned int} arg2 + * @param {float} arg3 + * @return {bool} + */ +initWithDuration : function ( +float, +size, +int, +float +) +{ + return false; +}, + +/** + * @method getAmplitude + * @return {float} + */ +getAmplitude : function ( +) +{ + return 0; +}, + +/** + * @method getAmplitudeRate + * @return {float} + */ +getAmplitudeRate : function ( +) +{ + return 0; +}, + +/** + * @method setAmplitude + * @param {float} arg0 + */ +setAmplitude : function ( +float +) +{ +}, + +/** + * @method create + * @param {float} arg0 + * @param {size_object} arg1 + * @param {unsigned int} arg2 + * @param {float} arg3 + * @return {cc.WavesTiles3D} + */ +create : function ( +float, +size, +int, +float +) +{ + return cc.WavesTiles3D; +}, + +/** + * @method WavesTiles3D + * @constructor + */ +WavesTiles3D : function ( +) +{ +}, + +}; + +/** + * @class JumpTiles3D + */ +cc.JumpTiles3D = { + +/** + * @method setAmplitudeRate + * @param {float} arg0 + */ +setAmplitudeRate : function ( +float +) +{ +}, + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {size_object} arg1 + * @param {unsigned int} arg2 + * @param {float} arg3 + * @return {bool} + */ +initWithDuration : function ( +float, +size, +int, +float +) +{ + return false; +}, + +/** + * @method getAmplitude + * @return {float} + */ +getAmplitude : function ( +) +{ + return 0; +}, + +/** + * @method getAmplitudeRate + * @return {float} + */ +getAmplitudeRate : function ( +) +{ + return 0; +}, + +/** + * @method setAmplitude + * @param {float} arg0 + */ +setAmplitude : function ( +float +) +{ +}, + +/** + * @method create + * @param {float} arg0 + * @param {size_object} arg1 + * @param {unsigned int} arg2 + * @param {float} arg3 + * @return {cc.JumpTiles3D} + */ +create : function ( +float, +size, +int, +float +) +{ + return cc.JumpTiles3D; +}, + +/** + * @method JumpTiles3D + * @constructor + */ +JumpTiles3D : function ( +) +{ +}, + +}; + +/** + * @class SplitRows + */ +cc.SplitRows = { + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {unsigned int} arg1 + * @return {bool} + */ +initWithDuration : function ( +float, +int +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @param {unsigned int} arg1 + * @return {cc.SplitRows} + */ +create : function ( +float, +int +) +{ + return cc.SplitRows; +}, + +/** + * @method SplitRows + * @constructor + */ +SplitRows : function ( +) +{ +}, + +}; + +/** + * @class SplitCols + */ +cc.SplitCols = { + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {unsigned int} arg1 + * @return {bool} + */ +initWithDuration : function ( +float, +int +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @param {unsigned int} arg1 + * @return {cc.SplitCols} + */ +create : function ( +float, +int +) +{ + return cc.SplitCols; +}, + +/** + * @method SplitCols + * @constructor + */ +SplitCols : function ( +) +{ +}, + +}; + +/** + * @class ActionTween + */ +cc.ActionTween = { + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {String} arg1 + * @param {float} arg2 + * @param {float} arg3 + * @return {bool} + */ +initWithDuration : function ( +float, +str, +float, +float +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @param {String} arg1 + * @param {float} arg2 + * @param {float} arg3 + * @return {cc.ActionTween} + */ +create : function ( +float, +str, +float, +float +) +{ + return cc.ActionTween; +}, + +}; + +/** + * @class CardinalSplineTo + */ +cc.CardinalSplineTo = { + +/** + * @method getPoints + * @return {point_object} + */ +getPoints : function ( +) +{ + return cc.PointArray; +}, + +/** + * @method updatePosition + * @param {vec2_object} arg0 + */ +updatePosition : function ( +vec2 +) +{ +}, + +/** + * @method CardinalSplineTo + * @constructor + */ +CardinalSplineTo : function ( +) +{ +}, + +}; + +/** + * @class CardinalSplineBy + */ +cc.CardinalSplineBy = { + +/** + * @method CardinalSplineBy + * @constructor + */ +CardinalSplineBy : function ( +) +{ +}, + +}; + +/** + * @class CatmullRomTo + */ +cc.CatmullRomTo = { + +}; + +/** + * @class CatmullRomBy + */ +cc.CatmullRomBy = { + +}; + +/** + * @class ProtectedNode + */ +cc.ProtectedNode = { + +/** + * @method addProtectedChild +* @param {cc.Node|cc.Node|cc.Node} node +* @param {int|int} int +* @param {int} int +*/ +addProtectedChild : function( +node, +int, +int +) +{ +}, + +/** + * @method disableCascadeColor + */ +disableCascadeColor : function ( +) +{ +}, + +/** + * @method removeProtectedChildByTag + * @param {int} arg0 + * @param {bool} arg1 + */ +removeProtectedChildByTag : function ( +int, +bool +) +{ +}, + +/** + * @method reorderProtectedChild + * @param {cc.Node} arg0 + * @param {int} arg1 + */ +reorderProtectedChild : function ( +node, +int +) +{ +}, + +/** + * @method removeAllProtectedChildrenWithCleanup + * @param {bool} arg0 + */ +removeAllProtectedChildrenWithCleanup : function ( +bool +) +{ +}, + +/** + * @method disableCascadeOpacity + */ +disableCascadeOpacity : function ( +) +{ +}, + +/** + * @method sortAllProtectedChildren + */ +sortAllProtectedChildren : function ( +) +{ +}, + +/** + * @method getProtectedChildByTag + * @param {int} arg0 + * @return {cc.Node} + */ +getProtectedChildByTag : function ( +int +) +{ + return cc.Node; +}, + +/** + * @method removeProtectedChild + * @param {cc.Node} arg0 + * @param {bool} arg1 + */ +removeProtectedChild : function ( +node, +bool +) +{ +}, + +/** + * @method removeAllProtectedChildren + */ +removeAllProtectedChildren : function ( +) +{ +}, + +/** + * @method create + * @return {cc.ProtectedNode} + */ +create : function ( +) +{ + return cc.ProtectedNode; +}, + +/** + * @method ProtectedNode + * @constructor + */ +ProtectedNode : function ( +) +{ +}, + +}; + +/** + * @class GLProgramState + */ +cc.GLProgramState = { + +/** + * @method setUniformCallback +* @param {int|String} int +* @param {function|function} func +*/ +setUniformCallback : function( +str, +func +) +{ +}, + +/** + * @method getVertexAttribsFlags + * @return {unsigned int} + */ +getVertexAttribsFlags : function ( +) +{ + return 0; +}, + +/** + * @method setUniformVec2 +* @param {int|String} int +* @param {vec2_object|vec2_object} vec2 +*/ +setUniformVec2 : function( +str, +vec2 +) +{ +}, + +/** + * @method setUniformVec3 +* @param {int|String} int +* @param {vec3_object|vec3_object} vec3 +*/ +setUniformVec3 : function( +str, +vec3 +) +{ +}, + +/** + * @method setVertexAttribCallback + * @param {String} arg0 + * @param {function} arg1 + */ +setVertexAttribCallback : function ( +str, +func +) +{ +}, + +/** + * @method apply + * @param {mat4_object} arg0 + */ +apply : function ( +mat4 +) +{ +}, + +/** + * @method applyGLProgram + * @param {mat4_object} arg0 + */ +applyGLProgram : function ( +mat4 +) +{ +}, + +/** + * @method setUniformInt +* @param {int|String} int +* @param {int|int} int +*/ +setUniformInt : function( +str, +int +) +{ +}, + +/** + * @method setUniformVec2v +* @param {int|String} int +* @param {vec2_object|vec2_object} vec2 +* @param {long|long} long +*/ +setUniformVec2v : function( +str, +vec2, +long +) +{ +}, + +/** + * @method getUniformCount + * @return {long} + */ +getUniformCount : function ( +) +{ + return 0; +}, + +/** + * @method applyAttributes + */ +applyAttributes : function ( +) +{ +}, + +/** + * @method clone + * @return {cc.GLProgramState} + */ +clone : function ( +) +{ + return cc.GLProgramState; +}, + +/** + * @method setGLProgram + * @param {cc.GLProgram} arg0 + */ +setGLProgram : function ( +glprogram +) +{ +}, + +/** + * @method setUniformFloatv +* @param {int|String} int +* @param {float|float} float +* @param {long|long} long +*/ +setUniformFloatv : function( +str, +float, +long +) +{ +}, + +/** + * @method getGLProgram + * @return {cc.GLProgram} + */ +getGLProgram : function ( +) +{ + return cc.GLProgram; +}, + +/** + * @method setUniformTexture +* @param {String|String|int|int} str +* @param {unsigned int|cc.Texture2D|cc.Texture2D|unsigned int} int +*/ +setUniformTexture : function( +int, +int +) +{ +}, + +/** + * @method applyUniforms + */ +applyUniforms : function ( +) +{ +}, + +/** + * @method setUniformFloat +* @param {int|String} int +* @param {float|float} float +*/ +setUniformFloat : function( +str, +float +) +{ +}, + +/** + * @method setUniformMat4 +* @param {int|String} int +* @param {mat4_object|mat4_object} mat4 +*/ +setUniformMat4 : function( +str, +mat4 +) +{ +}, + +/** + * @method setUniformVec3v +* @param {int|String} int +* @param {vec3_object|vec3_object} vec3 +* @param {long|long} long +*/ +setUniformVec3v : function( +str, +vec3, +long +) +{ +}, + +/** + * @method getVertexAttribCount + * @return {long} + */ +getVertexAttribCount : function ( +) +{ + return 0; +}, + +/** + * @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; +}, + +/** + * @method getOrCreateWithShaders + * @param {String} arg0 + * @param {String} arg1 + * @param {String} arg2 + * @return {cc.GLProgramState} + */ +getOrCreateWithShaders : function ( +str, +str, +str +) +{ + return cc.GLProgramState; +}, + +}; + +/** + * @class AtlasNode + */ +cc.AtlasNode = { + +/** + * @method updateAtlasValues + */ +updateAtlasValues : function ( +) +{ +}, + +/** + * @method initWithTileFile + * @param {String} arg0 + * @param {int} arg1 + * @param {int} arg2 + * @param {int} arg3 + * @return {bool} + */ +initWithTileFile : function ( +str, +int, +int, +int +) +{ + return false; +}, + +/** + * @method getTexture + * @return {cc.Texture2D} + */ +getTexture : function ( +) +{ + return cc.Texture2D; +}, + +/** + * @method setTextureAtlas + * @param {cc.TextureAtlas} arg0 + */ +setTextureAtlas : function ( +textureatlas +) +{ +}, + +/** + * @method setBlendFunc + * @param {cc.BlendFunc} arg0 + */ +setBlendFunc : function ( +blendfunc +) +{ +}, + +/** + * @method getTextureAtlas + * @return {cc.TextureAtlas} + */ +getTextureAtlas : function ( +) +{ + return cc.TextureAtlas; +}, + +/** + * @method getBlendFunc + * @return {cc.BlendFunc} + */ +getBlendFunc : function ( +) +{ + return cc.BlendFunc; +}, + +/** + * @method getQuadsToDraw + * @return {long} + */ +getQuadsToDraw : function ( +) +{ + return 0; +}, + +/** + * @method setTexture + * @param {cc.Texture2D} arg0 + */ +setTexture : function ( +texture2d +) +{ +}, + +/** + * @method initWithTexture + * @param {cc.Texture2D} arg0 + * @param {int} arg1 + * @param {int} arg2 + * @param {int} arg3 + * @return {bool} + */ +initWithTexture : function ( +texture2d, +int, +int, +int +) +{ + return false; +}, + +/** + * @method setQuadsToDraw + * @param {long} arg0 + */ +setQuadsToDraw : function ( +long +) +{ +}, + +/** + * @method create + * @param {String} arg0 + * @param {int} arg1 + * @param {int} arg2 + * @param {int} arg3 + * @return {cc.AtlasNode} + */ +create : function ( +str, +int, +int, +int +) +{ + return cc.AtlasNode; +}, + +/** + * @method AtlasNode + * @constructor + */ +AtlasNode : function ( +) +{ +}, + +}; + +/** + * @class DrawNode + */ +cc.DrawNode = { + +/** + * @method drawLine + * @param {vec2_object} arg0 + * @param {vec2_object} arg1 + * @param {color4f_object} arg2 + */ +drawLine : function ( +vec2, +vec2, +color4f +) +{ +}, + +/** + * @method drawPoints +* @param {vec2_object|vec2_object} vec2 +* @param {unsigned int|unsigned int} int +* @param {float|color4f_object} float +* @param {color4f_object} color4f +*/ +drawPoints : function( +vec2, +int, +float, +color4f +) +{ +}, + +/** + * @method drawRect +* @param {vec2_object|vec2_object} vec2 +* @param {vec2_object|vec2_object} vec2 +* @param {vec2_object|color4f_object} vec2 +* @param {vec2_object} vec2 +* @param {color4f_object} color4f +*/ +drawRect : function( +vec2, +vec2, +vec2, +vec2, +color4f +) +{ +}, + +/** + * @method drawSolidCircle +* @param {vec2_object|vec2_object} vec2 +* @param {float|float} float +* @param {float|float} float +* @param {unsigned int|unsigned int} int +* @param {color4f_object|float} color4f +* @param {float} float +* @param {color4f_object} color4f +*/ +drawSolidCircle : function( +vec2, +float, +float, +int, +float, +float, +color4f +) +{ +}, + +/** + * @method onDrawGLPoint + * @param {mat4_object} arg0 + * @param {unsigned int} arg1 + */ +onDrawGLPoint : function ( +mat4, +int +) +{ +}, + +/** + * @method drawDot + * @param {vec2_object} arg0 + * @param {float} arg1 + * @param {color4f_object} arg2 + */ +drawDot : function ( +vec2, +float, +color4f +) +{ +}, + +/** + * @method drawCatmullRom + * @param {point_object} arg0 + * @param {unsigned int} arg1 + * @param {color4f_object} arg2 + */ +drawCatmullRom : function ( +pointarray, +int, +color4f +) +{ +}, + +/** + * @method drawSegment + * @param {vec2_object} arg0 + * @param {vec2_object} arg1 + * @param {float} arg2 + * @param {color4f_object} arg3 + */ +drawSegment : function ( +vec2, +vec2, +float, +color4f +) +{ +}, + +/** + * @method getBlendFunc + * @return {cc.BlendFunc} + */ +getBlendFunc : function ( +) +{ + return cc.BlendFunc; +}, + +/** + * @method onDraw + * @param {mat4_object} arg0 + * @param {unsigned int} arg1 + */ +onDraw : function ( +mat4, +int +) +{ +}, + +/** + * @method drawCircle +* @param {vec2_object|vec2_object} vec2 +* @param {float|float} float +* @param {float|float} float +* @param {unsigned int|unsigned int} int +* @param {bool|bool} bool +* @param {color4f_object|float} color4f +* @param {float} float +* @param {color4f_object} color4f +*/ +drawCircle : function( +vec2, +float, +float, +int, +bool, +float, +float, +color4f +) +{ +}, + +/** + * @method drawQuadBezier + * @param {vec2_object} arg0 + * @param {vec2_object} arg1 + * @param {vec2_object} arg2 + * @param {unsigned int} arg3 + * @param {color4f_object} arg4 + */ +drawQuadBezier : function ( +vec2, +vec2, +vec2, +int, +color4f +) +{ +}, + +/** + * @method onDrawGLLine + * @param {mat4_object} arg0 + * @param {unsigned int} arg1 + */ +onDrawGLLine : function ( +mat4, +int +) +{ +}, + +/** + * @method drawSolidPoly + * @param {vec2_object} arg0 + * @param {unsigned int} arg1 + * @param {color4f_object} arg2 + */ +drawSolidPoly : function ( +vec2, +int, +color4f +) +{ +}, + +/** + * @method drawTriangle + * @param {vec2_object} arg0 + * @param {vec2_object} arg1 + * @param {vec2_object} arg2 + * @param {color4f_object} arg3 + */ +drawTriangle : function ( +vec2, +vec2, +vec2, +color4f +) +{ +}, + +/** + * @method setBlendFunc + * @param {cc.BlendFunc} arg0 + */ +setBlendFunc : function ( +blendfunc +) +{ +}, + +/** + * @method clear + */ +clear : function ( +) +{ +}, + +/** + * @method drawCardinalSpline + * @param {point_object} arg0 + * @param {float} arg1 + * @param {unsigned int} arg2 + * @param {color4f_object} arg3 + */ +drawCardinalSpline : function ( +pointarray, +float, +int, +color4f +) +{ +}, + +/** + * @method drawSolidRect + * @param {vec2_object} arg0 + * @param {vec2_object} arg1 + * @param {color4f_object} arg2 + */ +drawSolidRect : function ( +vec2, +vec2, +color4f +) +{ +}, + +/** + * @method drawPoly + * @param {vec2_object} arg0 + * @param {unsigned int} arg1 + * @param {bool} arg2 + * @param {color4f_object} arg3 + */ +drawPoly : function ( +vec2, +int, +bool, +color4f +) +{ +}, + +/** + * @method drawPoint + * @param {vec2_object} arg0 + * @param {float} arg1 + * @param {color4f_object} arg2 + */ +drawPoint : function ( +vec2, +float, +color4f +) +{ +}, + +/** + * @method drawCubicBezier + * @param {vec2_object} arg0 + * @param {vec2_object} arg1 + * @param {vec2_object} arg2 + * @param {vec2_object} arg3 + * @param {unsigned int} arg4 + * @param {color4f_object} arg5 + */ +drawCubicBezier : function ( +vec2, +vec2, +vec2, +vec2, +int, +color4f +) +{ +}, + +/** + * @method create + * @return {cc.DrawNode} + */ +create : function ( +) +{ + return cc.DrawNode; +}, + +/** + * @method DrawNode + * @constructor + */ +DrawNode : function ( +) +{ +}, + +}; + +/** + * @class LabelAtlas + */ +cc.LabelAtlas = { + +/** + * @method setString + * @param {String} arg0 + */ +setString : function ( +str +) +{ +}, + +/** + * @method initWithString +* @param {String|String|String} str +* @param {String|String|cc.Texture2D} str +* @param {int|int} int +* @param {int|int} int +* @param {int|int} int +* @return {bool|bool|bool} +*/ +initWithString : function( +str, +texture2d, +int, +int, +int +) +{ + return false; +}, + +/** + * @method getString + * @return {String} + */ +getString : function ( +) +{ + return ; +}, + +/** + * @method create +* @param {String|String} str +* @param {String|String} str +* @param {int} int +* @param {int} int +* @param {int} int +* @return {cc.LabelAtlas|cc.LabelAtlas|cc.LabelAtlas} +*/ +create : function( +str, +str, +int, +int, +int +) +{ + return cc.LabelAtlas; +}, + +/** + * @method LabelAtlas + * @constructor + */ +LabelAtlas : function ( +) +{ +}, + +}; + +/** + * @class LabelTTF + */ +cc.LabelTTF = { + +/** + * @method enableShadow + * @param {size_object} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @param {bool} arg3 + */ +enableShadow : function ( +size, +float, +float, +bool +) +{ +}, + +/** + * @method setDimensions + * @param {size_object} arg0 + */ +setDimensions : function ( +size +) +{ +}, + +/** + * @method getFontSize + * @return {float} + */ +getFontSize : function ( +) +{ + return 0; +}, + +/** + * @method getString + * @return {String} + */ +getString : function ( +) +{ + return ; +}, + +/** + * @method setFlippedY + * @param {bool} arg0 + */ +setFlippedY : function ( +bool +) +{ +}, + +/** + * @method setFlippedX + * @param {bool} arg0 + */ +setFlippedX : function ( +bool +) +{ +}, + +/** + * @method setTextDefinition + * @param {cc.FontDefinition} arg0 + */ +setTextDefinition : function ( +fontdefinition +) +{ +}, + +/** + * @method setFontName + * @param {String} arg0 + */ +setFontName : function ( +str +) +{ +}, + +/** + * @method getHorizontalAlignment + * @return {cc.TextHAlignment} + */ +getHorizontalAlignment : function ( +) +{ + return 0; +}, + +/** + * @method initWithStringAndTextDefinition + * @param {String} arg0 + * @param {cc.FontDefinition} arg1 + * @return {bool} + */ +initWithStringAndTextDefinition : function ( +str, +fontdefinition +) +{ + return false; +}, + +/** + * @method setString + * @param {String} arg0 + */ +setString : function ( +str +) +{ +}, + +/** + * @method initWithString + * @param {String} arg0 + * @param {String} arg1 + * @param {float} arg2 + * @param {size_object} arg3 + * @param {cc.TextHAlignment} arg4 + * @param {cc.TextVAlignment} arg5 + * @return {bool} + */ +initWithString : function ( +str, +str, +float, +size, +texthalignment, +textvalignment +) +{ + return false; +}, + +/** + * @method setFontFillColor + * @param {color3b_object} arg0 + * @param {bool} arg1 + */ +setFontFillColor : function ( +color3b, +bool +) +{ +}, + +/** + * @method getBlendFunc + * @return {cc.BlendFunc} + */ +getBlendFunc : function ( +) +{ + return cc.BlendFunc; +}, + +/** + * @method enableStroke + * @param {color3b_object} arg0 + * @param {float} arg1 + * @param {bool} arg2 + */ +enableStroke : function ( +color3b, +float, +bool +) +{ +}, + +/** + * @method getDimensions + * @return {size_object} + */ +getDimensions : function ( +) +{ + return cc.Size; +}, + +/** + * @method setVerticalAlignment + * @param {cc.TextVAlignment} arg0 + */ +setVerticalAlignment : function ( +textvalignment +) +{ +}, + +/** + * @method setFontSize + * @param {float} arg0 + */ +setFontSize : function ( +float +) +{ +}, + +/** + * @method getVerticalAlignment + * @return {cc.TextVAlignment} + */ +getVerticalAlignment : function ( +) +{ + return 0; +}, + +/** + * @method getTextDefinition + * @return {cc.FontDefinition} + */ +getTextDefinition : function ( +) +{ + return cc.FontDefinition; +}, + +/** + * @method setBlendFunc + * @param {cc.BlendFunc} arg0 + */ +setBlendFunc : function ( +blendfunc +) +{ +}, + +/** + * @method getFontName + * @return {String} + */ +getFontName : function ( +) +{ + return ; +}, + +/** + * @method setHorizontalAlignment + * @param {cc.TextHAlignment} arg0 + */ +setHorizontalAlignment : function ( +texthalignment +) +{ +}, + +/** + * @method disableShadow + */ +disableShadow : function ( +) +{ +}, + +/** + * @method disableStroke + */ +disableStroke : function ( +) +{ +}, + +/** + * @method create +* @param {String} str +* @param {String} str +* @param {float} float +* @param {size_object} size +* @param {cc.TextHAlignment} texthalignment +* @param {cc.TextVAlignment} textvalignment +* @return {cc.LabelTTF|cc.LabelTTF} +*/ +create : function( +str, +str, +float, +size, +texthalignment, +textvalignment +) +{ + return cc.LabelTTF; +}, + +/** + * @method createWithFontDefinition + * @param {String} arg0 + * @param {cc.FontDefinition} arg1 + * @return {cc.LabelTTF} + */ +createWithFontDefinition : function ( +str, +fontdefinition +) +{ + return cc.LabelTTF; +}, + +/** + * @method LabelTTF + * @constructor + */ +LabelTTF : function ( +) +{ +}, + +}; + +/** + * @class SpriteBatchNode + */ +cc.SpriteBatchNode = { + +/** + * @method appendChild + * @param {cc.Sprite} arg0 + */ +appendChild : function ( +sprite +) +{ +}, + +/** + * @method addSpriteWithoutQuad + * @param {cc.Sprite} arg0 + * @param {int} arg1 + * @param {int} arg2 + * @return {cc.SpriteBatchNode} + */ +addSpriteWithoutQuad : function ( +sprite, +int, +int +) +{ + return cc.SpriteBatchNode; +}, + +/** + * @method reorderBatch + * @param {bool} arg0 + */ +reorderBatch : function ( +bool +) +{ +}, + +/** + * @method initWithTexture + * @param {cc.Texture2D} arg0 + * @param {long} arg1 + * @return {bool} + */ +initWithTexture : function ( +texture2d, +long +) +{ + return false; +}, + +/** + * @method getBlendFunc + * @return {cc.BlendFunc} + */ +getBlendFunc : function ( +) +{ + return cc.BlendFunc; +}, + +/** + * @method lowestAtlasIndexInChild + * @param {cc.Sprite} arg0 + * @return {long} + */ +lowestAtlasIndexInChild : function ( +sprite +) +{ + return 0; +}, + +/** + * @method atlasIndexForChild + * @param {cc.Sprite} arg0 + * @param {int} arg1 + * @return {long} + */ +atlasIndexForChild : function ( +sprite, +int +) +{ + return 0; +}, + +/** + * @method setTextureAtlas + * @param {cc.TextureAtlas} arg0 + */ +setTextureAtlas : function ( +textureatlas +) +{ +}, + +/** + * @method initWithFile + * @param {String} arg0 + * @param {long} arg1 + * @return {bool} + */ +initWithFile : function ( +str, +long +) +{ + return false; +}, + +/** + * @method getTexture + * @return {cc.Texture2D} + */ +getTexture : function ( +) +{ + return cc.Texture2D; +}, + +/** + * @method increaseAtlasCapacity + */ +increaseAtlasCapacity : function ( +) +{ +}, + +/** + * @method getTextureAtlas + * @return {cc.TextureAtlas} + */ +getTextureAtlas : function ( +) +{ + return cc.TextureAtlas; +}, + +/** + * @method insertQuadFromSprite + * @param {cc.Sprite} arg0 + * @param {long} arg1 + */ +insertQuadFromSprite : function ( +sprite, +long +) +{ +}, + +/** + * @method setTexture + * @param {cc.Texture2D} arg0 + */ +setTexture : function ( +texture2d +) +{ +}, + +/** + * @method rebuildIndexInOrder + * @param {cc.Sprite} arg0 + * @param {long} arg1 + * @return {long} + */ +rebuildIndexInOrder : function ( +sprite, +long +) +{ + return 0; +}, + +/** + * @method highestAtlasIndexInChild + * @param {cc.Sprite} arg0 + * @return {long} + */ +highestAtlasIndexInChild : function ( +sprite +) +{ + return 0; +}, + +/** + * @method removeChildAtIndex + * @param {long} arg0 + * @param {bool} arg1 + */ +removeChildAtIndex : function ( +long, +bool +) +{ +}, + +/** + * @method removeSpriteFromAtlas + * @param {cc.Sprite} arg0 + */ +removeSpriteFromAtlas : function ( +sprite +) +{ +}, + +/** + * @method setBlendFunc + * @param {cc.BlendFunc} arg0 + */ +setBlendFunc : function ( +blendfunc +) +{ +}, + +/** + * @method create + * @param {String} arg0 + * @param {long} arg1 + * @return {cc.SpriteBatchNode} + */ +create : function ( +str, +long +) +{ + return cc.SpriteBatchNode; +}, + +/** + * @method createWithTexture + * @param {cc.Texture2D} arg0 + * @param {long} arg1 + * @return {cc.SpriteBatchNode} + */ +createWithTexture : function ( +texture2d, +long +) +{ + return cc.SpriteBatchNode; +}, + +/** + * @method SpriteBatchNode + * @constructor + */ +SpriteBatchNode : function ( +) +{ +}, + +}; + +/** + * @class Label + */ +cc.Label = { + +/** + * @method isClipMarginEnabled + * @return {bool} + */ +isClipMarginEnabled : function ( +) +{ + return false; +}, + +/** + * @method enableShadow + */ +enableShadow : function ( +) +{ +}, + +/** + * @method setDimensions + * @param {float} arg0 + * @param {float} arg1 + */ +setDimensions : function ( +float, +float +) +{ +}, + +/** + * @method getString + * @return {String} + */ +getString : function ( +) +{ + return ; +}, + +/** + * @method getHeight + * @return {float} + */ +getHeight : function ( +) +{ + return 0; +}, + +/** + * @method disableEffect +* @param {cc.LabelEffect} labeleffect +*/ +disableEffect : function( +labeleffect +) +{ +}, + +/** + * @method getTextColor + * @return {color4b_object} + */ +getTextColor : function ( +) +{ + return cc.Color4B; +}, + +/** + * @method setWidth + * @param {float} arg0 + */ +setWidth : function ( +float +) +{ +}, + +/** + * @method getMaxLineWidth + * @return {float} + */ +getMaxLineWidth : function ( +) +{ + return 0; +}, + +/** + * @method getHorizontalAlignment + * @return {cc.TextHAlignment} + */ +getHorizontalAlignment : function ( +) +{ + return 0; +}, + +/** + * @method setClipMarginEnabled + * @param {bool} arg0 + */ +setClipMarginEnabled : function ( +bool +) +{ +}, + +/** + * @method setString + * @param {String} arg0 + */ +setString : function ( +str +) +{ +}, + +/** + * @method setSystemFontName + * @param {String} arg0 + */ +setSystemFontName : function ( +str +) +{ +}, + +/** + * @method setBMFontFilePath + * @param {String} arg0 + * @param {vec2_object} arg1 + * @return {bool} + */ +setBMFontFilePath : function ( +str, +vec2 +) +{ + return false; +}, + +/** + * @method setLineHeight + * @param {float} arg0 + */ +setLineHeight : function ( +float +) +{ +}, + +/** + * @method setSystemFontSize + * @param {float} arg0 + */ +setSystemFontSize : function ( +float +) +{ +}, + +/** + * @method updateContent + */ +updateContent : function ( +) +{ +}, + +/** + * @method getStringLength + * @return {int} + */ +getStringLength : function ( +) +{ + return 0; +}, + +/** + * @method setLineBreakWithoutSpace + * @param {bool} arg0 + */ +setLineBreakWithoutSpace : function ( +bool +) +{ +}, + +/** + * @method getStringNumLines + * @return {int} + */ +getStringNumLines : function ( +) +{ + return 0; +}, + +/** + * @method enableOutline + * @param {color4b_object} arg0 + * @param {int} arg1 + */ +enableOutline : function ( +color4b, +int +) +{ +}, + +/** + * @method getAdditionalKerning + * @return {float} + */ +getAdditionalKerning : function ( +) +{ + return 0; +}, + +/** + * @method setCharMap +* @param {cc.Texture2D|String|String} texture2d +* @param {int|int} int +* @param {int|int} int +* @param {int|int} int +* @return {bool|bool|bool} +*/ +setCharMap : function( +str, +int, +int, +int +) +{ + return false; +}, + +/** + * @method getDimensions + * @return {size_object} + */ +getDimensions : function ( +) +{ + return cc.Size; +}, + +/** + * @method setMaxLineWidth + * @param {float} arg0 + */ +setMaxLineWidth : function ( +float +) +{ +}, + +/** + * @method getSystemFontName + * @return {String} + */ +getSystemFontName : function ( +) +{ + return ; +}, + +/** + * @method setVerticalAlignment + * @param {cc.TextVAlignment} arg0 + */ +setVerticalAlignment : function ( +textvalignment +) +{ +}, + +/** + * @method getLineHeight + * @return {float} + */ +getLineHeight : function ( +) +{ + return 0; +}, + +/** + * @method getTTFConfig + * @return {cc._ttfConfig} + */ +getTTFConfig : function ( +) +{ + return cc._ttfConfig; +}, + +/** + * @method getVerticalAlignment + * @return {cc.TextVAlignment} + */ +getVerticalAlignment : function ( +) +{ + return 0; +}, + +/** + * @method setTextColor + * @param {color4b_object} arg0 + */ +setTextColor : function ( +color4b +) +{ +}, + +/** + * @method setHeight + * @param {float} arg0 + */ +setHeight : function ( +float +) +{ +}, + +/** + * @method getWidth + * @return {float} + */ +getWidth : function ( +) +{ + return 0; +}, + +/** + * @method enableGlow + * @param {color4b_object} arg0 + */ +enableGlow : function ( +color4b +) +{ +}, + +/** + * @method getLetter + * @param {int} arg0 + * @return {cc.Sprite} + */ +getLetter : function ( +int +) +{ + return cc.Sprite; +}, + +/** + * @method setAdditionalKerning + * @param {float} arg0 + */ +setAdditionalKerning : function ( +float +) +{ +}, + +/** + * @method getSystemFontSize + * @return {float} + */ +getSystemFontSize : function ( +) +{ + return 0; +}, + +/** + * @method getTextAlignment + * @return {cc.TextHAlignment} + */ +getTextAlignment : function ( +) +{ + return 0; +}, + +/** + * @method getBMFontFilePath + * @return {String} + */ +getBMFontFilePath : function ( +) +{ + return ; +}, + +/** + * @method setHorizontalAlignment + * @param {cc.TextHAlignment} arg0 + */ +setHorizontalAlignment : function ( +texthalignment +) +{ +}, + +/** + * @method setAlignment +* @param {cc.TextHAlignment|cc.TextHAlignment} texthalignment +* @param {cc.TextVAlignment} textvalignment +*/ +setAlignment : function( +texthalignment, +textvalignment +) +{ +}, + +/** + * @method requestSystemFontRefresh + */ +requestSystemFontRefresh : function ( +) +{ +}, + +/** + * @method createWithBMFont + * @param {String} arg0 + * @param {String} arg1 + * @param {cc.TextHAlignment} arg2 + * @param {int} arg3 + * @param {vec2_object} arg4 + * @return {cc.Label} + */ +createWithBMFont : function ( +str, +str, +texthalignment, +int, +vec2 +) +{ + return cc.Label; +}, + +/** + * @method create + * @return {cc.Label} + */ +create : function ( +) +{ + return cc.Label; +}, + +/** + * @method createWithCharMap +* @param {cc.Texture2D|String|String} texture2d +* @param {int|int} int +* @param {int|int} int +* @param {int|int} int +* @return {cc.Label|cc.Label|cc.Label} +*/ +createWithCharMap : function( +str, +int, +int, +int +) +{ + return cc.Label; +}, + +/** + * @method createWithSystemFont + * @param {String} arg0 + * @param {String} arg1 + * @param {float} arg2 + * @param {size_object} arg3 + * @param {cc.TextHAlignment} arg4 + * @param {cc.TextVAlignment} arg5 + * @return {cc.Label} + */ +createWithSystemFont : function ( +str, +str, +float, +size, +texthalignment, +textvalignment +) +{ + return cc.Label; +}, + +/** + * @method Label + * @constructor + */ +Label : function ( +) +{ +}, + +}; + +/** + * @class LabelBMFont + */ +cc.LabelBMFont = { + +/** + * @method setLineBreakWithoutSpace + * @param {bool} arg0 + */ +setLineBreakWithoutSpace : function ( +bool +) +{ +}, + +/** + * @method getBlendFunc + * @return {cc.BlendFunc} + */ +getBlendFunc : function ( +) +{ + return cc.BlendFunc; +}, + +/** + * @method getLetter + * @param {int} arg0 + * @return {cc.Sprite} + */ +getLetter : function ( +int +) +{ + return cc.Sprite; +}, + +/** + * @method getString + * @return {String} + */ +getString : function ( +) +{ + return ; +}, + +/** + * @method setBlendFunc + * @param {cc.BlendFunc} arg0 + */ +setBlendFunc : function ( +blendfunc +) +{ +}, + +/** + * @method setString + * @param {String} arg0 + */ +setString : function ( +str +) +{ +}, + +/** + * @method initWithString + * @param {String} arg0 + * @param {String} arg1 + * @param {float} arg2 + * @param {cc.TextHAlignment} arg3 + * @param {vec2_object} arg4 + * @return {bool} + */ +initWithString : function ( +str, +str, +float, +texthalignment, +vec2 +) +{ + return false; +}, + +/** + * @method getFntFile + * @return {String} + */ +getFntFile : function ( +) +{ + return ; +}, + +/** + * @method setFntFile + * @param {String} arg0 + * @param {vec2_object} arg1 + */ +setFntFile : function ( +str, +vec2 +) +{ +}, + +/** + * @method setAlignment + * @param {cc.TextHAlignment} arg0 + */ +setAlignment : function ( +texthalignment +) +{ +}, + +/** + * @method setWidth + * @param {float} arg0 + */ +setWidth : function ( +float +) +{ +}, + +/** + * @method create +* @param {String} str +* @param {String} str +* @param {float} float +* @param {cc.TextHAlignment} texthalignment +* @param {vec2_object} vec2 +* @return {cc.LabelBMFont|cc.LabelBMFont} +*/ +create : function( +str, +str, +float, +texthalignment, +vec2 +) +{ + return cc.LabelBMFont; +}, + +/** + * @method LabelBMFont + * @constructor + */ +LabelBMFont : function ( +) +{ +}, + +}; + +/** + * @class Layer + */ +cc.Layer = { + +/** + * @method create + * @return {cc.Layer} + */ +create : function ( +) +{ + return cc.Layer; +}, + +/** + * @method Layer + * @constructor + */ +Layer : function ( +) +{ +}, + +}; + +/** + * @class __LayerRGBA + */ +cc.LayerRGBA = { + +/** + * @method create + * @return {cc.__LayerRGBA} + */ +create : function ( +) +{ + return cc.__LayerRGBA; +}, + +/** + * @method __LayerRGBA + * @constructor + */ +__LayerRGBA : function ( +) +{ +}, + +}; + +/** + * @class LayerColor + */ +cc.LayerColor = { + +/** + * @method changeWidthAndHeight + * @param {float} arg0 + * @param {float} arg1 + */ +changeWidthAndHeight : function ( +float, +float +) +{ +}, + +/** + * @method getBlendFunc + * @return {cc.BlendFunc} + */ +getBlendFunc : function ( +) +{ + return cc.BlendFunc; +}, + +/** + * @method setBlendFunc + * @param {cc.BlendFunc} arg0 + */ +setBlendFunc : function ( +blendfunc +) +{ +}, + +/** + * @method changeWidth + * @param {float} arg0 + */ +changeWidth : function ( +float +) +{ +}, + +/** + * @method initWithColor +* @param {color4b_object|color4b_object} color4b +* @param {float} float +* @param {float} float +* @return {bool|bool} +*/ +initWithColor : function( +color4b, +float, +float +) +{ + return false; +}, + +/** + * @method changeHeight + * @param {float} arg0 + */ +changeHeight : function ( +float +) +{ +}, + +/** + * @method create +* @param {color4b_object|color4b_object} color4b +* @param {float} float +* @param {float} float +* @return {cc.LayerColor|cc.LayerColor|cc.LayerColor} +*/ +create : function( +color4b, +float, +float +) +{ + return cc.LayerColor; +}, + +/** + * @method LayerColor + * @constructor + */ +LayerColor : function ( +) +{ +}, + +}; + +/** + * @class LayerGradient + */ +cc.LayerGradient = { + +/** + * @method getStartColor + * @return {color3b_object} + */ +getStartColor : function ( +) +{ + return cc.Color3B; +}, + +/** + * @method isCompressedInterpolation + * @return {bool} + */ +isCompressedInterpolation : function ( +) +{ + return false; +}, + +/** + * @method getStartOpacity + * @return {unsigned char} + */ +getStartOpacity : function ( +) +{ + return 0; +}, + +/** + * @method setVector + * @param {vec2_object} arg0 + */ +setVector : function ( +vec2 +) +{ +}, + +/** + * @method setStartOpacity + * @param {unsigned char} arg0 + */ +setStartOpacity : function ( +char +) +{ +}, + +/** + * @method setCompressedInterpolation + * @param {bool} arg0 + */ +setCompressedInterpolation : function ( +bool +) +{ +}, + +/** + * @method setEndOpacity + * @param {unsigned char} arg0 + */ +setEndOpacity : function ( +char +) +{ +}, + +/** + * @method getVector + * @return {vec2_object} + */ +getVector : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method setEndColor + * @param {color3b_object} arg0 + */ +setEndColor : function ( +color3b +) +{ +}, + +/** + * @method initWithColor +* @param {color4b_object|color4b_object} color4b +* @param {color4b_object|color4b_object} color4b +* @param {vec2_object} vec2 +* @return {bool|bool} +*/ +initWithColor : function( +color4b, +color4b, +vec2 +) +{ + return false; +}, + +/** + * @method getEndColor + * @return {color3b_object} + */ +getEndColor : function ( +) +{ + return cc.Color3B; +}, + +/** + * @method getEndOpacity + * @return {unsigned char} + */ +getEndOpacity : function ( +) +{ + return 0; +}, + +/** + * @method setStartColor + * @param {color3b_object} arg0 + */ +setStartColor : function ( +color3b +) +{ +}, + +/** + * @method create +* @param {color4b_object|color4b_object} color4b +* @param {color4b_object|color4b_object} color4b +* @param {vec2_object} vec2 +* @return {cc.LayerGradient|cc.LayerGradient|cc.LayerGradient} +*/ +create : function( +color4b, +color4b, +vec2 +) +{ + return cc.LayerGradient; +}, + +/** + * @method LayerGradient + * @constructor + */ +LayerGradient : function ( +) +{ +}, + +}; + +/** + * @class LayerMultiplex + */ +cc.LayerMultiplex = { + +/** + * @method initWithArray + * @param {Array} arg0 + * @return {bool} + */ +initWithArray : function ( +array +) +{ + return false; +}, + +/** + * @method switchToAndReleaseMe + * @param {int} arg0 + */ +switchToAndReleaseMe : function ( +int +) +{ +}, + +/** + * @method addLayer + * @param {cc.Layer} arg0 + */ +addLayer : function ( +layer +) +{ +}, + +/** + * @method switchTo + * @param {int} arg0 + */ +switchTo : function ( +int +) +{ +}, + +/** + * @method LayerMultiplex + * @constructor + */ +LayerMultiplex : function ( +) +{ +}, + +}; + +/** + * @class TransitionEaseScene + */ +cc.TransitionEaseScene = { + +/** + * @method easeActionWithAction + * @param {cc.ActionInterval} arg0 + * @return {cc.ActionInterval} + */ +easeActionWithAction : function ( +actioninterval +) +{ + return cc.ActionInterval; +}, + +}; + +/** + * @class TransitionScene + */ +cc.TransitionScene = { + +/** + * @method getInScene + * @return {cc.Scene} + */ +getInScene : function ( +) +{ + return cc.Scene; +}, + +/** + * @method finish + */ +finish : function ( +) +{ +}, + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {bool} + */ +initWithDuration : function ( +float, +scene +) +{ + return false; +}, + +/** + * @method getDuration + * @return {float} + */ +getDuration : function ( +) +{ + return 0; +}, + +/** + * @method hideOutShowIn + */ +hideOutShowIn : function ( +) +{ +}, + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionScene} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionScene; +}, + +/** + * @method TransitionScene + * @constructor + */ +TransitionScene : function ( +) +{ +}, + +}; + +/** + * @class TransitionSceneOriented + */ +cc.TransitionSceneOriented = { + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @param {cc.TransitionScene::Orientation} arg2 + * @return {bool} + */ +initWithDuration : function ( +float, +scene, +orientation +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @param {cc.TransitionScene::Orientation} arg2 + * @return {cc.TransitionSceneOriented} + */ +create : function ( +float, +scene, +orientation +) +{ + return cc.TransitionSceneOriented; +}, + +/** + * @method TransitionSceneOriented + * @constructor + */ +TransitionSceneOriented : function ( +) +{ +}, + +}; + +/** + * @class TransitionRotoZoom + */ +cc.TransitionRotoZoom = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionRotoZoom} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionRotoZoom; +}, + +/** + * @method TransitionRotoZoom + * @constructor + */ +TransitionRotoZoom : function ( +) +{ +}, + +}; + +/** + * @class TransitionJumpZoom + */ +cc.TransitionJumpZoom = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionJumpZoom} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionJumpZoom; +}, + +/** + * @method TransitionJumpZoom + * @constructor + */ +TransitionJumpZoom : function ( +) +{ +}, + +}; + +/** + * @class TransitionMoveInL + */ +cc.TransitionMoveInL = { + +/** + * @method action + * @return {cc.ActionInterval} + */ +action : function ( +) +{ + return cc.ActionInterval; +}, + +/** + * @method easeActionWithAction + * @param {cc.ActionInterval} arg0 + * @return {cc.ActionInterval} + */ +easeActionWithAction : function ( +actioninterval +) +{ + return cc.ActionInterval; +}, + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionMoveInL} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionMoveInL; +}, + +/** + * @method TransitionMoveInL + * @constructor + */ +TransitionMoveInL : function ( +) +{ +}, + +}; + +/** + * @class TransitionMoveInR + */ +cc.TransitionMoveInR = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionMoveInR} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionMoveInR; +}, + +/** + * @method TransitionMoveInR + * @constructor + */ +TransitionMoveInR : function ( +) +{ +}, + +}; + +/** + * @class TransitionMoveInT + */ +cc.TransitionMoveInT = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionMoveInT} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionMoveInT; +}, + +/** + * @method TransitionMoveInT + * @constructor + */ +TransitionMoveInT : function ( +) +{ +}, + +}; + +/** + * @class TransitionMoveInB + */ +cc.TransitionMoveInB = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionMoveInB} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionMoveInB; +}, + +/** + * @method TransitionMoveInB + * @constructor + */ +TransitionMoveInB : function ( +) +{ +}, + +}; + +/** + * @class TransitionSlideInL + */ +cc.TransitionSlideInL = { + +/** + * @method action + * @return {cc.ActionInterval} + */ +action : function ( +) +{ + return cc.ActionInterval; +}, + +/** + * @method easeActionWithAction + * @param {cc.ActionInterval} arg0 + * @return {cc.ActionInterval} + */ +easeActionWithAction : function ( +actioninterval +) +{ + return cc.ActionInterval; +}, + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionSlideInL} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionSlideInL; +}, + +/** + * @method TransitionSlideInL + * @constructor + */ +TransitionSlideInL : function ( +) +{ +}, + +}; + +/** + * @class TransitionSlideInR + */ +cc.TransitionSlideInR = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionSlideInR} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionSlideInR; +}, + +/** + * @method TransitionSlideInR + * @constructor + */ +TransitionSlideInR : function ( +) +{ +}, + +}; + +/** + * @class TransitionSlideInB + */ +cc.TransitionSlideInB = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionSlideInB} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionSlideInB; +}, + +/** + * @method TransitionSlideInB + * @constructor + */ +TransitionSlideInB : function ( +) +{ +}, + +}; + +/** + * @class TransitionSlideInT + */ +cc.TransitionSlideInT = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionSlideInT} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionSlideInT; +}, + +/** + * @method TransitionSlideInT + * @constructor + */ +TransitionSlideInT : function ( +) +{ +}, + +}; + +/** + * @class TransitionShrinkGrow + */ +cc.TransitionShrinkGrow = { + +/** + * @method easeActionWithAction + * @param {cc.ActionInterval} arg0 + * @return {cc.ActionInterval} + */ +easeActionWithAction : function ( +actioninterval +) +{ + return cc.ActionInterval; +}, + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionShrinkGrow} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionShrinkGrow; +}, + +/** + * @method TransitionShrinkGrow + * @constructor + */ +TransitionShrinkGrow : function ( +) +{ +}, + +}; + +/** + * @class TransitionFlipX + */ +cc.TransitionFlipX = { + +/** + * @method create +* @param {float|float} float +* @param {cc.Scene|cc.Scene} scene +* @param {cc.TransitionScene::Orientation} orientation +* @return {cc.TransitionFlipX|cc.TransitionFlipX} +*/ +create : function( +float, +scene, +orientation +) +{ + return cc.TransitionFlipX; +}, + +/** + * @method TransitionFlipX + * @constructor + */ +TransitionFlipX : function ( +) +{ +}, + +}; + +/** + * @class TransitionFlipY + */ +cc.TransitionFlipY = { + +/** + * @method create +* @param {float|float} float +* @param {cc.Scene|cc.Scene} scene +* @param {cc.TransitionScene::Orientation} orientation +* @return {cc.TransitionFlipY|cc.TransitionFlipY} +*/ +create : function( +float, +scene, +orientation +) +{ + return cc.TransitionFlipY; +}, + +/** + * @method TransitionFlipY + * @constructor + */ +TransitionFlipY : function ( +) +{ +}, + +}; + +/** + * @class TransitionFlipAngular + */ +cc.TransitionFlipAngular = { + +/** + * @method create +* @param {float|float} float +* @param {cc.Scene|cc.Scene} scene +* @param {cc.TransitionScene::Orientation} orientation +* @return {cc.TransitionFlipAngular|cc.TransitionFlipAngular} +*/ +create : function( +float, +scene, +orientation +) +{ + return cc.TransitionFlipAngular; +}, + +/** + * @method TransitionFlipAngular + * @constructor + */ +TransitionFlipAngular : function ( +) +{ +}, + +}; + +/** + * @class TransitionZoomFlipX + */ +cc.TransitionZoomFlipX = { + +/** + * @method create +* @param {float|float} float +* @param {cc.Scene|cc.Scene} scene +* @param {cc.TransitionScene::Orientation} orientation +* @return {cc.TransitionZoomFlipX|cc.TransitionZoomFlipX} +*/ +create : function( +float, +scene, +orientation +) +{ + return cc.TransitionZoomFlipX; +}, + +/** + * @method TransitionZoomFlipX + * @constructor + */ +TransitionZoomFlipX : function ( +) +{ +}, + +}; + +/** + * @class TransitionZoomFlipY + */ +cc.TransitionZoomFlipY = { + +/** + * @method create +* @param {float|float} float +* @param {cc.Scene|cc.Scene} scene +* @param {cc.TransitionScene::Orientation} orientation +* @return {cc.TransitionZoomFlipY|cc.TransitionZoomFlipY} +*/ +create : function( +float, +scene, +orientation +) +{ + return cc.TransitionZoomFlipY; +}, + +/** + * @method TransitionZoomFlipY + * @constructor + */ +TransitionZoomFlipY : function ( +) +{ +}, + +}; + +/** + * @class TransitionZoomFlipAngular + */ +cc.TransitionZoomFlipAngular = { + +/** + * @method create +* @param {float|float} float +* @param {cc.Scene|cc.Scene} scene +* @param {cc.TransitionScene::Orientation} orientation +* @return {cc.TransitionZoomFlipAngular|cc.TransitionZoomFlipAngular} +*/ +create : function( +float, +scene, +orientation +) +{ + return cc.TransitionZoomFlipAngular; +}, + +/** + * @method TransitionZoomFlipAngular + * @constructor + */ +TransitionZoomFlipAngular : function ( +) +{ +}, + +}; + +/** + * @class TransitionFade + */ +cc.TransitionFade = { + +/** + * @method initWithDuration +* @param {float|float} float +* @param {cc.Scene|cc.Scene} scene +* @param {color3b_object} color3b +* @return {bool|bool} +*/ +initWithDuration : function( +float, +scene, +color3b +) +{ + return false; +}, + +/** + * @method create +* @param {float|float} float +* @param {cc.Scene|cc.Scene} scene +* @param {color3b_object} color3b +* @return {cc.TransitionFade|cc.TransitionFade} +*/ +create : function( +float, +scene, +color3b +) +{ + return cc.TransitionFade; +}, + +/** + * @method TransitionFade + * @constructor + */ +TransitionFade : function ( +) +{ +}, + +}; + +/** + * @class TransitionCrossFade + */ +cc.TransitionCrossFade = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionCrossFade} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionCrossFade; +}, + +/** + * @method TransitionCrossFade + * @constructor + */ +TransitionCrossFade : function ( +) +{ +}, + +}; + +/** + * @class TransitionTurnOffTiles + */ +cc.TransitionTurnOffTiles = { + +/** + * @method easeActionWithAction + * @param {cc.ActionInterval} arg0 + * @return {cc.ActionInterval} + */ +easeActionWithAction : function ( +actioninterval +) +{ + return cc.ActionInterval; +}, + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionTurnOffTiles} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionTurnOffTiles; +}, + +/** + * @method TransitionTurnOffTiles + * @constructor + */ +TransitionTurnOffTiles : function ( +) +{ +}, + +}; + +/** + * @class TransitionSplitCols + */ +cc.TransitionSplitCols = { + +/** + * @method action + * @return {cc.ActionInterval} + */ +action : function ( +) +{ + return cc.ActionInterval; +}, + +/** + * @method easeActionWithAction + * @param {cc.ActionInterval} arg0 + * @return {cc.ActionInterval} + */ +easeActionWithAction : function ( +actioninterval +) +{ + return cc.ActionInterval; +}, + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionSplitCols} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionSplitCols; +}, + +/** + * @method TransitionSplitCols + * @constructor + */ +TransitionSplitCols : function ( +) +{ +}, + +}; + +/** + * @class TransitionSplitRows + */ +cc.TransitionSplitRows = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionSplitRows} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionSplitRows; +}, + +/** + * @method TransitionSplitRows + * @constructor + */ +TransitionSplitRows : function ( +) +{ +}, + +}; + +/** + * @class TransitionFadeTR + */ +cc.TransitionFadeTR = { + +/** + * @method easeActionWithAction + * @param {cc.ActionInterval} arg0 + * @return {cc.ActionInterval} + */ +easeActionWithAction : function ( +actioninterval +) +{ + return cc.ActionInterval; +}, + +/** + * @method actionWithSize + * @param {size_object} arg0 + * @return {cc.ActionInterval} + */ +actionWithSize : function ( +size +) +{ + return cc.ActionInterval; +}, + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionFadeTR} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionFadeTR; +}, + +/** + * @method TransitionFadeTR + * @constructor + */ +TransitionFadeTR : function ( +) +{ +}, + +}; + +/** + * @class TransitionFadeBL + */ +cc.TransitionFadeBL = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionFadeBL} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionFadeBL; +}, + +/** + * @method TransitionFadeBL + * @constructor + */ +TransitionFadeBL : function ( +) +{ +}, + +}; + +/** + * @class TransitionFadeUp + */ +cc.TransitionFadeUp = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionFadeUp} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionFadeUp; +}, + +/** + * @method TransitionFadeUp + * @constructor + */ +TransitionFadeUp : function ( +) +{ +}, + +}; + +/** + * @class TransitionFadeDown + */ +cc.TransitionFadeDown = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionFadeDown} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionFadeDown; +}, + +/** + * @method TransitionFadeDown + * @constructor + */ +TransitionFadeDown : function ( +) +{ +}, + +}; + +/** + * @class TransitionPageTurn + */ +cc.TransitionPageTurn = { + +/** + * @method actionWithSize + * @param {size_object} arg0 + * @return {cc.ActionInterval} + */ +actionWithSize : function ( +size +) +{ + return cc.ActionInterval; +}, + +/** + * @method initWithDuration + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @param {bool} arg2 + * @return {bool} + */ +initWithDuration : function ( +float, +scene, +bool +) +{ + return false; +}, + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @param {bool} arg2 + * @return {cc.TransitionPageTurn} + */ +create : function ( +float, +scene, +bool +) +{ + return cc.TransitionPageTurn; +}, + +/** + * @method TransitionPageTurn + * @constructor + */ +TransitionPageTurn : function ( +) +{ +}, + +}; + +/** + * @class TransitionProgress + */ +cc.TransitionProgress = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionProgress} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionProgress; +}, + +/** + * @method TransitionProgress + * @constructor + */ +TransitionProgress : function ( +) +{ +}, + +}; + +/** + * @class TransitionProgressRadialCCW + */ +cc.TransitionProgressRadialCCW = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionProgressRadialCCW} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionProgressRadialCCW; +}, + +/** + * @method TransitionProgressRadialCCW + * @constructor + */ +TransitionProgressRadialCCW : function ( +) +{ +}, + +}; + +/** + * @class TransitionProgressRadialCW + */ +cc.TransitionProgressRadialCW = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionProgressRadialCW} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionProgressRadialCW; +}, + +/** + * @method TransitionProgressRadialCW + * @constructor + */ +TransitionProgressRadialCW : function ( +) +{ +}, + +}; + +/** + * @class TransitionProgressHorizontal + */ +cc.TransitionProgressHorizontal = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionProgressHorizontal} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionProgressHorizontal; +}, + +/** + * @method TransitionProgressHorizontal + * @constructor + */ +TransitionProgressHorizontal : function ( +) +{ +}, + +}; + +/** + * @class TransitionProgressVertical + */ +cc.TransitionProgressVertical = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionProgressVertical} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionProgressVertical; +}, + +/** + * @method TransitionProgressVertical + * @constructor + */ +TransitionProgressVertical : function ( +) +{ +}, + +}; + +/** + * @class TransitionProgressInOut + */ +cc.TransitionProgressInOut = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionProgressInOut} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionProgressInOut; +}, + +/** + * @method TransitionProgressInOut + * @constructor + */ +TransitionProgressInOut : function ( +) +{ +}, + +}; + +/** + * @class TransitionProgressOutIn + */ +cc.TransitionProgressOutIn = { + +/** + * @method create + * @param {float} arg0 + * @param {cc.Scene} arg1 + * @return {cc.TransitionProgressOutIn} + */ +create : function ( +float, +scene +) +{ + return cc.TransitionProgressOutIn; +}, + +/** + * @method TransitionProgressOutIn + * @constructor + */ +TransitionProgressOutIn : function ( +) +{ +}, + +}; + +/** + * @class MenuItem + */ +cc.MenuItem = { + +/** + * @method setEnabled + * @param {bool} arg0 + */ +setEnabled : function ( +bool +) +{ +}, + +/** + * @method activate + */ +activate : function ( +) +{ +}, + +/** + * @method initWithCallback + * @param {function} arg0 + * @return {bool} + */ +initWithCallback : function ( +func +) +{ + return false; +}, + +/** + * @method isEnabled + * @return {bool} + */ +isEnabled : function ( +) +{ + return false; +}, + +/** + * @method selected + */ +selected : function ( +) +{ +}, + +/** + * @method isSelected + * @return {bool} + */ +isSelected : function ( +) +{ + return false; +}, + +/** + * @method unselected + */ +unselected : function ( +) +{ +}, + +/** + * @method rect + * @return {rect_object} + */ +rect : function ( +) +{ + return cc.Rect; +}, + +/** + * @method MenuItem + * @constructor + */ +MenuItem : function ( +) +{ +}, + +}; + +/** + * @class MenuItemLabel + */ +cc.MenuItemLabel = { + +/** + * @method setLabel + * @param {cc.Node} arg0 + */ +setLabel : function ( +node +) +{ +}, + +/** + * @method getDisabledColor + * @return {color3b_object} + */ +getDisabledColor : function ( +) +{ + return cc.Color3B; +}, + +/** + * @method setString + * @param {String} arg0 + */ +setString : function ( +str +) +{ +}, + +/** + * @method initWithLabel + * @param {cc.Node} arg0 + * @param {function} arg1 + * @return {bool} + */ +initWithLabel : function ( +node, +func +) +{ + return false; +}, + +/** + * @method setDisabledColor + * @param {color3b_object} arg0 + */ +setDisabledColor : function ( +color3b +) +{ +}, + +/** + * @method getLabel + * @return {cc.Node} + */ +getLabel : function ( +) +{ + return cc.Node; +}, + +/** + * @method MenuItemLabel + * @constructor + */ +MenuItemLabel : function ( +) +{ +}, + +}; + +/** + * @class MenuItemAtlasFont + */ +cc.MenuItemAtlasFont = { + +/** + * @method initWithString + * @param {String} arg0 + * @param {String} arg1 + * @param {int} arg2 + * @param {int} arg3 + * @param {char} arg4 + * @param {function} arg5 + * @return {bool} + */ +initWithString : function ( +str, +str, +int, +int, +char, +func +) +{ + return false; +}, + +/** + * @method MenuItemAtlasFont + * @constructor + */ +MenuItemAtlasFont : function ( +) +{ +}, + +}; + +/** + * @class MenuItemFont + */ +cc.MenuItemFont = { + +/** + * @method setFontNameObj + * @param {String} arg0 + */ +setFontNameObj : function ( +str +) +{ +}, + +/** + * @method getFontSizeObj + * @return {int} + */ +getFontSizeObj : function ( +) +{ + return 0; +}, + +/** + * @method setFontSizeObj + * @param {int} arg0 + */ +setFontSizeObj : function ( +int +) +{ +}, + +/** + * @method initWithString + * @param {String} arg0 + * @param {function} arg1 + * @return {bool} + */ +initWithString : function ( +str, +func +) +{ + return false; +}, + +/** + * @method getFontNameObj + * @return {String} + */ +getFontNameObj : function ( +) +{ + return ; +}, + +/** + * @method setFontName + * @param {String} arg0 + */ +setFontName : function ( +str +) +{ +}, + +/** + * @method getFontSize + * @return {int} + */ +getFontSize : function ( +) +{ + return 0; +}, + +/** + * @method getFontName + * @return {String} + */ +getFontName : function ( +) +{ + return ; +}, + +/** + * @method setFontSize + * @param {int} arg0 + */ +setFontSize : function ( +int +) +{ +}, + +/** + * @method MenuItemFont + * @constructor + */ +MenuItemFont : function ( +) +{ +}, + +}; + +/** + * @class MenuItemSprite + */ +cc.MenuItemSprite = { + +/** + * @method setEnabled + * @param {bool} arg0 + */ +setEnabled : function ( +bool +) +{ +}, + +/** + * @method selected + */ +selected : function ( +) +{ +}, + +/** + * @method setNormalImage + * @param {cc.Node} arg0 + */ +setNormalImage : function ( +node +) +{ +}, + +/** + * @method setDisabledImage + * @param {cc.Node} arg0 + */ +setDisabledImage : function ( +node +) +{ +}, + +/** + * @method initWithNormalSprite + * @param {cc.Node} arg0 + * @param {cc.Node} arg1 + * @param {cc.Node} arg2 + * @param {function} arg3 + * @return {bool} + */ +initWithNormalSprite : function ( +node, +node, +node, +func +) +{ + return false; +}, + +/** + * @method setSelectedImage + * @param {cc.Node} arg0 + */ +setSelectedImage : function ( +node +) +{ +}, + +/** + * @method getDisabledImage + * @return {cc.Node} + */ +getDisabledImage : function ( +) +{ + return cc.Node; +}, + +/** + * @method getSelectedImage + * @return {cc.Node} + */ +getSelectedImage : function ( +) +{ + return cc.Node; +}, + +/** + * @method getNormalImage + * @return {cc.Node} + */ +getNormalImage : function ( +) +{ + return cc.Node; +}, + +/** + * @method unselected + */ +unselected : function ( +) +{ +}, + +/** + * @method MenuItemSprite + * @constructor + */ +MenuItemSprite : function ( +) +{ +}, + +}; + +/** + * @class MenuItemImage + */ +cc.MenuItemImage = { + +/** + * @method setDisabledSpriteFrame + * @param {cc.SpriteFrame} arg0 + */ +setDisabledSpriteFrame : function ( +spriteframe +) +{ +}, + +/** + * @method setSelectedSpriteFrame + * @param {cc.SpriteFrame} arg0 + */ +setSelectedSpriteFrame : function ( +spriteframe +) +{ +}, + +/** + * @method setNormalSpriteFrame + * @param {cc.SpriteFrame} arg0 + */ +setNormalSpriteFrame : function ( +spriteframe +) +{ +}, + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method initWithNormalImage + * @param {String} arg0 + * @param {String} arg1 + * @param {String} arg2 + * @param {function} arg3 + * @return {bool} + */ +initWithNormalImage : function ( +str, +str, +str, +func +) +{ + return false; +}, + +/** + * @method MenuItemImage + * @constructor + */ +MenuItemImage : function ( +) +{ +}, + +}; + +/** + * @class MenuItemToggle + */ +cc.MenuItemToggle = { + +/** + * @method setSubItems + * @param {Array} arg0 + */ +setSubItems : function ( +array +) +{ +}, + +/** + * @method initWithItem + * @param {cc.MenuItem} arg0 + * @return {bool} + */ +initWithItem : function ( +menuitem +) +{ + return false; +}, + +/** + * @method getSelectedIndex + * @return {unsigned int} + */ +getSelectedIndex : function ( +) +{ + return 0; +}, + +/** + * @method addSubItem + * @param {cc.MenuItem} arg0 + */ +addSubItem : function ( +menuitem +) +{ +}, + +/** + * @method getSelectedItem + * @return {cc.MenuItem} + */ +getSelectedItem : function ( +) +{ + return cc.MenuItem; +}, + +/** + * @method setSelectedIndex + * @param {unsigned int} arg0 + */ +setSelectedIndex : function ( +int +) +{ +}, + +/** + * @method MenuItemToggle + * @constructor + */ +MenuItemToggle : function ( +) +{ +}, + +}; + +/** + * @class Menu + */ +cc.Menu = { + +/** + * @method initWithArray + * @param {Array} arg0 + * @return {bool} + */ +initWithArray : function ( +array +) +{ + return false; +}, + +/** + * @method setEnabled + * @param {bool} arg0 + */ +setEnabled : function ( +bool +) +{ +}, + +/** + * @method alignItemsVertically + */ +alignItemsVertically : function ( +) +{ +}, + +/** + * @method isEnabled + * @return {bool} + */ +isEnabled : function ( +) +{ + return false; +}, + +/** + * @method alignItemsHorizontallyWithPadding + * @param {float} arg0 + */ +alignItemsHorizontallyWithPadding : function ( +float +) +{ +}, + +/** + * @method alignItemsVerticallyWithPadding + * @param {float} arg0 + */ +alignItemsVerticallyWithPadding : function ( +float +) +{ +}, + +/** + * @method alignItemsHorizontally + */ +alignItemsHorizontally : function ( +) +{ +}, + +/** + * @method Menu + * @constructor + */ +Menu : function ( +) +{ +}, + +}; + +/** + * @class ClippingNode + */ +cc.ClippingNode = { + +/** + * @method hasContent + * @return {bool} + */ +hasContent : function ( +) +{ + return false; +}, + +/** + * @method setInverted + * @param {bool} arg0 + */ +setInverted : function ( +bool +) +{ +}, + +/** + * @method setStencil + * @param {cc.Node} arg0 + */ +setStencil : function ( +node +) +{ +}, + +/** + * @method getAlphaThreshold + * @return {float} + */ +getAlphaThreshold : function ( +) +{ + return 0; +}, + +/** + * @method getStencil + * @return {cc.Node} + */ +getStencil : function ( +) +{ + return cc.Node; +}, + +/** + * @method setAlphaThreshold + * @param {float} arg0 + */ +setAlphaThreshold : function ( +float +) +{ +}, + +/** + * @method isInverted + * @return {bool} + */ +isInverted : function ( +) +{ + return false; +}, + +/** + * @method create +* @param {cc.Node} node +* @return {cc.ClippingNode|cc.ClippingNode} +*/ +create : function( +node +) +{ + return cc.ClippingNode; +}, + +/** + * @method ClippingNode + * @constructor + */ +ClippingNode : function ( +) +{ +}, + +}; + +/** + * @class MotionStreak + */ +cc.MotionStreak = { + +/** + * @method reset + */ +reset : function ( +) +{ +}, + +/** + * @method setTexture + * @param {cc.Texture2D} arg0 + */ +setTexture : function ( +texture2d +) +{ +}, + +/** + * @method getTexture + * @return {cc.Texture2D} + */ +getTexture : function ( +) +{ + return cc.Texture2D; +}, + +/** + * @method tintWithColor + * @param {color3b_object} arg0 + */ +tintWithColor : function ( +color3b +) +{ +}, + +/** + * @method setBlendFunc + * @param {cc.BlendFunc} arg0 + */ +setBlendFunc : function ( +blendfunc +) +{ +}, + +/** + * @method setStartingPositionInitialized + * @param {bool} arg0 + */ +setStartingPositionInitialized : function ( +bool +) +{ +}, + +/** + * @method getBlendFunc + * @return {cc.BlendFunc} + */ +getBlendFunc : function ( +) +{ + return cc.BlendFunc; +}, + +/** + * @method isStartingPositionInitialized + * @return {bool} + */ +isStartingPositionInitialized : function ( +) +{ + return false; +}, + +/** + * @method isFastMode + * @return {bool} + */ +isFastMode : function ( +) +{ + return false; +}, + +/** + * @method getStroke + * @return {float} + */ +getStroke : function ( +) +{ + return 0; +}, + +/** + * @method initWithFade +* @param {float|float} float +* @param {float|float} float +* @param {float|float} float +* @param {color3b_object|color3b_object} color3b +* @param {cc.Texture2D|String} texture2d +* @return {bool|bool} +*/ +initWithFade : function( +float, +float, +float, +color3b, +str +) +{ + return false; +}, + +/** + * @method setFastMode + * @param {bool} arg0 + */ +setFastMode : function ( +bool +) +{ +}, + +/** + * @method setStroke + * @param {float} arg0 + */ +setStroke : function ( +float +) +{ +}, + +/** + * @method create +* @param {float|float} float +* @param {float|float} float +* @param {float|float} float +* @param {color3b_object|color3b_object} color3b +* @param {cc.Texture2D|String} texture2d +* @return {cc.MotionStreak|cc.MotionStreak} +*/ +create : function( +float, +float, +float, +color3b, +str +) +{ + return cc.MotionStreak; +}, + +/** + * @method MotionStreak + * @constructor + */ +MotionStreak : function ( +) +{ +}, + +}; + +/** + * @class ProgressTimer + */ +cc.ProgressTimer = { + +/** + * @method initWithSprite + * @param {cc.Sprite} arg0 + * @return {bool} + */ +initWithSprite : function ( +sprite +) +{ + return false; +}, + +/** + * @method isReverseDirection + * @return {bool} + */ +isReverseDirection : function ( +) +{ + return false; +}, + +/** + * @method setBarChangeRate + * @param {vec2_object} arg0 + */ +setBarChangeRate : function ( +vec2 +) +{ +}, + +/** + * @method getPercentage + * @return {float} + */ +getPercentage : function ( +) +{ + return 0; +}, + +/** + * @method setSprite + * @param {cc.Sprite} arg0 + */ +setSprite : function ( +sprite +) +{ +}, + +/** + * @method getType + * @return {cc.ProgressTimer::Type} + */ +getType : function ( +) +{ + return 0; +}, + +/** + * @method getSprite + * @return {cc.Sprite} + */ +getSprite : function ( +) +{ + return cc.Sprite; +}, + +/** + * @method setMidpoint + * @param {vec2_object} arg0 + */ +setMidpoint : function ( +vec2 +) +{ +}, + +/** + * @method getBarChangeRate + * @return {vec2_object} + */ +getBarChangeRate : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method setReverseDirection +* @param {bool|bool} bool +*/ +setReverseDirection : function( +bool +) +{ +}, + +/** + * @method getMidpoint + * @return {vec2_object} + */ +getMidpoint : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method setPercentage + * @param {float} arg0 + */ +setPercentage : function ( +float +) +{ +}, + +/** + * @method setType + * @param {cc.ProgressTimer::Type} arg0 + */ +setType : function ( +type +) +{ +}, + +/** + * @method create + * @param {cc.Sprite} arg0 + * @return {cc.ProgressTimer} + */ +create : function ( +sprite +) +{ + return cc.ProgressTimer; +}, + +/** + * @method ProgressTimer + * @constructor + */ +ProgressTimer : function ( +) +{ +}, + +}; + +/** + * @class Sprite + */ +cc.Sprite = { + +/** + * @method setSpriteFrame +* @param {cc.SpriteFrame|String} spriteframe +*/ +setSpriteFrame : function( +str +) +{ +}, + +/** + * @method setTexture +* @param {cc.Texture2D|String} texture2d +*/ +setTexture : function( +str +) +{ +}, + +/** + * @method getTexture + * @return {cc.Texture2D} + */ +getTexture : function ( +) +{ + return cc.Texture2D; +}, + +/** + * @method setFlippedY + * @param {bool} arg0 + */ +setFlippedY : function ( +bool +) +{ +}, + +/** + * @method setFlippedX + * @param {bool} arg0 + */ +setFlippedX : function ( +bool +) +{ +}, + +/** + * @method setRotationSkewX + * @param {float} arg0 + */ +setRotationSkewX : function ( +float +) +{ +}, + +/** + * @method setRotationSkewY + * @param {float} arg0 + */ +setRotationSkewY : function ( +float +) +{ +}, + +/** + * @method initWithTexture +* @param {cc.Texture2D|cc.Texture2D|cc.Texture2D} texture2d +* @param {rect_object|rect_object} rect +* @param {bool} bool +* @return {bool|bool|bool} +*/ +initWithTexture : function( +texture2d, +rect, +bool +) +{ + return false; +}, + +/** + * @method getBatchNode + * @return {cc.SpriteBatchNode} + */ +getBatchNode : function ( +) +{ + return cc.SpriteBatchNode; +}, + +/** + * @method getOffsetPosition + * @return {vec2_object} + */ +getOffsetPosition : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method removeAllChildrenWithCleanup + * @param {bool} arg0 + */ +removeAllChildrenWithCleanup : function ( +bool +) +{ +}, + +/** + * @method setTextureRect +* @param {rect_object|rect_object} rect +* @param {bool} bool +* @param {size_object} size +*/ +setTextureRect : function( +rect, +bool, +size +) +{ +}, + +/** + * @method initWithSpriteFrameName + * @param {String} arg0 + * @return {bool} + */ +initWithSpriteFrameName : function ( +str +) +{ + return false; +}, + +/** + * @method isFrameDisplayed + * @param {cc.SpriteFrame} arg0 + * @return {bool} + */ +isFrameDisplayed : function ( +spriteframe +) +{ + return false; +}, + +/** + * @method getAtlasIndex + * @return {long} + */ +getAtlasIndex : function ( +) +{ + return 0; +}, + +/** + * @method setBatchNode + * @param {cc.SpriteBatchNode} arg0 + */ +setBatchNode : function ( +spritebatchnode +) +{ +}, + +/** + * @method getBlendFunc + * @return {cc.BlendFunc} + */ +getBlendFunc : function ( +) +{ + return cc.BlendFunc; +}, + +/** + * @method setDisplayFrameWithAnimationName + * @param {String} arg0 + * @param {long} arg1 + */ +setDisplayFrameWithAnimationName : function ( +str, +long +) +{ +}, + +/** + * @method setTextureAtlas + * @param {cc.TextureAtlas} arg0 + */ +setTextureAtlas : function ( +textureatlas +) +{ +}, + +/** + * @method getSpriteFrame + * @return {cc.SpriteFrame} + */ +getSpriteFrame : function ( +) +{ + return cc.SpriteFrame; +}, + +/** + * @method isDirty + * @return {bool} + */ +isDirty : function ( +) +{ + return false; +}, + +/** + * @method setAtlasIndex + * @param {long} arg0 + */ +setAtlasIndex : function ( +long +) +{ +}, + +/** + * @method setDirty + * @param {bool} arg0 + */ +setDirty : function ( +bool +) +{ +}, + +/** + * @method isTextureRectRotated + * @return {bool} + */ +isTextureRectRotated : function ( +) +{ + return false; +}, + +/** + * @method getTextureRect + * @return {rect_object} + */ +getTextureRect : function ( +) +{ + return cc.Rect; +}, + +/** + * @method initWithFile +* @param {String|String} str +* @param {rect_object} rect +* @return {bool|bool} +*/ +initWithFile : function( +str, +rect +) +{ + return false; +}, + +/** + * @method setBlendFunc + * @param {cc.BlendFunc} arg0 + */ +setBlendFunc : function ( +blendfunc +) +{ +}, + +/** + * @method getTextureAtlas + * @return {cc.TextureAtlas} + */ +getTextureAtlas : function ( +) +{ + return cc.TextureAtlas; +}, + +/** + * @method initWithSpriteFrame + * @param {cc.SpriteFrame} arg0 + * @return {bool} + */ +initWithSpriteFrame : function ( +spriteframe +) +{ + return false; +}, + +/** + * @method isFlippedX + * @return {bool} + */ +isFlippedX : function ( +) +{ + return false; +}, + +/** + * @method isFlippedY + * @return {bool} + */ +isFlippedY : function ( +) +{ + return false; +}, + +/** + * @method setVertexRect + * @param {rect_object} arg0 + */ +setVertexRect : function ( +rect +) +{ +}, + +/** + * @method create +* @param {String|String} str +* @param {rect_object} rect +* @return {cc.Sprite|cc.Sprite|cc.Sprite} +*/ +create : function( +str, +rect +) +{ + return cc.Sprite; +}, + +/** + * @method createWithTexture +* @param {cc.Texture2D|cc.Texture2D} texture2d +* @param {rect_object} rect +* @param {bool} bool +* @return {cc.Sprite|cc.Sprite} +*/ +createWithTexture : function( +texture2d, +rect, +bool +) +{ + return cc.Sprite; +}, + +/** + * @method createWithSpriteFrameName + * @param {String} arg0 + * @return {cc.Sprite} + */ +createWithSpriteFrameName : function ( +str +) +{ + return cc.Sprite; +}, + +/** + * @method createWithSpriteFrame + * @param {cc.SpriteFrame} arg0 + * @return {cc.Sprite} + */ +createWithSpriteFrame : function ( +spriteframe +) +{ + return cc.Sprite; +}, + +/** + * @method Sprite + * @constructor + */ +Sprite : function ( +) +{ +}, + +}; + +/** + * @class Image + */ +cc.Image = { + +/** + * @method hasPremultipliedAlpha + * @return {bool} + */ +hasPremultipliedAlpha : function ( +) +{ + return false; +}, + +/** + * @method getDataLen + * @return {long} + */ +getDataLen : function ( +) +{ + return 0; +}, + +/** + * @method saveToFile + * @param {String} arg0 + * @param {bool} arg1 + * @return {bool} + */ +saveToFile : function ( +str, +bool +) +{ + return false; +}, + +/** + * @method hasAlpha + * @return {bool} + */ +hasAlpha : function ( +) +{ + return false; +}, + +/** + * @method isCompressed + * @return {bool} + */ +isCompressed : function ( +) +{ + return false; +}, + +/** + * @method getHeight + * @return {int} + */ +getHeight : function ( +) +{ + return 0; +}, + +/** + * @method initWithImageFile + * @param {String} arg0 + * @return {bool} + */ +initWithImageFile : function ( +str +) +{ + return false; +}, + +/** + * @method getWidth + * @return {int} + */ +getWidth : function ( +) +{ + return 0; +}, + +/** + * @method getBitPerPixel + * @return {int} + */ +getBitPerPixel : function ( +) +{ + return 0; +}, + +/** + * @method getFileType + * @return {cc.Image::Format} + */ +getFileType : function ( +) +{ + return 0; +}, + +/** + * @method getNumberOfMipmaps + * @return {int} + */ +getNumberOfMipmaps : function ( +) +{ + return 0; +}, + +/** + * @method getRenderFormat + * @return {cc.Texture2D::PixelFormat} + */ +getRenderFormat : function ( +) +{ + return 0; +}, + +/** + * @method getData + * @return {unsigned char} + */ +getData : function ( +) +{ + return 0; +}, + +/** + * @method getMipmaps + * @return {cc._MipmapInfo} + */ +getMipmaps : function ( +) +{ + return cc._MipmapInfo; +}, + +/** + * @method initWithRawData + * @param {unsigned char} arg0 + * @param {long} arg1 + * @param {int} arg2 + * @param {int} arg3 + * @param {int} arg4 + * @param {bool} arg5 + * @return {bool} + */ +initWithRawData : function ( +char, +long, +int, +int, +int, +bool +) +{ + return false; +}, + +/** + * @method setPVRImagesHavePremultipliedAlpha + * @param {bool} arg0 + */ +setPVRImagesHavePremultipliedAlpha : function ( +bool +) +{ +}, + +/** + * @method Image + * @constructor + */ +Image : function ( +) +{ +}, + +}; + +/** + * @class RenderTexture + */ +cc.RenderTexture = { + +/** + * @method setVirtualViewport + * @param {vec2_object} arg0 + * @param {rect_object} arg1 + * @param {rect_object} arg2 + */ +setVirtualViewport : function ( +vec2, +rect, +rect +) +{ +}, + +/** + * @method clearStencil + * @param {int} arg0 + */ +clearStencil : function ( +int +) +{ +}, + +/** + * @method getClearDepth + * @return {float} + */ +getClearDepth : function ( +) +{ + return 0; +}, + +/** + * @method getClearStencil + * @return {int} + */ +getClearStencil : function ( +) +{ + return 0; +}, + +/** + * @method end + */ +end : function ( +) +{ +}, + +/** + * @method setClearStencil + * @param {int} arg0 + */ +setClearStencil : function ( +int +) +{ +}, + +/** + * @method setSprite + * @param {cc.Sprite} arg0 + */ +setSprite : function ( +sprite +) +{ +}, + +/** + * @method getSprite + * @return {cc.Sprite} + */ +getSprite : function ( +) +{ + return cc.Sprite; +}, + +/** + * @method isAutoDraw + * @return {bool} + */ +isAutoDraw : function ( +) +{ + return false; +}, + +/** + * @method setKeepMatrix + * @param {bool} arg0 + */ +setKeepMatrix : function ( +bool +) +{ +}, + +/** + * @method setClearFlags + * @param {unsigned int} arg0 + */ +setClearFlags : function ( +int +) +{ +}, + +/** + * @method begin + */ +begin : function ( +) +{ +}, + +/** + * @method setAutoDraw + * @param {bool} arg0 + */ +setAutoDraw : function ( +bool +) +{ +}, + +/** + * @method setClearColor + * @param {color4f_object} arg0 + */ +setClearColor : function ( +color4f +) +{ +}, + +/** + * @method endToLua + */ +endToLua : function ( +) +{ +}, + +/** + * @method beginWithClear +* @param {float|float|float} float +* @param {float|float|float} float +* @param {float|float|float} float +* @param {float|float|float} float +* @param {float|float} float +* @param {int} int +*/ +beginWithClear : function( +float, +float, +float, +float, +float, +int +) +{ +}, + +/** + * @method clearDepth + * @param {float} arg0 + */ +clearDepth : function ( +float +) +{ +}, + +/** + * @method getClearColor + * @return {color4f_object} + */ +getClearColor : function ( +) +{ + return cc.Color4F; +}, + +/** + * @method clear + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @param {float} arg3 + */ +clear : function ( +float, +float, +float, +float +) +{ +}, + +/** + * @method getClearFlags + * @return {unsigned int} + */ +getClearFlags : function ( +) +{ + return 0; +}, + +/** + * @method newImage + * @return {cc.Image} + */ +newImage : function ( +) +{ + return cc.Image; +}, + +/** + * @method setClearDepth + * @param {float} arg0 + */ +setClearDepth : function ( +float +) +{ +}, + +/** + * @method initWithWidthAndHeight +* @param {int|int} int +* @param {int|int} int +* @param {cc.Texture2D::PixelFormat|cc.Texture2D::PixelFormat} pixelformat +* @param {unsigned int} int +* @return {bool|bool} +*/ +initWithWidthAndHeight : function( +int, +int, +pixelformat, +int +) +{ + return false; +}, + +/** + * @method create +* @param {int|int|int} int +* @param {int|int|int} int +* @param {cc.Texture2D::PixelFormat|cc.Texture2D::PixelFormat} pixelformat +* @param {unsigned int} int +* @return {cc.RenderTexture|cc.RenderTexture|cc.RenderTexture} +*/ +create : function( +int, +int, +pixelformat, +int +) +{ + return cc.RenderTexture; +}, + +/** + * @method RenderTexture + * @constructor + */ +RenderTexture : function ( +) +{ +}, + +}; + +/** + * @class NodeGrid + */ +cc.NodeGrid = { + +/** + * @method setTarget + * @param {cc.Node} arg0 + */ +setTarget : function ( +node +) +{ +}, + +/** + * @method getGrid +* @return {cc.GridBase|cc.GridBase} +*/ +getGrid : function( +) +{ + return cc.GridBase; +}, + +/** + * @method create + * @return {cc.NodeGrid} + */ +create : function ( +) +{ + return cc.NodeGrid; +}, + +/** + * @method NodeGrid + * @constructor + */ +NodeGrid : function ( +) +{ +}, + +}; + +/** + * @class ParticleBatchNode + */ +cc.ParticleBatchNode = { + +/** + * @method setTexture + * @param {cc.Texture2D} arg0 + */ +setTexture : function ( +texture2d +) +{ +}, + +/** + * @method initWithTexture + * @param {cc.Texture2D} arg0 + * @param {int} arg1 + * @return {bool} + */ +initWithTexture : function ( +texture2d, +int +) +{ + return false; +}, + +/** + * @method disableParticle + * @param {int} arg0 + */ +disableParticle : function ( +int +) +{ +}, + +/** + * @method getTexture + * @return {cc.Texture2D} + */ +getTexture : function ( +) +{ + return cc.Texture2D; +}, + +/** + * @method setTextureAtlas + * @param {cc.TextureAtlas} arg0 + */ +setTextureAtlas : function ( +textureatlas +) +{ +}, + +/** + * @method initWithFile + * @param {String} arg0 + * @param {int} arg1 + * @return {bool} + */ +initWithFile : function ( +str, +int +) +{ + return false; +}, + +/** + * @method setBlendFunc + * @param {cc.BlendFunc} arg0 + */ +setBlendFunc : function ( +blendfunc +) +{ +}, + +/** + * @method removeAllChildrenWithCleanup + * @param {bool} arg0 + */ +removeAllChildrenWithCleanup : function ( +bool +) +{ +}, + +/** + * @method getTextureAtlas + * @return {cc.TextureAtlas} + */ +getTextureAtlas : function ( +) +{ + return cc.TextureAtlas; +}, + +/** + * @method getBlendFunc + * @return {cc.BlendFunc} + */ +getBlendFunc : function ( +) +{ + return cc.BlendFunc; +}, + +/** + * @method insertChild + * @param {cc.ParticleSystem} arg0 + * @param {int} arg1 + */ +insertChild : function ( +particlesystem, +int +) +{ +}, + +/** + * @method removeChildAtIndex + * @param {int} arg0 + * @param {bool} arg1 + */ +removeChildAtIndex : function ( +int, +bool +) +{ +}, + +/** + * @method create + * @param {String} arg0 + * @param {int} arg1 + * @return {cc.ParticleBatchNode} + */ +create : function ( +str, +int +) +{ + return cc.ParticleBatchNode; +}, + +/** + * @method createWithTexture + * @param {cc.Texture2D} arg0 + * @param {int} arg1 + * @return {cc.ParticleBatchNode} + */ +createWithTexture : function ( +texture2d, +int +) +{ + return cc.ParticleBatchNode; +}, + +/** + * @method ParticleBatchNode + * @constructor + */ +ParticleBatchNode : function ( +) +{ +}, + +}; + +/** + * @class ParticleSystem + */ +cc.ParticleSystem = { + +/** + * @method getStartSizeVar + * @return {float} + */ +getStartSizeVar : function ( +) +{ + return 0; +}, + +/** + * @method getTexture + * @return {cc.Texture2D} + */ +getTexture : function ( +) +{ + return cc.Texture2D; +}, + +/** + * @method isFull + * @return {bool} + */ +isFull : function ( +) +{ + return false; +}, + +/** + * @method getBatchNode + * @return {cc.ParticleBatchNode} + */ +getBatchNode : function ( +) +{ + return cc.ParticleBatchNode; +}, + +/** + * @method getStartColor + * @return {color4f_object} + */ +getStartColor : function ( +) +{ + return cc.Color4F; +}, + +/** + * @method getPositionType + * @return {cc.ParticleSystem::PositionType} + */ +getPositionType : function ( +) +{ + return 0; +}, + +/** + * @method setPosVar + * @param {vec2_object} arg0 + */ +setPosVar : function ( +vec2 +) +{ +}, + +/** + * @method getEndSpin + * @return {float} + */ +getEndSpin : function ( +) +{ + return 0; +}, + +/** + * @method setRotatePerSecondVar + * @param {float} arg0 + */ +setRotatePerSecondVar : function ( +float +) +{ +}, + +/** + * @method getStartSpinVar + * @return {float} + */ +getStartSpinVar : function ( +) +{ + return 0; +}, + +/** + * @method getRadialAccelVar + * @return {float} + */ +getRadialAccelVar : function ( +) +{ + return 0; +}, + +/** + * @method getEndSizeVar + * @return {float} + */ +getEndSizeVar : function ( +) +{ + return 0; +}, + +/** + * @method setTangentialAccel + * @param {float} arg0 + */ +setTangentialAccel : function ( +float +) +{ +}, + +/** + * @method getRadialAccel + * @return {float} + */ +getRadialAccel : function ( +) +{ + return 0; +}, + +/** + * @method setStartRadius + * @param {float} arg0 + */ +setStartRadius : function ( +float +) +{ +}, + +/** + * @method setRotatePerSecond + * @param {float} arg0 + */ +setRotatePerSecond : function ( +float +) +{ +}, + +/** + * @method setEndSize + * @param {float} arg0 + */ +setEndSize : function ( +float +) +{ +}, + +/** + * @method getGravity + * @return {vec2_object} + */ +getGravity : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getTangentialAccel + * @return {float} + */ +getTangentialAccel : function ( +) +{ + return 0; +}, + +/** + * @method setEndRadius + * @param {float} arg0 + */ +setEndRadius : function ( +float +) +{ +}, + +/** + * @method getSpeed + * @return {float} + */ +getSpeed : function ( +) +{ + return 0; +}, + +/** + * @method getAngle + * @return {float} + */ +getAngle : function ( +) +{ + return 0; +}, + +/** + * @method setEndColor + * @param {color4f_object} arg0 + */ +setEndColor : function ( +color4f +) +{ +}, + +/** + * @method setStartSpin + * @param {float} arg0 + */ +setStartSpin : function ( +float +) +{ +}, + +/** + * @method setDuration + * @param {float} arg0 + */ +setDuration : function ( +float +) +{ +}, + +/** + * @method initWithTotalParticles + * @param {int} arg0 + * @return {bool} + */ +initWithTotalParticles : function ( +int +) +{ + return false; +}, + +/** + * @method setTexture + * @param {cc.Texture2D} arg0 + */ +setTexture : function ( +texture2d +) +{ +}, + +/** + * @method getPosVar + * @return {vec2_object} + */ +getPosVar : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method updateWithNoTime + */ +updateWithNoTime : function ( +) +{ +}, + +/** + * @method isBlendAdditive + * @return {bool} + */ +isBlendAdditive : function ( +) +{ + return false; +}, + +/** + * @method getSpeedVar + * @return {float} + */ +getSpeedVar : function ( +) +{ + return 0; +}, + +/** + * @method setPositionType + * @param {cc.ParticleSystem::PositionType} arg0 + */ +setPositionType : function ( +positiontype +) +{ +}, + +/** + * @method stopSystem + */ +stopSystem : function ( +) +{ +}, + +/** + * @method getSourcePosition + * @return {vec2_object} + */ +getSourcePosition : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method setLifeVar + * @param {float} arg0 + */ +setLifeVar : function ( +float +) +{ +}, + +/** + * @method setTotalParticles + * @param {int} arg0 + */ +setTotalParticles : function ( +int +) +{ +}, + +/** + * @method setEndColorVar + * @param {color4f_object} arg0 + */ +setEndColorVar : function ( +color4f +) +{ +}, + +/** + * @method updateQuadWithParticle + * @param {cc.sParticle} arg0 + * @param {vec2_object} arg1 + */ +updateQuadWithParticle : function ( +sparticle, +vec2 +) +{ +}, + +/** + * @method getAtlasIndex + * @return {int} + */ +getAtlasIndex : function ( +) +{ + return 0; +}, + +/** + * @method getStartSize + * @return {float} + */ +getStartSize : function ( +) +{ + return 0; +}, + +/** + * @method setStartSpinVar + * @param {float} arg0 + */ +setStartSpinVar : function ( +float +) +{ +}, + +/** + * @method resetSystem + */ +resetSystem : function ( +) +{ +}, + +/** + * @method setAtlasIndex + * @param {int} arg0 + */ +setAtlasIndex : function ( +int +) +{ +}, + +/** + * @method setTangentialAccelVar + * @param {float} arg0 + */ +setTangentialAccelVar : function ( +float +) +{ +}, + +/** + * @method setEndRadiusVar + * @param {float} arg0 + */ +setEndRadiusVar : function ( +float +) +{ +}, + +/** + * @method getEndRadius + * @return {float} + */ +getEndRadius : function ( +) +{ + return 0; +}, + +/** + * @method isActive + * @return {bool} + */ +isActive : function ( +) +{ + return false; +}, + +/** + * @method setRadialAccelVar + * @param {float} arg0 + */ +setRadialAccelVar : function ( +float +) +{ +}, + +/** + * @method setStartSize + * @param {float} arg0 + */ +setStartSize : function ( +float +) +{ +}, + +/** + * @method setSpeed + * @param {float} arg0 + */ +setSpeed : function ( +float +) +{ +}, + +/** + * @method getStartSpin + * @return {float} + */ +getStartSpin : function ( +) +{ + return 0; +}, + +/** + * @method getRotatePerSecond + * @return {float} + */ +getRotatePerSecond : function ( +) +{ + return 0; +}, + +/** + * @method initParticle + * @param {cc.sParticle} arg0 + */ +initParticle : function ( +sparticle +) +{ +}, + +/** + * @method setEmitterMode + * @param {cc.ParticleSystem::Mode} arg0 + */ +setEmitterMode : function ( +mode +) +{ +}, + +/** + * @method getDuration + * @return {float} + */ +getDuration : function ( +) +{ + return 0; +}, + +/** + * @method setSourcePosition + * @param {vec2_object} arg0 + */ +setSourcePosition : function ( +vec2 +) +{ +}, + +/** + * @method getEndSpinVar + * @return {float} + */ +getEndSpinVar : function ( +) +{ + return 0; +}, + +/** + * @method setBlendAdditive + * @param {bool} arg0 + */ +setBlendAdditive : function ( +bool +) +{ +}, + +/** + * @method setLife + * @param {float} arg0 + */ +setLife : function ( +float +) +{ +}, + +/** + * @method setAngleVar + * @param {float} arg0 + */ +setAngleVar : function ( +float +) +{ +}, + +/** + * @method setRotationIsDir + * @param {bool} arg0 + */ +setRotationIsDir : function ( +bool +) +{ +}, + +/** + * @method setEndSizeVar + * @param {float} arg0 + */ +setEndSizeVar : function ( +float +) +{ +}, + +/** + * @method setAngle + * @param {float} arg0 + */ +setAngle : function ( +float +) +{ +}, + +/** + * @method setBatchNode + * @param {cc.ParticleBatchNode} arg0 + */ +setBatchNode : function ( +particlebatchnode +) +{ +}, + +/** + * @method getTangentialAccelVar + * @return {float} + */ +getTangentialAccelVar : function ( +) +{ + return 0; +}, + +/** + * @method getEmitterMode + * @return {cc.ParticleSystem::Mode} + */ +getEmitterMode : function ( +) +{ + return 0; +}, + +/** + * @method setEndSpinVar + * @param {float} arg0 + */ +setEndSpinVar : function ( +float +) +{ +}, + +/** + * @method initWithFile + * @param {String} arg0 + * @return {bool} + */ +initWithFile : function ( +str +) +{ + return false; +}, + +/** + * @method getAngleVar + * @return {float} + */ +getAngleVar : function ( +) +{ + return 0; +}, + +/** + * @method setStartColor + * @param {color4f_object} arg0 + */ +setStartColor : function ( +color4f +) +{ +}, + +/** + * @method getRotatePerSecondVar + * @return {float} + */ +getRotatePerSecondVar : function ( +) +{ + return 0; +}, + +/** + * @method getEndSize + * @return {float} + */ +getEndSize : function ( +) +{ + return 0; +}, + +/** + * @method getLife + * @return {float} + */ +getLife : function ( +) +{ + return 0; +}, + +/** + * @method setSpeedVar + * @param {float} arg0 + */ +setSpeedVar : function ( +float +) +{ +}, + +/** + * @method setAutoRemoveOnFinish + * @param {bool} arg0 + */ +setAutoRemoveOnFinish : function ( +bool +) +{ +}, + +/** + * @method setGravity + * @param {vec2_object} arg0 + */ +setGravity : function ( +vec2 +) +{ +}, + +/** + * @method postStep + */ +postStep : function ( +) +{ +}, + +/** + * @method setEmissionRate + * @param {float} arg0 + */ +setEmissionRate : function ( +float +) +{ +}, + +/** + * @method getEndColorVar + * @return {color4f_object} + */ +getEndColorVar : function ( +) +{ + return cc.Color4F; +}, + +/** + * @method getRotationIsDir + * @return {bool} + */ +getRotationIsDir : function ( +) +{ + return false; +}, + +/** + * @method getEmissionRate + * @return {float} + */ +getEmissionRate : function ( +) +{ + return 0; +}, + +/** + * @method getEndColor + * @return {color4f_object} + */ +getEndColor : function ( +) +{ + return cc.Color4F; +}, + +/** + * @method getLifeVar + * @return {float} + */ +getLifeVar : function ( +) +{ + return 0; +}, + +/** + * @method setStartSizeVar + * @param {float} arg0 + */ +setStartSizeVar : function ( +float +) +{ +}, + +/** + * @method addParticle + * @return {bool} + */ +addParticle : function ( +) +{ + return false; +}, + +/** + * @method getStartRadius + * @return {float} + */ +getStartRadius : function ( +) +{ + return 0; +}, + +/** + * @method getParticleCount + * @return {unsigned int} + */ +getParticleCount : function ( +) +{ + return 0; +}, + +/** + * @method getStartRadiusVar + * @return {float} + */ +getStartRadiusVar : function ( +) +{ + return 0; +}, + +/** + * @method getBlendFunc + * @return {cc.BlendFunc} + */ +getBlendFunc : function ( +) +{ + return cc.BlendFunc; +}, + +/** + * @method setStartColorVar + * @param {color4f_object} arg0 + */ +setStartColorVar : function ( +color4f +) +{ +}, + +/** + * @method setEndSpin + * @param {float} arg0 + */ +setEndSpin : function ( +float +) +{ +}, + +/** + * @method setRadialAccel + * @param {float} arg0 + */ +setRadialAccel : function ( +float +) +{ +}, + +/** + * @method initWithDictionary +* @param {map_object|map_object} map +* @param {String} str +* @return {bool|bool} +*/ +initWithDictionary : function( +map, +str +) +{ + return false; +}, + +/** + * @method isAutoRemoveOnFinish + * @return {bool} + */ +isAutoRemoveOnFinish : function ( +) +{ + return false; +}, + +/** + * @method getTotalParticles + * @return {int} + */ +getTotalParticles : function ( +) +{ + return 0; +}, + +/** + * @method setStartRadiusVar + * @param {float} arg0 + */ +setStartRadiusVar : function ( +float +) +{ +}, + +/** + * @method setBlendFunc + * @param {cc.BlendFunc} arg0 + */ +setBlendFunc : function ( +blendfunc +) +{ +}, + +/** + * @method getEndRadiusVar + * @return {float} + */ +getEndRadiusVar : function ( +) +{ + return 0; +}, + +/** + * @method getStartColorVar + * @return {color4f_object} + */ +getStartColorVar : function ( +) +{ + return cc.Color4F; +}, + +/** + * @method create + * @param {String} arg0 + * @return {cc.ParticleSystem} + */ +create : function ( +str +) +{ + return cc.ParticleSystem; +}, + +/** + * @method createWithTotalParticles + * @param {int} arg0 + * @return {cc.ParticleSystem} + */ +createWithTotalParticles : function ( +int +) +{ + return cc.ParticleSystem; +}, + +/** + * @method ParticleSystem + * @constructor + */ +ParticleSystem : function ( +) +{ +}, + +}; + +/** + * @class ParticleSystemQuad + */ +cc.ParticleSystem = { + +/** + * @method setDisplayFrame + * @param {cc.SpriteFrame} arg0 + */ +setDisplayFrame : function ( +spriteframe +) +{ +}, + +/** + * @method setTextureWithRect + * @param {cc.Texture2D} arg0 + * @param {rect_object} arg1 + */ +setTextureWithRect : function ( +texture2d, +rect +) +{ +}, + +/** + * @method listenRendererRecreated + * @param {cc.EventCustom} arg0 + */ +listenRendererRecreated : function ( +eventcustom +) +{ +}, + +/** + * @method create +* @param {String|map_object} str +* @return {cc.ParticleSystemQuad|cc.ParticleSystemQuad|cc.ParticleSystemQuad} +*/ +create : function( +map +) +{ + return cc.ParticleSystemQuad; +}, + +/** + * @method createWithTotalParticles + * @param {int} arg0 + * @return {cc.ParticleSystemQuad} + */ +createWithTotalParticles : function ( +int +) +{ + return cc.ParticleSystemQuad; +}, + +/** + * @method ParticleSystemQuad + * @constructor + */ +ParticleSystemQuad : function ( +) +{ +}, + +}; + +/** + * @class ParticleFire + */ +cc.ParticleFire = { + +/** + * @method create + * @return {cc.ParticleFire} + */ +create : function ( +) +{ + return cc.ParticleFire; +}, + +/** + * @method createWithTotalParticles + * @param {int} arg0 + * @return {cc.ParticleFire} + */ +createWithTotalParticles : function ( +int +) +{ + return cc.ParticleFire; +}, + +/** + * @method ParticleFire + * @constructor + */ +ParticleFire : function ( +) +{ +}, + +}; + +/** + * @class ParticleFireworks + */ +cc.ParticleFireworks = { + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method initWithTotalParticles + * @param {int} arg0 + * @return {bool} + */ +initWithTotalParticles : function ( +int +) +{ + return false; +}, + +/** + * @method create + * @return {cc.ParticleFireworks} + */ +create : function ( +) +{ + return cc.ParticleFireworks; +}, + +/** + * @method createWithTotalParticles + * @param {int} arg0 + * @return {cc.ParticleFireworks} + */ +createWithTotalParticles : function ( +int +) +{ + return cc.ParticleFireworks; +}, + +/** + * @method ParticleFireworks + * @constructor + */ +ParticleFireworks : function ( +) +{ +}, + +}; + +/** + * @class ParticleSun + */ +cc.ParticleSun = { + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method initWithTotalParticles + * @param {int} arg0 + * @return {bool} + */ +initWithTotalParticles : function ( +int +) +{ + return false; +}, + +/** + * @method create + * @return {cc.ParticleSun} + */ +create : function ( +) +{ + return cc.ParticleSun; +}, + +/** + * @method createWithTotalParticles + * @param {int} arg0 + * @return {cc.ParticleSun} + */ +createWithTotalParticles : function ( +int +) +{ + return cc.ParticleSun; +}, + +/** + * @method ParticleSun + * @constructor + */ +ParticleSun : function ( +) +{ +}, + +}; + +/** + * @class ParticleGalaxy + */ +cc.ParticleGalaxy = { + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method initWithTotalParticles + * @param {int} arg0 + * @return {bool} + */ +initWithTotalParticles : function ( +int +) +{ + return false; +}, + +/** + * @method create + * @return {cc.ParticleGalaxy} + */ +create : function ( +) +{ + return cc.ParticleGalaxy; +}, + +/** + * @method createWithTotalParticles + * @param {int} arg0 + * @return {cc.ParticleGalaxy} + */ +createWithTotalParticles : function ( +int +) +{ + return cc.ParticleGalaxy; +}, + +/** + * @method ParticleGalaxy + * @constructor + */ +ParticleGalaxy : function ( +) +{ +}, + +}; + +/** + * @class ParticleFlower + */ +cc.ParticleFlower = { + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method initWithTotalParticles + * @param {int} arg0 + * @return {bool} + */ +initWithTotalParticles : function ( +int +) +{ + return false; +}, + +/** + * @method create + * @return {cc.ParticleFlower} + */ +create : function ( +) +{ + return cc.ParticleFlower; +}, + +/** + * @method createWithTotalParticles + * @param {int} arg0 + * @return {cc.ParticleFlower} + */ +createWithTotalParticles : function ( +int +) +{ + return cc.ParticleFlower; +}, + +/** + * @method ParticleFlower + * @constructor + */ +ParticleFlower : function ( +) +{ +}, + +}; + +/** + * @class ParticleMeteor + */ +cc.ParticleMeteor = { + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method initWithTotalParticles + * @param {int} arg0 + * @return {bool} + */ +initWithTotalParticles : function ( +int +) +{ + return false; +}, + +/** + * @method create + * @return {cc.ParticleMeteor} + */ +create : function ( +) +{ + return cc.ParticleMeteor; +}, + +/** + * @method createWithTotalParticles + * @param {int} arg0 + * @return {cc.ParticleMeteor} + */ +createWithTotalParticles : function ( +int +) +{ + return cc.ParticleMeteor; +}, + +/** + * @method ParticleMeteor + * @constructor + */ +ParticleMeteor : function ( +) +{ +}, + +}; + +/** + * @class ParticleSpiral + */ +cc.ParticleSpiral = { + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method initWithTotalParticles + * @param {int} arg0 + * @return {bool} + */ +initWithTotalParticles : function ( +int +) +{ + return false; +}, + +/** + * @method create + * @return {cc.ParticleSpiral} + */ +create : function ( +) +{ + return cc.ParticleSpiral; +}, + +/** + * @method createWithTotalParticles + * @param {int} arg0 + * @return {cc.ParticleSpiral} + */ +createWithTotalParticles : function ( +int +) +{ + return cc.ParticleSpiral; +}, + +/** + * @method ParticleSpiral + * @constructor + */ +ParticleSpiral : function ( +) +{ +}, + +}; + +/** + * @class ParticleExplosion + */ +cc.ParticleExplosion = { + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method initWithTotalParticles + * @param {int} arg0 + * @return {bool} + */ +initWithTotalParticles : function ( +int +) +{ + return false; +}, + +/** + * @method create + * @return {cc.ParticleExplosion} + */ +create : function ( +) +{ + return cc.ParticleExplosion; +}, + +/** + * @method createWithTotalParticles + * @param {int} arg0 + * @return {cc.ParticleExplosion} + */ +createWithTotalParticles : function ( +int +) +{ + return cc.ParticleExplosion; +}, + +/** + * @method ParticleExplosion + * @constructor + */ +ParticleExplosion : function ( +) +{ +}, + +}; + +/** + * @class ParticleSmoke + */ +cc.ParticleSmoke = { + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method initWithTotalParticles + * @param {int} arg0 + * @return {bool} + */ +initWithTotalParticles : function ( +int +) +{ + return false; +}, + +/** + * @method create + * @return {cc.ParticleSmoke} + */ +create : function ( +) +{ + return cc.ParticleSmoke; +}, + +/** + * @method createWithTotalParticles + * @param {int} arg0 + * @return {cc.ParticleSmoke} + */ +createWithTotalParticles : function ( +int +) +{ + return cc.ParticleSmoke; +}, + +/** + * @method ParticleSmoke + * @constructor + */ +ParticleSmoke : function ( +) +{ +}, + +}; + +/** + * @class ParticleSnow + */ +cc.ParticleSnow = { + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method initWithTotalParticles + * @param {int} arg0 + * @return {bool} + */ +initWithTotalParticles : function ( +int +) +{ + return false; +}, + +/** + * @method create + * @return {cc.ParticleSnow} + */ +create : function ( +) +{ + return cc.ParticleSnow; +}, + +/** + * @method createWithTotalParticles + * @param {int} arg0 + * @return {cc.ParticleSnow} + */ +createWithTotalParticles : function ( +int +) +{ + return cc.ParticleSnow; +}, + +/** + * @method ParticleSnow + * @constructor + */ +ParticleSnow : function ( +) +{ +}, + +}; + +/** + * @class ParticleRain + */ +cc.ParticleRain = { + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method initWithTotalParticles + * @param {int} arg0 + * @return {bool} + */ +initWithTotalParticles : function ( +int +) +{ + return false; +}, + +/** + * @method create + * @return {cc.ParticleRain} + */ +create : function ( +) +{ + return cc.ParticleRain; +}, + +/** + * @method createWithTotalParticles + * @param {int} arg0 + * @return {cc.ParticleRain} + */ +createWithTotalParticles : function ( +int +) +{ + return cc.ParticleRain; +}, + +/** + * @method ParticleRain + * @constructor + */ +ParticleRain : function ( +) +{ +}, + +}; + +/** + * @class GridBase + */ +cc.GridBase = { + +/** + * @method setGridSize + * @param {size_object} arg0 + */ +setGridSize : function ( +size +) +{ +}, + +/** + * @method afterBlit + */ +afterBlit : function ( +) +{ +}, + +/** + * @method afterDraw + * @param {cc.Node} arg0 + */ +afterDraw : function ( +node +) +{ +}, + +/** + * @method beforeDraw + */ +beforeDraw : function ( +) +{ +}, + +/** + * @method calculateVertexPoints + */ +calculateVertexPoints : function ( +) +{ +}, + +/** + * @method isTextureFlipped + * @return {bool} + */ +isTextureFlipped : function ( +) +{ + return false; +}, + +/** + * @method getGridSize + * @return {size_object} + */ +getGridSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method getStep + * @return {vec2_object} + */ +getStep : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method set2DProjection + */ +set2DProjection : function ( +) +{ +}, + +/** + * @method setStep + * @param {vec2_object} arg0 + */ +setStep : function ( +vec2 +) +{ +}, + +/** + * @method setTextureFlipped + * @param {bool} arg0 + */ +setTextureFlipped : function ( +bool +) +{ +}, + +/** + * @method blit + */ +blit : function ( +) +{ +}, + +/** + * @method setActive + * @param {bool} arg0 + */ +setActive : function ( +bool +) +{ +}, + +/** + * @method getReuseGrid + * @return {int} + */ +getReuseGrid : function ( +) +{ + return 0; +}, + +/** + * @method initWithSize +* @param {size_object|size_object} size +* @param {cc.Texture2D} texture2d +* @param {bool} bool +* @return {bool|bool} +*/ +initWithSize : function( +size, +texture2d, +bool +) +{ + return false; +}, + +/** + * @method beforeBlit + */ +beforeBlit : function ( +) +{ +}, + +/** + * @method setReuseGrid + * @param {int} arg0 + */ +setReuseGrid : function ( +int +) +{ +}, + +/** + * @method isActive + * @return {bool} + */ +isActive : function ( +) +{ + return false; +}, + +/** + * @method reuse + */ +reuse : function ( +) +{ +}, + +/** + * @method create +* @param {size_object|size_object} size +* @param {cc.Texture2D} texture2d +* @param {bool} bool +* @return {cc.GridBase|cc.GridBase} +*/ +create : function( +size, +texture2d, +bool +) +{ + return cc.GridBase; +}, + +}; + +/** + * @class Grid3D + */ +cc.Grid3D = { + +/** + * @method getNeedDepthTestForBlit + * @return {bool} + */ +getNeedDepthTestForBlit : function ( +) +{ + return false; +}, + +/** + * @method setNeedDepthTestForBlit + * @param {bool} arg0 + */ +setNeedDepthTestForBlit : function ( +bool +) +{ +}, + +/** + * @method create +* @param {size_object|size_object} size +* @param {cc.Texture2D} texture2d +* @param {bool} bool +* @return {cc.Grid3D|cc.Grid3D} +*/ +create : function( +size, +texture2d, +bool +) +{ + return cc.Grid3D; +}, + +/** + * @method Grid3D + * @constructor + */ +Grid3D : function ( +) +{ +}, + +}; + +/** + * @class TiledGrid3D + */ +cc.TiledGrid3D = { + +/** + * @method create +* @param {size_object|size_object} size +* @param {cc.Texture2D} texture2d +* @param {bool} bool +* @return {cc.TiledGrid3D|cc.TiledGrid3D} +*/ +create : function( +size, +texture2d, +bool +) +{ + return cc.TiledGrid3D; +}, + +/** + * @method TiledGrid3D + * @constructor + */ +TiledGrid3D : function ( +) +{ +}, + +}; + +/** + * @class Camera + */ +cc.Camera = { + +/** + * @method setScene + * @param {cc.Scene} arg0 + */ +setScene : function ( +scene +) +{ +}, + +/** + * @method initPerspective + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @param {float} arg3 + * @return {bool} + */ +initPerspective : function ( +float, +float, +float, +float +) +{ + return false; +}, + +/** + * @method getProjectionMatrix + * @return {mat4_object} + */ +getProjectionMatrix : function ( +) +{ + return cc.Mat4; +}, + +/** + * @method getViewProjectionMatrix + * @return {mat4_object} + */ +getViewProjectionMatrix : function ( +) +{ + return cc.Mat4; +}, + +/** + * @method getViewMatrix + * @return {mat4_object} + */ +getViewMatrix : function ( +) +{ + return cc.Mat4; +}, + +/** + * @method getCameraFlag + * @return {cc.CameraFlag} + */ +getCameraFlag : function ( +) +{ + return 0; +}, + +/** + * @method getType + * @return {cc.Camera::Type} + */ +getType : function ( +) +{ + return 0; +}, + +/** + * @method initDefault + * @return {bool} + */ +initDefault : function ( +) +{ + return false; +}, + +/** + * @method project + * @param {vec3_object} arg0 + * @return {vec2_object} + */ +project : function ( +vec3 +) +{ + return cc.Vec2; +}, + +/** + * @method getDepthInView + * @param {mat4_object} arg0 + * @return {float} + */ +getDepthInView : function ( +mat4 +) +{ + return 0; +}, + +/** + * @method lookAt + * @param {vec3_object} arg0 + * @param {vec3_object} arg1 + */ +lookAt : function ( +vec3, +vec3 +) +{ +}, + +/** + * @method setCameraFlag + * @param {cc.CameraFlag} arg0 + */ +setCameraFlag : function ( +cameraflag +) +{ +}, + +/** + * @method initOrthographic + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @param {float} arg3 + * @return {bool} + */ +initOrthographic : function ( +float, +float, +float, +float +) +{ + return false; +}, + +/** + * @method setAdditionalProjection + * @param {mat4_object} arg0 + */ +setAdditionalProjection : function ( +mat4 +) +{ +}, + +/** + * @method getDepth + * @return {int} + */ +getDepth : function ( +) +{ + return 0; +}, + +/** + * @method setDepth + * @param {int} arg0 + */ +setDepth : function ( +int +) +{ +}, + +/** + * @method create + * @return {cc.Camera} + */ +create : function ( +) +{ + return cc.Camera; +}, + +/** + * @method createPerspective + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @param {float} arg3 + * @return {cc.Camera} + */ +createPerspective : function ( +float, +float, +float, +float +) +{ + return cc.Camera; +}, + +/** + * @method createOrthographic + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @param {float} arg3 + * @return {cc.Camera} + */ +createOrthographic : function ( +float, +float, +float, +float +) +{ + return cc.Camera; +}, + +/** + * @method getDefaultCamera + * @return {cc.Camera} + */ +getDefaultCamera : function ( +) +{ + return cc.Camera; +}, + +/** + * @method getVisitingCamera + * @return {cc.Camera} + */ +getVisitingCamera : function ( +) +{ + return cc.Camera; +}, + +/** + * @method Camera + * @constructor + */ +Camera : function ( +) +{ +}, + +}; + +/** + * @class BaseLight + */ +cc.BaseLight = { + +/** + * @method setEnabled + * @param {bool} arg0 + */ +setEnabled : function ( +bool +) +{ +}, + +/** + * @method getIntensity + * @return {float} + */ +getIntensity : function ( +) +{ + return 0; +}, + +/** + * @method isEnabled + * @return {bool} + */ +isEnabled : function ( +) +{ + return false; +}, + +/** + * @method getLightType + * @return {cc.LightType} + */ +getLightType : function ( +) +{ + return 0; +}, + +/** + * @method setLightFlag + * @param {cc.LightFlag} arg0 + */ +setLightFlag : function ( +lightflag +) +{ +}, + +/** + * @method setIntensity + * @param {float} arg0 + */ +setIntensity : function ( +float +) +{ +}, + +/** + * @method getLightFlag + * @return {cc.LightFlag} + */ +getLightFlag : function ( +) +{ + return 0; +}, + +}; + +/** + * @class DirectionLight + */ +cc.DirectionLight = { + +/** + * @method getDirection + * @return {vec3_object} + */ +getDirection : function ( +) +{ + return cc.Vec3; +}, + +/** + * @method getDirectionInWorld + * @return {vec3_object} + */ +getDirectionInWorld : function ( +) +{ + return cc.Vec3; +}, + +/** + * @method setDirection + * @param {vec3_object} arg0 + */ +setDirection : function ( +vec3 +) +{ +}, + +/** + * @method create + * @param {vec3_object} arg0 + * @param {color3b_object} arg1 + * @return {cc.DirectionLight} + */ +create : function ( +vec3, +color3b +) +{ + return cc.DirectionLight; +}, + +/** + * @method DirectionLight + * @constructor + */ +DirectionLight : function ( +) +{ +}, + +}; + +/** + * @class PointLight + */ +cc.PointLight = { + +/** + * @method getRange + * @return {float} + */ +getRange : function ( +) +{ + return 0; +}, + +/** + * @method setRange + * @param {float} arg0 + */ +setRange : function ( +float +) +{ +}, + +/** + * @method create + * @param {vec3_object} arg0 + * @param {color3b_object} arg1 + * @param {float} arg2 + * @return {point_object} + */ +create : function ( +vec3, +color3b, +float +) +{ + return cc.PointLight; +}, + +/** + * @method PointLight + * @constructor + */ +PointLight : function ( +) +{ +}, + +}; + +/** + * @class SpotLight + */ +cc.SpotLight = { + +/** + * @method getRange + * @return {float} + */ +getRange : function ( +) +{ + return 0; +}, + +/** + * @method setDirection + * @param {vec3_object} arg0 + */ +setDirection : function ( +vec3 +) +{ +}, + +/** + * @method getCosInnerAngle + * @return {float} + */ +getCosInnerAngle : function ( +) +{ + return 0; +}, + +/** + * @method getOuterAngle + * @return {float} + */ +getOuterAngle : function ( +) +{ + return 0; +}, + +/** + * @method getInnerAngle + * @return {float} + */ +getInnerAngle : function ( +) +{ + return 0; +}, + +/** + * @method getDirection + * @return {vec3_object} + */ +getDirection : function ( +) +{ + return cc.Vec3; +}, + +/** + * @method getCosOuterAngle + * @return {float} + */ +getCosOuterAngle : function ( +) +{ + return 0; +}, + +/** + * @method setOuterAngle + * @param {float} arg0 + */ +setOuterAngle : function ( +float +) +{ +}, + +/** + * @method setInnerAngle + * @param {float} arg0 + */ +setInnerAngle : function ( +float +) +{ +}, + +/** + * @method getDirectionInWorld + * @return {vec3_object} + */ +getDirectionInWorld : function ( +) +{ + return cc.Vec3; +}, + +/** + * @method setRange + * @param {float} arg0 + */ +setRange : function ( +float +) +{ +}, + +/** + * @method create + * @param {vec3_object} arg0 + * @param {vec3_object} arg1 + * @param {color3b_object} arg2 + * @param {float} arg3 + * @param {float} arg4 + * @param {float} arg5 + * @return {cc.SpotLight} + */ +create : function ( +vec3, +vec3, +color3b, +float, +float, +float +) +{ + return cc.SpotLight; +}, + +/** + * @method SpotLight + * @constructor + */ +SpotLight : function ( +) +{ +}, + +}; + +/** + * @class AmbientLight + */ +cc.AmbientLight = { + +/** + * @method create + * @param {color3b_object} arg0 + * @return {cc.AmbientLight} + */ +create : function ( +color3b +) +{ + return cc.AmbientLight; +}, + +/** + * @method AmbientLight + * @constructor + */ +AmbientLight : function ( +) +{ +}, + +}; + +/** + * @class GLProgram + */ +cc.GLProgram = { + +/** + * @method getFragmentShaderLog + * @return {String} + */ +getFragmentShaderLog : function ( +) +{ + return ; +}, + +/** + * @method bindAttribLocation + * @param {String} arg0 + * @param {unsigned int} arg1 + */ +bindAttribLocation : function ( +str, +int +) +{ +}, + +/** + * @method getUniformLocationForName + * @param {char} arg0 + * @return {int} + */ +getUniformLocationForName : function ( +char +) +{ + return 0; +}, + +/** + * @method use + */ +use : function ( +) +{ +}, + +/** + * @method getVertexShaderLog + * @return {String} + */ +getVertexShaderLog : function ( +) +{ + return ; +}, + +/** + * @method getUniform + * @param {String} arg0 + * @return {cc.Uniform} + */ +getUniform : function ( +str +) +{ + return cc.Uniform; +}, + +/** + * @method initWithByteArrays +* @param {char|char} char +* @param {char|char} char +* @param {String} str +* @return {bool|bool} +*/ +initWithByteArrays : function( +char, +char, +str +) +{ + return false; +}, + +/** + * @method setUniformLocationWith1f + * @param {int} arg0 + * @param {float} arg1 + */ +setUniformLocationWith1f : function ( +int, +float +) +{ +}, + +/** + * @method initWithFilenames +* @param {String|String} str +* @param {String|String} str +* @param {String} str +* @return {bool|bool} +*/ +initWithFilenames : function( +str, +str, +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 +*/ +setUniformsForBuiltins : function( +mat4 +) +{ +}, + +/** + * @method setUniformLocationWith3i + * @param {int} arg0 + * @param {int} arg1 + * @param {int} arg2 + * @param {int} arg3 + */ +setUniformLocationWith3i : function ( +int, +int, +int, +int +) +{ +}, + +/** + * @method setUniformLocationWith4f + * @param {int} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @param {float} arg3 + * @param {float} arg4 + */ +setUniformLocationWith4f : function ( +int, +float, +float, +float, +float +) +{ +}, + +/** + * @method updateUniforms + */ +updateUniforms : function ( +) +{ +}, + +/** + * @method getUniformLocation + * @param {String} arg0 + * @return {int} + */ +getUniformLocation : function ( +str +) +{ + return 0; +}, + +/** + * @method link + * @return {bool} + */ +link : function ( +) +{ + return false; +}, + +/** + * @method reset + */ +reset : function ( +) +{ +}, + +/** + * @method getAttribLocation + * @param {String} arg0 + * @return {int} + */ +getAttribLocation : function ( +str +) +{ + return 0; +}, + +/** + * @method getVertexAttrib + * @param {String} arg0 + * @return {cc.VertexAttrib} + */ +getVertexAttrib : function ( +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 + * @param {int} arg1 + * @param {int} arg2 + * @param {int} arg3 + * @param {int} arg4 + */ +setUniformLocationWith4i : function ( +int, +int, +int, +int, +int +) +{ +}, + +/** + * @method setUniformLocationWith1i + * @param {int} arg0 + * @param {int} arg1 + */ +setUniformLocationWith1i : function ( +int, +int +) +{ +}, + +/** + * @method setUniformLocationWith2i + * @param {int} arg0 + * @param {int} arg1 + * @param {int} arg2 + */ +setUniformLocationWith2i : function ( +int, +int, +int +) +{ +}, + +/** + * @method createWithByteArrays +* @param {char|char} char +* @param {char|char} char +* @param {String} str +* @return {cc.GLProgram|cc.GLProgram} +*/ +createWithByteArrays : function( +char, +char, +str +) +{ + return cc.GLProgram; +}, + +/** + * @method createWithFilenames +* @param {String|String} str +* @param {String|String} str +* @param {String} str +* @return {cc.GLProgram|cc.GLProgram} +*/ +createWithFilenames : function( +str, +str, +str +) +{ + return cc.GLProgram; +}, + +/** + * @method GLProgram + * @constructor + */ +GLProgram : function ( +) +{ +}, + +}; + +/** + * @class GLProgramCache + */ +cc.ShaderCache = { + +/** + * @method reloadDefaultGLPrograms + */ +reloadDefaultGLPrograms : function ( +) +{ +}, + +/** + * @method addGLProgram + * @param {cc.GLProgram} arg0 + * @param {String} arg1 + */ +addGLProgram : function ( +glprogram, +str +) +{ +}, + +/** + * @method getGLProgram + * @param {String} arg0 + * @return {cc.GLProgram} + */ +getGLProgram : function ( +str +) +{ + return cc.GLProgram; +}, + +/** + * @method loadDefaultGLPrograms + */ +loadDefaultGLPrograms : function ( +) +{ +}, + +/** + * @method destroyInstance + */ +destroyInstance : function ( +) +{ +}, + +/** + * @method getInstance + * @return {cc.GLProgramCache} + */ +getInstance : function ( +) +{ + return cc.GLProgramCache; +}, + +/** + * @method GLProgramCache + * @constructor + */ +GLProgramCache : function ( +) +{ +}, + +}; + +/** + * @class TextureCache + */ +cc.TextureCache = { + +/** + * @method reloadTexture + * @param {String} arg0 + * @return {bool} + */ +reloadTexture : function ( +str +) +{ + return false; +}, + +/** + * @method unbindAllImageAsync + */ +unbindAllImageAsync : function ( +) +{ +}, + +/** + * @method removeTextureForKey + * @param {String} arg0 + */ +removeTextureForKey : function ( +str +) +{ +}, + +/** + * @method removeAllTextures + */ +removeAllTextures : function ( +) +{ +}, + +/** + * @method addImageAsync + * @param {String} arg0 + * @param {function} arg1 + */ +addImageAsync : function ( +str, +func +) +{ +}, + +/** + * @method getDescription + * @return {String} + */ +getDescription : function ( +) +{ + return ; +}, + +/** + * @method getCachedTextureInfo + * @return {String} + */ +getCachedTextureInfo : function ( +) +{ + return ; +}, + +/** + * @method addImage +* @param {cc.Image|String} image +* @param {String} str +* @return {cc.Texture2D|cc.Texture2D} +*/ +addImage : function( +image, +str +) +{ + return cc.Texture2D; +}, + +/** + * @method unbindImageAsync + * @param {String} arg0 + */ +unbindImageAsync : function ( +str +) +{ +}, + +/** + * @method getTextureForKey + * @param {String} arg0 + * @return {cc.Texture2D} + */ +getTextureForKey : function ( +str +) +{ + return cc.Texture2D; +}, + +/** + * @method removeUnusedTextures + */ +removeUnusedTextures : function ( +) +{ +}, + +/** + * @method removeTexture + * @param {cc.Texture2D} arg0 + */ +removeTexture : function ( +texture2d +) +{ +}, + +/** + * @method waitForQuit + */ +waitForQuit : function ( +) +{ +}, + +/** + * @method TextureCache + * @constructor + */ +TextureCache : function ( +) +{ +}, + +}; + +/** + * @class Device + */ +cc.Device = { + +/** + * @method setAccelerometerEnabled + * @param {bool} arg0 + */ +setAccelerometerEnabled : function ( +bool +) +{ +}, + +/** + * @method setKeepScreenOn + * @param {bool} arg0 + */ +setKeepScreenOn : function ( +bool +) +{ +}, + +/** + * @method setAccelerometerInterval + * @param {float} arg0 + */ +setAccelerometerInterval : function ( +float +) +{ +}, + +/** + * @method getDPI + * @return {int} + */ +getDPI : function ( +) +{ + return 0; +}, + +}; + +/** + * @class SAXParser + */ +cc.PlistParser = { + +/** + * @method init + * @param {char} arg0 + * @return {bool} + */ +init : function ( +char +) +{ + return false; +}, + +}; + +/** + * @class Application + */ +cc.Application = { + +/** + * @method openURL + * @param {String} arg0 + * @return {bool} + */ +openURL : function ( +str +) +{ + return false; +}, + +/** + * @method getTargetPlatform + * @return {cc.ApplicationProtocol::Platform} + */ +getTargetPlatform : function ( +) +{ + return 0; +}, + +/** + * @method getCurrentLanguage + * @return {cc.LanguageType} + */ +getCurrentLanguage : function ( +) +{ + return 0; +}, + +/** + * @method getInstance + * @return {cc.Application} + */ +getInstance : function ( +) +{ + return cc.Application; +}, + +}; + +/** + * @class AnimationCache + */ +cc.AnimationCache = { + +/** + * @method getAnimation + * @param {String} arg0 + * @return {cc.Animation} + */ +getAnimation : function ( +str +) +{ + return cc.Animation; +}, + +/** + * @method addAnimation + * @param {cc.Animation} arg0 + * @param {String} arg1 + */ +addAnimation : function ( +animation, +str +) +{ +}, + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method addAnimationsWithDictionary + * @param {map_object} arg0 + * @param {String} arg1 + */ +addAnimationsWithDictionary : function ( +map, +str +) +{ +}, + +/** + * @method removeAnimation + * @param {String} arg0 + */ +removeAnimation : function ( +str +) +{ +}, + +/** + * @method addAnimationsWithFile + * @param {String} arg0 + */ +addAnimationsWithFile : function ( +str +) +{ +}, + +/** + * @method destroyInstance + */ +destroyInstance : function ( +) +{ +}, + +/** + * @method getInstance + * @return {cc.AnimationCache} + */ +getInstance : function ( +) +{ + return cc.AnimationCache; +}, + +/** + * @method AnimationCache + * @constructor + */ +AnimationCache : function ( +) +{ +}, + +}; + +/** + * @class SpriteFrameCache + */ +cc.SpriteFrameCache = { + +/** + * @method addSpriteFramesWithFileContent + * @param {String} arg0 + * @param {cc.Texture2D} arg1 + */ +addSpriteFramesWithFileContent : function ( +str, +texture2d +) +{ +}, + +/** + * @method addSpriteFrame + * @param {cc.SpriteFrame} arg0 + * @param {String} arg1 + */ +addSpriteFrame : function ( +spriteframe, +str +) +{ +}, + +/** + * @method addSpriteFramesWithFile +* @param {String|String|String} str +* @param {String|cc.Texture2D} str +*/ +addSpriteFramesWithFile : function( +str, +texture2d +) +{ +}, + +/** + * @method getSpriteFrameByName + * @param {String} arg0 + * @return {cc.SpriteFrame} + */ +getSpriteFrameByName : function ( +str +) +{ + return cc.SpriteFrame; +}, + +/** + * @method removeSpriteFramesFromFile + * @param {String} arg0 + */ +removeSpriteFramesFromFile : function ( +str +) +{ +}, + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method removeSpriteFrames + */ +removeSpriteFrames : function ( +) +{ +}, + +/** + * @method removeUnusedSpriteFrames + */ +removeUnusedSpriteFrames : function ( +) +{ +}, + +/** + * @method removeSpriteFramesFromFileContent + * @param {String} arg0 + */ +removeSpriteFramesFromFileContent : function ( +str +) +{ +}, + +/** + * @method removeSpriteFrameByName + * @param {String} arg0 + */ +removeSpriteFrameByName : function ( +str +) +{ +}, + +/** + * @method isSpriteFramesWithFileLoaded + * @param {String} arg0 + * @return {bool} + */ +isSpriteFramesWithFileLoaded : function ( +str +) +{ + return false; +}, + +/** + * @method removeSpriteFramesFromTexture + * @param {cc.Texture2D} arg0 + */ +removeSpriteFramesFromTexture : function ( +texture2d +) +{ +}, + +/** + * @method destroyInstance + */ +destroyInstance : function ( +) +{ +}, + +/** + * @method getInstance + * @return {cc.SpriteFrameCache} + */ +getInstance : function ( +) +{ + return cc.SpriteFrameCache; +}, + +}; + +/** + * @class TextFieldTTF + */ +cc.TextFieldTTF = { + +/** + * @method getCharCount + * @return {int} + */ +getCharCount : function ( +) +{ + return 0; +}, + +/** + * @method setSecureTextEntry + * @param {bool} arg0 + */ +setSecureTextEntry : function ( +bool +) +{ +}, + +/** + * @method getColorSpaceHolder + * @return {color4b_object} + */ +getColorSpaceHolder : function ( +) +{ + return cc.Color4B; +}, + +/** + * @method initWithPlaceHolder +* @param {String|String} str +* @param {String|size_object} str +* @param {float|cc.TextHAlignment} float +* @param {String} str +* @param {float} float +* @return {bool|bool} +*/ +initWithPlaceHolder : function( +str, +size, +texthalignment, +str, +float +) +{ + return false; +}, + +/** + * @method setColorSpaceHolder +* @param {color4b_object|color3b_object} color4b +*/ +setColorSpaceHolder : function( +color3b +) +{ +}, + +/** + * @method detachWithIME + * @return {bool} + */ +detachWithIME : function ( +) +{ + return false; +}, + +/** + * @method setPlaceHolder + * @param {String} arg0 + */ +setPlaceHolder : function ( +str +) +{ +}, + +/** + * @method isSecureTextEntry + * @return {bool} + */ +isSecureTextEntry : function ( +) +{ + return false; +}, + +/** + * @method getPlaceHolder + * @return {String} + */ +getPlaceHolder : function ( +) +{ + return ; +}, + +/** + * @method attachWithIME + * @return {bool} + */ +attachWithIME : function ( +) +{ + return false; +}, + +/** + * @method textFieldWithPlaceHolder +* @param {String|String} str +* @param {String|size_object} str +* @param {float|cc.TextHAlignment} float +* @param {String} str +* @param {float} float +* @return {cc.TextFieldTTF|cc.TextFieldTTF} +*/ +textFieldWithPlaceHolder : function( +str, +size, +texthalignment, +str, +float +) +{ + return cc.TextFieldTTF; +}, + +/** + * @method TextFieldTTF + * @constructor + */ +TextFieldTTF : function ( +) +{ +}, + +}; + +/** + * @class ParallaxNode + */ +cc.ParallaxNode = { + +/** + * @method getParallaxArray +* @return {cc._ccArray|cc._ccArray} +*/ +getParallaxArray : function( +) +{ + return cc._ccArray; +}, + +/** + * @method addChild + * @param {cc.Node} arg0 + * @param {int} arg1 + * @param {vec2_object} arg2 + * @param {vec2_object} arg3 + */ +addChild : function ( +node, +int, +vec2, +vec2 +) +{ +}, + +/** + * @method removeAllChildrenWithCleanup + * @param {bool} arg0 + */ +removeAllChildrenWithCleanup : function ( +bool +) +{ +}, + +/** + * @method setParallaxArray + * @param {cc._ccArray} arg0 + */ +setParallaxArray : function ( +_ccarray +) +{ +}, + +/** + * @method create + * @return {cc.ParallaxNode} + */ +create : function ( +) +{ + return cc.ParallaxNode; +}, + +/** + * @method ParallaxNode + * @constructor + */ +ParallaxNode : function ( +) +{ +}, + +}; + +/** + * @class TMXObjectGroup + */ +cc.TMXObjectGroup = { + +/** + * @method setPositionOffset + * @param {vec2_object} arg0 + */ +setPositionOffset : function ( +vec2 +) +{ +}, + +/** + * @method getProperty + * @param {String} arg0 + * @return {cc.Value} + */ +getProperty : function ( +str +) +{ + return cc.Value; +}, + +/** + * @method getPositionOffset + * @return {vec2_object} + */ +getPositionOffset : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getObject + * @param {String} arg0 + * @return {map_object} + */ +getObject : function ( +str +) +{ + return map_object; +}, + +/** + * @method getObjects +* @return {Array|Array} +*/ +getObjects : function( +) +{ + return new Array(); +}, + +/** + * @method setGroupName + * @param {String} arg0 + */ +setGroupName : function ( +str +) +{ +}, + +/** + * @method getProperties +* @return {map_object|map_object} +*/ +getProperties : function( +) +{ + return map_object; +}, + +/** + * @method getGroupName + * @return {String} + */ +getGroupName : function ( +) +{ + return ; +}, + +/** + * @method setProperties + * @param {map_object} arg0 + */ +setProperties : function ( +map +) +{ +}, + +/** + * @method setObjects + * @param {Array} arg0 + */ +setObjects : function ( +array +) +{ +}, + +/** + * @method TMXObjectGroup + * @constructor + */ +TMXObjectGroup : function ( +) +{ +}, + +}; + +/** + * @class TMXLayerInfo + */ +cc.TMXLayerInfo = { + +/** + * @method setProperties + * @param {map_object} arg0 + */ +setProperties : function ( +map +) +{ +}, + +/** + * @method getProperties + * @return {map_object} + */ +getProperties : function ( +) +{ + return map_object; +}, + +/** + * @method TMXLayerInfo + * @constructor + */ +TMXLayerInfo : function ( +) +{ +}, + +}; + +/** + * @class TMXTilesetInfo + */ +cc.TMXTilesetInfo = { + +/** + * @method getRectForGID + * @param {unsigned int} arg0 + * @return {rect_object} + */ +getRectForGID : function ( +int +) +{ + return cc.Rect; +}, + +/** + * @method TMXTilesetInfo + * @constructor + */ +TMXTilesetInfo : function ( +) +{ +}, + +}; + +/** + * @class TMXMapInfo + */ +cc.TMXMapInfo = { + +/** + * @method setObjectGroups + * @param {Array} arg0 + */ +setObjectGroups : function ( +array +) +{ +}, + +/** + * @method setTileSize + * @param {size_object} arg0 + */ +setTileSize : function ( +size +) +{ +}, + +/** + * @method initWithTMXFile + * @param {String} arg0 + * @return {bool} + */ +initWithTMXFile : function ( +str +) +{ + return false; +}, + +/** + * @method getOrientation + * @return {int} + */ +getOrientation : function ( +) +{ + return 0; +}, + +/** + * @method isStoringCharacters + * @return {bool} + */ +isStoringCharacters : function ( +) +{ + return false; +}, + +/** + * @method setLayers + * @param {Array} arg0 + */ +setLayers : function ( +array +) +{ +}, + +/** + * @method parseXMLFile + * @param {String} arg0 + * @return {bool} + */ +parseXMLFile : function ( +str +) +{ + return false; +}, + +/** + * @method getParentElement + * @return {int} + */ +getParentElement : function ( +) +{ + return 0; +}, + +/** + * @method setTMXFileName + * @param {String} arg0 + */ +setTMXFileName : function ( +str +) +{ +}, + +/** + * @method parseXMLString + * @param {String} arg0 + * @return {bool} + */ +parseXMLString : function ( +str +) +{ + return false; +}, + +/** + * @method getLayers +* @return {Array|Array} +*/ +getLayers : function( +) +{ + return new Array(); +}, + +/** + * @method getTilesets +* @return {Array|Array} +*/ +getTilesets : function( +) +{ + return new Array(); +}, + +/** + * @method getParentGID + * @return {int} + */ +getParentGID : function ( +) +{ + return 0; +}, + +/** + * @method setParentElement + * @param {int} arg0 + */ +setParentElement : function ( +int +) +{ +}, + +/** + * @method initWithXML + * @param {String} arg0 + * @param {String} arg1 + * @return {bool} + */ +initWithXML : function ( +str, +str +) +{ + return false; +}, + +/** + * @method setParentGID + * @param {int} arg0 + */ +setParentGID : function ( +int +) +{ +}, + +/** + * @method getLayerAttribs + * @return {int} + */ +getLayerAttribs : function ( +) +{ + return 0; +}, + +/** + * @method getTileSize + * @return {size_object} + */ +getTileSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method getTileProperties + * @return {map_object} + */ +getTileProperties : function ( +) +{ + return map_object; +}, + +/** + * @method getObjectGroups +* @return {Array|Array} +*/ +getObjectGroups : function( +) +{ + return new Array(); +}, + +/** + * @method getTMXFileName + * @return {String} + */ +getTMXFileName : function ( +) +{ + return ; +}, + +/** + * @method setCurrentString + * @param {String} arg0 + */ +setCurrentString : function ( +str +) +{ +}, + +/** + * @method setProperties + * @param {map_object} arg0 + */ +setProperties : function ( +map +) +{ +}, + +/** + * @method setOrientation + * @param {int} arg0 + */ +setOrientation : function ( +int +) +{ +}, + +/** + * @method setTileProperties + * @param {map_object} arg0 + */ +setTileProperties : function ( +map +) +{ +}, + +/** + * @method setMapSize + * @param {size_object} arg0 + */ +setMapSize : function ( +size +) +{ +}, + +/** + * @method setStoringCharacters + * @param {bool} arg0 + */ +setStoringCharacters : function ( +bool +) +{ +}, + +/** + * @method getMapSize + * @return {size_object} + */ +getMapSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method setTilesets + * @param {Array} arg0 + */ +setTilesets : function ( +array +) +{ +}, + +/** + * @method getProperties +* @return {map_object|map_object} +*/ +getProperties : function( +) +{ + return map_object; +}, + +/** + * @method getCurrentString + * @return {String} + */ +getCurrentString : function ( +) +{ + return ; +}, + +/** + * @method setLayerAttribs + * @param {int} arg0 + */ +setLayerAttribs : function ( +int +) +{ +}, + +/** + * @method create + * @param {String} arg0 + * @return {cc.TMXMapInfo} + */ +create : function ( +str +) +{ + return cc.TMXMapInfo; +}, + +/** + * @method createWithXML + * @param {String} arg0 + * @param {String} arg1 + * @return {cc.TMXMapInfo} + */ +createWithXML : function ( +str, +str +) +{ + return cc.TMXMapInfo; +}, + +/** + * @method TMXMapInfo + * @constructor + */ +TMXMapInfo : function ( +) +{ +}, + +}; + +/** + * @class TMXLayer + */ +cc.TMXLayer = { + +/** + * @method getTileGIDAt + * @param {vec2_object} arg0 + * @param {cc.TMXTileFlags_} arg1 + * @return {unsigned int} + */ +getTileGIDAt : function ( +vec2, +tmxtileflags_ +) +{ + return 0; +}, + +/** + * @method getPositionAt + * @param {vec2_object} arg0 + * @return {vec2_object} + */ +getPositionAt : function ( +vec2 +) +{ + return cc.Vec2; +}, + +/** + * @method setLayerOrientation + * @param {int} arg0 + */ +setLayerOrientation : function ( +int +) +{ +}, + +/** + * @method releaseMap + */ +releaseMap : function ( +) +{ +}, + +/** + * @method setTiles + * @param {unsigned int} arg0 + */ +setTiles : function ( +int +) +{ +}, + +/** + * @method getLayerSize + * @return {size_object} + */ +getLayerSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method setMapTileSize + * @param {size_object} arg0 + */ +setMapTileSize : function ( +size +) +{ +}, + +/** + * @method getLayerOrientation + * @return {int} + */ +getLayerOrientation : function ( +) +{ + return 0; +}, + +/** + * @method setProperties + * @param {map_object} arg0 + */ +setProperties : function ( +map +) +{ +}, + +/** + * @method setLayerName + * @param {String} arg0 + */ +setLayerName : function ( +str +) +{ +}, + +/** + * @method removeTileAt + * @param {vec2_object} arg0 + */ +removeTileAt : function ( +vec2 +) +{ +}, + +/** + * @method initWithTilesetInfo + * @param {cc.TMXTilesetInfo} arg0 + * @param {cc.TMXLayerInfo} arg1 + * @param {cc.TMXMapInfo} arg2 + * @return {bool} + */ +initWithTilesetInfo : function ( +tmxtilesetinfo, +tmxlayerinfo, +map +) +{ + return false; +}, + +/** + * @method setupTiles + */ +setupTiles : function ( +) +{ +}, + +/** + * @method setTileGID +* @param {unsigned int|unsigned int} int +* @param {vec2_object|vec2_object} vec2 +* @param {cc.TMXTileFlags_} tmxtileflags_ +*/ +setTileGID : function( +int, +vec2, +tmxtileflags_ +) +{ +}, + +/** + * @method getMapTileSize + * @return {size_object} + */ +getMapTileSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method getProperty + * @param {String} arg0 + * @return {cc.Value} + */ +getProperty : function ( +str +) +{ + return cc.Value; +}, + +/** + * @method setLayerSize + * @param {size_object} arg0 + */ +setLayerSize : function ( +size +) +{ +}, + +/** + * @method getLayerName + * @return {String} + */ +getLayerName : function ( +) +{ + return ; +}, + +/** + * @method setTileSet + * @param {cc.TMXTilesetInfo} arg0 + */ +setTileSet : function ( +tmxtilesetinfo +) +{ +}, + +/** + * @method getTileSet + * @return {cc.TMXTilesetInfo} + */ +getTileSet : function ( +) +{ + return cc.TMXTilesetInfo; +}, + +/** + * @method getProperties +* @return {map_object|map_object} +*/ +getProperties : function( +) +{ + return map_object; +}, + +/** + * @method getTileAt + * @param {vec2_object} arg0 + * @return {cc.Sprite} + */ +getTileAt : function ( +vec2 +) +{ + return cc.Sprite; +}, + +/** + * @method create + * @param {cc.TMXTilesetInfo} arg0 + * @param {cc.TMXLayerInfo} arg1 + * @param {cc.TMXMapInfo} arg2 + * @return {cc.TMXLayer} + */ +create : function ( +tmxtilesetinfo, +tmxlayerinfo, +map +) +{ + return cc.TMXLayer; +}, + +/** + * @method TMXLayer + * @constructor + */ +TMXLayer : function ( +) +{ +}, + +}; + +/** + * @class TMXTiledMap + */ +cc.TMXTiledMap = { + +/** + * @method setObjectGroups + * @param {Array} arg0 + */ +setObjectGroups : function ( +array +) +{ +}, + +/** + * @method getProperty + * @param {String} arg0 + * @return {cc.Value} + */ +getProperty : function ( +str +) +{ + return cc.Value; +}, + +/** + * @method setMapSize + * @param {size_object} arg0 + */ +setMapSize : function ( +size +) +{ +}, + +/** + * @method getObjectGroup + * @param {String} arg0 + * @return {cc.TMXObjectGroup} + */ +getObjectGroup : function ( +str +) +{ + return cc.TMXObjectGroup; +}, + +/** + * @method getObjectGroups +* @return {Array|Array} +*/ +getObjectGroups : function( +) +{ + return new Array(); +}, + +/** + * @method initWithXML + * @param {String} arg0 + * @param {String} arg1 + * @return {bool} + */ +initWithXML : function ( +str, +str +) +{ + return false; +}, + +/** + * @method initWithTMXFile + * @param {String} arg0 + * @return {bool} + */ +initWithTMXFile : function ( +str +) +{ + return false; +}, + +/** + * @method getTileSize + * @return {size_object} + */ +getTileSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method getMapSize + * @return {size_object} + */ +getMapSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method getProperties + * @return {map_object} + */ +getProperties : function ( +) +{ + return map_object; +}, + +/** + * @method getPropertiesForGID +* @param {int|int} int +* @param {cc.Value} value +* @return {bool|cc.Value} +*/ +getPropertiesForGID : function( +int, +value +) +{ + return false; +}, + +/** + * @method setTileSize + * @param {size_object} arg0 + */ +setTileSize : function ( +size +) +{ +}, + +/** + * @method setProperties + * @param {map_object} arg0 + */ +setProperties : function ( +map +) +{ +}, + +/** + * @method getLayer + * @param {String} arg0 + * @return {cc.TMXLayer} + */ +getLayer : function ( +str +) +{ + return cc.TMXLayer; +}, + +/** + * @method getMapOrientation + * @return {int} + */ +getMapOrientation : function ( +) +{ + return 0; +}, + +/** + * @method setMapOrientation + * @param {int} arg0 + */ +setMapOrientation : function ( +int +) +{ +}, + +/** + * @method create + * @param {String} arg0 + * @return {cc.TMXTiledMap} + */ +create : function ( +str +) +{ + return cc.TMXTiledMap; +}, + +/** + * @method createWithXML + * @param {String} arg0 + * @param {String} arg1 + * @return {cc.TMXTiledMap} + */ +createWithXML : function ( +str, +str +) +{ + return cc.TMXTiledMap; +}, + +/** + * @method TMXTiledMap + * @constructor + */ +TMXTiledMap : function ( +) +{ +}, + +}; + +/** + * @class TileMapAtlas + */ +cc.TileMapAtlas = { + +/** + * @method initWithTileFile + * @param {String} arg0 + * @param {String} arg1 + * @param {int} arg2 + * @param {int} arg3 + * @return {bool} + */ +initWithTileFile : function ( +str, +str, +int, +int +) +{ + return false; +}, + +/** + * @method releaseMap + */ +releaseMap : function ( +) +{ +}, + +/** + * @method getTGAInfo + * @return {cc.sImageTGA} + */ +getTGAInfo : function ( +) +{ + return cc.sImageTGA; +}, + +/** + * @method getTileAt + * @param {vec2_object} arg0 + * @return {color3b_object} + */ +getTileAt : function ( +vec2 +) +{ + return cc.Color3B; +}, + +/** + * @method setTile + * @param {color3b_object} arg0 + * @param {vec2_object} arg1 + */ +setTile : function ( +color3b, +vec2 +) +{ +}, + +/** + * @method setTGAInfo + * @param {cc.sImageTGA} arg0 + */ +setTGAInfo : function ( +simagetga +) +{ +}, + +/** + * @method create + * @param {String} arg0 + * @param {String} arg1 + * @param {int} arg2 + * @param {int} arg3 + * @return {cc.TileMapAtlas} + */ +create : function ( +str, +str, +int, +int +) +{ + return cc.TileMapAtlas; +}, + +/** + * @method TileMapAtlas + * @constructor + */ +TileMapAtlas : function ( +) +{ +}, + +}; + +/** + * @class Component + */ +cc.Component = { + +/** + * @method setEnabled + * @param {bool} arg0 + */ +setEnabled : function ( +bool +) +{ +}, + +/** + * @method setName + * @param {String} arg0 + */ +setName : function ( +str +) +{ +}, + +/** + * @method isEnabled + * @return {bool} + */ +isEnabled : function ( +) +{ + return false; +}, + +/** + * @method update + * @param {float} arg0 + */ +update : function ( +float +) +{ +}, + +/** + * @method getOwner + * @return {cc.Node} + */ +getOwner : function ( +) +{ + return cc.Node; +}, + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method setOwner + * @param {cc.Node} arg0 + */ +setOwner : function ( +node +) +{ +}, + +/** + * @method getName + * @return {String} + */ +getName : function ( +) +{ + return ; +}, + +/** + * @method create + * @return {cc.Component} + */ +create : function ( +) +{ + return cc.Component; +}, + +/** + * @method Component + * @constructor + */ +Component : function ( +) +{ +}, + +}; + +/** + * @class ComponentContainer + */ +cc.ComponentContainer = { + +/** + * @method visit + * @param {float} arg0 + */ +visit : function ( +float +) +{ +}, + +/** + * @method remove +* @param {cc.Component|String} component +* @return {bool|bool} +*/ +remove : function( +str +) +{ + return false; +}, + +/** + * @method removeAll + */ +removeAll : function ( +) +{ +}, + +/** + * @method add + * @param {cc.Component} arg0 + * @return {bool} + */ +add : function ( +component +) +{ + return false; +}, + +/** + * @method isEmpty + * @return {bool} + */ +isEmpty : function ( +) +{ + return false; +}, + +/** + * @method get + * @param {String} arg0 + * @return {cc.Component} + */ +get : function ( +str +) +{ + return cc.Component; +}, + +}; + +/** + * @class SimpleAudioEngine + */ +cc.AudioEngine = { + +/** + * @method preloadBackgroundMusic + * @param {char} arg0 + */ +preloadBackgroundMusic : function ( +char +) +{ +}, + +/** + * @method stopBackgroundMusic + */ +stopBackgroundMusic : function ( +) +{ +}, + +/** + * @method stopAllEffects + */ +stopAllEffects : function ( +) +{ +}, + +/** + * @method getBackgroundMusicVolume + * @return {float} + */ +getBackgroundMusicVolume : function ( +) +{ + return 0; +}, + +/** + * @method resumeBackgroundMusic + */ +resumeBackgroundMusic : function ( +) +{ +}, + +/** + * @method setBackgroundMusicVolume + * @param {float} arg0 + */ +setBackgroundMusicVolume : function ( +float +) +{ +}, + +/** + * @method preloadEffect + * @param {char} arg0 + */ +preloadEffect : function ( +char +) +{ +}, + +/** + * @method isBackgroundMusicPlaying + * @return {bool} + */ +isBackgroundMusicPlaying : function ( +) +{ + return false; +}, + +/** + * @method getEffectsVolume + * @return {float} + */ +getEffectsVolume : function ( +) +{ + return 0; +}, + +/** + * @method willPlayBackgroundMusic + * @return {bool} + */ +willPlayBackgroundMusic : function ( +) +{ + return false; +}, + +/** + * @method pauseEffect + * @param {unsigned int} arg0 + */ +pauseEffect : function ( +int +) +{ +}, + +/** + * @method playEffect + * @param {char} arg0 + * @param {bool} arg1 + * @param {float} arg2 + * @param {float} arg3 + * @param {float} arg4 + * @return {unsigned int} + */ +playEffect : function ( +char, +bool, +float, +float, +float +) +{ + return 0; +}, + +/** + * @method rewindBackgroundMusic + */ +rewindBackgroundMusic : function ( +) +{ +}, + +/** + * @method playBackgroundMusic + * @param {char} arg0 + * @param {bool} arg1 + */ +playBackgroundMusic : function ( +char, +bool +) +{ +}, + +/** + * @method resumeAllEffects + */ +resumeAllEffects : function ( +) +{ +}, + +/** + * @method setEffectsVolume + * @param {float} arg0 + */ +setEffectsVolume : function ( +float +) +{ +}, + +/** + * @method stopEffect + * @param {unsigned int} arg0 + */ +stopEffect : function ( +int +) +{ +}, + +/** + * @method pauseBackgroundMusic + */ +pauseBackgroundMusic : function ( +) +{ +}, + +/** + * @method pauseAllEffects + */ +pauseAllEffects : function ( +) +{ +}, + +/** + * @method unloadEffect + * @param {char} arg0 + */ +unloadEffect : function ( +char +) +{ +}, + +/** + * @method resumeEffect + * @param {unsigned int} arg0 + */ +resumeEffect : function ( +int +) +{ +}, + +/** + * @method end + */ +end : function ( +) +{ +}, + +/** + * @method getInstance + * @return {cc.SimpleAudioEngine} + */ +getInstance : function ( +) +{ + return cc.SimpleAudioEngine; +}, + +}; diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_builder_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_builder_auto_api.js new file mode 100644 index 0000000000..1626c4dd4a --- /dev/null +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_builder_auto_api.js @@ -0,0 +1,632 @@ +/** + * @module cocos2dx_builder + */ +var cc = cc || {}; + +/** + * @class CCBAnimationManager + */ +cc.BuilderAnimationManager = { + +/** + * @method moveAnimationsFromNode + * @param {cc.Node} arg0 + * @param {cc.Node} arg1 + */ +moveAnimationsFromNode : function ( +node, +node +) +{ +}, + +/** + * @method setAutoPlaySequenceId + * @param {int} arg0 + */ +setAutoPlaySequenceId : function ( +int +) +{ +}, + +/** + * @method getDocumentCallbackNames + * @return {Array} + */ +getDocumentCallbackNames : function ( +) +{ + return new Array(); +}, + +/** + * @method actionForSoundChannel + * @param {cc.CCBSequenceProperty} arg0 + * @return {cc.Sequence} + */ +actionForSoundChannel : function ( +ccbsequenceproperty +) +{ + return cc.Sequence; +}, + +/** + * @method setBaseValue + * @param {cc.Value} arg0 + * @param {cc.Node} arg1 + * @param {String} arg2 + */ +setBaseValue : function ( +value, +node, +str +) +{ +}, + +/** + * @method getDocumentOutletNodes + * @return {Array} + */ +getDocumentOutletNodes : function ( +) +{ + return new Array(); +}, + +/** + * @method getLastCompletedSequenceName + * @return {String} + */ +getLastCompletedSequenceName : function ( +) +{ + return ; +}, + +/** + * @method setRootNode + * @param {cc.Node} arg0 + */ +setRootNode : function ( +node +) +{ +}, + +/** + * @method runAnimationsForSequenceNamedTweenDuration + * @param {char} arg0 + * @param {float} arg1 + */ +runAnimationsForSequenceNamedTweenDuration : function ( +char, +float +) +{ +}, + +/** + * @method addDocumentOutletName + * @param {String} arg0 + */ +addDocumentOutletName : function ( +str +) +{ +}, + +/** + * @method getRootContainerSize + * @return {size_object} + */ +getRootContainerSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method setDocumentControllerName + * @param {String} arg0 + */ +setDocumentControllerName : function ( +str +) +{ +}, + +/** + * @method setObject + * @param {cc.Ref} arg0 + * @param {cc.Node} arg1 + * @param {String} arg2 + */ +setObject : function ( +ref, +node, +str +) +{ +}, + +/** + * @method getContainerSize + * @param {cc.Node} arg0 + * @return {size_object} + */ +getContainerSize : function ( +node +) +{ + return cc.Size; +}, + +/** + * @method actionForCallbackChannel + * @param {cc.CCBSequenceProperty} arg0 + * @return {cc.Sequence} + */ +actionForCallbackChannel : function ( +ccbsequenceproperty +) +{ + return cc.Sequence; +}, + +/** + * @method getDocumentOutletNames + * @return {Array} + */ +getDocumentOutletNames : function ( +) +{ + return new Array(); +}, + +/** + * @method addDocumentCallbackControlEvents + * @param {cc.Control::EventType} arg0 + */ +addDocumentCallbackControlEvents : function ( +eventtype +) +{ +}, + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method getKeyframeCallbacks + * @return {Array} + */ +getKeyframeCallbacks : function ( +) +{ + return new Array(); +}, + +/** + * @method getDocumentCallbackControlEvents + * @return {Array} + */ +getDocumentCallbackControlEvents : function ( +) +{ + return new Array(); +}, + +/** + * @method setRootContainerSize + * @param {size_object} arg0 + */ +setRootContainerSize : function ( +size +) +{ +}, + +/** + * @method runAnimationsForSequenceIdTweenDuration + * @param {int} arg0 + * @param {float} arg1 + */ +runAnimationsForSequenceIdTweenDuration : function ( +int, +float +) +{ +}, + +/** + * @method getRunningSequenceName + * @return {char} + */ +getRunningSequenceName : function ( +) +{ + return 0; +}, + +/** + * @method getAutoPlaySequenceId + * @return {int} + */ +getAutoPlaySequenceId : function ( +) +{ + return 0; +}, + +/** + * @method addDocumentCallbackName + * @param {String} arg0 + */ +addDocumentCallbackName : function ( +str +) +{ +}, + +/** + * @method getRootNode + * @return {cc.Node} + */ +getRootNode : function ( +) +{ + return cc.Node; +}, + +/** + * @method addDocumentOutletNode + * @param {cc.Node} arg0 + */ +addDocumentOutletNode : function ( +node +) +{ +}, + +/** + * @method setDelegate + * @param {cc.CCBAnimationManagerDelegate} arg0 + */ +setDelegate : function ( +ccbanimationmanagerdelegate +) +{ +}, + +/** + * @method getSequenceDuration + * @param {char} arg0 + * @return {float} + */ +getSequenceDuration : function ( +char +) +{ + return 0; +}, + +/** + * @method addDocumentCallbackNode + * @param {cc.Node} arg0 + */ +addDocumentCallbackNode : function ( +node +) +{ +}, + +/** + * @method runAnimationsForSequenceNamed + * @param {char} arg0 + */ +runAnimationsForSequenceNamed : function ( +char +) +{ +}, + +/** + * @method getSequenceId + * @param {char} arg0 + * @return {int} + */ +getSequenceId : function ( +char +) +{ + return 0; +}, + +/** + * @method setCallFunc + * @param {cc.CallFunc} arg0 + * @param {String} arg1 + */ +setCallFunc : function ( +callfunc, +str +) +{ +}, + +/** + * @method getDocumentCallbackNodes + * @return {Array} + */ +getDocumentCallbackNodes : function ( +) +{ + return new Array(); +}, + +/** + * @method setSequences + * @param {Array} arg0 + */ +setSequences : function ( +array +) +{ +}, + +/** + * @method debug + */ +debug : function ( +) +{ +}, + +/** + * @method getDocumentControllerName + * @return {String} + */ +getDocumentControllerName : function ( +) +{ + return ; +}, + +/** + * @method CCBAnimationManager + * @constructor + */ +CCBAnimationManager : function ( +) +{ +}, + +}; + +/** + * @class CCBReader + */ +cc._Reader = { + +/** + * @method getAnimationManager + * @return {cc.CCBAnimationManager} + */ +getAnimationManager : function ( +) +{ + return cc.CCBAnimationManager; +}, + +/** + * @method setAnimationManager + * @param {cc.CCBAnimationManager} arg0 + */ +setAnimationManager : function ( +ccbanimationmanager +) +{ +}, + +/** + * @method addOwnerOutletName + * @param {String} arg0 + */ +addOwnerOutletName : function ( +str +) +{ +}, + +/** + * @method getOwnerCallbackNames + * @return {Array} + */ +getOwnerCallbackNames : function ( +) +{ + return new Array(); +}, + +/** + * @method addDocumentCallbackControlEvents + * @param {cc.Control::EventType} arg0 + */ +addDocumentCallbackControlEvents : function ( +eventtype +) +{ +}, + +/** + * @method setCCBRootPath + * @param {char} arg0 + */ +setCCBRootPath : function ( +char +) +{ +}, + +/** + * @method addOwnerOutletNode + * @param {cc.Node} arg0 + */ +addOwnerOutletNode : function ( +node +) +{ +}, + +/** + * @method getOwnerCallbackNodes + * @return {Array} + */ +getOwnerCallbackNodes : function ( +) +{ + return new Array(); +}, + +/** + * @method readSoundKeyframesForSeq + * @param {cc.CCBSequence} arg0 + * @return {bool} + */ +readSoundKeyframesForSeq : function ( +ccbsequence +) +{ + return false; +}, + +/** + * @method getCCBRootPath + * @return {String} + */ +getCCBRootPath : function ( +) +{ + return ; +}, + +/** + * @method getOwnerCallbackControlEvents + * @return {Array} + */ +getOwnerCallbackControlEvents : function ( +) +{ + return new Array(); +}, + +/** + * @method getOwnerOutletNodes + * @return {Array} + */ +getOwnerOutletNodes : function ( +) +{ + return new Array(); +}, + +/** + * @method readUTF8 + * @return {String} + */ +readUTF8 : function ( +) +{ + return ; +}, + +/** + * @method addOwnerCallbackControlEvents + * @param {cc.Control::EventType} arg0 + */ +addOwnerCallbackControlEvents : function ( +eventtype +) +{ +}, + +/** + * @method getOwnerOutletNames + * @return {Array} + */ +getOwnerOutletNames : function ( +) +{ + return new Array(); +}, + +/** + * @method readCallbackKeyframesForSeq + * @param {cc.CCBSequence} arg0 + * @return {bool} + */ +readCallbackKeyframesForSeq : function ( +ccbsequence +) +{ + return false; +}, + +/** + * @method getAnimationManagersForNodes + * @return {Array} + */ +getAnimationManagersForNodes : function ( +) +{ + return new Array(); +}, + +/** + * @method getNodesWithAnimationManagers + * @return {Array} + */ +getNodesWithAnimationManagers : function ( +) +{ + return new Array(); +}, + +/** + * @method setResolutionScale + * @param {float} arg0 + */ +setResolutionScale : function ( +float +) +{ +}, + +/** + * @method CCBReader + * @constructor +* @param {cc.CCBReader|cc.NodeLoaderLibrary} ccbreader +* @param {cc.CCBMemberVariableAssigner} ccbmembervariableassigner +* @param {cc.CCBSelectorResolver} ccbselectorresolver +* @param {cc.NodeLoaderListener} nodeloaderlistener +*/ +CCBReader : function( +nodeloaderlibrary, +ccbmembervariableassigner, +ccbselectorresolver, +nodeloaderlistener +) +{ +}, + +}; diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_extension_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_extension_auto_api.js new file mode 100644 index 0000000000..89a1e3796d --- /dev/null +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_extension_auto_api.js @@ -0,0 +1,2655 @@ +/** + * @module cocos2dx_extension + */ +var cc = cc || {}; + +/** + * @class Control + */ +cc.Control = { + +/** + * @method setEnabled + * @param {bool} arg0 + */ +setEnabled : function ( +bool +) +{ +}, + +/** + * @method getState + * @return {cc.Control::State} + */ +getState : function ( +) +{ + return 0; +}, + +/** + * @method sendActionsForControlEvents + * @param {cc.Control::EventType} arg0 + */ +sendActionsForControlEvents : function ( +eventtype +) +{ +}, + +/** + * @method setSelected + * @param {bool} arg0 + */ +setSelected : function ( +bool +) +{ +}, + +/** + * @method isEnabled + * @return {bool} + */ +isEnabled : function ( +) +{ + return false; +}, + +/** + * @method needsLayout + */ +needsLayout : function ( +) +{ +}, + +/** + * @method hasVisibleParents + * @return {bool} + */ +hasVisibleParents : function ( +) +{ + return false; +}, + +/** + * @method isSelected + * @return {bool} + */ +isSelected : function ( +) +{ + return false; +}, + +/** + * @method isTouchInside + * @param {cc.Touch} arg0 + * @return {bool} + */ +isTouchInside : function ( +touch +) +{ + return false; +}, + +/** + * @method setHighlighted + * @param {bool} arg0 + */ +setHighlighted : function ( +bool +) +{ +}, + +/** + * @method getTouchLocation + * @param {cc.Touch} arg0 + * @return {vec2_object} + */ +getTouchLocation : function ( +touch +) +{ + return cc.Vec2; +}, + +/** + * @method isHighlighted + * @return {bool} + */ +isHighlighted : function ( +) +{ + return false; +}, + +/** + * @method create + * @return {cc.Control} + */ +create : function ( +) +{ + return cc.Control; +}, + +/** + * @method Control + * @constructor + */ +Control : function ( +) +{ +}, + +}; + +/** + * @class ControlButton + */ +cc.ControlButton = { + +/** + * @method isPushed + * @return {bool} + */ +isPushed : function ( +) +{ + return false; +}, + +/** + * @method setTitleLabelForState + * @param {cc.Node} arg0 + * @param {cc.Control::State} arg1 + */ +setTitleLabelForState : function ( +node, +state +) +{ +}, + +/** + * @method setAdjustBackgroundImage + * @param {bool} arg0 + */ +setAdjustBackgroundImage : function ( +bool +) +{ +}, + +/** + * @method setTitleForState + * @param {String} arg0 + * @param {cc.Control::State} arg1 + */ +setTitleForState : function ( +str, +state +) +{ +}, + +/** + * @method setLabelAnchorPoint + * @param {vec2_object} arg0 + */ +setLabelAnchorPoint : function ( +vec2 +) +{ +}, + +/** + * @method getLabelAnchorPoint + * @return {vec2_object} + */ +getLabelAnchorPoint : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method initWithBackgroundSprite + * @param {ccui.Scale9Sprite} arg0 + * @return {bool} + */ +initWithBackgroundSprite : function ( +scale9sprite +) +{ + return false; +}, + +/** + * @method getTitleTTFSizeForState + * @param {cc.Control::State} arg0 + * @return {float} + */ +getTitleTTFSizeForState : function ( +state +) +{ + return 0; +}, + +/** + * @method setTitleTTFForState + * @param {String} arg0 + * @param {cc.Control::State} arg1 + */ +setTitleTTFForState : function ( +str, +state +) +{ +}, + +/** + * @method setTitleTTFSizeForState + * @param {float} arg0 + * @param {cc.Control::State} arg1 + */ +setTitleTTFSizeForState : function ( +float, +state +) +{ +}, + +/** + * @method setTitleLabel + * @param {cc.Node} arg0 + */ +setTitleLabel : function ( +node +) +{ +}, + +/** + * @method setPreferredSize + * @param {size_object} arg0 + */ +setPreferredSize : function ( +size +) +{ +}, + +/** + * @method getCurrentTitleColor + * @return {color3b_object} + */ +getCurrentTitleColor : function ( +) +{ + return cc.Color3B; +}, + +/** + * @method setZoomOnTouchDown + * @param {bool} arg0 + */ +setZoomOnTouchDown : function ( +bool +) +{ +}, + +/** + * @method setBackgroundSprite + * @param {ccui.Scale9Sprite} arg0 + */ +setBackgroundSprite : function ( +scale9sprite +) +{ +}, + +/** + * @method getBackgroundSpriteForState + * @param {cc.Control::State} arg0 + * @return {ccui.Scale9Sprite} + */ +getBackgroundSpriteForState : function ( +state +) +{ + return ccui.Scale9Sprite; +}, + +/** + * @method getHorizontalOrigin + * @return {int} + */ +getHorizontalOrigin : function ( +) +{ + return 0; +}, + +/** + * @method initWithTitleAndFontNameAndFontSize + * @param {String} arg0 + * @param {String} arg1 + * @param {float} arg2 + * @return {bool} + */ +initWithTitleAndFontNameAndFontSize : function ( +str, +str, +float +) +{ + return false; +}, + +/** + * @method setTitleBMFontForState + * @param {String} arg0 + * @param {cc.Control::State} arg1 + */ +setTitleBMFontForState : function ( +str, +state +) +{ +}, + +/** + * @method getScaleRatio + * @return {float} + */ +getScaleRatio : function ( +) +{ + return 0; +}, + +/** + * @method getTitleTTFForState + * @param {cc.Control::State} arg0 + * @return {String} + */ +getTitleTTFForState : function ( +state +) +{ + return ; +}, + +/** + * @method getBackgroundSprite + * @return {ccui.Scale9Sprite} + */ +getBackgroundSprite : function ( +) +{ + return ccui.Scale9Sprite; +}, + +/** + * @method getTitleColorForState + * @param {cc.Control::State} arg0 + * @return {color3b_object} + */ +getTitleColorForState : function ( +state +) +{ + return cc.Color3B; +}, + +/** + * @method setTitleColorForState + * @param {color3b_object} arg0 + * @param {cc.Control::State} arg1 + */ +setTitleColorForState : function ( +color3b, +state +) +{ +}, + +/** + * @method doesAdjustBackgroundImage + * @return {bool} + */ +doesAdjustBackgroundImage : function ( +) +{ + return false; +}, + +/** + * @method setBackgroundSpriteFrameForState + * @param {cc.SpriteFrame} arg0 + * @param {cc.Control::State} arg1 + */ +setBackgroundSpriteFrameForState : function ( +spriteframe, +state +) +{ +}, + +/** + * @method setBackgroundSpriteForState + * @param {ccui.Scale9Sprite} arg0 + * @param {cc.Control::State} arg1 + */ +setBackgroundSpriteForState : function ( +scale9sprite, +state +) +{ +}, + +/** + * @method setScaleRatio + * @param {float} arg0 + */ +setScaleRatio : function ( +float +) +{ +}, + +/** + * @method getTitleBMFontForState + * @param {cc.Control::State} arg0 + * @return {String} + */ +getTitleBMFontForState : function ( +state +) +{ + return ; +}, + +/** + * @method getTitleLabel + * @return {cc.Node} + */ +getTitleLabel : function ( +) +{ + return cc.Node; +}, + +/** + * @method getPreferredSize + * @return {size_object} + */ +getPreferredSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method getVerticalMargin + * @return {int} + */ +getVerticalMargin : function ( +) +{ + return 0; +}, + +/** + * @method getTitleLabelForState + * @param {cc.Control::State} arg0 + * @return {cc.Node} + */ +getTitleLabelForState : function ( +state +) +{ + return cc.Node; +}, + +/** + * @method setMargins + * @param {int} arg0 + * @param {int} arg1 + */ +setMargins : function ( +int, +int +) +{ +}, + +/** + * @method getCurrentTitle +* @return {String|String} +*/ +getCurrentTitle : function( +) +{ + return ; +}, + +/** + * @method initWithLabelAndBackgroundSprite + * @param {cc.Node} arg0 + * @param {ccui.Scale9Sprite} arg1 + * @return {bool} + */ +initWithLabelAndBackgroundSprite : function ( +node, +scale9sprite +) +{ + return false; +}, + +/** + * @method getZoomOnTouchDown + * @return {bool} + */ +getZoomOnTouchDown : function ( +) +{ + return false; +}, + +/** + * @method getTitleForState + * @param {cc.Control::State} arg0 + * @return {String} + */ +getTitleForState : function ( +state +) +{ + return ; +}, + +/** + * @method create +* @param {ccui.Scale9Sprite|cc.Node|String} scale9sprite +* @param {ccui.Scale9Sprite|String} scale9sprite +* @param {float} float +* @return {cc.ControlButton|cc.ControlButton|cc.ControlButton|cc.ControlButton} +*/ +create : function( +str, +str, +float +) +{ + return cc.ControlButton; +}, + +/** + * @method ControlButton + * @constructor + */ +ControlButton : function ( +) +{ +}, + +}; + +/** + * @class ControlHuePicker + */ +cc.ControlHuePicker = { + +/** + * @method initWithTargetAndPos + * @param {cc.Node} arg0 + * @param {vec2_object} arg1 + * @return {bool} + */ +initWithTargetAndPos : function ( +node, +vec2 +) +{ + return false; +}, + +/** + * @method setHue + * @param {float} arg0 + */ +setHue : function ( +float +) +{ +}, + +/** + * @method getStartPos + * @return {vec2_object} + */ +getStartPos : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getHue + * @return {float} + */ +getHue : function ( +) +{ + return 0; +}, + +/** + * @method getSlider + * @return {cc.Sprite} + */ +getSlider : function ( +) +{ + return cc.Sprite; +}, + +/** + * @method setBackground + * @param {cc.Sprite} arg0 + */ +setBackground : function ( +sprite +) +{ +}, + +/** + * @method setHuePercentage + * @param {float} arg0 + */ +setHuePercentage : function ( +float +) +{ +}, + +/** + * @method getBackground + * @return {cc.Sprite} + */ +getBackground : function ( +) +{ + return cc.Sprite; +}, + +/** + * @method getHuePercentage + * @return {float} + */ +getHuePercentage : function ( +) +{ + return 0; +}, + +/** + * @method setSlider + * @param {cc.Sprite} arg0 + */ +setSlider : function ( +sprite +) +{ +}, + +/** + * @method create + * @param {cc.Node} arg0 + * @param {vec2_object} arg1 + * @return {cc.ControlHuePicker} + */ +create : function ( +node, +vec2 +) +{ + return cc.ControlHuePicker; +}, + +/** + * @method ControlHuePicker + * @constructor + */ +ControlHuePicker : function ( +) +{ +}, + +}; + +/** + * @class ControlSaturationBrightnessPicker + */ +cc.ControlSaturationBrightnessPicker = { + +/** + * @method getShadow + * @return {cc.Sprite} + */ +getShadow : function ( +) +{ + return cc.Sprite; +}, + +/** + * @method initWithTargetAndPos + * @param {cc.Node} arg0 + * @param {vec2_object} arg1 + * @return {bool} + */ +initWithTargetAndPos : function ( +node, +vec2 +) +{ + return false; +}, + +/** + * @method getStartPos + * @return {vec2_object} + */ +getStartPos : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getOverlay + * @return {cc.Sprite} + */ +getOverlay : function ( +) +{ + return cc.Sprite; +}, + +/** + * @method getSlider + * @return {cc.Sprite} + */ +getSlider : function ( +) +{ + return cc.Sprite; +}, + +/** + * @method getBackground + * @return {cc.Sprite} + */ +getBackground : function ( +) +{ + return cc.Sprite; +}, + +/** + * @method getSaturation + * @return {float} + */ +getSaturation : function ( +) +{ + return 0; +}, + +/** + * @method getBrightness + * @return {float} + */ +getBrightness : function ( +) +{ + return 0; +}, + +/** + * @method create + * @param {cc.Node} arg0 + * @param {vec2_object} arg1 + * @return {cc.ControlSaturationBrightnessPicker} + */ +create : function ( +node, +vec2 +) +{ + return cc.ControlSaturationBrightnessPicker; +}, + +/** + * @method ControlSaturationBrightnessPicker + * @constructor + */ +ControlSaturationBrightnessPicker : function ( +) +{ +}, + +}; + +/** + * @class ControlColourPicker + */ +cc.ControlColourPicker = { + +/** + * @method hueSliderValueChanged + * @param {cc.Ref} arg0 + * @param {cc.Control::EventType} arg1 + */ +hueSliderValueChanged : function ( +ref, +eventtype +) +{ +}, + +/** + * @method getHuePicker + * @return {cc.ControlHuePicker} + */ +getHuePicker : function ( +) +{ + return cc.ControlHuePicker; +}, + +/** + * @method getcolourPicker + * @return {cc.ControlSaturationBrightnessPicker} + */ +getcolourPicker : function ( +) +{ + return cc.ControlSaturationBrightnessPicker; +}, + +/** + * @method setBackground + * @param {cc.Sprite} arg0 + */ +setBackground : function ( +sprite +) +{ +}, + +/** + * @method setcolourPicker + * @param {cc.ControlSaturationBrightnessPicker} arg0 + */ +setcolourPicker : function ( +controlsaturationbrightnesspicker +) +{ +}, + +/** + * @method colourSliderValueChanged + * @param {cc.Ref} arg0 + * @param {cc.Control::EventType} arg1 + */ +colourSliderValueChanged : function ( +ref, +eventtype +) +{ +}, + +/** + * @method setHuePicker + * @param {cc.ControlHuePicker} arg0 + */ +setHuePicker : function ( +controlhuepicker +) +{ +}, + +/** + * @method getBackground + * @return {cc.Sprite} + */ +getBackground : function ( +) +{ + return cc.Sprite; +}, + +/** + * @method create + * @return {cc.ControlColourPicker} + */ +create : function ( +) +{ + return cc.ControlColourPicker; +}, + +/** + * @method ControlColourPicker + * @constructor + */ +ControlColourPicker : function ( +) +{ +}, + +}; + +/** + * @class ControlPotentiometer + */ +cc.ControlPotentiometer = { + +/** + * @method setPreviousLocation + * @param {vec2_object} arg0 + */ +setPreviousLocation : function ( +vec2 +) +{ +}, + +/** + * @method setValue + * @param {float} arg0 + */ +setValue : function ( +float +) +{ +}, + +/** + * @method getProgressTimer + * @return {cc.ProgressTimer} + */ +getProgressTimer : function ( +) +{ + return cc.ProgressTimer; +}, + +/** + * @method getMaximumValue + * @return {float} + */ +getMaximumValue : function ( +) +{ + return 0; +}, + +/** + * @method angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint + * @param {vec2_object} arg0 + * @param {vec2_object} arg1 + * @param {vec2_object} arg2 + * @param {vec2_object} arg3 + * @return {float} + */ +angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint : function ( +vec2, +vec2, +vec2, +vec2 +) +{ + return 0; +}, + +/** + * @method potentiometerBegan + * @param {vec2_object} arg0 + */ +potentiometerBegan : function ( +vec2 +) +{ +}, + +/** + * @method setMaximumValue + * @param {float} arg0 + */ +setMaximumValue : function ( +float +) +{ +}, + +/** + * @method getMinimumValue + * @return {float} + */ +getMinimumValue : function ( +) +{ + return 0; +}, + +/** + * @method setThumbSprite + * @param {cc.Sprite} arg0 + */ +setThumbSprite : function ( +sprite +) +{ +}, + +/** + * @method getValue + * @return {float} + */ +getValue : function ( +) +{ + return 0; +}, + +/** + * @method getPreviousLocation + * @return {vec2_object} + */ +getPreviousLocation : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method distanceBetweenPointAndPoint + * @param {vec2_object} arg0 + * @param {vec2_object} arg1 + * @return {float} + */ +distanceBetweenPointAndPoint : function ( +vec2, +vec2 +) +{ + return 0; +}, + +/** + * @method potentiometerEnded + * @param {vec2_object} arg0 + */ +potentiometerEnded : function ( +vec2 +) +{ +}, + +/** + * @method setProgressTimer + * @param {cc.ProgressTimer} arg0 + */ +setProgressTimer : function ( +progresstimer +) +{ +}, + +/** + * @method setMinimumValue + * @param {float} arg0 + */ +setMinimumValue : function ( +float +) +{ +}, + +/** + * @method getThumbSprite + * @return {cc.Sprite} + */ +getThumbSprite : function ( +) +{ + return cc.Sprite; +}, + +/** + * @method initWithTrackSprite_ProgressTimer_ThumbSprite + * @param {cc.Sprite} arg0 + * @param {cc.ProgressTimer} arg1 + * @param {cc.Sprite} arg2 + * @return {bool} + */ +initWithTrackSprite_ProgressTimer_ThumbSprite : function ( +sprite, +progresstimer, +sprite +) +{ + return false; +}, + +/** + * @method potentiometerMoved + * @param {vec2_object} arg0 + */ +potentiometerMoved : function ( +vec2 +) +{ +}, + +/** + * @method create + * @param {char} arg0 + * @param {char} arg1 + * @param {char} arg2 + * @return {cc.ControlPotentiometer} + */ +create : function ( +char, +char, +char +) +{ + return cc.ControlPotentiometer; +}, + +/** + * @method ControlPotentiometer + * @constructor + */ +ControlPotentiometer : function ( +) +{ +}, + +}; + +/** + * @class ControlSlider + */ +cc.ControlSlider = { + +/** + * @method setBackgroundSprite + * @param {cc.Sprite} arg0 + */ +setBackgroundSprite : function ( +sprite +) +{ +}, + +/** + * @method getMaximumAllowedValue + * @return {float} + */ +getMaximumAllowedValue : function ( +) +{ + return 0; +}, + +/** + * @method initWithSprites +* @param {cc.Sprite|cc.Sprite} sprite +* @param {cc.Sprite|cc.Sprite} sprite +* @param {cc.Sprite|cc.Sprite} sprite +* @param {cc.Sprite} sprite +* @return {bool|bool} +*/ +initWithSprites : function( +sprite, +sprite, +sprite, +sprite +) +{ + return false; +}, + +/** + * @method getMinimumAllowedValue + * @return {float} + */ +getMinimumAllowedValue : function ( +) +{ + return 0; +}, + +/** + * @method getMaximumValue + * @return {float} + */ +getMaximumValue : function ( +) +{ + return 0; +}, + +/** + * @method getSelectedThumbSprite + * @return {cc.Sprite} + */ +getSelectedThumbSprite : function ( +) +{ + return cc.Sprite; +}, + +/** + * @method setProgressSprite + * @param {cc.Sprite} arg0 + */ +setProgressSprite : function ( +sprite +) +{ +}, + +/** + * @method setMaximumValue + * @param {float} arg0 + */ +setMaximumValue : function ( +float +) +{ +}, + +/** + * @method getMinimumValue + * @return {float} + */ +getMinimumValue : function ( +) +{ + return 0; +}, + +/** + * @method setThumbSprite + * @param {cc.Sprite} arg0 + */ +setThumbSprite : function ( +sprite +) +{ +}, + +/** + * @method getValue + * @return {float} + */ +getValue : function ( +) +{ + return 0; +}, + +/** + * @method getBackgroundSprite + * @return {cc.Sprite} + */ +getBackgroundSprite : function ( +) +{ + return cc.Sprite; +}, + +/** + * @method getThumbSprite + * @return {cc.Sprite} + */ +getThumbSprite : function ( +) +{ + return cc.Sprite; +}, + +/** + * @method setValue + * @param {float} arg0 + */ +setValue : function ( +float +) +{ +}, + +/** + * @method locationFromTouch + * @param {cc.Touch} arg0 + * @return {vec2_object} + */ +locationFromTouch : function ( +touch +) +{ + return cc.Vec2; +}, + +/** + * @method setMinimumValue + * @param {float} arg0 + */ +setMinimumValue : function ( +float +) +{ +}, + +/** + * @method setMinimumAllowedValue + * @param {float} arg0 + */ +setMinimumAllowedValue : function ( +float +) +{ +}, + +/** + * @method getProgressSprite + * @return {cc.Sprite} + */ +getProgressSprite : function ( +) +{ + return cc.Sprite; +}, + +/** + * @method setSelectedThumbSprite + * @param {cc.Sprite} arg0 + */ +setSelectedThumbSprite : function ( +sprite +) +{ +}, + +/** + * @method setMaximumAllowedValue + * @param {float} arg0 + */ +setMaximumAllowedValue : function ( +float +) +{ +}, + +/** + * @method create +* @param {cc.Sprite|char|char|cc.Sprite} sprite +* @param {cc.Sprite|char|char|cc.Sprite} sprite +* @param {cc.Sprite|char|char|cc.Sprite} sprite +* @param {char|cc.Sprite} char +* @return {cc.ControlSlider|cc.ControlSlider|cc.ControlSlider|cc.ControlSlider} +*/ +create : function( +sprite, +sprite, +sprite, +sprite +) +{ + return cc.ControlSlider; +}, + +/** + * @method ControlSlider + * @constructor + */ +ControlSlider : function ( +) +{ +}, + +}; + +/** + * @class ControlStepper + */ +cc.ControlStepper = { + +/** + * @method getMinusSprite + * @return {cc.Sprite} + */ +getMinusSprite : function ( +) +{ + return cc.Sprite; +}, + +/** + * @method setValue + * @param {double} arg0 + */ +setValue : function ( +double +) +{ +}, + +/** + * @method setStepValue + * @param {double} arg0 + */ +setStepValue : function ( +double +) +{ +}, + +/** + * @method initWithMinusSpriteAndPlusSprite + * @param {cc.Sprite} arg0 + * @param {cc.Sprite} arg1 + * @return {bool} + */ +initWithMinusSpriteAndPlusSprite : function ( +sprite, +sprite +) +{ + return false; +}, + +/** + * @method setValueWithSendingEvent + * @param {double} arg0 + * @param {bool} arg1 + */ +setValueWithSendingEvent : function ( +double, +bool +) +{ +}, + +/** + * @method setMaximumValue + * @param {double} arg0 + */ +setMaximumValue : function ( +double +) +{ +}, + +/** + * @method getMinusLabel + * @return {cc.Label} + */ +getMinusLabel : function ( +) +{ + return cc.Label; +}, + +/** + * @method getPlusLabel + * @return {cc.Label} + */ +getPlusLabel : function ( +) +{ + return cc.Label; +}, + +/** + * @method setWraps + * @param {bool} arg0 + */ +setWraps : function ( +bool +) +{ +}, + +/** + * @method setMinusLabel + * @param {cc.Label} arg0 + */ +setMinusLabel : function ( +label +) +{ +}, + +/** + * @method startAutorepeat + */ +startAutorepeat : function ( +) +{ +}, + +/** + * @method updateLayoutUsingTouchLocation + * @param {vec2_object} arg0 + */ +updateLayoutUsingTouchLocation : function ( +vec2 +) +{ +}, + +/** + * @method isContinuous + * @return {bool} + */ +isContinuous : function ( +) +{ + return false; +}, + +/** + * @method stopAutorepeat + */ +stopAutorepeat : function ( +) +{ +}, + +/** + * @method setMinimumValue + * @param {double} arg0 + */ +setMinimumValue : function ( +double +) +{ +}, + +/** + * @method setPlusLabel + * @param {cc.Label} arg0 + */ +setPlusLabel : function ( +label +) +{ +}, + +/** + * @method getValue + * @return {double} + */ +getValue : function ( +) +{ + return 0; +}, + +/** + * @method getPlusSprite + * @return {cc.Sprite} + */ +getPlusSprite : function ( +) +{ + return cc.Sprite; +}, + +/** + * @method setPlusSprite + * @param {cc.Sprite} arg0 + */ +setPlusSprite : function ( +sprite +) +{ +}, + +/** + * @method setMinusSprite + * @param {cc.Sprite} arg0 + */ +setMinusSprite : function ( +sprite +) +{ +}, + +/** + * @method create + * @param {cc.Sprite} arg0 + * @param {cc.Sprite} arg1 + * @return {cc.ControlStepper} + */ +create : function ( +sprite, +sprite +) +{ + return cc.ControlStepper; +}, + +/** + * @method ControlStepper + * @constructor + */ +ControlStepper : function ( +) +{ +}, + +}; + +/** + * @class ControlSwitch + */ +cc.ControlSwitch = { + +/** + * @method setOn +* @param {bool|bool} bool +* @param {bool} bool +*/ +setOn : function( +bool, +bool +) +{ +}, + +/** + * @method locationFromTouch + * @param {cc.Touch} arg0 + * @return {vec2_object} + */ +locationFromTouch : function ( +touch +) +{ + return cc.Vec2; +}, + +/** + * @method isOn + * @return {bool} + */ +isOn : function ( +) +{ + return false; +}, + +/** + * @method initWithMaskSprite +* @param {cc.Sprite|cc.Sprite} sprite +* @param {cc.Sprite|cc.Sprite} sprite +* @param {cc.Sprite|cc.Sprite} sprite +* @param {cc.Sprite|cc.Sprite} sprite +* @param {cc.Label} label +* @param {cc.Label} label +* @return {bool|bool} +*/ +initWithMaskSprite : function( +sprite, +sprite, +sprite, +sprite, +label, +label +) +{ + return false; +}, + +/** + * @method hasMoved + * @return {bool} + */ +hasMoved : function ( +) +{ + return false; +}, + +/** + * @method create +* @param {cc.Sprite|cc.Sprite} sprite +* @param {cc.Sprite|cc.Sprite} sprite +* @param {cc.Sprite|cc.Sprite} sprite +* @param {cc.Sprite|cc.Sprite} sprite +* @param {cc.Label} label +* @param {cc.Label} label +* @return {cc.ControlSwitch|cc.ControlSwitch} +*/ +create : function( +sprite, +sprite, +sprite, +sprite, +label, +label +) +{ + return cc.ControlSwitch; +}, + +/** + * @method ControlSwitch + * @constructor + */ +ControlSwitch : function ( +) +{ +}, + +}; + +/** + * @class ScrollView + */ +cc.ScrollView = { + +/** + * @method isClippingToBounds + * @return {bool} + */ +isClippingToBounds : function ( +) +{ + return false; +}, + +/** + * @method setContainer + * @param {cc.Node} arg0 + */ +setContainer : function ( +node +) +{ +}, + +/** + * @method setContentOffsetInDuration + * @param {vec2_object} arg0 + * @param {float} arg1 + */ +setContentOffsetInDuration : function ( +vec2, +float +) +{ +}, + +/** + * @method setZoomScaleInDuration + * @param {float} arg0 + * @param {float} arg1 + */ +setZoomScaleInDuration : function ( +float, +float +) +{ +}, + +/** + * @method updateTweenAction + * @param {float} arg0 + * @param {String} arg1 + */ +updateTweenAction : function ( +float, +str +) +{ +}, + +/** + * @method setMaxScale + * @param {float} arg0 + */ +setMaxScale : function ( +float +) +{ +}, + +/** + * @method hasVisibleParents + * @return {bool} + */ +hasVisibleParents : function ( +) +{ + return false; +}, + +/** + * @method getDirection + * @return {cc.ScrollView::Direction} + */ +getDirection : function ( +) +{ + return 0; +}, + +/** + * @method getContainer + * @return {cc.Node} + */ +getContainer : function ( +) +{ + return cc.Node; +}, + +/** + * @method setMinScale + * @param {float} arg0 + */ +setMinScale : function ( +float +) +{ +}, + +/** + * @method getZoomScale + * @return {float} + */ +getZoomScale : function ( +) +{ + return 0; +}, + +/** + * @method updateInset + */ +updateInset : function ( +) +{ +}, + +/** + * @method initWithViewSize + * @param {size_object} arg0 + * @param {cc.Node} arg1 + * @return {bool} + */ +initWithViewSize : function ( +size, +node +) +{ + return false; +}, + +/** + * @method pause + * @param {cc.Ref} arg0 + */ +pause : function ( +ref +) +{ +}, + +/** + * @method setDirection + * @param {cc.ScrollView::Direction} arg0 + */ +setDirection : function ( +direction +) +{ +}, + +/** + * @method setBounceable + * @param {bool} arg0 + */ +setBounceable : function ( +bool +) +{ +}, + +/** + * @method setContentOffset + * @param {vec2_object} arg0 + * @param {bool} arg1 + */ +setContentOffset : function ( +vec2, +bool +) +{ +}, + +/** + * @method isDragging + * @return {bool} + */ +isDragging : function ( +) +{ + return false; +}, + +/** + * @method isTouchEnabled + * @return {bool} + */ +isTouchEnabled : function ( +) +{ + return false; +}, + +/** + * @method isBounceable + * @return {bool} + */ +isBounceable : function ( +) +{ + return false; +}, + +/** + * @method setTouchEnabled + * @param {bool} arg0 + */ +setTouchEnabled : function ( +bool +) +{ +}, + +/** + * @method getContentOffset + * @return {vec2_object} + */ +getContentOffset : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method resume + * @param {cc.Ref} arg0 + */ +resume : function ( +ref +) +{ +}, + +/** + * @method setClippingToBounds + * @param {bool} arg0 + */ +setClippingToBounds : function ( +bool +) +{ +}, + +/** + * @method setViewSize + * @param {size_object} arg0 + */ +setViewSize : function ( +size +) +{ +}, + +/** + * @method getViewSize + * @return {size_object} + */ +getViewSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method maxContainerOffset + * @return {vec2_object} + */ +maxContainerOffset : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method isTouchMoved + * @return {bool} + */ +isTouchMoved : function ( +) +{ + return false; +}, + +/** + * @method isNodeVisible + * @param {cc.Node} arg0 + * @return {bool} + */ +isNodeVisible : function ( +node +) +{ + return false; +}, + +/** + * @method minContainerOffset + * @return {vec2_object} + */ +minContainerOffset : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method setZoomScale +* @param {float|float} float +* @param {bool} bool +*/ +setZoomScale : function( +float, +bool +) +{ +}, + +/** + * @method create +* @param {size_object} size +* @param {cc.Node} node +* @return {cc.ScrollView|cc.ScrollView} +*/ +create : function( +size, +node +) +{ + return cc.ScrollView; +}, + +/** + * @method ScrollView + * @constructor + */ +ScrollView : function ( +) +{ +}, + +}; + +/** + * @class TableViewCell + */ +cc.TableViewCell = { + +/** + * @method reset + */ +reset : function ( +) +{ +}, + +/** + * @method getIdx + * @return {long} + */ +getIdx : function ( +) +{ + return 0; +}, + +/** + * @method setIdx + * @param {long} arg0 + */ +setIdx : function ( +long +) +{ +}, + +/** + * @method create + * @return {cc.TableViewCell} + */ +create : function ( +) +{ + return cc.TableViewCell; +}, + +/** + * @method TableViewCell + * @constructor + */ +TableViewCell : function ( +) +{ +}, + +}; + +/** + * @class TableView + */ +cc.TableView = { + +/** + * @method updateCellAtIndex + * @param {long} arg0 + */ +updateCellAtIndex : function ( +long +) +{ +}, + +/** + * @method setVerticalFillOrder + * @param {cc.TableView::VerticalFillOrder} arg0 + */ +setVerticalFillOrder : function ( +verticalfillorder +) +{ +}, + +/** + * @method scrollViewDidZoom + * @param {cc.ScrollView} arg0 + */ +scrollViewDidZoom : function ( +scrollview +) +{ +}, + +/** + * @method _updateContentSize + */ +_updateContentSize : function ( +) +{ +}, + +/** + * @method getVerticalFillOrder + * @return {cc.TableView::VerticalFillOrder} + */ +getVerticalFillOrder : function ( +) +{ + return 0; +}, + +/** + * @method removeCellAtIndex + * @param {long} arg0 + */ +removeCellAtIndex : function ( +long +) +{ +}, + +/** + * @method initWithViewSize + * @param {size_object} arg0 + * @param {cc.Node} arg1 + * @return {bool} + */ +initWithViewSize : function ( +size, +node +) +{ + return false; +}, + +/** + * @method scrollViewDidScroll + * @param {cc.ScrollView} arg0 + */ +scrollViewDidScroll : function ( +scrollview +) +{ +}, + +/** + * @method reloadData + */ +reloadData : function ( +) +{ +}, + +/** + * @method insertCellAtIndex + * @param {long} arg0 + */ +insertCellAtIndex : function ( +long +) +{ +}, + +/** + * @method cellAtIndex + * @param {long} arg0 + * @return {cc.TableViewCell} + */ +cellAtIndex : function ( +long +) +{ + return cc.TableViewCell; +}, + +/** + * @method dequeueCell + * @return {cc.TableViewCell} + */ +dequeueCell : function ( +) +{ + return cc.TableViewCell; +}, + +/** + * @method TableView + * @constructor + */ +TableView : function ( +) +{ +}, + +}; + +/** + * @class EventAssetsManagerEx + */ +cc.EventAssetsManager = { + +/** + * @method getAssetsManagerEx + * @return {cc.AssetsManagerEx} + */ +getAssetsManagerEx : function ( +) +{ + return cc.AssetsManagerEx; +}, + +/** + * @method getAssetId + * @return {String} + */ +getAssetId : function ( +) +{ + return ; +}, + +/** + * @method getCURLECode + * @return {int} + */ +getCURLECode : function ( +) +{ + return 0; +}, + +/** + * @method getMessage + * @return {String} + */ +getMessage : function ( +) +{ + return ; +}, + +/** + * @method getCURLMCode + * @return {int} + */ +getCURLMCode : function ( +) +{ + return 0; +}, + +/** + * @method getPercentByFile + * @return {float} + */ +getPercentByFile : function ( +) +{ + return 0; +}, + +/** + * @method getEventCode + * @return {cc.EventAssetsManagerEx::EventCode} + */ +getEventCode : function ( +) +{ + return 0; +}, + +/** + * @method getPercent + * @return {float} + */ +getPercent : function ( +) +{ + return 0; +}, + +/** + * @method EventAssetsManagerEx + * @constructor + * @param {String} arg0 + * @param {cc.AssetsManagerEx} arg1 + * @param {cc.EventAssetsManagerEx::EventCode} arg2 + * @param {float} arg3 + * @param {float} arg4 + * @param {String} arg5 + * @param {String} arg6 + * @param {int} arg7 + * @param {int} arg8 + */ +EventAssetsManagerEx : function ( +str, +assetsmanagerex, +eventcode, +float, +float, +str, +str, +int, +int +) +{ +}, + +}; + +/** + * @class Manifest + */ +cc.Manifest = { + +/** + * @method getManifestFileUrl + * @return {String} + */ +getManifestFileUrl : function ( +) +{ + return ; +}, + +/** + * @method isVersionLoaded + * @return {bool} + */ +isVersionLoaded : function ( +) +{ + return false; +}, + +/** + * @method isLoaded + * @return {bool} + */ +isLoaded : function ( +) +{ + return false; +}, + +/** + * @method getPackageUrl + * @return {String} + */ +getPackageUrl : function ( +) +{ + return ; +}, + +/** + * @method getVersion + * @return {String} + */ +getVersion : function ( +) +{ + return ; +}, + +/** + * @method getVersionFileUrl + * @return {String} + */ +getVersionFileUrl : function ( +) +{ + return ; +}, + +/** + * @method getSearchPaths + * @return {Array} + */ +getSearchPaths : function ( +) +{ + return new Array(); +}, + +}; + +/** + * @class AssetsManagerEx + */ +cc.AssetsManager = { + +/** + * @method getState + * @return {cc.AssetsManagerEx::State} + */ +getState : function ( +) +{ + return 0; +}, + +/** + * @method checkUpdate + */ +checkUpdate : function ( +) +{ +}, + +/** + * @method getStoragePath + * @return {String} + */ +getStoragePath : function ( +) +{ + return ; +}, + +/** + * @method update + */ +update : function ( +) +{ +}, + +/** + * @method getLocalManifest + * @return {cc.Manifest} + */ +getLocalManifest : function ( +) +{ + return cc.Manifest; +}, + +/** + * @method getRemoteManifest + * @return {cc.Manifest} + */ +getRemoteManifest : function ( +) +{ + return cc.Manifest; +}, + +/** + * @method downloadFailedAssets + */ +downloadFailedAssets : function ( +) +{ +}, + +/** + * @method create + * @param {String} arg0 + * @param {String} arg1 + * @return {cc.AssetsManagerEx} + */ +create : function ( +str, +str +) +{ + return cc.AssetsManagerEx; +}, + +/** + * @method AssetsManagerEx + * @constructor + * @param {String} arg0 + * @param {String} arg1 + */ +AssetsManagerEx : function ( +str, +str +) +{ +}, + +}; + +/** + * @class EventListenerAssetsManagerEx + */ +cc.EventListenerAssetsManager = { + +/** + * @method init + * @param {cc.AssetsManagerEx} arg0 + * @param {function} arg1 + * @return {bool} + */ +init : function ( +assetsmanagerex, +func +) +{ + return false; +}, + +/** + * @method create + * @param {cc.AssetsManagerEx} arg0 + * @param {function} arg1 + * @return {cc.EventListenerAssetsManagerEx} + */ +create : function ( +assetsmanagerex, +func +) +{ + return cc.EventListenerAssetsManagerEx; +}, + +/** + * @method EventListenerAssetsManagerEx + * @constructor + */ +EventListenerAssetsManagerEx : function ( +) +{ +}, + +}; diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_spine_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_spine_auto_api.js new file mode 100644 index 0000000000..6bb5bad6f6 --- /dev/null +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_spine_auto_api.js @@ -0,0 +1,472 @@ +/** + * @module cocos2dx_spine + */ +var sp = sp || {}; + +/** + * @class SkeletonRenderer + */ +sp.Skeleton = { + +/** + * @method setTimeScale + * @param {float} arg0 + */ +setTimeScale : function ( +float +) +{ +}, + +/** + * @method getDebugSlotsEnabled + * @return {bool} + */ +getDebugSlotsEnabled : function ( +) +{ + return false; +}, + +/** + * @method setAttachment +* @param {String|String} str +* @param {char|String} char +* @return {bool|bool} +*/ +setAttachment : function( +str, +str +) +{ + return false; +}, + +/** + * @method setBonesToSetupPose + */ +setBonesToSetupPose : function ( +) +{ +}, + +/** + * @method isOpacityModifyRGB + * @return {bool} + */ +isOpacityModifyRGB : function ( +) +{ + return false; +}, + +/** + * @method initWithData + * @param {spSkeletonData} arg0 + * @param {bool} arg1 + */ +initWithData : function ( +spskeletondata, +bool +) +{ +}, + +/** + * @method setDebugSlotsEnabled + * @param {bool} arg0 + */ +setDebugSlotsEnabled : function ( +bool +) +{ +}, + +/** + * @method setSlotsToSetupPose + */ +setSlotsToSetupPose : function ( +) +{ +}, + +/** + * @method setOpacityModifyRGB + * @param {bool} arg0 + */ +setOpacityModifyRGB : function ( +bool +) +{ +}, + +/** + * @method setToSetupPose + */ +setToSetupPose : function ( +) +{ +}, + +/** + * @method getBlendFunc + * @return {cc.BlendFunc} + */ +getBlendFunc : function ( +) +{ + return cc.BlendFunc; +}, + +/** + * @method drawSkeleton + * @param {mat4_object} arg0 + * @param {unsigned int} arg1 + */ +drawSkeleton : function ( +mat4, +int +) +{ +}, + +/** + * @method updateWorldTransform + */ +updateWorldTransform : function ( +) +{ +}, + +/** + * @method initialize + */ +initialize : function ( +) +{ +}, + +/** + * @method setDebugBonesEnabled + * @param {bool} arg0 + */ +setDebugBonesEnabled : function ( +bool +) +{ +}, + +/** + * @method getDebugBonesEnabled + * @return {bool} + */ +getDebugBonesEnabled : function ( +) +{ + return false; +}, + +/** + * @method getTimeScale + * @return {float} + */ +getTimeScale : function ( +) +{ + return 0; +}, + +/** + * @method initWithFile +* @param {String|String} str +* @param {String|spAtlas} str +* @param {float|float} float +*/ +initWithFile : function( +str, +spatlas, +float +) +{ +}, + +/** + * @method setBlendFunc + * @param {cc.BlendFunc} arg0 + */ +setBlendFunc : function ( +blendfunc +) +{ +}, + +/** + * @method setSkin +* @param {char|String} char +* @return {bool|bool} +*/ +setSkin : function( +str +) +{ + return false; +}, + +/** + * @method getSkeleton + * @return {spSkeleton} + */ +getSkeleton : function ( +) +{ + return spSkeleton; +}, + +/** + * @method createWithFile +* @param {String|String} str +* @param {String|spAtlas} str +* @param {float|float} float +* @return {sp.SkeletonRenderer|sp.SkeletonRenderer} +*/ +createWithFile : function( +str, +spatlas, +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 +) +{ +}, + +}; + +/** + * @class SkeletonAnimation + */ +sp.SkeletonAnimation = { + +/** + * @method setStartListener + * @param {function} arg0 + */ +setStartListener : function ( +func +) +{ +}, + +/** + * @method setTrackEventListener + * @param {spTrackEntry} arg0 + * @param {function} arg1 + */ +setTrackEventListener : function ( +sptrackentry, +func +) +{ +}, + +/** + * @method getState + * @return {spAnimationState} + */ +getState : function ( +) +{ + return spAnimationState; +}, + +/** + * @method setTrackCompleteListener + * @param {spTrackEntry} arg0 + * @param {function} arg1 + */ +setTrackCompleteListener : function ( +sptrackentry, +func +) +{ +}, + +/** + * @method onTrackEntryEvent + * @param {int} arg0 + * @param {spEventType} arg1 + * @param {spEvent} arg2 + * @param {int} arg3 + */ +onTrackEntryEvent : function ( +int, +speventtype, +spevent, +int +) +{ +}, + +/** + * @method setTrackStartListener + * @param {spTrackEntry} arg0 + * @param {function} arg1 + */ +setTrackStartListener : function ( +sptrackentry, +func +) +{ +}, + +/** + * @method update + * @param {float} arg0 + */ +update : function ( +float +) +{ +}, + +/** + * @method setCompleteListener + * @param {function} arg0 + */ +setCompleteListener : function ( +func +) +{ +}, + +/** + * @method setTrackEndListener + * @param {spTrackEntry} arg0 + * @param {function} arg1 + */ +setTrackEndListener : function ( +sptrackentry, +func +) +{ +}, + +/** + * @method setEventListener + * @param {function} arg0 + */ +setEventListener : function ( +func +) +{ +}, + +/** + * @method setMix + * @param {String} arg0 + * @param {String} arg1 + * @param {float} arg2 + */ +setMix : function ( +str, +str, +float +) +{ +}, + +/** + * @method setEndListener + * @param {function} arg0 + */ +setEndListener : function ( +func +) +{ +}, + +/** + * @method initialize + */ +initialize : function ( +) +{ +}, + +/** + * @method clearTracks + */ +clearTracks : function ( +) +{ +}, + +/** + * @method clearTrack + */ +clearTrack : function ( +) +{ +}, + +/** + * @method onAnimationStateEvent + * @param {int} arg0 + * @param {spEventType} arg1 + * @param {spEvent} arg2 + * @param {int} arg3 + */ +onAnimationStateEvent : function ( +int, +speventtype, +spevent, +int +) +{ +}, + +/** + * @method createWithFile +* @param {String|String} str +* @param {String|spAtlas} str +* @param {float|float} float +* @return {sp.SkeletonAnimation|sp.SkeletonAnimation} +*/ +createWithFile : function( +str, +spatlas, +float +) +{ + return sp.SkeletonAnimation; +}, + +/** + * @method SkeletonAnimation + * @constructor +* @param {spSkeletonData|String|String} spskeletondata +* @param {spAtlas|String} spatlas +* @param {float|float} float +*/ +SkeletonAnimation : function( +str, +str, +float +) +{ +}, + +}; diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_studio_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_studio_auto_api.js new file mode 100644 index 0000000000..cfad8eb3da --- /dev/null +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_studio_auto_api.js @@ -0,0 +1,4489 @@ +/** + * @module cocos2dx_studio + */ +var ccs = ccs || {}; + +/** + * @class ActionObject + */ +ccs.ActionObject = { + +/** + * @method setCurrentTime + * @param {float} arg0 + */ +setCurrentTime : function ( +float +) +{ +}, + +/** + * @method pause + */ +pause : function ( +) +{ +}, + +/** + * @method setName + * @param {char} arg0 + */ +setName : function ( +char +) +{ +}, + +/** + * @method setUnitTime + * @param {float} arg0 + */ +setUnitTime : function ( +float +) +{ +}, + +/** + * @method getTotalTime + * @return {float} + */ +getTotalTime : function ( +) +{ + return 0; +}, + +/** + * @method getName + * @return {char} + */ +getName : function ( +) +{ + return 0; +}, + +/** + * @method stop + */ +stop : function ( +) +{ +}, + +/** + * @method play +* @param {cc.CallFunc} callfunc +*/ +play : function( +callfunc +) +{ +}, + +/** + * @method getCurrentTime + * @return {float} + */ +getCurrentTime : function ( +) +{ + return 0; +}, + +/** + * @method removeActionNode + * @param {ccs.ActionNode} arg0 + */ +removeActionNode : function ( +actionnode +) +{ +}, + +/** + * @method getLoop + * @return {bool} + */ +getLoop : function ( +) +{ + return false; +}, + +/** + * @method initWithBinary + * @param {ccs.CocoLoader} arg0 + * @param {ccs.stExpCocoNode} arg1 + * @param {cc.Ref} arg2 + */ +initWithBinary : function ( +cocoloader, +stexpcoconode, +ref +) +{ +}, + +/** + * @method addActionNode + * @param {ccs.ActionNode} arg0 + */ +addActionNode : function ( +actionnode +) +{ +}, + +/** + * @method getUnitTime + * @return {float} + */ +getUnitTime : function ( +) +{ + return 0; +}, + +/** + * @method isPlaying + * @return {bool} + */ +isPlaying : function ( +) +{ + return false; +}, + +/** + * @method updateToFrameByTime + * @param {float} arg0 + */ +updateToFrameByTime : function ( +float +) +{ +}, + +/** + * @method setLoop + * @param {bool} arg0 + */ +setLoop : function ( +bool +) +{ +}, + +/** + * @method simulationActionUpdate + * @param {float} arg0 + */ +simulationActionUpdate : function ( +float +) +{ +}, + +/** + * @method ActionObject + * @constructor + */ +ActionObject : function ( +) +{ +}, + +}; + +/** + * @class ActionManagerEx + */ +ccs.ActionManager = { + +/** + * @method stopActionByName + * @param {char} arg0 + * @param {char} arg1 + * @return {ccs.ActionObject} + */ +stopActionByName : function ( +char, +char +) +{ + return ccs.ActionObject; +}, + +/** + * @method getActionByName + * @param {char} arg0 + * @param {char} arg1 + * @return {ccs.ActionObject} + */ +getActionByName : function ( +char, +char +) +{ + return ccs.ActionObject; +}, + +/** + * @method initWithBinary + * @param {char} arg0 + * @param {cc.Ref} arg1 + * @param {ccs.CocoLoader} arg2 + * @param {ccs.stExpCocoNode} arg3 + */ +initWithBinary : function ( +char, +ref, +cocoloader, +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 + */ +releaseActions : function ( +) +{ +}, + +/** + * @method destroyInstance + */ +destroyInstance : function ( +) +{ +}, + +/** + * @method getInstance + * @return {ccs.ActionManagerEx} + */ +getInstance : function ( +) +{ + return ccs.ActionManagerEx; +}, + +}; + +/** + * @class BaseData + */ +ccs.BaseData = { + +/** + * @method getColor + * @return {color4b_object} + */ +getColor : function ( +) +{ + return cc.Color4B; +}, + +/** + * @method setColor + * @param {color4b_object} arg0 + */ +setColor : function ( +color4b +) +{ +}, + +/** + * @method create + * @return {ccs.BaseData} + */ +create : function ( +) +{ + return ccs.BaseData; +}, + +/** + * @method BaseData + * @constructor + */ +BaseData : function ( +) +{ +}, + +}; + +/** + * @class MovementData + */ +ccs.MovementData = { + +/** + * @method getMovementBoneData + * @param {String} arg0 + * @return {ccs.MovementBoneData} + */ +getMovementBoneData : function ( +str +) +{ + return ccs.MovementBoneData; +}, + +/** + * @method addMovementBoneData + * @param {ccs.MovementBoneData} arg0 + */ +addMovementBoneData : function ( +movementbonedata +) +{ +}, + +/** + * @method create + * @return {ccs.MovementData} + */ +create : function ( +) +{ + return ccs.MovementData; +}, + +/** + * @method MovementData + * @constructor + */ +MovementData : function ( +) +{ +}, + +}; + +/** + * @class AnimationData + */ +ccs.AnimationData = { + +/** + * @method getMovement + * @param {String} arg0 + * @return {ccs.MovementData} + */ +getMovement : function ( +str +) +{ + return ccs.MovementData; +}, + +/** + * @method getMovementCount + * @return {long} + */ +getMovementCount : function ( +) +{ + return 0; +}, + +/** + * @method addMovement + * @param {ccs.MovementData} arg0 + */ +addMovement : function ( +movementdata +) +{ +}, + +/** + * @method create + * @return {ccs.AnimationData} + */ +create : function ( +) +{ + return ccs.AnimationData; +}, + +/** + * @method AnimationData + * @constructor + */ +AnimationData : function ( +) +{ +}, + +}; + +/** + * @class ContourData + */ +ccs.ContourData = { + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method addVertex + * @param {vec2_object} arg0 + */ +addVertex : function ( +vec2 +) +{ +}, + +/** + * @method create + * @return {ccs.ContourData} + */ +create : function ( +) +{ + return ccs.ContourData; +}, + +/** + * @method ContourData + * @constructor + */ +ContourData : function ( +) +{ +}, + +}; + +/** + * @class TextureData + */ +ccs.TextureData = { + +/** + * @method getContourData + * @param {int} arg0 + * @return {ccs.ContourData} + */ +getContourData : function ( +int +) +{ + return ccs.ContourData; +}, + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method addContourData + * @param {ccs.ContourData} arg0 + */ +addContourData : function ( +contourdata +) +{ +}, + +/** + * @method create + * @return {ccs.TextureData} + */ +create : function ( +) +{ + return ccs.TextureData; +}, + +/** + * @method TextureData + * @constructor + */ +TextureData : function ( +) +{ +}, + +}; + +/** + * @class ProcessBase + */ +ccs.ProcessBase = { + +/** + * @method play + * @param {int} arg0 + * @param {int} arg1 + * @param {int} arg2 + * @param {int} arg3 + */ +play : function ( +int, +int, +int, +int +) +{ +}, + +/** + * @method pause + */ +pause : function ( +) +{ +}, + +/** + * @method getRawDuration + * @return {int} + */ +getRawDuration : function ( +) +{ + return 0; +}, + +/** + * @method resume + */ +resume : function ( +) +{ +}, + +/** + * @method setIsComplete + * @param {bool} arg0 + */ +setIsComplete : function ( +bool +) +{ +}, + +/** + * @method stop + */ +stop : function ( +) +{ +}, + +/** + * @method update + * @param {float} arg0 + */ +update : function ( +float +) +{ +}, + +/** + * @method getCurrentFrameIndex + * @return {int} + */ +getCurrentFrameIndex : function ( +) +{ + return 0; +}, + +/** + * @method isComplete + * @return {bool} + */ +isComplete : function ( +) +{ + return false; +}, + +/** + * @method getCurrentPercent + * @return {float} + */ +getCurrentPercent : function ( +) +{ + return 0; +}, + +/** + * @method setIsPause + * @param {bool} arg0 + */ +setIsPause : function ( +bool +) +{ +}, + +/** + * @method getProcessScale + * @return {float} + */ +getProcessScale : function ( +) +{ + return 0; +}, + +/** + * @method isPause + * @return {bool} + */ +isPause : function ( +) +{ + return false; +}, + +/** + * @method isPlaying + * @return {bool} + */ +isPlaying : function ( +) +{ + return false; +}, + +/** + * @method setProcessScale + * @param {float} arg0 + */ +setProcessScale : function ( +float +) +{ +}, + +/** + * @method setIsPlaying + * @param {bool} arg0 + */ +setIsPlaying : function ( +bool +) +{ +}, + +/** + * @method ProcessBase + * @constructor + */ +ProcessBase : function ( +) +{ +}, + +}; + +/** + * @class Tween + */ +ccs.Tween = { + +/** + * @method getAnimation + * @return {ccs.ArmatureAnimation} + */ +getAnimation : function ( +) +{ + return ccs.ArmatureAnimation; +}, + +/** + * @method gotoAndPause + * @param {int} arg0 + */ +gotoAndPause : function ( +int +) +{ +}, + +/** + * @method play + * @param {ccs.MovementBoneData} arg0 + * @param {int} arg1 + * @param {int} arg2 + * @param {int} arg3 + * @param {int} arg4 + */ +play : function ( +movementbonedata, +int, +int, +int, +int +) +{ +}, + +/** + * @method gotoAndPlay + * @param {int} arg0 + */ +gotoAndPlay : function ( +int +) +{ +}, + +/** + * @method init + * @param {ccs.Bone} arg0 + * @return {bool} + */ +init : function ( +bone +) +{ + return false; +}, + +/** + * @method setAnimation + * @param {ccs.ArmatureAnimation} arg0 + */ +setAnimation : function ( +armatureanimation +) +{ +}, + +/** + * @method create + * @param {ccs.Bone} arg0 + * @return {ccs.Tween} + */ +create : function ( +bone +) +{ + return ccs.Tween; +}, + +/** + * @method Tween + * @constructor + */ +Tween : function ( +) +{ +}, + +}; + +/** + * @class ColliderFilter + */ +ccs.ColliderFilter = { + +}; + +/** + * @class ColliderBody + */ +ccs.ColliderBody = { + +}; + +/** + * @class ColliderDetector + */ +ccs.ColliderDetector = { + +/** + * @method getBone + * @return {ccs.Bone} + */ +getBone : function ( +) +{ + return ccs.Bone; +}, + +/** + * @method getActive + * @return {bool} + */ +getActive : function ( +) +{ + return false; +}, + +/** + * @method getColliderBodyList + * @return {Array} + */ +getColliderBodyList : function ( +) +{ + return new Array(); +}, + +/** + * @method updateTransform + * @param {mat4_object} arg0 + */ +updateTransform : function ( +mat4 +) +{ +}, + +/** + * @method removeAll + */ +removeAll : function ( +) +{ +}, + +/** + * @method init +* @param {ccs.Bone} bone +* @return {bool|bool} +*/ +init : function( +bone +) +{ + return false; +}, + +/** + * @method setActive + * @param {bool} arg0 + */ +setActive : function ( +bool +) +{ +}, + +/** + * @method setBone + * @param {ccs.Bone} arg0 + */ +setBone : function ( +bone +) +{ +}, + +/** + * @method create +* @param {ccs.Bone} bone +* @return {ccs.ColliderDetector|ccs.ColliderDetector} +*/ +create : function( +bone +) +{ + return ccs.ColliderDetector; +}, + +}; + +/** + * @class DecorativeDisplay + */ +ccs.DecorativeDisplay = { + +/** + * @method getColliderDetector + * @return {ccs.ColliderDetector} + */ +getColliderDetector : function ( +) +{ + return ccs.ColliderDetector; +}, + +/** + * @method getDisplay + * @return {cc.Node} + */ +getDisplay : function ( +) +{ + return cc.Node; +}, + +/** + * @method setDisplay + * @param {cc.Node} arg0 + */ +setDisplay : function ( +node +) +{ +}, + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method setDisplayData + * @param {ccs.DisplayData} arg0 + */ +setDisplayData : function ( +displaydata +) +{ +}, + +/** + * @method getDisplayData + * @return {ccs.DisplayData} + */ +getDisplayData : function ( +) +{ + return ccs.DisplayData; +}, + +/** + * @method setColliderDetector + * @param {ccs.ColliderDetector} arg0 + */ +setColliderDetector : function ( +colliderdetector +) +{ +}, + +/** + * @method create + * @return {ccs.DecorativeDisplay} + */ +create : function ( +) +{ + return ccs.DecorativeDisplay; +}, + +}; + +/** + * @class DisplayManager + */ +ccs.DisplayManager = { + +/** + * @method getCurrentDecorativeDisplay + * @return {ccs.DecorativeDisplay} + */ +getCurrentDecorativeDisplay : function ( +) +{ + return ccs.DecorativeDisplay; +}, + +/** + * @method getDisplayRenderNode + * @return {cc.Node} + */ +getDisplayRenderNode : function ( +) +{ + return cc.Node; +}, + +/** + * @method getAnchorPointInPoints + * @return {vec2_object} + */ +getAnchorPointInPoints : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method setCurrentDecorativeDisplay + * @param {ccs.DecorativeDisplay} arg0 + */ +setCurrentDecorativeDisplay : function ( +decorativedisplay +) +{ +}, + +/** + * @method getDisplayRenderNodeType + * @return {ccs.DisplayType} + */ +getDisplayRenderNodeType : function ( +) +{ + return 0; +}, + +/** + * @method removeDisplay + * @param {int} arg0 + */ +removeDisplay : function ( +int +) +{ +}, + +/** + * @method setForceChangeDisplay + * @param {bool} arg0 + */ +setForceChangeDisplay : function ( +bool +) +{ +}, + +/** + * @method init + * @param {ccs.Bone} arg0 + * @return {bool} + */ +init : function ( +bone +) +{ + return false; +}, + +/** + * @method getContentSize + * @return {size_object} + */ +getContentSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method getBoundingBox + * @return {rect_object} + */ +getBoundingBox : function ( +) +{ + return cc.Rect; +}, + +/** + * @method addDisplay +* @param {cc.Node|ccs.DisplayData} node +* @param {int|int} int +*/ +addDisplay : function( +displaydata, +int +) +{ +}, + +/** + * @method containPoint +* @param {float|vec2_object} float +* @param {float} float +* @return {bool|bool} +*/ +containPoint : function( +float, +float +) +{ + return false; +}, + +/** + * @method initDisplayList + * @param {ccs.BoneData} arg0 + */ +initDisplayList : function ( +bonedata +) +{ +}, + +/** + * @method changeDisplayWithIndex + * @param {int} arg0 + * @param {bool} arg1 + */ +changeDisplayWithIndex : function ( +int, +bool +) +{ +}, + +/** + * @method changeDisplayWithName + * @param {String} arg0 + * @param {bool} arg1 + */ +changeDisplayWithName : function ( +str, +bool +) +{ +}, + +/** + * @method isForceChangeDisplay + * @return {bool} + */ +isForceChangeDisplay : function ( +) +{ + return false; +}, + +/** + * @method getDecorativeDisplayByIndex + * @param {int} arg0 + * @return {ccs.DecorativeDisplay} + */ +getDecorativeDisplayByIndex : function ( +int +) +{ + return ccs.DecorativeDisplay; +}, + +/** + * @method getCurrentDisplayIndex + * @return {int} + */ +getCurrentDisplayIndex : function ( +) +{ + return 0; +}, + +/** + * @method getAnchorPoint + * @return {vec2_object} + */ +getAnchorPoint : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getDecorativeDisplayList + * @return {Array} + */ +getDecorativeDisplayList : function ( +) +{ + return new Array(); +}, + +/** + * @method isVisible + * @return {bool} + */ +isVisible : function ( +) +{ + return false; +}, + +/** + * @method setVisible + * @param {bool} arg0 + */ +setVisible : function ( +bool +) +{ +}, + +/** + * @method create + * @param {ccs.Bone} arg0 + * @return {ccs.DisplayManager} + */ +create : function ( +bone +) +{ + return ccs.DisplayManager; +}, + +/** + * @method DisplayManager + * @constructor + */ +DisplayManager : function ( +) +{ +}, + +}; + +/** + * @class Bone + */ +ccs.Bone = { + +/** + * @method isTransformDirty + * @return {bool} + */ +isTransformDirty : function ( +) +{ + return false; +}, + +/** + * @method setBlendFunc + * @param {cc.BlendFunc} arg0 + */ +setBlendFunc : function ( +blendfunc +) +{ +}, + +/** + * @method isIgnoreMovementBoneData + * @return {bool} + */ +isIgnoreMovementBoneData : function ( +) +{ + return false; +}, + +/** + * @method updateZOrder + */ +updateZOrder : function ( +) +{ +}, + +/** + * @method getDisplayRenderNode + * @return {cc.Node} + */ +getDisplayRenderNode : function ( +) +{ + return cc.Node; +}, + +/** + * @method isBlendDirty + * @return {bool} + */ +isBlendDirty : function ( +) +{ + return false; +}, + +/** + * @method addChildBone + * @param {ccs.Bone} arg0 + */ +addChildBone : function ( +bone +) +{ +}, + +/** + * @method getWorldInfo + * @return {ccs.BaseData} + */ +getWorldInfo : function ( +) +{ + return ccs.BaseData; +}, + +/** + * @method getTween + * @return {ccs.Tween} + */ +getTween : function ( +) +{ + return ccs.Tween; +}, + +/** + * @method getParentBone + * @return {ccs.Bone} + */ +getParentBone : function ( +) +{ + return ccs.Bone; +}, + +/** + * @method updateColor + */ +updateColor : function ( +) +{ +}, + +/** + * @method setTransformDirty + * @param {bool} arg0 + */ +setTransformDirty : function ( +bool +) +{ +}, + +/** + * @method getDisplayRenderNodeType + * @return {ccs.DisplayType} + */ +getDisplayRenderNodeType : function ( +) +{ + return 0; +}, + +/** + * @method removeDisplay + * @param {int} arg0 + */ +removeDisplay : function ( +int +) +{ +}, + +/** + * @method setBoneData + * @param {ccs.BoneData} arg0 + */ +setBoneData : function ( +bonedata +) +{ +}, + +/** + * @method init + * @param {String} arg0 + * @return {bool} + */ +init : function ( +str +) +{ + return false; +}, + +/** + * @method setParentBone + * @param {ccs.Bone} arg0 + */ +setParentBone : function ( +bone +) +{ +}, + +/** + * @method addDisplay +* @param {cc.Node|ccs.DisplayData} node +* @param {int|int} int +*/ +addDisplay : function( +displaydata, +int +) +{ +}, + +/** + * @method setIgnoreMovementBoneData + * @param {bool} arg0 + */ +setIgnoreMovementBoneData : function ( +bool +) +{ +}, + +/** + * @method getBlendFunc + * @return {cc.BlendFunc} + */ +getBlendFunc : function ( +) +{ + return cc.BlendFunc; +}, + +/** + * @method removeFromParent + * @param {bool} arg0 + */ +removeFromParent : function ( +bool +) +{ +}, + +/** + * @method getColliderDetector + * @return {ccs.ColliderDetector} + */ +getColliderDetector : function ( +) +{ + return ccs.ColliderDetector; +}, + +/** + * @method getChildArmature + * @return {ccs.Armature} + */ +getChildArmature : function ( +) +{ + return ccs.Armature; +}, + +/** + * @method changeDisplayWithIndex + * @param {int} arg0 + * @param {bool} arg1 + */ +changeDisplayWithIndex : function ( +int, +bool +) +{ +}, + +/** + * @method changeDisplayWithName + * @param {String} arg0 + * @param {bool} arg1 + */ +changeDisplayWithName : function ( +str, +bool +) +{ +}, + +/** + * @method setArmature + * @param {ccs.Armature} arg0 + */ +setArmature : function ( +armature +) +{ +}, + +/** + * @method setBlendDirty + * @param {bool} arg0 + */ +setBlendDirty : function ( +bool +) +{ +}, + +/** + * @method removeChildBone + * @param {ccs.Bone} arg0 + * @param {bool} arg1 + */ +removeChildBone : function ( +bone, +bool +) +{ +}, + +/** + * @method setChildArmature + * @param {ccs.Armature} arg0 + */ +setChildArmature : function ( +armature +) +{ +}, + +/** + * @method getNodeToArmatureTransform + * @return {mat4_object} + */ +getNodeToArmatureTransform : function ( +) +{ + return cc.Mat4; +}, + +/** + * @method getDisplayManager + * @return {ccs.DisplayManager} + */ +getDisplayManager : function ( +) +{ + return ccs.DisplayManager; +}, + +/** + * @method getArmature + * @return {ccs.Armature} + */ +getArmature : function ( +) +{ + return ccs.Armature; +}, + +/** + * @method create +* @param {String} str +* @return {ccs.Bone|ccs.Bone} +*/ +create : function( +str +) +{ + return ccs.Bone; +}, + +/** + * @method Bone + * @constructor + */ +Bone : function ( +) +{ +}, + +}; + +/** + * @class BatchNode + */ +ccs.BatchNode = { + +/** + * @method create + * @return {ccs.BatchNode} + */ +create : function ( +) +{ + return ccs.BatchNode; +}, + +}; + +/** + * @class ArmatureAnimation + */ +ccs.ArmatureAnimation = { + +/** + * @method getSpeedScale + * @return {float} + */ +getSpeedScale : function ( +) +{ + return 0; +}, + +/** + * @method play + * @param {String} arg0 + * @param {int} arg1 + * @param {int} arg2 + */ +play : function ( +str, +int, +int +) +{ +}, + +/** + * @method gotoAndPause + * @param {int} arg0 + */ +gotoAndPause : function ( +int +) +{ +}, + +/** + * @method playWithIndexes + * @param {Array} arg0 + * @param {int} arg1 + * @param {bool} arg2 + */ +playWithIndexes : function ( +array, +int, +bool +) +{ +}, + +/** + * @method setAnimationData + * @param {ccs.AnimationData} arg0 + */ +setAnimationData : function ( +animationdata +) +{ +}, + +/** + * @method setSpeedScale + * @param {float} arg0 + */ +setSpeedScale : function ( +float +) +{ +}, + +/** + * @method getAnimationData + * @return {ccs.AnimationData} + */ +getAnimationData : function ( +) +{ + return ccs.AnimationData; +}, + +/** + * @method gotoAndPlay + * @param {int} arg0 + */ +gotoAndPlay : function ( +int +) +{ +}, + +/** + * @method init + * @param {ccs.Armature} arg0 + * @return {bool} + */ +init : function ( +armature +) +{ + return false; +}, + +/** + * @method playWithNames + * @param {Array} arg0 + * @param {int} arg1 + * @param {bool} arg2 + */ +playWithNames : function ( +array, +int, +bool +) +{ +}, + +/** + * @method getMovementCount + * @return {long} + */ +getMovementCount : function ( +) +{ + return 0; +}, + +/** + * @method playWithIndex + * @param {int} arg0 + * @param {int} arg1 + * @param {int} arg2 + */ +playWithIndex : function ( +int, +int, +int +) +{ +}, + +/** + * @method getCurrentMovementID + * @return {String} + */ +getCurrentMovementID : function ( +) +{ + return ; +}, + +/** + * @method create + * @param {ccs.Armature} arg0 + * @return {ccs.ArmatureAnimation} + */ +create : function ( +armature +) +{ + return ccs.ArmatureAnimation; +}, + +/** + * @method ArmatureAnimation + * @constructor + */ +ArmatureAnimation : function ( +) +{ +}, + +}; + +/** + * @class ArmatureDataManager + */ +ccs.ArmatureDataManager = { + +/** + * @method getAnimationDatas + * @return {map_object} + */ +getAnimationDatas : function ( +) +{ + return map_object; +}, + +/** + * @method removeAnimationData + * @param {String} arg0 + */ +removeAnimationData : function ( +str +) +{ +}, + +/** + * @method addArmatureData + * @param {String} arg0 + * @param {ccs.ArmatureData} arg1 + * @param {String} arg2 + */ +addArmatureData : function ( +str, +armaturedata, +str +) +{ +}, + +/** + * @method addArmatureFileInfo +* @param {String|String} str +* @param {String} str +* @param {String} str +*/ +addArmatureFileInfo : function( +str, +str, +str +) +{ +}, + +/** + * @method removeArmatureFileInfo + * @param {String} arg0 + */ +removeArmatureFileInfo : function ( +str +) +{ +}, + +/** + * @method getTextureData + * @param {String} arg0 + * @return {ccs.TextureData} + */ +getTextureData : function ( +str +) +{ + return ccs.TextureData; +}, + +/** + * @method getArmatureData + * @param {String} arg0 + * @return {ccs.ArmatureData} + */ +getArmatureData : function ( +str +) +{ + return ccs.ArmatureData; +}, + +/** + * @method getAnimationData + * @param {String} arg0 + * @return {ccs.AnimationData} + */ +getAnimationData : function ( +str +) +{ + return ccs.AnimationData; +}, + +/** + * @method addAnimationData + * @param {String} arg0 + * @param {ccs.AnimationData} arg1 + * @param {String} arg2 + */ +addAnimationData : function ( +str, +animationdata, +str +) +{ +}, + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method removeArmatureData + * @param {String} arg0 + */ +removeArmatureData : function ( +str +) +{ +}, + +/** + * @method getArmatureDatas + * @return {map_object} + */ +getArmatureDatas : function ( +) +{ + return map_object; +}, + +/** + * @method removeTextureData + * @param {String} arg0 + */ +removeTextureData : function ( +str +) +{ +}, + +/** + * @method addTextureData + * @param {String} arg0 + * @param {ccs.TextureData} arg1 + * @param {String} arg2 + */ +addTextureData : function ( +str, +texturedata, +str +) +{ +}, + +/** + * @method isAutoLoadSpriteFile + * @return {bool} + */ +isAutoLoadSpriteFile : function ( +) +{ + return false; +}, + +/** + * @method addSpriteFrameFromFile + * @param {String} arg0 + * @param {String} arg1 + * @param {String} arg2 + */ +addSpriteFrameFromFile : function ( +str, +str, +str +) +{ +}, + +/** + * @method destroyInstance + */ +destroyInstance : function ( +) +{ +}, + +/** + * @method getInstance + * @return {ccs.ArmatureDataManager} + */ +getInstance : function ( +) +{ + return ccs.ArmatureDataManager; +}, + +}; + +/** + * @class Armature + */ +ccs.Armature = { + +/** + * @method getBone + * @param {String} arg0 + * @return {ccs.Bone} + */ +getBone : function ( +str +) +{ + return ccs.Bone; +}, + +/** + * @method changeBoneParent + * @param {ccs.Bone} arg0 + * @param {String} arg1 + */ +changeBoneParent : function ( +bone, +str +) +{ +}, + +/** + * @method setAnimation + * @param {ccs.ArmatureAnimation} arg0 + */ +setAnimation : function ( +armatureanimation +) +{ +}, + +/** + * @method getBoneAtPoint + * @param {float} arg0 + * @param {float} arg1 + * @return {ccs.Bone} + */ +getBoneAtPoint : function ( +float, +float +) +{ + return ccs.Bone; +}, + +/** + * @method getArmatureTransformDirty + * @return {bool} + */ +getArmatureTransformDirty : function ( +) +{ + return false; +}, + +/** + * @method setVersion + * @param {float} arg0 + */ +setVersion : function ( +float +) +{ +}, + +/** + * @method updateOffsetPoint + */ +updateOffsetPoint : function ( +) +{ +}, + +/** + * @method getParentBone + * @return {ccs.Bone} + */ +getParentBone : function ( +) +{ + return ccs.Bone; +}, + +/** + * @method removeBone + * @param {ccs.Bone} arg0 + * @param {bool} arg1 + */ +removeBone : function ( +bone, +bool +) +{ +}, + +/** + * @method getBatchNode + * @return {ccs.BatchNode} + */ +getBatchNode : function ( +) +{ + return ccs.BatchNode; +}, + +/** + * @method init +* @param {String|String} str +* @param {ccs.Bone} bone +* @return {bool|bool} +*/ +init : function( +str, +bone +) +{ + return false; +}, + +/** + * @method setParentBone + * @param {ccs.Bone} arg0 + */ +setParentBone : function ( +bone +) +{ +}, + +/** + * @method setBatchNode + * @param {ccs.BatchNode} arg0 + */ +setBatchNode : function ( +batchnode +) +{ +}, + +/** + * @method getBlendFunc + * @return {cc.BlendFunc} + */ +getBlendFunc : function ( +) +{ + return cc.BlendFunc; +}, + +/** + * @method setArmatureData + * @param {ccs.ArmatureData} arg0 + */ +setArmatureData : function ( +armaturedata +) +{ +}, + +/** + * @method addBone + * @param {ccs.Bone} arg0 + * @param {String} arg1 + */ +addBone : function ( +bone, +str +) +{ +}, + +/** + * @method getArmatureData + * @return {ccs.ArmatureData} + */ +getArmatureData : function ( +) +{ + return ccs.ArmatureData; +}, + +/** + * @method getBoundingBox + * @return {rect_object} + */ +getBoundingBox : function ( +) +{ + return cc.Rect; +}, + +/** + * @method getVersion + * @return {float} + */ +getVersion : function ( +) +{ + return 0; +}, + +/** + * @method getAnimation + * @return {ccs.ArmatureAnimation} + */ +getAnimation : function ( +) +{ + return ccs.ArmatureAnimation; +}, + +/** + * @method getOffsetPoints + * @return {vec2_object} + */ +getOffsetPoints : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method setBlendFunc + * @param {cc.BlendFunc} arg0 + */ +setBlendFunc : function ( +blendfunc +) +{ +}, + +/** + * @method getBoneDic + * @return {map_object} + */ +getBoneDic : function ( +) +{ + return map_object; +}, + +/** + * @method create +* @param {String|String} str +* @param {ccs.Bone} bone +* @return {ccs.Armature|ccs.Armature|ccs.Armature} +*/ +create : function( +str, +bone +) +{ + return ccs.Armature; +}, + +/** + * @method Armature + * @constructor + */ +Armature : function ( +) +{ +}, + +}; + +/** + * @class Skin + */ +ccs.Skin = { + +/** + * @method getBone + * @return {ccs.Bone} + */ +getBone : function ( +) +{ + return ccs.Bone; +}, + +/** + * @method getNodeToWorldTransformAR + * @return {mat4_object} + */ +getNodeToWorldTransformAR : function ( +) +{ + return cc.Mat4; +}, + +/** + * @method getDisplayName + * @return {String} + */ +getDisplayName : function ( +) +{ + return ; +}, + +/** + * @method updateArmatureTransform + */ +updateArmatureTransform : function ( +) +{ +}, + +/** + * @method setBone + * @param {ccs.Bone} arg0 + */ +setBone : function ( +bone +) +{ +}, + +/** + * @method create +* @param {String} str +* @return {ccs.Skin|ccs.Skin} +*/ +create : function( +str +) +{ + return ccs.Skin; +}, + +/** + * @method createWithSpriteFrameName + * @param {String} arg0 + * @return {ccs.Skin} + */ +createWithSpriteFrameName : function ( +str +) +{ + return ccs.Skin; +}, + +/** + * @method Skin + * @constructor + */ +Skin : function ( +) +{ +}, + +}; + +/** + * @class ComAttribute + */ +ccs.ComAttribute = { + +/** + * @method getFloat + * @param {String} arg0 + * @param {float} arg1 + * @return {float} + */ +getFloat : function ( +str, +float +) +{ + return 0; +}, + +/** + * @method getBool + * @param {String} arg0 + * @param {bool} arg1 + * @return {bool} + */ +getBool : function ( +str, +bool +) +{ + return false; +}, + +/** + * @method getString + * @param {String} arg0 + * @param {String} arg1 + * @return {String} + */ +getString : function ( +str, +str +) +{ + return ; +}, + +/** + * @method setFloat + * @param {String} arg0 + * @param {float} arg1 + */ +setFloat : function ( +str, +float +) +{ +}, + +/** + * @method setString + * @param {String} arg0 + * @param {String} arg1 + */ +setString : function ( +str, +str +) +{ +}, + +/** + * @method setInt + * @param {String} arg0 + * @param {int} arg1 + */ +setInt : function ( +str, +int +) +{ +}, + +/** + * @method parse + * @param {String} arg0 + * @return {bool} + */ +parse : function ( +str +) +{ + return false; +}, + +/** + * @method getInt + * @param {String} arg0 + * @param {int} arg1 + * @return {int} + */ +getInt : function ( +str, +int +) +{ + return 0; +}, + +/** + * @method setBool + * @param {String} arg0 + * @param {bool} arg1 + */ +setBool : function ( +str, +bool +) +{ +}, + +/** + * @method create + * @return {ccs.ComAttribute} + */ +create : function ( +) +{ + return ccs.ComAttribute; +}, + +/** + * @method ComAttribute + * @constructor + */ +ComAttribute : function ( +) +{ +}, + +}; + +/** + * @class ComAudio + */ +ccs.ComAudio = { + +/** + * @method stopAllEffects + */ +stopAllEffects : function ( +) +{ +}, + +/** + * @method getEffectsVolume + * @return {float} + */ +getEffectsVolume : function ( +) +{ + return 0; +}, + +/** + * @method stopEffect + * @param {unsigned int} arg0 + */ +stopEffect : function ( +int +) +{ +}, + +/** + * @method getBackgroundMusicVolume + * @return {float} + */ +getBackgroundMusicVolume : function ( +) +{ + return 0; +}, + +/** + * @method willPlayBackgroundMusic + * @return {bool} + */ +willPlayBackgroundMusic : function ( +) +{ + return false; +}, + +/** + * @method setBackgroundMusicVolume + * @param {float} arg0 + */ +setBackgroundMusicVolume : function ( +float +) +{ +}, + +/** + * @method end + */ +end : function ( +) +{ +}, + +/** + * @method stopBackgroundMusic +* @param {bool} bool +*/ +stopBackgroundMusic : function( +bool +) +{ +}, + +/** + * @method pauseBackgroundMusic + */ +pauseBackgroundMusic : function ( +) +{ +}, + +/** + * @method isBackgroundMusicPlaying + * @return {bool} + */ +isBackgroundMusicPlaying : function ( +) +{ + return false; +}, + +/** + * @method isLoop + * @return {bool} + */ +isLoop : function ( +) +{ + return false; +}, + +/** + * @method resumeAllEffects + */ +resumeAllEffects : function ( +) +{ +}, + +/** + * @method pauseAllEffects + */ +pauseAllEffects : function ( +) +{ +}, + +/** + * @method preloadBackgroundMusic + * @param {char} arg0 + */ +preloadBackgroundMusic : function ( +char +) +{ +}, + +/** + * @method playBackgroundMusic +* @param {char|char} char +* @param {bool} bool +*/ +playBackgroundMusic : function( +char, +bool +) +{ +}, + +/** + * @method playEffect +* @param {char|char} char +* @param {bool} bool +* @return {unsigned int|unsigned int|unsigned int} +*/ +playEffect : function( +char, +bool +) +{ + return 0; +}, + +/** + * @method preloadEffect + * @param {char} arg0 + */ +preloadEffect : function ( +char +) +{ +}, + +/** + * @method setLoop + * @param {bool} arg0 + */ +setLoop : function ( +bool +) +{ +}, + +/** + * @method unloadEffect + * @param {char} arg0 + */ +unloadEffect : function ( +char +) +{ +}, + +/** + * @method rewindBackgroundMusic + */ +rewindBackgroundMusic : function ( +) +{ +}, + +/** + * @method pauseEffect + * @param {unsigned int} arg0 + */ +pauseEffect : function ( +int +) +{ +}, + +/** + * @method resumeBackgroundMusic + */ +resumeBackgroundMusic : function ( +) +{ +}, + +/** + * @method setFile + * @param {char} arg0 + */ +setFile : function ( +char +) +{ +}, + +/** + * @method setEffectsVolume + * @param {float} arg0 + */ +setEffectsVolume : function ( +float +) +{ +}, + +/** + * @method getFile + * @return {char} + */ +getFile : function ( +) +{ + return 0; +}, + +/** + * @method resumeEffect + * @param {unsigned int} arg0 + */ +resumeEffect : function ( +int +) +{ +}, + +/** + * @method create + * @return {ccs.ComAudio} + */ +create : function ( +) +{ + return ccs.ComAudio; +}, + +/** + * @method ComAudio + * @constructor + */ +ComAudio : function ( +) +{ +}, + +}; + +/** + * @class InputDelegate + */ +ccs.InputDelegate = { + +/** + * @method isAccelerometerEnabled + * @return {bool} + */ +isAccelerometerEnabled : function ( +) +{ + return false; +}, + +/** + * @method setKeypadEnabled + * @param {bool} arg0 + */ +setKeypadEnabled : function ( +bool +) +{ +}, + +/** + * @method getTouchMode + * @return {cc.Touch::DispatchMode} + */ +getTouchMode : function ( +) +{ + return 0; +}, + +/** + * @method setAccelerometerEnabled + * @param {bool} arg0 + */ +setAccelerometerEnabled : function ( +bool +) +{ +}, + +/** + * @method isKeypadEnabled + * @return {bool} + */ +isKeypadEnabled : function ( +) +{ + return false; +}, + +/** + * @method isTouchEnabled + * @return {bool} + */ +isTouchEnabled : function ( +) +{ + return false; +}, + +/** + * @method setTouchPriority + * @param {int} arg0 + */ +setTouchPriority : function ( +int +) +{ +}, + +/** + * @method getTouchPriority + * @return {int} + */ +getTouchPriority : function ( +) +{ + return 0; +}, + +/** + * @method setTouchEnabled + * @param {bool} arg0 + */ +setTouchEnabled : function ( +bool +) +{ +}, + +/** + * @method setTouchMode + * @param {cc.Touch::DispatchMode} arg0 + */ +setTouchMode : function ( +dispatchmode +) +{ +}, + +}; + +/** + * @class ComController + */ +ccs.ComController = { + +/** + * @method create + * @return {ccs.ComController} + */ +create : function ( +) +{ + return ccs.ComController; +}, + +/** + * @method ComController + * @constructor + */ +ComController : function ( +) +{ +}, + +}; + +/** + * @class ComRender + */ +ccs.ComRender = { + +/** + * @method getNode + * @return {cc.Node} + */ +getNode : function ( +) +{ + return cc.Node; +}, + +/** + * @method setNode + * @param {cc.Node} arg0 + */ +setNode : function ( +node +) +{ +}, + +/** + * @method create +* @param {cc.Node} node +* @param {char} char +* @return {ccs.ComRender|ccs.ComRender} +*/ +create : function( +node, +char +) +{ + return ccs.ComRender; +}, + +/** + * @method ComRender + * @constructor +* @param {cc.Node} node +* @param {char} char +*/ +ComRender : function( +node, +char +) +{ +}, + +}; + +/** + * @class Frame + */ +ccs.Frame = { + +/** + * @method clone + * @return {ccs.timeline::Frame} + */ +clone : function ( +) +{ + return ccs.timeline::Frame; +}, + +/** + * @method setTweenType + * @param {cc.tweenfunc::TweenType} arg0 + */ +setTweenType : function ( +tweentype +) +{ +}, + +/** + * @method setNode + * @param {cc.Node} arg0 + */ +setNode : function ( +node +) +{ +}, + +/** + * @method setTimeline + * @param {ccs.timeline::Timeline} arg0 + */ +setTimeline : function ( +timeline +) +{ +}, + +/** + * @method isEnterWhenPassed + * @return {bool} + */ +isEnterWhenPassed : function ( +) +{ + return false; +}, + +/** + * @method getTweenType + * @return {cc.tweenfunc::TweenType} + */ +getTweenType : function ( +) +{ + return 0; +}, + +/** + * @method getFrameIndex + * @return {unsigned int} + */ +getFrameIndex : function ( +) +{ + return 0; +}, + +/** + * @method apply + * @param {float} arg0 + */ +apply : function ( +float +) +{ +}, + +/** + * @method isTween + * @return {bool} + */ +isTween : function ( +) +{ + return false; +}, + +/** + * @method setFrameIndex + * @param {unsigned int} arg0 + */ +setFrameIndex : function ( +int +) +{ +}, + +/** + * @method setTween + * @param {bool} arg0 + */ +setTween : function ( +bool +) +{ +}, + +/** + * @method getTimeline + * @return {ccs.timeline::Timeline} + */ +getTimeline : function ( +) +{ + return ccs.timeline::Timeline; +}, + +/** + * @method getNode + * @return {cc.Node} + */ +getNode : function ( +) +{ + return cc.Node; +}, + +}; + +/** + * @class VisibleFrame + */ +ccs.VisibleFrame = { + +/** + * @method isVisible + * @return {bool} + */ +isVisible : function ( +) +{ + return false; +}, + +/** + * @method setVisible + * @param {bool} arg0 + */ +setVisible : function ( +bool +) +{ +}, + +/** + * @method create + * @return {ccs.timeline::VisibleFrame} + */ +create : function ( +) +{ + return ccs.timeline::VisibleFrame; +}, + +/** + * @method VisibleFrame + * @constructor + */ +VisibleFrame : function ( +) +{ +}, + +}; + +/** + * @class TextureFrame + */ +ccs.TextureFrame = { + +/** + * @method getTextureName + * @return {String} + */ +getTextureName : function ( +) +{ + return ; +}, + +/** + * @method setTextureName + * @param {String} arg0 + */ +setTextureName : function ( +str +) +{ +}, + +/** + * @method create + * @return {ccs.timeline::TextureFrame} + */ +create : function ( +) +{ + return ccs.timeline::TextureFrame; +}, + +/** + * @method TextureFrame + * @constructor + */ +TextureFrame : function ( +) +{ +}, + +}; + +/** + * @class RotationFrame + */ +ccs.RotationFrame = { + +/** + * @method setRotation + * @param {float} arg0 + */ +setRotation : function ( +float +) +{ +}, + +/** + * @method getRotation + * @return {float} + */ +getRotation : function ( +) +{ + return 0; +}, + +/** + * @method create + * @return {ccs.timeline::RotationFrame} + */ +create : function ( +) +{ + return ccs.timeline::RotationFrame; +}, + +/** + * @method RotationFrame + * @constructor + */ +RotationFrame : function ( +) +{ +}, + +}; + +/** + * @class SkewFrame + */ +ccs.SkewFrame = { + +/** + * @method getSkewY + * @return {float} + */ +getSkewY : function ( +) +{ + return 0; +}, + +/** + * @method setSkewX + * @param {float} arg0 + */ +setSkewX : function ( +float +) +{ +}, + +/** + * @method setSkewY + * @param {float} arg0 + */ +setSkewY : function ( +float +) +{ +}, + +/** + * @method getSkewX + * @return {float} + */ +getSkewX : function ( +) +{ + return 0; +}, + +/** + * @method create + * @return {ccs.timeline::SkewFrame} + */ +create : function ( +) +{ + return ccs.timeline::SkewFrame; +}, + +/** + * @method SkewFrame + * @constructor + */ +SkewFrame : function ( +) +{ +}, + +}; + +/** + * @class RotationSkewFrame + */ +ccs.RotationSkewFrame = { + +/** + * @method create + * @return {ccs.timeline::RotationSkewFrame} + */ +create : function ( +) +{ + return ccs.timeline::RotationSkewFrame; +}, + +/** + * @method RotationSkewFrame + * @constructor + */ +RotationSkewFrame : function ( +) +{ +}, + +}; + +/** + * @class PositionFrame + */ +ccs.PositionFrame = { + +/** + * @method getX + * @return {float} + */ +getX : function ( +) +{ + return 0; +}, + +/** + * @method getY + * @return {float} + */ +getY : function ( +) +{ + return 0; +}, + +/** + * @method setPosition + * @param {vec2_object} arg0 + */ +setPosition : function ( +vec2 +) +{ +}, + +/** + * @method setX + * @param {float} arg0 + */ +setX : function ( +float +) +{ +}, + +/** + * @method setY + * @param {float} arg0 + */ +setY : function ( +float +) +{ +}, + +/** + * @method getPosition + * @return {vec2_object} + */ +getPosition : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method create + * @return {ccs.timeline::PositionFrame} + */ +create : function ( +) +{ + return ccs.timeline::PositionFrame; +}, + +/** + * @method PositionFrame + * @constructor + */ +PositionFrame : function ( +) +{ +}, + +}; + +/** + * @class ScaleFrame + */ +ccs.ScaleFrame = { + +/** + * @method setScaleY + * @param {float} arg0 + */ +setScaleY : function ( +float +) +{ +}, + +/** + * @method setScaleX + * @param {float} arg0 + */ +setScaleX : function ( +float +) +{ +}, + +/** + * @method getScaleY + * @return {float} + */ +getScaleY : function ( +) +{ + return 0; +}, + +/** + * @method getScaleX + * @return {float} + */ +getScaleX : function ( +) +{ + return 0; +}, + +/** + * @method setScale + * @param {float} arg0 + */ +setScale : function ( +float +) +{ +}, + +/** + * @method create + * @return {ccs.timeline::ScaleFrame} + */ +create : function ( +) +{ + return ccs.timeline::ScaleFrame; +}, + +/** + * @method ScaleFrame + * @constructor + */ +ScaleFrame : function ( +) +{ +}, + +}; + +/** + * @class AnchorPointFrame + */ +ccs.AnchorPointFrame = { + +/** + * @method setAnchorPoint + * @param {vec2_object} arg0 + */ +setAnchorPoint : function ( +vec2 +) +{ +}, + +/** + * @method getAnchorPoint + * @return {vec2_object} + */ +getAnchorPoint : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method create + * @return {ccs.timeline::AnchorPointFrame} + */ +create : function ( +) +{ + return ccs.timeline::AnchorPointFrame; +}, + +/** + * @method AnchorPointFrame + * @constructor + */ +AnchorPointFrame : function ( +) +{ +}, + +}; + +/** + * @class InnerActionFrame + */ +ccs.InnerActionFrame = { + +/** + * @method getEndFrameIndex + * @return {int} + */ +getEndFrameIndex : function ( +) +{ + return 0; +}, + +/** + * @method getStartFrameIndex + * @return {int} + */ +getStartFrameIndex : function ( +) +{ + return 0; +}, + +/** + * @method getInnerActionType + * @return {ccs.timeline::InnerActionType} + */ +getInnerActionType : function ( +) +{ + return 0; +}, + +/** + * @method setEndFrameIndex + * @param {int} arg0 + */ +setEndFrameIndex : function ( +int +) +{ +}, + +/** + * @method setEnterWithName + * @param {bool} arg0 + */ +setEnterWithName : function ( +bool +) +{ +}, + +/** + * @method setSingleFrameIndex + * @param {int} arg0 + */ +setSingleFrameIndex : function ( +int +) +{ +}, + +/** + * @method setStartFrameIndex + * @param {int} arg0 + */ +setStartFrameIndex : function ( +int +) +{ +}, + +/** + * @method getSingleFrameIndex + * @return {int} + */ +getSingleFrameIndex : function ( +) +{ + return 0; +}, + +/** + * @method setInnerActionType + * @param {ccs.timeline::InnerActionType} arg0 + */ +setInnerActionType : function ( +inneractiontype +) +{ +}, + +/** + * @method setAnimationName + * @param {String} arg0 + */ +setAnimationName : function ( +str +) +{ +}, + +/** + * @method create + * @return {ccs.timeline::InnerActionFrame} + */ +create : function ( +) +{ + return ccs.timeline::InnerActionFrame; +}, + +/** + * @method InnerActionFrame + * @constructor + */ +InnerActionFrame : function ( +) +{ +}, + +}; + +/** + * @class ColorFrame + */ +ccs.ColorFrame = { + +/** + * @method getColor + * @return {color3b_object} + */ +getColor : function ( +) +{ + return cc.Color3B; +}, + +/** + * @method setColor + * @param {color3b_object} arg0 + */ +setColor : function ( +color3b +) +{ +}, + +/** + * @method create + * @return {ccs.timeline::ColorFrame} + */ +create : function ( +) +{ + return ccs.timeline::ColorFrame; +}, + +/** + * @method ColorFrame + * @constructor + */ +ColorFrame : function ( +) +{ +}, + +}; + +/** + * @class AlphaFrame + */ +ccs.AlphaFrame = { + +/** + * @method getAlpha + * @return {unsigned char} + */ +getAlpha : function ( +) +{ + return 0; +}, + +/** + * @method setAlpha + * @param {unsigned char} arg0 + */ +setAlpha : function ( +char +) +{ +}, + +/** + * @method create + * @return {ccs.timeline::AlphaFrame} + */ +create : function ( +) +{ + return ccs.timeline::AlphaFrame; +}, + +/** + * @method AlphaFrame + * @constructor + */ +AlphaFrame : function ( +) +{ +}, + +}; + +/** + * @class EventFrame + */ +ccs.EventFrame = { + +/** + * @method setEvent + * @param {String} arg0 + */ +setEvent : function ( +str +) +{ +}, + +/** + * @method init + */ +init : function ( +) +{ +}, + +/** + * @method getEvent + * @return {String} + */ +getEvent : function ( +) +{ + return ; +}, + +/** + * @method create + * @return {ccs.timeline::EventFrame} + */ +create : function ( +) +{ + return ccs.timeline::EventFrame; +}, + +/** + * @method EventFrame + * @constructor + */ +EventFrame : function ( +) +{ +}, + +}; + +/** + * @class ZOrderFrame + */ +ccs.ZOrderFrame = { + +/** + * @method getZOrder + * @return {int} + */ +getZOrder : function ( +) +{ + return 0; +}, + +/** + * @method setZOrder + * @param {int} arg0 + */ +setZOrder : function ( +int +) +{ +}, + +/** + * @method create + * @return {ccs.timeline::ZOrderFrame} + */ +create : function ( +) +{ + return ccs.timeline::ZOrderFrame; +}, + +/** + * @method ZOrderFrame + * @constructor + */ +ZOrderFrame : function ( +) +{ +}, + +}; + +/** + * @class Timeline + */ +ccs.Timeline = { + +/** + * @method clone + * @return {ccs.timeline::Timeline} + */ +clone : function ( +) +{ + return ccs.timeline::Timeline; +}, + +/** + * @method gotoFrame + * @param {int} arg0 + */ +gotoFrame : function ( +int +) +{ +}, + +/** + * @method setNode + * @param {cc.Node} arg0 + */ +setNode : function ( +node +) +{ +}, + +/** + * @method getActionTimeline + * @return {ccs.timeline::ActionTimeline} + */ +getActionTimeline : function ( +) +{ + return ccs.timeline::ActionTimeline; +}, + +/** + * @method insertFrame + * @param {ccs.timeline::Frame} arg0 + * @param {int} arg1 + */ +insertFrame : function ( +frame, +int +) +{ +}, + +/** + * @method setActionTag + * @param {int} arg0 + */ +setActionTag : function ( +int +) +{ +}, + +/** + * @method addFrame + * @param {ccs.timeline::Frame} arg0 + */ +addFrame : function ( +frame +) +{ +}, + +/** + * @method getFrames + * @return {Array} + */ +getFrames : function ( +) +{ + return new Array(); +}, + +/** + * @method getActionTag + * @return {int} + */ +getActionTag : function ( +) +{ + return 0; +}, + +/** + * @method getNode + * @return {cc.Node} + */ +getNode : function ( +) +{ + return cc.Node; +}, + +/** + * @method removeFrame + * @param {ccs.timeline::Frame} arg0 + */ +removeFrame : function ( +frame +) +{ +}, + +/** + * @method setActionTimeline + * @param {ccs.timeline::ActionTimeline} arg0 + */ +setActionTimeline : function ( +actiontimeline +) +{ +}, + +/** + * @method stepToFrame + * @param {int} arg0 + */ +stepToFrame : function ( +int +) +{ +}, + +/** + * @method create + * @return {ccs.timeline::Timeline} + */ +create : function ( +) +{ + return ccs.timeline::Timeline; +}, + +/** + * @method Timeline + * @constructor + */ +Timeline : function ( +) +{ +}, + +}; + +/** + * @class ActionTimelineData + */ +ccs.ActionTimelineData = { + +/** + * @method setActionTag + * @param {int} arg0 + */ +setActionTag : function ( +int +) +{ +}, + +/** + * @method init + * @param {int} arg0 + * @return {bool} + */ +init : function ( +int +) +{ + return false; +}, + +/** + * @method getActionTag + * @return {int} + */ +getActionTag : function ( +) +{ + return 0; +}, + +/** + * @method create + * @param {int} arg0 + * @return {ccs.timeline::ActionTimelineData} + */ +create : function ( +int +) +{ + return ccs.timeline::ActionTimelineData; +}, + +/** + * @method ActionTimelineData + * @constructor + */ +ActionTimelineData : function ( +) +{ +}, + +}; + +/** + * @class ActionTimeline + */ +ccs.ActionTimeline = { + +/** + * @method setFrameEventCallFunc + * @param {function} arg0 + */ +setFrameEventCallFunc : function ( +func +) +{ +}, + +/** + * @method addTimeline + * @param {ccs.timeline::Timeline} arg0 + */ +addTimeline : function ( +timeline +) +{ +}, + +/** + * @method getCurrentFrame + * @return {int} + */ +getCurrentFrame : function ( +) +{ + return 0; +}, + +/** + * @method getStartFrame + * @return {int} + */ +getStartFrame : function ( +) +{ + return 0; +}, + +/** + * @method pause + */ +pause : function ( +) +{ +}, + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method removeTimeline + * @param {ccs.timeline::Timeline} arg0 + */ +removeTimeline : function ( +timeline +) +{ +}, + +/** + * @method setLastFrameCallFunc + * @param {function} arg0 + */ +setLastFrameCallFunc : function ( +func +) +{ +}, + +/** + * @method IsAnimationInfoExists + * @param {String} arg0 + * @return {bool} + */ +IsAnimationInfoExists : function ( +str +) +{ + return false; +}, + +/** + * @method getTimelines + * @return {Array} + */ +getTimelines : function ( +) +{ + return new Array(); +}, + +/** + * @method play + * @param {String} arg0 + * @param {bool} arg1 + */ +play : function ( +str, +bool +) +{ +}, + +/** + * @method getAnimationInfo + * @param {String} arg0 + * @return {ccs.timeline::AnimationInfo} + */ +getAnimationInfo : function ( +str +) +{ + return ccs.timeline::AnimationInfo; +}, + +/** + * @method resume + */ +resume : function ( +) +{ +}, + +/** + * @method removeAnimationInfo + * @param {String} arg0 + */ +removeAnimationInfo : function ( +str +) +{ +}, + +/** + * @method getTimeSpeed + * @return {float} + */ +getTimeSpeed : function ( +) +{ + return 0; +}, + +/** + * @method addAnimationInfo + * @param {ccs.timeline::AnimationInfo} arg0 + */ +addAnimationInfo : function ( +animationinfo +) +{ +}, + +/** + * @method getDuration + * @return {int} + */ +getDuration : function ( +) +{ + return 0; +}, + +/** + * @method gotoFrameAndPause + * @param {int} arg0 + */ +gotoFrameAndPause : function ( +int +) +{ +}, + +/** + * @method isPlaying + * @return {bool} + */ +isPlaying : function ( +) +{ + return false; +}, + +/** + * @method gotoFrameAndPlay +* @param {int|int|int|int} int +* @param {bool|int|int} bool +* @param {bool|int} bool +* @param {bool} bool +*/ +gotoFrameAndPlay : function( +int, +int, +int, +bool +) +{ +}, + +/** + * @method clearFrameEventCallFunc + */ +clearFrameEventCallFunc : function ( +) +{ +}, + +/** + * @method getEndFrame + * @return {int} + */ +getEndFrame : function ( +) +{ + return 0; +}, + +/** + * @method setTimeSpeed + * @param {float} arg0 + */ +setTimeSpeed : function ( +float +) +{ +}, + +/** + * @method clearLastFrameCallFunc + */ +clearLastFrameCallFunc : function ( +) +{ +}, + +/** + * @method setDuration + * @param {int} arg0 + */ +setDuration : function ( +int +) +{ +}, + +/** + * @method setCurrentFrame + * @param {int} arg0 + */ +setCurrentFrame : function ( +int +) +{ +}, + +/** + * @method create + * @return {ccs.timeline::ActionTimeline} + */ +create : function ( +) +{ + return ccs.timeline::ActionTimeline; +}, + +/** + * @method ActionTimeline + * @constructor + */ +ActionTimeline : function ( +) +{ +}, + +}; + +/** + * @class ObjectExtensionData + */ +ccs.ObjectExtensionData = { + +/** + * @method setActionTag + * @param {int} arg0 + */ +setActionTag : function ( +int +) +{ +}, + +/** + * @method setCustomProperty + * @param {String} arg0 + */ +setCustomProperty : function ( +str +) +{ +}, + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method getCustomProperty + * @return {String} + */ +getCustomProperty : function ( +) +{ + return ; +}, + +/** + * @method getActionTag + * @return {int} + */ +getActionTag : function ( +) +{ + return 0; +}, + +/** + * @method create + * @return {ccs.ObjectExtensionData} + */ +create : function ( +) +{ + return ccs.ObjectExtensionData; +}, + +/** + * @method ObjectExtensionData + * @constructor + */ +ObjectExtensionData : function ( +) +{ +}, + +}; diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js new file mode 100644 index 0000000000..93a53d1097 --- /dev/null +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js @@ -0,0 +1,5893 @@ +/** + * @module cocos2dx_ui + */ +var ccui = ccui || {}; + +/** + * @class LayoutParameter + */ +ccui.LayoutParameter = { + +/** + * @method clone + * @return {ccui.LayoutParameter} + */ +clone : function ( +) +{ + return ccui.LayoutParameter; +}, + +/** + * @method getLayoutType + * @return {ccui.LayoutParameter::Type} + */ +getLayoutType : function ( +) +{ + return 0; +}, + +/** + * @method createCloneInstance + * @return {ccui.LayoutParameter} + */ +createCloneInstance : function ( +) +{ + return ccui.LayoutParameter; +}, + +/** + * @method copyProperties + * @param {ccui.LayoutParameter} arg0 + */ +copyProperties : function ( +layoutparameter +) +{ +}, + +/** + * @method create + * @return {ccui.LayoutParameter} + */ +create : function ( +) +{ + return ccui.LayoutParameter; +}, + +/** + * @method LayoutParameter + * @constructor + */ +LayoutParameter : function ( +) +{ +}, + +}; + +/** + * @class LinearLayoutParameter + */ +ccui.LinearLayoutParameter = { + +/** + * @method setGravity + * @param {ccui.LinearLayoutParameter::LinearGravity} arg0 + */ +setGravity : function ( +lineargravity +) +{ +}, + +/** + * @method getGravity + * @return {ccui.LinearLayoutParameter::LinearGravity} + */ +getGravity : function ( +) +{ + return 0; +}, + +/** + * @method create + * @return {ccui.LinearLayoutParameter} + */ +create : function ( +) +{ + return ccui.LinearLayoutParameter; +}, + +/** + * @method LinearLayoutParameter + * @constructor + */ +LinearLayoutParameter : function ( +) +{ +}, + +}; + +/** + * @class RelativeLayoutParameter + */ +ccui.RelativeLayoutParameter = { + +/** + * @method setAlign + * @param {ccui.RelativeLayoutParameter::RelativeAlign} arg0 + */ +setAlign : function ( +relativealign +) +{ +}, + +/** + * @method setRelativeToWidgetName + * @param {String} arg0 + */ +setRelativeToWidgetName : function ( +str +) +{ +}, + +/** + * @method getRelativeName + * @return {String} + */ +getRelativeName : function ( +) +{ + return ; +}, + +/** + * @method getRelativeToWidgetName + * @return {String} + */ +getRelativeToWidgetName : function ( +) +{ + return ; +}, + +/** + * @method setRelativeName + * @param {String} arg0 + */ +setRelativeName : function ( +str +) +{ +}, + +/** + * @method getAlign + * @return {ccui.RelativeLayoutParameter::RelativeAlign} + */ +getAlign : function ( +) +{ + return 0; +}, + +/** + * @method create + * @return {ccui.RelativeLayoutParameter} + */ +create : function ( +) +{ + return ccui.RelativeLayoutParameter; +}, + +/** + * @method RelativeLayoutParameter + * @constructor + */ +RelativeLayoutParameter : function ( +) +{ +}, + +}; + +/** + * @class Widget + */ +ccui.Widget = { + +/** + * @method setLayoutComponentEnabled + * @param {bool} arg0 + */ +setLayoutComponentEnabled : function ( +bool +) +{ +}, + +/** + * @method setSizePercent + * @param {vec2_object} arg0 + */ +setSizePercent : function ( +vec2 +) +{ +}, + +/** + * @method getCustomSize + * @return {size_object} + */ +getCustomSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method getLeftBoundary + * @return {float} + */ +getLeftBoundary : function ( +) +{ + return 0; +}, + +/** + * @method setFlippedX + * @param {bool} arg0 + */ +setFlippedX : function ( +bool +) +{ +}, + +/** + * @method setCallbackName + * @param {String} arg0 + */ +setCallbackName : function ( +str +) +{ +}, + +/** + * @method getVirtualRenderer + * @return {cc.Node} + */ +getVirtualRenderer : function ( +) +{ + return cc.Node; +}, + +/** + * @method setPropagateTouchEvents + * @param {bool} arg0 + */ +setPropagateTouchEvents : function ( +bool +) +{ +}, + +/** + * @method isUnifySizeEnabled + * @return {bool} + */ +isUnifySizeEnabled : function ( +) +{ + return false; +}, + +/** + * @method getSizePercent + * @return {vec2_object} + */ +getSizePercent : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method setPositionPercent + * @param {vec2_object} arg0 + */ +setPositionPercent : function ( +vec2 +) +{ +}, + +/** + * @method setSwallowTouches + * @param {bool} arg0 + */ +setSwallowTouches : function ( +bool +) +{ +}, + +/** + * @method getLayoutSize + * @return {size_object} + */ +getLayoutSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method setHighlighted + * @param {bool} arg0 + */ +setHighlighted : function ( +bool +) +{ +}, + +/** + * @method setPositionType + * @param {ccui.Widget::PositionType} arg0 + */ +setPositionType : function ( +positiontype +) +{ +}, + +/** + * @method isIgnoreContentAdaptWithSize + * @return {bool} + */ +isIgnoreContentAdaptWithSize : function ( +) +{ + return false; +}, + +/** + * @method getVirtualRendererSize + * @return {size_object} + */ +getVirtualRendererSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method isHighlighted + * @return {bool} + */ +isHighlighted : function ( +) +{ + return false; +}, + +/** + * @method getLayoutParameter + * @return {ccui.LayoutParameter} + */ +getLayoutParameter : function ( +) +{ + return ccui.LayoutParameter; +}, + +/** + * @method addCCSEventListener + * @param {function} arg0 + */ +addCCSEventListener : function ( +func +) +{ +}, + +/** + * @method getPositionType + * @return {ccui.Widget::PositionType} + */ +getPositionType : function ( +) +{ + return 0; +}, + +/** + * @method getTopBoundary + * @return {float} + */ +getTopBoundary : function ( +) +{ + return 0; +}, + +/** + * @method ignoreContentAdaptWithSize + * @param {bool} arg0 + */ +ignoreContentAdaptWithSize : function ( +bool +) +{ +}, + +/** + * @method findNextFocusedWidget + * @param {ccui.Widget::FocusDirection} arg0 + * @param {ccui.Widget} arg1 + * @return {ccui.Widget} + */ +findNextFocusedWidget : function ( +focusdirection, +widget +) +{ + return ccui.Widget; +}, + +/** + * @method isEnabled + * @return {bool} + */ +isEnabled : function ( +) +{ + return false; +}, + +/** + * @method isFocused + * @return {bool} + */ +isFocused : function ( +) +{ + return false; +}, + +/** + * @method getTouchBeganPosition + * @return {vec2_object} + */ +getTouchBeganPosition : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method isTouchEnabled + * @return {bool} + */ +isTouchEnabled : function ( +) +{ + return false; +}, + +/** + * @method getCallbackName + * @return {String} + */ +getCallbackName : function ( +) +{ + return ; +}, + +/** + * @method getActionTag + * @return {int} + */ +getActionTag : function ( +) +{ + return 0; +}, + +/** + * @method getWorldPosition + * @return {vec2_object} + */ +getWorldPosition : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method isFocusEnabled + * @return {bool} + */ +isFocusEnabled : function ( +) +{ + return false; +}, + +/** + * @method setFocused + * @param {bool} arg0 + */ +setFocused : function ( +bool +) +{ +}, + +/** + * @method setActionTag + * @param {int} arg0 + */ +setActionTag : function ( +int +) +{ +}, + +/** + * @method setTouchEnabled + * @param {bool} arg0 + */ +setTouchEnabled : function ( +bool +) +{ +}, + +/** + * @method setFlippedY + * @param {bool} arg0 + */ +setFlippedY : function ( +bool +) +{ +}, + +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + +/** + * @method setEnabled + * @param {bool} arg0 + */ +setEnabled : function ( +bool +) +{ +}, + +/** + * @method getRightBoundary + * @return {float} + */ +getRightBoundary : function ( +) +{ + return 0; +}, + +/** + * @method setBrightStyle + * @param {ccui.Widget::BrightStyle} arg0 + */ +setBrightStyle : function ( +brightstyle +) +{ +}, + +/** + * @method setLayoutParameter + * @param {ccui.LayoutParameter} arg0 + */ +setLayoutParameter : function ( +layoutparameter +) +{ +}, + +/** + * @method clone + * @return {ccui.Widget} + */ +clone : function ( +) +{ + return ccui.Widget; +}, + +/** + * @method setFocusEnabled + * @param {bool} arg0 + */ +setFocusEnabled : function ( +bool +) +{ +}, + +/** + * @method getBottomBoundary + * @return {float} + */ +getBottomBoundary : function ( +) +{ + return 0; +}, + +/** + * @method isBright + * @return {bool} + */ +isBright : function ( +) +{ + return false; +}, + +/** + * @method dispatchFocusEvent + * @param {ccui.Widget} arg0 + * @param {ccui.Widget} arg1 + */ +dispatchFocusEvent : function ( +widget, +widget +) +{ +}, + +/** + * @method setUnifySizeEnabled + * @param {bool} arg0 + */ +setUnifySizeEnabled : function ( +bool +) +{ +}, + +/** + * @method isPropagateTouchEvents + * @return {bool} + */ +isPropagateTouchEvents : function ( +) +{ + return false; +}, + +/** + * @method getCurrentFocusedWidget + * @return {ccui.Widget} + */ +getCurrentFocusedWidget : function ( +) +{ + return ccui.Widget; +}, + +/** + * @method hitTest + * @param {vec2_object} arg0 + * @return {bool} + */ +hitTest : function ( +vec2 +) +{ + return false; +}, + +/** + * @method isLayoutComponentEnabled + * @return {bool} + */ +isLayoutComponentEnabled : function ( +) +{ + return false; +}, + +/** + * @method requestFocus + */ +requestFocus : function ( +) +{ +}, + +/** + * @method updateSizeAndPosition +* @param {size_object} size +*/ +updateSizeAndPosition : function( +size +) +{ +}, + +/** + * @method onFocusChange + * @param {ccui.Widget} arg0 + * @param {ccui.Widget} arg1 + */ +onFocusChange : function ( +widget, +widget +) +{ +}, + +/** + * @method getTouchMovePosition + * @return {vec2_object} + */ +getTouchMovePosition : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getSizeType + * @return {ccui.Widget::SizeType} + */ +getSizeType : function ( +) +{ + return 0; +}, + +/** + * @method getCallbackType + * @return {String} + */ +getCallbackType : function ( +) +{ + return ; +}, + +/** + * @method getTouchEndPosition + * @return {vec2_object} + */ +getTouchEndPosition : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getPositionPercent + * @return {vec2_object} + */ +getPositionPercent : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method propagateTouchEvent + * @param {ccui.Widget::TouchEventType} arg0 + * @param {ccui.Widget} arg1 + * @param {cc.Touch} arg2 + */ +propagateTouchEvent : function ( +toucheventtype, +widget, +touch +) +{ +}, + +/** + * @method addClickEventListener + * @param {function} arg0 + */ +addClickEventListener : function ( +func +) +{ +}, + +/** + * @method isFlippedX + * @return {bool} + */ +isFlippedX : function ( +) +{ + return false; +}, + +/** + * @method isFlippedY + * @return {bool} + */ +isFlippedY : function ( +) +{ + return false; +}, + +/** + * @method isClippingParentContainsPoint + * @param {vec2_object} arg0 + * @return {bool} + */ +isClippingParentContainsPoint : function ( +vec2 +) +{ + return false; +}, + +/** + * @method setSizeType + * @param {ccui.Widget::SizeType} arg0 + */ +setSizeType : function ( +sizetype +) +{ +}, + +/** + * @method interceptTouchEvent + * @param {ccui.Widget::TouchEventType} arg0 + * @param {ccui.Widget} arg1 + * @param {cc.Touch} arg2 + */ +interceptTouchEvent : function ( +toucheventtype, +widget, +touch +) +{ +}, + +/** + * @method setBright + * @param {bool} arg0 + */ +setBright : function ( +bool +) +{ +}, + +/** + * @method setCallbackType + * @param {String} arg0 + */ +setCallbackType : function ( +str +) +{ +}, + +/** + * @method isSwallowTouches + * @return {bool} + */ +isSwallowTouches : function ( +) +{ + return false; +}, + +/** + * @method enableDpadNavigation + * @param {bool} arg0 + */ +enableDpadNavigation : function ( +bool +) +{ +}, + +/** + * @method create + * @return {ccui.Widget} + */ +create : function ( +) +{ + return ccui.Widget; +}, + +/** + * @method Widget + * @constructor + */ +Widget : function ( +) +{ +}, + +}; + +/** + * @class Layout + */ +ccui.Layout = { + +/** + * @method setBackGroundColorVector + * @param {vec2_object} arg0 + */ +setBackGroundColorVector : function ( +vec2 +) +{ +}, + +/** + * @method setClippingType + * @param {ccui.Layout::ClippingType} arg0 + */ +setClippingType : function ( +clippingtype +) +{ +}, + +/** + * @method setBackGroundColorType + * @param {ccui.Layout::BackGroundColorType} arg0 + */ +setBackGroundColorType : function ( +backgroundcolortype +) +{ +}, + +/** + * @method setLoopFocus + * @param {bool} arg0 + */ +setLoopFocus : function ( +bool +) +{ +}, + +/** + * @method setBackGroundImageColor + * @param {color3b_object} arg0 + */ +setBackGroundImageColor : function ( +color3b +) +{ +}, + +/** + * @method getBackGroundColorVector + * @return {vec2_object} + */ +getBackGroundColorVector : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getClippingType + * @return {ccui.Layout::ClippingType} + */ +getClippingType : function ( +) +{ + return 0; +}, + +/** + * @method isLoopFocus + * @return {bool} + */ +isLoopFocus : function ( +) +{ + return false; +}, + +/** + * @method removeBackGroundImage + */ +removeBackGroundImage : function ( +) +{ +}, + +/** + * @method getBackGroundColorOpacity + * @return {unsigned char} + */ +getBackGroundColorOpacity : function ( +) +{ + return 0; +}, + +/** + * @method isClippingEnabled + * @return {bool} + */ +isClippingEnabled : function ( +) +{ + return false; +}, + +/** + * @method setBackGroundImageOpacity + * @param {unsigned char} arg0 + */ +setBackGroundImageOpacity : function ( +char +) +{ +}, + +/** + * @method setBackGroundImage + * @param {String} arg0 + * @param {ccui.Widget::TextureResType} arg1 + */ +setBackGroundImage : function ( +str, +texturerestype +) +{ +}, + +/** + * @method setBackGroundColor +* @param {color3b_object|color3b_object} color3b +* @param {color3b_object} color3b +*/ +setBackGroundColor : function( +color3b, +color3b +) +{ +}, + +/** + * @method requestDoLayout + */ +requestDoLayout : function ( +) +{ +}, + +/** + * @method getBackGroundImageCapInsets + * @return {rect_object} + */ +getBackGroundImageCapInsets : function ( +) +{ + return cc.Rect; +}, + +/** + * @method getBackGroundColor + * @return {color3b_object} + */ +getBackGroundColor : function ( +) +{ + return cc.Color3B; +}, + +/** + * @method setClippingEnabled + * @param {bool} arg0 + */ +setClippingEnabled : function ( +bool +) +{ +}, + +/** + * @method getBackGroundImageColor + * @return {color3b_object} + */ +getBackGroundImageColor : function ( +) +{ + return cc.Color3B; +}, + +/** + * @method isBackGroundImageScale9Enabled + * @return {bool} + */ +isBackGroundImageScale9Enabled : function ( +) +{ + return false; +}, + +/** + * @method getBackGroundColorType + * @return {ccui.Layout::BackGroundColorType} + */ +getBackGroundColorType : function ( +) +{ + return 0; +}, + +/** + * @method getBackGroundEndColor + * @return {color3b_object} + */ +getBackGroundEndColor : function ( +) +{ + return cc.Color3B; +}, + +/** + * @method setBackGroundColorOpacity + * @param {unsigned char} arg0 + */ +setBackGroundColorOpacity : function ( +char +) +{ +}, + +/** + * @method getBackGroundImageOpacity + * @return {unsigned char} + */ +getBackGroundImageOpacity : function ( +) +{ + return 0; +}, + +/** + * @method isPassFocusToChild + * @return {bool} + */ +isPassFocusToChild : function ( +) +{ + return false; +}, + +/** + * @method setBackGroundImageCapInsets + * @param {rect_object} arg0 + */ +setBackGroundImageCapInsets : function ( +rect +) +{ +}, + +/** + * @method getBackGroundImageTextureSize + * @return {size_object} + */ +getBackGroundImageTextureSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method forceDoLayout + */ +forceDoLayout : function ( +) +{ +}, + +/** + * @method getLayoutType + * @return {ccui.Layout::Type} + */ +getLayoutType : function ( +) +{ + return 0; +}, + +/** + * @method setPassFocusToChild + * @param {bool} arg0 + */ +setPassFocusToChild : function ( +bool +) +{ +}, + +/** + * @method getBackGroundStartColor + * @return {color3b_object} + */ +getBackGroundStartColor : function ( +) +{ + return cc.Color3B; +}, + +/** + * @method setBackGroundImageScale9Enabled + * @param {bool} arg0 + */ +setBackGroundImageScale9Enabled : function ( +bool +) +{ +}, + +/** + * @method setLayoutType + * @param {ccui.Layout::Type} arg0 + */ +setLayoutType : function ( +type +) +{ +}, + +/** + * @method create + * @return {ccui.Layout} + */ +create : function ( +) +{ + return ccui.Layout; +}, + +/** + * @method createInstance + * @return {cc.Ref} + */ +createInstance : function ( +) +{ + return cc.Ref; +}, + +/** + * @method Layout + * @constructor + */ +Layout : function ( +) +{ +}, + +}; + +/** + * @class Button + */ +ccui.Button = { + +/** + * @method getNormalTextureSize + * @return {size_object} + */ +getNormalTextureSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method getTitleText + * @return {String} + */ +getTitleText : function ( +) +{ + return ; +}, + +/** + * @method setTitleFontSize + * @param {float} arg0 + */ +setTitleFontSize : function ( +float +) +{ +}, + +/** + * @method setScale9Enabled + * @param {bool} arg0 + */ +setScale9Enabled : function ( +bool +) +{ +}, + +/** + * @method getTitleRenderer + * @return {cc.Label} + */ +getTitleRenderer : function ( +) +{ + return cc.Label; +}, + +/** + * @method getZoomScale + * @return {float} + */ +getZoomScale : function ( +) +{ + return 0; +}, + +/** + * @method getCapInsetsDisabledRenderer + * @return {rect_object} + */ +getCapInsetsDisabledRenderer : function ( +) +{ + return cc.Rect; +}, + +/** + * @method setTitleColor + * @param {color3b_object} arg0 + */ +setTitleColor : function ( +color3b +) +{ +}, + +/** + * @method setCapInsetsDisabledRenderer + * @param {rect_object} arg0 + */ +setCapInsetsDisabledRenderer : function ( +rect +) +{ +}, + +/** + * @method setCapInsets + * @param {rect_object} arg0 + */ +setCapInsets : function ( +rect +) +{ +}, + +/** + * @method loadTextureDisabled + * @param {String} arg0 + * @param {ccui.Widget::TextureResType} arg1 + */ +loadTextureDisabled : function ( +str, +texturerestype +) +{ +}, + +/** + * @method init + * @param {String} arg0 + * @param {String} arg1 + * @param {String} arg2 + * @param {ccui.Widget::TextureResType} arg3 + * @return {bool} + */ +init : function ( +str, +str, +str, +texturerestype +) +{ + return false; +}, + +/** + * @method setTitleText + * @param {String} arg0 + */ +setTitleText : function ( +str +) +{ +}, + +/** + * @method setCapInsetsNormalRenderer + * @param {rect_object} arg0 + */ +setCapInsetsNormalRenderer : function ( +rect +) +{ +}, + +/** + * @method loadTexturePressed + * @param {String} arg0 + * @param {ccui.Widget::TextureResType} arg1 + */ +loadTexturePressed : function ( +str, +texturerestype +) +{ +}, + +/** + * @method setTitleFontName + * @param {String} arg0 + */ +setTitleFontName : function ( +str +) +{ +}, + +/** + * @method getCapInsetsNormalRenderer + * @return {rect_object} + */ +getCapInsetsNormalRenderer : function ( +) +{ + return cc.Rect; +}, + +/** + * @method getCapInsetsPressedRenderer + * @return {rect_object} + */ +getCapInsetsPressedRenderer : function ( +) +{ + return cc.Rect; +}, + +/** + * @method loadTextures + * @param {String} arg0 + * @param {String} arg1 + * @param {String} arg2 + * @param {ccui.Widget::TextureResType} arg3 + */ +loadTextures : function ( +str, +str, +str, +texturerestype +) +{ +}, + +/** + * @method isScale9Enabled + * @return {bool} + */ +isScale9Enabled : function ( +) +{ + return false; +}, + +/** + * @method loadTextureNormal + * @param {String} arg0 + * @param {ccui.Widget::TextureResType} arg1 + */ +loadTextureNormal : function ( +str, +texturerestype +) +{ +}, + +/** + * @method setCapInsetsPressedRenderer + * @param {rect_object} arg0 + */ +setCapInsetsPressedRenderer : function ( +rect +) +{ +}, + +/** + * @method getTitleFontSize + * @return {float} + */ +getTitleFontSize : function ( +) +{ + return 0; +}, + +/** + * @method getTitleFontName + * @return {String} + */ +getTitleFontName : function ( +) +{ + return ; +}, + +/** + * @method getTitleColor + * @return {color3b_object} + */ +getTitleColor : function ( +) +{ + return cc.Color3B; +}, + +/** + * @method setPressedActionEnabled + * @param {bool} arg0 + */ +setPressedActionEnabled : function ( +bool +) +{ +}, + +/** + * @method setZoomScale + * @param {float} arg0 + */ +setZoomScale : function ( +float +) +{ +}, + +/** + * @method create +* @param {String} str +* @param {String} str +* @param {String} str +* @param {ccui.Widget::TextureResType} texturerestype +* @return {ccui.Button|ccui.Button} +*/ +create : function( +str, +str, +str, +texturerestype +) +{ + return ccui.Button; +}, + +/** + * @method createInstance + * @return {cc.Ref} + */ +createInstance : function ( +) +{ + return cc.Ref; +}, + +/** + * @method Button + * @constructor + */ +Button : function ( +) +{ +}, + +}; + +/** + * @class CheckBox + */ +ccui.CheckBox = { + +/** + * @method loadTextureBackGroundSelected + * @param {String} arg0 + * @param {ccui.Widget::TextureResType} arg1 + */ +loadTextureBackGroundSelected : function ( +str, +texturerestype +) +{ +}, + +/** + * @method loadTextureBackGroundDisabled + * @param {String} arg0 + * @param {ccui.Widget::TextureResType} arg1 + */ +loadTextureBackGroundDisabled : function ( +str, +texturerestype +) +{ +}, + +/** + * @method setSelected + * @param {bool} arg0 + */ +setSelected : function ( +bool +) +{ +}, + +/** + * @method loadTextureFrontCross + * @param {String} arg0 + * @param {ccui.Widget::TextureResType} arg1 + */ +loadTextureFrontCross : function ( +str, +texturerestype +) +{ +}, + +/** + * @method isSelected + * @return {bool} + */ +isSelected : function ( +) +{ + return false; +}, + +/** + * @method init + * @param {String} arg0 + * @param {String} arg1 + * @param {String} arg2 + * @param {String} arg3 + * @param {String} arg4 + * @param {ccui.Widget::TextureResType} arg5 + * @return {bool} + */ +init : function ( +str, +str, +str, +str, +str, +texturerestype +) +{ + return false; +}, + +/** + * @method loadTextures + * @param {String} arg0 + * @param {String} arg1 + * @param {String} arg2 + * @param {String} arg3 + * @param {String} arg4 + * @param {ccui.Widget::TextureResType} arg5 + */ +loadTextures : function ( +str, +str, +str, +str, +str, +texturerestype +) +{ +}, + +/** + * @method getZoomScale + * @return {float} + */ +getZoomScale : function ( +) +{ + return 0; +}, + +/** + * @method loadTextureBackGround + * @param {String} arg0 + * @param {ccui.Widget::TextureResType} arg1 + */ +loadTextureBackGround : function ( +str, +texturerestype +) +{ +}, + +/** + * @method setZoomScale + * @param {float} arg0 + */ +setZoomScale : function ( +float +) +{ +}, + +/** + * @method loadTextureFrontCrossDisabled + * @param {String} arg0 + * @param {ccui.Widget::TextureResType} arg1 + */ +loadTextureFrontCrossDisabled : function ( +str, +texturerestype +) +{ +}, + +/** + * @method create +* @param {String|String} str +* @param {String|String} str +* @param {String|ccui.Widget::TextureResType} str +* @param {String} str +* @param {String} str +* @param {ccui.Widget::TextureResType} texturerestype +* @return {ccui.CheckBox|ccui.CheckBox|ccui.CheckBox} +*/ +create : function( +str, +str, +str, +str, +str, +texturerestype +) +{ + return ccui.CheckBox; +}, + +/** + * @method createInstance + * @return {cc.Ref} + */ +createInstance : function ( +) +{ + return cc.Ref; +}, + +/** + * @method CheckBox + * @constructor + */ +CheckBox : function ( +) +{ +}, + +}; + +/** + * @class ImageView + */ +ccui.ImageView = { + +/** + * @method loadTexture + * @param {String} arg0 + * @param {ccui.Widget::TextureResType} arg1 + */ +loadTexture : function ( +str, +texturerestype +) +{ +}, + +/** + * @method init + * @param {String} arg0 + * @param {ccui.Widget::TextureResType} arg1 + * @return {bool} + */ +init : function ( +str, +texturerestype +) +{ + return false; +}, + +/** + * @method setScale9Enabled + * @param {bool} arg0 + */ +setScale9Enabled : function ( +bool +) +{ +}, + +/** + * @method setTextureRect + * @param {rect_object} arg0 + */ +setTextureRect : function ( +rect +) +{ +}, + +/** + * @method setCapInsets + * @param {rect_object} arg0 + */ +setCapInsets : function ( +rect +) +{ +}, + +/** + * @method getCapInsets + * @return {rect_object} + */ +getCapInsets : function ( +) +{ + return cc.Rect; +}, + +/** + * @method isScale9Enabled + * @return {bool} + */ +isScale9Enabled : function ( +) +{ + return false; +}, + +/** + * @method create +* @param {String} str +* @param {ccui.Widget::TextureResType} texturerestype +* @return {ccui.ImageView|ccui.ImageView} +*/ +create : function( +str, +texturerestype +) +{ + return ccui.ImageView; +}, + +/** + * @method createInstance + * @return {cc.Ref} + */ +createInstance : function ( +) +{ + return cc.Ref; +}, + +/** + * @method ImageView + * @constructor + */ +ImageView : function ( +) +{ +}, + +}; + +/** + * @class Text + */ +ccui.Text = { + +/** + * @method enableShadow + */ +enableShadow : function ( +) +{ +}, + +/** + * @method getFontSize + * @return {int} + */ +getFontSize : function ( +) +{ + return 0; +}, + +/** + * @method getString + * @return {String} + */ +getString : function ( +) +{ + return ; +}, + +/** + * @method disableEffect +* @param {cc.LabelEffect} labeleffect +*/ +disableEffect : function( +labeleffect +) +{ +}, + +/** + * @method getTextColor + * @return {color4b_object} + */ +getTextColor : function ( +) +{ + return cc.Color4B; +}, + +/** + * @method setTextVerticalAlignment + * @param {cc.TextVAlignment} arg0 + */ +setTextVerticalAlignment : function ( +textvalignment +) +{ +}, + +/** + * @method setFontName + * @param {String} arg0 + */ +setFontName : function ( +str +) +{ +}, + +/** + * @method setTouchScaleChangeEnabled + * @param {bool} arg0 + */ +setTouchScaleChangeEnabled : function ( +bool +) +{ +}, + +/** + * @method setString + * @param {String} arg0 + */ +setString : function ( +str +) +{ +}, + +/** + * @method init + * @param {String} arg0 + * @param {String} arg1 + * @param {int} arg2 + * @return {bool} + */ +init : function ( +str, +str, +int +) +{ + return false; +}, + +/** + * @method isTouchScaleChangeEnabled + * @return {bool} + */ +isTouchScaleChangeEnabled : function ( +) +{ + return false; +}, + +/** + * @method getFontName + * @return {String} + */ +getFontName : function ( +) +{ + return ; +}, + +/** + * @method setTextAreaSize + * @param {size_object} arg0 + */ +setTextAreaSize : function ( +size +) +{ +}, + +/** + * @method getStringLength + * @return {long} + */ +getStringLength : function ( +) +{ + return 0; +}, + +/** + * @method getAutoRenderSize + * @return {size_object} + */ +getAutoRenderSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method enableOutline + * @param {color4b_object} arg0 + * @param {int} arg1 + */ +enableOutline : function ( +color4b, +int +) +{ +}, + +/** + * @method getType + * @return {ccui.Text::Type} + */ +getType : function ( +) +{ + return 0; +}, + +/** + * @method getTextHorizontalAlignment + * @return {cc.TextHAlignment} + */ +getTextHorizontalAlignment : function ( +) +{ + return 0; +}, + +/** + * @method setFontSize + * @param {int} arg0 + */ +setFontSize : function ( +int +) +{ +}, + +/** + * @method setTextColor + * @param {color4b_object} arg0 + */ +setTextColor : function ( +color4b +) +{ +}, + +/** + * @method enableGlow + * @param {color4b_object} arg0 + */ +enableGlow : function ( +color4b +) +{ +}, + +/** + * @method getTextVerticalAlignment + * @return {cc.TextVAlignment} + */ +getTextVerticalAlignment : function ( +) +{ + return 0; +}, + +/** + * @method getTextAreaSize + * @return {size_object} + */ +getTextAreaSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method setTextHorizontalAlignment + * @param {cc.TextHAlignment} arg0 + */ +setTextHorizontalAlignment : function ( +texthalignment +) +{ +}, + +/** + * @method create +* @param {String} str +* @param {String} str +* @param {int} int +* @return {ccui.Text|ccui.Text} +*/ +create : function( +str, +str, +int +) +{ + return ccui.Text; +}, + +/** + * @method createInstance + * @return {cc.Ref} + */ +createInstance : function ( +) +{ + return cc.Ref; +}, + +/** + * @method Text + * @constructor + */ +Text : function ( +) +{ +}, + +}; + +/** + * @class TextAtlas + */ +ccui.TextAtlas = { + +/** + * @method getStringLength + * @return {long} + */ +getStringLength : function ( +) +{ + return 0; +}, + +/** + * @method getString + * @return {String} + */ +getString : function ( +) +{ + return ; +}, + +/** + * @method setString + * @param {String} arg0 + */ +setString : function ( +str +) +{ +}, + +/** + * @method setProperty + * @param {String} arg0 + * @param {String} arg1 + * @param {int} arg2 + * @param {int} arg3 + * @param {String} arg4 + */ +setProperty : function ( +str, +str, +int, +int, +str +) +{ +}, + +/** + * @method adaptRenderers + */ +adaptRenderers : function ( +) +{ +}, + +/** + * @method create +* @param {String} str +* @param {String} str +* @param {int} int +* @param {int} int +* @param {String} str +* @return {ccui.TextAtlas|ccui.TextAtlas} +*/ +create : function( +str, +str, +int, +int, +str +) +{ + return ccui.TextAtlas; +}, + +/** + * @method createInstance + * @return {cc.Ref} + */ +createInstance : function ( +) +{ + return cc.Ref; +}, + +/** + * @method TextAtlas + * @constructor + */ +TextAtlas : function ( +) +{ +}, + +}; + +/** + * @class LoadingBar + */ +ccui.LoadingBar = { + +/** + * @method setPercent + * @param {float} arg0 + */ +setPercent : function ( +float +) +{ +}, + +/** + * @method loadTexture + * @param {String} arg0 + * @param {ccui.Widget::TextureResType} arg1 + */ +loadTexture : function ( +str, +texturerestype +) +{ +}, + +/** + * @method setDirection + * @param {ccui.LoadingBar::Direction} arg0 + */ +setDirection : function ( +direction +) +{ +}, + +/** + * @method setScale9Enabled + * @param {bool} arg0 + */ +setScale9Enabled : function ( +bool +) +{ +}, + +/** + * @method setCapInsets + * @param {rect_object} arg0 + */ +setCapInsets : function ( +rect +) +{ +}, + +/** + * @method getDirection + * @return {ccui.LoadingBar::Direction} + */ +getDirection : function ( +) +{ + return 0; +}, + +/** + * @method getCapInsets + * @return {rect_object} + */ +getCapInsets : function ( +) +{ + return cc.Rect; +}, + +/** + * @method isScale9Enabled + * @return {bool} + */ +isScale9Enabled : function ( +) +{ + return false; +}, + +/** + * @method getPercent + * @return {float} + */ +getPercent : function ( +) +{ + return 0; +}, + +/** + * @method create +* @param {String|String} str +* @param {float|ccui.Widget::TextureResType} float +* @param {float} float +* @return {ccui.LoadingBar|ccui.LoadingBar|ccui.LoadingBar} +*/ +create : function( +str, +texturerestype, +float +) +{ + return ccui.LoadingBar; +}, + +/** + * @method createInstance + * @return {cc.Ref} + */ +createInstance : function ( +) +{ + return cc.Ref; +}, + +/** + * @method LoadingBar + * @constructor + */ +LoadingBar : function ( +) +{ +}, + +}; + +/** + * @class ScrollView + */ +ccui.ScrollView = { + +/** + * @method scrollToTop + * @param {float} arg0 + * @param {bool} arg1 + */ +scrollToTop : function ( +float, +bool +) +{ +}, + +/** + * @method scrollToPercentHorizontal + * @param {float} arg0 + * @param {float} arg1 + * @param {bool} arg2 + */ +scrollToPercentHorizontal : function ( +float, +float, +bool +) +{ +}, + +/** + * @method isInertiaScrollEnabled + * @return {bool} + */ +isInertiaScrollEnabled : function ( +) +{ + return false; +}, + +/** + * @method scrollToPercentBothDirection + * @param {vec2_object} arg0 + * @param {float} arg1 + * @param {bool} arg2 + */ +scrollToPercentBothDirection : function ( +vec2, +float, +bool +) +{ +}, + +/** + * @method getDirection + * @return {ccui.ScrollView::Direction} + */ +getDirection : function ( +) +{ + return 0; +}, + +/** + * @method scrollToBottomLeft + * @param {float} arg0 + * @param {bool} arg1 + */ +scrollToBottomLeft : function ( +float, +bool +) +{ +}, + +/** + * @method getInnerContainer + * @return {ccui.Layout} + */ +getInnerContainer : function ( +) +{ + return ccui.Layout; +}, + +/** + * @method jumpToBottom + */ +jumpToBottom : function ( +) +{ +}, + +/** + * @method setDirection + * @param {ccui.ScrollView::Direction} arg0 + */ +setDirection : function ( +direction +) +{ +}, + +/** + * @method scrollToTopLeft + * @param {float} arg0 + * @param {bool} arg1 + */ +scrollToTopLeft : function ( +float, +bool +) +{ +}, + +/** + * @method jumpToTopRight + */ +jumpToTopRight : function ( +) +{ +}, + +/** + * @method jumpToBottomLeft + */ +jumpToBottomLeft : function ( +) +{ +}, + +/** + * @method setInnerContainerSize + * @param {size_object} arg0 + */ +setInnerContainerSize : function ( +size +) +{ +}, + +/** + * @method getInnerContainerSize + * @return {size_object} + */ +getInnerContainerSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method isBounceEnabled + * @return {bool} + */ +isBounceEnabled : function ( +) +{ + return false; +}, + +/** + * @method jumpToPercentVertical + * @param {float} arg0 + */ +jumpToPercentVertical : function ( +float +) +{ +}, + +/** + * @method setInertiaScrollEnabled + * @param {bool} arg0 + */ +setInertiaScrollEnabled : function ( +bool +) +{ +}, + +/** + * @method jumpToTopLeft + */ +jumpToTopLeft : function ( +) +{ +}, + +/** + * @method jumpToPercentHorizontal + * @param {float} arg0 + */ +jumpToPercentHorizontal : function ( +float +) +{ +}, + +/** + * @method jumpToBottomRight + */ +jumpToBottomRight : function ( +) +{ +}, + +/** + * @method setBounceEnabled + * @param {bool} arg0 + */ +setBounceEnabled : function ( +bool +) +{ +}, + +/** + * @method jumpToTop + */ +jumpToTop : function ( +) +{ +}, + +/** + * @method scrollToLeft + * @param {float} arg0 + * @param {bool} arg1 + */ +scrollToLeft : function ( +float, +bool +) +{ +}, + +/** + * @method jumpToPercentBothDirection + * @param {vec2_object} arg0 + */ +jumpToPercentBothDirection : function ( +vec2 +) +{ +}, + +/** + * @method scrollToPercentVertical + * @param {float} arg0 + * @param {float} arg1 + * @param {bool} arg2 + */ +scrollToPercentVertical : function ( +float, +float, +bool +) +{ +}, + +/** + * @method scrollToBottom + * @param {float} arg0 + * @param {bool} arg1 + */ +scrollToBottom : function ( +float, +bool +) +{ +}, + +/** + * @method scrollToBottomRight + * @param {float} arg0 + * @param {bool} arg1 + */ +scrollToBottomRight : function ( +float, +bool +) +{ +}, + +/** + * @method jumpToLeft + */ +jumpToLeft : function ( +) +{ +}, + +/** + * @method scrollToRight + * @param {float} arg0 + * @param {bool} arg1 + */ +scrollToRight : function ( +float, +bool +) +{ +}, + +/** + * @method jumpToRight + */ +jumpToRight : function ( +) +{ +}, + +/** + * @method scrollToTopRight + * @param {float} arg0 + * @param {bool} arg1 + */ +scrollToTopRight : function ( +float, +bool +) +{ +}, + +/** + * @method create + * @return {ccui.ScrollView} + */ +create : function ( +) +{ + return ccui.ScrollView; +}, + +/** + * @method createInstance + * @return {cc.Ref} + */ +createInstance : function ( +) +{ + return cc.Ref; +}, + +/** + * @method ScrollView + * @constructor + */ +ScrollView : function ( +) +{ +}, + +}; + +/** + * @class ListView + */ +ccui.ListView = { + +/** + * @method getIndex + * @param {ccui.Widget} arg0 + * @return {long} + */ +getIndex : function ( +widget +) +{ + return 0; +}, + +/** + * @method removeAllItems + */ +removeAllItems : function ( +) +{ +}, + +/** + * @method setGravity + * @param {ccui.ListView::Gravity} arg0 + */ +setGravity : function ( +gravity +) +{ +}, + +/** + * @method pushBackCustomItem + * @param {ccui.Widget} arg0 + */ +pushBackCustomItem : function ( +widget +) +{ +}, + +/** + * @method getItems + * @return {Array} + */ +getItems : function ( +) +{ + return new Array(); +}, + +/** + * @method removeItem + * @param {long} arg0 + */ +removeItem : function ( +long +) +{ +}, + +/** + * @method getCurSelectedIndex + * @return {long} + */ +getCurSelectedIndex : function ( +) +{ + return 0; +}, + +/** + * @method insertDefaultItem + * @param {long} arg0 + */ +insertDefaultItem : function ( +long +) +{ +}, + +/** + * @method requestRefreshView + */ +requestRefreshView : function ( +) +{ +}, + +/** + * @method setItemsMargin + * @param {float} arg0 + */ +setItemsMargin : function ( +float +) +{ +}, + +/** + * @method refreshView + */ +refreshView : function ( +) +{ +}, + +/** + * @method removeLastItem + */ +removeLastItem : function ( +) +{ +}, + +/** + * @method getItemsMargin + * @return {float} + */ +getItemsMargin : function ( +) +{ + return 0; +}, + +/** + * @method getItem + * @param {long} arg0 + * @return {ccui.Widget} + */ +getItem : function ( +long +) +{ + return ccui.Widget; +}, + +/** + * @method setItemModel + * @param {ccui.Widget} arg0 + */ +setItemModel : function ( +widget +) +{ +}, + +/** + * @method doLayout + */ +doLayout : function ( +) +{ +}, + +/** + * @method pushBackDefaultItem + */ +pushBackDefaultItem : function ( +) +{ +}, + +/** + * @method insertCustomItem + * @param {ccui.Widget} arg0 + * @param {long} arg1 + */ +insertCustomItem : function ( +widget, +long +) +{ +}, + +/** + * @method create + * @return {ccui.ListView} + */ +create : function ( +) +{ + return ccui.ListView; +}, + +/** + * @method createInstance + * @return {cc.Ref} + */ +createInstance : function ( +) +{ + return cc.Ref; +}, + +/** + * @method ListView + * @constructor + */ +ListView : function ( +) +{ +}, + +}; + +/** + * @class Slider + */ +ccui.Slider = { + +/** + * @method setPercent + * @param {int} arg0 + */ +setPercent : function ( +int +) +{ +}, + +/** + * @method loadSlidBallTextureDisabled + * @param {String} arg0 + * @param {ccui.Widget::TextureResType} arg1 + */ +loadSlidBallTextureDisabled : function ( +str, +texturerestype +) +{ +}, + +/** + * @method loadSlidBallTextureNormal + * @param {String} arg0 + * @param {ccui.Widget::TextureResType} arg1 + */ +loadSlidBallTextureNormal : function ( +str, +texturerestype +) +{ +}, + +/** + * @method loadBarTexture + * @param {String} arg0 + * @param {ccui.Widget::TextureResType} arg1 + */ +loadBarTexture : function ( +str, +texturerestype +) +{ +}, + +/** + * @method loadProgressBarTexture + * @param {String} arg0 + * @param {ccui.Widget::TextureResType} arg1 + */ +loadProgressBarTexture : function ( +str, +texturerestype +) +{ +}, + +/** + * @method loadSlidBallTextures + * @param {String} arg0 + * @param {String} arg1 + * @param {String} arg2 + * @param {ccui.Widget::TextureResType} arg3 + */ +loadSlidBallTextures : function ( +str, +str, +str, +texturerestype +) +{ +}, + +/** + * @method setCapInsetProgressBarRebderer + * @param {rect_object} arg0 + */ +setCapInsetProgressBarRebderer : function ( +rect +) +{ +}, + +/** + * @method setCapInsetsBarRenderer + * @param {rect_object} arg0 + */ +setCapInsetsBarRenderer : function ( +rect +) +{ +}, + +/** + * @method getCapInsetsProgressBarRebderer + * @return {rect_object} + */ +getCapInsetsProgressBarRebderer : function ( +) +{ + return cc.Rect; +}, + +/** + * @method setScale9Enabled + * @param {bool} arg0 + */ +setScale9Enabled : function ( +bool +) +{ +}, + +/** + * @method setZoomScale + * @param {float} arg0 + */ +setZoomScale : function ( +float +) +{ +}, + +/** + * @method setCapInsets + * @param {rect_object} arg0 + */ +setCapInsets : function ( +rect +) +{ +}, + +/** + * @method getZoomScale + * @return {float} + */ +getZoomScale : function ( +) +{ + return 0; +}, + +/** + * @method loadSlidBallTexturePressed + * @param {String} arg0 + * @param {ccui.Widget::TextureResType} arg1 + */ +loadSlidBallTexturePressed : function ( +str, +texturerestype +) +{ +}, + +/** + * @method isScale9Enabled + * @return {bool} + */ +isScale9Enabled : function ( +) +{ + return false; +}, + +/** + * @method getCapInsetsBarRenderer + * @return {rect_object} + */ +getCapInsetsBarRenderer : function ( +) +{ + return cc.Rect; +}, + +/** + * @method getPercent + * @return {int} + */ +getPercent : function ( +) +{ + return 0; +}, + +/** + * @method create +* @param {String} str +* @param {String} str +* @param {ccui.Widget::TextureResType} texturerestype +* @return {ccui.Slider|ccui.Slider} +*/ +create : function( +str, +str, +texturerestype +) +{ + return ccui.Slider; +}, + +/** + * @method createInstance + * @return {cc.Ref} + */ +createInstance : function ( +) +{ + return cc.Ref; +}, + +/** + * @method Slider + * @constructor + */ +Slider : function ( +) +{ +}, + +}; + +/** + * @class UICCTextField + */ +ccui.UICCTextField = { + +/** + * @method onTextFieldAttachWithIME + * @param {cc.TextFieldTTF} arg0 + * @return {bool} + */ +onTextFieldAttachWithIME : function ( +textfieldttf +) +{ + return false; +}, + +/** + * @method setPasswordText + * @param {String} arg0 + */ +setPasswordText : function ( +str +) +{ +}, + +/** + * @method setAttachWithIME + * @param {bool} arg0 + */ +setAttachWithIME : function ( +bool +) +{ +}, + +/** + * @method getDeleteBackward + * @return {bool} + */ +getDeleteBackward : function ( +) +{ + return false; +}, + +/** + * @method getAttachWithIME + * @return {bool} + */ +getAttachWithIME : function ( +) +{ + return false; +}, + +/** + * @method onTextFieldDeleteBackward + * @param {cc.TextFieldTTF} arg0 + * @param {char} arg1 + * @param {unsigned long} arg2 + * @return {bool} + */ +onTextFieldDeleteBackward : function ( +textfieldttf, +char, +long +) +{ + return false; +}, + +/** + * @method getInsertText + * @return {bool} + */ +getInsertText : function ( +) +{ + return false; +}, + +/** + * @method deleteBackward + */ +deleteBackward : function ( +) +{ +}, + +/** + * @method setInsertText + * @param {bool} arg0 + */ +setInsertText : function ( +bool +) +{ +}, + +/** + * @method getDetachWithIME + * @return {bool} + */ +getDetachWithIME : function ( +) +{ + return false; +}, + +/** + * @method getCharCount + * @return {int} + */ +getCharCount : function ( +) +{ + return 0; +}, + +/** + * @method closeIME + */ +closeIME : function ( +) +{ +}, + +/** + * @method setPasswordEnabled + * @param {bool} arg0 + */ +setPasswordEnabled : function ( +bool +) +{ +}, + +/** + * @method setMaxLengthEnabled + * @param {bool} arg0 + */ +setMaxLengthEnabled : function ( +bool +) +{ +}, + +/** + * @method isPasswordEnabled + * @return {bool} + */ +isPasswordEnabled : function ( +) +{ + return false; +}, + +/** + * @method insertText + * @param {char} arg0 + * @param {unsigned long} arg1 + */ +insertText : function ( +char, +long +) +{ +}, + +/** + * @method setPasswordStyleText + * @param {String} arg0 + */ +setPasswordStyleText : function ( +str +) +{ +}, + +/** + * @method onTextFieldInsertText + * @param {cc.TextFieldTTF} arg0 + * @param {char} arg1 + * @param {unsigned long} arg2 + * @return {bool} + */ +onTextFieldInsertText : function ( +textfieldttf, +char, +long +) +{ + return false; +}, + +/** + * @method onTextFieldDetachWithIME + * @param {cc.TextFieldTTF} arg0 + * @return {bool} + */ +onTextFieldDetachWithIME : function ( +textfieldttf +) +{ + return false; +}, + +/** + * @method getMaxLength + * @return {int} + */ +getMaxLength : function ( +) +{ + return 0; +}, + +/** + * @method isMaxLengthEnabled + * @return {bool} + */ +isMaxLengthEnabled : function ( +) +{ + return false; +}, + +/** + * @method openIME + */ +openIME : function ( +) +{ +}, + +/** + * @method setDetachWithIME + * @param {bool} arg0 + */ +setDetachWithIME : function ( +bool +) +{ +}, + +/** + * @method setMaxLength + * @param {int} arg0 + */ +setMaxLength : function ( +int +) +{ +}, + +/** + * @method setDeleteBackward + * @param {bool} arg0 + */ +setDeleteBackward : function ( +bool +) +{ +}, + +/** + * @method create + * @param {String} arg0 + * @param {String} arg1 + * @param {float} arg2 + * @return {ccui.UICCTextField} + */ +create : function ( +str, +str, +float +) +{ + return ccui.UICCTextField; +}, + +/** + * @method UICCTextField + * @constructor + */ +UICCTextField : function ( +) +{ +}, + +}; + +/** + * @class TextField + */ +ccui.TextField = { + +/** + * @method setAttachWithIME + * @param {bool} arg0 + */ +setAttachWithIME : function ( +bool +) +{ +}, + +/** + * @method getFontSize + * @return {int} + */ +getFontSize : function ( +) +{ + return 0; +}, + +/** + * @method getString + * @return {String} + */ +getString : function ( +) +{ + return ; +}, + +/** + * @method setPasswordStyleText + * @param {char} arg0 + */ +setPasswordStyleText : function ( +char +) +{ +}, + +/** + * @method getDeleteBackward + * @return {bool} + */ +getDeleteBackward : function ( +) +{ + return false; +}, + +/** + * @method getPlaceHolder + * @return {String} + */ +getPlaceHolder : function ( +) +{ + return ; +}, + +/** + * @method getAttachWithIME + * @return {bool} + */ +getAttachWithIME : function ( +) +{ + return false; +}, + +/** + * @method setFontName + * @param {String} arg0 + */ +setFontName : function ( +str +) +{ +}, + +/** + * @method getInsertText + * @return {bool} + */ +getInsertText : function ( +) +{ + return false; +}, + +/** + * @method setInsertText + * @param {bool} arg0 + */ +setInsertText : function ( +bool +) +{ +}, + +/** + * @method setString + * @param {String} arg0 + */ +setString : function ( +str +) +{ +}, + +/** + * @method getDetachWithIME + * @return {bool} + */ +getDetachWithIME : function ( +) +{ + return false; +}, + +/** + * @method setTextVerticalAlignment + * @param {cc.TextVAlignment} arg0 + */ +setTextVerticalAlignment : function ( +textvalignment +) +{ +}, + +/** + * @method didNotSelectSelf + */ +didNotSelectSelf : function ( +) +{ +}, + +/** + * @method getFontName + * @return {String} + */ +getFontName : function ( +) +{ + return ; +}, + +/** + * @method setTextAreaSize + * @param {size_object} arg0 + */ +setTextAreaSize : function ( +size +) +{ +}, + +/** + * @method attachWithIME + */ +attachWithIME : function ( +) +{ +}, + +/** + * @method getStringLength + * @return {int} + */ +getStringLength : function ( +) +{ + return 0; +}, + +/** + * @method getAutoRenderSize + * @return {size_object} + */ +getAutoRenderSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method setPasswordEnabled + * @param {bool} arg0 + */ +setPasswordEnabled : function ( +bool +) +{ +}, + +/** + * @method getPlaceHolderColor + * @return {color4b_object} + */ +getPlaceHolderColor : function ( +) +{ + return cc.Color4B; +}, + +/** + * @method getPasswordStyleText + * @return {char} + */ +getPasswordStyleText : function ( +) +{ + return 0; +}, + +/** + * @method setMaxLengthEnabled + * @param {bool} arg0 + */ +setMaxLengthEnabled : function ( +bool +) +{ +}, + +/** + * @method isPasswordEnabled + * @return {bool} + */ +isPasswordEnabled : function ( +) +{ + return false; +}, + +/** + * @method setDeleteBackward + * @param {bool} arg0 + */ +setDeleteBackward : function ( +bool +) +{ +}, + +/** + * @method setFontSize + * @param {int} arg0 + */ +setFontSize : function ( +int +) +{ +}, + +/** + * @method setPlaceHolder + * @param {String} arg0 + */ +setPlaceHolder : function ( +str +) +{ +}, + +/** + * @method setPlaceHolderColor +* @param {color4b_object|color3b_object} color4b +*/ +setPlaceHolderColor : function( +color3b +) +{ +}, + +/** + * @method setTextHorizontalAlignment + * @param {cc.TextHAlignment} arg0 + */ +setTextHorizontalAlignment : function ( +texthalignment +) +{ +}, + +/** + * @method setTextColor + * @param {color4b_object} arg0 + */ +setTextColor : function ( +color4b +) +{ +}, + +/** + * @method getMaxLength + * @return {int} + */ +getMaxLength : function ( +) +{ + return 0; +}, + +/** + * @method isMaxLengthEnabled + * @return {bool} + */ +isMaxLengthEnabled : function ( +) +{ + return false; +}, + +/** + * @method setDetachWithIME + * @param {bool} arg0 + */ +setDetachWithIME : function ( +bool +) +{ +}, + +/** + * @method setTouchAreaEnabled + * @param {bool} arg0 + */ +setTouchAreaEnabled : function ( +bool +) +{ +}, + +/** + * @method setMaxLength + * @param {int} arg0 + */ +setMaxLength : function ( +int +) +{ +}, + +/** + * @method setTouchSize + * @param {size_object} arg0 + */ +setTouchSize : function ( +size +) +{ +}, + +/** + * @method getTouchSize + * @return {size_object} + */ +getTouchSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method create +* @param {String} str +* @param {String} str +* @param {int} int +* @return {ccui.TextField|ccui.TextField} +*/ +create : function( +str, +str, +int +) +{ + return ccui.TextField; +}, + +/** + * @method createInstance + * @return {cc.Ref} + */ +createInstance : function ( +) +{ + return cc.Ref; +}, + +/** + * @method TextField + * @constructor + */ +TextField : function ( +) +{ +}, + +}; + +/** + * @class TextBMFont + */ +ccui.TextBMFont = { + +/** + * @method setFntFile + * @param {String} arg0 + */ +setFntFile : function ( +str +) +{ +}, + +/** + * @method getStringLength + * @return {long} + */ +getStringLength : function ( +) +{ + return 0; +}, + +/** + * @method setString + * @param {String} arg0 + */ +setString : function ( +str +) +{ +}, + +/** + * @method getString + * @return {String} + */ +getString : function ( +) +{ + return ; +}, + +/** + * @method create +* @param {String} str +* @param {String} str +* @return {ccui.TextBMFont|ccui.TextBMFont} +*/ +create : function( +str, +str +) +{ + return ccui.TextBMFont; +}, + +/** + * @method createInstance + * @return {cc.Ref} + */ +createInstance : function ( +) +{ + return cc.Ref; +}, + +/** + * @method TextBMFont + * @constructor + */ +TextBMFont : function ( +) +{ +}, + +}; + +/** + * @class PageView + */ +ccui.PageView = { + +/** + * @method getCustomScrollThreshold + * @return {float} + */ +getCustomScrollThreshold : function ( +) +{ + return 0; +}, + +/** + * @method getCurPageIndex + * @return {long} + */ +getCurPageIndex : function ( +) +{ + return 0; +}, + +/** + * @method addWidgetToPage + * @param {ccui.Widget} arg0 + * @param {long} arg1 + * @param {bool} arg2 + */ +addWidgetToPage : function ( +widget, +long, +bool +) +{ +}, + +/** + * @method isUsingCustomScrollThreshold + * @return {bool} + */ +isUsingCustomScrollThreshold : function ( +) +{ + return false; +}, + +/** + * @method getPage + * @param {long} arg0 + * @return {ccui.Layout} + */ +getPage : function ( +long +) +{ + return ccui.Layout; +}, + +/** + * @method removePage + * @param {ccui.Layout} arg0 + */ +removePage : function ( +layout +) +{ +}, + +/** + * @method setUsingCustomScrollThreshold + * @param {bool} arg0 + */ +setUsingCustomScrollThreshold : function ( +bool +) +{ +}, + +/** + * @method setCustomScrollThreshold + * @param {float} arg0 + */ +setCustomScrollThreshold : function ( +float +) +{ +}, + +/** + * @method insertPage + * @param {ccui.Layout} arg0 + * @param {int} arg1 + */ +insertPage : function ( +layout, +int +) +{ +}, + +/** + * @method scrollToPage + * @param {long} arg0 + */ +scrollToPage : function ( +long +) +{ +}, + +/** + * @method removePageAtIndex + * @param {long} arg0 + */ +removePageAtIndex : function ( +long +) +{ +}, + +/** + * @method getPages + * @return {Array} + */ +getPages : function ( +) +{ + return new Array(); +}, + +/** + * @method removeAllPages + */ +removeAllPages : function ( +) +{ +}, + +/** + * @method addPage + * @param {ccui.Layout} arg0 + */ +addPage : function ( +layout +) +{ +}, + +/** + * @method create + * @return {ccui.PageView} + */ +create : function ( +) +{ + return ccui.PageView; +}, + +/** + * @method createInstance + * @return {cc.Ref} + */ +createInstance : function ( +) +{ + return cc.Ref; +}, + +/** + * @method PageView + * @constructor + */ +PageView : function ( +) +{ +}, + +}; + +/** + * @class Helper + */ +ccui.Helper = { + +/** + * @method getSubStringOfUTF8String + * @param {String} arg0 + * @param {unsigned long} arg1 + * @param {unsigned long} arg2 + * @return {String} + */ +getSubStringOfUTF8String : function ( +str, +long, +long +) +{ + return ; +}, + +/** + * @method changeLayoutSystemActiveState + * @param {bool} arg0 + */ +changeLayoutSystemActiveState : function ( +bool +) +{ +}, + +/** + * @method seekActionWidgetByActionTag + * @param {ccui.Widget} arg0 + * @param {int} arg1 + * @return {ccui.Widget} + */ +seekActionWidgetByActionTag : function ( +widget, +int +) +{ + return ccui.Widget; +}, + +/** + * @method seekWidgetByName + * @param {ccui.Widget} arg0 + * @param {String} arg1 + * @return {ccui.Widget} + */ +seekWidgetByName : function ( +widget, +str +) +{ + return ccui.Widget; +}, + +/** + * @method seekWidgetByTag + * @param {ccui.Widget} arg0 + * @param {int} arg1 + * @return {ccui.Widget} + */ +seekWidgetByTag : function ( +widget, +int +) +{ + return ccui.Widget; +}, + +/** + * @method restrictCapInsetRect + * @param {rect_object} arg0 + * @param {size_object} arg1 + * @return {rect_object} + */ +restrictCapInsetRect : function ( +rect, +size +) +{ + return cc.Rect; +}, + +/** + * @method doLayout + * @param {cc.Node} arg0 + */ +doLayout : function ( +node +) +{ +}, + +}; + +/** + * @class RichElement + */ +ccui.RichElement = { + +/** + * @method init + * @param {int} arg0 + * @param {color3b_object} arg1 + * @param {unsigned char} arg2 + * @return {bool} + */ +init : function ( +int, +color3b, +char +) +{ + return false; +}, + +/** + * @method RichElement + * @constructor + */ +RichElement : function ( +) +{ +}, + +}; + +/** + * @class RichElementText + */ +ccui.RichElementText = { + +/** + * @method init + * @param {int} arg0 + * @param {color3b_object} arg1 + * @param {unsigned char} arg2 + * @param {String} arg3 + * @param {String} arg4 + * @param {float} arg5 + * @return {bool} + */ +init : function ( +int, +color3b, +char, +str, +str, +float +) +{ + return false; +}, + +/** + * @method create + * @param {int} arg0 + * @param {color3b_object} arg1 + * @param {unsigned char} arg2 + * @param {String} arg3 + * @param {String} arg4 + * @param {float} arg5 + * @return {ccui.RichElementText} + */ +create : function ( +int, +color3b, +char, +str, +str, +float +) +{ + return ccui.RichElementText; +}, + +/** + * @method RichElementText + * @constructor + */ +RichElementText : function ( +) +{ +}, + +}; + +/** + * @class RichElementImage + */ +ccui.RichElementImage = { + +/** + * @method init + * @param {int} arg0 + * @param {color3b_object} arg1 + * @param {unsigned char} arg2 + * @param {String} arg3 + * @return {bool} + */ +init : function ( +int, +color3b, +char, +str +) +{ + return false; +}, + +/** + * @method create + * @param {int} arg0 + * @param {color3b_object} arg1 + * @param {unsigned char} arg2 + * @param {String} arg3 + * @return {ccui.RichElementImage} + */ +create : function ( +int, +color3b, +char, +str +) +{ + return ccui.RichElementImage; +}, + +/** + * @method RichElementImage + * @constructor + */ +RichElementImage : function ( +) +{ +}, + +}; + +/** + * @class RichElementCustomNode + */ +ccui.RichElementCustomNode = { + +/** + * @method init + * @param {int} arg0 + * @param {color3b_object} arg1 + * @param {unsigned char} arg2 + * @param {cc.Node} arg3 + * @return {bool} + */ +init : function ( +int, +color3b, +char, +node +) +{ + return false; +}, + +/** + * @method create + * @param {int} arg0 + * @param {color3b_object} arg1 + * @param {unsigned char} arg2 + * @param {cc.Node} arg3 + * @return {ccui.RichElementCustomNode} + */ +create : function ( +int, +color3b, +char, +node +) +{ + return ccui.RichElementCustomNode; +}, + +/** + * @method RichElementCustomNode + * @constructor + */ +RichElementCustomNode : function ( +) +{ +}, + +}; + +/** + * @class RichText + */ +ccui.RichText = { + +/** + * @method insertElement + * @param {ccui.RichElement} arg0 + * @param {int} arg1 + */ +insertElement : function ( +richelement, +int +) +{ +}, + +/** + * @method pushBackElement + * @param {ccui.RichElement} arg0 + */ +pushBackElement : function ( +richelement +) +{ +}, + +/** + * @method setVerticalSpace + * @param {float} arg0 + */ +setVerticalSpace : function ( +float +) +{ +}, + +/** + * @method formatText + */ +formatText : function ( +) +{ +}, + +/** + * @method removeElement +* @param {ccui.RichElement|int} richelement +*/ +removeElement : function( +int +) +{ +}, + +/** + * @method create + * @return {ccui.RichText} + */ +create : function ( +) +{ + return ccui.RichText; +}, + +/** + * @method RichText + * @constructor + */ +RichText : function ( +) +{ +}, + +}; + +/** + * @class HBox + */ +ccui.HBox = { + +/** + * @method initWithSize + * @param {size_object} arg0 + * @return {bool} + */ +initWithSize : function ( +size +) +{ + return false; +}, + +/** + * @method create +* @param {size_object} size +* @return {ccui.HBox|ccui.HBox} +*/ +create : function( +size +) +{ + return ccui.HBox; +}, + +/** + * @method HBox + * @constructor + */ +HBox : function ( +) +{ +}, + +}; + +/** + * @class VBox + */ +ccui.VBox = { + +/** + * @method initWithSize + * @param {size_object} arg0 + * @return {bool} + */ +initWithSize : function ( +size +) +{ + return false; +}, + +/** + * @method create +* @param {size_object} size +* @return {ccui.VBox|ccui.VBox} +*/ +create : function( +size +) +{ + return ccui.VBox; +}, + +/** + * @method VBox + * @constructor + */ +VBox : function ( +) +{ +}, + +}; + +/** + * @class RelativeBox + */ +ccui.RelativeBox = { + +/** + * @method initWithSize + * @param {size_object} arg0 + * @return {bool} + */ +initWithSize : function ( +size +) +{ + return false; +}, + +/** + * @method create +* @param {size_object} size +* @return {ccui.RelativeBox|ccui.RelativeBox} +*/ +create : function( +size +) +{ + return ccui.RelativeBox; +}, + +/** + * @method RelativeBox + * @constructor + */ +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 setScale9Enabled + * @param {bool} arg0 + */ +setScale9Enabled : function ( +bool +) +{ +}, + +/** + * @method setFlippedY + * @param {bool} arg0 + */ +setFlippedY : function ( +bool +) +{ +}, + +/** + * @method setFlippedX + * @param {bool} arg0 + */ +setFlippedX : function ( +bool +) +{ +}, + +/** + * @method resizableSpriteWithCapInsets + * @param {rect_object} arg0 + * @return {ccui.Scale9Sprite} + */ +resizableSpriteWithCapInsets : function ( +rect +) +{ + return ccui.Scale9Sprite; +}, + +/** + * @method disableCascadeOpacity + */ +disableCascadeOpacity : function ( +) +{ +}, + +/** + * @method setState + * @param {ccui.Scale9Sprite::State} arg0 + */ +setState : function ( +state +) +{ +}, + +/** + * @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 {rect_object|bool|bool} rect +* @param {rect_object|vec2_object} rect +* @param {size_object} size +* @param {rect_object} rect +* @return {bool|bool|bool} +*/ +init : function( +sprite, +rect, +bool, +vec2, +size, +rect +) +{ + return false; +}, + +/** + * @method setPreferredSize + * @param {size_object} arg0 + */ +setPreferredSize : function ( +size +) +{ +}, + +/** + * @method setSpriteFrame + * @param {cc.SpriteFrame} arg0 + * @param {rect_object} arg1 + */ +setSpriteFrame : function ( +spriteframe, +rect +) +{ +}, + +/** + * @method getBlendFunc + * @return {cc.BlendFunc} + */ +getBlendFunc : function ( +) +{ + return cc.BlendFunc; +}, + +/** + * @method getInsetBottom + * @return {float} + */ +getInsetBottom : function ( +) +{ + return 0; +}, + +/** + * @method getCapInsets + * @return {rect_object} + */ +getCapInsets : function ( +) +{ + return cc.Rect; +}, + +/** + * @method isScale9Enabled + * @return {bool} + */ +isScale9Enabled : function ( +) +{ + return false; +}, + +/** + * @method getInsetRight + * @return {float} + */ +getInsetRight : function ( +) +{ + return 0; +}, + +/** + * @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 setBlendFunc + * @param {cc.BlendFunc} arg0 + */ +setBlendFunc : function ( +blendfunc +) +{ +}, + +/** + * @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 + */ +ccui.EditBox = { + +/** + * @method getText + * @return {char} + */ +getText : function ( +) +{ + return 0; +}, + +/** + * @method setFontSize + * @param {int} arg0 + */ +setFontSize : function ( +int +) +{ +}, + +/** + * @method setPlaceholderFontName + * @param {char} arg0 + */ +setPlaceholderFontName : function ( +char +) +{ +}, + +/** + * @method getPlaceHolder + * @return {char} + */ +getPlaceHolder : function ( +) +{ + return 0; +}, + +/** + * @method setFontName + * @param {char} arg0 + */ +setFontName : function ( +char +) +{ +}, + +/** + * @method setText + * @param {char} arg0 + */ +setText : function ( +char +) +{ +}, + +/** + * @method setPlaceholderFontSize + * @param {int} arg0 + */ +setPlaceholderFontSize : function ( +int +) +{ +}, + +/** + * @method setInputMode + * @param {ccui.EditBox::InputMode} arg0 + */ +setInputMode : function ( +inputmode +) +{ +}, + +/** + * @method setPlaceholderFontColor +* @param {color4b_object|color3b_object} color4b +*/ +setPlaceholderFontColor : function( +color3b +) +{ +}, + +/** + * @method setFontColor +* @param {color4b_object|color3b_object} color4b +*/ +setFontColor : function( +color3b +) +{ +}, + +/** + * @method setPlaceholderFont + * @param {char} arg0 + * @param {int} arg1 + */ +setPlaceholderFont : function ( +char, +int +) +{ +}, + +/** + * @method initWithSizeAndBackgroundSprite +* @param {size_object|size_object} size +* @param {ccui.Scale9Sprite|String} scale9sprite +* @param {ccui.Widget::TextureResType} texturerestype +* @return {bool|bool} +*/ +initWithSizeAndBackgroundSprite : function( +size, +str, +texturerestype +) +{ + return false; +}, + +/** + * @method setPlaceHolder + * @param {char} arg0 + */ +setPlaceHolder : function ( +char +) +{ +}, + +/** + * @method setReturnType + * @param {ccui.EditBox::KeyboardReturnType} arg0 + */ +setReturnType : function ( +keyboardreturntype +) +{ +}, + +/** + * @method setInputFlag + * @param {ccui.EditBox::InputFlag} arg0 + */ +setInputFlag : function ( +inputflag +) +{ +}, + +/** + * @method getMaxLength + * @return {int} + */ +getMaxLength : function ( +) +{ + return 0; +}, + +/** + * @method setMaxLength + * @param {int} arg0 + */ +setMaxLength : function ( +int +) +{ +}, + +/** + * @method setFont + * @param {char} arg0 + * @param {int} arg1 + */ +setFont : function ( +char, +int +) +{ +}, + +/** + * @method create +* @param {size_object|size_object} size +* @param {String|ccui.Scale9Sprite} str +* @param {ccui.Widget::TextureResType|ccui.Scale9Sprite} texturerestype +* @param {ccui.Scale9Sprite} scale9sprite +* @return {ccui.EditBox|ccui.EditBox} +*/ +create : function( +size, +scale9sprite, +scale9sprite, +scale9sprite +) +{ + return ccui.EditBox; +}, + +/** + * @method EditBox + * @constructor + */ +EditBox : function ( +) +{ +}, + +}; + +/** + * @class LayoutComponent + */ +ccui.LayoutComponent = { + +/** + * @method setStretchWidthEnabled + * @param {bool} arg0 + */ +setStretchWidthEnabled : function ( +bool +) +{ +}, + +/** + * @method setPercentWidth + * @param {float} arg0 + */ +setPercentWidth : function ( +float +) +{ +}, + +/** + * @method getAnchorPosition + * @return {vec2_object} + */ +getAnchorPosition : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method setPositionPercentXEnabled + * @param {bool} arg0 + */ +setPositionPercentXEnabled : function ( +bool +) +{ +}, + +/** + * @method setStretchHeightEnabled + * @param {bool} arg0 + */ +setStretchHeightEnabled : function ( +bool +) +{ +}, + +/** + * @method setActiveEnabled + * @param {bool} arg0 + */ +setActiveEnabled : function ( +bool +) +{ +}, + +/** + * @method getRightMargin + * @return {float} + */ +getRightMargin : function ( +) +{ + return 0; +}, + +/** + * @method getSize + * @return {size_object} + */ +getSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method setAnchorPosition + * @param {vec2_object} arg0 + */ +setAnchorPosition : function ( +vec2 +) +{ +}, + +/** + * @method refreshLayout + */ +refreshLayout : function ( +) +{ +}, + +/** + * @method isPercentWidthEnabled + * @return {bool} + */ +isPercentWidthEnabled : function ( +) +{ + return false; +}, + +/** + * @method setVerticalEdge + * @param {ccui.LayoutComponent::VerticalEdge} arg0 + */ +setVerticalEdge : function ( +verticaledge +) +{ +}, + +/** + * @method getTopMargin + * @return {float} + */ +getTopMargin : function ( +) +{ + return 0; +}, + +/** + * @method setSizeWidth + * @param {float} arg0 + */ +setSizeWidth : function ( +float +) +{ +}, + +/** + * @method getPercentContentSize + * @return {vec2_object} + */ +getPercentContentSize : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method getVerticalEdge + * @return {ccui.LayoutComponent::VerticalEdge} + */ +getVerticalEdge : function ( +) +{ + return 0; +}, + +/** + * @method setPercentWidthEnabled + * @param {bool} arg0 + */ +setPercentWidthEnabled : function ( +bool +) +{ +}, + +/** + * @method isStretchWidthEnabled + * @return {bool} + */ +isStretchWidthEnabled : function ( +) +{ + return false; +}, + +/** + * @method setLeftMargin + * @param {float} arg0 + */ +setLeftMargin : function ( +float +) +{ +}, + +/** + * @method getSizeWidth + * @return {float} + */ +getSizeWidth : function ( +) +{ + return 0; +}, + +/** + * @method setPositionPercentYEnabled + * @param {bool} arg0 + */ +setPositionPercentYEnabled : function ( +bool +) +{ +}, + +/** + * @method getSizeHeight + * @return {float} + */ +getSizeHeight : function ( +) +{ + return 0; +}, + +/** + * @method getPositionPercentY + * @return {float} + */ +getPositionPercentY : function ( +) +{ + return 0; +}, + +/** + * @method getPositionPercentX + * @return {float} + */ +getPositionPercentX : function ( +) +{ + return 0; +}, + +/** + * @method setTopMargin + * @param {float} arg0 + */ +setTopMargin : function ( +float +) +{ +}, + +/** + * @method getPercentHeight + * @return {float} + */ +getPercentHeight : function ( +) +{ + return 0; +}, + +/** + * @method getUsingPercentContentSize + * @return {bool} + */ +getUsingPercentContentSize : function ( +) +{ + return false; +}, + +/** + * @method setPositionPercentY + * @param {float} arg0 + */ +setPositionPercentY : function ( +float +) +{ +}, + +/** + * @method setPositionPercentX + * @param {float} arg0 + */ +setPositionPercentX : function ( +float +) +{ +}, + +/** + * @method setRightMargin + * @param {float} arg0 + */ +setRightMargin : function ( +float +) +{ +}, + +/** + * @method isPositionPercentYEnabled + * @return {bool} + */ +isPositionPercentYEnabled : function ( +) +{ + return false; +}, + +/** + * @method setPercentHeight + * @param {float} arg0 + */ +setPercentHeight : function ( +float +) +{ +}, + +/** + * @method setPercentOnlyEnabled + * @param {bool} arg0 + */ +setPercentOnlyEnabled : function ( +bool +) +{ +}, + +/** + * @method setHorizontalEdge + * @param {ccui.LayoutComponent::HorizontalEdge} arg0 + */ +setHorizontalEdge : function ( +horizontaledge +) +{ +}, + +/** + * @method setPosition + * @param {vec2_object} arg0 + */ +setPosition : function ( +vec2 +) +{ +}, + +/** + * @method setUsingPercentContentSize + * @param {bool} arg0 + */ +setUsingPercentContentSize : function ( +bool +) +{ +}, + +/** + * @method getLeftMargin + * @return {float} + */ +getLeftMargin : function ( +) +{ + return 0; +}, + +/** + * @method getPosition + * @return {vec2_object} + */ +getPosition : function ( +) +{ + return cc.Vec2; +}, + +/** + * @method setSizeHeight + * @param {float} arg0 + */ +setSizeHeight : function ( +float +) +{ +}, + +/** + * @method isPositionPercentXEnabled + * @return {bool} + */ +isPositionPercentXEnabled : function ( +) +{ + return false; +}, + +/** + * @method getBottomMargin + * @return {float} + */ +getBottomMargin : function ( +) +{ + return 0; +}, + +/** + * @method setPercentHeightEnabled + * @param {bool} arg0 + */ +setPercentHeightEnabled : function ( +bool +) +{ +}, + +/** + * @method setPercentContentSize + * @param {vec2_object} arg0 + */ +setPercentContentSize : function ( +vec2 +) +{ +}, + +/** + * @method isPercentHeightEnabled + * @return {bool} + */ +isPercentHeightEnabled : function ( +) +{ + return false; +}, + +/** + * @method getPercentWidth + * @return {float} + */ +getPercentWidth : function ( +) +{ + return 0; +}, + +/** + * @method getHorizontalEdge + * @return {ccui.LayoutComponent::HorizontalEdge} + */ +getHorizontalEdge : function ( +) +{ + return 0; +}, + +/** + * @method isStretchHeightEnabled + * @return {bool} + */ +isStretchHeightEnabled : function ( +) +{ + return false; +}, + +/** + * @method setBottomMargin + * @param {float} arg0 + */ +setBottomMargin : function ( +float +) +{ +}, + +/** + * @method setSize + * @param {size_object} arg0 + */ +setSize : function ( +size +) +{ +}, + +/** + * @method create + * @return {ccui.LayoutComponent} + */ +create : function ( +) +{ + return ccui.LayoutComponent; +}, + +/** + * @method bindLayoutComponent + * @param {cc.Node} arg0 + * @return {ccui.LayoutComponent} + */ +bindLayoutComponent : function ( +node +) +{ + return ccui.LayoutComponent; +}, + +/** + * @method LayoutComponent + * @constructor + */ +LayoutComponent : function ( +) +{ +}, + +}; diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp new file mode 100644 index 0000000000..db3c975290 --- /dev/null +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp @@ -0,0 +1,4356 @@ +#include "jsb_cocos2dx_3d_auto.hpp" +#include "cocos2d_specifics.hpp" +#include "cocos2d.h" + +template +static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedValue initializing(cx); + bool isNewValid = true; + JS::RootedObject global(cx, ScriptingCore::getInstance()->getGlobalObject()); + isNewValid = JS_GetProperty(cx, global, "initializing", &initializing) && initializing.toBoolean(); + if (isNewValid) + { + 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."); + + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + + args.rval().set(OBJECT_TO_JSVAL(_tmp)); + return true; + } + + JS_ReportError(cx, "Constructor for the requested class is not available, please refer to the API reference."); + return false; +} + +static bool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) { + return false; +} + +static bool js_is_native_obj(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().setBoolean(true); + return true; +} +JSClass *jsb_cocos2d_Animation3D_class; +JSObject *jsb_cocos2d_Animation3D_prototype; + +bool js_cocos2dx_3d_Animation3D_initWithFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation3D* cobj = (cocos2d::Animation3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Animation3D_initWithFile : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Animation3D_initWithFile : Error processing arguments"); + bool ret = cobj->initWithFile(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Animation3D_initWithFile : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_3d_Animation3D_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation3D* cobj = (cocos2d::Animation3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Animation3D_init : Invalid Native Object"); + if (argc == 1) { + cocos2d::Animation3DData arg0; + #pragma warning NO CONVERSION TO NATIVE FOR Animation3DData + ok = false; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Animation3D_init : Error processing arguments"); + bool ret = cobj->init(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Animation3D_init : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Animation3D_getBoneCurveByName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation3D* cobj = (cocos2d::Animation3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Animation3D_getBoneCurveByName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Animation3D_getBoneCurveByName : Error processing arguments"); + cocos2d::Animation3D::Curve* ret = cobj->getBoneCurveByName(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Animation3D::Curve*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Animation3D_getBoneCurveByName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Animation3D_getDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation3D* cobj = (cocos2d::Animation3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Animation3D_getDuration : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getDuration(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Animation3D_getDuration : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Animation3D_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Animation3D_create : Error processing arguments"); + cocos2d::Animation3D* ret = cocos2d::Animation3D::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Animation3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Animation3D_create : Error processing arguments"); + cocos2d::Animation3D* ret = cocos2d::Animation3D::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Animation3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_3d_Animation3D_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_3d_Animation3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Animation3D* cobj = new (std::nothrow) cocos2d::Animation3D(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Animation3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_Animation3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Animation3D)", obj); +} + +void js_register_cocos2dx_3d_Animation3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Animation3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Animation3D_class->name = "Animation3D"; + jsb_cocos2d_Animation3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Animation3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Animation3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Animation3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Animation3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Animation3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_Animation3D_class->convert = JS_ConvertStub; + jsb_cocos2d_Animation3D_class->finalize = js_cocos2d_Animation3D_finalize; + jsb_cocos2d_Animation3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithFile", js_cocos2dx_3d_Animation3D_initWithFile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_3d_Animation3D_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBoneCurveByName", js_cocos2dx_3d_Animation3D_getBoneCurveByName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDuration", js_cocos2dx_3d_Animation3D_getDuration, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_3d_Animation3D_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Animation3D_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_Animation3D_class, + js_cocos2dx_3d_Animation3D_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, "Animation3D", 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_Animation3D_class; + p->proto = jsb_cocos2d_Animation3D_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Animate3D_class; +JSObject *jsb_cocos2d_Animate3D_prototype; + +bool js_cocos2dx_3d_Animate3D_getSpeed(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animate3D* cobj = (cocos2d::Animate3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Animate3D_getSpeed : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getSpeed(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Animate3D_getSpeed : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Animate3D_setQuality(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animate3D* cobj = (cocos2d::Animate3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Animate3D_setQuality : Invalid Native Object"); + if (argc == 1) { + cocos2d::Animate3DQuality arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Animate3D_setQuality : Error processing arguments"); + cobj->setQuality(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Animate3D_setQuality : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Animate3D_setWeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animate3D* cobj = (cocos2d::Animate3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Animate3D_setWeight : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Animate3D_setWeight : Error processing arguments"); + cobj->setWeight(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Animate3D_setWeight : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Animate3D_removeFromMap(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animate3D* cobj = (cocos2d::Animate3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Animate3D_removeFromMap : Invalid Native Object"); + if (argc == 0) { + cobj->removeFromMap(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Animate3D_removeFromMap : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Animate3D_initWithFrames(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animate3D* cobj = (cocos2d::Animate3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Animate3D_initWithFrames : Invalid Native Object"); + if (argc == 4) { + cocos2d::Animation3D* arg0; + int arg1; + int arg2; + double arg3; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Animate3D_initWithFrames : Error processing arguments"); + bool ret = cobj->initWithFrames(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Animate3D_initWithFrames : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_3d_Animate3D_getOriginInterval(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animate3D* cobj = (cocos2d::Animate3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Animate3D_getOriginInterval : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getOriginInterval(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Animate3D_getOriginInterval : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Animate3D_setSpeed(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animate3D* cobj = (cocos2d::Animate3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Animate3D_setSpeed : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Animate3D_setSpeed : Error processing arguments"); + cobj->setSpeed(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Animate3D_setSpeed : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Animate3D_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Animate3D* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Animate3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Animate3D_init : Invalid Native Object"); + do { + if (argc == 3) { + cocos2d::Animation3D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + bool ret = cobj->init(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::Animation3D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + bool ret = cobj->init(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_3d_Animate3D_init : wrong number of arguments"); + return false; +} +bool js_cocos2dx_3d_Animate3D_setOriginInterval(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animate3D* cobj = (cocos2d::Animate3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Animate3D_setOriginInterval : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Animate3D_setOriginInterval : Error processing arguments"); + cobj->setOriginInterval(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Animate3D_setOriginInterval : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Animate3D_getWeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animate3D* cobj = (cocos2d::Animate3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Animate3D_getWeight : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getWeight(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Animate3D_getWeight : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Animate3D_getQuality(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animate3D* cobj = (cocos2d::Animate3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Animate3D_getQuality : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getQuality(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Animate3D_getQuality : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Animate3D_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 3) { + cocos2d::Animation3D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::Animate3D* ret = cocos2d::Animate3D::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Animate3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 1) { + cocos2d::Animation3D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Animate3D* ret = cocos2d::Animate3D::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Animate3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_3d_Animate3D_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_3d_Animate3D_getTransitionTime(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + double ret = cocos2d::Animate3D::getTransitionTime(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_3d_Animate3D_getTransitionTime : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_3d_Animate3D_createWithFrames(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 3) { + cocos2d::Animation3D* arg0; + int arg1; + int arg2; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Animate3D_createWithFrames : Error processing arguments"); + cocos2d::Animate3D* ret = cocos2d::Animate3D::createWithFrames(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Animate3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 4) { + cocos2d::Animation3D* arg0; + int arg1; + int arg2; + double arg3; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Animation3D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Animate3D_createWithFrames : Error processing arguments"); + cocos2d::Animate3D* ret = cocos2d::Animate3D::createWithFrames(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Animate3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_3d_Animate3D_createWithFrames : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_3d_Animate3D_setTransitionTime(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Animate3D_setTransitionTime : Error processing arguments"); + cocos2d::Animate3D::setTransitionTime(arg0); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_3d_Animate3D_setTransitionTime : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_3d_Animate3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Animate3D* cobj = new (std::nothrow) cocos2d::Animate3D(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Animate3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_Animate3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Animate3D)", obj); +} + +void js_register_cocos2dx_3d_Animate3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Animate3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Animate3D_class->name = "Animate3D"; + jsb_cocos2d_Animate3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Animate3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Animate3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Animate3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Animate3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Animate3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_Animate3D_class->convert = JS_ConvertStub; + jsb_cocos2d_Animate3D_class->finalize = js_cocos2d_Animate3D_finalize; + jsb_cocos2d_Animate3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getSpeed", js_cocos2dx_3d_Animate3D_getSpeed, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setQuality", js_cocos2dx_3d_Animate3D_setQuality, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setWeight", js_cocos2dx_3d_Animate3D_setWeight, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeFromMap", js_cocos2dx_3d_Animate3D_removeFromMap, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithFrames", js_cocos2dx_3d_Animate3D_initWithFrames, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOriginInterval", js_cocos2dx_3d_Animate3D_getOriginInterval, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSpeed", js_cocos2dx_3d_Animate3D_setSpeed, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_3d_Animate3D_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setOriginInterval", js_cocos2dx_3d_Animate3D_setOriginInterval, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getWeight", js_cocos2dx_3d_Animate3D_getWeight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getQuality", js_cocos2dx_3d_Animate3D_getQuality, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_3d_Animate3D_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTransitionTime", js_cocos2dx_3d_Animate3D_getTransitionTime, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithFrames", js_cocos2dx_3d_Animate3D_createWithFrames, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTransitionTime", js_cocos2dx_3d_Animate3D_setTransitionTime, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Animate3D_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_Animate3D_class, + js_cocos2dx_3d_Animate3D_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, "Animate3D", 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_Animate3D_class; + p->proto = jsb_cocos2d_Animate3D_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Skeleton3D_class; +JSObject *jsb_cocos2d_Skeleton3D_prototype; + +bool js_cocos2dx_3d_Skeleton3D_removeAllBones(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Skeleton3D* cobj = (cocos2d::Skeleton3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Skeleton3D_removeAllBones : Invalid Native Object"); + if (argc == 0) { + cobj->removeAllBones(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Skeleton3D_removeAllBones : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Skeleton3D_addBone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Skeleton3D* cobj = (cocos2d::Skeleton3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Skeleton3D_addBone : Invalid Native Object"); + if (argc == 1) { + cocos2d::Bone3D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Bone3D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Skeleton3D_addBone : Error processing arguments"); + cobj->addBone(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Skeleton3D_addBone : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Skeleton3D_getBoneByName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Skeleton3D* cobj = (cocos2d::Skeleton3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Skeleton3D_getBoneByName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Skeleton3D_getBoneByName : Error processing arguments"); + cocos2d::Bone3D* ret = cobj->getBoneByName(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Bone3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Skeleton3D_getBoneByName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Skeleton3D_getRootBone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Skeleton3D* cobj = (cocos2d::Skeleton3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Skeleton3D_getRootBone : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Skeleton3D_getRootBone : Error processing arguments"); + cocos2d::Bone3D* ret = cobj->getRootBone(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Bone3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Skeleton3D_getRootBone : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Skeleton3D_updateBoneMatrix(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Skeleton3D* cobj = (cocos2d::Skeleton3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Skeleton3D_updateBoneMatrix : Invalid Native Object"); + if (argc == 0) { + cobj->updateBoneMatrix(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Skeleton3D_updateBoneMatrix : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Skeleton3D_getBoneByIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Skeleton3D* cobj = (cocos2d::Skeleton3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Skeleton3D_getBoneByIndex : Invalid Native Object"); + if (argc == 1) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Skeleton3D_getBoneByIndex : Error processing arguments"); + cocos2d::Bone3D* ret = cobj->getBoneByIndex(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Bone3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Skeleton3D_getBoneByIndex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Skeleton3D_getRootCount(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Skeleton3D* cobj = (cocos2d::Skeleton3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Skeleton3D_getRootCount : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getRootCount(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Skeleton3D_getRootCount : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Skeleton3D_getBoneIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Skeleton3D* cobj = (cocos2d::Skeleton3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Skeleton3D_getBoneIndex : Invalid Native Object"); + if (argc == 1) { + cocos2d::Bone3D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Bone3D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Skeleton3D_getBoneIndex : Error processing arguments"); + int ret = cobj->getBoneIndex(arg0); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Skeleton3D_getBoneIndex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Skeleton3D_getBoneCount(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Skeleton3D* cobj = (cocos2d::Skeleton3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Skeleton3D_getBoneCount : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getBoneCount(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Skeleton3D_getBoneCount : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Skeleton3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Skeleton3D* cobj = new (std::nothrow) cocos2d::Skeleton3D(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Skeleton3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_Skeleton3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Skeleton3D)", obj); +} + +void js_register_cocos2dx_3d_Skeleton3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Skeleton3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Skeleton3D_class->name = "Skeleton3D"; + jsb_cocos2d_Skeleton3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Skeleton3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Skeleton3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Skeleton3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Skeleton3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Skeleton3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_Skeleton3D_class->convert = JS_ConvertStub; + jsb_cocos2d_Skeleton3D_class->finalize = js_cocos2d_Skeleton3D_finalize; + jsb_cocos2d_Skeleton3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("removeAllBones", js_cocos2dx_3d_Skeleton3D_removeAllBones, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addBone", js_cocos2dx_3d_Skeleton3D_addBone, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBoneByName", js_cocos2dx_3d_Skeleton3D_getBoneByName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRootBone", js_cocos2dx_3d_Skeleton3D_getRootBone, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateBoneMatrix", js_cocos2dx_3d_Skeleton3D_updateBoneMatrix, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBoneByIndex", js_cocos2dx_3d_Skeleton3D_getBoneByIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRootCount", js_cocos2dx_3d_Skeleton3D_getRootCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBoneIndex", js_cocos2dx_3d_Skeleton3D_getBoneIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBoneCount", js_cocos2dx_3d_Skeleton3D_getBoneCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_Skeleton3D_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_Skeleton3D_class, + js_cocos2dx_3d_Skeleton3D_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, "Skeleton3D", 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_Skeleton3D_class; + p->proto = jsb_cocos2d_Skeleton3D_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Sprite3D_class; +JSObject *jsb_cocos2d_Sprite3D_prototype; + +bool js_cocos2dx_3d_Sprite3D_setCullFaceEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_setCullFaceEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_setCullFaceEnabled : Error processing arguments"); + cobj->setCullFaceEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_setCullFaceEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Sprite3D_setTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Sprite3D* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_setTexture : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cobj->setTexture(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->setTexture(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_setTexture : wrong number of arguments"); + return false; +} +bool js_cocos2dx_3d_Sprite3D_getLightMask(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_getLightMask : Invalid Native Object"); + if (argc == 0) { + unsigned int ret = cobj->getLightMask(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_getLightMask : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Sprite3D_createAttachSprite3DNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_createAttachSprite3DNode : Invalid Native Object"); + if (argc == 2) { + cocos2d::NodeData* arg0; + cocos2d::MaterialDatas arg1; + #pragma warning NO CONVERSION TO NATIVE FOR NodeData* + ok = false; + #pragma warning NO CONVERSION TO NATIVE FOR MaterialDatas + ok = false; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_createAttachSprite3DNode : Error processing arguments"); + cobj->createAttachSprite3DNode(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_createAttachSprite3DNode : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_3d_Sprite3D_loadFromFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_loadFromFile : Invalid Native Object"); + if (argc == 4) { + std::string arg0; + cocos2d::NodeDatas* arg1; + cocos2d::MeshDatas* arg2; + cocos2d::MaterialDatas* arg3; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + #pragma warning NO CONVERSION TO NATIVE FOR NodeDatas* + ok = false; + #pragma warning NO CONVERSION TO NATIVE FOR MeshDatas* + ok = false; + #pragma warning NO CONVERSION TO NATIVE FOR MaterialDatas* + ok = false; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_loadFromFile : Error processing arguments"); + bool ret = cobj->loadFromFile(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_loadFromFile : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_3d_Sprite3D_setCullFace(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_setCullFace : Invalid Native Object"); + if (argc == 1) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_setCullFace : Error processing arguments"); + cobj->setCullFace(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_setCullFace : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Sprite3D_addMesh(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_addMesh : Invalid Native Object"); + if (argc == 1) { + cocos2d::Mesh* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Mesh*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_addMesh : Error processing arguments"); + cobj->addMesh(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_addMesh : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Sprite3D_removeAllAttachNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_removeAllAttachNode : Invalid Native Object"); + if (argc == 0) { + cobj->removeAllAttachNode(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_removeAllAttachNode : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Sprite3D_setMaterial(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Sprite3D* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_setMaterial : Invalid Native Object"); + do { + if (argc == 2) { + cocos2d::Material* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Material*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cobj->setMaterial(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::Material* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Material*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cobj->setMaterial(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_setMaterial : wrong number of arguments"); + return false; +} +bool js_cocos2dx_3d_Sprite3D_genGLProgramState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_genGLProgramState : Invalid Native Object"); + if (argc == 0) { + cobj->genGLProgramState(); + args.rval().setUndefined(); + return true; + } + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_genGLProgramState : Error processing arguments"); + cobj->genGLProgramState(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_genGLProgramState : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Sprite3D_getMesh(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_getMesh : Invalid Native Object"); + if (argc == 0) { + cocos2d::Mesh* ret = cobj->getMesh(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Mesh*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_getMesh : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Sprite3D_createSprite3DNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_createSprite3DNode : Invalid Native Object"); + if (argc == 3) { + cocos2d::NodeData* arg0; + cocos2d::ModelData* arg1; + cocos2d::MaterialDatas arg2; + #pragma warning NO CONVERSION TO NATIVE FOR NodeData* + ok = false; + #pragma warning NO CONVERSION TO NATIVE FOR ModelData* + ok = false; + #pragma warning NO CONVERSION TO NATIVE FOR MaterialDatas + ok = false; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_createSprite3DNode : Error processing arguments"); + cocos2d::Sprite3D* ret = cobj->createSprite3DNode(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_createSprite3DNode : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_3d_Sprite3D_getMeshCount(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_getMeshCount : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getMeshCount(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_getMeshCount : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Sprite3D_onAABBDirty(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_onAABBDirty : Invalid Native Object"); + if (argc == 0) { + cobj->onAABBDirty(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_onAABBDirty : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Sprite3D_getMeshByIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_getMeshByIndex : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_getMeshByIndex : Error processing arguments"); + cocos2d::Mesh* ret = cobj->getMeshByIndex(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Mesh*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_getMeshByIndex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Sprite3D_createNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_createNode : Invalid Native Object"); + if (argc == 4) { + cocos2d::NodeData* arg0; + cocos2d::Node* arg1; + cocos2d::MaterialDatas arg2; + bool arg3; + #pragma warning NO CONVERSION TO NATIVE FOR NodeData* + ok = false; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + #pragma warning NO CONVERSION TO NATIVE FOR MaterialDatas + ok = false; + arg3 = JS::ToBoolean(args.get(3)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_createNode : Error processing arguments"); + cobj->createNode(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_createNode : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_3d_Sprite3D_isForceDepthWrite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_isForceDepthWrite : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isForceDepthWrite(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_isForceDepthWrite : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Sprite3D_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_getBlendFunc : Invalid Native Object"); + if (argc == 0) { + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Sprite3D_getMeshIndexData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_getMeshIndexData : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_getMeshIndexData : Error processing arguments"); + cocos2d::MeshIndexData* ret = cobj->getMeshIndexData(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::MeshIndexData*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_getMeshIndexData : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Sprite3D_removeAttachNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_removeAttachNode : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_removeAttachNode : Error processing arguments"); + cobj->removeAttachNode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_removeAttachNode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Sprite3D_setLightMask(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_setLightMask : Invalid Native Object"); + if (argc == 1) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_setLightMask : Error processing arguments"); + cobj->setLightMask(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_setLightMask : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Sprite3D_afterAsyncLoad(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_afterAsyncLoad : Invalid Native Object"); + if (argc == 1) { + void* arg0; + #pragma warning NO CONVERSION TO NATIVE FOR void* + ok = false; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_afterAsyncLoad : Error processing arguments"); + cobj->afterAsyncLoad(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_afterAsyncLoad : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Sprite3D_loadFromCache(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_loadFromCache : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_loadFromCache : Error processing arguments"); + bool ret = cobj->loadFromCache(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_loadFromCache : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Sprite3D_initFrom(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_initFrom : Invalid Native Object"); + if (argc == 3) { + cocos2d::NodeDatas arg0; + cocos2d::MeshDatas arg1; + cocos2d::MaterialDatas arg2; + #pragma warning NO CONVERSION TO NATIVE FOR NodeDatas + ok = false; + #pragma warning NO CONVERSION TO NATIVE FOR MeshDatas + ok = false; + #pragma warning NO CONVERSION TO NATIVE FOR MaterialDatas + ok = false; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_initFrom : Error processing arguments"); + bool ret = cobj->initFrom(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_initFrom : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_3d_Sprite3D_getAttachNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_getAttachNode : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_getAttachNode : Error processing arguments"); + cocos2d::AttachNode* ret = cobj->getAttachNode(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::AttachNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_getAttachNode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Sprite3D_initWithFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_initWithFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_initWithFile : Error processing arguments"); + bool ret = cobj->initWithFile(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_initWithFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Sprite3D_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_setBlendFunc : Invalid Native Object"); + if (argc == 1) { + cocos2d::BlendFunc arg0; + ok &= jsval_to_blendfunc(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_setBlendFunc : Error processing arguments"); + cobj->setBlendFunc(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Sprite3D_getSkeleton(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_getSkeleton : Invalid Native Object"); + if (argc == 0) { + cocos2d::Skeleton3D* ret = cobj->getSkeleton(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Skeleton3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_getSkeleton : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Sprite3D_setForceDepthWrite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_setForceDepthWrite : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_setForceDepthWrite : Error processing arguments"); + cobj->setForceDepthWrite(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_setForceDepthWrite : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Sprite3D_getMeshByName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_getMeshByName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_getMeshByName : Error processing arguments"); + cocos2d::Mesh* ret = cobj->getMeshByName(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Mesh*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_getMeshByName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Sprite3D_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Sprite3D* ret = cocos2d::Sprite3D::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::Sprite3D* ret = cocos2d::Sprite3D::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::Sprite3D* ret = cocos2d::Sprite3D::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3D_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_3d_Sprite3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Sprite3D* cobj = new (std::nothrow) cocos2d::Sprite3D(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Sprite3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_Sprite3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Sprite3D)", obj); +} + +static bool js_cocos2d_Sprite3D_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Sprite3D *nobj = new (std::nothrow) cocos2d::Sprite3D(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Sprite3D"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_3d_Sprite3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Sprite3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Sprite3D_class->name = "Sprite3D"; + jsb_cocos2d_Sprite3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Sprite3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Sprite3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Sprite3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Sprite3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Sprite3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_Sprite3D_class->convert = JS_ConvertStub; + jsb_cocos2d_Sprite3D_class->finalize = js_cocos2d_Sprite3D_finalize; + jsb_cocos2d_Sprite3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setCullFaceEnabled", js_cocos2dx_3d_Sprite3D_setCullFaceEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTexture", js_cocos2dx_3d_Sprite3D_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLightMask", js_cocos2dx_3d_Sprite3D_getLightMask, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createAttachSprite3DNode", js_cocos2dx_3d_Sprite3D_createAttachSprite3DNode, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadFromFile", js_cocos2dx_3d_Sprite3D_loadFromFile, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCullFace", js_cocos2dx_3d_Sprite3D_setCullFace, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addMesh", js_cocos2dx_3d_Sprite3D_addMesh, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllAttachNode", js_cocos2dx_3d_Sprite3D_removeAllAttachNode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaterial", js_cocos2dx_3d_Sprite3D_setMaterial, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("genGLProgramState", js_cocos2dx_3d_Sprite3D_genGLProgramState, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMesh", js_cocos2dx_3d_Sprite3D_getMesh, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createSprite3DNode", js_cocos2dx_3d_Sprite3D_createSprite3DNode, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMeshCount", js_cocos2dx_3d_Sprite3D_getMeshCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("onAABBDirty", js_cocos2dx_3d_Sprite3D_onAABBDirty, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMeshByIndex", js_cocos2dx_3d_Sprite3D_getMeshByIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createNode", js_cocos2dx_3d_Sprite3D_createNode, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isForceDepthWrite", js_cocos2dx_3d_Sprite3D_isForceDepthWrite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBlendFunc", js_cocos2dx_3d_Sprite3D_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMeshIndexData", js_cocos2dx_3d_Sprite3D_getMeshIndexData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAttachNode", js_cocos2dx_3d_Sprite3D_removeAttachNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLightMask", js_cocos2dx_3d_Sprite3D_setLightMask, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("afterAsyncLoad", js_cocos2dx_3d_Sprite3D_afterAsyncLoad, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadFromCache", js_cocos2dx_3d_Sprite3D_loadFromCache, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initFrom", js_cocos2dx_3d_Sprite3D_initFrom, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAttachNode", js_cocos2dx_3d_Sprite3D_getAttachNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithFile", js_cocos2dx_3d_Sprite3D_initWithFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBlendFunc", js_cocos2dx_3d_Sprite3D_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSkeleton", js_cocos2dx_3d_Sprite3D_getSkeleton, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setForceDepthWrite", js_cocos2dx_3d_Sprite3D_setForceDepthWrite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMeshByName", js_cocos2dx_3d_Sprite3D_getMeshByName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_Sprite3D_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_3d_Sprite3D_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Sprite3D_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_Sprite3D_class, + js_cocos2dx_3d_Sprite3D_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, "Sprite3D", 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_Sprite3D_class; + p->proto = jsb_cocos2d_Sprite3D_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Sprite3DCache_class; +JSObject *jsb_cocos2d_Sprite3DCache_prototype; + +bool js_cocos2dx_3d_Sprite3DCache_removeSprite3DData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3DCache* cobj = (cocos2d::Sprite3DCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3DCache_removeSprite3DData : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3DCache_removeSprite3DData : Error processing arguments"); + cobj->removeSprite3DData(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3DCache_removeSprite3DData : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3DCache* cobj = (cocos2d::Sprite3DCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData : Invalid Native Object"); + if (argc == 0) { + cobj->removeAllSprite3DData(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Sprite3DCache_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Sprite3DCache::destroyInstance(); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3DCache_destroyInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_3d_Sprite3DCache_getInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Sprite3DCache* ret = cocos2d::Sprite3DCache::getInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite3DCache*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_3d_Sprite3DCache_getInstance : wrong number of arguments"); + return false; +} + + + +void js_cocos2d_Sprite3DCache_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Sprite3DCache)", obj); +} + +void js_register_cocos2dx_3d_Sprite3DCache(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Sprite3DCache_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Sprite3DCache_class->name = "Sprite3DCache"; + jsb_cocos2d_Sprite3DCache_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Sprite3DCache_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Sprite3DCache_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Sprite3DCache_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Sprite3DCache_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Sprite3DCache_class->resolve = JS_ResolveStub; + jsb_cocos2d_Sprite3DCache_class->convert = JS_ConvertStub; + jsb_cocos2d_Sprite3DCache_class->finalize = js_cocos2d_Sprite3DCache_finalize; + jsb_cocos2d_Sprite3DCache_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("removeSprite3DData", js_cocos2dx_3d_Sprite3DCache_removeSprite3DData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllSprite3DData", js_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("destroyInstance", js_cocos2dx_3d_Sprite3DCache_destroyInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInstance", js_cocos2dx_3d_Sprite3DCache_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Sprite3DCache_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_Sprite3DCache_class, + empty_constructor, 0, + 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, "Sprite3DCache", 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_Sprite3DCache_class; + p->proto = jsb_cocos2d_Sprite3DCache_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Mesh_class; +JSObject *jsb_cocos2d_Mesh_prototype; + +bool js_cocos2dx_3d_Mesh_setTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Mesh* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_setTexture : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cobj->setTexture(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->setTexture(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_setTexture : wrong number of arguments"); + return false; +} +bool js_cocos2dx_3d_Mesh_getTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_getTexture : Invalid Native Object"); + if (argc == 0) { + cocos2d::Texture2D* ret = cobj->getTexture(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_getTexture : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Mesh_getSkin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_getSkin : Invalid Native Object"); + if (argc == 0) { + cocos2d::MeshSkin* ret = cobj->getSkin(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::MeshSkin*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_getSkin : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Mesh_getMaterial(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_getMaterial : Invalid Native Object"); + if (argc == 0) { + cocos2d::Material* ret = cobj->getMaterial(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Material*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_getMaterial : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Mesh_getVertexSizeInBytes(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_getVertexSizeInBytes : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getVertexSizeInBytes(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_getVertexSizeInBytes : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Mesh_setMaterial(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_setMaterial : Invalid Native Object"); + if (argc == 1) { + cocos2d::Material* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Material*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Mesh_setMaterial : Error processing arguments"); + cobj->setMaterial(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_setMaterial : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Mesh_getName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_getName : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_getName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Mesh_getIndexFormat(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_getIndexFormat : Invalid Native Object"); + if (argc == 0) { + unsigned int ret = cobj->getIndexFormat(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_getIndexFormat : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Mesh_getGLProgramState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_getGLProgramState : Invalid Native Object"); + if (argc == 0) { + cocos2d::GLProgramState* ret = cobj->getGLProgramState(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_getGLProgramState : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Mesh_getVertexBuffer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_getVertexBuffer : Invalid Native Object"); + if (argc == 0) { + unsigned int ret = cobj->getVertexBuffer(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_getVertexBuffer : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Mesh_calculateAABB(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_calculateAABB : Invalid Native Object"); + if (argc == 0) { + cobj->calculateAABB(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_calculateAABB : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Mesh_hasVertexAttrib(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_hasVertexAttrib : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Mesh_hasVertexAttrib : Error processing arguments"); + bool ret = cobj->hasVertexAttrib(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_hasVertexAttrib : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Mesh_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_getBlendFunc : Invalid Native Object"); + if (argc == 0) { + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Mesh_getMeshIndexData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_getMeshIndexData : Invalid Native Object"); + if (argc == 0) { + cocos2d::MeshIndexData* ret = cobj->getMeshIndexData(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::MeshIndexData*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_getMeshIndexData : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Mesh_setName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_setName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Mesh_setName : Error processing arguments"); + cobj->setName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_setName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Mesh_getIndexCount(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_getIndexCount : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getIndexCount(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_getIndexCount : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Mesh_setMeshIndexData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_setMeshIndexData : Invalid Native Object"); + if (argc == 1) { + cocos2d::MeshIndexData* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::MeshIndexData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Mesh_setMeshIndexData : Error processing arguments"); + cobj->setMeshIndexData(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_setMeshIndexData : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Mesh_getMeshVertexAttribCount(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_getMeshVertexAttribCount : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getMeshVertexAttribCount(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_getMeshVertexAttribCount : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Mesh_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_setBlendFunc : Invalid Native Object"); + if (argc == 1) { + cocos2d::BlendFunc arg0; + ok &= jsval_to_blendfunc(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Mesh_setBlendFunc : Error processing arguments"); + cobj->setBlendFunc(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Mesh_getPrimitiveType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_getPrimitiveType : Invalid Native Object"); + if (argc == 0) { + unsigned int ret = cobj->getPrimitiveType(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_getPrimitiveType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Mesh_setSkin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_setSkin : Invalid Native Object"); + if (argc == 1) { + cocos2d::MeshSkin* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::MeshSkin*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Mesh_setSkin : Error processing arguments"); + cobj->setSkin(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_setSkin : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Mesh_isVisible(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_isVisible : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isVisible(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_isVisible : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Mesh_getIndexBuffer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_getIndexBuffer : Invalid Native Object"); + if (argc == 0) { + unsigned int ret = cobj->getIndexBuffer(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_getIndexBuffer : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Mesh_setGLProgramState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_setGLProgramState : Invalid Native Object"); + if (argc == 1) { + cocos2d::GLProgramState* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::GLProgramState*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Mesh_setGLProgramState : Error processing arguments"); + cobj->setGLProgramState(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_setGLProgramState : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Mesh_setVisible(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_setVisible : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Mesh_setVisible : Error processing arguments"); + cobj->setVisible(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_setVisible : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Mesh_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Mesh* cobj = new (std::nothrow) cocos2d::Mesh(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Mesh"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_Mesh_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Mesh)", obj); +} + +void js_register_cocos2dx_3d_Mesh(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Mesh_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Mesh_class->name = "Mesh"; + jsb_cocos2d_Mesh_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Mesh_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Mesh_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Mesh_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Mesh_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Mesh_class->resolve = JS_ResolveStub; + jsb_cocos2d_Mesh_class->convert = JS_ConvertStub; + jsb_cocos2d_Mesh_class->finalize = js_cocos2d_Mesh_finalize; + jsb_cocos2d_Mesh_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setTexture", js_cocos2dx_3d_Mesh_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTexture", js_cocos2dx_3d_Mesh_getTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSkin", js_cocos2dx_3d_Mesh_getSkin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaterial", js_cocos2dx_3d_Mesh_getMaterial, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVertexSizeInBytes", js_cocos2dx_3d_Mesh_getVertexSizeInBytes, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaterial", js_cocos2dx_3d_Mesh_setMaterial, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getName", js_cocos2dx_3d_Mesh_getName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getIndexFormat", js_cocos2dx_3d_Mesh_getIndexFormat, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getGLProgramState", js_cocos2dx_3d_Mesh_getGLProgramState, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVertexBuffer", js_cocos2dx_3d_Mesh_getVertexBuffer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("calculateAABB", js_cocos2dx_3d_Mesh_calculateAABB, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("hasVertexAttrib", js_cocos2dx_3d_Mesh_hasVertexAttrib, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBlendFunc", js_cocos2dx_3d_Mesh_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMeshIndexData", js_cocos2dx_3d_Mesh_getMeshIndexData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setName", js_cocos2dx_3d_Mesh_setName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getIndexCount", js_cocos2dx_3d_Mesh_getIndexCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMeshIndexData", js_cocos2dx_3d_Mesh_setMeshIndexData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMeshVertexAttribCount", js_cocos2dx_3d_Mesh_getMeshVertexAttribCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBlendFunc", js_cocos2dx_3d_Mesh_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPrimitiveType", js_cocos2dx_3d_Mesh_getPrimitiveType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSkin", js_cocos2dx_3d_Mesh_setSkin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isVisible", js_cocos2dx_3d_Mesh_isVisible, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getIndexBuffer", js_cocos2dx_3d_Mesh_getIndexBuffer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setGLProgramState", js_cocos2dx_3d_Mesh_setGLProgramState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setVisible", js_cocos2dx_3d_Mesh_setVisible, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_Mesh_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_Mesh_class, + js_cocos2dx_3d_Mesh_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, "Mesh", 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_Mesh_class; + p->proto = jsb_cocos2d_Mesh_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_AttachNode_class; +JSObject *jsb_cocos2d_AttachNode_prototype; + +bool js_cocos2dx_3d_AttachNode_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Bone3D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Bone3D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_AttachNode_create : Error processing arguments"); + cocos2d::AttachNode* ret = cocos2d::AttachNode::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::AttachNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_3d_AttachNode_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_3d_AttachNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::AttachNode* cobj = new (std::nothrow) cocos2d::AttachNode(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::AttachNode"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_AttachNode_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (AttachNode)", obj); +} + +void js_register_cocos2dx_3d_AttachNode(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_AttachNode_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_AttachNode_class->name = "AttachNode"; + jsb_cocos2d_AttachNode_class->addProperty = JS_PropertyStub; + jsb_cocos2d_AttachNode_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_AttachNode_class->getProperty = JS_PropertyStub; + jsb_cocos2d_AttachNode_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_AttachNode_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_AttachNode_class->resolve = JS_ResolveStub; + jsb_cocos2d_AttachNode_class->convert = JS_ConvertStub; + jsb_cocos2d_AttachNode_class->finalize = js_cocos2d_AttachNode_finalize; + jsb_cocos2d_AttachNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_3d_AttachNode_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_AttachNode_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_AttachNode_class, + js_cocos2dx_3d_AttachNode_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, "AttachNode", 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_AttachNode_class; + p->proto = jsb_cocos2d_AttachNode_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_BillBoard_class; +JSObject *jsb_cocos2d_BillBoard_prototype; + +bool js_cocos2dx_3d_BillBoard_getMode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::BillBoard* cobj = (cocos2d::BillBoard *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_BillBoard_getMode : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getMode(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_BillBoard_getMode : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_BillBoard_setMode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::BillBoard* cobj = (cocos2d::BillBoard *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_BillBoard_setMode : Invalid Native Object"); + if (argc == 1) { + cocos2d::BillBoard::Mode arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_BillBoard_setMode : Error processing arguments"); + cobj->setMode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_BillBoard_setMode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_BillBoard_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::BillBoard* ret = cocos2d::BillBoard::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::BillBoard*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::BillBoard::Mode arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cocos2d::BillBoard* ret = cocos2d::BillBoard::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::BillBoard*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::BillBoard* ret = cocos2d::BillBoard::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::BillBoard*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 1) { + cocos2d::BillBoard::Mode arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + cocos2d::BillBoard* ret = cocos2d::BillBoard::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::BillBoard*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::BillBoard* ret = cocos2d::BillBoard::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::BillBoard*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::BillBoard::Mode arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + cocos2d::BillBoard* ret = cocos2d::BillBoard::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::BillBoard*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_3d_BillBoard_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_3d_BillBoard_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_BillBoard_createWithTexture : Error processing arguments"); + cocos2d::BillBoard* ret = cocos2d::BillBoard::createWithTexture(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::BillBoard*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + cocos2d::Texture2D* arg0; + cocos2d::BillBoard::Mode arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_BillBoard_createWithTexture : Error processing arguments"); + cocos2d::BillBoard* ret = cocos2d::BillBoard::createWithTexture(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::BillBoard*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_3d_BillBoard_createWithTexture : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_3d_BillBoard_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::BillBoard* cobj = new (std::nothrow) cocos2d::BillBoard(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::BillBoard"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Sprite_prototype; + +void js_cocos2d_BillBoard_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (BillBoard)", obj); +} + +void js_register_cocos2dx_3d_BillBoard(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_BillBoard_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_BillBoard_class->name = "BillBoard"; + jsb_cocos2d_BillBoard_class->addProperty = JS_PropertyStub; + jsb_cocos2d_BillBoard_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_BillBoard_class->getProperty = JS_PropertyStub; + jsb_cocos2d_BillBoard_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_BillBoard_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_BillBoard_class->resolve = JS_ResolveStub; + jsb_cocos2d_BillBoard_class->convert = JS_ConvertStub; + jsb_cocos2d_BillBoard_class->finalize = js_cocos2d_BillBoard_finalize; + jsb_cocos2d_BillBoard_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getMode", js_cocos2dx_3d_BillBoard_getMode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMode", js_cocos2dx_3d_BillBoard_setMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_3d_BillBoard_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithTexture", js_cocos2dx_3d_BillBoard_createWithTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_BillBoard_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Sprite_prototype), + jsb_cocos2d_BillBoard_class, + js_cocos2dx_3d_BillBoard_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, "BillBoard", 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_BillBoard_class; + p->proto = jsb_cocos2d_BillBoard_prototype; + p->parentProto = jsb_cocos2d_Sprite_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TextureCube_class; +JSObject *jsb_cocos2d_TextureCube_prototype; + +bool js_cocos2dx_3d_TextureCube_reloadTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextureCube* cobj = (cocos2d::TextureCube *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_TextureCube_reloadTexture : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->reloadTexture(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_TextureCube_reloadTexture : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_TextureCube_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 6) { + std::string arg0; + std::string arg1; + std::string arg2; + std::string arg3; + std::string arg4; + std::string arg5; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + ok &= jsval_to_std_string(cx, args.get(3), &arg3); + ok &= jsval_to_std_string(cx, args.get(4), &arg4); + ok &= jsval_to_std_string(cx, args.get(5), &arg5); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_TextureCube_create : Error processing arguments"); + cocos2d::TextureCube* ret = cocos2d::TextureCube::create(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TextureCube*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_3d_TextureCube_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_3d_TextureCube_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TextureCube* cobj = new (std::nothrow) cocos2d::TextureCube(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TextureCube"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Texture2D_prototype; + +void js_cocos2d_TextureCube_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TextureCube)", obj); +} + +void js_register_cocos2dx_3d_TextureCube(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TextureCube_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TextureCube_class->name = "TextureCube"; + jsb_cocos2d_TextureCube_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TextureCube_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TextureCube_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TextureCube_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TextureCube_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TextureCube_class->resolve = JS_ResolveStub; + jsb_cocos2d_TextureCube_class->convert = JS_ConvertStub; + jsb_cocos2d_TextureCube_class->finalize = js_cocos2d_TextureCube_finalize; + jsb_cocos2d_TextureCube_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("reloadTexture", js_cocos2dx_3d_TextureCube_reloadTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_3d_TextureCube_create, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TextureCube_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Texture2D_prototype), + jsb_cocos2d_TextureCube_class, + js_cocos2dx_3d_TextureCube_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, "TextureCube", 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_TextureCube_class; + p->proto = jsb_cocos2d_TextureCube_prototype; + p->parentProto = jsb_cocos2d_Texture2D_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Skybox_class; +JSObject *jsb_cocos2d_Skybox_prototype; + +bool js_cocos2dx_3d_Skybox_reload(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Skybox* cobj = (cocos2d::Skybox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Skybox_reload : Invalid Native Object"); + if (argc == 0) { + cobj->reload(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Skybox_reload : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Skybox_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Skybox* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Skybox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Skybox_init : Invalid Native Object"); + do { + if (argc == 6) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + std::string arg3; + ok &= jsval_to_std_string(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + std::string arg4; + ok &= jsval_to_std_string(cx, args.get(4), &arg4); + if (!ok) { ok = true; break; } + std::string arg5; + ok &= jsval_to_std_string(cx, args.get(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); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_3d_Skybox_init : wrong number of arguments"); + return false; +} +bool js_cocos2dx_3d_Skybox_setTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Skybox* cobj = (cocos2d::Skybox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Skybox_setTexture : Invalid Native Object"); + if (argc == 1) { + cocos2d::TextureCube* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::TextureCube*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Skybox_setTexture : Error processing arguments"); + cobj->setTexture(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Skybox_setTexture : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Skybox_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 6) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + std::string arg3; + ok &= jsval_to_std_string(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + std::string arg4; + ok &= jsval_to_std_string(cx, args.get(4), &arg4); + if (!ok) { ok = true; break; } + std::string arg5; + ok &= jsval_to_std_string(cx, args.get(5), &arg5); + if (!ok) { ok = true; break; } + cocos2d::Skybox* ret = cocos2d::Skybox::create(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Skybox*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::Skybox* ret = cocos2d::Skybox::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Skybox*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_3d_Skybox_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_3d_Skybox_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Skybox* cobj = new (std::nothrow) cocos2d::Skybox(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Skybox"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_Skybox_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Skybox)", obj); +} + +void js_register_cocos2dx_3d_Skybox(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Skybox_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Skybox_class->name = "Skybox"; + jsb_cocos2d_Skybox_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Skybox_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Skybox_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Skybox_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Skybox_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Skybox_class->resolve = JS_ResolveStub; + jsb_cocos2d_Skybox_class->convert = JS_ConvertStub; + jsb_cocos2d_Skybox_class->finalize = js_cocos2d_Skybox_finalize; + jsb_cocos2d_Skybox_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("reload", js_cocos2dx_3d_Skybox_reload, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_3d_Skybox_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTexture", js_cocos2dx_3d_Skybox_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_3d_Skybox_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Skybox_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_Skybox_class, + js_cocos2dx_3d_Skybox_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, "Skybox", 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_Skybox_class; + p->proto = jsb_cocos2d_Skybox_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Terrain_class; +JSObject *jsb_cocos2d_Terrain_prototype; + +bool js_cocos2dx_3d_Terrain_initHeightMap(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_initHeightMap : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Terrain_initHeightMap : Error processing arguments"); + bool ret = cobj->initHeightMap(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_initHeightMap : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Terrain_setMaxDetailMapAmount(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_setMaxDetailMapAmount : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Terrain_setMaxDetailMapAmount : Error processing arguments"); + cobj->setMaxDetailMapAmount(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_setMaxDetailMapAmount : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Terrain_setDrawWire(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_setDrawWire : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Terrain_setDrawWire : Error processing arguments"); + cobj->setDrawWire(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_setDrawWire : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Terrain_setIsEnableFrustumCull(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_setIsEnableFrustumCull : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Terrain_setIsEnableFrustumCull : Error processing arguments"); + cobj->setIsEnableFrustumCull(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_setIsEnableFrustumCull : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Terrain_getHeightData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getHeightData : Invalid Native Object"); + if (argc == 0) { + std::vector > ret = cobj->getHeightData(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy >>(cx, (std::vector >)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_getHeightData : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Terrain_setDetailMap(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_setDetailMap : Invalid Native Object"); + if (argc == 2) { + unsigned int arg0; + cocos2d::Terrain::DetailMap arg1; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + #pragma warning NO CONVERSION TO NATIVE FOR DetailMap + ok = false; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Terrain_setDetailMap : Error processing arguments"); + cobj->setDetailMap(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_setDetailMap : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_3d_Terrain_resetHeightMap(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_resetHeightMap : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Terrain_resetHeightMap : Error processing arguments"); + cobj->resetHeightMap(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_resetHeightMap : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Terrain_setAlphaMap(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_setAlphaMap : Invalid Native Object"); + if (argc == 1) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Terrain_setAlphaMap : Error processing arguments"); + cobj->setAlphaMap(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_setAlphaMap : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Terrain_setSkirtHeightRatio(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_setSkirtHeightRatio : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Terrain_setSkirtHeightRatio : Error processing arguments"); + cobj->setSkirtHeightRatio(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_setSkirtHeightRatio : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Terrain_convertToTerrainSpace(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_convertToTerrainSpace : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Terrain_convertToTerrainSpace : Error processing arguments"); + cocos2d::Vec2 ret = cobj->convertToTerrainSpace(arg0); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_convertToTerrainSpace : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Terrain_initTextures(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_initTextures : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->initTextures(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_initTextures : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Terrain_initProperties(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_initProperties : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->initProperties(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_initProperties : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Terrain_getHeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Terrain* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getHeight : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + double ret = cobj->getHeight(arg0); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec3* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + double ret = cobj->getHeight(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double ret = cobj->getHeight(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 3) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + cocos2d::Vec3* arg2; + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + double ret = cobj->getHeight(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_getHeight : wrong number of arguments"); + return false; +} +bool js_cocos2dx_3d_Terrain_setLODDistance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_setLODDistance : Invalid Native Object"); + if (argc == 3) { + double arg0; + double arg1; + double arg2; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Terrain_setLODDistance : Error processing arguments"); + cobj->setLODDistance(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_setLODDistance : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_3d_Terrain_getTerrainSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getTerrainSize : Invalid Native Object"); + if (argc == 0) { + cocos2d::Size ret = cobj->getTerrainSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_getTerrainSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Terrain_getIntersectionPoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getIntersectionPoint : Invalid Native Object"); + if (argc == 1) { + cocos2d::Ray arg0; + ok &= jsval_to_ray(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Terrain_getIntersectionPoint : Error processing arguments"); + cocos2d::Vec3 ret = cobj->getIntersectionPoint(arg0); + jsval jsret = JSVAL_NULL; + jsret = vector3_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_getIntersectionPoint : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_Terrain_getNormal(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getNormal : Invalid Native Object"); + if (argc == 2) { + int arg0; + int arg1; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Terrain_getNormal : Error processing arguments"); + cocos2d::Vec3 ret = cobj->getNormal(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = vector3_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_getNormal : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_3d_Terrain_reload(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_reload : Invalid Native Object"); + if (argc == 0) { + cobj->reload(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_reload : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Terrain_getImageHeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getImageHeight : Invalid Native Object"); + if (argc == 2) { + int arg0; + int arg1; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Terrain_getImageHeight : Error processing arguments"); + double ret = cobj->getImageHeight(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_getImageHeight : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_3d_Terrain_getMaxHeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getMaxHeight : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getMaxHeight(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_getMaxHeight : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_Terrain_getMinHeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getMinHeight : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getMinHeight(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Terrain_getMinHeight : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_Terrain_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Terrain)", obj); +} + +void js_register_cocos2dx_3d_Terrain(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Terrain_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Terrain_class->name = "Terrain"; + jsb_cocos2d_Terrain_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Terrain_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Terrain_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Terrain_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Terrain_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Terrain_class->resolve = JS_ResolveStub; + jsb_cocos2d_Terrain_class->convert = JS_ConvertStub; + jsb_cocos2d_Terrain_class->finalize = js_cocos2d_Terrain_finalize; + jsb_cocos2d_Terrain_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initHeightMap", js_cocos2dx_3d_Terrain_initHeightMap, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaxDetailMapAmount", js_cocos2dx_3d_Terrain_setMaxDetailMapAmount, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDrawWire", js_cocos2dx_3d_Terrain_setDrawWire, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setIsEnableFrustumCull", js_cocos2dx_3d_Terrain_setIsEnableFrustumCull, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getHeightData", js_cocos2dx_3d_Terrain_getHeightData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDetailMap", js_cocos2dx_3d_Terrain_setDetailMap, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resetHeightMap", js_cocos2dx_3d_Terrain_resetHeightMap, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAlphaMap", js_cocos2dx_3d_Terrain_setAlphaMap, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSkirtHeightRatio", js_cocos2dx_3d_Terrain_setSkirtHeightRatio, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("convertToTerrainSpace", js_cocos2dx_3d_Terrain_convertToTerrainSpace, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initTextures", js_cocos2dx_3d_Terrain_initTextures, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initProperties", js_cocos2dx_3d_Terrain_initProperties, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getHeight", js_cocos2dx_3d_Terrain_getHeight, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLODDistance", js_cocos2dx_3d_Terrain_setLODDistance, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTerrainSize", js_cocos2dx_3d_Terrain_getTerrainSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getIntersectionPoint", js_cocos2dx_3d_Terrain_getIntersectionPoint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNormal", js_cocos2dx_3d_Terrain_getNormal, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("reload", js_cocos2dx_3d_Terrain_reload, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getImageHeight", js_cocos2dx_3d_Terrain_getImageHeight, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaxHeight", js_cocos2dx_3d_Terrain_getMaxHeight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMinHeight", js_cocos2dx_3d_Terrain_getMinHeight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_Terrain_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_Terrain_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, "Terrain", 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_Terrain_class; + p->proto = jsb_cocos2d_Terrain_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +void register_all_cocos2dx_3d(JSContext* cx, JS::HandleObject obj) { + // Get the ns + JS::RootedObject ns(cx); + get_or_create_js_obj(cx, obj, "jsb", &ns); + + js_register_cocos2dx_3d_Animate3D(cx, ns); + js_register_cocos2dx_3d_Sprite3D(cx, ns); + js_register_cocos2dx_3d_AttachNode(cx, ns); + js_register_cocos2dx_3d_TextureCube(cx, ns); + js_register_cocos2dx_3d_Sprite3DCache(cx, ns); + js_register_cocos2dx_3d_Terrain(cx, ns); + js_register_cocos2dx_3d_Skybox(cx, ns); + js_register_cocos2dx_3d_BillBoard(cx, ns); + js_register_cocos2dx_3d_Skeleton3D(cx, ns); + js_register_cocos2dx_3d_Mesh(cx, ns); + js_register_cocos2dx_3d_Animation3D(cx, ns); +} + diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.hpp new file mode 100644 index 0000000000..5fe0698b9f --- /dev/null +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.hpp @@ -0,0 +1,226 @@ +#ifndef __cocos2dx_3d_h__ +#define __cocos2dx_3d_h__ + +#include "jsapi.h" +#include "jsfriendapi.h" + + +extern JSClass *jsb_cocos2d_Animation3D_class; +extern JSObject *jsb_cocos2d_Animation3D_prototype; + +bool js_cocos2dx_3d_Animation3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_3d_Animation3D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_3d_Animation3D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_3d(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_3d_Animation3D_initWithFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animation3D_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animation3D_getBoneCurveByName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animation3D_getDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animation3D_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animation3D_Animation3D(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Animate3D_class; +extern JSObject *jsb_cocos2d_Animate3D_prototype; + +bool js_cocos2dx_3d_Animate3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_3d_Animate3D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_3d_Animate3D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_3d(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_3d_Animate3D_getSpeed(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animate3D_setQuality(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animate3D_setWeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animate3D_removeFromMap(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animate3D_initWithFrames(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animate3D_getOriginInterval(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animate3D_setSpeed(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animate3D_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animate3D_setOriginInterval(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animate3D_getWeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animate3D_getQuality(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animate3D_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animate3D_getTransitionTime(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animate3D_createWithFrames(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animate3D_setTransitionTime(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Animate3D_Animate3D(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Skeleton3D_class; +extern JSObject *jsb_cocos2d_Skeleton3D_prototype; + +bool js_cocos2dx_3d_Skeleton3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_3d_Skeleton3D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_3d_Skeleton3D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_3d(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_3d_Skeleton3D_removeAllBones(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Skeleton3D_addBone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Skeleton3D_getBoneByName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Skeleton3D_getRootBone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Skeleton3D_updateBoneMatrix(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Skeleton3D_getBoneByIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Skeleton3D_getRootCount(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Skeleton3D_getBoneIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Skeleton3D_getBoneCount(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Skeleton3D_Skeleton3D(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Sprite3D_class; +extern JSObject *jsb_cocos2d_Sprite3D_prototype; + +bool js_cocos2dx_3d_Sprite3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_3d_Sprite3D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_3d_Sprite3D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_3d(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_3d_Sprite3D_setCullFaceEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_setTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_getLightMask(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_createAttachSprite3DNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_loadFromFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_setCullFace(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_addMesh(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_removeAllAttachNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_setMaterial(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_genGLProgramState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_getMesh(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_createSprite3DNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_getMeshCount(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_onAABBDirty(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_getMeshByIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_createNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_isForceDepthWrite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_getMeshIndexData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_removeAttachNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_setLightMask(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_afterAsyncLoad(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_loadFromCache(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_initFrom(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_getAttachNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_initWithFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_getSkeleton(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_setForceDepthWrite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_getMeshByName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3D_Sprite3D(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Sprite3DCache_class; +extern JSObject *jsb_cocos2d_Sprite3DCache_prototype; + +bool js_cocos2dx_3d_Sprite3DCache_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_3d_Sprite3DCache_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_3d_Sprite3DCache(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_3d(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_3d_Sprite3DCache_removeSprite3DData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3DCache_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Sprite3DCache_getInstance(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Mesh_class; +extern JSObject *jsb_cocos2d_Mesh_prototype; + +bool js_cocos2dx_3d_Mesh_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_3d_Mesh_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_3d_Mesh(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_3d(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_3d_Mesh_setTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_getTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_getSkin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_getMaterial(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_getVertexSizeInBytes(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_setMaterial(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_getName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_getIndexFormat(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_getGLProgramState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_getVertexBuffer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_calculateAABB(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_hasVertexAttrib(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_getMeshIndexData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_setName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_getIndexCount(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_setMeshIndexData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_getMeshVertexAttribCount(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_getPrimitiveType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_setSkin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_isVisible(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_getIndexBuffer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_setGLProgramState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_setVisible(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Mesh_Mesh(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_AttachNode_class; +extern JSObject *jsb_cocos2d_AttachNode_prototype; + +bool js_cocos2dx_3d_AttachNode_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_3d_AttachNode_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_3d_AttachNode(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_3d(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_3d_AttachNode_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_AttachNode_AttachNode(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_BillBoard_class; +extern JSObject *jsb_cocos2d_BillBoard_prototype; + +bool js_cocos2dx_3d_BillBoard_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_3d_BillBoard_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_3d_BillBoard(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_3d(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_3d_BillBoard_getMode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_BillBoard_setMode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_BillBoard_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_BillBoard_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_BillBoard_BillBoard(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TextureCube_class; +extern JSObject *jsb_cocos2d_TextureCube_prototype; + +bool js_cocos2dx_3d_TextureCube_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_3d_TextureCube_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_3d_TextureCube(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_3d(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_3d_TextureCube_reloadTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_TextureCube_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_TextureCube_TextureCube(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Skybox_class; +extern JSObject *jsb_cocos2d_Skybox_prototype; + +bool js_cocos2dx_3d_Skybox_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_3d_Skybox_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_3d_Skybox(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_3d(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_3d_Skybox_reload(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Skybox_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Skybox_setTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Skybox_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Skybox_Skybox(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Terrain_class; +extern JSObject *jsb_cocos2d_Terrain_prototype; + +bool js_cocos2dx_3d_Terrain_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_3d_Terrain_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_3d_Terrain(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_3d(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_3d_Terrain_initHeightMap(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_setMaxDetailMapAmount(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_setDrawWire(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_setIsEnableFrustumCull(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_getHeightData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_setDetailMap(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_resetHeightMap(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_setAlphaMap(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_setSkirtHeightRatio(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_convertToTerrainSpace(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_initTextures(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_initProperties(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_getHeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_setLODDistance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_getTerrainSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_getIntersectionPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_getNormal(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_reload(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_getImageHeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_getMaxHeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_Terrain_getMinHeight(JSContext *cx, uint32_t argc, jsval *vp); +#endif + diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.cpp new file mode 100644 index 0000000000..8bc9e813e1 --- /dev/null +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.cpp @@ -0,0 +1,1244 @@ +#include "jsb_cocos2dx_3d_extension_auto.hpp" +#include "cocos2d_specifics.hpp" +#include "cocos-ext.h" + +template +static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedValue initializing(cx); + bool isNewValid = true; + JS::RootedObject global(cx, ScriptingCore::getInstance()->getGlobalObject()); + isNewValid = JS_GetProperty(cx, global, "initializing", &initializing) && initializing.toBoolean(); + if (isNewValid) + { + 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."); + + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + + args.rval().set(OBJECT_TO_JSVAL(_tmp)); + return true; + } + + JS_ReportError(cx, "Constructor for the requested class is not available, please refer to the API reference."); + return false; +} + +static bool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) { + return false; +} + +static bool js_is_native_obj(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().setBoolean(true); + return true; +} +JSClass *jsb_cocos2d_ParticleSystem3D_class; +JSObject *jsb_cocos2d_ParticleSystem3D_prototype; + +bool js_cocos2dx_3d_extension_ParticleSystem3D_resumeParticleSystem(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem3D* cobj = (cocos2d::ParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_ParticleSystem3D_resumeParticleSystem : Invalid Native Object"); + if (argc == 0) { + cobj->resumeParticleSystem(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_ParticleSystem3D_resumeParticleSystem : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_ParticleSystem3D_startParticleSystem(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem3D* cobj = (cocos2d::ParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_ParticleSystem3D_startParticleSystem : Invalid Native Object"); + if (argc == 0) { + cobj->startParticleSystem(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_ParticleSystem3D_startParticleSystem : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_ParticleSystem3D_isEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem3D* cobj = (cocos2d::ParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_ParticleSystem3D_isEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_ParticleSystem3D_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_ParticleSystem3D_isKeepLocal(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem3D* cobj = (cocos2d::ParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_ParticleSystem3D_isKeepLocal : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isKeepLocal(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_ParticleSystem3D_isKeepLocal : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_ParticleSystem3D_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem3D* cobj = (cocos2d::ParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_ParticleSystem3D_setEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_extension_ParticleSystem3D_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_ParticleSystem3D_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_extension_ParticleSystem3D_getParticleQuota(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem3D* cobj = (cocos2d::ParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_ParticleSystem3D_getParticleQuota : Invalid Native Object"); + if (argc == 0) { + unsigned int ret = cobj->getParticleQuota(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_ParticleSystem3D_getParticleQuota : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_ParticleSystem3D_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem3D* cobj = (cocos2d::ParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_ParticleSystem3D_getBlendFunc : Invalid Native Object"); + if (argc == 0) { + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_ParticleSystem3D_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_ParticleSystem3D_pauseParticleSystem(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem3D* cobj = (cocos2d::ParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_ParticleSystem3D_pauseParticleSystem : Invalid Native Object"); + if (argc == 0) { + cobj->pauseParticleSystem(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_ParticleSystem3D_pauseParticleSystem : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_ParticleSystem3D_getState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem3D* cobj = (cocos2d::ParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_ParticleSystem3D_getState : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getState(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_ParticleSystem3D_getState : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_ParticleSystem3D_getAliveParticleCount(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem3D* cobj = (cocos2d::ParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_ParticleSystem3D_getAliveParticleCount : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getAliveParticleCount(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_ParticleSystem3D_getAliveParticleCount : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_ParticleSystem3D_setParticleQuota(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem3D* cobj = (cocos2d::ParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_ParticleSystem3D_setParticleQuota : Invalid Native Object"); + if (argc == 1) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_extension_ParticleSystem3D_setParticleQuota : Error processing arguments"); + cobj->setParticleQuota(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_ParticleSystem3D_setParticleQuota : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_extension_ParticleSystem3D_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem3D* cobj = (cocos2d::ParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_ParticleSystem3D_setBlendFunc : Invalid Native Object"); + if (argc == 1) { + cocos2d::BlendFunc arg0; + ok &= jsval_to_blendfunc(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_extension_ParticleSystem3D_setBlendFunc : Error processing arguments"); + cobj->setBlendFunc(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_ParticleSystem3D_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_extension_ParticleSystem3D_stopParticleSystem(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem3D* cobj = (cocos2d::ParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_ParticleSystem3D_stopParticleSystem : Invalid Native Object"); + if (argc == 0) { + cobj->stopParticleSystem(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_ParticleSystem3D_stopParticleSystem : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_ParticleSystem3D_setKeepLocal(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem3D* cobj = (cocos2d::ParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_ParticleSystem3D_setKeepLocal : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_extension_ParticleSystem3D_setKeepLocal : Error processing arguments"); + cobj->setKeepLocal(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_ParticleSystem3D_setKeepLocal : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_extension_ParticleSystem3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ParticleSystem3D* cobj = new (std::nothrow) cocos2d::ParticleSystem3D(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ParticleSystem3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_ParticleSystem3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ParticleSystem3D)", obj); +} + +void js_register_cocos2dx_3d_extension_ParticleSystem3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ParticleSystem3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ParticleSystem3D_class->name = "ParticleSystem3D"; + jsb_cocos2d_ParticleSystem3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ParticleSystem3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ParticleSystem3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ParticleSystem3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ParticleSystem3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ParticleSystem3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_ParticleSystem3D_class->convert = JS_ConvertStub; + jsb_cocos2d_ParticleSystem3D_class->finalize = js_cocos2d_ParticleSystem3D_finalize; + jsb_cocos2d_ParticleSystem3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("resumeParticleSystem", js_cocos2dx_3d_extension_ParticleSystem3D_resumeParticleSystem, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("startParticleSystem", js_cocos2dx_3d_extension_ParticleSystem3D_startParticleSystem, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isEnabled", js_cocos2dx_3d_extension_ParticleSystem3D_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isKeepLocal", js_cocos2dx_3d_extension_ParticleSystem3D_isKeepLocal, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEnabled", js_cocos2dx_3d_extension_ParticleSystem3D_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getParticleQuota", js_cocos2dx_3d_extension_ParticleSystem3D_getParticleQuota, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBlendFunc", js_cocos2dx_3d_extension_ParticleSystem3D_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pauseParticleSystem", js_cocos2dx_3d_extension_ParticleSystem3D_pauseParticleSystem, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getState", js_cocos2dx_3d_extension_ParticleSystem3D_getState, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAliveParticleCount", js_cocos2dx_3d_extension_ParticleSystem3D_getAliveParticleCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setParticleQuota", js_cocos2dx_3d_extension_ParticleSystem3D_setParticleQuota, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBlendFunc", js_cocos2dx_3d_extension_ParticleSystem3D_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("stopParticleSystem", js_cocos2dx_3d_extension_ParticleSystem3D_stopParticleSystem, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setKeepLocal", js_cocos2dx_3d_extension_ParticleSystem3D_setKeepLocal, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_ParticleSystem3D_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_ParticleSystem3D_class, + js_cocos2dx_3d_extension_ParticleSystem3D_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, "ParticleSystem3D", 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_ParticleSystem3D_class; + p->proto = jsb_cocos2d_ParticleSystem3D_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_PUParticleSystem3D_class; +JSObject *jsb_cocos2d_PUParticleSystem3D_prototype; + +bool js_cocos2dx_3d_extension_PUParticleSystem3D_initWithFilePath(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_initWithFilePath : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_initWithFilePath : Error processing arguments"); + bool ret = cobj->initWithFilePath(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_initWithFilePath : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getParticleSystemScaleVelocity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_getParticleSystemScaleVelocity : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getParticleSystemScaleVelocity(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_getParticleSystemScaleVelocity : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_setEmittedSystemQuota(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_setEmittedSystemQuota : Invalid Native Object"); + if (argc == 1) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_setEmittedSystemQuota : Error processing arguments"); + cobj->setEmittedSystemQuota(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_setEmittedSystemQuota : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getDefaultDepth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_getDefaultDepth : Invalid Native Object"); + if (argc == 0) { + const float ret = cobj->getDefaultDepth(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_getDefaultDepth : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getEmittedSystemQuota(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_getEmittedSystemQuota : Invalid Native Object"); + if (argc == 0) { + unsigned int ret = cobj->getEmittedSystemQuota(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_getEmittedSystemQuota : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_initWithFilePathAndMaterialPath(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_initWithFilePathAndMaterialPath : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_initWithFilePathAndMaterialPath : Error processing arguments"); + bool ret = cobj->initWithFilePathAndMaterialPath(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_initWithFilePathAndMaterialPath : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_clearAllParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_clearAllParticles : Invalid Native Object"); + if (argc == 0) { + cobj->clearAllParticles(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_clearAllParticles : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getMaterialName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_getMaterialName : Invalid Native Object"); + if (argc == 0) { + const std::string ret = cobj->getMaterialName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_getMaterialName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_calulateRotationOffset(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_calulateRotationOffset : Invalid Native Object"); + if (argc == 0) { + cobj->calulateRotationOffset(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_calulateRotationOffset : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getMaxVelocity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_getMaxVelocity : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getMaxVelocity(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_getMaxVelocity : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_forceUpdate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_forceUpdate : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_forceUpdate : Error processing arguments"); + cobj->forceUpdate(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_forceUpdate : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getTimeElapsedSinceStart(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_getTimeElapsedSinceStart : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getTimeElapsedSinceStart(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_getTimeElapsedSinceStart : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getEmittedEmitterQuota(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_getEmittedEmitterQuota : Invalid Native Object"); + if (argc == 0) { + unsigned int ret = cobj->getEmittedEmitterQuota(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_getEmittedEmitterQuota : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_isMarkedForEmission(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_isMarkedForEmission : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isMarkedForEmission(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_isMarkedForEmission : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getDefaultWidth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_getDefaultWidth : Invalid Native Object"); + if (argc == 0) { + const float ret = cobj->getDefaultWidth(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_getDefaultWidth : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_setEmittedEmitterQuota(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_setEmittedEmitterQuota : Invalid Native Object"); + if (argc == 1) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_setEmittedEmitterQuota : Error processing arguments"); + cobj->setEmittedEmitterQuota(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_setEmittedEmitterQuota : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_setMarkedForEmission(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_setMarkedForEmission : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_setMarkedForEmission : Error processing arguments"); + cobj->setMarkedForEmission(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_setMarkedForEmission : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_clone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_clone : Invalid Native Object"); + if (argc == 0) { + cocos2d::PUParticleSystem3D* ret = cobj->clone(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::PUParticleSystem3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_clone : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultWidth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultWidth : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultWidth : Error processing arguments"); + cobj->setDefaultWidth(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultWidth : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_copyAttributesTo(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_copyAttributesTo : Invalid Native Object"); + if (argc == 1) { + cocos2d::PUParticleSystem3D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::PUParticleSystem3D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_copyAttributesTo : Error processing arguments"); + cobj->copyAttributesTo(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_copyAttributesTo : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_setMaterialName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_setMaterialName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_setMaterialName : Error processing arguments"); + cobj->setMaterialName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_setMaterialName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getParentParticleSystem(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_getParentParticleSystem : Invalid Native Object"); + if (argc == 0) { + cocos2d::PUParticleSystem3D* ret = cobj->getParentParticleSystem(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::PUParticleSystem3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_getParentParticleSystem : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_setMaxVelocity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_setMaxVelocity : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_setMaxVelocity : Error processing arguments"); + cobj->setMaxVelocity(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_setMaxVelocity : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getDefaultHeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_getDefaultHeight : Invalid Native Object"); + if (argc == 0) { + const float ret = cobj->getDefaultHeight(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_getDefaultHeight : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedPosition : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec3 ret = cobj->getDerivedPosition(); + jsval jsret = JSVAL_NULL; + jsret = vector3_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedPosition : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_rotationOffset(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_rotationOffset : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec3 arg0; + ok &= jsval_to_vector3(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_rotationOffset : Error processing arguments"); + cobj->rotationOffset(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_rotationOffset : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedOrientation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedOrientation : Invalid Native Object"); + if (argc == 0) { + cocos2d::Quaternion ret = cobj->getDerivedOrientation(); + jsval jsret = JSVAL_NULL; + jsret = quaternion_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedOrientation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_removeAllEmitter(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_removeAllEmitter : Invalid Native Object"); + if (argc == 0) { + cobj->removeAllEmitter(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_removeAllEmitter : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_setParticleSystemScaleVelocity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_setParticleSystemScaleVelocity : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_setParticleSystemScaleVelocity : Error processing arguments"); + cobj->setParticleSystemScaleVelocity(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_setParticleSystemScaleVelocity : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedScale : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec3 ret = cobj->getDerivedScale(); + jsval jsret = JSVAL_NULL; + jsret = vector3_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedScale : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultHeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultHeight : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultHeight : Error processing arguments"); + cobj->setDefaultHeight(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultHeight : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_removeAllListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_removeAllListener : Invalid Native Object"); + if (argc == 0) { + cobj->removeAllListener(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_removeAllListener : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultDepth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PUParticleSystem3D* cobj = (cocos2d::PUParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultDepth : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultDepth : Error processing arguments"); + cobj->setDefaultDepth(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultDepth : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::PUParticleSystem3D* ret = cocos2d::PUParticleSystem3D::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::PUParticleSystem3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::PUParticleSystem3D* ret = cocos2d::PUParticleSystem3D::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::PUParticleSystem3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::PUParticleSystem3D* ret = cocos2d::PUParticleSystem3D::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::PUParticleSystem3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_3d_extension_PUParticleSystem3D_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_3d_extension_PUParticleSystem3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::PUParticleSystem3D* cobj = new (std::nothrow) cocos2d::PUParticleSystem3D(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::PUParticleSystem3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ParticleSystem3D_prototype; + +void js_cocos2d_PUParticleSystem3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (PUParticleSystem3D)", obj); +} + +void js_register_cocos2dx_3d_extension_PUParticleSystem3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_PUParticleSystem3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_PUParticleSystem3D_class->name = "PUParticleSystem3D"; + jsb_cocos2d_PUParticleSystem3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_PUParticleSystem3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_PUParticleSystem3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_PUParticleSystem3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_PUParticleSystem3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_PUParticleSystem3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_PUParticleSystem3D_class->convert = JS_ConvertStub; + jsb_cocos2d_PUParticleSystem3D_class->finalize = js_cocos2d_PUParticleSystem3D_finalize; + jsb_cocos2d_PUParticleSystem3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithFilePath", js_cocos2dx_3d_extension_PUParticleSystem3D_initWithFilePath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getParticleSystemScaleVelocity", js_cocos2dx_3d_extension_PUParticleSystem3D_getParticleSystemScaleVelocity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEmittedSystemQuota", js_cocos2dx_3d_extension_PUParticleSystem3D_setEmittedSystemQuota, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDefaultDepth", js_cocos2dx_3d_extension_PUParticleSystem3D_getDefaultDepth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEmittedSystemQuota", js_cocos2dx_3d_extension_PUParticleSystem3D_getEmittedSystemQuota, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithFilePathAndMaterialPath", js_cocos2dx_3d_extension_PUParticleSystem3D_initWithFilePathAndMaterialPath, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("clearAllParticles", js_cocos2dx_3d_extension_PUParticleSystem3D_clearAllParticles, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaterialName", js_cocos2dx_3d_extension_PUParticleSystem3D_getMaterialName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("calulateRotationOffset", js_cocos2dx_3d_extension_PUParticleSystem3D_calulateRotationOffset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaxVelocity", js_cocos2dx_3d_extension_PUParticleSystem3D_getMaxVelocity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("forceUpdate", js_cocos2dx_3d_extension_PUParticleSystem3D_forceUpdate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTimeElapsedSinceStart", js_cocos2dx_3d_extension_PUParticleSystem3D_getTimeElapsedSinceStart, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEmittedEmitterQuota", js_cocos2dx_3d_extension_PUParticleSystem3D_getEmittedEmitterQuota, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isMarkedForEmission", js_cocos2dx_3d_extension_PUParticleSystem3D_isMarkedForEmission, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDefaultWidth", js_cocos2dx_3d_extension_PUParticleSystem3D_getDefaultWidth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEmittedEmitterQuota", js_cocos2dx_3d_extension_PUParticleSystem3D_setEmittedEmitterQuota, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMarkedForEmission", js_cocos2dx_3d_extension_PUParticleSystem3D_setMarkedForEmission, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("clone", js_cocos2dx_3d_extension_PUParticleSystem3D_clone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDefaultWidth", js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultWidth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("copyAttributesTo", js_cocos2dx_3d_extension_PUParticleSystem3D_copyAttributesTo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaterialName", js_cocos2dx_3d_extension_PUParticleSystem3D_setMaterialName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getParentParticleSystem", js_cocos2dx_3d_extension_PUParticleSystem3D_getParentParticleSystem, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaxVelocity", js_cocos2dx_3d_extension_PUParticleSystem3D_setMaxVelocity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDefaultHeight", js_cocos2dx_3d_extension_PUParticleSystem3D_getDefaultHeight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDerivedPosition", js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("rotationOffset", js_cocos2dx_3d_extension_PUParticleSystem3D_rotationOffset, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDerivedOrientation", js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedOrientation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllEmitter", js_cocos2dx_3d_extension_PUParticleSystem3D_removeAllEmitter, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setParticleSystemScaleVelocity", js_cocos2dx_3d_extension_PUParticleSystem3D_setParticleSystemScaleVelocity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDerivedScale", js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDefaultHeight", js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultHeight, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllListener", js_cocos2dx_3d_extension_PUParticleSystem3D_removeAllListener, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDefaultDepth", js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultDepth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_3d_extension_PUParticleSystem3D_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_PUParticleSystem3D_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ParticleSystem3D_prototype), + jsb_cocos2d_PUParticleSystem3D_class, + js_cocos2dx_3d_extension_PUParticleSystem3D_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, "PUParticleSystem3D", 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_PUParticleSystem3D_class; + p->proto = jsb_cocos2d_PUParticleSystem3D_prototype; + p->parentProto = jsb_cocos2d_ParticleSystem3D_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +void register_all_cocos2dx_3d_extension(JSContext* cx, JS::HandleObject obj) { + // Get the ns + JS::RootedObject ns(cx); + get_or_create_js_obj(cx, obj, "jsb", &ns); + + js_register_cocos2dx_3d_extension_ParticleSystem3D(cx, ns); + js_register_cocos2dx_3d_extension_PUParticleSystem3D(cx, ns); +} + diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.hpp new file mode 100644 index 0000000000..145a09168d --- /dev/null +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.hpp @@ -0,0 +1,74 @@ +#ifndef __cocos2dx_3d_extension_h__ +#define __cocos2dx_3d_extension_h__ + +#include "jsapi.h" +#include "jsfriendapi.h" + + +extern JSClass *jsb_cocos2d_ParticleSystem3D_class; +extern JSObject *jsb_cocos2d_ParticleSystem3D_prototype; + +bool js_cocos2dx_3d_extension_ParticleSystem3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_3d_extension_ParticleSystem3D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_3d_extension_ParticleSystem3D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_3d_extension(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_3d_extension_ParticleSystem3D_resumeParticleSystem(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_ParticleSystem3D_startParticleSystem(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_ParticleSystem3D_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_ParticleSystem3D_isKeepLocal(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_ParticleSystem3D_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_ParticleSystem3D_getParticleQuota(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_ParticleSystem3D_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_ParticleSystem3D_pauseParticleSystem(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_ParticleSystem3D_getState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_ParticleSystem3D_getAliveParticleCount(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_ParticleSystem3D_setParticleQuota(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_ParticleSystem3D_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_ParticleSystem3D_stopParticleSystem(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_ParticleSystem3D_setKeepLocal(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_ParticleSystem3D_ParticleSystem3D(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_PUParticleSystem3D_class; +extern JSObject *jsb_cocos2d_PUParticleSystem3D_prototype; + +bool js_cocos2dx_3d_extension_PUParticleSystem3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_3d_extension_PUParticleSystem3D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_3d_extension_PUParticleSystem3D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_3d_extension(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_initWithFilePath(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getParticleSystemScaleVelocity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_setEmittedSystemQuota(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getDefaultDepth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getEmittedSystemQuota(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_initWithFilePathAndMaterialPath(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_clearAllParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getMaterialName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_calulateRotationOffset(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getMaxVelocity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_forceUpdate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getTimeElapsedSinceStart(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getEmittedEmitterQuota(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_isMarkedForEmission(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getDefaultWidth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_setEmittedEmitterQuota(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_setMarkedForEmission(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_clone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultWidth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_copyAttributesTo(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_setMaterialName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getParentParticleSystem(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_setMaxVelocity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getDefaultHeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_rotationOffset(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedOrientation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_removeAllEmitter(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_setParticleSystemScaleVelocity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_getDerivedScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultHeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_removeAllListener(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_setDefaultDepth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_PUParticleSystem3D_PUParticleSystem3D(JSContext *cx, uint32_t argc, jsval *vp); +#endif + diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp new file mode 100644 index 0000000000..ef102ab1aa --- /dev/null +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp @@ -0,0 +1,66336 @@ +#include "jsb_cocos2dx_auto.hpp" +#include "cocos2d_specifics.hpp" +#include "cocos2d.h" +#include "SimpleAudioEngine.h" +#include "CCProtectedNode.h" +#include "CCAsyncTaskPool.h" + +template +static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedValue initializing(cx); + bool isNewValid = true; + JS::RootedObject global(cx, ScriptingCore::getInstance()->getGlobalObject()); + isNewValid = JS_GetProperty(cx, global, "initializing", &initializing) && initializing.toBoolean(); + if (isNewValid) + { + 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."); + + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + + args.rval().set(OBJECT_TO_JSVAL(_tmp)); + return true; + } + + JS_ReportError(cx, "Constructor for the requested class is not available, please refer to the API reference."); + return false; +} + +static bool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) { + return false; +} + +static bool js_is_native_obj(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().setBoolean(true); + return true; +} +JSClass *jsb_cocos2d_Action_class; +JSObject *jsb_cocos2d_Action_prototype; + +bool js_cocos2dx_Action_startWithTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Action_startWithTarget : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Action_startWithTarget : Error processing arguments"); + cobj->startWithTarget(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Action_startWithTarget : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Action_setOriginalTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Action_setOriginalTarget : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Action_setOriginalTarget : Error processing arguments"); + cobj->setOriginalTarget(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Action_setOriginalTarget : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Action_clone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Action_clone : Invalid Native Object"); + if (argc == 0) { + cocos2d::Action* ret = cobj->clone(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Action*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Action_clone : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Action_getOriginalTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Action_getOriginalTarget : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getOriginalTarget(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Action_getOriginalTarget : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Action_stop(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Action_stop : Invalid Native Object"); + if (argc == 0) { + cobj->stop(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Action_stop : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Action_update(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Action_update : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Action_update : Error processing arguments"); + cobj->update(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Action_update : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Action_getTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Action_getTarget : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getTarget(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Action_getTarget : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Action_step(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Action_step : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Action_step : Error processing arguments"); + cobj->step(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Action_step : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Action_setTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Action_setTag : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Action_setTag : Error processing arguments"); + cobj->setTag(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Action_setTag : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Action_getTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Action_getTag : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getTag(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Action_getTag : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Action_setTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Action_setTarget : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Action_setTarget : Error processing arguments"); + cobj->setTarget(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Action_setTarget : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Action_isDone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Action_isDone : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isDone(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Action_isDone : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Action_reverse(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Action* cobj = (cocos2d::Action *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Action_reverse : Invalid Native Object"); + if (argc == 0) { + cocos2d::Action* ret = cobj->reverse(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Action*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Action_reverse : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + + +void js_cocos2d_Action_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Action)", obj); +} + +void js_register_cocos2dx_Action(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Action_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Action_class->name = "Action"; + jsb_cocos2d_Action_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Action_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Action_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Action_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Action_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Action_class->resolve = JS_ResolveStub; + jsb_cocos2d_Action_class->convert = JS_ConvertStub; + jsb_cocos2d_Action_class->finalize = js_cocos2d_Action_finalize; + jsb_cocos2d_Action_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("startWithTarget", js_cocos2dx_Action_startWithTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setOriginalTarget", js_cocos2dx_Action_setOriginalTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("clone", js_cocos2dx_Action_clone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOriginalTarget", js_cocos2dx_Action_getOriginalTarget, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("stop", js_cocos2dx_Action_stop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("update", js_cocos2dx_Action_update, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTarget", js_cocos2dx_Action_getTarget, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("step", js_cocos2dx_Action_step, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTag", js_cocos2dx_Action_setTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTag", js_cocos2dx_Action_getTag, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTarget", js_cocos2dx_Action_setTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isDone", js_cocos2dx_Action_isDone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("reverse", js_cocos2dx_Action_reverse, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_Action_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_Action_class, + empty_constructor, 0, + 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, "Action", 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_Action_class; + p->proto = jsb_cocos2d_Action_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_FiniteTimeAction_class; +JSObject *jsb_cocos2d_FiniteTimeAction_prototype; + +bool js_cocos2dx_FiniteTimeAction_setDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FiniteTimeAction* cobj = (cocos2d::FiniteTimeAction *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FiniteTimeAction_setDuration : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FiniteTimeAction_setDuration : Error processing arguments"); + cobj->setDuration(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FiniteTimeAction_setDuration : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FiniteTimeAction_getDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FiniteTimeAction* cobj = (cocos2d::FiniteTimeAction *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FiniteTimeAction_getDuration : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getDuration(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FiniteTimeAction_getDuration : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +extern JSObject *jsb_cocos2d_Action_prototype; + +void js_cocos2d_FiniteTimeAction_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (FiniteTimeAction)", obj); +} + +void js_register_cocos2dx_FiniteTimeAction(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_FiniteTimeAction_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_FiniteTimeAction_class->name = "FiniteTimeAction"; + jsb_cocos2d_FiniteTimeAction_class->addProperty = JS_PropertyStub; + jsb_cocos2d_FiniteTimeAction_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_FiniteTimeAction_class->getProperty = JS_PropertyStub; + jsb_cocos2d_FiniteTimeAction_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_FiniteTimeAction_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_FiniteTimeAction_class->resolve = JS_ResolveStub; + jsb_cocos2d_FiniteTimeAction_class->convert = JS_ConvertStub; + jsb_cocos2d_FiniteTimeAction_class->finalize = js_cocos2d_FiniteTimeAction_finalize; + jsb_cocos2d_FiniteTimeAction_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setDuration", js_cocos2dx_FiniteTimeAction_setDuration, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDuration", js_cocos2dx_FiniteTimeAction_getDuration, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_FiniteTimeAction_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Action_prototype), + jsb_cocos2d_FiniteTimeAction_class, + empty_constructor, 0, + 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, "FiniteTimeAction", 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_FiniteTimeAction_class; + p->proto = jsb_cocos2d_FiniteTimeAction_prototype; + p->parentProto = jsb_cocos2d_Action_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Speed_class; +JSObject *jsb_cocos2d_Speed_prototype; + +bool js_cocos2dx_Speed_setInnerAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Speed* cobj = (cocos2d::Speed *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Speed_setInnerAction : Invalid Native Object"); + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Speed_setInnerAction : Error processing arguments"); + cobj->setInnerAction(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Speed_setInnerAction : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Speed_getSpeed(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Speed* cobj = (cocos2d::Speed *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Speed_getSpeed : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getSpeed(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Speed_getSpeed : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Speed_setSpeed(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Speed* cobj = (cocos2d::Speed *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Speed_setSpeed : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Speed_setSpeed : Error processing arguments"); + cobj->setSpeed(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Speed_setSpeed : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Speed_initWithAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Speed* cobj = (cocos2d::Speed *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Speed_initWithAction : Invalid Native Object"); + if (argc == 2) { + cocos2d::ActionInterval* arg0; + double arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Speed_initWithAction : Error processing arguments"); + bool ret = cobj->initWithAction(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Speed_initWithAction : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_Speed_getInnerAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Speed* cobj = (cocos2d::Speed *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Speed_getInnerAction : Invalid Native Object"); + if (argc == 0) { + cocos2d::ActionInterval* ret = cobj->getInnerAction(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Speed_getInnerAction : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Speed_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::ActionInterval* arg0; + double arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Speed_create : Error processing arguments"); + cocos2d::Speed* ret = cocos2d::Speed::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Speed*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Speed_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Speed_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Speed* cobj = new (std::nothrow) cocos2d::Speed(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Speed"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Action_prototype; + +void js_cocos2d_Speed_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Speed)", obj); +} + +void js_register_cocos2dx_Speed(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Speed_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Speed_class->name = "Speed"; + jsb_cocos2d_Speed_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Speed_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Speed_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Speed_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Speed_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Speed_class->resolve = JS_ResolveStub; + jsb_cocos2d_Speed_class->convert = JS_ConvertStub; + jsb_cocos2d_Speed_class->finalize = js_cocos2d_Speed_finalize; + jsb_cocos2d_Speed_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setInnerAction", js_cocos2dx_Speed_setInnerAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("_getSpeed", js_cocos2dx_Speed_getSpeed, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("_setSpeed", js_cocos2dx_Speed_setSpeed, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithAction", js_cocos2dx_Speed_initWithAction, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInnerAction", js_cocos2dx_Speed_getInnerAction, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Speed_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Speed_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Action_prototype), + jsb_cocos2d_Speed_class, + js_cocos2dx_Speed_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, "Speed", 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_Speed_class; + p->proto = jsb_cocos2d_Speed_prototype; + p->parentProto = jsb_cocos2d_Action_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Follow_class; +JSObject *jsb_cocos2d_Follow_prototype; + +bool js_cocos2dx_Follow_setBoundarySet(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Follow_setBoundarySet : Error processing arguments"); + cobj->setBoundarySet(arg0); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_initWithTarget : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Follow_initWithTarget : Error processing arguments"); + bool ret = cobj->initWithTarget(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + cocos2d::Node* arg0; + cocos2d::Rect arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Follow_initWithTarget : Error processing arguments"); + bool ret = cobj->initWithTarget(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Follow_initWithTarget : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Follow_isBoundarySet(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isBoundarySet : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isBoundarySet(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Follow_isBoundarySet : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Follow_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Follow_create : Error processing arguments"); + cocos2d::Follow* ret = cocos2d::Follow::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Follow*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + cocos2d::Node* arg0; + cocos2d::Rect arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Follow_create : Error processing arguments"); + cocos2d::Follow* ret = cocos2d::Follow::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Follow*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Follow_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Follow_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Follow* cobj = new (std::nothrow) cocos2d::Follow(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Follow"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Action_prototype; + +void js_cocos2d_Follow_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Follow)", obj); +} + +void js_register_cocos2dx_Follow(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Follow_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Follow_class->name = "Follow"; + jsb_cocos2d_Follow_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Follow_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Follow_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Follow_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Follow_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Follow_class->resolve = JS_ResolveStub; + jsb_cocos2d_Follow_class->convert = JS_ConvertStub; + jsb_cocos2d_Follow_class->finalize = js_cocos2d_Follow_finalize; + jsb_cocos2d_Follow_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + 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("isBoundarySet", js_cocos2dx_Follow_isBoundarySet, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Follow_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Follow_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Action_prototype), + jsb_cocos2d_Follow_class, + js_cocos2dx_Follow_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, "Follow", 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_Follow_class; + p->proto = jsb_cocos2d_Follow_prototype; + p->parentProto = jsb_cocos2d_Action_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Texture2D_class; +JSObject *jsb_cocos2d_Texture2D_prototype; + +bool js_cocos2dx_Texture2D_getGLProgram(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_getGLProgram : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Texture2D_getMaxT(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_getMaxT : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getMaxT(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_getMaxT : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Texture2D_getStringForFormat(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_getStringForFormat : Invalid Native Object"); + if (argc == 0) { + const char* ret = cobj->getStringForFormat(); + jsval jsret = JSVAL_NULL; + jsret = c_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_getStringForFormat : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Texture2D_initWithImage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Texture2D* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_initWithImage : Invalid Native Object"); + do { + if (argc == 2) { + cocos2d::Image* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Image*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Texture2D::PixelFormat arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithImage(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::Image* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Image*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithImage(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Texture2D_initWithImage : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Texture2D_setGLProgram(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_setGLProgram : Invalid Native Object"); + if (argc == 1) { + cocos2d::GLProgram* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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_Texture2D_setGLProgram : Error processing arguments"); + cobj->setGLProgram(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_setGLProgram : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Texture2D_getMaxS(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_getMaxS : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getMaxS(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_getMaxS : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Texture2D_releaseGLTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_releaseGLTexture : Invalid Native Object"); + if (argc == 0) { + cobj->releaseGLTexture(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_releaseGLTexture : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Texture2D_hasPremultipliedAlpha(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_hasPremultipliedAlpha : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->hasPremultipliedAlpha(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_hasPremultipliedAlpha : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Texture2D_initWithMipmaps(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_initWithMipmaps : Invalid Native Object"); + if (argc == 5) { + cocos2d::_MipmapInfo* arg0; + int arg1; + cocos2d::Texture2D::PixelFormat arg2; + int arg3; + int arg4; + #pragma warning NO CONVERSION TO NATIVE FOR _MipmapInfo* + ok = false; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Texture2D_initWithMipmaps : Error processing arguments"); + bool ret = cobj->initWithMipmaps(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_initWithMipmaps : wrong number of arguments: %d, was expecting %d", argc, 5); + return false; +} +bool js_cocos2dx_Texture2D_getPixelsHigh(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_getPixelsHigh : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getPixelsHigh(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_getPixelsHigh : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Texture2D_getBitsPerPixelForFormat(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Texture2D* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_getBitsPerPixelForFormat : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::Texture2D::PixelFormat arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + unsigned int ret = cobj->getBitsPerPixelForFormat(arg0); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + unsigned int ret = cobj->getBitsPerPixelForFormat(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Texture2D_getBitsPerPixelForFormat : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Texture2D_getName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_getName : Invalid Native Object"); + if (argc == 0) { + unsigned int ret = cobj->getName(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_getName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Texture2D_initWithString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Texture2D* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_initWithString : Invalid Native Object"); + do { + if (argc == 2) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + if (!ok) { ok = true; break; } + cocos2d::FontDefinition arg1; + ok &= jsval_to_FontDefinition(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithString(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 3) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithString(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 4) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::Size arg3; + ok &= jsval_to_ccsize(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithString(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 5) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::Size arg3; + ok &= jsval_to_ccsize(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + cocos2d::TextHAlignment arg4; + ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 6) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::Size arg3; + ok &= jsval_to_ccsize(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + cocos2d::TextHAlignment arg4; + ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); + if (!ok) { ok = true; break; } + cocos2d::TextVAlignment arg5; + ok &= jsval_to_int32(cx, args.get(5), (int32_t *)&arg5); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Texture2D_initWithString : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Texture2D_setMaxT(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_setMaxT : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Texture2D_setMaxT : Error processing arguments"); + cobj->setMaxT(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_setMaxT : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Texture2D_drawInRect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_drawInRect : Invalid Native Object"); + if (argc == 1) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Texture2D_drawInRect : Error processing arguments"); + cobj->drawInRect(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_drawInRect : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Texture2D_getContentSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_getContentSize : Invalid Native Object"); + if (argc == 0) { + cocos2d::Size ret = cobj->getContentSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_getContentSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Texture2D_setAliasTexParameters(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_setAliasTexParameters : Invalid Native Object"); + if (argc == 0) { + cobj->setAliasTexParameters(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_setAliasTexParameters : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Texture2D_setAntiAliasTexParameters(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_setAntiAliasTexParameters : Invalid Native Object"); + if (argc == 0) { + cobj->setAntiAliasTexParameters(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_setAntiAliasTexParameters : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Texture2D_generateMipmap(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_generateMipmap : Invalid Native Object"); + if (argc == 0) { + cobj->generateMipmap(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_generateMipmap : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Texture2D_getDescription(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_getDescription : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getDescription(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_getDescription : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Texture2D_getPixelFormat(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_getPixelFormat : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getPixelFormat(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_getPixelFormat : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Texture2D_getContentSizeInPixels(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_getContentSizeInPixels : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getContentSizeInPixels(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_getContentSizeInPixels : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Texture2D_getPixelsWide(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_getPixelsWide : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getPixelsWide(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_getPixelsWide : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Texture2D_drawAtPoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_drawAtPoint : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Texture2D_drawAtPoint : Error processing arguments"); + cobj->drawAtPoint(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_drawAtPoint : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Texture2D_hasMipmaps(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_hasMipmaps : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->hasMipmaps(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_hasMipmaps : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Texture2D_setMaxS(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_setMaxS : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Texture2D_setMaxS : Error processing arguments"); + cobj->setMaxS(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Texture2D_setMaxS : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Texture2D_setDefaultAlphaPixelFormat(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Texture2D::PixelFormat arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Texture2D_setDefaultAlphaPixelFormat : Error processing arguments"); + cocos2d::Texture2D::setDefaultAlphaPixelFormat(arg0); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Texture2D_setDefaultAlphaPixelFormat : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Texture2D_getDefaultAlphaPixelFormat(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + int ret = (int)cocos2d::Texture2D::getDefaultAlphaPixelFormat(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Texture2D_getDefaultAlphaPixelFormat : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Texture2D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Texture2D* cobj = new (std::nothrow) cocos2d::Texture2D(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Texture2D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_Texture2D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Texture2D)", obj); +} + +void js_register_cocos2dx_Texture2D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Texture2D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Texture2D_class->name = "Texture2D"; + jsb_cocos2d_Texture2D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Texture2D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Texture2D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Texture2D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Texture2D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Texture2D_class->resolve = JS_ResolveStub; + jsb_cocos2d_Texture2D_class->convert = JS_ConvertStub; + jsb_cocos2d_Texture2D_class->finalize = js_cocos2d_Texture2D_finalize; + jsb_cocos2d_Texture2D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getShaderProgram", js_cocos2dx_Texture2D_getGLProgram, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaxT", js_cocos2dx_Texture2D_getMaxT, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStringForFormat", js_cocos2dx_Texture2D_getStringForFormat, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithImage", js_cocos2dx_Texture2D_initWithImage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setShaderProgram", js_cocos2dx_Texture2D_setGLProgram, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaxS", js_cocos2dx_Texture2D_getMaxS, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("releaseGLTexture", js_cocos2dx_Texture2D_releaseGLTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("hasPremultipliedAlpha", js_cocos2dx_Texture2D_hasPremultipliedAlpha, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithMipmaps", js_cocos2dx_Texture2D_initWithMipmaps, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPixelsHigh", js_cocos2dx_Texture2D_getPixelsHigh, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBitsPerPixelForFormat", js_cocos2dx_Texture2D_getBitsPerPixelForFormat, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getName", js_cocos2dx_Texture2D_getName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithString", js_cocos2dx_Texture2D_initWithString, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaxT", js_cocos2dx_Texture2D_setMaxT, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawInRect", js_cocos2dx_Texture2D_drawInRect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getContentSize", js_cocos2dx_Texture2D_getContentSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAliasTexParameters", js_cocos2dx_Texture2D_setAliasTexParameters, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAntiAliasTexParameters", js_cocos2dx_Texture2D_setAntiAliasTexParameters, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("generateMipmap", js_cocos2dx_Texture2D_generateMipmap, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDescription", js_cocos2dx_Texture2D_getDescription, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPixelFormat", js_cocos2dx_Texture2D_getPixelFormat, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getContentSizeInPixels", js_cocos2dx_Texture2D_getContentSizeInPixels, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPixelsWide", js_cocos2dx_Texture2D_getPixelsWide, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawAtPoint", js_cocos2dx_Texture2D_drawAtPoint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("hasMipmaps", js_cocos2dx_Texture2D_hasMipmaps, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaxS", js_cocos2dx_Texture2D_setMaxS, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("setDefaultAlphaPixelFormat", js_cocos2dx_Texture2D_setDefaultAlphaPixelFormat, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDefaultAlphaPixelFormat", js_cocos2dx_Texture2D_getDefaultAlphaPixelFormat, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Texture2D_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_Texture2D_class, + js_cocos2dx_Texture2D_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, "Texture2D", 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_Texture2D_class; + p->proto = jsb_cocos2d_Texture2D_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Touch_class; +JSObject *jsb_cocos2d_Touch_prototype; + +bool js_cocos2dx_Touch_getPreviousLocationInView(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Touch* cobj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Touch_getPreviousLocationInView : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getPreviousLocationInView(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Touch_getPreviousLocationInView : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Touch_getLocation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Touch* cobj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Touch_getLocation : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getLocation(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Touch_getLocation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Touch_getDelta(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Touch* cobj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Touch_getDelta : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getDelta(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Touch_getDelta : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Touch_getStartLocationInView(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Touch* cobj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Touch_getStartLocationInView : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getStartLocationInView(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Touch_getStartLocationInView : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Touch_getStartLocation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Touch* cobj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Touch_getStartLocation : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getStartLocation(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Touch_getStartLocation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Touch_getID(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Touch* cobj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Touch_getID : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getID(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Touch_getID : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Touch_setTouchInfo(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Touch* cobj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Touch_setTouchInfo : Invalid Native Object"); + if (argc == 3) { + int arg0; + double arg1; + double arg2; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Touch_setTouchInfo : Error processing arguments"); + cobj->setTouchInfo(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Touch_setTouchInfo : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_Touch_getLocationInView(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Touch* cobj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Touch_getLocationInView : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getLocationInView(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Touch_getLocationInView : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Touch_getPreviousLocation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Touch* cobj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Touch_getPreviousLocation : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getPreviousLocation(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Touch_getPreviousLocation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Touch_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Touch* cobj = new (std::nothrow) cocos2d::Touch(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Touch"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_Touch_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Touch)", obj); +} + +void js_register_cocos2dx_Touch(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Touch_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Touch_class->name = "Touch"; + jsb_cocos2d_Touch_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Touch_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Touch_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Touch_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Touch_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Touch_class->resolve = JS_ResolveStub; + jsb_cocos2d_Touch_class->convert = JS_ConvertStub; + jsb_cocos2d_Touch_class->finalize = js_cocos2d_Touch_finalize; + jsb_cocos2d_Touch_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getPreviousLocationInView", js_cocos2dx_Touch_getPreviousLocationInView, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLocation", js_cocos2dx_Touch_getLocation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDelta", js_cocos2dx_Touch_getDelta, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStartLocationInView", js_cocos2dx_Touch_getStartLocationInView, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStartLocation", js_cocos2dx_Touch_getStartLocation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getID", js_cocos2dx_Touch_getID, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTouchInfo", js_cocos2dx_Touch_setTouchInfo, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLocationInView", js_cocos2dx_Touch_getLocationInView, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPreviousLocation", js_cocos2dx_Touch_getPreviousLocation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_Touch_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_Touch_class, + js_cocos2dx_Touch_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, "Touch", 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_Touch_class; + p->proto = jsb_cocos2d_Touch_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Event_class; +JSObject *jsb_cocos2d_Event_prototype; + +bool js_cocos2dx_Event_isStopped(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Event* cobj = (cocos2d::Event *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Event_isStopped : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isStopped(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Event_isStopped : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Event_getType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Event* cobj = (cocos2d::Event *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Event_getType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Event_getType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Event_getCurrentTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Event* cobj = (cocos2d::Event *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Event_getCurrentTarget : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getCurrentTarget(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Event_getCurrentTarget : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Event_stopPropagation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Event* cobj = (cocos2d::Event *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Event_stopPropagation : Invalid Native Object"); + if (argc == 0) { + cobj->stopPropagation(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Event_stopPropagation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Event_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Event::Type arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Event_constructor : Error processing arguments"); + cocos2d::Event* cobj = new (std::nothrow) cocos2d::Event(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."); + // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Event"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_Event_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Event)", obj); +} + +void js_register_cocos2dx_Event(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Event_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Event_class->name = "Event"; + jsb_cocos2d_Event_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Event_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Event_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Event_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Event_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Event_class->resolve = JS_ResolveStub; + jsb_cocos2d_Event_class->convert = JS_ConvertStub; + jsb_cocos2d_Event_class->finalize = js_cocos2d_Event_finalize; + jsb_cocos2d_Event_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("isStopped", js_cocos2dx_Event_isStopped, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getType", js_cocos2dx_Event_getType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCurrentTarget", js_cocos2dx_Event_getCurrentTarget, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("stopPropagation", js_cocos2dx_Event_stopPropagation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_Event_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_Event_class, + js_cocos2dx_Event_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, "Event", 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_Event_class; + p->proto = jsb_cocos2d_Event_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EventTouch_class; +JSObject *jsb_cocos2d_EventTouch_prototype; + +bool js_cocos2dx_EventTouch_getEventCode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventTouch* cobj = (cocos2d::EventTouch *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventTouch_getEventCode : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getEventCode(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventTouch_getEventCode : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventTouch_setEventCode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventTouch* cobj = (cocos2d::EventTouch *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventTouch_setEventCode : Invalid Native Object"); + if (argc == 1) { + cocos2d::EventTouch::EventCode arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventTouch_setEventCode : Error processing arguments"); + cobj->setEventCode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventTouch_setEventCode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_EventTouch_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EventTouch* cobj = new (std::nothrow) cocos2d::EventTouch(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EventTouch"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Event_prototype; + +void js_cocos2d_EventTouch_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EventTouch)", obj); +} + +void js_register_cocos2dx_EventTouch(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EventTouch_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EventTouch_class->name = "EventTouch"; + jsb_cocos2d_EventTouch_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EventTouch_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EventTouch_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EventTouch_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EventTouch_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EventTouch_class->resolve = JS_ResolveStub; + jsb_cocos2d_EventTouch_class->convert = JS_ConvertStub; + jsb_cocos2d_EventTouch_class->finalize = js_cocos2d_EventTouch_finalize; + jsb_cocos2d_EventTouch_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getEventCode", js_cocos2dx_EventTouch_getEventCode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEventCode", js_cocos2dx_EventTouch_setEventCode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_EventTouch_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Event_prototype), + jsb_cocos2d_EventTouch_class, + js_cocos2dx_EventTouch_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, "EventTouch", 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_EventTouch_class; + p->proto = jsb_cocos2d_EventTouch_prototype; + p->parentProto = jsb_cocos2d_Event_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Node_class; +JSObject *jsb_cocos2d_Node_prototype; + +bool js_cocos2dx_Node_addChild(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Node* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_addChild : Invalid Native Object"); + do { + if (argc == 2) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cobj->addChild(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cobj->addChild(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 3) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + int arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + cobj->addChild(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 3) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cobj->addChild(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Node_addChild : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Node_removeComponent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Node* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_removeComponent : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::Component* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Component*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + bool ret = cobj->removeComponent(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + bool ret = cobj->removeComponent(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Node_removeComponent : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Node_setPhysicsBody(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setPhysicsBody : Invalid Native Object"); + if (argc == 1) { + cocos2d::PhysicsBody* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::PhysicsBody*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setPhysicsBody : Error processing arguments"); + cobj->setPhysicsBody(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setPhysicsBody : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_getGLProgram(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getGLProgram : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_updateTransformFromPhysics(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_updateTransformFromPhysics : Invalid Native Object"); + if (argc == 2) { + cocos2d::Mat4 arg0; + unsigned int arg1; + ok &= jsval_to_matrix(cx, args.get(0), &arg0); + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_updateTransformFromPhysics : Error processing arguments"); + cobj->updateTransformFromPhysics(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_updateTransformFromPhysics : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_Node_getDescription(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getDescription : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getDescription(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getDescription : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_setOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setOpacityModifyRGB : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setOpacityModifyRGB : Error processing arguments"); + cobj->setOpacityModifyRGB(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setOpacityModifyRGB : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setCascadeOpacityEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setCascadeOpacityEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setCascadeOpacityEnabled : Error processing arguments"); + cobj->setCascadeOpacityEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setCascadeOpacityEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_getChildren(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Node* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getChildren : Invalid Native Object"); + do { + if (argc == 0) { + const cocos2d::Vector& ret = cobj->getChildren(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + cocos2d::Vector& ret = cobj->getChildren(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Node_getChildren : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Node_setOnExitCallback(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setOnExitCallback : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + auto lambda = [=]() -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + JS::RootedValue rval(cx); + 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"); + cobj->setOnExitCallback(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setOnExitCallback : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_isIgnoreAnchorPointForPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isIgnoreAnchorPointForPosition : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isIgnoreAnchorPointForPosition(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_isIgnoreAnchorPointForPosition : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getChildByName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getChildByName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_getChildByName : Error processing arguments"); + cocos2d::Node* ret = cobj->getChildByName(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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getChildByName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_updateDisplayedOpacity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_updateDisplayedOpacity : Invalid Native Object"); + if (argc == 1) { + uint16_t arg0; + ok &= jsval_to_uint16(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_updateDisplayedOpacity : Error processing arguments"); + cobj->updateDisplayedOpacity(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_updateDisplayedOpacity : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getCameraMask(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getCameraMask : Invalid Native Object"); + if (argc == 0) { + unsigned short ret = cobj->getCameraMask(); + jsval jsret = JSVAL_NULL; + jsret = ushort_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getCameraMask : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_setRotation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setRotation : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setRotation : Error processing arguments"); + cobj->setRotation(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setRotation : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setScaleZ(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setScaleZ : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setScaleZ : Error processing arguments"); + cobj->setScaleZ(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setScaleZ : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setScaleY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setScaleY : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setScaleY : Error processing arguments"); + cobj->setScaleY(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setScaleY : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setScaleX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setScaleX : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setScaleX : Error processing arguments"); + cobj->setScaleX(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setScaleX : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_getColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getColor : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color3B& ret = cobj->getColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor3b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_setonEnterTransitionDidFinishCallback(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setonEnterTransitionDidFinishCallback : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + auto lambda = [=]() -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + JS::RootedValue rval(cx); + 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"); + cobj->setonEnterTransitionDidFinishCallback(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setonEnterTransitionDidFinishCallback : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_removeFromPhysicsWorld(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_removeFromPhysicsWorld : Invalid Native Object"); + if (argc == 0) { + cobj->removeFromPhysicsWorld(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_removeFromPhysicsWorld : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_removeAllComponents(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_removeAllComponents : Invalid Native Object"); + if (argc == 0) { + cobj->removeAllComponents(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_removeAllComponents : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getOpacity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getOpacity : Invalid Native Object"); + if (argc == 0) { + uint16_t ret = cobj->getOpacity(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getOpacity : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_setCameraMask(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setCameraMask : Invalid Native Object"); + if (argc == 1) { + unsigned short arg0; + ok &= jsval_to_ushort(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setCameraMask : Error processing arguments"); + cobj->setCameraMask(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + unsigned short arg0; + bool arg1; + ok &= jsval_to_ushort(cx, args.get(0), &arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setCameraMask : Error processing arguments"); + cobj->setCameraMask(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setCameraMask : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_getTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getTag : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getTag(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getTag : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getonEnterTransitionDidFinishCallback(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getonEnterTransitionDidFinishCallback : Invalid Native Object"); + if (argc == 0) { + const std::function& ret = cobj->getonEnterTransitionDidFinishCallback(); + jsval jsret = JSVAL_NULL; + #pragma warning NO CONVERSION FROM NATIVE FOR std::function; + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getonEnterTransitionDidFinishCallback : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_isOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isOpacityModifyRGB : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isOpacityModifyRGB(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_isOpacityModifyRGB : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getNodeToWorldAffineTransform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getNodeToWorldAffineTransform : Invalid Native Object"); + if (argc == 0) { + cocos2d::AffineTransform ret = cobj->getNodeToWorldAffineTransform(); + jsval jsret = JSVAL_NULL; + jsret = ccaffinetransform_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getNodeToWorldAffineTransform : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getPosition3D(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getPosition3D : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec3 ret = cobj->getPosition3D(); + jsval jsret = JSVAL_NULL; + jsret = vector3_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getPosition3D : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_removeChild(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_removeChild : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_removeChild : Error processing arguments"); + cobj->removeChild(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + cocos2d::Node* arg0; + bool arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_removeChild : Error processing arguments"); + cobj->removeChild(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_removeChild : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_getScene(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getScene : Invalid Native Object"); + if (argc == 0) { + cocos2d::Scene* ret = cobj->getScene(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Scene*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getScene : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getEventDispatcher(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getEventDispatcher : Invalid Native Object"); + if (argc == 0) { + cocos2d::EventDispatcher* ret = cobj->getEventDispatcher(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EventDispatcher*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getEventDispatcher : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_setSkewX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setSkewX : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setSkewX : Error processing arguments"); + cobj->setSkewX(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setSkewX : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setGLProgramState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setGLProgramState : Invalid Native Object"); + if (argc == 1) { + cocos2d::GLProgramState* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::GLProgramState*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setGLProgramState : Error processing arguments"); + cobj->setGLProgramState(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setGLProgramState : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setOnEnterCallback(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setOnEnterCallback : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + auto lambda = [=]() -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + JS::RootedValue rval(cx); + 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"); + cobj->setOnEnterCallback(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setOnEnterCallback : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setNormalizedPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setNormalizedPosition : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setNormalizedPosition : Error processing arguments"); + cobj->setNormalizedPosition(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setNormalizedPosition : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setonExitTransitionDidStartCallback(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setonExitTransitionDidStartCallback : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + auto lambda = [=]() -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + JS::RootedValue rval(cx); + 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"); + cobj->setonExitTransitionDidStartCallback(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setonExitTransitionDidStartCallback : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_convertTouchToNodeSpace(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_convertTouchToNodeSpace : Invalid Native Object"); + if (argc == 1) { + cocos2d::Touch* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_convertTouchToNodeSpace : Error processing arguments"); + cocos2d::Vec2 ret = cobj->convertTouchToNodeSpace(arg0); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_convertTouchToNodeSpace : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Node* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_removeAllChildrenWithCleanup : Invalid Native Object"); + do { + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + cobj->removeAllChildrenWithCleanup(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 0) { + cobj->removeAllChildren(); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Node_removeAllChildrenWithCleanup : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Node_getRotationSkewX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getRotationSkewX : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getRotationSkewX(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getRotationSkewX : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getRotationSkewY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getRotationSkewY : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getRotationSkewY(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getRotationSkewY : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getNodeToWorldTransform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getNodeToWorldTransform : Invalid Native Object"); + if (argc == 0) { + cocos2d::Mat4 ret = cobj->getNodeToWorldTransform(); + jsval jsret = JSVAL_NULL; + jsret = matrix_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getNodeToWorldTransform : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_isCascadeOpacityEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isCascadeOpacityEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isCascadeOpacityEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_isCascadeOpacityEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_setParent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setParent : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setParent : Error processing arguments"); + cobj->setParent(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setParent : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_getName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getName : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getRotation3D(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getRotation3D : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec3 ret = cobj->getRotation3D(); + jsval jsret = JSVAL_NULL; + jsret = vector3_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getRotation3D : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getNodeToParentAffineTransform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getNodeToParentAffineTransform : Invalid Native Object"); + if (argc == 0) { + cocos2d::AffineTransform ret = cobj->getNodeToParentAffineTransform(); + jsval jsret = JSVAL_NULL; + jsret = ccaffinetransform_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getNodeToParentAffineTransform : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_convertTouchToNodeSpaceAR(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_convertTouchToNodeSpaceAR : Invalid Native Object"); + if (argc == 1) { + cocos2d::Touch* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_convertTouchToNodeSpaceAR : Error processing arguments"); + cocos2d::Vec2 ret = cobj->convertTouchToNodeSpaceAR(arg0); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_convertTouchToNodeSpaceAR : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_getOnEnterCallback(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getOnEnterCallback : Invalid Native Object"); + if (argc == 0) { + const std::function& ret = cobj->getOnEnterCallback(); + jsval jsret = JSVAL_NULL; + #pragma warning NO CONVERSION FROM NATIVE FOR std::function; + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getOnEnterCallback : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getPhysicsBody(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getPhysicsBody : Invalid Native Object"); + if (argc == 0) { + cocos2d::PhysicsBody* ret = cobj->getPhysicsBody(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::PhysicsBody*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getPhysicsBody : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_stopActionByTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_stopActionByTag : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_stopActionByTag : Error processing arguments"); + cobj->stopActionByTag(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_stopActionByTag : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_reorderChild(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_reorderChild : Invalid Native Object"); + if (argc == 2) { + cocos2d::Node* arg0; + int arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_reorderChild : Error processing arguments"); + cobj->reorderChild(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_reorderChild : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_Node_ignoreAnchorPointForPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_ignoreAnchorPointForPosition : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_ignoreAnchorPointForPosition : Error processing arguments"); + cobj->ignoreAnchorPointForPosition(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_ignoreAnchorPointForPosition : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setSkewY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setSkewY : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setSkewY : Error processing arguments"); + cobj->setSkewY(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setSkewY : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setRotation3D(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setRotation3D : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec3 arg0; + ok &= jsval_to_vector3(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setRotation3D : Error processing arguments"); + cobj->setRotation3D(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setRotation3D : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setPositionX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setPositionX : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setPositionX : Error processing arguments"); + cobj->setPositionX(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setPositionX : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setNodeToParentTransform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setNodeToParentTransform : Invalid Native Object"); + if (argc == 1) { + cocos2d::Mat4 arg0; + ok &= jsval_to_matrix(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setNodeToParentTransform : Error processing arguments"); + cobj->setNodeToParentTransform(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setNodeToParentTransform : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_getAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getAnchorPoint : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getAnchorPoint(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getAnchorPoint : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getNumberOfRunningActions(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getNumberOfRunningActions : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getNumberOfRunningActions(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getNumberOfRunningActions : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_updateTransform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_updateTransform : Invalid Native Object"); + if (argc == 0) { + cobj->updateTransform(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_updateTransform : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_isVisible(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isVisible : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isVisible(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_isVisible : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getChildrenCount(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getChildrenCount : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getChildrenCount(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getChildrenCount : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getNodeToParentTransform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getNodeToParentTransform : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Mat4& ret = cobj->getNodeToParentTransform(); + jsval jsret = JSVAL_NULL; + jsret = matrix_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getNodeToParentTransform : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_convertToNodeSpaceAR(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_convertToNodeSpaceAR : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_convertToNodeSpaceAR : Error processing arguments"); + cocos2d::Vec2 ret = cobj->convertToNodeSpaceAR(arg0); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_convertToNodeSpaceAR : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_addComponent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_addComponent : Invalid Native Object"); + if (argc == 1) { + cocos2d::Component* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Component*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_addComponent : Error processing arguments"); + bool ret = cobj->addComponent(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_addComponent : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_runAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_runAction : Invalid Native Object"); + if (argc == 1) { + cocos2d::Action* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Action*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_runAction : Error processing arguments"); + cocos2d::Action* ret = cobj->runAction(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Action*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_runAction : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_visit(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Node* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_visit : Invalid Native Object"); + do { + if (argc == 0) { + cobj->visit(); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 3) { + cocos2d::Renderer* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Renderer*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Mat4 arg1; + ok &= jsval_to_matrix(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + unsigned int arg2; + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cobj->visit(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Node_visit : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Node_setGLProgram(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setGLProgram : Invalid Native Object"); + if (argc == 1) { + cocos2d::GLProgram* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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_Node_setGLProgram : Error processing arguments"); + cobj->setGLProgram(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setGLProgram : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_getRotation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getRotation : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getRotation(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getRotation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getAnchorPointInPoints(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getAnchorPointInPoints : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getAnchorPointInPoints(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getAnchorPointInPoints : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getRotationQuat(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getRotationQuat : Invalid Native Object"); + if (argc == 0) { + cocos2d::Quaternion ret = cobj->getRotationQuat(); + jsval jsret = JSVAL_NULL; + jsret = quaternion_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getRotationQuat : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_removeChildByName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_removeChildByName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_removeChildByName : Error processing arguments"); + cobj->removeChildByName(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + bool arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_removeChildByName : Error processing arguments"); + cobj->removeChildByName(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_removeChildByName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setPositionZ(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setPositionZ : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setPositionZ : Error processing arguments"); + cobj->setPositionZ(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setPositionZ : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_getGLProgramState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getGLProgramState : Invalid Native Object"); + if (argc == 0) { + cocos2d::GLProgramState* ret = cobj->getGLProgramState(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getGLProgramState : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_setScheduler(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setScheduler : Invalid Native Object"); + if (argc == 1) { + cocos2d::Scheduler* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Scheduler*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setScheduler : Error processing arguments"); + cobj->setScheduler(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setScheduler : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_stopAllActions(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_stopAllActions : Invalid Native Object"); + if (argc == 0) { + cobj->stopAllActions(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_stopAllActions : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getSkewX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getSkewX : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getSkewX(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getSkewX : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getSkewY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getSkewY : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getSkewY(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getSkewY : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_isScheduled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isScheduled : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_isScheduled : Error processing arguments"); + bool ret = cobj->isScheduled(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_isScheduled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_getDisplayedColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getDisplayedColor : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color3B& ret = cobj->getDisplayedColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor3b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getDisplayedColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getActionByTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getActionByTag : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_getActionByTag : Error processing arguments"); + cocos2d::Action* ret = cobj->getActionByTag(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Action*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getActionByTag : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setRotationSkewX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setRotationSkewX : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setRotationSkewX : Error processing arguments"); + cobj->setRotationSkewX(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setRotationSkewX : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setRotationSkewY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setRotationSkewY : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setRotationSkewY : Error processing arguments"); + cobj->setRotationSkewY(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setRotationSkewY : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setName : Error processing arguments"); + cobj->setName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_updatePhysicsBodyTransform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_updatePhysicsBodyTransform : Invalid Native Object"); + if (argc == 4) { + cocos2d::Mat4 arg0; + unsigned int arg1; + double arg2; + double arg3; + ok &= jsval_to_matrix(cx, args.get(0), &arg0); + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_updatePhysicsBodyTransform : Error processing arguments"); + cobj->updatePhysicsBodyTransform(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_updatePhysicsBodyTransform : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_Node_getDisplayedOpacity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getDisplayedOpacity : Invalid Native Object"); + if (argc == 0) { + uint16_t ret = cobj->getDisplayedOpacity(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getDisplayedOpacity : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getLocalZOrder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getLocalZOrder : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getLocalZOrder(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getLocalZOrder : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getScheduler(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Node* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getScheduler : Invalid Native Object"); + do { + if (argc == 0) { + const cocos2d::Scheduler* ret = cobj->getScheduler(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Scheduler*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + cocos2d::Scheduler* ret = cobj->getScheduler(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Scheduler*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Node_getScheduler : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Node_getOrderOfArrival(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getOrderOfArrival : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getOrderOfArrival(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getOrderOfArrival : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_setActionManager(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setActionManager : Invalid Native Object"); + if (argc == 1) { + cocos2d::ActionManager* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionManager*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setActionManager : Error processing arguments"); + cobj->setActionManager(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setActionManager : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_getPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Node* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getPosition : Invalid Native Object"); + do { + if (argc == 2) { + float* arg0; + #pragma warning NO CONVERSION TO NATIVE FOR float* + ok = false; + if (!ok) { ok = true; break; } + float* arg1; + #pragma warning NO CONVERSION TO NATIVE FOR float* + ok = false; + if (!ok) { ok = true; break; } + cobj->getPosition(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getPosition(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Node_getPosition : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Node_isRunning(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isRunning : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isRunning(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_isRunning : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getParent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Node* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getParent : Invalid Native Object"); + do { + if (argc == 0) { + const cocos2d::Node* ret = cobj->getParent(); + 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); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + cocos2d::Node* ret = cobj->getParent(); + 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); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Node_getParent : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Node_getWorldToNodeTransform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getWorldToNodeTransform : Invalid Native Object"); + if (argc == 0) { + cocos2d::Mat4 ret = cobj->getWorldToNodeTransform(); + jsval jsret = JSVAL_NULL; + jsret = matrix_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getWorldToNodeTransform : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getPositionY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getPositionY : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getPositionY(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getPositionY : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getPositionX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getPositionX : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getPositionX(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getPositionX : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_removeChildByTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_removeChildByTag : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_removeChildByTag : Error processing arguments"); + cobj->removeChildByTag(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + int arg0; + bool arg1; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_removeChildByTag : Error processing arguments"); + cobj->removeChildByTag(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_removeChildByTag : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setPositionY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setPositionY : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setPositionY : Error processing arguments"); + cobj->setPositionY(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setPositionY : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_updateDisplayedColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_updateDisplayedColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color3B arg0; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_updateDisplayedColor : Error processing arguments"); + cobj->updateDisplayedColor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_updateDisplayedColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setVisible(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setVisible : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setVisible : Error processing arguments"); + cobj->setVisible(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setVisible : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_getParentToNodeAffineTransform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getParentToNodeAffineTransform : Invalid Native Object"); + if (argc == 0) { + cocos2d::AffineTransform ret = cobj->getParentToNodeAffineTransform(); + jsval jsret = JSVAL_NULL; + jsret = ccaffinetransform_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getParentToNodeAffineTransform : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getPositionZ(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getPositionZ : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getPositionZ(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getPositionZ : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_setGlobalZOrder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setGlobalZOrder : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setGlobalZOrder : Error processing arguments"); + cobj->setGlobalZOrder(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setGlobalZOrder : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Node* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_setScale : Invalid Native Object"); + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + cobj->setScale(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cobj->setScale(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Node_setScale : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Node_getOnExitCallback(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getOnExitCallback : Invalid Native Object"); + if (argc == 0) { + const std::function& ret = cobj->getOnExitCallback(); + jsval jsret = JSVAL_NULL; + #pragma warning NO CONVERSION FROM NATIVE FOR std::function; + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getOnExitCallback : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getChildByTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getChildByTag : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_getChildByTag : Error processing arguments"); + cocos2d::Node* ret = cobj->getChildByTag(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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getChildByTag : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setOrderOfArrival(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setOrderOfArrival : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setOrderOfArrival : Error processing arguments"); + cobj->setOrderOfArrival(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setOrderOfArrival : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_getScaleZ(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getScaleZ : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getScaleZ(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getScaleZ : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getScaleY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getScaleY : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getScaleY(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getScaleY : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getScaleX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getScaleX : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getScaleX(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getScaleX : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_setLocalZOrder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setLocalZOrder : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setLocalZOrder : Error processing arguments"); + cobj->setLocalZOrder(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setLocalZOrder : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setCascadeColorEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setCascadeColorEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setCascadeColorEnabled : Error processing arguments"); + cobj->setCascadeColorEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setCascadeColorEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setOpacity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setOpacity : Invalid Native Object"); + if (argc == 1) { + uint16_t arg0; + ok &= jsval_to_uint16(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setOpacity : Error processing arguments"); + cobj->setOpacity(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setOpacity : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_cleanup(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_cleanup : Invalid Native Object"); + if (argc == 0) { + cobj->cleanup(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_cleanup : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getComponent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getComponent : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_getComponent : Error processing arguments"); + cocos2d::Component* ret = cobj->getComponent(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Component*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getComponent : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_getContentSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getContentSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getContentSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getContentSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_stopAllActionsByTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_stopAllActionsByTag : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_stopAllActionsByTag : Error processing arguments"); + cobj->stopAllActionsByTag(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_stopAllActionsByTag : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_getBoundingBox(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getBoundingBox : Invalid Native Object"); + if (argc == 0) { + cocos2d::Rect ret = cobj->getBoundingBox(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getBoundingBox : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_setEventDispatcher(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setEventDispatcher : Invalid Native Object"); + if (argc == 1) { + cocos2d::EventDispatcher* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::EventDispatcher*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setEventDispatcher : Error processing arguments"); + cobj->setEventDispatcher(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setEventDispatcher : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_getGlobalZOrder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getGlobalZOrder : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getGlobalZOrder(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getGlobalZOrder : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_draw(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Node* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_draw : Invalid Native Object"); + do { + if (argc == 0) { + cobj->draw(); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 3) { + cocos2d::Renderer* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Renderer*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Mat4 arg1; + ok &= jsval_to_matrix(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + unsigned int arg2; + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cobj->draw(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Node_draw : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Node_setUserObject(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setUserObject : Invalid Native Object"); + if (argc == 1) { + cocos2d::Ref* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setUserObject : Error processing arguments"); + cobj->setUserObject(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setUserObject : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_enumerateChildren(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_enumerateChildren : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + std::function arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + do { + if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + auto lambda = [=](cocos2d::Node* larg0) -> bool { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + JS::RootedValue rval(cx); + bool ok = func->invoke(1, &largv[0], &rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + bool ret; + ret = JS::ToBoolean(rval); + return ret; + }; + arg1 = lambda; + } + else + { + arg1 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_enumerateChildren : Error processing arguments"); + cobj->enumerateChildren(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_enumerateChildren : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_Node_getonExitTransitionDidStartCallback(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getonExitTransitionDidStartCallback : Invalid Native Object"); + if (argc == 0) { + const std::function& ret = cobj->getonExitTransitionDidStartCallback(); + jsval jsret = JSVAL_NULL; + #pragma warning NO CONVERSION FROM NATIVE FOR std::function; + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getonExitTransitionDidStartCallback : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_removeFromParentAndCleanup(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Node* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_removeFromParentAndCleanup : Invalid Native Object"); + do { + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + cobj->removeFromParentAndCleanup(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 0) { + cobj->removeFromParent(); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Node_removeFromParentAndCleanup : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Node_setPosition3D(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setPosition3D : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec3 arg0; + ok &= jsval_to_vector3(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setPosition3D : Error processing arguments"); + cobj->setPosition3D(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setPosition3D : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_update(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_update : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_update : Error processing arguments"); + cobj->update(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_update : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_sortAllChildren(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_sortAllChildren : Invalid Native Object"); + if (argc == 0) { + cobj->sortAllChildren(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_sortAllChildren : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getWorldToNodeAffineTransform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getWorldToNodeAffineTransform : Invalid Native Object"); + if (argc == 0) { + cocos2d::AffineTransform ret = cobj->getWorldToNodeAffineTransform(); + jsval jsret = JSVAL_NULL; + jsret = ccaffinetransform_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getWorldToNodeAffineTransform : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getScale : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getScale(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getScale : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getNormalizedPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getNormalizedPosition : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getNormalizedPosition(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getNormalizedPosition : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_getParentToNodeTransform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getParentToNodeTransform : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Mat4& ret = cobj->getParentToNodeTransform(); + jsval jsret = JSVAL_NULL; + jsret = matrix_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_getParentToNodeTransform : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_convertToNodeSpace(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_convertToNodeSpace : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_convertToNodeSpace : Error processing arguments"); + cocos2d::Vec2 ret = cobj->convertToNodeSpace(arg0); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_convertToNodeSpace : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_setTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setTag : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setTag : Error processing arguments"); + cobj->setTag(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setTag : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_isCascadeColorEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isCascadeColorEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isCascadeColorEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_isCascadeColorEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Node_setRotationQuat(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setRotationQuat : Invalid Native Object"); + if (argc == 1) { + cocos2d::Quaternion arg0; + ok &= jsval_to_quaternion(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setRotationQuat : Error processing arguments"); + cobj->setRotationQuat(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setRotationQuat : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_stopAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_stopAction : Invalid Native Object"); + if (argc == 1) { + cocos2d::Action* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Action*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_stopAction : Error processing arguments"); + cobj->stopAction(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_stopAction : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Node_getActionManager(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Node* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_getActionManager : Invalid Native Object"); + do { + if (argc == 0) { + const cocos2d::ActionManager* ret = cobj->getActionManager(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionManager*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + cocos2d::ActionManager* ret = cobj->getActionManager(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionManager*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Node_getActionManager : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Node_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Node* ret = cocos2d::Node::create(); + 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); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Node_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Node_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Node* cobj = new (std::nothrow) cocos2d::Node(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Node"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_Node_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Node)", obj); +} + +static bool js_cocos2d_Node_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Node *nobj = new (std::nothrow) cocos2d::Node(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Node"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_Node(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Node_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Node_class->name = "Node"; + jsb_cocos2d_Node_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Node_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Node_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Node_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Node_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Node_class->resolve = JS_ResolveStub; + jsb_cocos2d_Node_class->convert = JS_ConvertStub; + jsb_cocos2d_Node_class->finalize = js_cocos2d_Node_finalize; + jsb_cocos2d_Node_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("addChild", js_cocos2dx_Node_addChild, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeComponent", js_cocos2dx_Node_removeComponent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPhysicsBody", js_cocos2dx_Node_setPhysicsBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getShaderProgram", js_cocos2dx_Node_getGLProgram, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateTransformFromPhysics", js_cocos2dx_Node_updateTransformFromPhysics, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDescription", js_cocos2dx_Node_getDescription, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setOpacityModifyRGB", js_cocos2dx_Node_setOpacityModifyRGB, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + 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("isIgnoreAnchorPointForPosition", js_cocos2dx_Node_isIgnoreAnchorPointForPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getChildByName", js_cocos2dx_Node_getChildByName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateDisplayedOpacity", js_cocos2dx_Node_updateDisplayedOpacity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_Node_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCameraMask", js_cocos2dx_Node_getCameraMask, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRotation", js_cocos2dx_Node_setRotation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setScaleZ", js_cocos2dx_Node_setScaleZ, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setScaleY", js_cocos2dx_Node_setScaleY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setScaleX", js_cocos2dx_Node_setScaleX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getColor", js_cocos2dx_Node_getColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setonEnterTransitionDidFinishCallback", js_cocos2dx_Node_setonEnterTransitionDidFinishCallback, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeFromPhysicsWorld", js_cocos2dx_Node_removeFromPhysicsWorld, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllComponents", js_cocos2dx_Node_removeAllComponents, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOpacity", js_cocos2dx_Node_getOpacity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCameraMask", js_cocos2dx_Node_setCameraMask, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTag", js_cocos2dx_Node_getTag, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getonEnterTransitionDidFinishCallback", js_cocos2dx_Node_getonEnterTransitionDidFinishCallback, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isOpacityModifyRGB", js_cocos2dx_Node_isOpacityModifyRGB, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNodeToWorldTransform", js_cocos2dx_Node_getNodeToWorldAffineTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPosition3D", js_cocos2dx_Node_getPosition3D, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeChild", js_cocos2dx_Node_removeChild, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getScene", js_cocos2dx_Node_getScene, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEventDispatcher", js_cocos2dx_Node_getEventDispatcher, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSkewX", js_cocos2dx_Node_setSkewX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setGLProgramState", js_cocos2dx_Node_setGLProgramState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setOnEnterCallback", js_cocos2dx_Node_setOnEnterCallback, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setNormalizedPosition", js_cocos2dx_Node_setNormalizedPosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setonExitTransitionDidStartCallback", js_cocos2dx_Node_setonExitTransitionDidStartCallback, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("convertTouchToNodeSpace", js_cocos2dx_Node_convertTouchToNodeSpace, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllChildren", js_cocos2dx_Node_removeAllChildrenWithCleanup, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRotationX", js_cocos2dx_Node_getRotationSkewX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRotationY", js_cocos2dx_Node_getRotationSkewY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNodeToWorldTransform3D", js_cocos2dx_Node_getNodeToWorldTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + 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("getRotation3D", js_cocos2dx_Node_getRotation3D, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNodeToParentTransform", js_cocos2dx_Node_getNodeToParentAffineTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("convertTouchToNodeSpaceAR", js_cocos2dx_Node_convertTouchToNodeSpaceAR, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOnEnterCallback", js_cocos2dx_Node_getOnEnterCallback, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPhysicsBody", js_cocos2dx_Node_getPhysicsBody, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("stopActionByTag", js_cocos2dx_Node_stopActionByTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("reorderChild", js_cocos2dx_Node_reorderChild, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ignoreAnchorPointForPosition", js_cocos2dx_Node_ignoreAnchorPointForPosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSkewY", js_cocos2dx_Node_setSkewY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRotation3D", js_cocos2dx_Node_setRotation3D, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPositionX", js_cocos2dx_Node_setPositionX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setNodeToParentTransform", js_cocos2dx_Node_setNodeToParentTransform, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAnchorPoint", js_cocos2dx_Node_getAnchorPoint, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNumberOfRunningActions", js_cocos2dx_Node_getNumberOfRunningActions, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateTransform", js_cocos2dx_Node_updateTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isVisible", js_cocos2dx_Node_isVisible, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getChildrenCount", js_cocos2dx_Node_getChildrenCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNodeToParentTransform3D", js_cocos2dx_Node_getNodeToParentTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("convertToNodeSpaceAR", js_cocos2dx_Node_convertToNodeSpaceAR, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addComponent", js_cocos2dx_Node_addComponent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("runAction", js_cocos2dx_Node_runAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("visit", js_cocos2dx_Node_visit, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setShaderProgram", js_cocos2dx_Node_setGLProgram, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRotation", js_cocos2dx_Node_getRotation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAnchorPointInPoints", js_cocos2dx_Node_getAnchorPointInPoints, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRotationQuat", js_cocos2dx_Node_getRotationQuat, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeChildByName", js_cocos2dx_Node_removeChildByName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setVertexZ", js_cocos2dx_Node_setPositionZ, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getGLProgramState", js_cocos2dx_Node_getGLProgramState, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setScheduler", js_cocos2dx_Node_setScheduler, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("stopAllActions", js_cocos2dx_Node_stopAllActions, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSkewX", js_cocos2dx_Node_getSkewX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSkewY", js_cocos2dx_Node_getSkewY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isScheduled", js_cocos2dx_Node_isScheduled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDisplayedColor", js_cocos2dx_Node_getDisplayedColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getActionByTag", js_cocos2dx_Node_getActionByTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRotationX", js_cocos2dx_Node_setRotationSkewX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRotationY", js_cocos2dx_Node_setRotationSkewY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setName", js_cocos2dx_Node_setName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updatePhysicsBodyTransform", js_cocos2dx_Node_updatePhysicsBodyTransform, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDisplayedOpacity", js_cocos2dx_Node_getDisplayedOpacity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLocalZOrder", js_cocos2dx_Node_getLocalZOrder, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getScheduler", js_cocos2dx_Node_getScheduler, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOrderOfArrival", js_cocos2dx_Node_getOrderOfArrival, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setActionManager", js_cocos2dx_Node_setActionManager, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPosition", js_cocos2dx_Node_getPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isRunning", js_cocos2dx_Node_isRunning, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getParent", js_cocos2dx_Node_getParent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getWorldToNodeTransform3D", js_cocos2dx_Node_getWorldToNodeTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPositionY", js_cocos2dx_Node_getPositionY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPositionX", js_cocos2dx_Node_getPositionX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeChildByTag", js_cocos2dx_Node_removeChildByTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPositionY", js_cocos2dx_Node_setPositionY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateDisplayedColor", js_cocos2dx_Node_updateDisplayedColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setVisible", js_cocos2dx_Node_setVisible, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getParentToNodeTransform", js_cocos2dx_Node_getParentToNodeAffineTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVertexZ", js_cocos2dx_Node_getPositionZ, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setGlobalZOrder", js_cocos2dx_Node_setGlobalZOrder, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setScale", js_cocos2dx_Node_setScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOnExitCallback", js_cocos2dx_Node_getOnExitCallback, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getChildByTag", js_cocos2dx_Node_getChildByTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setOrderOfArrival", js_cocos2dx_Node_setOrderOfArrival, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getScaleZ", js_cocos2dx_Node_getScaleZ, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getScaleY", js_cocos2dx_Node_getScaleY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getScaleX", js_cocos2dx_Node_getScaleX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLocalZOrder", js_cocos2dx_Node_setLocalZOrder, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCascadeColorEnabled", js_cocos2dx_Node_setCascadeColorEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setOpacity", js_cocos2dx_Node_setOpacity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("cleanup", js_cocos2dx_Node_cleanup, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getComponent", js_cocos2dx_Node_getComponent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getContentSize", js_cocos2dx_Node_getContentSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("stopAllActionsByTag", js_cocos2dx_Node_stopAllActionsByTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBoundingBox", js_cocos2dx_Node_getBoundingBox, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEventDispatcher", js_cocos2dx_Node_setEventDispatcher, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getGlobalZOrder", js_cocos2dx_Node_getGlobalZOrder, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("draw", js_cocos2dx_Node_draw, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUserObject", js_cocos2dx_Node_setUserObject, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("enumerateChildren", js_cocos2dx_Node_enumerateChildren, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getonExitTransitionDidStartCallback", js_cocos2dx_Node_getonExitTransitionDidStartCallback, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeFromParent", js_cocos2dx_Node_removeFromParentAndCleanup, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPosition3D", js_cocos2dx_Node_setPosition3D, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("update", js_cocos2dx_Node_update, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("sortAllChildren", js_cocos2dx_Node_sortAllChildren, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getWorldToNodeTransform", js_cocos2dx_Node_getWorldToNodeAffineTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getScale", js_cocos2dx_Node_getScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNormalizedPosition", js_cocos2dx_Node_getNormalizedPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getParentToNodeTransform3D", js_cocos2dx_Node_getParentToNodeTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("convertToNodeSpace", js_cocos2dx_Node_convertToNodeSpace, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTag", js_cocos2dx_Node_setTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isCascadeColorEnabled", js_cocos2dx_Node_isCascadeColorEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRotationQuat", js_cocos2dx_Node_setRotationQuat, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("stopAction", js_cocos2dx_Node_stopAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getActionManager", js_cocos2dx_Node_getActionManager, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_Node_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Node_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Node_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_Node_class, + js_cocos2dx_Node_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, "Node", 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_Node_class; + p->proto = jsb_cocos2d_Node_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d___NodeRGBA_class; +JSObject *jsb_cocos2d___NodeRGBA_prototype; + +bool js_cocos2dx___NodeRGBA_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::__NodeRGBA* cobj = new (std::nothrow) cocos2d::__NodeRGBA(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::__NodeRGBA"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d___NodeRGBA_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (__NodeRGBA)", obj); +} + +static bool js_cocos2d___NodeRGBA_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::__NodeRGBA *nobj = new (std::nothrow) cocos2d::__NodeRGBA(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::__NodeRGBA"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx___NodeRGBA(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d___NodeRGBA_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d___NodeRGBA_class->name = "NodeRGBA"; + jsb_cocos2d___NodeRGBA_class->addProperty = JS_PropertyStub; + jsb_cocos2d___NodeRGBA_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d___NodeRGBA_class->getProperty = JS_PropertyStub; + jsb_cocos2d___NodeRGBA_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d___NodeRGBA_class->enumerate = JS_EnumerateStub; + jsb_cocos2d___NodeRGBA_class->resolve = JS_ResolveStub; + jsb_cocos2d___NodeRGBA_class->convert = JS_ConvertStub; + jsb_cocos2d___NodeRGBA_class->finalize = js_cocos2d___NodeRGBA_finalize; + jsb_cocos2d___NodeRGBA_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2d___NodeRGBA_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d___NodeRGBA_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d___NodeRGBA_class, + js_cocos2dx___NodeRGBA_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, "NodeRGBA", 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___NodeRGBA_class; + p->proto = jsb_cocos2d___NodeRGBA_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_SpriteFrame_class; +JSObject *jsb_cocos2d_SpriteFrame_prototype; + +bool js_cocos2dx_SpriteFrame_clone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_clone : Invalid Native Object"); + if (argc == 0) { + cocos2d::SpriteFrame* ret = cobj->clone(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SpriteFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_clone : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpriteFrame_setRotated(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_setRotated : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteFrame_setRotated : Error processing arguments"); + cobj->setRotated(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_setRotated : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteFrame_setTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_setTexture : Invalid Native Object"); + if (argc == 1) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteFrame_setTexture : Error processing arguments"); + cobj->setTexture(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_setTexture : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteFrame_getOffset(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_getOffset : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getOffset(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_getOffset : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpriteFrame_setRectInPixels(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_setRectInPixels : Invalid Native Object"); + if (argc == 1) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteFrame_setRectInPixels : Error processing arguments"); + cobj->setRectInPixels(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_setRectInPixels : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteFrame_getTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_getTexture : Invalid Native Object"); + if (argc == 0) { + cocos2d::Texture2D* ret = cobj->getTexture(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_getTexture : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpriteFrame_getRect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_getRect : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Rect& ret = cobj->getRect(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_getRect : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpriteFrame_setOffsetInPixels(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_setOffsetInPixels : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteFrame_setOffsetInPixels : Error processing arguments"); + cobj->setOffsetInPixels(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_setOffsetInPixels : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteFrame_getRectInPixels(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_getRectInPixels : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Rect& ret = cobj->getRectInPixels(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_getRectInPixels : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpriteFrame_setOriginalSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_setOriginalSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteFrame_setOriginalSize : Error processing arguments"); + cobj->setOriginalSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_setOriginalSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteFrame_getOriginalSizeInPixels(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_getOriginalSizeInPixels : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getOriginalSizeInPixels(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_getOriginalSizeInPixels : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpriteFrame_setOriginalSizeInPixels(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_setOriginalSizeInPixels : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteFrame_setOriginalSizeInPixels : Error processing arguments"); + cobj->setOriginalSizeInPixels(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_setOriginalSizeInPixels : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteFrame_setOffset(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_setOffset : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteFrame_setOffset : Error processing arguments"); + cobj->setOffset(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_setOffset : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteFrame_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::SpriteFrame* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_initWithTexture : Invalid Native Object"); + do { + if (argc == 5) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(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, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool arg2; + arg2 = JS::ToBoolean(args.get(2)); + cocos2d::Vec2 arg3; + ok &= jsval_to_vector2(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + cocos2d::Size arg4; + ok &= jsval_to_ccsize(cx, args.get(4), &arg4); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithTexture(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(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, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithTexture(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_initWithTexture : wrong number of arguments"); + return false; +} +bool js_cocos2dx_SpriteFrame_isRotated(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_isRotated : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isRotated(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_isRotated : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpriteFrame_initWithTextureFilename(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::SpriteFrame* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_initWithTextureFilename : Invalid Native Object"); + do { + if (argc == 5) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool arg2; + arg2 = JS::ToBoolean(args.get(2)); + cocos2d::Vec2 arg3; + ok &= jsval_to_vector2(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + cocos2d::Size arg4; + ok &= jsval_to_ccsize(cx, args.get(4), &arg4); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithTextureFilename(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithTextureFilename(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_initWithTextureFilename : wrong number of arguments"); + return false; +} +bool js_cocos2dx_SpriteFrame_setRect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_setRect : Invalid Native Object"); + if (argc == 1) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteFrame_setRect : Error processing arguments"); + cobj->setRect(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_setRect : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteFrame_getOffsetInPixels(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_getOffsetInPixels : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getOffsetInPixels(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_getOffsetInPixels : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpriteFrame_getOriginalSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrame* cobj = (cocos2d::SpriteFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrame_getOriginalSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getOriginalSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_getOriginalSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpriteFrame_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 5) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool arg2; + arg2 = JS::ToBoolean(args.get(2)); + if (!ok) { ok = true; break; } + cocos2d::Vec2 arg3; + ok &= jsval_to_vector2(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + cocos2d::Size arg4; + ok &= jsval_to_ccsize(cx, args.get(4), &arg4); + if (!ok) { ok = true; break; } + cocos2d::SpriteFrame* ret = cocos2d::SpriteFrame::create(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SpriteFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::SpriteFrame* ret = cocos2d::SpriteFrame::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SpriteFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_SpriteFrame_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 5) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(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, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool arg2; + arg2 = JS::ToBoolean(args.get(2)); + if (!ok) { ok = true; break; } + cocos2d::Vec2 arg3; + ok &= jsval_to_vector2(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + cocos2d::Size arg4; + ok &= jsval_to_ccsize(cx, args.get(4), &arg4); + if (!ok) { ok = true; break; } + cocos2d::SpriteFrame* ret = cocos2d::SpriteFrame::createWithTexture(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SpriteFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(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, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::SpriteFrame* ret = cocos2d::SpriteFrame::createWithTexture(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SpriteFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_SpriteFrame_createWithTexture : wrong number of arguments"); + return false; +} +bool js_cocos2dx_SpriteFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::SpriteFrame* cobj = new (std::nothrow) cocos2d::SpriteFrame(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::SpriteFrame"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_SpriteFrame_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (SpriteFrame)", obj); +} + +static bool js_cocos2d_SpriteFrame_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::SpriteFrame *nobj = new (std::nothrow) cocos2d::SpriteFrame(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::SpriteFrame"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_SpriteFrame(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_SpriteFrame_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_SpriteFrame_class->name = "SpriteFrame"; + jsb_cocos2d_SpriteFrame_class->addProperty = JS_PropertyStub; + jsb_cocos2d_SpriteFrame_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_SpriteFrame_class->getProperty = JS_PropertyStub; + jsb_cocos2d_SpriteFrame_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_SpriteFrame_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_SpriteFrame_class->resolve = JS_ResolveStub; + jsb_cocos2d_SpriteFrame_class->convert = JS_ConvertStub; + jsb_cocos2d_SpriteFrame_class->finalize = js_cocos2d_SpriteFrame_finalize; + jsb_cocos2d_SpriteFrame_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("clone", js_cocos2dx_SpriteFrame_clone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRotated", js_cocos2dx_SpriteFrame_setRotated, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTexture", js_cocos2dx_SpriteFrame_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOffset", js_cocos2dx_SpriteFrame_getOffset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRectInPixels", js_cocos2dx_SpriteFrame_setRectInPixels, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTexture", js_cocos2dx_SpriteFrame_getTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRect", js_cocos2dx_SpriteFrame_getRect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setOffsetInPixels", js_cocos2dx_SpriteFrame_setOffsetInPixels, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRectInPixels", js_cocos2dx_SpriteFrame_getRectInPixels, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setOriginalSize", js_cocos2dx_SpriteFrame_setOriginalSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOriginalSizeInPixels", js_cocos2dx_SpriteFrame_getOriginalSizeInPixels, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setOriginalSizeInPixels", js_cocos2dx_SpriteFrame_setOriginalSizeInPixels, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setOffset", js_cocos2dx_SpriteFrame_setOffset, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTexture", js_cocos2dx_SpriteFrame_initWithTexture, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isRotated", js_cocos2dx_SpriteFrame_isRotated, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTextureFilename", js_cocos2dx_SpriteFrame_initWithTextureFilename, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRect", js_cocos2dx_SpriteFrame_setRect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOffsetInPixels", js_cocos2dx_SpriteFrame_getOffsetInPixels, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOriginalSize", js_cocos2dx_SpriteFrame_getOriginalSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_SpriteFrame_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_SpriteFrame_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithTexture", js_cocos2dx_SpriteFrame_createWithTexture, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_SpriteFrame_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_SpriteFrame_class, + js_cocos2dx_SpriteFrame_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, "SpriteFrame", 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_SpriteFrame_class; + p->proto = jsb_cocos2d_SpriteFrame_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_AnimationFrame_class; +JSObject *jsb_cocos2d_AnimationFrame_prototype; + +bool js_cocos2dx_AnimationFrame_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AnimationFrame* cobj = (cocos2d::AnimationFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AnimationFrame_setSpriteFrame : Invalid Native Object"); + if (argc == 1) { + cocos2d::SpriteFrame* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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_AnimationFrame_setSpriteFrame : Error processing arguments"); + cobj->setSpriteFrame(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AnimationFrame_setSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_AnimationFrame_getUserInfo(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::AnimationFrame* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::AnimationFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AnimationFrame_getUserInfo : Invalid Native Object"); + do { + if (argc == 0) { + cocos2d::ValueMap& ret = cobj->getUserInfo(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluemap_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + const cocos2d::ValueMap& ret = cobj->getUserInfo(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluemap_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_AnimationFrame_getUserInfo : wrong number of arguments"); + return false; +} +bool js_cocos2dx_AnimationFrame_setDelayUnits(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AnimationFrame* cobj = (cocos2d::AnimationFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AnimationFrame_setDelayUnits : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AnimationFrame_setDelayUnits : Error processing arguments"); + cobj->setDelayUnits(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AnimationFrame_setDelayUnits : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_AnimationFrame_clone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AnimationFrame* cobj = (cocos2d::AnimationFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AnimationFrame_clone : Invalid Native Object"); + if (argc == 0) { + cocos2d::AnimationFrame* ret = cobj->clone(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::AnimationFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AnimationFrame_clone : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_AnimationFrame_getSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AnimationFrame* cobj = (cocos2d::AnimationFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AnimationFrame_getSpriteFrame : Invalid Native Object"); + if (argc == 0) { + cocos2d::SpriteFrame* ret = cobj->getSpriteFrame(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SpriteFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AnimationFrame_getSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_AnimationFrame_getDelayUnits(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AnimationFrame* cobj = (cocos2d::AnimationFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AnimationFrame_getDelayUnits : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getDelayUnits(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AnimationFrame_getDelayUnits : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_AnimationFrame_setUserInfo(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AnimationFrame* cobj = (cocos2d::AnimationFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AnimationFrame_setUserInfo : Invalid Native Object"); + if (argc == 1) { + cocos2d::ValueMap arg0; + ok &= jsval_to_ccvaluemap(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AnimationFrame_setUserInfo : Error processing arguments"); + cobj->setUserInfo(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AnimationFrame_setUserInfo : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_AnimationFrame_initWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AnimationFrame* cobj = (cocos2d::AnimationFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AnimationFrame_initWithSpriteFrame : Invalid Native Object"); + if (argc == 3) { + cocos2d::SpriteFrame* arg0; + double arg1; + cocos2d::ValueMap arg2; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= jsval_to_ccvaluemap(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AnimationFrame_initWithSpriteFrame : Error processing arguments"); + bool ret = cobj->initWithSpriteFrame(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AnimationFrame_initWithSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_AnimationFrame_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 3) { + cocos2d::SpriteFrame* arg0; + double arg1; + cocos2d::ValueMap arg2; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= jsval_to_ccvaluemap(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AnimationFrame_create : Error processing arguments"); + cocos2d::AnimationFrame* ret = cocos2d::AnimationFrame::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::AnimationFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_AnimationFrame_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_AnimationFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::AnimationFrame* cobj = new (std::nothrow) cocos2d::AnimationFrame(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::AnimationFrame"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_AnimationFrame_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (AnimationFrame)", obj); +} + +void js_register_cocos2dx_AnimationFrame(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_AnimationFrame_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_AnimationFrame_class->name = "AnimationFrame"; + jsb_cocos2d_AnimationFrame_class->addProperty = JS_PropertyStub; + jsb_cocos2d_AnimationFrame_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_AnimationFrame_class->getProperty = JS_PropertyStub; + jsb_cocos2d_AnimationFrame_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_AnimationFrame_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_AnimationFrame_class->resolve = JS_ResolveStub; + jsb_cocos2d_AnimationFrame_class->convert = JS_ConvertStub; + jsb_cocos2d_AnimationFrame_class->finalize = js_cocos2d_AnimationFrame_finalize; + jsb_cocos2d_AnimationFrame_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setSpriteFrame", js_cocos2dx_AnimationFrame_setSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getUserInfo", js_cocos2dx_AnimationFrame_getUserInfo, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDelayUnits", js_cocos2dx_AnimationFrame_setDelayUnits, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("clone", js_cocos2dx_AnimationFrame_clone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSpriteFrame", js_cocos2dx_AnimationFrame_getSpriteFrame, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDelayUnits", js_cocos2dx_AnimationFrame_getDelayUnits, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUserInfo", js_cocos2dx_AnimationFrame_setUserInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithSpriteFrame", js_cocos2dx_AnimationFrame_initWithSpriteFrame, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_AnimationFrame_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_AnimationFrame_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_AnimationFrame_class, + js_cocos2dx_AnimationFrame_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, "AnimationFrame", 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_AnimationFrame_class; + p->proto = jsb_cocos2d_AnimationFrame_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Animation_class; +JSObject *jsb_cocos2d_Animation_prototype; + +bool js_cocos2dx_Animation_getLoops(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animation_getLoops : Invalid Native Object"); + if (argc == 0) { + unsigned int ret = cobj->getLoops(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Animation_getLoops : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Animation_addSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animation_addSpriteFrame : Invalid Native Object"); + if (argc == 1) { + cocos2d::SpriteFrame* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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_Animation_addSpriteFrame : Error processing arguments"); + cobj->addSpriteFrame(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Animation_addSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Animation_setRestoreOriginalFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animation_setRestoreOriginalFrame : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Animation_setRestoreOriginalFrame : Error processing arguments"); + cobj->setRestoreOriginalFrame(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Animation_setRestoreOriginalFrame : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Animation_clone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animation_clone : Invalid Native Object"); + if (argc == 0) { + cocos2d::Animation* ret = cobj->clone(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Animation*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Animation_clone : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Animation_getDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animation_getDuration : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getDuration(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Animation_getDuration : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Animation_initWithAnimationFrames(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animation_initWithAnimationFrames : Invalid Native Object"); + if (argc == 3) { + cocos2d::Vector arg0; + double arg1; + unsigned int arg2; + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Animation_initWithAnimationFrames : Error processing arguments"); + bool ret = cobj->initWithAnimationFrames(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Animation_initWithAnimationFrames : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_Animation_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animation_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Animation_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Animation_setFrames(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animation_setFrames : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vector arg0; + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Animation_setFrames : Error processing arguments"); + cobj->setFrames(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Animation_setFrames : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Animation_getFrames(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animation_getFrames : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vector& ret = cobj->getFrames(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Animation_getFrames : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Animation_setLoops(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animation_setLoops : Invalid Native Object"); + if (argc == 1) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Animation_setLoops : Error processing arguments"); + cobj->setLoops(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Animation_setLoops : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Animation_setDelayPerUnit(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animation_setDelayPerUnit : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Animation_setDelayPerUnit : Error processing arguments"); + cobj->setDelayPerUnit(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Animation_setDelayPerUnit : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Animation_addSpriteFrameWithFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animation_addSpriteFrameWithFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Animation_addSpriteFrameWithFile : Error processing arguments"); + cobj->addSpriteFrameWithFile(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Animation_addSpriteFrameWithFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Animation_getTotalDelayUnits(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animation_getTotalDelayUnits : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getTotalDelayUnits(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Animation_getTotalDelayUnits : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Animation_getDelayPerUnit(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animation_getDelayPerUnit : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getDelayPerUnit(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Animation_getDelayPerUnit : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Animation_initWithSpriteFrames(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animation_initWithSpriteFrames : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vector arg0; + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Animation_initWithSpriteFrames : Error processing arguments"); + bool ret = cobj->initWithSpriteFrames(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + cocos2d::Vector arg0; + double arg1; + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Animation_initWithSpriteFrames : Error processing arguments"); + bool ret = cobj->initWithSpriteFrames(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 3) { + cocos2d::Vector arg0; + double arg1; + unsigned int arg2; + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Animation_initWithSpriteFrames : Error processing arguments"); + bool ret = cobj->initWithSpriteFrames(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Animation_initWithSpriteFrames : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Animation_getRestoreOriginalFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animation_getRestoreOriginalFrame : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->getRestoreOriginalFrame(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Animation_getRestoreOriginalFrame : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Animation_addSpriteFrameWithTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animation* cobj = (cocos2d::Animation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animation_addSpriteFrameWithTexture : Invalid Native Object"); + if (argc == 2) { + cocos2d::Texture2D* arg0; + cocos2d::Rect arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Animation_addSpriteFrameWithTexture : Error processing arguments"); + cobj->addSpriteFrameWithTexture(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Animation_addSpriteFrameWithTexture : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_Animation_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + cocos2d::Vector arg0; + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + cocos2d::Animation* ret = cocos2d::Animation::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Animation*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 3) { + cocos2d::Vector arg0; + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + unsigned int arg2; + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cocos2d::Animation* ret = cocos2d::Animation::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Animation*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::Animation* ret = cocos2d::Animation::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Animation*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_Animation_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Animation_createWithSpriteFrames(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Vector arg0; + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Animation_createWithSpriteFrames : Error processing arguments"); + cocos2d::Animation* ret = cocos2d::Animation::createWithSpriteFrames(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Animation*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + cocos2d::Vector arg0; + double arg1; + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Animation_createWithSpriteFrames : Error processing arguments"); + cocos2d::Animation* ret = cocos2d::Animation::createWithSpriteFrames(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Animation*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 3) { + cocos2d::Vector arg0; + double arg1; + unsigned int arg2; + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Animation_createWithSpriteFrames : Error processing arguments"); + cocos2d::Animation* ret = cocos2d::Animation::createWithSpriteFrames(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Animation*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Animation_createWithSpriteFrames : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Animation_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Animation* cobj = new (std::nothrow) cocos2d::Animation(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Animation"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_Animation_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Animation)", obj); +} + +void js_register_cocos2dx_Animation(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Animation_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Animation_class->name = "Animation"; + jsb_cocos2d_Animation_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Animation_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Animation_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Animation_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Animation_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Animation_class->resolve = JS_ResolveStub; + jsb_cocos2d_Animation_class->convert = JS_ConvertStub; + jsb_cocos2d_Animation_class->finalize = js_cocos2d_Animation_finalize; + jsb_cocos2d_Animation_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getLoops", js_cocos2dx_Animation_getLoops, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addSpriteFrame", js_cocos2dx_Animation_addSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRestoreOriginalFrame", js_cocos2dx_Animation_setRestoreOriginalFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("clone", js_cocos2dx_Animation_clone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDuration", js_cocos2dx_Animation_getDuration, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithAnimationFrames", js_cocos2dx_Animation_initWithAnimationFrames, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_Animation_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFrames", js_cocos2dx_Animation_setFrames, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFrames", js_cocos2dx_Animation_getFrames, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLoops", js_cocos2dx_Animation_setLoops, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDelayPerUnit", js_cocos2dx_Animation_setDelayPerUnit, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addSpriteFrameWithFile", js_cocos2dx_Animation_addSpriteFrameWithFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTotalDelayUnits", js_cocos2dx_Animation_getTotalDelayUnits, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDelayPerUnit", js_cocos2dx_Animation_getDelayPerUnit, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithSpriteFrames", js_cocos2dx_Animation_initWithSpriteFrames, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRestoreOriginalFrame", js_cocos2dx_Animation_getRestoreOriginalFrame, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addSpriteFrameWithTexture", js_cocos2dx_Animation_addSpriteFrameWithTexture, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("createWithAnimationFrames", js_cocos2dx_Animation_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithSpriteFrames", js_cocos2dx_Animation_createWithSpriteFrames, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Animation_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_Animation_class, + js_cocos2dx_Animation_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, "Animation", 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_Animation_class; + p->proto = jsb_cocos2d_Animation_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ActionInterval_class; +JSObject *jsb_cocos2d_ActionInterval_prototype; + +bool js_cocos2dx_ActionInterval_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionInterval* cobj = (cocos2d::ActionInterval *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionInterval_getAmplitudeRate : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAmplitudeRate(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionInterval_getAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ActionInterval_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionInterval* cobj = (cocos2d::ActionInterval *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionInterval_initWithDuration : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ActionInterval_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionInterval_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ActionInterval_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionInterval* cobj = (cocos2d::ActionInterval *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionInterval_setAmplitudeRate : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ActionInterval_setAmplitudeRate : Error processing arguments"); + cobj->setAmplitudeRate(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionInterval_setAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ActionInterval_getElapsed(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionInterval* cobj = (cocos2d::ActionInterval *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionInterval_getElapsed : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getElapsed(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionInterval_getElapsed : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +extern JSObject *jsb_cocos2d_FiniteTimeAction_prototype; + +void js_cocos2d_ActionInterval_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ActionInterval)", obj); +} + +void js_register_cocos2dx_ActionInterval(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ActionInterval_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ActionInterval_class->name = "ActionInterval"; + jsb_cocos2d_ActionInterval_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ActionInterval_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ActionInterval_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ActionInterval_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ActionInterval_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ActionInterval_class->resolve = JS_ResolveStub; + jsb_cocos2d_ActionInterval_class->convert = JS_ConvertStub; + jsb_cocos2d_ActionInterval_class->finalize = js_cocos2d_ActionInterval_finalize; + jsb_cocos2d_ActionInterval_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getAmplitudeRate", js_cocos2dx_ActionInterval_getAmplitudeRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithDuration", js_cocos2dx_ActionInterval_initWithDuration, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAmplitudeRate", js_cocos2dx_ActionInterval_setAmplitudeRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getElapsed", js_cocos2dx_ActionInterval_getElapsed, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_ActionInterval_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_FiniteTimeAction_prototype), + jsb_cocos2d_ActionInterval_class, + empty_constructor, 0, + 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, "ActionInterval", 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_ActionInterval_class; + p->proto = jsb_cocos2d_ActionInterval_prototype; + p->parentProto = jsb_cocos2d_FiniteTimeAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Sequence_class; +JSObject *jsb_cocos2d_Sequence_prototype; + +bool js_cocos2dx_Sequence_initWithTwoActions(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sequence* cobj = (cocos2d::Sequence *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sequence_initWithTwoActions : Invalid Native Object"); + if (argc == 2) { + cocos2d::FiniteTimeAction* arg0; + cocos2d::FiniteTimeAction* arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sequence_initWithTwoActions : Error processing arguments"); + bool ret = cobj->initWithTwoActions(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sequence_initWithTwoActions : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_Sequence_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Sequence* cobj = new (std::nothrow) cocos2d::Sequence(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Sequence"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_Sequence_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Sequence)", obj); +} + +void js_register_cocos2dx_Sequence(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Sequence_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Sequence_class->name = "Sequence"; + jsb_cocos2d_Sequence_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Sequence_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Sequence_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Sequence_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Sequence_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Sequence_class->resolve = JS_ResolveStub; + jsb_cocos2d_Sequence_class->convert = JS_ConvertStub; + jsb_cocos2d_Sequence_class->finalize = js_cocos2d_Sequence_finalize; + jsb_cocos2d_Sequence_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithTwoActions", js_cocos2dx_Sequence_initWithTwoActions, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_Sequence_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_Sequence_class, + js_cocos2dx_Sequence_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, "Sequence", 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_Sequence_class; + p->proto = jsb_cocos2d_Sequence_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Repeat_class; +JSObject *jsb_cocos2d_Repeat_prototype; + +bool js_cocos2dx_Repeat_setInnerAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Repeat* cobj = (cocos2d::Repeat *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Repeat_setInnerAction : Invalid Native Object"); + if (argc == 1) { + cocos2d::FiniteTimeAction* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Repeat_setInnerAction : Error processing arguments"); + cobj->setInnerAction(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Repeat_setInnerAction : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Repeat_initWithAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Repeat* cobj = (cocos2d::Repeat *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Repeat_initWithAction : Invalid Native Object"); + if (argc == 2) { + cocos2d::FiniteTimeAction* arg0; + unsigned int arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Repeat_initWithAction : Error processing arguments"); + bool ret = cobj->initWithAction(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Repeat_initWithAction : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_Repeat_getInnerAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Repeat* cobj = (cocos2d::Repeat *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Repeat_getInnerAction : Invalid Native Object"); + if (argc == 0) { + cocos2d::FiniteTimeAction* ret = cobj->getInnerAction(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::FiniteTimeAction*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Repeat_getInnerAction : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Repeat_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::FiniteTimeAction* arg0; + unsigned int arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Repeat_create : Error processing arguments"); + cocos2d::Repeat* ret = cocos2d::Repeat::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Repeat*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Repeat_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Repeat_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Repeat* cobj = new (std::nothrow) cocos2d::Repeat(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Repeat"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_Repeat_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Repeat)", obj); +} + +void js_register_cocos2dx_Repeat(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Repeat_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Repeat_class->name = "Repeat"; + jsb_cocos2d_Repeat_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Repeat_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Repeat_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Repeat_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Repeat_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Repeat_class->resolve = JS_ResolveStub; + jsb_cocos2d_Repeat_class->convert = JS_ConvertStub; + jsb_cocos2d_Repeat_class->finalize = js_cocos2d_Repeat_finalize; + jsb_cocos2d_Repeat_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setInnerAction", js_cocos2dx_Repeat_setInnerAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithAction", js_cocos2dx_Repeat_initWithAction, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInnerAction", js_cocos2dx_Repeat_getInnerAction, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Repeat_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Repeat_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_Repeat_class, + js_cocos2dx_Repeat_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, "Repeat", 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_Repeat_class; + p->proto = jsb_cocos2d_Repeat_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_RepeatForever_class; +JSObject *jsb_cocos2d_RepeatForever_prototype; + +bool js_cocos2dx_RepeatForever_setInnerAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RepeatForever* cobj = (cocos2d::RepeatForever *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RepeatForever_setInnerAction : Invalid Native Object"); + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_RepeatForever_setInnerAction : Error processing arguments"); + cobj->setInnerAction(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RepeatForever_setInnerAction : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_RepeatForever_initWithAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RepeatForever* cobj = (cocos2d::RepeatForever *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RepeatForever_initWithAction : Invalid Native Object"); + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_RepeatForever_initWithAction : Error processing arguments"); + bool ret = cobj->initWithAction(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RepeatForever_initWithAction : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_RepeatForever_getInnerAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RepeatForever* cobj = (cocos2d::RepeatForever *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RepeatForever_getInnerAction : Invalid Native Object"); + if (argc == 0) { + cocos2d::ActionInterval* ret = cobj->getInnerAction(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RepeatForever_getInnerAction : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_RepeatForever_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_RepeatForever_create : Error processing arguments"); + cocos2d::RepeatForever* ret = cocos2d::RepeatForever::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::RepeatForever*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_RepeatForever_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_RepeatForever_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::RepeatForever* cobj = new (std::nothrow) cocos2d::RepeatForever(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::RepeatForever"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_RepeatForever_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (RepeatForever)", obj); +} + +void js_register_cocos2dx_RepeatForever(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_RepeatForever_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_RepeatForever_class->name = "RepeatForever"; + jsb_cocos2d_RepeatForever_class->addProperty = JS_PropertyStub; + jsb_cocos2d_RepeatForever_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_RepeatForever_class->getProperty = JS_PropertyStub; + jsb_cocos2d_RepeatForever_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_RepeatForever_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_RepeatForever_class->resolve = JS_ResolveStub; + jsb_cocos2d_RepeatForever_class->convert = JS_ConvertStub; + jsb_cocos2d_RepeatForever_class->finalize = js_cocos2d_RepeatForever_finalize; + jsb_cocos2d_RepeatForever_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setInnerAction", js_cocos2dx_RepeatForever_setInnerAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithAction", js_cocos2dx_RepeatForever_initWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInnerAction", js_cocos2dx_RepeatForever_getInnerAction, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_RepeatForever_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_RepeatForever_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_RepeatForever_class, + js_cocos2dx_RepeatForever_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, "RepeatForever", 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_RepeatForever_class; + p->proto = jsb_cocos2d_RepeatForever_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Spawn_class; +JSObject *jsb_cocos2d_Spawn_prototype; + +bool js_cocos2dx_Spawn_initWithTwoActions(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Spawn* cobj = (cocos2d::Spawn *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Spawn_initWithTwoActions : Invalid Native Object"); + if (argc == 2) { + cocos2d::FiniteTimeAction* arg0; + cocos2d::FiniteTimeAction* arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Spawn_initWithTwoActions : Error processing arguments"); + bool ret = cobj->initWithTwoActions(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Spawn_initWithTwoActions : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_Spawn_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Spawn* cobj = new (std::nothrow) cocos2d::Spawn(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Spawn"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_Spawn_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Spawn)", obj); +} + +void js_register_cocos2dx_Spawn(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Spawn_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Spawn_class->name = "Spawn"; + jsb_cocos2d_Spawn_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Spawn_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Spawn_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Spawn_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Spawn_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Spawn_class->resolve = JS_ResolveStub; + jsb_cocos2d_Spawn_class->convert = JS_ConvertStub; + jsb_cocos2d_Spawn_class->finalize = js_cocos2d_Spawn_finalize; + jsb_cocos2d_Spawn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithTwoActions", js_cocos2dx_Spawn_initWithTwoActions, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_Spawn_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_Spawn_class, + js_cocos2dx_Spawn_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, "Spawn", 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_Spawn_class; + p->proto = jsb_cocos2d_Spawn_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_RotateTo_class; +JSObject *jsb_cocos2d_RotateTo_prototype; + +bool js_cocos2dx_RotateTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::RotateTo* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::RotateTo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RotateTo_initWithDuration : Invalid Native Object"); + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec3 arg1; + ok &= jsval_to_vector3(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithDuration(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 3) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithDuration(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_RotateTo_initWithDuration : wrong number of arguments"); + return false; +} +bool js_cocos2dx_RotateTo_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + cocos2d::RotateTo* ret = cocos2d::RotateTo::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::RotateTo*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 3) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::RotateTo* ret = cocos2d::RotateTo::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::RotateTo*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec3 arg1; + ok &= jsval_to_vector3(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::RotateTo* ret = cocos2d::RotateTo::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::RotateTo*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_RotateTo_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_RotateTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::RotateTo* cobj = new (std::nothrow) cocos2d::RotateTo(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::RotateTo"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_RotateTo_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (RotateTo)", obj); +} + +void js_register_cocos2dx_RotateTo(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_RotateTo_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_RotateTo_class->name = "RotateTo"; + jsb_cocos2d_RotateTo_class->addProperty = JS_PropertyStub; + jsb_cocos2d_RotateTo_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_RotateTo_class->getProperty = JS_PropertyStub; + jsb_cocos2d_RotateTo_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_RotateTo_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_RotateTo_class->resolve = JS_ResolveStub; + jsb_cocos2d_RotateTo_class->convert = JS_ConvertStub; + jsb_cocos2d_RotateTo_class->finalize = js_cocos2d_RotateTo_finalize; + jsb_cocos2d_RotateTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_RotateTo_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_RotateTo_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_RotateTo_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_RotateTo_class, + js_cocos2dx_RotateTo_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, "RotateTo", 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_RotateTo_class; + p->proto = jsb_cocos2d_RotateTo_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_RotateBy_class; +JSObject *jsb_cocos2d_RotateBy_prototype; + +bool js_cocos2dx_RotateBy_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::RotateBy* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::RotateBy *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RotateBy_initWithDuration : Invalid Native Object"); + do { + if (argc == 3) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithDuration(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithDuration(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec3 arg1; + ok &= jsval_to_vector3(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithDuration(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_RotateBy_initWithDuration : wrong number of arguments"); + return false; +} +bool js_cocos2dx_RotateBy_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 3) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::RotateBy* ret = cocos2d::RotateBy::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::RotateBy*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + cocos2d::RotateBy* ret = cocos2d::RotateBy::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::RotateBy*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec3 arg1; + ok &= jsval_to_vector3(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::RotateBy* ret = cocos2d::RotateBy::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::RotateBy*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_RotateBy_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_RotateBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::RotateBy* cobj = new (std::nothrow) cocos2d::RotateBy(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::RotateBy"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_RotateBy_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (RotateBy)", obj); +} + +void js_register_cocos2dx_RotateBy(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_RotateBy_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_RotateBy_class->name = "RotateBy"; + jsb_cocos2d_RotateBy_class->addProperty = JS_PropertyStub; + jsb_cocos2d_RotateBy_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_RotateBy_class->getProperty = JS_PropertyStub; + jsb_cocos2d_RotateBy_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_RotateBy_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_RotateBy_class->resolve = JS_ResolveStub; + jsb_cocos2d_RotateBy_class->convert = JS_ConvertStub; + jsb_cocos2d_RotateBy_class->finalize = js_cocos2d_RotateBy_finalize; + jsb_cocos2d_RotateBy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_RotateBy_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_RotateBy_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_RotateBy_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_RotateBy_class, + js_cocos2dx_RotateBy_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, "RotateBy", 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_RotateBy_class; + p->proto = jsb_cocos2d_RotateBy_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_MoveBy_class; +JSObject *jsb_cocos2d_MoveBy_prototype; + +bool js_cocos2dx_MoveBy_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::MoveBy* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::MoveBy *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MoveBy_initWithDuration : Invalid Native Object"); + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec3 arg1; + ok &= jsval_to_vector3(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithDuration(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec2 arg1; + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithDuration(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_MoveBy_initWithDuration : wrong number of arguments"); + return false; +} +bool js_cocos2dx_MoveBy_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec3 arg1; + ok &= jsval_to_vector3(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::MoveBy* ret = cocos2d::MoveBy::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::MoveBy*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec2 arg1; + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::MoveBy* ret = cocos2d::MoveBy::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::MoveBy*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_MoveBy_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_MoveBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::MoveBy* cobj = new (std::nothrow) cocos2d::MoveBy(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MoveBy"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_MoveBy_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (MoveBy)", obj); +} + +void js_register_cocos2dx_MoveBy(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_MoveBy_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_MoveBy_class->name = "MoveBy"; + jsb_cocos2d_MoveBy_class->addProperty = JS_PropertyStub; + jsb_cocos2d_MoveBy_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_MoveBy_class->getProperty = JS_PropertyStub; + jsb_cocos2d_MoveBy_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_MoveBy_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_MoveBy_class->resolve = JS_ResolveStub; + jsb_cocos2d_MoveBy_class->convert = JS_ConvertStub; + jsb_cocos2d_MoveBy_class->finalize = js_cocos2d_MoveBy_finalize; + jsb_cocos2d_MoveBy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_MoveBy_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_MoveBy_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_MoveBy_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_MoveBy_class, + js_cocos2dx_MoveBy_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, "MoveBy", 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_MoveBy_class; + p->proto = jsb_cocos2d_MoveBy_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_MoveTo_class; +JSObject *jsb_cocos2d_MoveTo_prototype; + +bool js_cocos2dx_MoveTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::MoveTo* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::MoveTo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MoveTo_initWithDuration : Invalid Native Object"); + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec3 arg1; + ok &= jsval_to_vector3(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithDuration(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec2 arg1; + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithDuration(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_MoveTo_initWithDuration : wrong number of arguments"); + return false; +} +bool js_cocos2dx_MoveTo_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec3 arg1; + ok &= jsval_to_vector3(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::MoveTo* ret = cocos2d::MoveTo::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::MoveTo*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec2 arg1; + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::MoveTo* ret = cocos2d::MoveTo::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::MoveTo*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_MoveTo_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_MoveTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::MoveTo* cobj = new (std::nothrow) cocos2d::MoveTo(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MoveTo"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_MoveBy_prototype; + +void js_cocos2d_MoveTo_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (MoveTo)", obj); +} + +void js_register_cocos2dx_MoveTo(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_MoveTo_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_MoveTo_class->name = "MoveTo"; + jsb_cocos2d_MoveTo_class->addProperty = JS_PropertyStub; + jsb_cocos2d_MoveTo_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_MoveTo_class->getProperty = JS_PropertyStub; + jsb_cocos2d_MoveTo_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_MoveTo_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_MoveTo_class->resolve = JS_ResolveStub; + jsb_cocos2d_MoveTo_class->convert = JS_ConvertStub; + jsb_cocos2d_MoveTo_class->finalize = js_cocos2d_MoveTo_finalize; + jsb_cocos2d_MoveTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_MoveTo_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_MoveTo_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_MoveTo_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_MoveBy_prototype), + jsb_cocos2d_MoveTo_class, + js_cocos2dx_MoveTo_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, "MoveTo", 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_MoveTo_class; + p->proto = jsb_cocos2d_MoveTo_prototype; + p->parentProto = jsb_cocos2d_MoveBy_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_SkewTo_class; +JSObject *jsb_cocos2d_SkewTo_prototype; + +bool js_cocos2dx_SkewTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SkewTo* cobj = (cocos2d::SkewTo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SkewTo_initWithDuration : Invalid Native Object"); + if (argc == 3) { + double arg0; + double arg1; + double arg2; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SkewTo_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SkewTo_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_SkewTo_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 3) { + double arg0; + double arg1; + double arg2; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SkewTo_create : Error processing arguments"); + cocos2d::SkewTo* ret = cocos2d::SkewTo::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SkewTo*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_SkewTo_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_SkewTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::SkewTo* cobj = new (std::nothrow) cocos2d::SkewTo(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::SkewTo"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_SkewTo_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (SkewTo)", obj); +} + +void js_register_cocos2dx_SkewTo(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_SkewTo_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_SkewTo_class->name = "SkewTo"; + jsb_cocos2d_SkewTo_class->addProperty = JS_PropertyStub; + jsb_cocos2d_SkewTo_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_SkewTo_class->getProperty = JS_PropertyStub; + jsb_cocos2d_SkewTo_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_SkewTo_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_SkewTo_class->resolve = JS_ResolveStub; + jsb_cocos2d_SkewTo_class->convert = JS_ConvertStub; + jsb_cocos2d_SkewTo_class->finalize = js_cocos2d_SkewTo_finalize; + jsb_cocos2d_SkewTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_SkewTo_initWithDuration, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_SkewTo_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_SkewTo_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_SkewTo_class, + js_cocos2dx_SkewTo_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, "SkewTo", 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_SkewTo_class; + p->proto = jsb_cocos2d_SkewTo_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_SkewBy_class; +JSObject *jsb_cocos2d_SkewBy_prototype; + +bool js_cocos2dx_SkewBy_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SkewBy* cobj = (cocos2d::SkewBy *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SkewBy_initWithDuration : Invalid Native Object"); + if (argc == 3) { + double arg0; + double arg1; + double arg2; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SkewBy_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SkewBy_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_SkewBy_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 3) { + double arg0; + double arg1; + double arg2; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SkewBy_create : Error processing arguments"); + cocos2d::SkewBy* ret = cocos2d::SkewBy::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SkewBy*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_SkewBy_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_SkewBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::SkewBy* cobj = new (std::nothrow) cocos2d::SkewBy(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::SkewBy"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_SkewTo_prototype; + +void js_cocos2d_SkewBy_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (SkewBy)", obj); +} + +void js_register_cocos2dx_SkewBy(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_SkewBy_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_SkewBy_class->name = "SkewBy"; + jsb_cocos2d_SkewBy_class->addProperty = JS_PropertyStub; + jsb_cocos2d_SkewBy_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_SkewBy_class->getProperty = JS_PropertyStub; + jsb_cocos2d_SkewBy_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_SkewBy_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_SkewBy_class->resolve = JS_ResolveStub; + jsb_cocos2d_SkewBy_class->convert = JS_ConvertStub; + jsb_cocos2d_SkewBy_class->finalize = js_cocos2d_SkewBy_finalize; + jsb_cocos2d_SkewBy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_SkewBy_initWithDuration, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_SkewBy_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_SkewBy_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_SkewTo_prototype), + jsb_cocos2d_SkewBy_class, + js_cocos2dx_SkewBy_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, "SkewBy", 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_SkewBy_class; + p->proto = jsb_cocos2d_SkewBy_prototype; + p->parentProto = jsb_cocos2d_SkewTo_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_JumpBy_class; +JSObject *jsb_cocos2d_JumpBy_prototype; + +bool js_cocos2dx_JumpBy_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::JumpBy* cobj = (cocos2d::JumpBy *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_JumpBy_initWithDuration : Invalid Native Object"); + if (argc == 4) { + double arg0; + cocos2d::Vec2 arg1; + double arg2; + int arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_JumpBy_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_JumpBy_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_JumpBy_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 4) { + double arg0; + cocos2d::Vec2 arg1; + double arg2; + int arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_JumpBy_create : Error processing arguments"); + cocos2d::JumpBy* ret = cocos2d::JumpBy::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::JumpBy*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_JumpBy_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_JumpBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::JumpBy* cobj = new (std::nothrow) cocos2d::JumpBy(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::JumpBy"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_JumpBy_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (JumpBy)", obj); +} + +void js_register_cocos2dx_JumpBy(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_JumpBy_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_JumpBy_class->name = "JumpBy"; + jsb_cocos2d_JumpBy_class->addProperty = JS_PropertyStub; + jsb_cocos2d_JumpBy_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_JumpBy_class->getProperty = JS_PropertyStub; + jsb_cocos2d_JumpBy_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_JumpBy_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_JumpBy_class->resolve = JS_ResolveStub; + jsb_cocos2d_JumpBy_class->convert = JS_ConvertStub; + jsb_cocos2d_JumpBy_class->finalize = js_cocos2d_JumpBy_finalize; + jsb_cocos2d_JumpBy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_JumpBy_initWithDuration, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_JumpBy_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_JumpBy_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_JumpBy_class, + js_cocos2dx_JumpBy_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, "JumpBy", 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_JumpBy_class; + p->proto = jsb_cocos2d_JumpBy_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_JumpTo_class; +JSObject *jsb_cocos2d_JumpTo_prototype; + +bool js_cocos2dx_JumpTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::JumpTo* cobj = (cocos2d::JumpTo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_JumpTo_initWithDuration : Invalid Native Object"); + if (argc == 4) { + double arg0; + cocos2d::Vec2 arg1; + double arg2; + int arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_JumpTo_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_JumpTo_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_JumpTo_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 4) { + double arg0; + cocos2d::Vec2 arg1; + double arg2; + int arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_JumpTo_create : Error processing arguments"); + cocos2d::JumpTo* ret = cocos2d::JumpTo::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::JumpTo*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_JumpTo_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_JumpTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::JumpTo* cobj = new (std::nothrow) cocos2d::JumpTo(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::JumpTo"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_JumpBy_prototype; + +void js_cocos2d_JumpTo_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (JumpTo)", obj); +} + +void js_register_cocos2dx_JumpTo(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_JumpTo_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_JumpTo_class->name = "JumpTo"; + jsb_cocos2d_JumpTo_class->addProperty = JS_PropertyStub; + jsb_cocos2d_JumpTo_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_JumpTo_class->getProperty = JS_PropertyStub; + jsb_cocos2d_JumpTo_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_JumpTo_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_JumpTo_class->resolve = JS_ResolveStub; + jsb_cocos2d_JumpTo_class->convert = JS_ConvertStub; + jsb_cocos2d_JumpTo_class->finalize = js_cocos2d_JumpTo_finalize; + jsb_cocos2d_JumpTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_JumpTo_initWithDuration, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_JumpTo_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_JumpTo_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_JumpBy_prototype), + jsb_cocos2d_JumpTo_class, + js_cocos2dx_JumpTo_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, "JumpTo", 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_JumpTo_class; + p->proto = jsb_cocos2d_JumpTo_prototype; + p->parentProto = jsb_cocos2d_JumpBy_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_BezierBy_class; +JSObject *jsb_cocos2d_BezierBy_prototype; + +bool js_cocos2dx_BezierBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::BezierBy* cobj = new (std::nothrow) cocos2d::BezierBy(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::BezierBy"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_BezierBy_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (BezierBy)", obj); +} + +void js_register_cocos2dx_BezierBy(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_BezierBy_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_BezierBy_class->name = "BezierBy"; + jsb_cocos2d_BezierBy_class->addProperty = JS_PropertyStub; + jsb_cocos2d_BezierBy_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_BezierBy_class->getProperty = JS_PropertyStub; + jsb_cocos2d_BezierBy_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_BezierBy_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_BezierBy_class->resolve = JS_ResolveStub; + jsb_cocos2d_BezierBy_class->convert = JS_ConvertStub; + jsb_cocos2d_BezierBy_class->finalize = js_cocos2d_BezierBy_finalize; + jsb_cocos2d_BezierBy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_BezierBy_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_BezierBy_class, + js_cocos2dx_BezierBy_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, "BezierBy", 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_BezierBy_class; + p->proto = jsb_cocos2d_BezierBy_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_BezierTo_class; +JSObject *jsb_cocos2d_BezierTo_prototype; + +bool js_cocos2dx_BezierTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::BezierTo* cobj = new (std::nothrow) cocos2d::BezierTo(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::BezierTo"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_BezierBy_prototype; + +void js_cocos2d_BezierTo_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (BezierTo)", obj); +} + +void js_register_cocos2dx_BezierTo(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_BezierTo_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_BezierTo_class->name = "BezierTo"; + jsb_cocos2d_BezierTo_class->addProperty = JS_PropertyStub; + jsb_cocos2d_BezierTo_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_BezierTo_class->getProperty = JS_PropertyStub; + jsb_cocos2d_BezierTo_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_BezierTo_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_BezierTo_class->resolve = JS_ResolveStub; + jsb_cocos2d_BezierTo_class->convert = JS_ConvertStub; + jsb_cocos2d_BezierTo_class->finalize = js_cocos2d_BezierTo_finalize; + jsb_cocos2d_BezierTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_BezierTo_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_BezierBy_prototype), + jsb_cocos2d_BezierTo_class, + js_cocos2dx_BezierTo_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, "BezierTo", 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_BezierTo_class; + p->proto = jsb_cocos2d_BezierTo_prototype; + p->parentProto = jsb_cocos2d_BezierBy_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ScaleTo_class; +JSObject *jsb_cocos2d_ScaleTo_prototype; + +bool js_cocos2dx_ScaleTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ScaleTo* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ScaleTo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ScaleTo_initWithDuration : Invalid Native Object"); + do { + if (argc == 3) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithDuration(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithDuration(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 4) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + double arg3; + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ScaleTo_initWithDuration : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ScaleTo_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 3) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::ScaleTo* ret = cocos2d::ScaleTo::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ScaleTo*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + cocos2d::ScaleTo* ret = cocos2d::ScaleTo::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ScaleTo*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 4) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + double arg3; + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + if (!ok) { ok = true; break; } + cocos2d::ScaleTo* ret = cocos2d::ScaleTo::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ScaleTo*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ScaleTo_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ScaleTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ScaleTo* cobj = new (std::nothrow) cocos2d::ScaleTo(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ScaleTo"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_ScaleTo_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ScaleTo)", obj); +} + +void js_register_cocos2dx_ScaleTo(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ScaleTo_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ScaleTo_class->name = "ScaleTo"; + jsb_cocos2d_ScaleTo_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ScaleTo_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ScaleTo_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ScaleTo_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ScaleTo_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ScaleTo_class->resolve = JS_ResolveStub; + jsb_cocos2d_ScaleTo_class->convert = JS_ConvertStub; + jsb_cocos2d_ScaleTo_class->finalize = js_cocos2d_ScaleTo_finalize; + jsb_cocos2d_ScaleTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_ScaleTo_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ScaleTo_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ScaleTo_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_ScaleTo_class, + js_cocos2dx_ScaleTo_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, "ScaleTo", 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_ScaleTo_class; + p->proto = jsb_cocos2d_ScaleTo_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ScaleBy_class; +JSObject *jsb_cocos2d_ScaleBy_prototype; + +bool js_cocos2dx_ScaleBy_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 3) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::ScaleBy* ret = cocos2d::ScaleBy::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ScaleBy*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + cocos2d::ScaleBy* ret = cocos2d::ScaleBy::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ScaleBy*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 4) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + double arg3; + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + if (!ok) { ok = true; break; } + cocos2d::ScaleBy* ret = cocos2d::ScaleBy::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ScaleBy*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ScaleBy_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ScaleBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ScaleBy* cobj = new (std::nothrow) cocos2d::ScaleBy(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ScaleBy"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ScaleTo_prototype; + +void js_cocos2d_ScaleBy_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ScaleBy)", obj); +} + +void js_register_cocos2dx_ScaleBy(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ScaleBy_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ScaleBy_class->name = "ScaleBy"; + jsb_cocos2d_ScaleBy_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ScaleBy_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ScaleBy_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ScaleBy_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ScaleBy_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ScaleBy_class->resolve = JS_ResolveStub; + jsb_cocos2d_ScaleBy_class->convert = JS_ConvertStub; + jsb_cocos2d_ScaleBy_class->finalize = js_cocos2d_ScaleBy_finalize; + jsb_cocos2d_ScaleBy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ScaleBy_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ScaleBy_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ScaleTo_prototype), + jsb_cocos2d_ScaleBy_class, + js_cocos2dx_ScaleBy_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, "ScaleBy", 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_ScaleBy_class; + p->proto = jsb_cocos2d_ScaleBy_prototype; + p->parentProto = jsb_cocos2d_ScaleTo_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Blink_class; +JSObject *jsb_cocos2d_Blink_prototype; + +bool js_cocos2dx_Blink_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Blink* cobj = (cocos2d::Blink *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Blink_initWithDuration : Invalid Native Object"); + if (argc == 2) { + double arg0; + int arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Blink_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Blink_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_Blink_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + int arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Blink_create : Error processing arguments"); + cocos2d::Blink* ret = cocos2d::Blink::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Blink*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Blink_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Blink_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Blink* cobj = new (std::nothrow) cocos2d::Blink(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Blink"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_Blink_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Blink)", obj); +} + +void js_register_cocos2dx_Blink(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Blink_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Blink_class->name = "Blink"; + jsb_cocos2d_Blink_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Blink_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Blink_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Blink_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Blink_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Blink_class->resolve = JS_ResolveStub; + jsb_cocos2d_Blink_class->convert = JS_ConvertStub; + jsb_cocos2d_Blink_class->finalize = js_cocos2d_Blink_finalize; + jsb_cocos2d_Blink_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_Blink_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Blink_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Blink_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_Blink_class, + js_cocos2dx_Blink_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, "Blink", 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_Blink_class; + p->proto = jsb_cocos2d_Blink_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_FadeTo_class; +JSObject *jsb_cocos2d_FadeTo_prototype; + +bool js_cocos2dx_FadeTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FadeTo* cobj = (cocos2d::FadeTo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FadeTo_initWithDuration : Invalid Native Object"); + if (argc == 2) { + double arg0; + uint16_t arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_uint16(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FadeTo_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FadeTo_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_FadeTo_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + uint16_t arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_uint16(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FadeTo_create : Error processing arguments"); + cocos2d::FadeTo* ret = cocos2d::FadeTo::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::FadeTo*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_FadeTo_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_FadeTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::FadeTo* cobj = new (std::nothrow) cocos2d::FadeTo(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FadeTo"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_FadeTo_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (FadeTo)", obj); +} + +void js_register_cocos2dx_FadeTo(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_FadeTo_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_FadeTo_class->name = "FadeTo"; + jsb_cocos2d_FadeTo_class->addProperty = JS_PropertyStub; + jsb_cocos2d_FadeTo_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_FadeTo_class->getProperty = JS_PropertyStub; + jsb_cocos2d_FadeTo_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_FadeTo_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_FadeTo_class->resolve = JS_ResolveStub; + jsb_cocos2d_FadeTo_class->convert = JS_ConvertStub; + jsb_cocos2d_FadeTo_class->finalize = js_cocos2d_FadeTo_finalize; + jsb_cocos2d_FadeTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_FadeTo_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_FadeTo_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_FadeTo_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_FadeTo_class, + js_cocos2dx_FadeTo_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, "FadeTo", 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_FadeTo_class; + p->proto = jsb_cocos2d_FadeTo_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_FadeIn_class; +JSObject *jsb_cocos2d_FadeIn_prototype; + +bool js_cocos2dx_FadeIn_setReverseAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FadeIn* cobj = (cocos2d::FadeIn *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FadeIn_setReverseAction : Invalid Native Object"); + if (argc == 1) { + cocos2d::FadeTo* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::FadeTo*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FadeIn_setReverseAction : Error processing arguments"); + cobj->setReverseAction(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FadeIn_setReverseAction : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FadeIn_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FadeIn_create : Error processing arguments"); + cocos2d::FadeIn* ret = cocos2d::FadeIn::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::FadeIn*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_FadeIn_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_FadeIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::FadeIn* cobj = new (std::nothrow) cocos2d::FadeIn(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FadeIn"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_FadeTo_prototype; + +void js_cocos2d_FadeIn_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (FadeIn)", obj); +} + +void js_register_cocos2dx_FadeIn(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_FadeIn_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_FadeIn_class->name = "FadeIn"; + jsb_cocos2d_FadeIn_class->addProperty = JS_PropertyStub; + jsb_cocos2d_FadeIn_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_FadeIn_class->getProperty = JS_PropertyStub; + jsb_cocos2d_FadeIn_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_FadeIn_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_FadeIn_class->resolve = JS_ResolveStub; + jsb_cocos2d_FadeIn_class->convert = JS_ConvertStub; + jsb_cocos2d_FadeIn_class->finalize = js_cocos2d_FadeIn_finalize; + jsb_cocos2d_FadeIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setReverseAction", js_cocos2dx_FadeIn_setReverseAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_FadeIn_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_FadeIn_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_FadeTo_prototype), + jsb_cocos2d_FadeIn_class, + js_cocos2dx_FadeIn_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, "FadeIn", 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_FadeIn_class; + p->proto = jsb_cocos2d_FadeIn_prototype; + p->parentProto = jsb_cocos2d_FadeTo_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_FadeOut_class; +JSObject *jsb_cocos2d_FadeOut_prototype; + +bool js_cocos2dx_FadeOut_setReverseAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FadeOut* cobj = (cocos2d::FadeOut *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FadeOut_setReverseAction : Invalid Native Object"); + if (argc == 1) { + cocos2d::FadeTo* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::FadeTo*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FadeOut_setReverseAction : Error processing arguments"); + cobj->setReverseAction(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FadeOut_setReverseAction : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FadeOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FadeOut_create : Error processing arguments"); + cocos2d::FadeOut* ret = cocos2d::FadeOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::FadeOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_FadeOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_FadeOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::FadeOut* cobj = new (std::nothrow) cocos2d::FadeOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FadeOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_FadeTo_prototype; + +void js_cocos2d_FadeOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (FadeOut)", obj); +} + +void js_register_cocos2dx_FadeOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_FadeOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_FadeOut_class->name = "FadeOut"; + jsb_cocos2d_FadeOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_FadeOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_FadeOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_FadeOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_FadeOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_FadeOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_FadeOut_class->convert = JS_ConvertStub; + jsb_cocos2d_FadeOut_class->finalize = js_cocos2d_FadeOut_finalize; + jsb_cocos2d_FadeOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setReverseAction", js_cocos2dx_FadeOut_setReverseAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_FadeOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_FadeOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_FadeTo_prototype), + jsb_cocos2d_FadeOut_class, + js_cocos2dx_FadeOut_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, "FadeOut", 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_FadeOut_class; + p->proto = jsb_cocos2d_FadeOut_prototype; + p->parentProto = jsb_cocos2d_FadeTo_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TintTo_class; +JSObject *jsb_cocos2d_TintTo_prototype; + +bool js_cocos2dx_TintTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TintTo* cobj = (cocos2d::TintTo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TintTo_initWithDuration : Invalid Native Object"); + if (argc == 4) { + double arg0; + uint16_t arg1; + uint16_t arg2; + uint16_t arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_uint16(cx, args.get(1), &arg1); + ok &= jsval_to_uint16(cx, args.get(2), &arg2); + ok &= jsval_to_uint16(cx, args.get(3), &arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TintTo_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TintTo_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_TintTo_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Color3B arg1; + ok &= jsval_to_cccolor3b(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::TintTo* ret = cocos2d::TintTo::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TintTo*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 4) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + uint16_t arg1; + ok &= jsval_to_uint16(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + uint16_t arg2; + ok &= jsval_to_uint16(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + uint16_t arg3; + ok &= jsval_to_uint16(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + cocos2d::TintTo* ret = cocos2d::TintTo::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TintTo*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_TintTo_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TintTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TintTo* cobj = new (std::nothrow) cocos2d::TintTo(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TintTo"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_TintTo_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TintTo)", obj); +} + +void js_register_cocos2dx_TintTo(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TintTo_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TintTo_class->name = "TintTo"; + jsb_cocos2d_TintTo_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TintTo_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TintTo_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TintTo_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TintTo_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TintTo_class->resolve = JS_ResolveStub; + jsb_cocos2d_TintTo_class->convert = JS_ConvertStub; + jsb_cocos2d_TintTo_class->finalize = js_cocos2d_TintTo_finalize; + jsb_cocos2d_TintTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_TintTo_initWithDuration, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TintTo_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TintTo_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_TintTo_class, + js_cocos2dx_TintTo_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, "TintTo", 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_TintTo_class; + p->proto = jsb_cocos2d_TintTo_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TintBy_class; +JSObject *jsb_cocos2d_TintBy_prototype; + +bool js_cocos2dx_TintBy_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TintBy* cobj = (cocos2d::TintBy *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TintBy_initWithDuration : Invalid Native Object"); + if (argc == 4) { + double arg0; + int32_t arg1; + int32_t arg2; + int32_t arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_int32(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), &arg2); + ok &= jsval_to_int32(cx, args.get(3), &arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TintBy_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TintBy_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_TintBy_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 4) { + double arg0; + int32_t arg1; + int32_t arg2; + int32_t arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_int32(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), &arg2); + ok &= jsval_to_int32(cx, args.get(3), &arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TintBy_create : Error processing arguments"); + cocos2d::TintBy* ret = cocos2d::TintBy::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TintBy*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TintBy_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TintBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TintBy* cobj = new (std::nothrow) cocos2d::TintBy(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TintBy"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_TintBy_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TintBy)", obj); +} + +void js_register_cocos2dx_TintBy(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TintBy_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TintBy_class->name = "TintBy"; + jsb_cocos2d_TintBy_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TintBy_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TintBy_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TintBy_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TintBy_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TintBy_class->resolve = JS_ResolveStub; + jsb_cocos2d_TintBy_class->convert = JS_ConvertStub; + jsb_cocos2d_TintBy_class->finalize = js_cocos2d_TintBy_finalize; + jsb_cocos2d_TintBy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_TintBy_initWithDuration, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TintBy_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TintBy_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_TintBy_class, + js_cocos2dx_TintBy_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, "TintBy", 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_TintBy_class; + p->proto = jsb_cocos2d_TintBy_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_DelayTime_class; +JSObject *jsb_cocos2d_DelayTime_prototype; + +bool js_cocos2dx_DelayTime_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DelayTime_create : Error processing arguments"); + cocos2d::DelayTime* ret = cocos2d::DelayTime::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::DelayTime*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_DelayTime_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_DelayTime_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::DelayTime* cobj = new (std::nothrow) cocos2d::DelayTime(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::DelayTime"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_DelayTime_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (DelayTime)", obj); +} + +void js_register_cocos2dx_DelayTime(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_DelayTime_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_DelayTime_class->name = "DelayTime"; + jsb_cocos2d_DelayTime_class->addProperty = JS_PropertyStub; + jsb_cocos2d_DelayTime_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_DelayTime_class->getProperty = JS_PropertyStub; + jsb_cocos2d_DelayTime_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_DelayTime_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_DelayTime_class->resolve = JS_ResolveStub; + jsb_cocos2d_DelayTime_class->convert = JS_ConvertStub; + jsb_cocos2d_DelayTime_class->finalize = js_cocos2d_DelayTime_finalize; + jsb_cocos2d_DelayTime_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_DelayTime_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_DelayTime_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_DelayTime_class, + js_cocos2dx_DelayTime_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, "DelayTime", 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_DelayTime_class; + p->proto = jsb_cocos2d_DelayTime_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ReverseTime_class; +JSObject *jsb_cocos2d_ReverseTime_prototype; + +bool js_cocos2dx_ReverseTime_initWithAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ReverseTime* cobj = (cocos2d::ReverseTime *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ReverseTime_initWithAction : Invalid Native Object"); + if (argc == 1) { + cocos2d::FiniteTimeAction* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ReverseTime_initWithAction : Error processing arguments"); + bool ret = cobj->initWithAction(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ReverseTime_initWithAction : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ReverseTime_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::FiniteTimeAction* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ReverseTime_create : Error processing arguments"); + cocos2d::ReverseTime* ret = cocos2d::ReverseTime::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ReverseTime*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ReverseTime_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ReverseTime_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ReverseTime* cobj = new (std::nothrow) cocos2d::ReverseTime(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ReverseTime"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_ReverseTime_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ReverseTime)", obj); +} + +void js_register_cocos2dx_ReverseTime(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ReverseTime_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ReverseTime_class->name = "ReverseTime"; + jsb_cocos2d_ReverseTime_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ReverseTime_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ReverseTime_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ReverseTime_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ReverseTime_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ReverseTime_class->resolve = JS_ResolveStub; + jsb_cocos2d_ReverseTime_class->convert = JS_ConvertStub; + jsb_cocos2d_ReverseTime_class->finalize = js_cocos2d_ReverseTime_finalize; + jsb_cocos2d_ReverseTime_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithAction", js_cocos2dx_ReverseTime_initWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ReverseTime_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ReverseTime_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_ReverseTime_class, + js_cocos2dx_ReverseTime_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, "ReverseTime", 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_ReverseTime_class; + p->proto = jsb_cocos2d_ReverseTime_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Animate_class; +JSObject *jsb_cocos2d_Animate_prototype; + +bool js_cocos2dx_Animate_getAnimation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Animate* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Animate *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animate_getAnimation : Invalid Native Object"); + do { + if (argc == 0) { + const cocos2d::Animation* ret = cobj->getAnimation(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Animation*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + cocos2d::Animation* ret = cobj->getAnimation(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Animation*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Animate_getAnimation : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Animate_initWithAnimation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animate* cobj = (cocos2d::Animate *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animate_initWithAnimation : Invalid Native Object"); + if (argc == 1) { + cocos2d::Animation* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Animation*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Animate_initWithAnimation : Error processing arguments"); + bool ret = cobj->initWithAnimation(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Animate_initWithAnimation : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Animate_setAnimation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Animate* cobj = (cocos2d::Animate *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Animate_setAnimation : Invalid Native Object"); + if (argc == 1) { + cocos2d::Animation* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Animation*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Animate_setAnimation : Error processing arguments"); + cobj->setAnimation(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Animate_setAnimation : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Animate_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Animation* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Animation*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Animate_create : Error processing arguments"); + cocos2d::Animate* ret = cocos2d::Animate::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Animate*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Animate_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Animate_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Animate* cobj = new (std::nothrow) cocos2d::Animate(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Animate"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_Animate_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Animate)", obj); +} + +void js_register_cocos2dx_Animate(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Animate_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Animate_class->name = "Animate"; + jsb_cocos2d_Animate_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Animate_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Animate_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Animate_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Animate_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Animate_class->resolve = JS_ResolveStub; + jsb_cocos2d_Animate_class->convert = JS_ConvertStub; + jsb_cocos2d_Animate_class->finalize = js_cocos2d_Animate_finalize; + jsb_cocos2d_Animate_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getAnimation", js_cocos2dx_Animate_getAnimation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithAnimation", js_cocos2dx_Animate_initWithAnimation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAnimation", js_cocos2dx_Animate_setAnimation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Animate_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Animate_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_Animate_class, + js_cocos2dx_Animate_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, "Animate", 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_Animate_class; + p->proto = jsb_cocos2d_Animate_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TargetedAction_class; +JSObject *jsb_cocos2d_TargetedAction_prototype; + +bool js_cocos2dx_TargetedAction_getForcedTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::TargetedAction* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::TargetedAction *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TargetedAction_getForcedTarget : Invalid Native Object"); + do { + if (argc == 0) { + const cocos2d::Node* ret = cobj->getForcedTarget(); + 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); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + cocos2d::Node* ret = cobj->getForcedTarget(); + 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); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_TargetedAction_getForcedTarget : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TargetedAction_initWithTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TargetedAction* cobj = (cocos2d::TargetedAction *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TargetedAction_initWithTarget : Invalid Native Object"); + if (argc == 2) { + cocos2d::Node* arg0; + cocos2d::FiniteTimeAction* arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TargetedAction_initWithTarget : Error processing arguments"); + bool ret = cobj->initWithTarget(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TargetedAction_initWithTarget : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_TargetedAction_setForcedTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TargetedAction* cobj = (cocos2d::TargetedAction *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TargetedAction_setForcedTarget : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TargetedAction_setForcedTarget : Error processing arguments"); + cobj->setForcedTarget(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TargetedAction_setForcedTarget : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TargetedAction_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::Node* arg0; + cocos2d::FiniteTimeAction* arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::FiniteTimeAction*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TargetedAction_create : Error processing arguments"); + cocos2d::TargetedAction* ret = cocos2d::TargetedAction::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TargetedAction*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TargetedAction_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TargetedAction_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TargetedAction* cobj = new (std::nothrow) cocos2d::TargetedAction(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TargetedAction"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_TargetedAction_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TargetedAction)", obj); +} + +static bool js_cocos2d_TargetedAction_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TargetedAction *nobj = new (std::nothrow) cocos2d::TargetedAction(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TargetedAction"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_TargetedAction(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TargetedAction_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TargetedAction_class->name = "TargetedAction"; + jsb_cocos2d_TargetedAction_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TargetedAction_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TargetedAction_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TargetedAction_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TargetedAction_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TargetedAction_class->resolve = JS_ResolveStub; + jsb_cocos2d_TargetedAction_class->convert = JS_ConvertStub; + jsb_cocos2d_TargetedAction_class->finalize = js_cocos2d_TargetedAction_finalize; + jsb_cocos2d_TargetedAction_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getForcedTarget", js_cocos2dx_TargetedAction_getForcedTarget, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTarget", js_cocos2dx_TargetedAction_initWithTarget, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setForcedTarget", js_cocos2dx_TargetedAction_setForcedTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_TargetedAction_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TargetedAction_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TargetedAction_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_TargetedAction_class, + js_cocos2dx_TargetedAction_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, "TargetedAction", 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_TargetedAction_class; + p->proto = jsb_cocos2d_TargetedAction_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ActionFloat_class; +JSObject *jsb_cocos2d_ActionFloat_prototype; + +bool js_cocos2dx_ActionFloat_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionFloat* cobj = (cocos2d::ActionFloat *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionFloat_initWithDuration : Invalid Native Object"); + if (argc == 4) { + double arg0; + double arg1; + double arg2; + std::function arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + do { + if(JS_TypeOfValue(cx, args.get(3)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(3))); + auto lambda = [=](float larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[1]; + largv[0] = DOUBLE_TO_JSVAL(larg0); + JS::RootedValue rval(cx); + 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_ActionFloat_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionFloat_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_ActionFloat_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 4) { + double arg0; + double arg1; + double arg2; + std::function arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + do { + if(JS_TypeOfValue(cx, args.get(3)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(3))); + auto lambda = [=](float larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[1]; + largv[0] = DOUBLE_TO_JSVAL(larg0); + JS::RootedValue rval(cx); + 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_ActionFloat_create : Error processing arguments"); + cocos2d::ActionFloat* ret = cocos2d::ActionFloat::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionFloat*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ActionFloat_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ActionFloat_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ActionFloat* cobj = new (std::nothrow) cocos2d::ActionFloat(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ActionFloat"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_ActionFloat_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ActionFloat)", obj); +} + +static bool js_cocos2d_ActionFloat_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ActionFloat *nobj = new (std::nothrow) cocos2d::ActionFloat(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ActionFloat"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ActionFloat(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ActionFloat_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ActionFloat_class->name = "ActionFloat"; + jsb_cocos2d_ActionFloat_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ActionFloat_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ActionFloat_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ActionFloat_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ActionFloat_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ActionFloat_class->resolve = JS_ResolveStub; + jsb_cocos2d_ActionFloat_class->convert = JS_ConvertStub; + jsb_cocos2d_ActionFloat_class->finalize = js_cocos2d_ActionFloat_finalize; + jsb_cocos2d_ActionFloat_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_ActionFloat_initWithDuration, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ActionFloat_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ActionFloat_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ActionFloat_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_ActionFloat_class, + js_cocos2dx_ActionFloat_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, "ActionFloat", 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_ActionFloat_class; + p->proto = jsb_cocos2d_ActionFloat_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Configuration_class; +JSObject *jsb_cocos2d_Configuration_prototype; + +bool js_cocos2dx_Configuration_supportsPVRTC(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_supportsPVRTC : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->supportsPVRTC(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_supportsPVRTC : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Configuration_getMaxModelviewStackDepth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_getMaxModelviewStackDepth : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getMaxModelviewStackDepth(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_getMaxModelviewStackDepth : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Configuration_supportsShareableVAO(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_supportsShareableVAO : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->supportsShareableVAO(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_supportsShareableVAO : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Configuration_supportsBGRA8888(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_supportsBGRA8888 : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->supportsBGRA8888(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_supportsBGRA8888 : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Configuration_checkForGLExtension(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_checkForGLExtension : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Configuration_checkForGLExtension : Error processing arguments"); + bool ret = cobj->checkForGLExtension(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_checkForGLExtension : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Configuration_supportsATITC(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_supportsATITC : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->supportsATITC(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_supportsATITC : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Configuration_supportsNPOT(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_supportsNPOT : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->supportsNPOT(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_supportsNPOT : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Configuration_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Configuration_getAnimate3DQuality(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_getAnimate3DQuality : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getAnimate3DQuality(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_getAnimate3DQuality : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Configuration_getMaxSupportPointLightInShader(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_getMaxSupportPointLightInShader : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getMaxSupportPointLightInShader(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_getMaxSupportPointLightInShader : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Configuration_getMaxTextureSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_getMaxTextureSize : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getMaxTextureSize(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_getMaxTextureSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Configuration_setValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_setValue : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + cocos2d::Value arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_ccvalue(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Configuration_setValue : Error processing arguments"); + cobj->setValue(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_setValue : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_Configuration_getMaxSupportSpotLightInShader(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_getMaxSupportSpotLightInShader : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getMaxSupportSpotLightInShader(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_getMaxSupportSpotLightInShader : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Configuration_supportsETC(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_supportsETC : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->supportsETC(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_supportsETC : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Configuration_getMaxSupportDirLightInShader(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_getMaxSupportDirLightInShader : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getMaxSupportDirLightInShader(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_getMaxSupportDirLightInShader : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Configuration_loadConfigFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_loadConfigFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Configuration_loadConfigFile : Error processing arguments"); + cobj->loadConfigFile(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_loadConfigFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Configuration_supportsDiscardFramebuffer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_supportsDiscardFramebuffer : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->supportsDiscardFramebuffer(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_supportsDiscardFramebuffer : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Configuration_supportsS3TC(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_supportsS3TC : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->supportsS3TC(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_supportsS3TC : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Configuration_getInfo(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_getInfo : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getInfo(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_getInfo : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Configuration_getMaxTextureUnits(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_getMaxTextureUnits : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getMaxTextureUnits(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_getMaxTextureUnits : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Configuration_getValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_getValue : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Configuration_getValue : Error processing arguments"); + const cocos2d::Value& ret = cobj->getValue(arg0); + jsval jsret = JSVAL_NULL; + jsret = ccvalue_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::Value arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_ccvalue(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Configuration_getValue : Error processing arguments"); + const cocos2d::Value& ret = cobj->getValue(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = ccvalue_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_getValue : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Configuration_gatherGPUInfo(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Configuration* cobj = (cocos2d::Configuration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Configuration_gatherGPUInfo : Invalid Native Object"); + if (argc == 0) { + cobj->gatherGPUInfo(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Configuration_gatherGPUInfo : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Configuration_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Configuration::destroyInstance(); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Configuration_destroyInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Configuration_getInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Configuration* ret = cocos2d::Configuration::getInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Configuration*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Configuration_getInstance : wrong number of arguments"); + return false; +} + + + +void js_cocos2d_Configuration_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Configuration)", obj); +} + +void js_register_cocos2dx_Configuration(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Configuration_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Configuration_class->name = "Configuration"; + jsb_cocos2d_Configuration_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Configuration_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Configuration_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Configuration_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Configuration_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Configuration_class->resolve = JS_ResolveStub; + jsb_cocos2d_Configuration_class->convert = JS_ConvertStub; + jsb_cocos2d_Configuration_class->finalize = js_cocos2d_Configuration_finalize; + jsb_cocos2d_Configuration_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("supportsPVRTC", js_cocos2dx_Configuration_supportsPVRTC, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaxModelviewStackDepth", js_cocos2dx_Configuration_getMaxModelviewStackDepth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("supportsShareableVAO", js_cocos2dx_Configuration_supportsShareableVAO, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("supportsBGRA8888", js_cocos2dx_Configuration_supportsBGRA8888, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("checkForGLExtension", js_cocos2dx_Configuration_checkForGLExtension, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("supportsATITC", js_cocos2dx_Configuration_supportsATITC, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("supportsNPOT", js_cocos2dx_Configuration_supportsNPOT, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_Configuration_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAnimate3DQuality", js_cocos2dx_Configuration_getAnimate3DQuality, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaxSupportPointLightInShader", js_cocos2dx_Configuration_getMaxSupportPointLightInShader, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaxTextureSize", js_cocos2dx_Configuration_getMaxTextureSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setValue", js_cocos2dx_Configuration_setValue, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaxSupportSpotLightInShader", js_cocos2dx_Configuration_getMaxSupportSpotLightInShader, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("supportsETC", js_cocos2dx_Configuration_supportsETC, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaxSupportDirLightInShader", js_cocos2dx_Configuration_getMaxSupportDirLightInShader, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadConfigFile", js_cocos2dx_Configuration_loadConfigFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("supportsDiscardFramebuffer", js_cocos2dx_Configuration_supportsDiscardFramebuffer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("supportsS3TC", js_cocos2dx_Configuration_supportsS3TC, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("dumpInfo", js_cocos2dx_Configuration_getInfo, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaxTextureUnits", js_cocos2dx_Configuration_getMaxTextureUnits, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getValue", js_cocos2dx_Configuration_getValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("gatherGPUInfo", js_cocos2dx_Configuration_gatherGPUInfo, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("destroyInstance", js_cocos2dx_Configuration_destroyInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInstance", js_cocos2dx_Configuration_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Configuration_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_Configuration_class, + empty_constructor, 0, + 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, "Configuration", 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_Configuration_class; + p->proto = jsb_cocos2d_Configuration_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Scene_class; +JSObject *jsb_cocos2d_Scene_prototype; + +bool js_cocos2dx_Scene_setCameraOrderDirty(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scene* cobj = (cocos2d::Scene *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Scene_setCameraOrderDirty : Invalid Native Object"); + if (argc == 0) { + cobj->setCameraOrderDirty(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Scene_setCameraOrderDirty : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Scene_render(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scene* cobj = (cocos2d::Scene *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Scene_render : Invalid Native Object"); + if (argc == 1) { + cocos2d::Renderer* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Renderer*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Scene_render : Error processing arguments"); + cobj->render(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Scene_render : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Scene_onProjectionChanged(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scene* cobj = (cocos2d::Scene *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Scene_onProjectionChanged : Invalid Native Object"); + if (argc == 1) { + cocos2d::EventCustom* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::EventCustom*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Scene_onProjectionChanged : Error processing arguments"); + cobj->onProjectionChanged(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Scene_onProjectionChanged : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Scene_initWithSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scene* cobj = (cocos2d::Scene *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Scene_initWithSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Scene_initWithSize : Error processing arguments"); + bool ret = cobj->initWithSize(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Scene_initWithSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Scene_getDefaultCamera(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scene* cobj = (cocos2d::Scene *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Scene_getDefaultCamera : Invalid Native Object"); + if (argc == 0) { + cocos2d::Camera* ret = cobj->getDefaultCamera(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Camera*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Scene_getDefaultCamera : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Scene_createWithSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Scene_createWithSize : Error processing arguments"); + cocos2d::Scene* ret = cocos2d::Scene::createWithSize(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Scene*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Scene_createWithSize : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Scene_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Scene* ret = cocos2d::Scene::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Scene*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Scene_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Scene_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Scene* cobj = new (std::nothrow) cocos2d::Scene(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Scene"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_Scene_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Scene)", obj); +} + +static bool js_cocos2d_Scene_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Scene *nobj = new (std::nothrow) cocos2d::Scene(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Scene"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_Scene(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Scene_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Scene_class->name = "Scene"; + jsb_cocos2d_Scene_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Scene_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Scene_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Scene_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Scene_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Scene_class->resolve = JS_ResolveStub; + jsb_cocos2d_Scene_class->convert = JS_ConvertStub; + jsb_cocos2d_Scene_class->finalize = js_cocos2d_Scene_finalize; + jsb_cocos2d_Scene_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setCameraOrderDirty", js_cocos2dx_Scene_setCameraOrderDirty, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("render", js_cocos2dx_Scene_render, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("onProjectionChanged", js_cocos2dx_Scene_onProjectionChanged, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithSize", js_cocos2dx_Scene_initWithSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDefaultCamera", js_cocos2dx_Scene_getDefaultCamera, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_Scene_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("createWithSize", js_cocos2dx_Scene_createWithSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("create", js_cocos2dx_Scene_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Scene_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_Scene_class, + js_cocos2dx_Scene_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, "Scene", 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_Scene_class; + p->proto = jsb_cocos2d_Scene_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_GLView_class; +JSObject *jsb_cocos2d_GLView_prototype; + +bool js_cocos2dx_GLView_setFrameSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_setFrameSize : Invalid Native Object"); + if (argc == 2) { + double arg0; + double arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLView_setFrameSize : Error processing arguments"); + cobj->setFrameSize(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_setFrameSize : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_GLView_getViewPortRect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_getViewPortRect : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Rect& ret = cobj->getViewPortRect(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_getViewPortRect : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLView_setContentScaleFactor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_setContentScaleFactor : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLView_setContentScaleFactor : Error processing arguments"); + bool ret = cobj->setContentScaleFactor(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_setContentScaleFactor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_GLView_getContentScaleFactor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_getContentScaleFactor : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getContentScaleFactor(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_getContentScaleFactor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLView_setIMEKeyboardState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_setIMEKeyboardState : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLView_setIMEKeyboardState : Error processing arguments"); + cobj->setIMEKeyboardState(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_setIMEKeyboardState : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_GLView_setScissorInPoints(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_setScissorInPoints : Invalid Native Object"); + if (argc == 4) { + double arg0; + double arg1; + double arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLView_setScissorInPoints : Error processing arguments"); + cobj->setScissorInPoints(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_setScissorInPoints : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_GLView_getViewName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_getViewName : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getViewName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_getViewName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLView_isOpenGLReady(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_isOpenGLReady : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isOpenGLReady(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_isOpenGLReady : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLView_setCursorVisible(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_setCursorVisible : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLView_setCursorVisible : Error processing arguments"); + cobj->setCursorVisible(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_setCursorVisible : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_GLView_getScaleY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_getScaleY : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getScaleY(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_getScaleY : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLView_getScaleX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_getScaleX : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getScaleX(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_getScaleX : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLView_getVisibleOrigin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_getVisibleOrigin : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getVisibleOrigin(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_getVisibleOrigin : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLView_getFrameSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_getFrameSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getFrameSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_getFrameSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLView_setFrameZoomFactor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_setFrameZoomFactor : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLView_setFrameZoomFactor : Error processing arguments"); + cobj->setFrameZoomFactor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_setFrameZoomFactor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_GLView_getFrameZoomFactor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_getFrameZoomFactor : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getFrameZoomFactor(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_getFrameZoomFactor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLView_getDesignResolutionSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_getDesignResolutionSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getDesignResolutionSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_getDesignResolutionSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLView_windowShouldClose(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_windowShouldClose : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->windowShouldClose(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_windowShouldClose : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLView_setDesignResolutionSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_setDesignResolutionSize : Invalid Native Object"); + if (argc == 3) { + double arg0; + double arg1; + ResolutionPolicy arg2; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLView_setDesignResolutionSize : Error processing arguments"); + cobj->setDesignResolutionSize(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_setDesignResolutionSize : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_GLView_getResolutionPolicy(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_getResolutionPolicy : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getResolutionPolicy(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_getResolutionPolicy : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLView_isRetinaDisplay(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_isRetinaDisplay : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isRetinaDisplay(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_isRetinaDisplay : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLView_setViewPortInPoints(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_setViewPortInPoints : Invalid Native Object"); + if (argc == 4) { + double arg0; + double arg1; + double arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLView_setViewPortInPoints : Error processing arguments"); + cobj->setViewPortInPoints(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_setViewPortInPoints : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_GLView_getScissorRect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_getScissorRect : Invalid Native Object"); + if (argc == 0) { + cocos2d::Rect ret = cobj->getScissorRect(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_getScissorRect : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLView_getRetinaFactor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_getRetinaFactor : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getRetinaFactor(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_getRetinaFactor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLView_setViewName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_setViewName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLView_setViewName : Error processing arguments"); + cobj->setViewName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_setViewName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_GLView_getVisibleRect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_getVisibleRect : Invalid Native Object"); + if (argc == 0) { + cocos2d::Rect ret = cobj->getVisibleRect(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_getVisibleRect : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLView_getVisibleSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_getVisibleSize : Invalid Native Object"); + if (argc == 0) { + cocos2d::Size ret = cobj->getVisibleSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_getVisibleSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLView_isScissorEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_isScissorEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isScissorEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_isScissorEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLView_pollEvents(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLView* cobj = (cocos2d::GLView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLView_pollEvents : Invalid Native Object"); + if (argc == 0) { + cobj->pollEvents(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLView_pollEvents : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLView_setGLContextAttrs(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + GLContextAttrs arg0; + #pragma warning NO CONVERSION TO NATIVE FOR GLContextAttrs + ok = false; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLView_setGLContextAttrs : Error processing arguments"); + cocos2d::GLView::setGLContextAttrs(arg0); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_GLView_setGLContextAttrs : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_GLView_getGLContextAttrs(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + GLContextAttrs ret = cocos2d::GLView::getGLContextAttrs(); + jsval jsret = JSVAL_NULL; + #pragma warning NO CONVERSION FROM NATIVE FOR GLContextAttrs; + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_GLView_getGLContextAttrs : wrong number of arguments"); + return false; +} + + + +void js_cocos2d_GLView_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (GLView)", obj); +} + +void js_register_cocos2dx_GLView(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_GLView_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_GLView_class->name = "GLView"; + jsb_cocos2d_GLView_class->addProperty = JS_PropertyStub; + jsb_cocos2d_GLView_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_GLView_class->getProperty = JS_PropertyStub; + jsb_cocos2d_GLView_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_GLView_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_GLView_class->resolve = JS_ResolveStub; + jsb_cocos2d_GLView_class->convert = JS_ConvertStub; + jsb_cocos2d_GLView_class->finalize = js_cocos2d_GLView_finalize; + jsb_cocos2d_GLView_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setFrameSize", js_cocos2dx_GLView_setFrameSize, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getViewPortRect", js_cocos2dx_GLView_getViewPortRect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setContentScaleFactor", js_cocos2dx_GLView_setContentScaleFactor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getContentScaleFactor", js_cocos2dx_GLView_getContentScaleFactor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setIMEKeyboardState", js_cocos2dx_GLView_setIMEKeyboardState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setScissorInPoints", js_cocos2dx_GLView_setScissorInPoints, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getViewName", js_cocos2dx_GLView_getViewName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isOpenGLReady", js_cocos2dx_GLView_isOpenGLReady, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCursorVisible", js_cocos2dx_GLView_setCursorVisible, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getScaleY", js_cocos2dx_GLView_getScaleY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getScaleX", js_cocos2dx_GLView_getScaleX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVisibleOrigin", js_cocos2dx_GLView_getVisibleOrigin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFrameSize", js_cocos2dx_GLView_getFrameSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFrameZoomFactor", js_cocos2dx_GLView_setFrameZoomFactor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFrameZoomFactor", js_cocos2dx_GLView_getFrameZoomFactor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDesignResolutionSize", js_cocos2dx_GLView_getDesignResolutionSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("windowShouldClose", js_cocos2dx_GLView_windowShouldClose, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDesignResolutionSize", js_cocos2dx_GLView_setDesignResolutionSize, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getResolutionPolicy", js_cocos2dx_GLView_getResolutionPolicy, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isRetinaDisplay", js_cocos2dx_GLView_isRetinaDisplay, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setViewPortInPoints", js_cocos2dx_GLView_setViewPortInPoints, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getScissorRect", js_cocos2dx_GLView_getScissorRect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRetinaFactor", js_cocos2dx_GLView_getRetinaFactor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setViewName", js_cocos2dx_GLView_setViewName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVisibleRect", js_cocos2dx_GLView_getVisibleRect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVisibleSize", js_cocos2dx_GLView_getVisibleSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isScissorEnabled", js_cocos2dx_GLView_isScissorEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pollEvents", js_cocos2dx_GLView_pollEvents, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("setGLContextAttrs", js_cocos2dx_GLView_setGLContextAttrs, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getGLContextAttrs", js_cocos2dx_GLView_getGLContextAttrs, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_GLView_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_GLView_class, + empty_constructor, 0, + 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, "GLView", 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_GLView_class; + p->proto = jsb_cocos2d_GLView_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Director_class; +JSObject *jsb_cocos2d_Director_prototype; + +bool js_cocos2dx_Director_pause(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_pause : Invalid Native Object"); + if (argc == 0) { + cobj->pause(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_pause : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_setEventDispatcher(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setEventDispatcher : Invalid Native Object"); + if (argc == 1) { + cocos2d::EventDispatcher* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::EventDispatcher*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_setEventDispatcher : Error processing arguments"); + cobj->setEventDispatcher(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_setEventDispatcher : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Director_setContentScaleFactor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_setContentScaleFactor : Error processing arguments"); + cobj->setContentScaleFactor(arg0); + args.rval().setUndefined(); + 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_getContentScaleFactor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getContentScaleFactor : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getContentScaleFactor(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_getContentScaleFactor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_getWinSizeInPixels(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getWinSizeInPixels : Invalid Native Object"); + if (argc == 0) { + cocos2d::Size ret = cobj->getWinSizeInPixels(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_getWinSizeInPixels : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_getDeltaTime(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(jsret); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setGLDefaultValues : Invalid Native Object"); + if (argc == 0) { + cobj->setGLDefaultValues(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_setGLDefaultValues : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_setActionManager(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setActionManager : Invalid Native Object"); + if (argc == 1) { + cocos2d::ActionManager* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionManager*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_setActionManager : Error processing arguments"); + cobj->setActionManager(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_setActionManager : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Director_setAlphaBlending(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setAlphaBlending : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_setAlphaBlending : Error processing arguments"); + cobj->setAlphaBlending(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_setAlphaBlending : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Director_popToRootScene(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_popToRootScene : Invalid Native Object"); + if (argc == 0) { + cobj->popToRootScene(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_popToRootScene : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_loadMatrix(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_loadMatrix : Invalid Native Object"); + if (argc == 2) { + cocos2d::MATRIX_STACK_TYPE arg0; + cocos2d::Mat4 arg1; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_matrix(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_loadMatrix : Error processing arguments"); + cobj->loadMatrix(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_loadMatrix : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_Director_getNotificationNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getNotificationNode : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getNotificationNode(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_getNotificationNode : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_getWinSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getWinSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getWinSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_getWinSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_end(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_end : Invalid Native Object"); + if (argc == 0) { + cobj->end(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_end : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_getTextureCache(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getTextureCache : Invalid Native Object"); + if (argc == 0) { + cocos2d::TextureCache* ret = cobj->getTextureCache(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TextureCache*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_getTextureCache : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_isSendCleanupToScene(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isSendCleanupToScene : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isSendCleanupToScene(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_isSendCleanupToScene : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_getVisibleOrigin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getVisibleOrigin : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getVisibleOrigin(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_getVisibleOrigin : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_mainLoop(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_mainLoop : Invalid Native Object"); + if (argc == 0) { + cobj->mainLoop(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_mainLoop : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_setDepthTest(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setDepthTest : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_setDepthTest : Error processing arguments"); + cobj->setDepthTest(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_setDepthTest : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Director_getFrameRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getFrameRate : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getFrameRate(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_getFrameRate : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_getSecondsPerFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getSecondsPerFrame : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getSecondsPerFrame(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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(); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_convertToUI : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_convertToUI : Error processing arguments"); + cocos2d::Vec2 ret = cobj->convertToUI(arg0); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_pushMatrix : Error processing arguments"); + cobj->pushMatrix(arg0); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setDefaultValues : Invalid Native Object"); + if (argc == 0) { + cobj->setDefaultValues(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_setDefaultValues : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_setScheduler(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setScheduler : Invalid Native Object"); + if (argc == 1) { + cocos2d::Scheduler* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Scheduler*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_setScheduler : Error processing arguments"); + cobj->setScheduler(arg0); + args.rval().setUndefined(); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_startAnimation : Invalid Native Object"); + if (argc == 0) { + cobj->startAnimation(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_startAnimation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_getOpenGLView(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getOpenGLView : Invalid Native Object"); + if (argc == 0) { + cocos2d::GLView* ret = cobj->getOpenGLView(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::GLView*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_getOpenGLView : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_getRunningScene(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getRunningScene : Invalid Native Object"); + if (argc == 0) { + cocos2d::Scene* ret = cobj->getRunningScene(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Scene*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_getRunningScene : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_setViewport(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setViewport : Invalid Native Object"); + if (argc == 0) { + cobj->setViewport(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_setViewport : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_stopAnimation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_stopAnimation : Invalid Native Object"); + if (argc == 0) { + cobj->stopAnimation(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_stopAnimation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_popToSceneStackLevel(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_popToSceneStackLevel : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_popToSceneStackLevel : Error processing arguments"); + cobj->popToSceneStackLevel(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_popToSceneStackLevel : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Director_resume(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_resume : Invalid Native Object"); + if (argc == 0) { + cobj->resume(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_resume : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_isNextDeltaTimeZero(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isNextDeltaTimeZero : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isNextDeltaTimeZero(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_isNextDeltaTimeZero : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_setClearColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setClearColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color4F arg0; + ok &= jsval_to_cccolor4f(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_setClearColor : Error processing arguments"); + cobj->setClearColor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_setClearColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Director_setOpenGLView(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setOpenGLView : Invalid Native Object"); + if (argc == 1) { + cocos2d::GLView* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::GLView*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_setOpenGLView : Error processing arguments"); + cobj->setOpenGLView(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_setOpenGLView : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Director_convertToGL(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_convertToGL : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_convertToGL : Error processing arguments"); + cocos2d::Vec2 ret = cobj->convertToGL(arg0); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_convertToGL : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Director_purgeCachedData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_purgeCachedData : Invalid Native Object"); + if (argc == 0) { + cobj->purgeCachedData(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_purgeCachedData : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_getTotalFrames(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getTotalFrames : Invalid Native Object"); + if (argc == 0) { + unsigned int ret = cobj->getTotalFrames(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_getTotalFrames : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_runWithScene(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_runWithScene : Invalid Native Object"); + if (argc == 1) { + cocos2d::Scene* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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_runWithScene : Error processing arguments"); + cobj->runWithScene(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_runWithScene : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Director_setNotificationNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setNotificationNode : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_setNotificationNode : Error processing arguments"); + cobj->setNotificationNode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_setNotificationNode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Director_drawScene(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_drawScene : Invalid Native Object"); + if (argc == 0) { + cobj->drawScene(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_drawScene : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_restart(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_restart : Invalid Native Object"); + if (argc == 0) { + cobj->restart(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_restart : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_popScene(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_popScene : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_loadIdentityMatrix(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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) { + cocos2d::MATRIX_STACK_TYPE arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_loadIdentityMatrix : Error processing arguments"); + cobj->loadIdentityMatrix(arg0); + args.rval().setUndefined(); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isDisplayStats : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isDisplayStats(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_isDisplayStats : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_setProjection(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setProjection : Invalid Native Object"); + if (argc == 1) { + cocos2d::Director::Projection arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_setProjection : Error processing arguments"); + cobj->setProjection(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_setProjection : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Director_multiplyMatrix(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_matrix(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_multiplyMatrix : Error processing arguments"); + cobj->multiplyMatrix(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setNextDeltaTimeZero : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_setNextDeltaTimeZero : Error processing arguments"); + cobj->setNextDeltaTimeZero(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_setNextDeltaTimeZero : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Director_popMatrix(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_popMatrix : Invalid Native Object"); + if (argc == 1) { + cocos2d::MATRIX_STACK_TYPE arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_popMatrix : Error processing arguments"); + cobj->popMatrix(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_popMatrix : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Director_getVisibleSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getVisibleSize : Invalid Native Object"); + if (argc == 0) { + cocos2d::Size ret = cobj->getVisibleSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_getVisibleSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_getScheduler(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getScheduler : Invalid Native Object"); + if (argc == 0) { + cocos2d::Scheduler* ret = cobj->getScheduler(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Scheduler*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_getScheduler : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_pushScene(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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"); + if (argc == 1) { + cocos2d::Scene* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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); + args.rval().setUndefined(); + 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_getAnimationInterval(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getAnimationInterval : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAnimationInterval(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_getAnimationInterval : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_isPaused(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isPaused : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isPaused(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_isPaused : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_setDisplayStats(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setDisplayStats : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_setDisplayStats : Error processing arguments"); + cobj->setDisplayStats(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_setDisplayStats : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Director_getEventDispatcher(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getEventDispatcher : Invalid Native Object"); + if (argc == 0) { + cocos2d::EventDispatcher* ret = cobj->getEventDispatcher(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EventDispatcher*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_getEventDispatcher : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_replaceScene(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_replaceScene : Invalid Native Object"); + if (argc == 1) { + cocos2d::Scene* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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_replaceScene : Error processing arguments"); + cobj->replaceScene(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_replaceScene : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Director_setAnimationInterval(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_setAnimationInterval : Error processing arguments"); + cobj->setAnimationInterval(arg0); + args.rval().setUndefined(); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getActionManager : Invalid Native Object"); + if (argc == 0) { + cocos2d::ActionManager* ret = cobj->getActionManager(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionManager*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_getActionManager : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Director_getInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Director* ret = cocos2d::Director::getInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Director*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Director_getInstance : wrong number of arguments"); + return false; +} + + + +void js_cocos2d_Director_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Director)", obj); +} + +void js_register_cocos2dx_Director(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Director_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Director_class->name = "Director"; + jsb_cocos2d_Director_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Director_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Director_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Director_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Director_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Director_class->resolve = JS_ResolveStub; + jsb_cocos2d_Director_class->convert = JS_ConvertStub; + jsb_cocos2d_Director_class->finalize = js_cocos2d_Director_finalize; + jsb_cocos2d_Director_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + 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("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("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), + JS_FN("popToRootScene", js_cocos2dx_Director_popToRootScene, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadMatrix", js_cocos2dx_Director_loadMatrix, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNotificationNode", js_cocos2dx_Director_getNotificationNode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getWinSize", js_cocos2dx_Director_getWinSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("end", js_cocos2dx_Director_end, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTextureCache", js_cocos2dx_Director_getTextureCache, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isSendCleanupToScene", js_cocos2dx_Director_isSendCleanupToScene, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVisibleOrigin", js_cocos2dx_Director_getVisibleOrigin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("mainLoop", js_cocos2dx_Director_mainLoop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + 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("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), + JS_FN("setClearColor", js_cocos2dx_Director_setClearColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setOpenGLView", js_cocos2dx_Director_setOpenGLView, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("convertToGL", js_cocos2dx_Director_convertToGL, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("purgeCachedData", js_cocos2dx_Director_purgeCachedData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTotalFrames", js_cocos2dx_Director_getTotalFrames, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + 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("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("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("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("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("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 + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("getInstance", js_cocos2dx_Director_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Director_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_Director_class, + empty_constructor, 0, + 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, "Director", 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_Director_class; + p->proto = jsb_cocos2d_Director_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Scheduler_class; +JSObject *jsb_cocos2d_Scheduler_prototype; + +bool js_cocos2dx_Scheduler_setTimeScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Scheduler_setTimeScale : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Scheduler_setTimeScale : Error processing arguments"); + cobj->setTimeScale(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Scheduler_setTimeScale : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Scheduler_unscheduleAllWithMinPriority(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Scheduler_unscheduleAllWithMinPriority : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Scheduler_unscheduleAllWithMinPriority : Error processing arguments"); + cobj->unscheduleAllWithMinPriority(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Scheduler_unscheduleAllWithMinPriority : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Scheduler_update(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Scheduler_update : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Scheduler_update : Error processing arguments"); + cobj->update(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Scheduler_update : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Scheduler_unscheduleScriptEntry(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Scheduler_unscheduleScriptEntry : Invalid Native Object"); + if (argc == 1) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Scheduler_unscheduleScriptEntry : Error processing arguments"); + cobj->unscheduleScriptEntry(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Scheduler_unscheduleScriptEntry : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Scheduler_performFunctionInCocosThread(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Scheduler_performFunctionInCocosThread : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + auto lambda = [=]() -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + JS::RootedValue rval(cx); + 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"); + cobj->performFunctionInCocosThread(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Scheduler_performFunctionInCocosThread : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Scheduler_unscheduleAll(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Scheduler_unscheduleAll : Invalid Native Object"); + if (argc == 0) { + cobj->unscheduleAll(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Scheduler_unscheduleAll : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Scheduler_getTimeScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Scheduler_getTimeScale : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getTimeScale(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Scheduler_getTimeScale : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Scheduler_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Scheduler* cobj = new (std::nothrow) cocos2d::Scheduler(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Scheduler"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_Scheduler_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Scheduler)", obj); +} + +void js_register_cocos2dx_Scheduler(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Scheduler_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Scheduler_class->name = "Scheduler"; + jsb_cocos2d_Scheduler_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Scheduler_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Scheduler_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Scheduler_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Scheduler_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Scheduler_class->resolve = JS_ResolveStub; + jsb_cocos2d_Scheduler_class->convert = JS_ConvertStub; + jsb_cocos2d_Scheduler_class->finalize = js_cocos2d_Scheduler_finalize; + jsb_cocos2d_Scheduler_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setTimeScale", js_cocos2dx_Scheduler_setTimeScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("unscheduleAllWithMinPriority", js_cocos2dx_Scheduler_unscheduleAllWithMinPriority, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("update", js_cocos2dx_Scheduler_update, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("unscheduleScriptEntry", js_cocos2dx_Scheduler_unscheduleScriptEntry, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("performFunctionInCocosThread", js_cocos2dx_Scheduler_performFunctionInCocosThread, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("unscheduleAll", js_cocos2dx_Scheduler_unscheduleAll, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTimeScale", js_cocos2dx_Scheduler_getTimeScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_Scheduler_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_Scheduler_class, + js_cocos2dx_Scheduler_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, "Scheduler", 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_Scheduler_class; + p->proto = jsb_cocos2d_Scheduler_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_FileUtils_class; +JSObject *jsb_cocos2d_FileUtils_prototype; + +bool js_cocos2dx_FileUtils_fullPathForFilename(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_fullPathForFilename : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_fullPathForFilename : Error processing arguments"); + std::string ret = cobj->fullPathForFilename(arg0); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_fullPathForFilename : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_getStringFromFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_getStringFromFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_getStringFromFile : Error processing arguments"); + std::string ret = cobj->getStringFromFile(arg0); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_getStringFromFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_removeFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_removeFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_removeFile : Error processing arguments"); + bool ret = cobj->removeFile(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_removeFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_isAbsolutePath(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_isAbsolutePath : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_isAbsolutePath : Error processing arguments"); + bool ret = cobj->isAbsolutePath(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_isAbsolutePath : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_renameFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_renameFile : Invalid Native Object"); + if (argc == 3) { + std::string arg0; + std::string arg1; + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_renameFile : Error processing arguments"); + bool ret = cobj->renameFile(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_renameFile : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile : Error processing arguments"); + cobj->loadFilenameLookupDictionaryFromFile(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_isPopupNotify(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_isPopupNotify : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isPopupNotify(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_isPopupNotify : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_FileUtils_getValueVectorFromFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_getValueVectorFromFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_getValueVectorFromFile : Error processing arguments"); + cocos2d::ValueVector ret = cobj->getValueVectorFromFile(arg0); + jsval jsret = JSVAL_NULL; + jsret = ccvaluevector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_getValueVectorFromFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_getSearchPaths(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_getSearchPaths : Invalid Native Object"); + if (argc == 0) { + const std::vector& ret = cobj->getSearchPaths(); + jsval jsret = JSVAL_NULL; + jsret = std_vector_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_getSearchPaths : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_FileUtils_writeToFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_writeToFile : Invalid Native Object"); + if (argc == 2) { + cocos2d::ValueMap arg0; + std::string arg1; + ok &= jsval_to_ccvaluemap(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_writeToFile : Error processing arguments"); + bool ret = cobj->writeToFile(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_writeToFile : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_FileUtils_getValueMapFromFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_getValueMapFromFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_getValueMapFromFile : Error processing arguments"); + cocos2d::ValueMap ret = cobj->getValueMapFromFile(arg0); + jsval jsret = JSVAL_NULL; + jsret = ccvaluemap_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_getValueMapFromFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_getValueMapFromData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_getValueMapFromData : Invalid Native Object"); + if (argc == 2) { + const char* arg0; + int arg1; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_getValueMapFromData : Error processing arguments"); + cocos2d::ValueMap ret = cobj->getValueMapFromData(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = ccvaluemap_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_getValueMapFromData : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_FileUtils_removeDirectory(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_removeDirectory : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_removeDirectory : Error processing arguments"); + bool ret = cobj->removeDirectory(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_removeDirectory : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_setSearchPaths(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + 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, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_setSearchPaths : Error processing arguments"); + cobj->setSearchPaths(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_setSearchPaths : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_getFileSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_getFileSize : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_getFileSize : Error processing arguments"); + long ret = cobj->getFileSize(arg0); + jsval jsret = JSVAL_NULL; + jsret = long_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_getFileSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_setSearchResolutionsOrder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_setSearchResolutionsOrder : Invalid Native Object"); + if (argc == 1) { + std::vector arg0; + ok &= jsval_to_std_vector_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_setSearchResolutionsOrder : Error processing arguments"); + cobj->setSearchResolutionsOrder(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_setSearchResolutionsOrder : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_addSearchResolutionsOrder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_addSearchResolutionsOrder : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_addSearchResolutionsOrder : Error processing arguments"); + cobj->addSearchResolutionsOrder(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + bool arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_addSearchResolutionsOrder : Error processing arguments"); + cobj->addSearchResolutionsOrder(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_addSearchResolutionsOrder : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_addSearchPath(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_addSearchPath : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_addSearchPath : Error processing arguments"); + cobj->addSearchPath(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + bool arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_addSearchPath : Error processing arguments"); + cobj->addSearchPath(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_addSearchPath : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_isFileExist(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_isFileExist : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_isFileExist : Error processing arguments"); + bool ret = cobj->isFileExist(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_isFileExist : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_purgeCachedEntries(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_purgeCachedEntries : Invalid Native Object"); + if (argc == 0) { + cobj->purgeCachedEntries(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_purgeCachedEntries : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_FileUtils_fullPathFromRelativeFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_fullPathFromRelativeFile : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_fullPathFromRelativeFile : Error processing arguments"); + std::string ret = cobj->fullPathFromRelativeFile(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_fullPathFromRelativeFile : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_FileUtils_getSuitableFOpen(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_getSuitableFOpen : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_getSuitableFOpen : Error processing arguments"); + std::string ret = cobj->getSuitableFOpen(arg0); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_getSuitableFOpen : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_setWritablePath(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_setWritablePath : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_setWritablePath : Error processing arguments"); + cobj->setWritablePath(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_setWritablePath : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_setPopupNotify(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_setPopupNotify : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_setPopupNotify : Error processing arguments"); + cobj->setPopupNotify(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_setPopupNotify : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_isDirectoryExist(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_isDirectoryExist : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_isDirectoryExist : Error processing arguments"); + bool ret = cobj->isDirectoryExist(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_isDirectoryExist : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_setDefaultResourceRootPath(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_setDefaultResourceRootPath : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_setDefaultResourceRootPath : Error processing arguments"); + cobj->setDefaultResourceRootPath(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_setDefaultResourceRootPath : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_getSearchResolutionsOrder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_getSearchResolutionsOrder : Invalid Native Object"); + if (argc == 0) { + const std::vector& ret = cobj->getSearchResolutionsOrder(); + jsval jsret = JSVAL_NULL; + jsret = std_vector_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_getSearchResolutionsOrder : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_FileUtils_createDirectory(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_createDirectory : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_createDirectory : Error processing arguments"); + bool ret = cobj->createDirectory(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_createDirectory : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FileUtils_getWritablePath(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_getWritablePath : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getWritablePath(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FileUtils_getWritablePath : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_FileUtils_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::FileUtils* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::FileUtils*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_setDelegate : Error processing arguments"); + cocos2d::FileUtils::setDelegate(arg0); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_FileUtils_setDelegate : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_FileUtils_getInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::FileUtils* ret = cocos2d::FileUtils::getInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::FileUtils*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_FileUtils_getInstance : wrong number of arguments"); + return false; +} + + + +void js_cocos2d_FileUtils_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (FileUtils)", obj); +} + +void js_register_cocos2dx_FileUtils(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_FileUtils_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_FileUtils_class->name = "FileUtils"; + jsb_cocos2d_FileUtils_class->addProperty = JS_PropertyStub; + jsb_cocos2d_FileUtils_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_FileUtils_class->getProperty = JS_PropertyStub; + jsb_cocos2d_FileUtils_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_FileUtils_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_FileUtils_class->resolve = JS_ResolveStub; + jsb_cocos2d_FileUtils_class->convert = JS_ConvertStub; + jsb_cocos2d_FileUtils_class->finalize = js_cocos2d_FileUtils_finalize; + jsb_cocos2d_FileUtils_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("fullPathForFilename", js_cocos2dx_FileUtils_fullPathForFilename, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStringFromFile", js_cocos2dx_FileUtils_getStringFromFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeFile", js_cocos2dx_FileUtils_removeFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isAbsolutePath", js_cocos2dx_FileUtils_isAbsolutePath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("renameFile", js_cocos2dx_FileUtils_renameFile, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadFilenameLookup", js_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isPopupNotify", js_cocos2dx_FileUtils_isPopupNotify, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getValueVectorFromFile", js_cocos2dx_FileUtils_getValueVectorFromFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSearchPaths", js_cocos2dx_FileUtils_getSearchPaths, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("writeToFile", js_cocos2dx_FileUtils_writeToFile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getValueMapFromFile", js_cocos2dx_FileUtils_getValueMapFromFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getValueMapFromData", js_cocos2dx_FileUtils_getValueMapFromData, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeDirectory", js_cocos2dx_FileUtils_removeDirectory, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSearchPaths", js_cocos2dx_FileUtils_setSearchPaths, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFileSize", js_cocos2dx_FileUtils_getFileSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSearchResolutionsOrder", js_cocos2dx_FileUtils_setSearchResolutionsOrder, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addSearchResolutionsOrder", js_cocos2dx_FileUtils_addSearchResolutionsOrder, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addSearchPath", js_cocos2dx_FileUtils_addSearchPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isFileExist", js_cocos2dx_FileUtils_isFileExist, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("purgeCachedEntries", js_cocos2dx_FileUtils_purgeCachedEntries, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("fullPathFromRelativeFile", js_cocos2dx_FileUtils_fullPathFromRelativeFile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSuitableFOpen", js_cocos2dx_FileUtils_getSuitableFOpen, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setWritablePath", js_cocos2dx_FileUtils_setWritablePath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPopupNotify", js_cocos2dx_FileUtils_setPopupNotify, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isDirectoryExist", js_cocos2dx_FileUtils_isDirectoryExist, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDefaultResourceRootPath", js_cocos2dx_FileUtils_setDefaultResourceRootPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSearchResolutionsOrder", js_cocos2dx_FileUtils_getSearchResolutionsOrder, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createDirectory", js_cocos2dx_FileUtils_createDirectory, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getWritablePath", js_cocos2dx_FileUtils_getWritablePath, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("setDelegate", js_cocos2dx_FileUtils_setDelegate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInstance", js_cocos2dx_FileUtils_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_FileUtils_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_FileUtils_class, + empty_constructor, 0, + 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, "FileUtils", 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_FileUtils_class; + p->proto = jsb_cocos2d_FileUtils_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_AsyncTaskPool_class; +JSObject *jsb_cocos2d_AsyncTaskPool_prototype; + +bool js_cocos2dx_AsyncTaskPool_stopTasks(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AsyncTaskPool* cobj = (cocos2d::AsyncTaskPool *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AsyncTaskPool_stopTasks : Invalid Native Object"); + if (argc == 1) { + cocos2d::AsyncTaskPool::TaskType arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AsyncTaskPool_stopTasks : Error processing arguments"); + cobj->stopTasks(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AsyncTaskPool_stopTasks : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_AsyncTaskPool_destoryInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::AsyncTaskPool::destoryInstance(); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_AsyncTaskPool_destoryInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_AsyncTaskPool_getInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::AsyncTaskPool* ret = cocos2d::AsyncTaskPool::getInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::AsyncTaskPool*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_AsyncTaskPool_getInstance : wrong number of arguments"); + return false; +} + + + +void js_cocos2d_AsyncTaskPool_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (AsyncTaskPool)", obj); +} + +void js_register_cocos2dx_AsyncTaskPool(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_AsyncTaskPool_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_AsyncTaskPool_class->name = "AsyncTaskPool"; + jsb_cocos2d_AsyncTaskPool_class->addProperty = JS_PropertyStub; + jsb_cocos2d_AsyncTaskPool_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_AsyncTaskPool_class->getProperty = JS_PropertyStub; + jsb_cocos2d_AsyncTaskPool_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_AsyncTaskPool_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_AsyncTaskPool_class->resolve = JS_ResolveStub; + jsb_cocos2d_AsyncTaskPool_class->convert = JS_ConvertStub; + jsb_cocos2d_AsyncTaskPool_class->finalize = js_cocos2d_AsyncTaskPool_finalize; + jsb_cocos2d_AsyncTaskPool_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("stopTasks", js_cocos2dx_AsyncTaskPool_stopTasks, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("destoryInstance", js_cocos2dx_AsyncTaskPool_destoryInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInstance", js_cocos2dx_AsyncTaskPool_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_AsyncTaskPool_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_AsyncTaskPool_class, + empty_constructor, 0, + 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, "AsyncTaskPool", 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_AsyncTaskPool_class; + p->proto = jsb_cocos2d_AsyncTaskPool_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EventListener_class; +JSObject *jsb_cocos2d_EventListener_prototype; + +bool js_cocos2dx_EventListener_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventListener* cobj = (cocos2d::EventListener *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventListener_setEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventListener_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventListener_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_EventListener_isEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventListener* cobj = (cocos2d::EventListener *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventListener_isEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventListener_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventListener_clone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventListener* cobj = (cocos2d::EventListener *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventListener_clone : Invalid Native Object"); + if (argc == 0) { + cocos2d::EventListener* ret = cobj->clone(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EventListener*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventListener_clone : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventListener_checkAvailable(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventListener* cobj = (cocos2d::EventListener *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventListener_checkAvailable : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->checkAvailable(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventListener_checkAvailable : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + + +void js_cocos2d_EventListener_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EventListener)", obj); +} + +void js_register_cocos2dx_EventListener(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EventListener_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EventListener_class->name = "EventListener"; + jsb_cocos2d_EventListener_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EventListener_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EventListener_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EventListener_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EventListener_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EventListener_class->resolve = JS_ResolveStub; + jsb_cocos2d_EventListener_class->convert = JS_ConvertStub; + jsb_cocos2d_EventListener_class->finalize = js_cocos2d_EventListener_finalize; + jsb_cocos2d_EventListener_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setEnabled", js_cocos2dx_EventListener_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isEnabled", js_cocos2dx_EventListener_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("clone", js_cocos2dx_EventListener_clone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("checkAvailable", js_cocos2dx_EventListener_checkAvailable, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_EventListener_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_EventListener_class, + empty_constructor, 0, + 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, "EventListener", 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_EventListener_class; + p->proto = jsb_cocos2d_EventListener_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EventDispatcher_class; +JSObject *jsb_cocos2d_EventDispatcher_prototype; + +bool js_cocos2dx_EventDispatcher_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventDispatcher* cobj = (cocos2d::EventDispatcher *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventDispatcher_setEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventDispatcher_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventDispatcher_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_EventDispatcher_removeAllEventListeners(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventDispatcher* cobj = (cocos2d::EventDispatcher *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventDispatcher_removeAllEventListeners : Invalid Native Object"); + if (argc == 0) { + cobj->removeAllEventListeners(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventDispatcher_removeAllEventListeners : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventDispatcher* cobj = (cocos2d::EventDispatcher *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority : Invalid Native Object"); + if (argc == 2) { + cocos2d::EventListener* arg0; + cocos2d::Node* arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::EventListener*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority : Error processing arguments"); + cobj->addEventListenerWithSceneGraphPriority(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_EventDispatcher_addCustomEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventDispatcher* cobj = (cocos2d::EventDispatcher *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventDispatcher_addCustomEventListener : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + std::function arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + do { + if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + auto lambda = [=](cocos2d::EventCustom* larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + JS::RootedValue rval(cx); + 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"); + cocos2d::EventListenerCustom* ret = cobj->addCustomEventListener(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EventListenerCustom*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventDispatcher_addCustomEventListener : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventDispatcher* cobj = (cocos2d::EventDispatcher *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority : Invalid Native Object"); + if (argc == 2) { + cocos2d::EventListener* arg0; + int arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::EventListener*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority : Error processing arguments"); + cobj->addEventListenerWithFixedPriority(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_EventDispatcher_removeEventListenersForTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::EventDispatcher* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::EventDispatcher *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventDispatcher_removeEventListenersForTarget : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cobj->removeEventListenersForTarget(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 2) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + bool arg1; + arg1 = JS::ToBoolean(args.get(1)); + cobj->removeEventListenersForTarget(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::EventListener::Type arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + cobj->removeEventListenersForType(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_EventDispatcher_removeEventListenersForTarget : wrong number of arguments"); + return false; +} +bool js_cocos2dx_EventDispatcher_resumeEventListenersForTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventDispatcher* cobj = (cocos2d::EventDispatcher *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventDispatcher_resumeEventListenersForTarget : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventDispatcher_resumeEventListenersForTarget : Error processing arguments"); + cobj->resumeEventListenersForTarget(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + cocos2d::Node* arg0; + bool arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventDispatcher_resumeEventListenersForTarget : Error processing arguments"); + cobj->resumeEventListenersForTarget(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventDispatcher_resumeEventListenersForTarget : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_EventDispatcher_setPriority(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventDispatcher* cobj = (cocos2d::EventDispatcher *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventDispatcher_setPriority : Invalid Native Object"); + if (argc == 2) { + cocos2d::EventListener* arg0; + int arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::EventListener*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventDispatcher_setPriority : Error processing arguments"); + cobj->setPriority(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventDispatcher_setPriority : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_EventDispatcher_dispatchEvent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventDispatcher* cobj = (cocos2d::EventDispatcher *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventDispatcher_dispatchEvent : Invalid Native Object"); + if (argc == 1) { + cocos2d::Event* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Event*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventDispatcher_dispatchEvent : Error processing arguments"); + cobj->dispatchEvent(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventDispatcher_dispatchEvent : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_EventDispatcher_pauseEventListenersForTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventDispatcher* cobj = (cocos2d::EventDispatcher *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventDispatcher_pauseEventListenersForTarget : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventDispatcher_pauseEventListenersForTarget : Error processing arguments"); + cobj->pauseEventListenersForTarget(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + cocos2d::Node* arg0; + bool arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventDispatcher_pauseEventListenersForTarget : Error processing arguments"); + cobj->pauseEventListenersForTarget(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventDispatcher_pauseEventListenersForTarget : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_EventDispatcher_removeCustomEventListeners(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventDispatcher* cobj = (cocos2d::EventDispatcher *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventDispatcher_removeCustomEventListeners : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventDispatcher_removeCustomEventListeners : Error processing arguments"); + cobj->removeCustomEventListeners(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventDispatcher_removeCustomEventListeners : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_EventDispatcher_removeEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventDispatcher* cobj = (cocos2d::EventDispatcher *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventDispatcher_removeEventListener : Invalid Native Object"); + if (argc == 1) { + cocos2d::EventListener* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::EventListener*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventDispatcher_removeEventListener : Error processing arguments"); + cobj->removeEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventDispatcher_removeEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_EventDispatcher_isEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventDispatcher* cobj = (cocos2d::EventDispatcher *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventDispatcher_isEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventDispatcher_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventDispatcher_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EventDispatcher* cobj = new (std::nothrow) cocos2d::EventDispatcher(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EventDispatcher"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_EventDispatcher_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EventDispatcher)", obj); +} + +void js_register_cocos2dx_EventDispatcher(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EventDispatcher_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EventDispatcher_class->name = "EventDispatcher"; + jsb_cocos2d_EventDispatcher_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EventDispatcher_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EventDispatcher_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EventDispatcher_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EventDispatcher_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EventDispatcher_class->resolve = JS_ResolveStub; + jsb_cocos2d_EventDispatcher_class->convert = JS_ConvertStub; + jsb_cocos2d_EventDispatcher_class->finalize = js_cocos2d_EventDispatcher_finalize; + jsb_cocos2d_EventDispatcher_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setEnabled", js_cocos2dx_EventDispatcher_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllListeners", js_cocos2dx_EventDispatcher_removeAllEventListeners, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addEventListenerWithSceneGraphPriority", js_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addCustomListener", js_cocos2dx_EventDispatcher_addCustomEventListener, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addEventListenerWithFixedPriority", js_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeListeners", js_cocos2dx_EventDispatcher_removeEventListenersForTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resumeTarget", js_cocos2dx_EventDispatcher_resumeEventListenersForTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPriority", js_cocos2dx_EventDispatcher_setPriority, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("dispatchEvent", js_cocos2dx_EventDispatcher_dispatchEvent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pauseTarget", js_cocos2dx_EventDispatcher_pauseEventListenersForTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeCustomListeners", js_cocos2dx_EventDispatcher_removeCustomEventListeners, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeListener", js_cocos2dx_EventDispatcher_removeEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isEnabled", js_cocos2dx_EventDispatcher_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_EventDispatcher_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_EventDispatcher_class, + js_cocos2dx_EventDispatcher_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, "EventDispatcher", 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_EventDispatcher_class; + p->proto = jsb_cocos2d_EventDispatcher_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EventListenerTouchOneByOne_class; +JSObject *jsb_cocos2d_EventListenerTouchOneByOne_prototype; + +bool js_cocos2dx_EventListenerTouchOneByOne_isSwallowTouches(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventListenerTouchOneByOne* cobj = (cocos2d::EventListenerTouchOneByOne *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventListenerTouchOneByOne_isSwallowTouches : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isSwallowTouches(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventListenerTouchOneByOne_isSwallowTouches : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventListenerTouchOneByOne_setSwallowTouches(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventListenerTouchOneByOne* cobj = (cocos2d::EventListenerTouchOneByOne *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventListenerTouchOneByOne_setSwallowTouches : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventListenerTouchOneByOne_setSwallowTouches : Error processing arguments"); + cobj->setSwallowTouches(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventListenerTouchOneByOne_setSwallowTouches : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_EventListenerTouchOneByOne_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventListenerTouchOneByOne* cobj = (cocos2d::EventListenerTouchOneByOne *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventListenerTouchOneByOne_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventListenerTouchOneByOne_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventListenerTouchOneByOne_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EventListenerTouchOneByOne* cobj = new (std::nothrow) cocos2d::EventListenerTouchOneByOne(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EventListenerTouchOneByOne"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_EventListener_prototype; + +void js_cocos2d_EventListenerTouchOneByOne_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EventListenerTouchOneByOne)", obj); +} + +void js_register_cocos2dx_EventListenerTouchOneByOne(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EventListenerTouchOneByOne_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EventListenerTouchOneByOne_class->name = "EventListenerTouchOneByOne"; + jsb_cocos2d_EventListenerTouchOneByOne_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EventListenerTouchOneByOne_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EventListenerTouchOneByOne_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EventListenerTouchOneByOne_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EventListenerTouchOneByOne_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EventListenerTouchOneByOne_class->resolve = JS_ResolveStub; + jsb_cocos2d_EventListenerTouchOneByOne_class->convert = JS_ConvertStub; + jsb_cocos2d_EventListenerTouchOneByOne_class->finalize = js_cocos2d_EventListenerTouchOneByOne_finalize; + jsb_cocos2d_EventListenerTouchOneByOne_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("isSwallowTouches", js_cocos2dx_EventListenerTouchOneByOne_isSwallowTouches, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSwallowTouches", js_cocos2dx_EventListenerTouchOneByOne_setSwallowTouches, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_EventListenerTouchOneByOne_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_EventListenerTouchOneByOne_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + jsb_cocos2d_EventListenerTouchOneByOne_class, + js_cocos2dx_EventListenerTouchOneByOne_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, "EventListenerTouchOneByOne", 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_EventListenerTouchOneByOne_class; + p->proto = jsb_cocos2d_EventListenerTouchOneByOne_prototype; + p->parentProto = jsb_cocos2d_EventListener_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EventListenerTouchAllAtOnce_class; +JSObject *jsb_cocos2d_EventListenerTouchAllAtOnce_prototype; + +bool js_cocos2dx_EventListenerTouchAllAtOnce_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventListenerTouchAllAtOnce* cobj = (cocos2d::EventListenerTouchAllAtOnce *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventListenerTouchAllAtOnce_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventListenerTouchAllAtOnce_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventListenerTouchAllAtOnce_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EventListenerTouchAllAtOnce* cobj = new (std::nothrow) cocos2d::EventListenerTouchAllAtOnce(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EventListenerTouchAllAtOnce"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_EventListener_prototype; + +void js_cocos2d_EventListenerTouchAllAtOnce_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EventListenerTouchAllAtOnce)", obj); +} + +void js_register_cocos2dx_EventListenerTouchAllAtOnce(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EventListenerTouchAllAtOnce_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EventListenerTouchAllAtOnce_class->name = "EventListenerTouchAllAtOnce"; + jsb_cocos2d_EventListenerTouchAllAtOnce_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EventListenerTouchAllAtOnce_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EventListenerTouchAllAtOnce_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EventListenerTouchAllAtOnce_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EventListenerTouchAllAtOnce_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EventListenerTouchAllAtOnce_class->resolve = JS_ResolveStub; + jsb_cocos2d_EventListenerTouchAllAtOnce_class->convert = JS_ConvertStub; + jsb_cocos2d_EventListenerTouchAllAtOnce_class->finalize = js_cocos2d_EventListenerTouchAllAtOnce_finalize; + jsb_cocos2d_EventListenerTouchAllAtOnce_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_EventListenerTouchAllAtOnce_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_EventListenerTouchAllAtOnce_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + jsb_cocos2d_EventListenerTouchAllAtOnce_class, + js_cocos2dx_EventListenerTouchAllAtOnce_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, "EventListenerTouchAllAtOnce", 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_EventListenerTouchAllAtOnce_class; + p->proto = jsb_cocos2d_EventListenerTouchAllAtOnce_prototype; + p->parentProto = jsb_cocos2d_EventListener_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EventListenerKeyboard_class; +JSObject *jsb_cocos2d_EventListenerKeyboard_prototype; + +bool js_cocos2dx_EventListenerKeyboard_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventListenerKeyboard* cobj = (cocos2d::EventListenerKeyboard *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventListenerKeyboard_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventListenerKeyboard_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventListenerKeyboard_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EventListenerKeyboard* cobj = new (std::nothrow) cocos2d::EventListenerKeyboard(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EventListenerKeyboard"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_EventListener_prototype; + +void js_cocos2d_EventListenerKeyboard_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EventListenerKeyboard)", obj); +} + +void js_register_cocos2dx_EventListenerKeyboard(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EventListenerKeyboard_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EventListenerKeyboard_class->name = "EventListenerKeyboard"; + jsb_cocos2d_EventListenerKeyboard_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EventListenerKeyboard_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EventListenerKeyboard_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EventListenerKeyboard_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EventListenerKeyboard_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EventListenerKeyboard_class->resolve = JS_ResolveStub; + jsb_cocos2d_EventListenerKeyboard_class->convert = JS_ConvertStub; + jsb_cocos2d_EventListenerKeyboard_class->finalize = js_cocos2d_EventListenerKeyboard_finalize; + jsb_cocos2d_EventListenerKeyboard_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_EventListenerKeyboard_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_EventListenerKeyboard_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + jsb_cocos2d_EventListenerKeyboard_class, + js_cocos2dx_EventListenerKeyboard_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, "EventListenerKeyboard", 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_EventListenerKeyboard_class; + p->proto = jsb_cocos2d_EventListenerKeyboard_prototype; + p->parentProto = jsb_cocos2d_EventListener_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EventMouse_class; +JSObject *jsb_cocos2d_EventMouse_prototype; + +bool js_cocos2dx_EventMouse_getMouseButton(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventMouse* cobj = (cocos2d::EventMouse *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventMouse_getMouseButton : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getMouseButton(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventMouse_getMouseButton : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventMouse_getLocation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventMouse* cobj = (cocos2d::EventMouse *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventMouse_getLocation : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getLocation(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventMouse_getLocation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventMouse_setMouseButton(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventMouse* cobj = (cocos2d::EventMouse *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventMouse_setMouseButton : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventMouse_setMouseButton : Error processing arguments"); + cobj->setMouseButton(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventMouse_setMouseButton : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_EventMouse_setScrollData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventMouse* cobj = (cocos2d::EventMouse *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventMouse_setScrollData : Invalid Native Object"); + if (argc == 2) { + double arg0; + double arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventMouse_setScrollData : Error processing arguments"); + cobj->setScrollData(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventMouse_setScrollData : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_EventMouse_getPreviousLocationInView(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventMouse* cobj = (cocos2d::EventMouse *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventMouse_getPreviousLocationInView : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getPreviousLocationInView(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventMouse_getPreviousLocationInView : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventMouse_getDelta(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventMouse* cobj = (cocos2d::EventMouse *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventMouse_getDelta : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getDelta(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventMouse_getDelta : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventMouse_getStartLocation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventMouse* cobj = (cocos2d::EventMouse *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventMouse_getStartLocation : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getStartLocation(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventMouse_getStartLocation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventMouse_getCursorY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventMouse* cobj = (cocos2d::EventMouse *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventMouse_getCursorY : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getCursorY(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventMouse_getCursorY : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventMouse_getCursorX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventMouse* cobj = (cocos2d::EventMouse *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventMouse_getCursorX : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getCursorX(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventMouse_getCursorX : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventMouse_getLocationInView(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventMouse* cobj = (cocos2d::EventMouse *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventMouse_getLocationInView : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getLocationInView(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventMouse_getLocationInView : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventMouse_getScrollY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventMouse* cobj = (cocos2d::EventMouse *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventMouse_getScrollY : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getScrollY(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventMouse_getScrollY : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventMouse_setCursorPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventMouse* cobj = (cocos2d::EventMouse *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventMouse_setCursorPosition : Invalid Native Object"); + if (argc == 2) { + double arg0; + double arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventMouse_setCursorPosition : Error processing arguments"); + cobj->setCursorPosition(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventMouse_setCursorPosition : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_EventMouse_getScrollX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventMouse* cobj = (cocos2d::EventMouse *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventMouse_getScrollX : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getScrollX(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventMouse_getScrollX : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventMouse_getPreviousLocation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventMouse* cobj = (cocos2d::EventMouse *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventMouse_getPreviousLocation : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getPreviousLocation(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventMouse_getPreviousLocation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventMouse_getStartLocationInView(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventMouse* cobj = (cocos2d::EventMouse *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventMouse_getStartLocationInView : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getStartLocationInView(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventMouse_getStartLocationInView : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventMouse_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EventMouse::MouseEventType arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventMouse_constructor : Error processing arguments"); + cocos2d::EventMouse* cobj = new (std::nothrow) cocos2d::EventMouse(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."); + // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EventMouse"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Event_prototype; + +void js_cocos2d_EventMouse_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EventMouse)", obj); +} + +void js_register_cocos2dx_EventMouse(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EventMouse_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EventMouse_class->name = "EventMouse"; + jsb_cocos2d_EventMouse_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EventMouse_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EventMouse_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EventMouse_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EventMouse_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EventMouse_class->resolve = JS_ResolveStub; + jsb_cocos2d_EventMouse_class->convert = JS_ConvertStub; + jsb_cocos2d_EventMouse_class->finalize = js_cocos2d_EventMouse_finalize; + jsb_cocos2d_EventMouse_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getButton", js_cocos2dx_EventMouse_getMouseButton, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLocation", js_cocos2dx_EventMouse_getLocation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setButton", js_cocos2dx_EventMouse_setMouseButton, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setScrollData", js_cocos2dx_EventMouse_setScrollData, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPreviousLocationInView", js_cocos2dx_EventMouse_getPreviousLocationInView, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDelta", js_cocos2dx_EventMouse_getDelta, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStartLocation", js_cocos2dx_EventMouse_getStartLocation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLocationY", js_cocos2dx_EventMouse_getCursorY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLocationX", js_cocos2dx_EventMouse_getCursorX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLocationInView", js_cocos2dx_EventMouse_getLocationInView, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getScrollY", js_cocos2dx_EventMouse_getScrollY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLocation", js_cocos2dx_EventMouse_setCursorPosition, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getScrollX", js_cocos2dx_EventMouse_getScrollX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPreviousLocation", js_cocos2dx_EventMouse_getPreviousLocation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStartLocationInView", js_cocos2dx_EventMouse_getStartLocationInView, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_EventMouse_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Event_prototype), + jsb_cocos2d_EventMouse_class, + js_cocos2dx_EventMouse_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, "EventMouse", 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_EventMouse_class; + p->proto = jsb_cocos2d_EventMouse_prototype; + p->parentProto = jsb_cocos2d_Event_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EventListenerMouse_class; +JSObject *jsb_cocos2d_EventListenerMouse_prototype; + +bool js_cocos2dx_EventListenerMouse_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventListenerMouse* cobj = (cocos2d::EventListenerMouse *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventListenerMouse_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventListenerMouse_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventListenerMouse_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EventListenerMouse* cobj = new (std::nothrow) cocos2d::EventListenerMouse(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EventListenerMouse"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_EventListener_prototype; + +void js_cocos2d_EventListenerMouse_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EventListenerMouse)", obj); +} + +void js_register_cocos2dx_EventListenerMouse(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EventListenerMouse_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EventListenerMouse_class->name = "EventListenerMouse"; + jsb_cocos2d_EventListenerMouse_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EventListenerMouse_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EventListenerMouse_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EventListenerMouse_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EventListenerMouse_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EventListenerMouse_class->resolve = JS_ResolveStub; + jsb_cocos2d_EventListenerMouse_class->convert = JS_ConvertStub; + jsb_cocos2d_EventListenerMouse_class->finalize = js_cocos2d_EventListenerMouse_finalize; + jsb_cocos2d_EventListenerMouse_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_EventListenerMouse_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_EventListenerMouse_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + jsb_cocos2d_EventListenerMouse_class, + js_cocos2dx_EventListenerMouse_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, "EventListenerMouse", 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_EventListenerMouse_class; + p->proto = jsb_cocos2d_EventListenerMouse_prototype; + p->parentProto = jsb_cocos2d_EventListener_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EventAcceleration_class; +JSObject *jsb_cocos2d_EventAcceleration_prototype; + +bool js_cocos2dx_EventAcceleration_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Acceleration arg0; + ok &= jsval_to_ccacceleration(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventAcceleration_constructor : Error processing arguments"); + cocos2d::EventAcceleration* cobj = new (std::nothrow) cocos2d::EventAcceleration(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."); + // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EventAcceleration"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Event_prototype; + +void js_cocos2d_EventAcceleration_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EventAcceleration)", obj); +} + +void js_register_cocos2dx_EventAcceleration(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EventAcceleration_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EventAcceleration_class->name = "EventAcceleration"; + jsb_cocos2d_EventAcceleration_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EventAcceleration_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EventAcceleration_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EventAcceleration_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EventAcceleration_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EventAcceleration_class->resolve = JS_ResolveStub; + jsb_cocos2d_EventAcceleration_class->convert = JS_ConvertStub; + jsb_cocos2d_EventAcceleration_class->finalize = js_cocos2d_EventAcceleration_finalize; + jsb_cocos2d_EventAcceleration_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_EventAcceleration_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Event_prototype), + jsb_cocos2d_EventAcceleration_class, + js_cocos2dx_EventAcceleration_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, "EventAcceleration", 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_EventAcceleration_class; + p->proto = jsb_cocos2d_EventAcceleration_prototype; + p->parentProto = jsb_cocos2d_Event_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EventListenerAcceleration_class; +JSObject *jsb_cocos2d_EventListenerAcceleration_prototype; + +bool js_cocos2dx_EventListenerAcceleration_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventListenerAcceleration* cobj = (cocos2d::EventListenerAcceleration *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventListenerAcceleration_init : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + auto lambda = [=](cocos2d::Acceleration* larg0, cocos2d::Event* larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + } else { + largv[1] = JSVAL_NULL; + } + } while (0); + JS::RootedValue rval(cx); + 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"); + bool ret = cobj->init(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventListenerAcceleration_init : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_EventListenerAcceleration_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + auto lambda = [=](cocos2d::Acceleration* larg0, cocos2d::Event* larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + } else { + largv[1] = JSVAL_NULL; + } + } while (0); + JS::RootedValue rval(cx); + 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"); + cocos2d::EventListenerAcceleration* ret = cocos2d::EventListenerAcceleration::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EventListenerAcceleration*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EventListenerAcceleration_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EventListenerAcceleration_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EventListenerAcceleration* cobj = new (std::nothrow) cocos2d::EventListenerAcceleration(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EventListenerAcceleration"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_EventListener_prototype; + +void js_cocos2d_EventListenerAcceleration_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EventListenerAcceleration)", obj); +} + +void js_register_cocos2dx_EventListenerAcceleration(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EventListenerAcceleration_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EventListenerAcceleration_class->name = "EventListenerAcceleration"; + jsb_cocos2d_EventListenerAcceleration_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EventListenerAcceleration_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EventListenerAcceleration_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EventListenerAcceleration_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EventListenerAcceleration_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EventListenerAcceleration_class->resolve = JS_ResolveStub; + jsb_cocos2d_EventListenerAcceleration_class->convert = JS_ConvertStub; + jsb_cocos2d_EventListenerAcceleration_class->finalize = js_cocos2d_EventListenerAcceleration_finalize; + jsb_cocos2d_EventListenerAcceleration_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_EventListenerAcceleration_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EventListenerAcceleration_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EventListenerAcceleration_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + jsb_cocos2d_EventListenerAcceleration_class, + js_cocos2dx_EventListenerAcceleration_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, "EventListenerAcceleration", 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_EventListenerAcceleration_class; + p->proto = jsb_cocos2d_EventListenerAcceleration_prototype; + p->parentProto = jsb_cocos2d_EventListener_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EventCustom_class; +JSObject *jsb_cocos2d_EventCustom_prototype; + +bool js_cocos2dx_EventCustom_getEventName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventCustom* cobj = (cocos2d::EventCustom *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventCustom_getEventName : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getEventName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventCustom_getEventName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventCustom_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventCustom_constructor : Error processing arguments"); + cocos2d::EventCustom* cobj = new (std::nothrow) cocos2d::EventCustom(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."); + // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EventCustom"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Event_prototype; + +void js_cocos2d_EventCustom_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EventCustom)", obj); +} + +void js_register_cocos2dx_EventCustom(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EventCustom_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EventCustom_class->name = "EventCustom"; + jsb_cocos2d_EventCustom_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EventCustom_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EventCustom_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EventCustom_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EventCustom_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EventCustom_class->resolve = JS_ResolveStub; + jsb_cocos2d_EventCustom_class->convert = JS_ConvertStub; + jsb_cocos2d_EventCustom_class->finalize = js_cocos2d_EventCustom_finalize; + jsb_cocos2d_EventCustom_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getEventName", js_cocos2dx_EventCustom_getEventName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_EventCustom_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Event_prototype), + jsb_cocos2d_EventCustom_class, + js_cocos2dx_EventCustom_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, "EventCustom", 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_EventCustom_class; + p->proto = jsb_cocos2d_EventCustom_prototype; + p->parentProto = jsb_cocos2d_Event_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EventListenerCustom_class; +JSObject *jsb_cocos2d_EventListenerCustom_prototype; + +bool js_cocos2dx_EventListenerCustom_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + std::string arg0; + std::function arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + do { + if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + auto lambda = [=](cocos2d::EventCustom* larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + JS::RootedValue rval(cx); + 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"); + cocos2d::EventListenerCustom* ret = cocos2d::EventListenerCustom::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EventListenerCustom*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EventListenerCustom_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EventListenerCustom_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EventListenerCustom* cobj = new (std::nothrow) cocos2d::EventListenerCustom(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EventListenerCustom"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_EventListener_prototype; + +void js_cocos2d_EventListenerCustom_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EventListenerCustom)", obj); +} + +void js_register_cocos2dx_EventListenerCustom(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EventListenerCustom_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EventListenerCustom_class->name = "EventListenerCustom"; + jsb_cocos2d_EventListenerCustom_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EventListenerCustom_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EventListenerCustom_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EventListenerCustom_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EventListenerCustom_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EventListenerCustom_class->resolve = JS_ResolveStub; + jsb_cocos2d_EventListenerCustom_class->convert = JS_ConvertStub; + jsb_cocos2d_EventListenerCustom_class->finalize = js_cocos2d_EventListenerCustom_finalize; + jsb_cocos2d_EventListenerCustom_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EventListenerCustom_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EventListenerCustom_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + jsb_cocos2d_EventListenerCustom_class, + js_cocos2dx_EventListenerCustom_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, "EventListenerCustom", 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_EventListenerCustom_class; + p->proto = jsb_cocos2d_EventListenerCustom_prototype; + p->parentProto = jsb_cocos2d_EventListener_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EventFocus_class; +JSObject *jsb_cocos2d_EventFocus_prototype; + +bool js_cocos2dx_EventFocus_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::Widget* arg0; + cocos2d::ui::Widget* arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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 (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + 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_EventFocus_constructor : Error processing arguments"); + cocos2d::EventFocus* cobj = new (std::nothrow) cocos2d::EventFocus(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."); + // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EventFocus"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Event_prototype; + +void js_cocos2d_EventFocus_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EventFocus)", obj); +} + +void js_register_cocos2dx_EventFocus(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EventFocus_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EventFocus_class->name = "EventFocus"; + jsb_cocos2d_EventFocus_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EventFocus_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EventFocus_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EventFocus_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EventFocus_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EventFocus_class->resolve = JS_ResolveStub; + jsb_cocos2d_EventFocus_class->convert = JS_ConvertStub; + jsb_cocos2d_EventFocus_class->finalize = js_cocos2d_EventFocus_finalize; + jsb_cocos2d_EventFocus_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_EventFocus_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Event_prototype), + jsb_cocos2d_EventFocus_class, + js_cocos2dx_EventFocus_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, "EventFocus", 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_EventFocus_class; + p->proto = jsb_cocos2d_EventFocus_prototype; + p->parentProto = jsb_cocos2d_Event_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EventListenerFocus_class; +JSObject *jsb_cocos2d_EventListenerFocus_prototype; + +bool js_cocos2dx_EventListenerFocus_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventListenerFocus* cobj = (cocos2d::EventListenerFocus *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventListenerFocus_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventListenerFocus_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EventListenerFocus_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EventListenerFocus* cobj = new (std::nothrow) cocos2d::EventListenerFocus(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EventListenerFocus"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_EventListener_prototype; + +void js_cocos2d_EventListenerFocus_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EventListenerFocus)", obj); +} + +void js_register_cocos2dx_EventListenerFocus(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EventListenerFocus_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EventListenerFocus_class->name = "EventListenerFocus"; + jsb_cocos2d_EventListenerFocus_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EventListenerFocus_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EventListenerFocus_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EventListenerFocus_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EventListenerFocus_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EventListenerFocus_class->resolve = JS_ResolveStub; + jsb_cocos2d_EventListenerFocus_class->convert = JS_ConvertStub; + jsb_cocos2d_EventListenerFocus_class->finalize = js_cocos2d_EventListenerFocus_finalize; + jsb_cocos2d_EventListenerFocus_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_EventListenerFocus_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_EventListenerFocus_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_EventListener_prototype), + jsb_cocos2d_EventListenerFocus_class, + js_cocos2dx_EventListenerFocus_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, "EventListenerFocus", 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_EventListenerFocus_class; + p->proto = jsb_cocos2d_EventListenerFocus_prototype; + p->parentProto = jsb_cocos2d_EventListener_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ActionCamera_class; +JSObject *jsb_cocos2d_ActionCamera_prototype; + +bool js_cocos2dx_ActionCamera_setEye(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ActionCamera* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ActionCamera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionCamera_setEye : Invalid Native Object"); + do { + if (argc == 3) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cobj->setEye(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::Vec3 arg0; + ok &= jsval_to_vector3(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->setEye(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ActionCamera_setEye : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ActionCamera_getEye(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionCamera* cobj = (cocos2d::ActionCamera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionCamera_getEye : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec3& ret = cobj->getEye(); + jsval jsret = JSVAL_NULL; + jsret = vector3_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionCamera_getEye : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ActionCamera_setUp(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionCamera* cobj = (cocos2d::ActionCamera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionCamera_setUp : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec3 arg0; + ok &= jsval_to_vector3(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ActionCamera_setUp : Error processing arguments"); + cobj->setUp(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionCamera_setUp : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ActionCamera_getCenter(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionCamera* cobj = (cocos2d::ActionCamera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionCamera_getCenter : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec3& ret = cobj->getCenter(); + jsval jsret = JSVAL_NULL; + jsret = vector3_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionCamera_getCenter : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ActionCamera_setCenter(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionCamera* cobj = (cocos2d::ActionCamera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionCamera_setCenter : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec3 arg0; + ok &= jsval_to_vector3(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ActionCamera_setCenter : Error processing arguments"); + cobj->setCenter(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionCamera_setCenter : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ActionCamera_getUp(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionCamera* cobj = (cocos2d::ActionCamera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionCamera_getUp : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec3& ret = cobj->getUp(); + jsval jsret = JSVAL_NULL; + jsret = vector3_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionCamera_getUp : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ActionCamera_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ActionCamera* cobj = new (std::nothrow) cocos2d::ActionCamera(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ActionCamera"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_ActionCamera_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ActionCamera)", obj); +} + +static bool js_cocos2d_ActionCamera_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ActionCamera *nobj = new (std::nothrow) cocos2d::ActionCamera(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ActionCamera"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ActionCamera(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ActionCamera_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ActionCamera_class->name = "ActionCamera"; + jsb_cocos2d_ActionCamera_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ActionCamera_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ActionCamera_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ActionCamera_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ActionCamera_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ActionCamera_class->resolve = JS_ResolveStub; + jsb_cocos2d_ActionCamera_class->convert = JS_ConvertStub; + jsb_cocos2d_ActionCamera_class->finalize = js_cocos2d_ActionCamera_finalize; + jsb_cocos2d_ActionCamera_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setEye", js_cocos2dx_ActionCamera_setEye, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEye", js_cocos2dx_ActionCamera_getEye, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUp", js_cocos2dx_ActionCamera_setUp, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCenter", js_cocos2dx_ActionCamera_getCenter, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCenter", js_cocos2dx_ActionCamera_setCenter, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getUp", js_cocos2dx_ActionCamera_getUp, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ActionCamera_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_ActionCamera_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_ActionCamera_class, + js_cocos2dx_ActionCamera_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, "ActionCamera", 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_ActionCamera_class; + p->proto = jsb_cocos2d_ActionCamera_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_OrbitCamera_class; +JSObject *jsb_cocos2d_OrbitCamera_prototype; + +bool js_cocos2dx_OrbitCamera_sphericalRadius(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::OrbitCamera* cobj = (cocos2d::OrbitCamera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_OrbitCamera_sphericalRadius : Invalid Native Object"); + if (argc == 3) { + float* arg0; + float* arg1; + float* arg2; + #pragma warning NO CONVERSION TO NATIVE FOR float* + ok = false; + #pragma warning NO CONVERSION TO NATIVE FOR float* + ok = false; + #pragma warning NO CONVERSION TO NATIVE FOR float* + ok = false; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_OrbitCamera_sphericalRadius : Error processing arguments"); + cobj->sphericalRadius(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_OrbitCamera_sphericalRadius : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_OrbitCamera_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::OrbitCamera* cobj = (cocos2d::OrbitCamera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_OrbitCamera_initWithDuration : Invalid Native Object"); + if (argc == 7) { + double arg0; + double arg1; + double arg2; + double arg3; + double arg4; + double arg5; + double arg6; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + ok &= JS::ToNumber( cx, args.get(4), &arg4) && !isnan(arg4); + ok &= JS::ToNumber( cx, args.get(5), &arg5) && !isnan(arg5); + ok &= JS::ToNumber( cx, args.get(6), &arg6) && !isnan(arg6); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_OrbitCamera_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_OrbitCamera_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 7); + return false; +} +bool js_cocos2dx_OrbitCamera_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 7) { + double arg0; + double arg1; + double arg2; + double arg3; + double arg4; + double arg5; + double arg6; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + ok &= JS::ToNumber( cx, args.get(4), &arg4) && !isnan(arg4); + ok &= JS::ToNumber( cx, args.get(5), &arg5) && !isnan(arg5); + ok &= JS::ToNumber( cx, args.get(6), &arg6) && !isnan(arg6); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_OrbitCamera_create : Error processing arguments"); + cocos2d::OrbitCamera* ret = cocos2d::OrbitCamera::create(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::OrbitCamera*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_OrbitCamera_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_OrbitCamera_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::OrbitCamera* cobj = new (std::nothrow) cocos2d::OrbitCamera(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::OrbitCamera"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionCamera_prototype; + +void js_cocos2d_OrbitCamera_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (OrbitCamera)", obj); +} + +void js_register_cocos2dx_OrbitCamera(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_OrbitCamera_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_OrbitCamera_class->name = "OrbitCamera"; + jsb_cocos2d_OrbitCamera_class->addProperty = JS_PropertyStub; + jsb_cocos2d_OrbitCamera_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_OrbitCamera_class->getProperty = JS_PropertyStub; + jsb_cocos2d_OrbitCamera_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_OrbitCamera_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_OrbitCamera_class->resolve = JS_ResolveStub; + jsb_cocos2d_OrbitCamera_class->convert = JS_ConvertStub; + jsb_cocos2d_OrbitCamera_class->finalize = js_cocos2d_OrbitCamera_finalize; + jsb_cocos2d_OrbitCamera_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("sphericalRadius", js_cocos2dx_OrbitCamera_sphericalRadius, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithDuration", js_cocos2dx_OrbitCamera_initWithDuration, 7, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_OrbitCamera_create, 7, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_OrbitCamera_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionCamera_prototype), + jsb_cocos2d_OrbitCamera_class, + js_cocos2dx_OrbitCamera_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, "OrbitCamera", 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_OrbitCamera_class; + p->proto = jsb_cocos2d_OrbitCamera_prototype; + p->parentProto = jsb_cocos2d_ActionCamera_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ActionManager_class; +JSObject *jsb_cocos2d_ActionManager_prototype; + +bool js_cocos2dx_ActionManager_getActionByTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionManager_getActionByTag : Invalid Native Object"); + if (argc == 2) { + int arg0; + const cocos2d::Node* arg1; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (const cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ActionManager_getActionByTag : Error processing arguments"); + cocos2d::Action* ret = cobj->getActionByTag(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Action*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionManager_getActionByTag : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ActionManager_removeActionByTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionManager_removeActionByTag : Invalid Native Object"); + if (argc == 2) { + int arg0; + cocos2d::Node* arg1; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ActionManager_removeActionByTag : Error processing arguments"); + cobj->removeActionByTag(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionManager_removeActionByTag : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ActionManager_removeAllActions(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionManager_removeAllActions : Invalid Native Object"); + if (argc == 0) { + cobj->removeAllActions(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionManager_removeAllActions : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ActionManager_addAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionManager_addAction : Invalid Native Object"); + if (argc == 3) { + cocos2d::Action* arg0; + cocos2d::Node* arg1; + bool arg2; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Action*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + arg2 = JS::ToBoolean(args.get(2)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ActionManager_addAction : Error processing arguments"); + cobj->addAction(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionManager_addAction : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_ActionManager_resumeTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionManager_resumeTarget : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ActionManager_resumeTarget : Error processing arguments"); + cobj->resumeTarget(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionManager_resumeTarget : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ActionManager_update(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionManager_update : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ActionManager_update : Error processing arguments"); + cobj->update(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionManager_update : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ActionManager_pauseTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionManager_pauseTarget : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ActionManager_pauseTarget : Error processing arguments"); + cobj->pauseTarget(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionManager_pauseTarget : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ActionManager_getNumberOfRunningActionsInTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionManager_getNumberOfRunningActionsInTarget : Invalid Native Object"); + if (argc == 1) { + const cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (const cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ActionManager_getNumberOfRunningActionsInTarget : Error processing arguments"); + ssize_t ret = cobj->getNumberOfRunningActionsInTarget(arg0); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionManager_getNumberOfRunningActionsInTarget : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ActionManager_removeAllActionsFromTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionManager_removeAllActionsFromTarget : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ActionManager_removeAllActionsFromTarget : Error processing arguments"); + cobj->removeAllActionsFromTarget(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionManager_removeAllActionsFromTarget : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ActionManager_resumeTargets(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionManager_resumeTargets : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vector arg0; + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ActionManager_resumeTargets : Error processing arguments"); + cobj->resumeTargets(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionManager_resumeTargets : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ActionManager_removeAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionManager_removeAction : Invalid Native Object"); + if (argc == 1) { + cocos2d::Action* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Action*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ActionManager_removeAction : Error processing arguments"); + cobj->removeAction(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionManager_removeAction : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ActionManager_removeAllActionsByTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionManager_removeAllActionsByTag : Invalid Native Object"); + if (argc == 2) { + int arg0; + cocos2d::Node* arg1; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ActionManager_removeAllActionsByTag : Error processing arguments"); + cobj->removeAllActionsByTag(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionManager_removeAllActionsByTag : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ActionManager_pauseAllRunningActions(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionManager* cobj = (cocos2d::ActionManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionManager_pauseAllRunningActions : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vector ret = cobj->pauseAllRunningActions(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionManager_pauseAllRunningActions : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ActionManager_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ActionManager* cobj = new (std::nothrow) cocos2d::ActionManager(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ActionManager"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_ActionManager_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ActionManager)", obj); +} + +static bool js_cocos2d_ActionManager_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ActionManager *nobj = new (std::nothrow) cocos2d::ActionManager(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ActionManager"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ActionManager(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ActionManager_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ActionManager_class->name = "ActionManager"; + jsb_cocos2d_ActionManager_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ActionManager_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ActionManager_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ActionManager_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ActionManager_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ActionManager_class->resolve = JS_ResolveStub; + jsb_cocos2d_ActionManager_class->convert = JS_ConvertStub; + jsb_cocos2d_ActionManager_class->finalize = js_cocos2d_ActionManager_finalize; + jsb_cocos2d_ActionManager_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getActionByTag", js_cocos2dx_ActionManager_getActionByTag, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeActionByTag", js_cocos2dx_ActionManager_removeActionByTag, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllActions", js_cocos2dx_ActionManager_removeAllActions, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addAction", js_cocos2dx_ActionManager_addAction, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resumeTarget", js_cocos2dx_ActionManager_resumeTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("update", js_cocos2dx_ActionManager_update, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pauseTarget", js_cocos2dx_ActionManager_pauseTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNumberOfRunningActionsInTarget", js_cocos2dx_ActionManager_getNumberOfRunningActionsInTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllActionsFromTarget", js_cocos2dx_ActionManager_removeAllActionsFromTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resumeTargets", js_cocos2dx_ActionManager_resumeTargets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAction", js_cocos2dx_ActionManager_removeAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllActionsByTag", js_cocos2dx_ActionManager_removeAllActionsByTag, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pauseAllRunningActions", js_cocos2dx_ActionManager_pauseAllRunningActions, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ActionManager_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_ActionManager_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_ActionManager_class, + js_cocos2dx_ActionManager_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, "ActionManager", 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_ActionManager_class; + p->proto = jsb_cocos2d_ActionManager_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ActionEase_class; +JSObject *jsb_cocos2d_ActionEase_prototype; + +bool js_cocos2dx_ActionEase_initWithAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionEase* cobj = (cocos2d::ActionEase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionEase_initWithAction : Invalid Native Object"); + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ActionEase_initWithAction : Error processing arguments"); + bool ret = cobj->initWithAction(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionEase_initWithAction : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ActionEase_getInnerAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionEase* cobj = (cocos2d::ActionEase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionEase_getInnerAction : Invalid Native Object"); + if (argc == 0) { + cocos2d::ActionInterval* ret = cobj->getInnerAction(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionEase_getInnerAction : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_ActionEase_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ActionEase)", obj); +} + +void js_register_cocos2dx_ActionEase(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ActionEase_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ActionEase_class->name = "ActionEase"; + jsb_cocos2d_ActionEase_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ActionEase_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ActionEase_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ActionEase_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ActionEase_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ActionEase_class->resolve = JS_ResolveStub; + jsb_cocos2d_ActionEase_class->convert = JS_ConvertStub; + jsb_cocos2d_ActionEase_class->finalize = js_cocos2d_ActionEase_finalize; + jsb_cocos2d_ActionEase_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithAction", js_cocos2dx_ActionEase_initWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInnerAction", js_cocos2dx_ActionEase_getInnerAction, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_ActionEase_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_ActionEase_class, + empty_constructor, 0, + 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, "ActionEase", 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_ActionEase_class; + p->proto = jsb_cocos2d_ActionEase_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseRateAction_class; +JSObject *jsb_cocos2d_EaseRateAction_prototype; + +bool js_cocos2dx_EaseRateAction_setRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EaseRateAction* cobj = (cocos2d::EaseRateAction *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EaseRateAction_setRate : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseRateAction_setRate : Error processing arguments"); + cobj->setRate(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EaseRateAction_setRate : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_EaseRateAction_initWithAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EaseRateAction* cobj = (cocos2d::EaseRateAction *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EaseRateAction_initWithAction : Invalid Native Object"); + if (argc == 2) { + cocos2d::ActionInterval* arg0; + double arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseRateAction_initWithAction : Error processing arguments"); + bool ret = cobj->initWithAction(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EaseRateAction_initWithAction : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_EaseRateAction_getRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EaseRateAction* cobj = (cocos2d::EaseRateAction *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EaseRateAction_getRate : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getRate(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EaseRateAction_getRate : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_EaseRateAction_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::ActionInterval* arg0; + double arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseRateAction_create : Error processing arguments"); + cocos2d::EaseRateAction* ret = cocos2d::EaseRateAction::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseRateAction*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseRateAction_create : wrong number of arguments"); + return false; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseRateAction_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseRateAction)", obj); +} + +void js_register_cocos2dx_EaseRateAction(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseRateAction_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseRateAction_class->name = "EaseRateAction"; + jsb_cocos2d_EaseRateAction_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseRateAction_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseRateAction_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseRateAction_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseRateAction_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseRateAction_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseRateAction_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseRateAction_class->finalize = js_cocos2d_EaseRateAction_finalize; + jsb_cocos2d_EaseRateAction_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setRate", js_cocos2dx_EaseRateAction_setRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithAction", js_cocos2dx_EaseRateAction_initWithAction, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRate", js_cocos2dx_EaseRateAction_getRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseRateAction_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseRateAction_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseRateAction_class, + empty_constructor, 0, + 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, "EaseRateAction", 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_EaseRateAction_class; + p->proto = jsb_cocos2d_EaseRateAction_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseIn_class; +JSObject *jsb_cocos2d_EaseIn_prototype; + +bool js_cocos2dx_EaseIn_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::ActionInterval* arg0; + double arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseIn_create : Error processing arguments"); + cocos2d::EaseIn* ret = cocos2d::EaseIn::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseIn*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseIn_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseIn* cobj = new (std::nothrow) cocos2d::EaseIn(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseIn"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_EaseRateAction_prototype; + +void js_cocos2d_EaseIn_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseIn)", obj); +} + +void js_register_cocos2dx_EaseIn(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseIn_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseIn_class->name = "EaseIn"; + jsb_cocos2d_EaseIn_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseIn_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseIn_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseIn_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseIn_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseIn_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseIn_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseIn_class->finalize = js_cocos2d_EaseIn_finalize; + jsb_cocos2d_EaseIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseIn_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseIn_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_EaseRateAction_prototype), + jsb_cocos2d_EaseIn_class, + js_cocos2dx_EaseIn_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, "EaseIn", 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_EaseIn_class; + p->proto = jsb_cocos2d_EaseIn_prototype; + p->parentProto = jsb_cocos2d_EaseRateAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseOut_class; +JSObject *jsb_cocos2d_EaseOut_prototype; + +bool js_cocos2dx_EaseOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::ActionInterval* arg0; + double arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseOut_create : Error processing arguments"); + cocos2d::EaseOut* ret = cocos2d::EaseOut::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseOut* cobj = new (std::nothrow) cocos2d::EaseOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_EaseRateAction_prototype; + +void js_cocos2d_EaseOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseOut)", obj); +} + +void js_register_cocos2dx_EaseOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseOut_class->name = "EaseOut"; + jsb_cocos2d_EaseOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseOut_class->finalize = js_cocos2d_EaseOut_finalize; + jsb_cocos2d_EaseOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseOut_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_EaseRateAction_prototype), + jsb_cocos2d_EaseOut_class, + js_cocos2dx_EaseOut_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, "EaseOut", 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_EaseOut_class; + p->proto = jsb_cocos2d_EaseOut_prototype; + p->parentProto = jsb_cocos2d_EaseRateAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseInOut_class; +JSObject *jsb_cocos2d_EaseInOut_prototype; + +bool js_cocos2dx_EaseInOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::ActionInterval* arg0; + double arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseInOut_create : Error processing arguments"); + cocos2d::EaseInOut* ret = cocos2d::EaseInOut::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseInOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseInOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseInOut* cobj = new (std::nothrow) cocos2d::EaseInOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseInOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_EaseRateAction_prototype; + +void js_cocos2d_EaseInOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseInOut)", obj); +} + +void js_register_cocos2dx_EaseInOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseInOut_class->name = "EaseInOut"; + jsb_cocos2d_EaseInOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseInOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseInOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseInOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseInOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseInOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseInOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseInOut_class->finalize = js_cocos2d_EaseInOut_finalize; + jsb_cocos2d_EaseInOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseInOut_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseInOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_EaseRateAction_prototype), + jsb_cocos2d_EaseInOut_class, + js_cocos2dx_EaseInOut_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, "EaseInOut", 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_EaseInOut_class; + p->proto = jsb_cocos2d_EaseInOut_prototype; + p->parentProto = jsb_cocos2d_EaseRateAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseExponentialIn_class; +JSObject *jsb_cocos2d_EaseExponentialIn_prototype; + +bool js_cocos2dx_EaseExponentialIn_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseExponentialIn_create : Error processing arguments"); + cocos2d::EaseExponentialIn* ret = cocos2d::EaseExponentialIn::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseExponentialIn*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseExponentialIn_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseExponentialIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseExponentialIn* cobj = new (std::nothrow) cocos2d::EaseExponentialIn(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseExponentialIn"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseExponentialIn_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseExponentialIn)", obj); +} + +void js_register_cocos2dx_EaseExponentialIn(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseExponentialIn_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseExponentialIn_class->name = "EaseExponentialIn"; + jsb_cocos2d_EaseExponentialIn_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseExponentialIn_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseExponentialIn_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseExponentialIn_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseExponentialIn_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseExponentialIn_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseExponentialIn_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseExponentialIn_class->finalize = js_cocos2d_EaseExponentialIn_finalize; + jsb_cocos2d_EaseExponentialIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseExponentialIn_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseExponentialIn_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseExponentialIn_class, + js_cocos2dx_EaseExponentialIn_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, "EaseExponentialIn", 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_EaseExponentialIn_class; + p->proto = jsb_cocos2d_EaseExponentialIn_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseExponentialOut_class; +JSObject *jsb_cocos2d_EaseExponentialOut_prototype; + +bool js_cocos2dx_EaseExponentialOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseExponentialOut_create : Error processing arguments"); + cocos2d::EaseExponentialOut* ret = cocos2d::EaseExponentialOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseExponentialOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseExponentialOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseExponentialOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseExponentialOut* cobj = new (std::nothrow) cocos2d::EaseExponentialOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseExponentialOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseExponentialOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseExponentialOut)", obj); +} + +void js_register_cocos2dx_EaseExponentialOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseExponentialOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseExponentialOut_class->name = "EaseExponentialOut"; + jsb_cocos2d_EaseExponentialOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseExponentialOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseExponentialOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseExponentialOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseExponentialOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseExponentialOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseExponentialOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseExponentialOut_class->finalize = js_cocos2d_EaseExponentialOut_finalize; + jsb_cocos2d_EaseExponentialOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseExponentialOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseExponentialOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseExponentialOut_class, + js_cocos2dx_EaseExponentialOut_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, "EaseExponentialOut", 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_EaseExponentialOut_class; + p->proto = jsb_cocos2d_EaseExponentialOut_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseExponentialInOut_class; +JSObject *jsb_cocos2d_EaseExponentialInOut_prototype; + +bool js_cocos2dx_EaseExponentialInOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseExponentialInOut_create : Error processing arguments"); + cocos2d::EaseExponentialInOut* ret = cocos2d::EaseExponentialInOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseExponentialInOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseExponentialInOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseExponentialInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseExponentialInOut* cobj = new (std::nothrow) cocos2d::EaseExponentialInOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseExponentialInOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseExponentialInOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseExponentialInOut)", obj); +} + +void js_register_cocos2dx_EaseExponentialInOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseExponentialInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseExponentialInOut_class->name = "EaseExponentialInOut"; + jsb_cocos2d_EaseExponentialInOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseExponentialInOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseExponentialInOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseExponentialInOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseExponentialInOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseExponentialInOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseExponentialInOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseExponentialInOut_class->finalize = js_cocos2d_EaseExponentialInOut_finalize; + jsb_cocos2d_EaseExponentialInOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseExponentialInOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseExponentialInOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseExponentialInOut_class, + js_cocos2dx_EaseExponentialInOut_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, "EaseExponentialInOut", 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_EaseExponentialInOut_class; + p->proto = jsb_cocos2d_EaseExponentialInOut_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseSineIn_class; +JSObject *jsb_cocos2d_EaseSineIn_prototype; + +bool js_cocos2dx_EaseSineIn_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseSineIn_create : Error processing arguments"); + cocos2d::EaseSineIn* ret = cocos2d::EaseSineIn::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseSineIn*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseSineIn_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseSineIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseSineIn* cobj = new (std::nothrow) cocos2d::EaseSineIn(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseSineIn"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseSineIn_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseSineIn)", obj); +} + +void js_register_cocos2dx_EaseSineIn(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseSineIn_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseSineIn_class->name = "EaseSineIn"; + jsb_cocos2d_EaseSineIn_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseSineIn_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseSineIn_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseSineIn_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseSineIn_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseSineIn_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseSineIn_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseSineIn_class->finalize = js_cocos2d_EaseSineIn_finalize; + jsb_cocos2d_EaseSineIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseSineIn_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseSineIn_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseSineIn_class, + js_cocos2dx_EaseSineIn_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, "EaseSineIn", 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_EaseSineIn_class; + p->proto = jsb_cocos2d_EaseSineIn_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseSineOut_class; +JSObject *jsb_cocos2d_EaseSineOut_prototype; + +bool js_cocos2dx_EaseSineOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseSineOut_create : Error processing arguments"); + cocos2d::EaseSineOut* ret = cocos2d::EaseSineOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseSineOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseSineOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseSineOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseSineOut* cobj = new (std::nothrow) cocos2d::EaseSineOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseSineOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseSineOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseSineOut)", obj); +} + +void js_register_cocos2dx_EaseSineOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseSineOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseSineOut_class->name = "EaseSineOut"; + jsb_cocos2d_EaseSineOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseSineOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseSineOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseSineOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseSineOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseSineOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseSineOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseSineOut_class->finalize = js_cocos2d_EaseSineOut_finalize; + jsb_cocos2d_EaseSineOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseSineOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseSineOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseSineOut_class, + js_cocos2dx_EaseSineOut_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, "EaseSineOut", 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_EaseSineOut_class; + p->proto = jsb_cocos2d_EaseSineOut_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseSineInOut_class; +JSObject *jsb_cocos2d_EaseSineInOut_prototype; + +bool js_cocos2dx_EaseSineInOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseSineInOut_create : Error processing arguments"); + cocos2d::EaseSineInOut* ret = cocos2d::EaseSineInOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseSineInOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseSineInOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseSineInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseSineInOut* cobj = new (std::nothrow) cocos2d::EaseSineInOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseSineInOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseSineInOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseSineInOut)", obj); +} + +void js_register_cocos2dx_EaseSineInOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseSineInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseSineInOut_class->name = "EaseSineInOut"; + jsb_cocos2d_EaseSineInOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseSineInOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseSineInOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseSineInOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseSineInOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseSineInOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseSineInOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseSineInOut_class->finalize = js_cocos2d_EaseSineInOut_finalize; + jsb_cocos2d_EaseSineInOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseSineInOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseSineInOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseSineInOut_class, + js_cocos2dx_EaseSineInOut_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, "EaseSineInOut", 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_EaseSineInOut_class; + p->proto = jsb_cocos2d_EaseSineInOut_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseElastic_class; +JSObject *jsb_cocos2d_EaseElastic_prototype; + +bool js_cocos2dx_EaseElastic_setPeriod(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EaseElastic* cobj = (cocos2d::EaseElastic *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EaseElastic_setPeriod : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseElastic_setPeriod : Error processing arguments"); + cobj->setPeriod(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EaseElastic_setPeriod : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_EaseElastic_initWithAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EaseElastic* cobj = (cocos2d::EaseElastic *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EaseElastic_initWithAction : Invalid Native Object"); + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseElastic_initWithAction : Error processing arguments"); + bool ret = cobj->initWithAction(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + cocos2d::ActionInterval* arg0; + double arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseElastic_initWithAction : Error processing arguments"); + bool ret = cobj->initWithAction(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EaseElastic_initWithAction : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_EaseElastic_getPeriod(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EaseElastic* cobj = (cocos2d::EaseElastic *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EaseElastic_getPeriod : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getPeriod(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EaseElastic_getPeriod : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseElastic_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseElastic)", obj); +} + +void js_register_cocos2dx_EaseElastic(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseElastic_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseElastic_class->name = "EaseElastic"; + jsb_cocos2d_EaseElastic_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseElastic_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseElastic_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseElastic_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseElastic_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseElastic_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseElastic_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseElastic_class->finalize = js_cocos2d_EaseElastic_finalize; + jsb_cocos2d_EaseElastic_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setPeriod", js_cocos2dx_EaseElastic_setPeriod, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithAction", js_cocos2dx_EaseElastic_initWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPeriod", js_cocos2dx_EaseElastic_getPeriod, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_EaseElastic_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseElastic_class, + empty_constructor, 0, + 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, "EaseElastic", 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_EaseElastic_class; + p->proto = jsb_cocos2d_EaseElastic_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseElasticIn_class; +JSObject *jsb_cocos2d_EaseElasticIn_prototype; + +bool js_cocos2dx_EaseElasticIn_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::EaseElasticIn* ret = cocos2d::EaseElasticIn::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseElasticIn*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + cocos2d::EaseElasticIn* ret = cocos2d::EaseElasticIn::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseElasticIn*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_EaseElasticIn_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_EaseElasticIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseElasticIn* cobj = new (std::nothrow) cocos2d::EaseElasticIn(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseElasticIn"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_EaseElastic_prototype; + +void js_cocos2d_EaseElasticIn_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseElasticIn)", obj); +} + +void js_register_cocos2dx_EaseElasticIn(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseElasticIn_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseElasticIn_class->name = "EaseElasticIn"; + jsb_cocos2d_EaseElasticIn_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseElasticIn_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseElasticIn_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseElasticIn_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseElasticIn_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseElasticIn_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseElasticIn_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseElasticIn_class->finalize = js_cocos2d_EaseElasticIn_finalize; + jsb_cocos2d_EaseElasticIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseElasticIn_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseElasticIn_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_EaseElastic_prototype), + jsb_cocos2d_EaseElasticIn_class, + js_cocos2dx_EaseElasticIn_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, "EaseElasticIn", 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_EaseElasticIn_class; + p->proto = jsb_cocos2d_EaseElasticIn_prototype; + p->parentProto = jsb_cocos2d_EaseElastic_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseElasticOut_class; +JSObject *jsb_cocos2d_EaseElasticOut_prototype; + +bool js_cocos2dx_EaseElasticOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::EaseElasticOut* ret = cocos2d::EaseElasticOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseElasticOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + cocos2d::EaseElasticOut* ret = cocos2d::EaseElasticOut::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseElasticOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_EaseElasticOut_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_EaseElasticOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseElasticOut* cobj = new (std::nothrow) cocos2d::EaseElasticOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseElasticOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_EaseElastic_prototype; + +void js_cocos2d_EaseElasticOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseElasticOut)", obj); +} + +void js_register_cocos2dx_EaseElasticOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseElasticOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseElasticOut_class->name = "EaseElasticOut"; + jsb_cocos2d_EaseElasticOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseElasticOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseElasticOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseElasticOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseElasticOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseElasticOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseElasticOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseElasticOut_class->finalize = js_cocos2d_EaseElasticOut_finalize; + jsb_cocos2d_EaseElasticOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseElasticOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseElasticOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_EaseElastic_prototype), + jsb_cocos2d_EaseElasticOut_class, + js_cocos2dx_EaseElasticOut_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, "EaseElasticOut", 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_EaseElasticOut_class; + p->proto = jsb_cocos2d_EaseElasticOut_prototype; + p->parentProto = jsb_cocos2d_EaseElastic_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseElasticInOut_class; +JSObject *jsb_cocos2d_EaseElasticInOut_prototype; + +bool js_cocos2dx_EaseElasticInOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::EaseElasticInOut* ret = cocos2d::EaseElasticInOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseElasticInOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + cocos2d::EaseElasticInOut* ret = cocos2d::EaseElasticInOut::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseElasticInOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_EaseElasticInOut_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_EaseElasticInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseElasticInOut* cobj = new (std::nothrow) cocos2d::EaseElasticInOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseElasticInOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_EaseElastic_prototype; + +void js_cocos2d_EaseElasticInOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseElasticInOut)", obj); +} + +void js_register_cocos2dx_EaseElasticInOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseElasticInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseElasticInOut_class->name = "EaseElasticInOut"; + jsb_cocos2d_EaseElasticInOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseElasticInOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseElasticInOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseElasticInOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseElasticInOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseElasticInOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseElasticInOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseElasticInOut_class->finalize = js_cocos2d_EaseElasticInOut_finalize; + jsb_cocos2d_EaseElasticInOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseElasticInOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseElasticInOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_EaseElastic_prototype), + jsb_cocos2d_EaseElasticInOut_class, + js_cocos2dx_EaseElasticInOut_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, "EaseElasticInOut", 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_EaseElasticInOut_class; + p->proto = jsb_cocos2d_EaseElasticInOut_prototype; + p->parentProto = jsb_cocos2d_EaseElastic_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseBounce_class; +JSObject *jsb_cocos2d_EaseBounce_prototype; + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseBounce_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseBounce)", obj); +} + +void js_register_cocos2dx_EaseBounce(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseBounce_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseBounce_class->name = "EaseBounce"; + jsb_cocos2d_EaseBounce_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseBounce_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseBounce_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseBounce_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseBounce_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseBounce_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseBounce_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseBounce_class->finalize = js_cocos2d_EaseBounce_finalize; + jsb_cocos2d_EaseBounce_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_EaseBounce_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseBounce_class, + empty_constructor, 0, + 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, "EaseBounce", 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_EaseBounce_class; + p->proto = jsb_cocos2d_EaseBounce_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseBounceIn_class; +JSObject *jsb_cocos2d_EaseBounceIn_prototype; + +bool js_cocos2dx_EaseBounceIn_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseBounceIn_create : Error processing arguments"); + cocos2d::EaseBounceIn* ret = cocos2d::EaseBounceIn::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseBounceIn*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseBounceIn_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseBounceIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseBounceIn* cobj = new (std::nothrow) cocos2d::EaseBounceIn(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseBounceIn"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_EaseBounce_prototype; + +void js_cocos2d_EaseBounceIn_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseBounceIn)", obj); +} + +void js_register_cocos2dx_EaseBounceIn(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseBounceIn_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseBounceIn_class->name = "EaseBounceIn"; + jsb_cocos2d_EaseBounceIn_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseBounceIn_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseBounceIn_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseBounceIn_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseBounceIn_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseBounceIn_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseBounceIn_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseBounceIn_class->finalize = js_cocos2d_EaseBounceIn_finalize; + jsb_cocos2d_EaseBounceIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseBounceIn_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseBounceIn_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_EaseBounce_prototype), + jsb_cocos2d_EaseBounceIn_class, + js_cocos2dx_EaseBounceIn_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, "EaseBounceIn", 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_EaseBounceIn_class; + p->proto = jsb_cocos2d_EaseBounceIn_prototype; + p->parentProto = jsb_cocos2d_EaseBounce_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseBounceOut_class; +JSObject *jsb_cocos2d_EaseBounceOut_prototype; + +bool js_cocos2dx_EaseBounceOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseBounceOut_create : Error processing arguments"); + cocos2d::EaseBounceOut* ret = cocos2d::EaseBounceOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseBounceOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseBounceOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseBounceOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseBounceOut* cobj = new (std::nothrow) cocos2d::EaseBounceOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseBounceOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_EaseBounce_prototype; + +void js_cocos2d_EaseBounceOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseBounceOut)", obj); +} + +void js_register_cocos2dx_EaseBounceOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseBounceOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseBounceOut_class->name = "EaseBounceOut"; + jsb_cocos2d_EaseBounceOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseBounceOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseBounceOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseBounceOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseBounceOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseBounceOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseBounceOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseBounceOut_class->finalize = js_cocos2d_EaseBounceOut_finalize; + jsb_cocos2d_EaseBounceOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseBounceOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseBounceOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_EaseBounce_prototype), + jsb_cocos2d_EaseBounceOut_class, + js_cocos2dx_EaseBounceOut_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, "EaseBounceOut", 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_EaseBounceOut_class; + p->proto = jsb_cocos2d_EaseBounceOut_prototype; + p->parentProto = jsb_cocos2d_EaseBounce_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseBounceInOut_class; +JSObject *jsb_cocos2d_EaseBounceInOut_prototype; + +bool js_cocos2dx_EaseBounceInOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseBounceInOut_create : Error processing arguments"); + cocos2d::EaseBounceInOut* ret = cocos2d::EaseBounceInOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseBounceInOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseBounceInOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseBounceInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseBounceInOut* cobj = new (std::nothrow) cocos2d::EaseBounceInOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseBounceInOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_EaseBounce_prototype; + +void js_cocos2d_EaseBounceInOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseBounceInOut)", obj); +} + +void js_register_cocos2dx_EaseBounceInOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseBounceInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseBounceInOut_class->name = "EaseBounceInOut"; + jsb_cocos2d_EaseBounceInOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseBounceInOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseBounceInOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseBounceInOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseBounceInOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseBounceInOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseBounceInOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseBounceInOut_class->finalize = js_cocos2d_EaseBounceInOut_finalize; + jsb_cocos2d_EaseBounceInOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseBounceInOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseBounceInOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_EaseBounce_prototype), + jsb_cocos2d_EaseBounceInOut_class, + js_cocos2dx_EaseBounceInOut_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, "EaseBounceInOut", 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_EaseBounceInOut_class; + p->proto = jsb_cocos2d_EaseBounceInOut_prototype; + p->parentProto = jsb_cocos2d_EaseBounce_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseBackIn_class; +JSObject *jsb_cocos2d_EaseBackIn_prototype; + +bool js_cocos2dx_EaseBackIn_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseBackIn_create : Error processing arguments"); + cocos2d::EaseBackIn* ret = cocos2d::EaseBackIn::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseBackIn*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseBackIn_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseBackIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseBackIn* cobj = new (std::nothrow) cocos2d::EaseBackIn(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseBackIn"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseBackIn_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseBackIn)", obj); +} + +void js_register_cocos2dx_EaseBackIn(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseBackIn_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseBackIn_class->name = "EaseBackIn"; + jsb_cocos2d_EaseBackIn_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseBackIn_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseBackIn_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseBackIn_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseBackIn_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseBackIn_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseBackIn_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseBackIn_class->finalize = js_cocos2d_EaseBackIn_finalize; + jsb_cocos2d_EaseBackIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseBackIn_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseBackIn_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseBackIn_class, + js_cocos2dx_EaseBackIn_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, "EaseBackIn", 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_EaseBackIn_class; + p->proto = jsb_cocos2d_EaseBackIn_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseBackOut_class; +JSObject *jsb_cocos2d_EaseBackOut_prototype; + +bool js_cocos2dx_EaseBackOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseBackOut_create : Error processing arguments"); + cocos2d::EaseBackOut* ret = cocos2d::EaseBackOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseBackOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseBackOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseBackOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseBackOut* cobj = new (std::nothrow) cocos2d::EaseBackOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseBackOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseBackOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseBackOut)", obj); +} + +void js_register_cocos2dx_EaseBackOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseBackOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseBackOut_class->name = "EaseBackOut"; + jsb_cocos2d_EaseBackOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseBackOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseBackOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseBackOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseBackOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseBackOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseBackOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseBackOut_class->finalize = js_cocos2d_EaseBackOut_finalize; + jsb_cocos2d_EaseBackOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseBackOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseBackOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseBackOut_class, + js_cocos2dx_EaseBackOut_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, "EaseBackOut", 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_EaseBackOut_class; + p->proto = jsb_cocos2d_EaseBackOut_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseBackInOut_class; +JSObject *jsb_cocos2d_EaseBackInOut_prototype; + +bool js_cocos2dx_EaseBackInOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseBackInOut_create : Error processing arguments"); + cocos2d::EaseBackInOut* ret = cocos2d::EaseBackInOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseBackInOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseBackInOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseBackInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseBackInOut* cobj = new (std::nothrow) cocos2d::EaseBackInOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseBackInOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseBackInOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseBackInOut)", obj); +} + +void js_register_cocos2dx_EaseBackInOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseBackInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseBackInOut_class->name = "EaseBackInOut"; + jsb_cocos2d_EaseBackInOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseBackInOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseBackInOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseBackInOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseBackInOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseBackInOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseBackInOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseBackInOut_class->finalize = js_cocos2d_EaseBackInOut_finalize; + jsb_cocos2d_EaseBackInOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseBackInOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseBackInOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseBackInOut_class, + js_cocos2dx_EaseBackInOut_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, "EaseBackInOut", 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_EaseBackInOut_class; + p->proto = jsb_cocos2d_EaseBackInOut_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseBezierAction_class; +JSObject *jsb_cocos2d_EaseBezierAction_prototype; + +bool js_cocos2dx_EaseBezierAction_setBezierParamer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EaseBezierAction* cobj = (cocos2d::EaseBezierAction *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EaseBezierAction_setBezierParamer : Invalid Native Object"); + if (argc == 4) { + double arg0; + double arg1; + double arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseBezierAction_setBezierParamer : Error processing arguments"); + cobj->setBezierParamer(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EaseBezierAction_setBezierParamer : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_EaseBezierAction_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseBezierAction_create : Error processing arguments"); + cocos2d::EaseBezierAction* ret = cocos2d::EaseBezierAction::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseBezierAction*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseBezierAction_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseBezierAction_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseBezierAction* cobj = new (std::nothrow) cocos2d::EaseBezierAction(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseBezierAction"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseBezierAction_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseBezierAction)", obj); +} + +static bool js_cocos2d_EaseBezierAction_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseBezierAction *nobj = new (std::nothrow) cocos2d::EaseBezierAction(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseBezierAction"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_EaseBezierAction(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseBezierAction_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseBezierAction_class->name = "EaseBezierAction"; + jsb_cocos2d_EaseBezierAction_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseBezierAction_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseBezierAction_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseBezierAction_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseBezierAction_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseBezierAction_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseBezierAction_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseBezierAction_class->finalize = js_cocos2d_EaseBezierAction_finalize; + jsb_cocos2d_EaseBezierAction_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setBezierParamer", js_cocos2dx_EaseBezierAction_setBezierParamer, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_EaseBezierAction_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseBezierAction_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseBezierAction_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseBezierAction_class, + js_cocos2dx_EaseBezierAction_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, "EaseBezierAction", 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_EaseBezierAction_class; + p->proto = jsb_cocos2d_EaseBezierAction_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseQuadraticActionIn_class; +JSObject *jsb_cocos2d_EaseQuadraticActionIn_prototype; + +bool js_cocos2dx_EaseQuadraticActionIn_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseQuadraticActionIn_create : Error processing arguments"); + cocos2d::EaseQuadraticActionIn* ret = cocos2d::EaseQuadraticActionIn::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseQuadraticActionIn*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseQuadraticActionIn_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseQuadraticActionIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseQuadraticActionIn* cobj = new (std::nothrow) cocos2d::EaseQuadraticActionIn(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseQuadraticActionIn"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseQuadraticActionIn_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseQuadraticActionIn)", obj); +} + +static bool js_cocos2d_EaseQuadraticActionIn_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseQuadraticActionIn *nobj = new (std::nothrow) cocos2d::EaseQuadraticActionIn(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseQuadraticActionIn"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_EaseQuadraticActionIn(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseQuadraticActionIn_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseQuadraticActionIn_class->name = "EaseQuadraticActionIn"; + jsb_cocos2d_EaseQuadraticActionIn_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseQuadraticActionIn_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseQuadraticActionIn_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseQuadraticActionIn_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseQuadraticActionIn_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseQuadraticActionIn_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseQuadraticActionIn_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseQuadraticActionIn_class->finalize = js_cocos2d_EaseQuadraticActionIn_finalize; + jsb_cocos2d_EaseQuadraticActionIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2d_EaseQuadraticActionIn_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseQuadraticActionIn_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseQuadraticActionIn_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseQuadraticActionIn_class, + js_cocos2dx_EaseQuadraticActionIn_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, "EaseQuadraticActionIn", 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_EaseQuadraticActionIn_class; + p->proto = jsb_cocos2d_EaseQuadraticActionIn_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseQuadraticActionOut_class; +JSObject *jsb_cocos2d_EaseQuadraticActionOut_prototype; + +bool js_cocos2dx_EaseQuadraticActionOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseQuadraticActionOut_create : Error processing arguments"); + cocos2d::EaseQuadraticActionOut* ret = cocos2d::EaseQuadraticActionOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseQuadraticActionOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseQuadraticActionOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseQuadraticActionOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseQuadraticActionOut* cobj = new (std::nothrow) cocos2d::EaseQuadraticActionOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseQuadraticActionOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseQuadraticActionOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseQuadraticActionOut)", obj); +} + +static bool js_cocos2d_EaseQuadraticActionOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseQuadraticActionOut *nobj = new (std::nothrow) cocos2d::EaseQuadraticActionOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseQuadraticActionOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_EaseQuadraticActionOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseQuadraticActionOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseQuadraticActionOut_class->name = "EaseQuadraticActionOut"; + jsb_cocos2d_EaseQuadraticActionOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseQuadraticActionOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseQuadraticActionOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseQuadraticActionOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseQuadraticActionOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseQuadraticActionOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseQuadraticActionOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseQuadraticActionOut_class->finalize = js_cocos2d_EaseQuadraticActionOut_finalize; + jsb_cocos2d_EaseQuadraticActionOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2d_EaseQuadraticActionOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseQuadraticActionOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseQuadraticActionOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseQuadraticActionOut_class, + js_cocos2dx_EaseQuadraticActionOut_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, "EaseQuadraticActionOut", 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_EaseQuadraticActionOut_class; + p->proto = jsb_cocos2d_EaseQuadraticActionOut_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseQuadraticActionInOut_class; +JSObject *jsb_cocos2d_EaseQuadraticActionInOut_prototype; + +bool js_cocos2dx_EaseQuadraticActionInOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseQuadraticActionInOut_create : Error processing arguments"); + cocos2d::EaseQuadraticActionInOut* ret = cocos2d::EaseQuadraticActionInOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseQuadraticActionInOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseQuadraticActionInOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseQuadraticActionInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseQuadraticActionInOut* cobj = new (std::nothrow) cocos2d::EaseQuadraticActionInOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseQuadraticActionInOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseQuadraticActionInOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseQuadraticActionInOut)", obj); +} + +static bool js_cocos2d_EaseQuadraticActionInOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseQuadraticActionInOut *nobj = new (std::nothrow) cocos2d::EaseQuadraticActionInOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseQuadraticActionInOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_EaseQuadraticActionInOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseQuadraticActionInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseQuadraticActionInOut_class->name = "EaseQuadraticActionInOut"; + jsb_cocos2d_EaseQuadraticActionInOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseQuadraticActionInOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseQuadraticActionInOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseQuadraticActionInOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseQuadraticActionInOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseQuadraticActionInOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseQuadraticActionInOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseQuadraticActionInOut_class->finalize = js_cocos2d_EaseQuadraticActionInOut_finalize; + jsb_cocos2d_EaseQuadraticActionInOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2d_EaseQuadraticActionInOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseQuadraticActionInOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseQuadraticActionInOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseQuadraticActionInOut_class, + js_cocos2dx_EaseQuadraticActionInOut_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, "EaseQuadraticActionInOut", 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_EaseQuadraticActionInOut_class; + p->proto = jsb_cocos2d_EaseQuadraticActionInOut_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseQuarticActionIn_class; +JSObject *jsb_cocos2d_EaseQuarticActionIn_prototype; + +bool js_cocos2dx_EaseQuarticActionIn_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseQuarticActionIn_create : Error processing arguments"); + cocos2d::EaseQuarticActionIn* ret = cocos2d::EaseQuarticActionIn::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseQuarticActionIn*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseQuarticActionIn_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseQuarticActionIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseQuarticActionIn* cobj = new (std::nothrow) cocos2d::EaseQuarticActionIn(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseQuarticActionIn"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseQuarticActionIn_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseQuarticActionIn)", obj); +} + +static bool js_cocos2d_EaseQuarticActionIn_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseQuarticActionIn *nobj = new (std::nothrow) cocos2d::EaseQuarticActionIn(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseQuarticActionIn"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_EaseQuarticActionIn(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseQuarticActionIn_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseQuarticActionIn_class->name = "EaseQuarticActionIn"; + jsb_cocos2d_EaseQuarticActionIn_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseQuarticActionIn_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseQuarticActionIn_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseQuarticActionIn_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseQuarticActionIn_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseQuarticActionIn_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseQuarticActionIn_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseQuarticActionIn_class->finalize = js_cocos2d_EaseQuarticActionIn_finalize; + jsb_cocos2d_EaseQuarticActionIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2d_EaseQuarticActionIn_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseQuarticActionIn_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseQuarticActionIn_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseQuarticActionIn_class, + js_cocos2dx_EaseQuarticActionIn_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, "EaseQuarticActionIn", 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_EaseQuarticActionIn_class; + p->proto = jsb_cocos2d_EaseQuarticActionIn_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseQuarticActionOut_class; +JSObject *jsb_cocos2d_EaseQuarticActionOut_prototype; + +bool js_cocos2dx_EaseQuarticActionOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseQuarticActionOut_create : Error processing arguments"); + cocos2d::EaseQuarticActionOut* ret = cocos2d::EaseQuarticActionOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseQuarticActionOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseQuarticActionOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseQuarticActionOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseQuarticActionOut* cobj = new (std::nothrow) cocos2d::EaseQuarticActionOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseQuarticActionOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseQuarticActionOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseQuarticActionOut)", obj); +} + +static bool js_cocos2d_EaseQuarticActionOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseQuarticActionOut *nobj = new (std::nothrow) cocos2d::EaseQuarticActionOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseQuarticActionOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_EaseQuarticActionOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseQuarticActionOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseQuarticActionOut_class->name = "EaseQuarticActionOut"; + jsb_cocos2d_EaseQuarticActionOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseQuarticActionOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseQuarticActionOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseQuarticActionOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseQuarticActionOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseQuarticActionOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseQuarticActionOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseQuarticActionOut_class->finalize = js_cocos2d_EaseQuarticActionOut_finalize; + jsb_cocos2d_EaseQuarticActionOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2d_EaseQuarticActionOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseQuarticActionOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseQuarticActionOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseQuarticActionOut_class, + js_cocos2dx_EaseQuarticActionOut_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, "EaseQuarticActionOut", 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_EaseQuarticActionOut_class; + p->proto = jsb_cocos2d_EaseQuarticActionOut_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseQuarticActionInOut_class; +JSObject *jsb_cocos2d_EaseQuarticActionInOut_prototype; + +bool js_cocos2dx_EaseQuarticActionInOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseQuarticActionInOut_create : Error processing arguments"); + cocos2d::EaseQuarticActionInOut* ret = cocos2d::EaseQuarticActionInOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseQuarticActionInOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseQuarticActionInOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseQuarticActionInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseQuarticActionInOut* cobj = new (std::nothrow) cocos2d::EaseQuarticActionInOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseQuarticActionInOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseQuarticActionInOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseQuarticActionInOut)", obj); +} + +static bool js_cocos2d_EaseQuarticActionInOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseQuarticActionInOut *nobj = new (std::nothrow) cocos2d::EaseQuarticActionInOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseQuarticActionInOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_EaseQuarticActionInOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseQuarticActionInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseQuarticActionInOut_class->name = "EaseQuarticActionInOut"; + jsb_cocos2d_EaseQuarticActionInOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseQuarticActionInOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseQuarticActionInOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseQuarticActionInOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseQuarticActionInOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseQuarticActionInOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseQuarticActionInOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseQuarticActionInOut_class->finalize = js_cocos2d_EaseQuarticActionInOut_finalize; + jsb_cocos2d_EaseQuarticActionInOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2d_EaseQuarticActionInOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseQuarticActionInOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseQuarticActionInOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseQuarticActionInOut_class, + js_cocos2dx_EaseQuarticActionInOut_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, "EaseQuarticActionInOut", 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_EaseQuarticActionInOut_class; + p->proto = jsb_cocos2d_EaseQuarticActionInOut_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseQuinticActionIn_class; +JSObject *jsb_cocos2d_EaseQuinticActionIn_prototype; + +bool js_cocos2dx_EaseQuinticActionIn_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseQuinticActionIn_create : Error processing arguments"); + cocos2d::EaseQuinticActionIn* ret = cocos2d::EaseQuinticActionIn::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseQuinticActionIn*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseQuinticActionIn_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseQuinticActionIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseQuinticActionIn* cobj = new (std::nothrow) cocos2d::EaseQuinticActionIn(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseQuinticActionIn"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseQuinticActionIn_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseQuinticActionIn)", obj); +} + +static bool js_cocos2d_EaseQuinticActionIn_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseQuinticActionIn *nobj = new (std::nothrow) cocos2d::EaseQuinticActionIn(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseQuinticActionIn"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_EaseQuinticActionIn(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseQuinticActionIn_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseQuinticActionIn_class->name = "EaseQuinticActionIn"; + jsb_cocos2d_EaseQuinticActionIn_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseQuinticActionIn_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseQuinticActionIn_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseQuinticActionIn_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseQuinticActionIn_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseQuinticActionIn_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseQuinticActionIn_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseQuinticActionIn_class->finalize = js_cocos2d_EaseQuinticActionIn_finalize; + jsb_cocos2d_EaseQuinticActionIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2d_EaseQuinticActionIn_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseQuinticActionIn_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseQuinticActionIn_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseQuinticActionIn_class, + js_cocos2dx_EaseQuinticActionIn_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, "EaseQuinticActionIn", 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_EaseQuinticActionIn_class; + p->proto = jsb_cocos2d_EaseQuinticActionIn_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseQuinticActionOut_class; +JSObject *jsb_cocos2d_EaseQuinticActionOut_prototype; + +bool js_cocos2dx_EaseQuinticActionOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseQuinticActionOut_create : Error processing arguments"); + cocos2d::EaseQuinticActionOut* ret = cocos2d::EaseQuinticActionOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseQuinticActionOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseQuinticActionOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseQuinticActionOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseQuinticActionOut* cobj = new (std::nothrow) cocos2d::EaseQuinticActionOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseQuinticActionOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseQuinticActionOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseQuinticActionOut)", obj); +} + +static bool js_cocos2d_EaseQuinticActionOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseQuinticActionOut *nobj = new (std::nothrow) cocos2d::EaseQuinticActionOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseQuinticActionOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_EaseQuinticActionOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseQuinticActionOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseQuinticActionOut_class->name = "EaseQuinticActionOut"; + jsb_cocos2d_EaseQuinticActionOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseQuinticActionOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseQuinticActionOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseQuinticActionOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseQuinticActionOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseQuinticActionOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseQuinticActionOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseQuinticActionOut_class->finalize = js_cocos2d_EaseQuinticActionOut_finalize; + jsb_cocos2d_EaseQuinticActionOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2d_EaseQuinticActionOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseQuinticActionOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseQuinticActionOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseQuinticActionOut_class, + js_cocos2dx_EaseQuinticActionOut_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, "EaseQuinticActionOut", 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_EaseQuinticActionOut_class; + p->proto = jsb_cocos2d_EaseQuinticActionOut_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseQuinticActionInOut_class; +JSObject *jsb_cocos2d_EaseQuinticActionInOut_prototype; + +bool js_cocos2dx_EaseQuinticActionInOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseQuinticActionInOut_create : Error processing arguments"); + cocos2d::EaseQuinticActionInOut* ret = cocos2d::EaseQuinticActionInOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseQuinticActionInOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseQuinticActionInOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseQuinticActionInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseQuinticActionInOut* cobj = new (std::nothrow) cocos2d::EaseQuinticActionInOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseQuinticActionInOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseQuinticActionInOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseQuinticActionInOut)", obj); +} + +static bool js_cocos2d_EaseQuinticActionInOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseQuinticActionInOut *nobj = new (std::nothrow) cocos2d::EaseQuinticActionInOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseQuinticActionInOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_EaseQuinticActionInOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseQuinticActionInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseQuinticActionInOut_class->name = "EaseQuinticActionInOut"; + jsb_cocos2d_EaseQuinticActionInOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseQuinticActionInOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseQuinticActionInOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseQuinticActionInOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseQuinticActionInOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseQuinticActionInOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseQuinticActionInOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseQuinticActionInOut_class->finalize = js_cocos2d_EaseQuinticActionInOut_finalize; + jsb_cocos2d_EaseQuinticActionInOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2d_EaseQuinticActionInOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseQuinticActionInOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseQuinticActionInOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseQuinticActionInOut_class, + js_cocos2dx_EaseQuinticActionInOut_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, "EaseQuinticActionInOut", 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_EaseQuinticActionInOut_class; + p->proto = jsb_cocos2d_EaseQuinticActionInOut_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseCircleActionIn_class; +JSObject *jsb_cocos2d_EaseCircleActionIn_prototype; + +bool js_cocos2dx_EaseCircleActionIn_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseCircleActionIn_create : Error processing arguments"); + cocos2d::EaseCircleActionIn* ret = cocos2d::EaseCircleActionIn::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseCircleActionIn*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseCircleActionIn_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseCircleActionIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseCircleActionIn* cobj = new (std::nothrow) cocos2d::EaseCircleActionIn(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseCircleActionIn"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseCircleActionIn_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseCircleActionIn)", obj); +} + +static bool js_cocos2d_EaseCircleActionIn_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseCircleActionIn *nobj = new (std::nothrow) cocos2d::EaseCircleActionIn(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseCircleActionIn"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_EaseCircleActionIn(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseCircleActionIn_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseCircleActionIn_class->name = "EaseCircleActionIn"; + jsb_cocos2d_EaseCircleActionIn_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseCircleActionIn_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseCircleActionIn_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseCircleActionIn_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseCircleActionIn_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseCircleActionIn_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseCircleActionIn_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseCircleActionIn_class->finalize = js_cocos2d_EaseCircleActionIn_finalize; + jsb_cocos2d_EaseCircleActionIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2d_EaseCircleActionIn_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseCircleActionIn_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseCircleActionIn_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseCircleActionIn_class, + js_cocos2dx_EaseCircleActionIn_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, "EaseCircleActionIn", 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_EaseCircleActionIn_class; + p->proto = jsb_cocos2d_EaseCircleActionIn_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseCircleActionOut_class; +JSObject *jsb_cocos2d_EaseCircleActionOut_prototype; + +bool js_cocos2dx_EaseCircleActionOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseCircleActionOut_create : Error processing arguments"); + cocos2d::EaseCircleActionOut* ret = cocos2d::EaseCircleActionOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseCircleActionOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseCircleActionOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseCircleActionOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseCircleActionOut* cobj = new (std::nothrow) cocos2d::EaseCircleActionOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseCircleActionOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseCircleActionOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseCircleActionOut)", obj); +} + +static bool js_cocos2d_EaseCircleActionOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseCircleActionOut *nobj = new (std::nothrow) cocos2d::EaseCircleActionOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseCircleActionOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_EaseCircleActionOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseCircleActionOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseCircleActionOut_class->name = "EaseCircleActionOut"; + jsb_cocos2d_EaseCircleActionOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseCircleActionOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseCircleActionOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseCircleActionOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseCircleActionOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseCircleActionOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseCircleActionOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseCircleActionOut_class->finalize = js_cocos2d_EaseCircleActionOut_finalize; + jsb_cocos2d_EaseCircleActionOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2d_EaseCircleActionOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseCircleActionOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseCircleActionOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseCircleActionOut_class, + js_cocos2dx_EaseCircleActionOut_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, "EaseCircleActionOut", 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_EaseCircleActionOut_class; + p->proto = jsb_cocos2d_EaseCircleActionOut_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseCircleActionInOut_class; +JSObject *jsb_cocos2d_EaseCircleActionInOut_prototype; + +bool js_cocos2dx_EaseCircleActionInOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseCircleActionInOut_create : Error processing arguments"); + cocos2d::EaseCircleActionInOut* ret = cocos2d::EaseCircleActionInOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseCircleActionInOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseCircleActionInOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseCircleActionInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseCircleActionInOut* cobj = new (std::nothrow) cocos2d::EaseCircleActionInOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseCircleActionInOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseCircleActionInOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseCircleActionInOut)", obj); +} + +static bool js_cocos2d_EaseCircleActionInOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseCircleActionInOut *nobj = new (std::nothrow) cocos2d::EaseCircleActionInOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseCircleActionInOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_EaseCircleActionInOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseCircleActionInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseCircleActionInOut_class->name = "EaseCircleActionInOut"; + jsb_cocos2d_EaseCircleActionInOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseCircleActionInOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseCircleActionInOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseCircleActionInOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseCircleActionInOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseCircleActionInOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseCircleActionInOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseCircleActionInOut_class->finalize = js_cocos2d_EaseCircleActionInOut_finalize; + jsb_cocos2d_EaseCircleActionInOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2d_EaseCircleActionInOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseCircleActionInOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseCircleActionInOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseCircleActionInOut_class, + js_cocos2dx_EaseCircleActionInOut_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, "EaseCircleActionInOut", 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_EaseCircleActionInOut_class; + p->proto = jsb_cocos2d_EaseCircleActionInOut_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseCubicActionIn_class; +JSObject *jsb_cocos2d_EaseCubicActionIn_prototype; + +bool js_cocos2dx_EaseCubicActionIn_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseCubicActionIn_create : Error processing arguments"); + cocos2d::EaseCubicActionIn* ret = cocos2d::EaseCubicActionIn::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseCubicActionIn*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseCubicActionIn_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseCubicActionIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseCubicActionIn* cobj = new (std::nothrow) cocos2d::EaseCubicActionIn(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseCubicActionIn"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseCubicActionIn_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseCubicActionIn)", obj); +} + +static bool js_cocos2d_EaseCubicActionIn_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseCubicActionIn *nobj = new (std::nothrow) cocos2d::EaseCubicActionIn(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseCubicActionIn"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_EaseCubicActionIn(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseCubicActionIn_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseCubicActionIn_class->name = "EaseCubicActionIn"; + jsb_cocos2d_EaseCubicActionIn_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseCubicActionIn_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseCubicActionIn_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseCubicActionIn_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseCubicActionIn_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseCubicActionIn_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseCubicActionIn_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseCubicActionIn_class->finalize = js_cocos2d_EaseCubicActionIn_finalize; + jsb_cocos2d_EaseCubicActionIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2d_EaseCubicActionIn_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseCubicActionIn_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseCubicActionIn_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseCubicActionIn_class, + js_cocos2dx_EaseCubicActionIn_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, "EaseCubicActionIn", 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_EaseCubicActionIn_class; + p->proto = jsb_cocos2d_EaseCubicActionIn_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseCubicActionOut_class; +JSObject *jsb_cocos2d_EaseCubicActionOut_prototype; + +bool js_cocos2dx_EaseCubicActionOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseCubicActionOut_create : Error processing arguments"); + cocos2d::EaseCubicActionOut* ret = cocos2d::EaseCubicActionOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseCubicActionOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseCubicActionOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseCubicActionOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseCubicActionOut* cobj = new (std::nothrow) cocos2d::EaseCubicActionOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseCubicActionOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseCubicActionOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseCubicActionOut)", obj); +} + +static bool js_cocos2d_EaseCubicActionOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseCubicActionOut *nobj = new (std::nothrow) cocos2d::EaseCubicActionOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseCubicActionOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_EaseCubicActionOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseCubicActionOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseCubicActionOut_class->name = "EaseCubicActionOut"; + jsb_cocos2d_EaseCubicActionOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseCubicActionOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseCubicActionOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseCubicActionOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseCubicActionOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseCubicActionOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseCubicActionOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseCubicActionOut_class->finalize = js_cocos2d_EaseCubicActionOut_finalize; + jsb_cocos2d_EaseCubicActionOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2d_EaseCubicActionOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseCubicActionOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseCubicActionOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseCubicActionOut_class, + js_cocos2dx_EaseCubicActionOut_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, "EaseCubicActionOut", 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_EaseCubicActionOut_class; + p->proto = jsb_cocos2d_EaseCubicActionOut_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_EaseCubicActionInOut_class; +JSObject *jsb_cocos2d_EaseCubicActionInOut_prototype; + +bool js_cocos2dx_EaseCubicActionInOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EaseCubicActionInOut_create : Error processing arguments"); + cocos2d::EaseCubicActionInOut* ret = cocos2d::EaseCubicActionInOut::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EaseCubicActionInOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EaseCubicActionInOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EaseCubicActionInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::EaseCubicActionInOut* cobj = new (std::nothrow) cocos2d::EaseCubicActionInOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseCubicActionInOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +void js_cocos2d_EaseCubicActionInOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EaseCubicActionInOut)", obj); +} + +static bool js_cocos2d_EaseCubicActionInOut_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::EaseCubicActionInOut *nobj = new (std::nothrow) cocos2d::EaseCubicActionInOut(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EaseCubicActionInOut"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_EaseCubicActionInOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EaseCubicActionInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EaseCubicActionInOut_class->name = "EaseCubicActionInOut"; + jsb_cocos2d_EaseCubicActionInOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EaseCubicActionInOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EaseCubicActionInOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EaseCubicActionInOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EaseCubicActionInOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EaseCubicActionInOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_EaseCubicActionInOut_class->convert = JS_ConvertStub; + jsb_cocos2d_EaseCubicActionInOut_class->finalize = js_cocos2d_EaseCubicActionInOut_finalize; + jsb_cocos2d_EaseCubicActionInOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2d_EaseCubicActionInOut_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_EaseCubicActionInOut_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_EaseCubicActionInOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionEase_prototype), + jsb_cocos2d_EaseCubicActionInOut_class, + js_cocos2dx_EaseCubicActionInOut_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, "EaseCubicActionInOut", 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_EaseCubicActionInOut_class; + p->proto = jsb_cocos2d_EaseCubicActionInOut_prototype; + p->parentProto = jsb_cocos2d_ActionEase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ActionInstant_class; +JSObject *jsb_cocos2d_ActionInstant_prototype; + + +extern JSObject *jsb_cocos2d_FiniteTimeAction_prototype; + +void js_cocos2d_ActionInstant_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ActionInstant)", obj); +} + +void js_register_cocos2dx_ActionInstant(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ActionInstant_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ActionInstant_class->name = "ActionInstant"; + jsb_cocos2d_ActionInstant_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ActionInstant_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ActionInstant_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ActionInstant_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ActionInstant_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ActionInstant_class->resolve = JS_ResolveStub; + jsb_cocos2d_ActionInstant_class->convert = JS_ConvertStub; + jsb_cocos2d_ActionInstant_class->finalize = js_cocos2d_ActionInstant_finalize; + jsb_cocos2d_ActionInstant_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_ActionInstant_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_FiniteTimeAction_prototype), + jsb_cocos2d_ActionInstant_class, + empty_constructor, 0, + 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, "ActionInstant", 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_ActionInstant_class; + p->proto = jsb_cocos2d_ActionInstant_prototype; + p->parentProto = jsb_cocos2d_FiniteTimeAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Show_class; +JSObject *jsb_cocos2d_Show_prototype; + +bool js_cocos2dx_Show_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Show* ret = cocos2d::Show::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Show*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Show_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Show_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Show* cobj = new (std::nothrow) cocos2d::Show(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Show"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInstant_prototype; + +void js_cocos2d_Show_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Show)", obj); +} + +void js_register_cocos2dx_Show(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Show_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Show_class->name = "Show"; + jsb_cocos2d_Show_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Show_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Show_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Show_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Show_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Show_class->resolve = JS_ResolveStub; + jsb_cocos2d_Show_class->convert = JS_ConvertStub; + jsb_cocos2d_Show_class->finalize = js_cocos2d_Show_finalize; + jsb_cocos2d_Show_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Show_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Show_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + jsb_cocos2d_Show_class, + js_cocos2dx_Show_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, "Show", 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_Show_class; + p->proto = jsb_cocos2d_Show_prototype; + p->parentProto = jsb_cocos2d_ActionInstant_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Hide_class; +JSObject *jsb_cocos2d_Hide_prototype; + +bool js_cocos2dx_Hide_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Hide* ret = cocos2d::Hide::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Hide*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Hide_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Hide_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Hide* cobj = new (std::nothrow) cocos2d::Hide(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Hide"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInstant_prototype; + +void js_cocos2d_Hide_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Hide)", obj); +} + +void js_register_cocos2dx_Hide(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Hide_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Hide_class->name = "Hide"; + jsb_cocos2d_Hide_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Hide_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Hide_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Hide_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Hide_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Hide_class->resolve = JS_ResolveStub; + jsb_cocos2d_Hide_class->convert = JS_ConvertStub; + jsb_cocos2d_Hide_class->finalize = js_cocos2d_Hide_finalize; + jsb_cocos2d_Hide_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Hide_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Hide_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + jsb_cocos2d_Hide_class, + js_cocos2dx_Hide_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, "Hide", 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_Hide_class; + p->proto = jsb_cocos2d_Hide_prototype; + p->parentProto = jsb_cocos2d_ActionInstant_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ToggleVisibility_class; +JSObject *jsb_cocos2d_ToggleVisibility_prototype; + +bool js_cocos2dx_ToggleVisibility_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ToggleVisibility* ret = cocos2d::ToggleVisibility::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ToggleVisibility*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ToggleVisibility_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ToggleVisibility_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ToggleVisibility* cobj = new (std::nothrow) cocos2d::ToggleVisibility(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ToggleVisibility"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInstant_prototype; + +void js_cocos2d_ToggleVisibility_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ToggleVisibility)", obj); +} + +void js_register_cocos2dx_ToggleVisibility(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ToggleVisibility_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ToggleVisibility_class->name = "ToggleVisibility"; + jsb_cocos2d_ToggleVisibility_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ToggleVisibility_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ToggleVisibility_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ToggleVisibility_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ToggleVisibility_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ToggleVisibility_class->resolve = JS_ResolveStub; + jsb_cocos2d_ToggleVisibility_class->convert = JS_ConvertStub; + jsb_cocos2d_ToggleVisibility_class->finalize = js_cocos2d_ToggleVisibility_finalize; + jsb_cocos2d_ToggleVisibility_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ToggleVisibility_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ToggleVisibility_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + jsb_cocos2d_ToggleVisibility_class, + js_cocos2dx_ToggleVisibility_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, "ToggleVisibility", 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_ToggleVisibility_class; + p->proto = jsb_cocos2d_ToggleVisibility_prototype; + p->parentProto = jsb_cocos2d_ActionInstant_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_RemoveSelf_class; +JSObject *jsb_cocos2d_RemoveSelf_prototype; + +bool js_cocos2dx_RemoveSelf_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RemoveSelf* cobj = (cocos2d::RemoveSelf *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RemoveSelf_init : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_RemoveSelf_init : Error processing arguments"); + bool ret = cobj->init(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RemoveSelf_init : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_RemoveSelf_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 0) { + cocos2d::RemoveSelf* ret = cocos2d::RemoveSelf::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::RemoveSelf*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_RemoveSelf_create : Error processing arguments"); + cocos2d::RemoveSelf* ret = cocos2d::RemoveSelf::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::RemoveSelf*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_RemoveSelf_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_RemoveSelf_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::RemoveSelf* cobj = new (std::nothrow) cocos2d::RemoveSelf(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::RemoveSelf"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInstant_prototype; + +void js_cocos2d_RemoveSelf_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (RemoveSelf)", obj); +} + +void js_register_cocos2dx_RemoveSelf(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_RemoveSelf_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_RemoveSelf_class->name = "RemoveSelf"; + jsb_cocos2d_RemoveSelf_class->addProperty = JS_PropertyStub; + jsb_cocos2d_RemoveSelf_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_RemoveSelf_class->getProperty = JS_PropertyStub; + jsb_cocos2d_RemoveSelf_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_RemoveSelf_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_RemoveSelf_class->resolve = JS_ResolveStub; + jsb_cocos2d_RemoveSelf_class->convert = JS_ConvertStub; + jsb_cocos2d_RemoveSelf_class->finalize = js_cocos2d_RemoveSelf_finalize; + jsb_cocos2d_RemoveSelf_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_RemoveSelf_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_RemoveSelf_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_RemoveSelf_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + jsb_cocos2d_RemoveSelf_class, + js_cocos2dx_RemoveSelf_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, "RemoveSelf", 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_RemoveSelf_class; + p->proto = jsb_cocos2d_RemoveSelf_prototype; + p->parentProto = jsb_cocos2d_ActionInstant_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_FlipX_class; +JSObject *jsb_cocos2d_FlipX_prototype; + +bool js_cocos2dx_FlipX_initWithFlipX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FlipX* cobj = (cocos2d::FlipX *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FlipX_initWithFlipX : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FlipX_initWithFlipX : Error processing arguments"); + bool ret = cobj->initWithFlipX(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FlipX_initWithFlipX : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FlipX_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FlipX_create : Error processing arguments"); + cocos2d::FlipX* ret = cocos2d::FlipX::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::FlipX*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_FlipX_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_FlipX_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::FlipX* cobj = new (std::nothrow) cocos2d::FlipX(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FlipX"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInstant_prototype; + +void js_cocos2d_FlipX_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (FlipX)", obj); +} + +void js_register_cocos2dx_FlipX(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_FlipX_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_FlipX_class->name = "FlipX"; + jsb_cocos2d_FlipX_class->addProperty = JS_PropertyStub; + jsb_cocos2d_FlipX_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_FlipX_class->getProperty = JS_PropertyStub; + jsb_cocos2d_FlipX_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_FlipX_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_FlipX_class->resolve = JS_ResolveStub; + jsb_cocos2d_FlipX_class->convert = JS_ConvertStub; + jsb_cocos2d_FlipX_class->finalize = js_cocos2d_FlipX_finalize; + jsb_cocos2d_FlipX_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithFlipX", js_cocos2dx_FlipX_initWithFlipX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_FlipX_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_FlipX_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + jsb_cocos2d_FlipX_class, + js_cocos2dx_FlipX_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, "FlipX", 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_FlipX_class; + p->proto = jsb_cocos2d_FlipX_prototype; + p->parentProto = jsb_cocos2d_ActionInstant_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_FlipY_class; +JSObject *jsb_cocos2d_FlipY_prototype; + +bool js_cocos2dx_FlipY_initWithFlipY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FlipY* cobj = (cocos2d::FlipY *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FlipY_initWithFlipY : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FlipY_initWithFlipY : Error processing arguments"); + bool ret = cobj->initWithFlipY(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FlipY_initWithFlipY : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FlipY_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FlipY_create : Error processing arguments"); + cocos2d::FlipY* ret = cocos2d::FlipY::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::FlipY*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_FlipY_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_FlipY_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::FlipY* cobj = new (std::nothrow) cocos2d::FlipY(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FlipY"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInstant_prototype; + +void js_cocos2d_FlipY_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (FlipY)", obj); +} + +void js_register_cocos2dx_FlipY(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_FlipY_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_FlipY_class->name = "FlipY"; + jsb_cocos2d_FlipY_class->addProperty = JS_PropertyStub; + jsb_cocos2d_FlipY_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_FlipY_class->getProperty = JS_PropertyStub; + jsb_cocos2d_FlipY_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_FlipY_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_FlipY_class->resolve = JS_ResolveStub; + jsb_cocos2d_FlipY_class->convert = JS_ConvertStub; + jsb_cocos2d_FlipY_class->finalize = js_cocos2d_FlipY_finalize; + jsb_cocos2d_FlipY_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithFlipY", js_cocos2dx_FlipY_initWithFlipY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_FlipY_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_FlipY_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + jsb_cocos2d_FlipY_class, + js_cocos2dx_FlipY_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, "FlipY", 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_FlipY_class; + p->proto = jsb_cocos2d_FlipY_prototype; + p->parentProto = jsb_cocos2d_ActionInstant_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Place_class; +JSObject *jsb_cocos2d_Place_prototype; + +bool js_cocos2dx_Place_initWithPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Place* cobj = (cocos2d::Place *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Place_initWithPosition : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Place_initWithPosition : Error processing arguments"); + bool ret = cobj->initWithPosition(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Place_initWithPosition : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Place_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Place_create : Error processing arguments"); + cocos2d::Place* ret = cocos2d::Place::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Place*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Place_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Place_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Place* cobj = new (std::nothrow) cocos2d::Place(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Place"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInstant_prototype; + +void js_cocos2d_Place_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Place)", obj); +} + +void js_register_cocos2dx_Place(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Place_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Place_class->name = "Place"; + jsb_cocos2d_Place_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Place_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Place_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Place_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Place_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Place_class->resolve = JS_ResolveStub; + jsb_cocos2d_Place_class->convert = JS_ConvertStub; + jsb_cocos2d_Place_class->finalize = js_cocos2d_Place_finalize; + jsb_cocos2d_Place_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithPosition", js_cocos2dx_Place_initWithPosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Place_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Place_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + jsb_cocos2d_Place_class, + js_cocos2dx_Place_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, "Place", 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_Place_class; + p->proto = jsb_cocos2d_Place_prototype; + p->parentProto = jsb_cocos2d_ActionInstant_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_CallFunc_class; +JSObject *jsb_cocos2d_CallFunc_prototype; + +bool js_cocos2dx_CallFunc_execute(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::CallFunc* cobj = (cocos2d::CallFunc *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CallFunc_execute : Invalid Native Object"); + if (argc == 0) { + cobj->execute(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_CallFunc_execute : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_CallFunc_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::CallFunc* cobj = new (std::nothrow) cocos2d::CallFunc(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::CallFunc"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInstant_prototype; + +void js_cocos2d_CallFunc_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (CallFunc)", obj); +} + +void js_register_cocos2dx_CallFunc(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_CallFunc_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_CallFunc_class->name = "_CallFunc"; + jsb_cocos2d_CallFunc_class->addProperty = JS_PropertyStub; + jsb_cocos2d_CallFunc_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_CallFunc_class->getProperty = JS_PropertyStub; + jsb_cocos2d_CallFunc_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_CallFunc_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_CallFunc_class->resolve = JS_ResolveStub; + jsb_cocos2d_CallFunc_class->convert = JS_ConvertStub; + jsb_cocos2d_CallFunc_class->finalize = js_cocos2d_CallFunc_finalize; + jsb_cocos2d_CallFunc_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("execute", js_cocos2dx_CallFunc_execute, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_CallFunc_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + jsb_cocos2d_CallFunc_class, + js_cocos2dx_CallFunc_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, "_CallFunc", 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_CallFunc_class; + p->proto = jsb_cocos2d_CallFunc_prototype; + p->parentProto = jsb_cocos2d_ActionInstant_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_CallFuncN_class; +JSObject *jsb_cocos2d_CallFuncN_prototype; + +bool js_cocos2dx_CallFuncN_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::CallFuncN* cobj = new (std::nothrow) cocos2d::CallFuncN(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::CallFuncN"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_CallFunc_prototype; + +void js_cocos2d_CallFuncN_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (CallFuncN)", obj); +} + +void js_register_cocos2dx_CallFuncN(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_CallFuncN_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_CallFuncN_class->name = "CallFunc"; + jsb_cocos2d_CallFuncN_class->addProperty = JS_PropertyStub; + jsb_cocos2d_CallFuncN_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_CallFuncN_class->getProperty = JS_PropertyStub; + jsb_cocos2d_CallFuncN_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_CallFuncN_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_CallFuncN_class->resolve = JS_ResolveStub; + jsb_cocos2d_CallFuncN_class->convert = JS_ConvertStub; + jsb_cocos2d_CallFuncN_class->finalize = js_cocos2d_CallFuncN_finalize; + jsb_cocos2d_CallFuncN_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_CallFuncN_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_CallFunc_prototype), + jsb_cocos2d_CallFuncN_class, + js_cocos2dx_CallFuncN_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, "CallFunc", 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_CallFuncN_class; + p->proto = jsb_cocos2d_CallFuncN_prototype; + p->parentProto = jsb_cocos2d_CallFunc_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_GridAction_class; +JSObject *jsb_cocos2d_GridAction_prototype; + +bool js_cocos2dx_GridAction_getGrid(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridAction* cobj = (cocos2d::GridAction *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridAction_getGrid : Invalid Native Object"); + if (argc == 0) { + cocos2d::GridBase* ret = cobj->getGrid(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::GridBase*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridAction_getGrid : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GridAction_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridAction* cobj = (cocos2d::GridAction *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridAction_initWithDuration : Invalid Native Object"); + if (argc == 2) { + double arg0; + cocos2d::Size arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GridAction_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridAction_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_GridAction_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (GridAction)", obj); +} + +void js_register_cocos2dx_GridAction(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_GridAction_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_GridAction_class->name = "GridAction"; + jsb_cocos2d_GridAction_class->addProperty = JS_PropertyStub; + jsb_cocos2d_GridAction_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_GridAction_class->getProperty = JS_PropertyStub; + jsb_cocos2d_GridAction_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_GridAction_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_GridAction_class->resolve = JS_ResolveStub; + jsb_cocos2d_GridAction_class->convert = JS_ConvertStub; + jsb_cocos2d_GridAction_class->finalize = js_cocos2d_GridAction_finalize; + jsb_cocos2d_GridAction_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getGrid", js_cocos2dx_GridAction_getGrid, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithDuration", js_cocos2dx_GridAction_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_GridAction_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_GridAction_class, + empty_constructor, 0, + 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, "GridAction", 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_GridAction_class; + p->proto = jsb_cocos2d_GridAction_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Grid3DAction_class; +JSObject *jsb_cocos2d_Grid3DAction_prototype; + + +extern JSObject *jsb_cocos2d_GridAction_prototype; + +void js_cocos2d_Grid3DAction_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Grid3DAction)", obj); +} + +void js_register_cocos2dx_Grid3DAction(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Grid3DAction_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Grid3DAction_class->name = "Grid3DAction"; + jsb_cocos2d_Grid3DAction_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Grid3DAction_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Grid3DAction_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Grid3DAction_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Grid3DAction_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Grid3DAction_class->resolve = JS_ResolveStub; + jsb_cocos2d_Grid3DAction_class->convert = JS_ConvertStub; + jsb_cocos2d_Grid3DAction_class->finalize = js_cocos2d_Grid3DAction_finalize; + jsb_cocos2d_Grid3DAction_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_Grid3DAction_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_GridAction_prototype), + jsb_cocos2d_Grid3DAction_class, + empty_constructor, 0, + 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, "Grid3DAction", 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_Grid3DAction_class; + p->proto = jsb_cocos2d_Grid3DAction_prototype; + p->parentProto = jsb_cocos2d_GridAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TiledGrid3DAction_class; +JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; + + +extern JSObject *jsb_cocos2d_GridAction_prototype; + +void js_cocos2d_TiledGrid3DAction_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TiledGrid3DAction)", obj); +} + +void js_register_cocos2dx_TiledGrid3DAction(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TiledGrid3DAction_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TiledGrid3DAction_class->name = "TiledGrid3DAction"; + jsb_cocos2d_TiledGrid3DAction_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TiledGrid3DAction_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TiledGrid3DAction_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TiledGrid3DAction_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TiledGrid3DAction_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TiledGrid3DAction_class->resolve = JS_ResolveStub; + jsb_cocos2d_TiledGrid3DAction_class->convert = JS_ConvertStub; + jsb_cocos2d_TiledGrid3DAction_class->finalize = js_cocos2d_TiledGrid3DAction_finalize; + jsb_cocos2d_TiledGrid3DAction_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_TiledGrid3DAction_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_GridAction_prototype), + jsb_cocos2d_TiledGrid3DAction_class, + empty_constructor, 0, + 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, "TiledGrid3DAction", 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_TiledGrid3DAction_class; + p->proto = jsb_cocos2d_TiledGrid3DAction_prototype; + p->parentProto = jsb_cocos2d_GridAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_StopGrid_class; +JSObject *jsb_cocos2d_StopGrid_prototype; + +bool js_cocos2dx_StopGrid_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::StopGrid* ret = cocos2d::StopGrid::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::StopGrid*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_StopGrid_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_StopGrid_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::StopGrid* cobj = new (std::nothrow) cocos2d::StopGrid(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::StopGrid"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInstant_prototype; + +void js_cocos2d_StopGrid_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (StopGrid)", obj); +} + +void js_register_cocos2dx_StopGrid(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_StopGrid_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_StopGrid_class->name = "StopGrid"; + jsb_cocos2d_StopGrid_class->addProperty = JS_PropertyStub; + jsb_cocos2d_StopGrid_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_StopGrid_class->getProperty = JS_PropertyStub; + jsb_cocos2d_StopGrid_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_StopGrid_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_StopGrid_class->resolve = JS_ResolveStub; + jsb_cocos2d_StopGrid_class->convert = JS_ConvertStub; + jsb_cocos2d_StopGrid_class->finalize = js_cocos2d_StopGrid_finalize; + jsb_cocos2d_StopGrid_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_StopGrid_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_StopGrid_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + jsb_cocos2d_StopGrid_class, + js_cocos2dx_StopGrid_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, "StopGrid", 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_StopGrid_class; + p->proto = jsb_cocos2d_StopGrid_prototype; + p->parentProto = jsb_cocos2d_ActionInstant_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ReuseGrid_class; +JSObject *jsb_cocos2d_ReuseGrid_prototype; + +bool js_cocos2dx_ReuseGrid_initWithTimes(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ReuseGrid* cobj = (cocos2d::ReuseGrid *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ReuseGrid_initWithTimes : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ReuseGrid_initWithTimes : Error processing arguments"); + bool ret = cobj->initWithTimes(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ReuseGrid_initWithTimes : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ReuseGrid_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ReuseGrid_create : Error processing arguments"); + cocos2d::ReuseGrid* ret = cocos2d::ReuseGrid::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ReuseGrid*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ReuseGrid_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ReuseGrid_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ReuseGrid* cobj = new (std::nothrow) cocos2d::ReuseGrid(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ReuseGrid"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInstant_prototype; + +void js_cocos2d_ReuseGrid_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ReuseGrid)", obj); +} + +void js_register_cocos2dx_ReuseGrid(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ReuseGrid_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ReuseGrid_class->name = "ReuseGrid"; + jsb_cocos2d_ReuseGrid_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ReuseGrid_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ReuseGrid_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ReuseGrid_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ReuseGrid_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ReuseGrid_class->resolve = JS_ResolveStub; + jsb_cocos2d_ReuseGrid_class->convert = JS_ConvertStub; + jsb_cocos2d_ReuseGrid_class->finalize = js_cocos2d_ReuseGrid_finalize; + jsb_cocos2d_ReuseGrid_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithTimes", js_cocos2dx_ReuseGrid_initWithTimes, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ReuseGrid_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ReuseGrid_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInstant_prototype), + jsb_cocos2d_ReuseGrid_class, + js_cocos2dx_ReuseGrid_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, "ReuseGrid", 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_ReuseGrid_class; + p->proto = jsb_cocos2d_ReuseGrid_prototype; + p->parentProto = jsb_cocos2d_ActionInstant_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Waves3D_class; +JSObject *jsb_cocos2d_Waves3D_prototype; + +bool js_cocos2dx_Waves3D_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Waves3D* cobj = (cocos2d::Waves3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Waves3D_setAmplitudeRate : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Waves3D_setAmplitudeRate : Error processing arguments"); + cobj->setAmplitudeRate(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Waves3D_setAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Waves3D_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Waves3D* cobj = (cocos2d::Waves3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Waves3D_initWithDuration : Invalid Native Object"); + if (argc == 4) { + double arg0; + cocos2d::Size arg1; + unsigned int arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Waves3D_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Waves3D_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_Waves3D_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Waves3D* cobj = (cocos2d::Waves3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Waves3D_getAmplitude : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAmplitude(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Waves3D_getAmplitude : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Waves3D_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Waves3D* cobj = (cocos2d::Waves3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Waves3D_getAmplitudeRate : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAmplitudeRate(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Waves3D_getAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Waves3D_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Waves3D* cobj = (cocos2d::Waves3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Waves3D_setAmplitude : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Waves3D_setAmplitude : Error processing arguments"); + cobj->setAmplitude(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Waves3D_setAmplitude : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Waves3D_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 4) { + double arg0; + cocos2d::Size arg1; + unsigned int arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Waves3D_create : Error processing arguments"); + cocos2d::Waves3D* ret = cocos2d::Waves3D::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Waves3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Waves3D_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Waves3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Waves3D* cobj = new (std::nothrow) cocos2d::Waves3D(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Waves3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Grid3DAction_prototype; + +void js_cocos2d_Waves3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Waves3D)", obj); +} + +void js_register_cocos2dx_Waves3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Waves3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Waves3D_class->name = "Waves3D"; + jsb_cocos2d_Waves3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Waves3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Waves3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Waves3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Waves3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Waves3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_Waves3D_class->convert = JS_ConvertStub; + jsb_cocos2d_Waves3D_class->finalize = js_cocos2d_Waves3D_finalize; + jsb_cocos2d_Waves3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setAmplitudeRate", js_cocos2dx_Waves3D_setAmplitudeRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithDuration", js_cocos2dx_Waves3D_initWithDuration, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAmplitude", js_cocos2dx_Waves3D_getAmplitude, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAmplitudeRate", js_cocos2dx_Waves3D_getAmplitudeRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAmplitude", js_cocos2dx_Waves3D_setAmplitude, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Waves3D_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Waves3D_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + jsb_cocos2d_Waves3D_class, + js_cocos2dx_Waves3D_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, "Waves3D", 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_Waves3D_class; + p->proto = jsb_cocos2d_Waves3D_prototype; + p->parentProto = jsb_cocos2d_Grid3DAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_FlipX3D_class; +JSObject *jsb_cocos2d_FlipX3D_prototype; + +bool js_cocos2dx_FlipX3D_initWithSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FlipX3D* cobj = (cocos2d::FlipX3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FlipX3D_initWithSize : Invalid Native Object"); + if (argc == 2) { + cocos2d::Size arg0; + double arg1; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FlipX3D_initWithSize : Error processing arguments"); + bool ret = cobj->initWithSize(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FlipX3D_initWithSize : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_FlipX3D_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FlipX3D* cobj = (cocos2d::FlipX3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FlipX3D_initWithDuration : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FlipX3D_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FlipX3D_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FlipX3D_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FlipX3D_create : Error processing arguments"); + cocos2d::FlipX3D* ret = cocos2d::FlipX3D::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::FlipX3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_FlipX3D_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_FlipX3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::FlipX3D* cobj = new (std::nothrow) cocos2d::FlipX3D(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FlipX3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Grid3DAction_prototype; + +void js_cocos2d_FlipX3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (FlipX3D)", obj); +} + +void js_register_cocos2dx_FlipX3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_FlipX3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_FlipX3D_class->name = "FlipX3D"; + jsb_cocos2d_FlipX3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_FlipX3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_FlipX3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_FlipX3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_FlipX3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_FlipX3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_FlipX3D_class->convert = JS_ConvertStub; + jsb_cocos2d_FlipX3D_class->finalize = js_cocos2d_FlipX3D_finalize; + jsb_cocos2d_FlipX3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithSize", js_cocos2dx_FlipX3D_initWithSize, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithDuration", js_cocos2dx_FlipX3D_initWithDuration, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_FlipX3D_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_FlipX3D_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + jsb_cocos2d_FlipX3D_class, + js_cocos2dx_FlipX3D_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, "FlipX3D", 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_FlipX3D_class; + p->proto = jsb_cocos2d_FlipX3D_prototype; + p->parentProto = jsb_cocos2d_Grid3DAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_FlipY3D_class; +JSObject *jsb_cocos2d_FlipY3D_prototype; + +bool js_cocos2dx_FlipY3D_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FlipY3D_create : Error processing arguments"); + cocos2d::FlipY3D* ret = cocos2d::FlipY3D::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::FlipY3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_FlipY3D_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_FlipY3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::FlipY3D* cobj = new (std::nothrow) cocos2d::FlipY3D(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FlipY3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_FlipX3D_prototype; + +void js_cocos2d_FlipY3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (FlipY3D)", obj); +} + +void js_register_cocos2dx_FlipY3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_FlipY3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_FlipY3D_class->name = "FlipY3D"; + jsb_cocos2d_FlipY3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_FlipY3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_FlipY3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_FlipY3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_FlipY3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_FlipY3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_FlipY3D_class->convert = JS_ConvertStub; + jsb_cocos2d_FlipY3D_class->finalize = js_cocos2d_FlipY3D_finalize; + jsb_cocos2d_FlipY3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_FlipY3D_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_FlipY3D_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_FlipX3D_prototype), + jsb_cocos2d_FlipY3D_class, + js_cocos2dx_FlipY3D_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, "FlipY3D", 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_FlipY3D_class; + p->proto = jsb_cocos2d_FlipY3D_prototype; + p->parentProto = jsb_cocos2d_FlipX3D_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Lens3D_class; +JSObject *jsb_cocos2d_Lens3D_prototype; + +bool js_cocos2dx_Lens3D_setConcave(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Lens3D* cobj = (cocos2d::Lens3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Lens3D_setConcave : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Lens3D_setConcave : Error processing arguments"); + cobj->setConcave(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Lens3D_setConcave : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Lens3D_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Lens3D* cobj = (cocos2d::Lens3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Lens3D_initWithDuration : Invalid Native Object"); + if (argc == 4) { + double arg0; + cocos2d::Size arg1; + cocos2d::Vec2 arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_vector2(cx, args.get(2), &arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Lens3D_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Lens3D_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_Lens3D_setLensEffect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Lens3D* cobj = (cocos2d::Lens3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Lens3D_setLensEffect : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Lens3D_setLensEffect : Error processing arguments"); + cobj->setLensEffect(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Lens3D_setLensEffect : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Lens3D_getLensEffect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Lens3D* cobj = (cocos2d::Lens3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Lens3D_getLensEffect : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getLensEffect(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Lens3D_getLensEffect : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Lens3D_setPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Lens3D* cobj = (cocos2d::Lens3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Lens3D_setPosition : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Lens3D_setPosition : Error processing arguments"); + cobj->setPosition(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Lens3D_setPosition : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Lens3D_getPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Lens3D* cobj = (cocos2d::Lens3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Lens3D_getPosition : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getPosition(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Lens3D_getPosition : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Lens3D_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 4) { + double arg0; + cocos2d::Size arg1; + cocos2d::Vec2 arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_vector2(cx, args.get(2), &arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Lens3D_create : Error processing arguments"); + cocos2d::Lens3D* ret = cocos2d::Lens3D::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Lens3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Lens3D_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Lens3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Lens3D* cobj = new (std::nothrow) cocos2d::Lens3D(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Lens3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Grid3DAction_prototype; + +void js_cocos2d_Lens3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Lens3D)", obj); +} + +void js_register_cocos2dx_Lens3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Lens3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Lens3D_class->name = "Lens3D"; + jsb_cocos2d_Lens3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Lens3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Lens3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Lens3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Lens3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Lens3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_Lens3D_class->convert = JS_ConvertStub; + jsb_cocos2d_Lens3D_class->finalize = js_cocos2d_Lens3D_finalize; + jsb_cocos2d_Lens3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setConcave", js_cocos2dx_Lens3D_setConcave, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithDuration", js_cocos2dx_Lens3D_initWithDuration, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLensEffect", js_cocos2dx_Lens3D_setLensEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLensEffect", js_cocos2dx_Lens3D_getLensEffect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPosition", js_cocos2dx_Lens3D_setPosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPosition", js_cocos2dx_Lens3D_getPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Lens3D_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Lens3D_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + jsb_cocos2d_Lens3D_class, + js_cocos2dx_Lens3D_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, "Lens3D", 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_Lens3D_class; + p->proto = jsb_cocos2d_Lens3D_prototype; + p->parentProto = jsb_cocos2d_Grid3DAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Ripple3D_class; +JSObject *jsb_cocos2d_Ripple3D_prototype; + +bool js_cocos2dx_Ripple3D_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Ripple3D* cobj = (cocos2d::Ripple3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Ripple3D_setAmplitudeRate : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Ripple3D_setAmplitudeRate : Error processing arguments"); + cobj->setAmplitudeRate(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Ripple3D_setAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Ripple3D_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Ripple3D* cobj = (cocos2d::Ripple3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Ripple3D_initWithDuration : Invalid Native Object"); + if (argc == 6) { + double arg0; + cocos2d::Size arg1; + cocos2d::Vec2 arg2; + double arg3; + unsigned int arg4; + double arg5; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_vector2(cx, args.get(2), &arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + ok &= jsval_to_uint32(cx, args.get(4), &arg4); + ok &= JS::ToNumber( cx, args.get(5), &arg5) && !isnan(arg5); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Ripple3D_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Ripple3D_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 6); + return false; +} +bool js_cocos2dx_Ripple3D_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Ripple3D* cobj = (cocos2d::Ripple3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Ripple3D_getAmplitudeRate : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAmplitudeRate(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Ripple3D_getAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Ripple3D_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Ripple3D* cobj = (cocos2d::Ripple3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Ripple3D_setAmplitude : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Ripple3D_setAmplitude : Error processing arguments"); + cobj->setAmplitude(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Ripple3D_setAmplitude : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Ripple3D_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Ripple3D* cobj = (cocos2d::Ripple3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Ripple3D_getAmplitude : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAmplitude(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Ripple3D_getAmplitude : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Ripple3D_setPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Ripple3D* cobj = (cocos2d::Ripple3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Ripple3D_setPosition : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Ripple3D_setPosition : Error processing arguments"); + cobj->setPosition(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Ripple3D_setPosition : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Ripple3D_getPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Ripple3D* cobj = (cocos2d::Ripple3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Ripple3D_getPosition : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getPosition(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Ripple3D_getPosition : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Ripple3D_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 6) { + double arg0; + cocos2d::Size arg1; + cocos2d::Vec2 arg2; + double arg3; + unsigned int arg4; + double arg5; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_vector2(cx, args.get(2), &arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + ok &= jsval_to_uint32(cx, args.get(4), &arg4); + ok &= JS::ToNumber( cx, args.get(5), &arg5) && !isnan(arg5); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Ripple3D_create : Error processing arguments"); + cocos2d::Ripple3D* ret = cocos2d::Ripple3D::create(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ripple3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Ripple3D_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Ripple3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Ripple3D* cobj = new (std::nothrow) cocos2d::Ripple3D(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Ripple3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Grid3DAction_prototype; + +void js_cocos2d_Ripple3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Ripple3D)", obj); +} + +void js_register_cocos2dx_Ripple3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Ripple3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Ripple3D_class->name = "Ripple3D"; + jsb_cocos2d_Ripple3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Ripple3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Ripple3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Ripple3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Ripple3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Ripple3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_Ripple3D_class->convert = JS_ConvertStub; + jsb_cocos2d_Ripple3D_class->finalize = js_cocos2d_Ripple3D_finalize; + jsb_cocos2d_Ripple3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setAmplitudeRate", js_cocos2dx_Ripple3D_setAmplitudeRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithDuration", js_cocos2dx_Ripple3D_initWithDuration, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAmplitudeRate", js_cocos2dx_Ripple3D_getAmplitudeRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAmplitude", js_cocos2dx_Ripple3D_setAmplitude, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAmplitude", js_cocos2dx_Ripple3D_getAmplitude, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPosition", js_cocos2dx_Ripple3D_setPosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPosition", js_cocos2dx_Ripple3D_getPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Ripple3D_create, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Ripple3D_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + jsb_cocos2d_Ripple3D_class, + js_cocos2dx_Ripple3D_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, "Ripple3D", 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_Ripple3D_class; + p->proto = jsb_cocos2d_Ripple3D_prototype; + p->parentProto = jsb_cocos2d_Grid3DAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Shaky3D_class; +JSObject *jsb_cocos2d_Shaky3D_prototype; + +bool js_cocos2dx_Shaky3D_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Shaky3D* cobj = (cocos2d::Shaky3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Shaky3D_initWithDuration : Invalid Native Object"); + if (argc == 4) { + double arg0; + cocos2d::Size arg1; + int arg2; + bool arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + arg3 = JS::ToBoolean(args.get(3)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Shaky3D_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Shaky3D_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_Shaky3D_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 4) { + double arg0; + cocos2d::Size arg1; + int arg2; + bool arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + arg3 = JS::ToBoolean(args.get(3)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Shaky3D_create : Error processing arguments"); + cocos2d::Shaky3D* ret = cocos2d::Shaky3D::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Shaky3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Shaky3D_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Shaky3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Shaky3D* cobj = new (std::nothrow) cocos2d::Shaky3D(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Shaky3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Grid3DAction_prototype; + +void js_cocos2d_Shaky3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Shaky3D)", obj); +} + +void js_register_cocos2dx_Shaky3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Shaky3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Shaky3D_class->name = "Shaky3D"; + jsb_cocos2d_Shaky3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Shaky3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Shaky3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Shaky3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Shaky3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Shaky3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_Shaky3D_class->convert = JS_ConvertStub; + jsb_cocos2d_Shaky3D_class->finalize = js_cocos2d_Shaky3D_finalize; + jsb_cocos2d_Shaky3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_Shaky3D_initWithDuration, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Shaky3D_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Shaky3D_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + jsb_cocos2d_Shaky3D_class, + js_cocos2dx_Shaky3D_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, "Shaky3D", 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_Shaky3D_class; + p->proto = jsb_cocos2d_Shaky3D_prototype; + p->parentProto = jsb_cocos2d_Grid3DAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Liquid_class; +JSObject *jsb_cocos2d_Liquid_prototype; + +bool js_cocos2dx_Liquid_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Liquid* cobj = (cocos2d::Liquid *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Liquid_setAmplitudeRate : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Liquid_setAmplitudeRate : Error processing arguments"); + cobj->setAmplitudeRate(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Liquid_setAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Liquid_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Liquid* cobj = (cocos2d::Liquid *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Liquid_initWithDuration : Invalid Native Object"); + if (argc == 4) { + double arg0; + cocos2d::Size arg1; + unsigned int arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Liquid_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Liquid_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_Liquid_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Liquid* cobj = (cocos2d::Liquid *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Liquid_getAmplitude : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAmplitude(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Liquid_getAmplitude : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Liquid_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Liquid* cobj = (cocos2d::Liquid *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Liquid_getAmplitudeRate : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAmplitudeRate(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Liquid_getAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Liquid_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Liquid* cobj = (cocos2d::Liquid *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Liquid_setAmplitude : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Liquid_setAmplitude : Error processing arguments"); + cobj->setAmplitude(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Liquid_setAmplitude : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Liquid_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 4) { + double arg0; + cocos2d::Size arg1; + unsigned int arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Liquid_create : Error processing arguments"); + cocos2d::Liquid* ret = cocos2d::Liquid::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Liquid*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Liquid_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Liquid_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Liquid* cobj = new (std::nothrow) cocos2d::Liquid(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Liquid"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Grid3DAction_prototype; + +void js_cocos2d_Liquid_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Liquid)", obj); +} + +void js_register_cocos2dx_Liquid(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Liquid_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Liquid_class->name = "Liquid"; + jsb_cocos2d_Liquid_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Liquid_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Liquid_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Liquid_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Liquid_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Liquid_class->resolve = JS_ResolveStub; + jsb_cocos2d_Liquid_class->convert = JS_ConvertStub; + jsb_cocos2d_Liquid_class->finalize = js_cocos2d_Liquid_finalize; + jsb_cocos2d_Liquid_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setAmplitudeRate", js_cocos2dx_Liquid_setAmplitudeRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithDuration", js_cocos2dx_Liquid_initWithDuration, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAmplitude", js_cocos2dx_Liquid_getAmplitude, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAmplitudeRate", js_cocos2dx_Liquid_getAmplitudeRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAmplitude", js_cocos2dx_Liquid_setAmplitude, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Liquid_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Liquid_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + jsb_cocos2d_Liquid_class, + js_cocos2dx_Liquid_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, "Liquid", 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_Liquid_class; + p->proto = jsb_cocos2d_Liquid_prototype; + p->parentProto = jsb_cocos2d_Grid3DAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Waves_class; +JSObject *jsb_cocos2d_Waves_prototype; + +bool js_cocos2dx_Waves_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Waves* cobj = (cocos2d::Waves *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Waves_setAmplitudeRate : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Waves_setAmplitudeRate : Error processing arguments"); + cobj->setAmplitudeRate(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Waves_setAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Waves_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Waves* cobj = (cocos2d::Waves *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Waves_initWithDuration : Invalid Native Object"); + if (argc == 6) { + double arg0; + cocos2d::Size arg1; + unsigned int arg2; + double arg3; + bool arg4; + bool arg5; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + arg4 = JS::ToBoolean(args.get(4)); + arg5 = JS::ToBoolean(args.get(5)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Waves_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Waves_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 6); + return false; +} +bool js_cocos2dx_Waves_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Waves* cobj = (cocos2d::Waves *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Waves_getAmplitude : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAmplitude(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Waves_getAmplitude : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Waves_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Waves* cobj = (cocos2d::Waves *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Waves_getAmplitudeRate : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAmplitudeRate(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Waves_getAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Waves_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Waves* cobj = (cocos2d::Waves *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Waves_setAmplitude : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Waves_setAmplitude : Error processing arguments"); + cobj->setAmplitude(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Waves_setAmplitude : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Waves_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 6) { + double arg0; + cocos2d::Size arg1; + unsigned int arg2; + double arg3; + bool arg4; + bool arg5; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + arg4 = JS::ToBoolean(args.get(4)); + arg5 = JS::ToBoolean(args.get(5)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Waves_create : Error processing arguments"); + cocos2d::Waves* ret = cocos2d::Waves::create(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Waves*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Waves_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Waves_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Waves* cobj = new (std::nothrow) cocos2d::Waves(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Waves"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Grid3DAction_prototype; + +void js_cocos2d_Waves_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Waves)", obj); +} + +void js_register_cocos2dx_Waves(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Waves_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Waves_class->name = "Waves"; + jsb_cocos2d_Waves_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Waves_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Waves_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Waves_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Waves_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Waves_class->resolve = JS_ResolveStub; + jsb_cocos2d_Waves_class->convert = JS_ConvertStub; + jsb_cocos2d_Waves_class->finalize = js_cocos2d_Waves_finalize; + jsb_cocos2d_Waves_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setAmplitudeRate", js_cocos2dx_Waves_setAmplitudeRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithDuration", js_cocos2dx_Waves_initWithDuration, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAmplitude", js_cocos2dx_Waves_getAmplitude, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAmplitudeRate", js_cocos2dx_Waves_getAmplitudeRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAmplitude", js_cocos2dx_Waves_setAmplitude, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Waves_create, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Waves_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + jsb_cocos2d_Waves_class, + js_cocos2dx_Waves_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, "Waves", 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_Waves_class; + p->proto = jsb_cocos2d_Waves_prototype; + p->parentProto = jsb_cocos2d_Grid3DAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Twirl_class; +JSObject *jsb_cocos2d_Twirl_prototype; + +bool js_cocos2dx_Twirl_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Twirl* cobj = (cocos2d::Twirl *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Twirl_setAmplitudeRate : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Twirl_setAmplitudeRate : Error processing arguments"); + cobj->setAmplitudeRate(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Twirl_setAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Twirl_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Twirl* cobj = (cocos2d::Twirl *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Twirl_initWithDuration : Invalid Native Object"); + if (argc == 5) { + double arg0; + cocos2d::Size arg1; + cocos2d::Vec2 arg2; + unsigned int arg3; + double arg4; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_vector2(cx, args.get(2), &arg2); + ok &= jsval_to_uint32(cx, args.get(3), &arg3); + ok &= JS::ToNumber( cx, args.get(4), &arg4) && !isnan(arg4); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Twirl_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Twirl_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 5); + return false; +} +bool js_cocos2dx_Twirl_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Twirl* cobj = (cocos2d::Twirl *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Twirl_getAmplitudeRate : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAmplitudeRate(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Twirl_getAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Twirl_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Twirl* cobj = (cocos2d::Twirl *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Twirl_setAmplitude : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Twirl_setAmplitude : Error processing arguments"); + cobj->setAmplitude(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Twirl_setAmplitude : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Twirl_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Twirl* cobj = (cocos2d::Twirl *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Twirl_getAmplitude : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAmplitude(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Twirl_getAmplitude : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Twirl_setPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Twirl* cobj = (cocos2d::Twirl *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Twirl_setPosition : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Twirl_setPosition : Error processing arguments"); + cobj->setPosition(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Twirl_setPosition : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Twirl_getPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Twirl* cobj = (cocos2d::Twirl *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Twirl_getPosition : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getPosition(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Twirl_getPosition : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Twirl_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 5) { + double arg0; + cocos2d::Size arg1; + cocos2d::Vec2 arg2; + unsigned int arg3; + double arg4; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_vector2(cx, args.get(2), &arg2); + ok &= jsval_to_uint32(cx, args.get(3), &arg3); + ok &= JS::ToNumber( cx, args.get(4), &arg4) && !isnan(arg4); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Twirl_create : Error processing arguments"); + cocos2d::Twirl* ret = cocos2d::Twirl::create(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Twirl*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Twirl_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Twirl_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Twirl* cobj = new (std::nothrow) cocos2d::Twirl(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Twirl"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Grid3DAction_prototype; + +void js_cocos2d_Twirl_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Twirl)", obj); +} + +void js_register_cocos2dx_Twirl(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Twirl_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Twirl_class->name = "Twirl"; + jsb_cocos2d_Twirl_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Twirl_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Twirl_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Twirl_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Twirl_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Twirl_class->resolve = JS_ResolveStub; + jsb_cocos2d_Twirl_class->convert = JS_ConvertStub; + jsb_cocos2d_Twirl_class->finalize = js_cocos2d_Twirl_finalize; + jsb_cocos2d_Twirl_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setAmplitudeRate", js_cocos2dx_Twirl_setAmplitudeRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithDuration", js_cocos2dx_Twirl_initWithDuration, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAmplitudeRate", js_cocos2dx_Twirl_getAmplitudeRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAmplitude", js_cocos2dx_Twirl_setAmplitude, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAmplitude", js_cocos2dx_Twirl_getAmplitude, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPosition", js_cocos2dx_Twirl_setPosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPosition", js_cocos2dx_Twirl_getPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Twirl_create, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Twirl_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + jsb_cocos2d_Twirl_class, + js_cocos2dx_Twirl_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, "Twirl", 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_Twirl_class; + p->proto = jsb_cocos2d_Twirl_prototype; + p->parentProto = jsb_cocos2d_Grid3DAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_PageTurn3D_class; +JSObject *jsb_cocos2d_PageTurn3D_prototype; + +bool js_cocos2dx_PageTurn3D_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Size arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_PageTurn3D_create : Error processing arguments"); + cocos2d::PageTurn3D* ret = cocos2d::PageTurn3D::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::PageTurn3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_PageTurn3D_create : wrong number of arguments"); + return false; +} + + +extern JSObject *jsb_cocos2d_Grid3DAction_prototype; + +void js_cocos2d_PageTurn3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (PageTurn3D)", obj); +} + +void js_register_cocos2dx_PageTurn3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_PageTurn3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_PageTurn3D_class->name = "PageTurn3D"; + jsb_cocos2d_PageTurn3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_PageTurn3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_PageTurn3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_PageTurn3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_PageTurn3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_PageTurn3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_PageTurn3D_class->convert = JS_ConvertStub; + jsb_cocos2d_PageTurn3D_class->finalize = js_cocos2d_PageTurn3D_finalize; + jsb_cocos2d_PageTurn3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_PageTurn3D_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_PageTurn3D_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Grid3DAction_prototype), + jsb_cocos2d_PageTurn3D_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, "PageTurn3D", 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_PageTurn3D_class; + p->proto = jsb_cocos2d_PageTurn3D_prototype; + p->parentProto = jsb_cocos2d_Grid3DAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ProgressTo_class; +JSObject *jsb_cocos2d_ProgressTo_prototype; + +bool js_cocos2dx_ProgressTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProgressTo* cobj = (cocos2d::ProgressTo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProgressTo_initWithDuration : Invalid Native Object"); + if (argc == 2) { + double arg0; + double arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ProgressTo_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProgressTo_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ProgressTo_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + double arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ProgressTo_create : Error processing arguments"); + cocos2d::ProgressTo* ret = cocos2d::ProgressTo::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ProgressTo*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ProgressTo_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ProgressTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ProgressTo* cobj = new (std::nothrow) cocos2d::ProgressTo(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ProgressTo"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_ProgressTo_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ProgressTo)", obj); +} + +void js_register_cocos2dx_ProgressTo(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ProgressTo_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ProgressTo_class->name = "ProgressTo"; + jsb_cocos2d_ProgressTo_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ProgressTo_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ProgressTo_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ProgressTo_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ProgressTo_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ProgressTo_class->resolve = JS_ResolveStub; + jsb_cocos2d_ProgressTo_class->convert = JS_ConvertStub; + jsb_cocos2d_ProgressTo_class->finalize = js_cocos2d_ProgressTo_finalize; + jsb_cocos2d_ProgressTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_ProgressTo_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ProgressTo_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ProgressTo_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_ProgressTo_class, + js_cocos2dx_ProgressTo_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, "ProgressTo", 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_ProgressTo_class; + p->proto = jsb_cocos2d_ProgressTo_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ProgressFromTo_class; +JSObject *jsb_cocos2d_ProgressFromTo_prototype; + +bool js_cocos2dx_ProgressFromTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProgressFromTo* cobj = (cocos2d::ProgressFromTo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProgressFromTo_initWithDuration : Invalid Native Object"); + if (argc == 3) { + double arg0; + double arg1; + double arg2; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ProgressFromTo_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProgressFromTo_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_ProgressFromTo_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 3) { + double arg0; + double arg1; + double arg2; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ProgressFromTo_create : Error processing arguments"); + cocos2d::ProgressFromTo* ret = cocos2d::ProgressFromTo::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ProgressFromTo*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ProgressFromTo_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ProgressFromTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ProgressFromTo* cobj = new (std::nothrow) cocos2d::ProgressFromTo(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ProgressFromTo"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_ProgressFromTo_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ProgressFromTo)", obj); +} + +void js_register_cocos2dx_ProgressFromTo(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ProgressFromTo_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ProgressFromTo_class->name = "ProgressFromTo"; + jsb_cocos2d_ProgressFromTo_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ProgressFromTo_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ProgressFromTo_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ProgressFromTo_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ProgressFromTo_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ProgressFromTo_class->resolve = JS_ResolveStub; + jsb_cocos2d_ProgressFromTo_class->convert = JS_ConvertStub; + jsb_cocos2d_ProgressFromTo_class->finalize = js_cocos2d_ProgressFromTo_finalize; + jsb_cocos2d_ProgressFromTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_ProgressFromTo_initWithDuration, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ProgressFromTo_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ProgressFromTo_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_ProgressFromTo_class, + js_cocos2dx_ProgressFromTo_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, "ProgressFromTo", 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_ProgressFromTo_class; + p->proto = jsb_cocos2d_ProgressFromTo_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ShakyTiles3D_class; +JSObject *jsb_cocos2d_ShakyTiles3D_prototype; + +bool js_cocos2dx_ShakyTiles3D_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ShakyTiles3D* cobj = (cocos2d::ShakyTiles3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ShakyTiles3D_initWithDuration : Invalid Native Object"); + if (argc == 4) { + double arg0; + cocos2d::Size arg1; + int arg2; + bool arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + arg3 = JS::ToBoolean(args.get(3)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ShakyTiles3D_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ShakyTiles3D_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_ShakyTiles3D_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 4) { + double arg0; + cocos2d::Size arg1; + int arg2; + bool arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + arg3 = JS::ToBoolean(args.get(3)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ShakyTiles3D_create : Error processing arguments"); + cocos2d::ShakyTiles3D* ret = cocos2d::ShakyTiles3D::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ShakyTiles3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ShakyTiles3D_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ShakyTiles3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ShakyTiles3D* cobj = new (std::nothrow) cocos2d::ShakyTiles3D(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ShakyTiles3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; + +void js_cocos2d_ShakyTiles3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ShakyTiles3D)", obj); +} + +void js_register_cocos2dx_ShakyTiles3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ShakyTiles3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ShakyTiles3D_class->name = "ShakyTiles3D"; + jsb_cocos2d_ShakyTiles3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ShakyTiles3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ShakyTiles3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ShakyTiles3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ShakyTiles3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ShakyTiles3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_ShakyTiles3D_class->convert = JS_ConvertStub; + jsb_cocos2d_ShakyTiles3D_class->finalize = js_cocos2d_ShakyTiles3D_finalize; + jsb_cocos2d_ShakyTiles3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_ShakyTiles3D_initWithDuration, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ShakyTiles3D_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ShakyTiles3D_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + jsb_cocos2d_ShakyTiles3D_class, + js_cocos2dx_ShakyTiles3D_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, "ShakyTiles3D", 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_ShakyTiles3D_class; + p->proto = jsb_cocos2d_ShakyTiles3D_prototype; + p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ShatteredTiles3D_class; +JSObject *jsb_cocos2d_ShatteredTiles3D_prototype; + +bool js_cocos2dx_ShatteredTiles3D_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ShatteredTiles3D* cobj = (cocos2d::ShatteredTiles3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ShatteredTiles3D_initWithDuration : Invalid Native Object"); + if (argc == 4) { + double arg0; + cocos2d::Size arg1; + int arg2; + bool arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + arg3 = JS::ToBoolean(args.get(3)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ShatteredTiles3D_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ShatteredTiles3D_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_ShatteredTiles3D_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 4) { + double arg0; + cocos2d::Size arg1; + int arg2; + bool arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + arg3 = JS::ToBoolean(args.get(3)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ShatteredTiles3D_create : Error processing arguments"); + cocos2d::ShatteredTiles3D* ret = cocos2d::ShatteredTiles3D::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ShatteredTiles3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ShatteredTiles3D_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ShatteredTiles3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ShatteredTiles3D* cobj = new (std::nothrow) cocos2d::ShatteredTiles3D(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ShatteredTiles3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; + +void js_cocos2d_ShatteredTiles3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ShatteredTiles3D)", obj); +} + +void js_register_cocos2dx_ShatteredTiles3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ShatteredTiles3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ShatteredTiles3D_class->name = "ShatteredTiles3D"; + jsb_cocos2d_ShatteredTiles3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ShatteredTiles3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ShatteredTiles3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ShatteredTiles3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ShatteredTiles3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ShatteredTiles3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_ShatteredTiles3D_class->convert = JS_ConvertStub; + jsb_cocos2d_ShatteredTiles3D_class->finalize = js_cocos2d_ShatteredTiles3D_finalize; + jsb_cocos2d_ShatteredTiles3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_ShatteredTiles3D_initWithDuration, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ShatteredTiles3D_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ShatteredTiles3D_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + jsb_cocos2d_ShatteredTiles3D_class, + js_cocos2dx_ShatteredTiles3D_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, "ShatteredTiles3D", 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_ShatteredTiles3D_class; + p->proto = jsb_cocos2d_ShatteredTiles3D_prototype; + p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ShuffleTiles_class; +JSObject *jsb_cocos2d_ShuffleTiles_prototype; + +bool js_cocos2dx_ShuffleTiles_placeTile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ShuffleTiles* cobj = (cocos2d::ShuffleTiles *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ShuffleTiles_placeTile : Invalid Native Object"); + if (argc == 2) { + cocos2d::Vec2 arg0; + cocos2d::Tile* arg1; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + #pragma warning NO CONVERSION TO NATIVE FOR Tile* + ok = false; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ShuffleTiles_placeTile : Error processing arguments"); + cobj->placeTile(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ShuffleTiles_placeTile : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ShuffleTiles_shuffle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ShuffleTiles* cobj = (cocos2d::ShuffleTiles *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ShuffleTiles_shuffle : Invalid Native Object"); + if (argc == 2) { + unsigned int* arg0; + unsigned int arg1; + #pragma warning NO CONVERSION TO NATIVE FOR unsigned int* + ok = false; + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ShuffleTiles_shuffle : Error processing arguments"); + cobj->shuffle(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ShuffleTiles_shuffle : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ShuffleTiles_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ShuffleTiles* cobj = (cocos2d::ShuffleTiles *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ShuffleTiles_initWithDuration : Invalid Native Object"); + if (argc == 3) { + double arg0; + cocos2d::Size arg1; + unsigned int arg2; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ShuffleTiles_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ShuffleTiles_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_ShuffleTiles_getDelta(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ShuffleTiles* cobj = (cocos2d::ShuffleTiles *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ShuffleTiles_getDelta : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ShuffleTiles_getDelta : Error processing arguments"); + cocos2d::Size ret = cobj->getDelta(arg0); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ShuffleTiles_getDelta : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ShuffleTiles_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 3) { + double arg0; + cocos2d::Size arg1; + unsigned int arg2; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ShuffleTiles_create : Error processing arguments"); + cocos2d::ShuffleTiles* ret = cocos2d::ShuffleTiles::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ShuffleTiles*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ShuffleTiles_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ShuffleTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ShuffleTiles* cobj = new (std::nothrow) cocos2d::ShuffleTiles(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ShuffleTiles"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; + +void js_cocos2d_ShuffleTiles_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ShuffleTiles)", obj); +} + +void js_register_cocos2dx_ShuffleTiles(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ShuffleTiles_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ShuffleTiles_class->name = "ShuffleTiles"; + jsb_cocos2d_ShuffleTiles_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ShuffleTiles_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ShuffleTiles_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ShuffleTiles_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ShuffleTiles_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ShuffleTiles_class->resolve = JS_ResolveStub; + jsb_cocos2d_ShuffleTiles_class->convert = JS_ConvertStub; + jsb_cocos2d_ShuffleTiles_class->finalize = js_cocos2d_ShuffleTiles_finalize; + jsb_cocos2d_ShuffleTiles_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("placeTile", js_cocos2dx_ShuffleTiles_placeTile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("shuffle", js_cocos2dx_ShuffleTiles_shuffle, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithDuration", js_cocos2dx_ShuffleTiles_initWithDuration, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDelta", js_cocos2dx_ShuffleTiles_getDelta, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ShuffleTiles_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ShuffleTiles_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + jsb_cocos2d_ShuffleTiles_class, + js_cocos2dx_ShuffleTiles_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, "ShuffleTiles", 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_ShuffleTiles_class; + p->proto = jsb_cocos2d_ShuffleTiles_prototype; + p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_FadeOutTRTiles_class; +JSObject *jsb_cocos2d_FadeOutTRTiles_prototype; + +bool js_cocos2dx_FadeOutTRTiles_turnOnTile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FadeOutTRTiles* cobj = (cocos2d::FadeOutTRTiles *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FadeOutTRTiles_turnOnTile : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FadeOutTRTiles_turnOnTile : Error processing arguments"); + cobj->turnOnTile(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FadeOutTRTiles_turnOnTile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FadeOutTRTiles_turnOffTile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FadeOutTRTiles* cobj = (cocos2d::FadeOutTRTiles *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FadeOutTRTiles_turnOffTile : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FadeOutTRTiles_turnOffTile : Error processing arguments"); + cobj->turnOffTile(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FadeOutTRTiles_turnOffTile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_FadeOutTRTiles_transformTile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FadeOutTRTiles* cobj = (cocos2d::FadeOutTRTiles *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FadeOutTRTiles_transformTile : Invalid Native Object"); + if (argc == 2) { + cocos2d::Vec2 arg0; + double arg1; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FadeOutTRTiles_transformTile : Error processing arguments"); + cobj->transformTile(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FadeOutTRTiles_transformTile : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_FadeOutTRTiles_testFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FadeOutTRTiles* cobj = (cocos2d::FadeOutTRTiles *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FadeOutTRTiles_testFunc : Invalid Native Object"); + if (argc == 2) { + cocos2d::Size arg0; + double arg1; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FadeOutTRTiles_testFunc : Error processing arguments"); + double ret = cobj->testFunc(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_FadeOutTRTiles_testFunc : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_FadeOutTRTiles_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Size arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FadeOutTRTiles_create : Error processing arguments"); + cocos2d::FadeOutTRTiles* ret = cocos2d::FadeOutTRTiles::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::FadeOutTRTiles*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_FadeOutTRTiles_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_FadeOutTRTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::FadeOutTRTiles* cobj = new (std::nothrow) cocos2d::FadeOutTRTiles(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FadeOutTRTiles"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; + +void js_cocos2d_FadeOutTRTiles_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (FadeOutTRTiles)", obj); +} + +void js_register_cocos2dx_FadeOutTRTiles(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_FadeOutTRTiles_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_FadeOutTRTiles_class->name = "FadeOutTRTiles"; + jsb_cocos2d_FadeOutTRTiles_class->addProperty = JS_PropertyStub; + jsb_cocos2d_FadeOutTRTiles_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_FadeOutTRTiles_class->getProperty = JS_PropertyStub; + jsb_cocos2d_FadeOutTRTiles_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_FadeOutTRTiles_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_FadeOutTRTiles_class->resolve = JS_ResolveStub; + jsb_cocos2d_FadeOutTRTiles_class->convert = JS_ConvertStub; + jsb_cocos2d_FadeOutTRTiles_class->finalize = js_cocos2d_FadeOutTRTiles_finalize; + jsb_cocos2d_FadeOutTRTiles_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("turnOnTile", js_cocos2dx_FadeOutTRTiles_turnOnTile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("turnOffTile", js_cocos2dx_FadeOutTRTiles_turnOffTile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("transformTile", js_cocos2dx_FadeOutTRTiles_transformTile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("testFunc", js_cocos2dx_FadeOutTRTiles_testFunc, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_FadeOutTRTiles_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_FadeOutTRTiles_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + jsb_cocos2d_FadeOutTRTiles_class, + js_cocos2dx_FadeOutTRTiles_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, "FadeOutTRTiles", 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_FadeOutTRTiles_class; + p->proto = jsb_cocos2d_FadeOutTRTiles_prototype; + p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_FadeOutBLTiles_class; +JSObject *jsb_cocos2d_FadeOutBLTiles_prototype; + +bool js_cocos2dx_FadeOutBLTiles_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Size arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FadeOutBLTiles_create : Error processing arguments"); + cocos2d::FadeOutBLTiles* ret = cocos2d::FadeOutBLTiles::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::FadeOutBLTiles*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_FadeOutBLTiles_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_FadeOutBLTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::FadeOutBLTiles* cobj = new (std::nothrow) cocos2d::FadeOutBLTiles(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FadeOutBLTiles"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_FadeOutTRTiles_prototype; + +void js_cocos2d_FadeOutBLTiles_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (FadeOutBLTiles)", obj); +} + +void js_register_cocos2dx_FadeOutBLTiles(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_FadeOutBLTiles_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_FadeOutBLTiles_class->name = "FadeOutBLTiles"; + jsb_cocos2d_FadeOutBLTiles_class->addProperty = JS_PropertyStub; + jsb_cocos2d_FadeOutBLTiles_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_FadeOutBLTiles_class->getProperty = JS_PropertyStub; + jsb_cocos2d_FadeOutBLTiles_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_FadeOutBLTiles_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_FadeOutBLTiles_class->resolve = JS_ResolveStub; + jsb_cocos2d_FadeOutBLTiles_class->convert = JS_ConvertStub; + jsb_cocos2d_FadeOutBLTiles_class->finalize = js_cocos2d_FadeOutBLTiles_finalize; + jsb_cocos2d_FadeOutBLTiles_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_FadeOutBLTiles_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_FadeOutBLTiles_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_FadeOutTRTiles_prototype), + jsb_cocos2d_FadeOutBLTiles_class, + js_cocos2dx_FadeOutBLTiles_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, "FadeOutBLTiles", 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_FadeOutBLTiles_class; + p->proto = jsb_cocos2d_FadeOutBLTiles_prototype; + p->parentProto = jsb_cocos2d_FadeOutTRTiles_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_FadeOutUpTiles_class; +JSObject *jsb_cocos2d_FadeOutUpTiles_prototype; + +bool js_cocos2dx_FadeOutUpTiles_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Size arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FadeOutUpTiles_create : Error processing arguments"); + cocos2d::FadeOutUpTiles* ret = cocos2d::FadeOutUpTiles::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::FadeOutUpTiles*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_FadeOutUpTiles_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_FadeOutUpTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::FadeOutUpTiles* cobj = new (std::nothrow) cocos2d::FadeOutUpTiles(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FadeOutUpTiles"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_FadeOutTRTiles_prototype; + +void js_cocos2d_FadeOutUpTiles_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (FadeOutUpTiles)", obj); +} + +void js_register_cocos2dx_FadeOutUpTiles(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_FadeOutUpTiles_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_FadeOutUpTiles_class->name = "FadeOutUpTiles"; + jsb_cocos2d_FadeOutUpTiles_class->addProperty = JS_PropertyStub; + jsb_cocos2d_FadeOutUpTiles_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_FadeOutUpTiles_class->getProperty = JS_PropertyStub; + jsb_cocos2d_FadeOutUpTiles_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_FadeOutUpTiles_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_FadeOutUpTiles_class->resolve = JS_ResolveStub; + jsb_cocos2d_FadeOutUpTiles_class->convert = JS_ConvertStub; + jsb_cocos2d_FadeOutUpTiles_class->finalize = js_cocos2d_FadeOutUpTiles_finalize; + jsb_cocos2d_FadeOutUpTiles_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_FadeOutUpTiles_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_FadeOutUpTiles_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_FadeOutTRTiles_prototype), + jsb_cocos2d_FadeOutUpTiles_class, + js_cocos2dx_FadeOutUpTiles_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, "FadeOutUpTiles", 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_FadeOutUpTiles_class; + p->proto = jsb_cocos2d_FadeOutUpTiles_prototype; + p->parentProto = jsb_cocos2d_FadeOutTRTiles_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_FadeOutDownTiles_class; +JSObject *jsb_cocos2d_FadeOutDownTiles_prototype; + +bool js_cocos2dx_FadeOutDownTiles_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Size arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FadeOutDownTiles_create : Error processing arguments"); + cocos2d::FadeOutDownTiles* ret = cocos2d::FadeOutDownTiles::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::FadeOutDownTiles*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_FadeOutDownTiles_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_FadeOutDownTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::FadeOutDownTiles* cobj = new (std::nothrow) cocos2d::FadeOutDownTiles(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::FadeOutDownTiles"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_FadeOutUpTiles_prototype; + +void js_cocos2d_FadeOutDownTiles_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (FadeOutDownTiles)", obj); +} + +void js_register_cocos2dx_FadeOutDownTiles(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_FadeOutDownTiles_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_FadeOutDownTiles_class->name = "FadeOutDownTiles"; + jsb_cocos2d_FadeOutDownTiles_class->addProperty = JS_PropertyStub; + jsb_cocos2d_FadeOutDownTiles_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_FadeOutDownTiles_class->getProperty = JS_PropertyStub; + jsb_cocos2d_FadeOutDownTiles_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_FadeOutDownTiles_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_FadeOutDownTiles_class->resolve = JS_ResolveStub; + jsb_cocos2d_FadeOutDownTiles_class->convert = JS_ConvertStub; + jsb_cocos2d_FadeOutDownTiles_class->finalize = js_cocos2d_FadeOutDownTiles_finalize; + jsb_cocos2d_FadeOutDownTiles_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_FadeOutDownTiles_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_FadeOutDownTiles_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_FadeOutUpTiles_prototype), + jsb_cocos2d_FadeOutDownTiles_class, + js_cocos2dx_FadeOutDownTiles_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, "FadeOutDownTiles", 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_FadeOutDownTiles_class; + p->proto = jsb_cocos2d_FadeOutDownTiles_prototype; + p->parentProto = jsb_cocos2d_FadeOutUpTiles_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TurnOffTiles_class; +JSObject *jsb_cocos2d_TurnOffTiles_prototype; + +bool js_cocos2dx_TurnOffTiles_turnOnTile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TurnOffTiles* cobj = (cocos2d::TurnOffTiles *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TurnOffTiles_turnOnTile : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TurnOffTiles_turnOnTile : Error processing arguments"); + cobj->turnOnTile(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TurnOffTiles_turnOnTile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TurnOffTiles_turnOffTile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TurnOffTiles* cobj = (cocos2d::TurnOffTiles *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TurnOffTiles_turnOffTile : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TurnOffTiles_turnOffTile : Error processing arguments"); + cobj->turnOffTile(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TurnOffTiles_turnOffTile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TurnOffTiles_shuffle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TurnOffTiles* cobj = (cocos2d::TurnOffTiles *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TurnOffTiles_shuffle : Invalid Native Object"); + if (argc == 2) { + unsigned int* arg0; + unsigned int arg1; + #pragma warning NO CONVERSION TO NATIVE FOR unsigned int* + ok = false; + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TurnOffTiles_shuffle : Error processing arguments"); + cobj->shuffle(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TurnOffTiles_shuffle : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_TurnOffTiles_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TurnOffTiles* cobj = (cocos2d::TurnOffTiles *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TurnOffTiles_initWithDuration : Invalid Native Object"); + if (argc == 3) { + double arg0; + cocos2d::Size arg1; + unsigned int arg2; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TurnOffTiles_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TurnOffTiles_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_TurnOffTiles_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 3) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Size arg1; + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + unsigned int arg2; + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cocos2d::TurnOffTiles* ret = cocos2d::TurnOffTiles::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TurnOffTiles*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Size arg1; + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::TurnOffTiles* ret = cocos2d::TurnOffTiles::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TurnOffTiles*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_TurnOffTiles_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TurnOffTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TurnOffTiles* cobj = new (std::nothrow) cocos2d::TurnOffTiles(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TurnOffTiles"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; + +void js_cocos2d_TurnOffTiles_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TurnOffTiles)", obj); +} + +void js_register_cocos2dx_TurnOffTiles(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TurnOffTiles_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TurnOffTiles_class->name = "TurnOffTiles"; + jsb_cocos2d_TurnOffTiles_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TurnOffTiles_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TurnOffTiles_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TurnOffTiles_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TurnOffTiles_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TurnOffTiles_class->resolve = JS_ResolveStub; + jsb_cocos2d_TurnOffTiles_class->convert = JS_ConvertStub; + jsb_cocos2d_TurnOffTiles_class->finalize = js_cocos2d_TurnOffTiles_finalize; + jsb_cocos2d_TurnOffTiles_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("turnOnTile", js_cocos2dx_TurnOffTiles_turnOnTile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("turnOffTile", js_cocos2dx_TurnOffTiles_turnOffTile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("shuffle", js_cocos2dx_TurnOffTiles_shuffle, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithDuration", js_cocos2dx_TurnOffTiles_initWithDuration, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TurnOffTiles_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TurnOffTiles_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + jsb_cocos2d_TurnOffTiles_class, + js_cocos2dx_TurnOffTiles_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, "TurnOffTiles", 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_TurnOffTiles_class; + p->proto = jsb_cocos2d_TurnOffTiles_prototype; + p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_WavesTiles3D_class; +JSObject *jsb_cocos2d_WavesTiles3D_prototype; + +bool js_cocos2dx_WavesTiles3D_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::WavesTiles3D* cobj = (cocos2d::WavesTiles3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_WavesTiles3D_setAmplitudeRate : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_WavesTiles3D_setAmplitudeRate : Error processing arguments"); + cobj->setAmplitudeRate(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_WavesTiles3D_setAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_WavesTiles3D_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::WavesTiles3D* cobj = (cocos2d::WavesTiles3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_WavesTiles3D_initWithDuration : Invalid Native Object"); + if (argc == 4) { + double arg0; + cocos2d::Size arg1; + unsigned int arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_WavesTiles3D_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_WavesTiles3D_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_WavesTiles3D_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::WavesTiles3D* cobj = (cocos2d::WavesTiles3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_WavesTiles3D_getAmplitude : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAmplitude(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_WavesTiles3D_getAmplitude : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_WavesTiles3D_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::WavesTiles3D* cobj = (cocos2d::WavesTiles3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_WavesTiles3D_getAmplitudeRate : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAmplitudeRate(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_WavesTiles3D_getAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_WavesTiles3D_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::WavesTiles3D* cobj = (cocos2d::WavesTiles3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_WavesTiles3D_setAmplitude : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_WavesTiles3D_setAmplitude : Error processing arguments"); + cobj->setAmplitude(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_WavesTiles3D_setAmplitude : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_WavesTiles3D_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 4) { + double arg0; + cocos2d::Size arg1; + unsigned int arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_WavesTiles3D_create : Error processing arguments"); + cocos2d::WavesTiles3D* ret = cocos2d::WavesTiles3D::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::WavesTiles3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_WavesTiles3D_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_WavesTiles3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::WavesTiles3D* cobj = new (std::nothrow) cocos2d::WavesTiles3D(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::WavesTiles3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; + +void js_cocos2d_WavesTiles3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (WavesTiles3D)", obj); +} + +void js_register_cocos2dx_WavesTiles3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_WavesTiles3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_WavesTiles3D_class->name = "WavesTiles3D"; + jsb_cocos2d_WavesTiles3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_WavesTiles3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_WavesTiles3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_WavesTiles3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_WavesTiles3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_WavesTiles3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_WavesTiles3D_class->convert = JS_ConvertStub; + jsb_cocos2d_WavesTiles3D_class->finalize = js_cocos2d_WavesTiles3D_finalize; + jsb_cocos2d_WavesTiles3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setAmplitudeRate", js_cocos2dx_WavesTiles3D_setAmplitudeRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithDuration", js_cocos2dx_WavesTiles3D_initWithDuration, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAmplitude", js_cocos2dx_WavesTiles3D_getAmplitude, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAmplitudeRate", js_cocos2dx_WavesTiles3D_getAmplitudeRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAmplitude", js_cocos2dx_WavesTiles3D_setAmplitude, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_WavesTiles3D_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_WavesTiles3D_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + jsb_cocos2d_WavesTiles3D_class, + js_cocos2dx_WavesTiles3D_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, "WavesTiles3D", 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_WavesTiles3D_class; + p->proto = jsb_cocos2d_WavesTiles3D_prototype; + p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_JumpTiles3D_class; +JSObject *jsb_cocos2d_JumpTiles3D_prototype; + +bool js_cocos2dx_JumpTiles3D_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::JumpTiles3D* cobj = (cocos2d::JumpTiles3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_JumpTiles3D_setAmplitudeRate : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_JumpTiles3D_setAmplitudeRate : Error processing arguments"); + cobj->setAmplitudeRate(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_JumpTiles3D_setAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_JumpTiles3D_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::JumpTiles3D* cobj = (cocos2d::JumpTiles3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_JumpTiles3D_initWithDuration : Invalid Native Object"); + if (argc == 4) { + double arg0; + cocos2d::Size arg1; + unsigned int arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_JumpTiles3D_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_JumpTiles3D_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_JumpTiles3D_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::JumpTiles3D* cobj = (cocos2d::JumpTiles3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_JumpTiles3D_getAmplitude : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAmplitude(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_JumpTiles3D_getAmplitude : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_JumpTiles3D_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::JumpTiles3D* cobj = (cocos2d::JumpTiles3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_JumpTiles3D_getAmplitudeRate : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAmplitudeRate(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_JumpTiles3D_getAmplitudeRate : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_JumpTiles3D_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::JumpTiles3D* cobj = (cocos2d::JumpTiles3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_JumpTiles3D_setAmplitude : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_JumpTiles3D_setAmplitude : Error processing arguments"); + cobj->setAmplitude(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_JumpTiles3D_setAmplitude : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_JumpTiles3D_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 4) { + double arg0; + cocos2d::Size arg1; + unsigned int arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_JumpTiles3D_create : Error processing arguments"); + cocos2d::JumpTiles3D* ret = cocos2d::JumpTiles3D::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::JumpTiles3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_JumpTiles3D_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_JumpTiles3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::JumpTiles3D* cobj = new (std::nothrow) cocos2d::JumpTiles3D(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::JumpTiles3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; + +void js_cocos2d_JumpTiles3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (JumpTiles3D)", obj); +} + +void js_register_cocos2dx_JumpTiles3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_JumpTiles3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_JumpTiles3D_class->name = "JumpTiles3D"; + jsb_cocos2d_JumpTiles3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_JumpTiles3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_JumpTiles3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_JumpTiles3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_JumpTiles3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_JumpTiles3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_JumpTiles3D_class->convert = JS_ConvertStub; + jsb_cocos2d_JumpTiles3D_class->finalize = js_cocos2d_JumpTiles3D_finalize; + jsb_cocos2d_JumpTiles3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setAmplitudeRate", js_cocos2dx_JumpTiles3D_setAmplitudeRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithDuration", js_cocos2dx_JumpTiles3D_initWithDuration, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAmplitude", js_cocos2dx_JumpTiles3D_getAmplitude, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAmplitudeRate", js_cocos2dx_JumpTiles3D_getAmplitudeRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAmplitude", js_cocos2dx_JumpTiles3D_setAmplitude, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_JumpTiles3D_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_JumpTiles3D_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + jsb_cocos2d_JumpTiles3D_class, + js_cocos2dx_JumpTiles3D_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, "JumpTiles3D", 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_JumpTiles3D_class; + p->proto = jsb_cocos2d_JumpTiles3D_prototype; + p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_SplitRows_class; +JSObject *jsb_cocos2d_SplitRows_prototype; + +bool js_cocos2dx_SplitRows_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SplitRows* cobj = (cocos2d::SplitRows *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SplitRows_initWithDuration : Invalid Native Object"); + if (argc == 2) { + double arg0; + unsigned int arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SplitRows_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SplitRows_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_SplitRows_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + unsigned int arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SplitRows_create : Error processing arguments"); + cocos2d::SplitRows* ret = cocos2d::SplitRows::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SplitRows*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_SplitRows_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_SplitRows_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::SplitRows* cobj = new (std::nothrow) cocos2d::SplitRows(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::SplitRows"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; + +void js_cocos2d_SplitRows_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (SplitRows)", obj); +} + +void js_register_cocos2dx_SplitRows(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_SplitRows_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_SplitRows_class->name = "SplitRows"; + jsb_cocos2d_SplitRows_class->addProperty = JS_PropertyStub; + jsb_cocos2d_SplitRows_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_SplitRows_class->getProperty = JS_PropertyStub; + jsb_cocos2d_SplitRows_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_SplitRows_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_SplitRows_class->resolve = JS_ResolveStub; + jsb_cocos2d_SplitRows_class->convert = JS_ConvertStub; + jsb_cocos2d_SplitRows_class->finalize = js_cocos2d_SplitRows_finalize; + jsb_cocos2d_SplitRows_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_SplitRows_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_SplitRows_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_SplitRows_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + jsb_cocos2d_SplitRows_class, + js_cocos2dx_SplitRows_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, "SplitRows", 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_SplitRows_class; + p->proto = jsb_cocos2d_SplitRows_prototype; + p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_SplitCols_class; +JSObject *jsb_cocos2d_SplitCols_prototype; + +bool js_cocos2dx_SplitCols_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SplitCols* cobj = (cocos2d::SplitCols *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SplitCols_initWithDuration : Invalid Native Object"); + if (argc == 2) { + double arg0; + unsigned int arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SplitCols_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SplitCols_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_SplitCols_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + unsigned int arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SplitCols_create : Error processing arguments"); + cocos2d::SplitCols* ret = cocos2d::SplitCols::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SplitCols*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_SplitCols_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_SplitCols_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::SplitCols* cobj = new (std::nothrow) cocos2d::SplitCols(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::SplitCols"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; + +void js_cocos2d_SplitCols_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (SplitCols)", obj); +} + +void js_register_cocos2dx_SplitCols(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_SplitCols_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_SplitCols_class->name = "SplitCols"; + jsb_cocos2d_SplitCols_class->addProperty = JS_PropertyStub; + jsb_cocos2d_SplitCols_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_SplitCols_class->getProperty = JS_PropertyStub; + jsb_cocos2d_SplitCols_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_SplitCols_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_SplitCols_class->resolve = JS_ResolveStub; + jsb_cocos2d_SplitCols_class->convert = JS_ConvertStub; + jsb_cocos2d_SplitCols_class->finalize = js_cocos2d_SplitCols_finalize; + jsb_cocos2d_SplitCols_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_SplitCols_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_SplitCols_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_SplitCols_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TiledGrid3DAction_prototype), + jsb_cocos2d_SplitCols_class, + js_cocos2dx_SplitCols_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, "SplitCols", 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_SplitCols_class; + p->proto = jsb_cocos2d_SplitCols_prototype; + p->parentProto = jsb_cocos2d_TiledGrid3DAction_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ActionTween_class; +JSObject *jsb_cocos2d_ActionTween_prototype; + +bool js_cocos2dx_ActionTween_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionTween* cobj = (cocos2d::ActionTween *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionTween_initWithDuration : Invalid Native Object"); + if (argc == 4) { + double arg0; + std::string arg1; + double arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ActionTween_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionTween_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_ActionTween_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 4) { + double arg0; + std::string arg1; + double arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ActionTween_create : Error processing arguments"); + cocos2d::ActionTween* ret = cocos2d::ActionTween::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionTween*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ActionTween_create : wrong number of arguments"); + return false; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_ActionTween_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ActionTween)", obj); +} + +static bool js_cocos2d_ActionTween_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ActionTween *nobj = new (std::nothrow) cocos2d::ActionTween(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ActionTween"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ActionTween(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ActionTween_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ActionTween_class->name = "ActionTween"; + jsb_cocos2d_ActionTween_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ActionTween_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ActionTween_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ActionTween_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ActionTween_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ActionTween_class->resolve = JS_ResolveStub; + jsb_cocos2d_ActionTween_class->convert = JS_ConvertStub; + jsb_cocos2d_ActionTween_class->finalize = js_cocos2d_ActionTween_finalize; + jsb_cocos2d_ActionTween_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_ActionTween_initWithDuration, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ActionTween_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ActionTween_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ActionTween_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_ActionTween_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, "ActionTween", 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_ActionTween_class; + p->proto = jsb_cocos2d_ActionTween_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_CardinalSplineTo_class; +JSObject *jsb_cocos2d_CardinalSplineTo_prototype; + +bool js_cocos2dx_CardinalSplineTo_getPoints(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::CardinalSplineTo* cobj = (cocos2d::CardinalSplineTo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CardinalSplineTo_getPoints : Invalid Native Object"); + if (argc == 0) { + cocos2d::PointArray* ret = cobj->getPoints(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::PointArray*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_CardinalSplineTo_getPoints : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_CardinalSplineTo_updatePosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::CardinalSplineTo* cobj = (cocos2d::CardinalSplineTo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CardinalSplineTo_updatePosition : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_CardinalSplineTo_updatePosition : Error processing arguments"); + cobj->updatePosition(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_CardinalSplineTo_updatePosition : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_CardinalSplineTo_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::CardinalSplineTo* cobj = new (std::nothrow) cocos2d::CardinalSplineTo(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::CardinalSplineTo"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +void js_cocos2d_CardinalSplineTo_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (CardinalSplineTo)", obj); +} + +void js_register_cocos2dx_CardinalSplineTo(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_CardinalSplineTo_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_CardinalSplineTo_class->name = "CardinalSplineTo"; + jsb_cocos2d_CardinalSplineTo_class->addProperty = JS_PropertyStub; + jsb_cocos2d_CardinalSplineTo_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_CardinalSplineTo_class->getProperty = JS_PropertyStub; + jsb_cocos2d_CardinalSplineTo_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_CardinalSplineTo_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_CardinalSplineTo_class->resolve = JS_ResolveStub; + jsb_cocos2d_CardinalSplineTo_class->convert = JS_ConvertStub; + jsb_cocos2d_CardinalSplineTo_class->finalize = js_cocos2d_CardinalSplineTo_finalize; + jsb_cocos2d_CardinalSplineTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getPoints", js_cocos2dx_CardinalSplineTo_getPoints, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updatePosition", js_cocos2dx_CardinalSplineTo_updatePosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_CardinalSplineTo_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ActionInterval_prototype), + jsb_cocos2d_CardinalSplineTo_class, + js_cocos2dx_CardinalSplineTo_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, "CardinalSplineTo", 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_CardinalSplineTo_class; + p->proto = jsb_cocos2d_CardinalSplineTo_prototype; + p->parentProto = jsb_cocos2d_ActionInterval_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_CardinalSplineBy_class; +JSObject *jsb_cocos2d_CardinalSplineBy_prototype; + +bool js_cocos2dx_CardinalSplineBy_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::CardinalSplineBy* cobj = new (std::nothrow) cocos2d::CardinalSplineBy(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::CardinalSplineBy"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_CardinalSplineTo_prototype; + +void js_cocos2d_CardinalSplineBy_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (CardinalSplineBy)", obj); +} + +void js_register_cocos2dx_CardinalSplineBy(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_CardinalSplineBy_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_CardinalSplineBy_class->name = "CardinalSplineBy"; + jsb_cocos2d_CardinalSplineBy_class->addProperty = JS_PropertyStub; + jsb_cocos2d_CardinalSplineBy_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_CardinalSplineBy_class->getProperty = JS_PropertyStub; + jsb_cocos2d_CardinalSplineBy_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_CardinalSplineBy_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_CardinalSplineBy_class->resolve = JS_ResolveStub; + jsb_cocos2d_CardinalSplineBy_class->convert = JS_ConvertStub; + jsb_cocos2d_CardinalSplineBy_class->finalize = js_cocos2d_CardinalSplineBy_finalize; + jsb_cocos2d_CardinalSplineBy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_CardinalSplineBy_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_CardinalSplineTo_prototype), + jsb_cocos2d_CardinalSplineBy_class, + js_cocos2dx_CardinalSplineBy_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, "CardinalSplineBy", 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_CardinalSplineBy_class; + p->proto = jsb_cocos2d_CardinalSplineBy_prototype; + p->parentProto = jsb_cocos2d_CardinalSplineTo_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_CatmullRomTo_class; +JSObject *jsb_cocos2d_CatmullRomTo_prototype; + + +extern JSObject *jsb_cocos2d_CardinalSplineTo_prototype; + +void js_cocos2d_CatmullRomTo_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (CatmullRomTo)", obj); +} + +void js_register_cocos2dx_CatmullRomTo(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_CatmullRomTo_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_CatmullRomTo_class->name = "CatmullRomTo"; + jsb_cocos2d_CatmullRomTo_class->addProperty = JS_PropertyStub; + jsb_cocos2d_CatmullRomTo_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_CatmullRomTo_class->getProperty = JS_PropertyStub; + jsb_cocos2d_CatmullRomTo_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_CatmullRomTo_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_CatmullRomTo_class->resolve = JS_ResolveStub; + jsb_cocos2d_CatmullRomTo_class->convert = JS_ConvertStub; + jsb_cocos2d_CatmullRomTo_class->finalize = js_cocos2d_CatmullRomTo_finalize; + jsb_cocos2d_CatmullRomTo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_CatmullRomTo_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_CardinalSplineTo_prototype), + jsb_cocos2d_CatmullRomTo_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, "CatmullRomTo", 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_CatmullRomTo_class; + p->proto = jsb_cocos2d_CatmullRomTo_prototype; + p->parentProto = jsb_cocos2d_CardinalSplineTo_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_CatmullRomBy_class; +JSObject *jsb_cocos2d_CatmullRomBy_prototype; + + +extern JSObject *jsb_cocos2d_CardinalSplineBy_prototype; + +void js_cocos2d_CatmullRomBy_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (CatmullRomBy)", obj); +} + +void js_register_cocos2dx_CatmullRomBy(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_CatmullRomBy_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_CatmullRomBy_class->name = "CatmullRomBy"; + jsb_cocos2d_CatmullRomBy_class->addProperty = JS_PropertyStub; + jsb_cocos2d_CatmullRomBy_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_CatmullRomBy_class->getProperty = JS_PropertyStub; + jsb_cocos2d_CatmullRomBy_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_CatmullRomBy_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_CatmullRomBy_class->resolve = JS_ResolveStub; + jsb_cocos2d_CatmullRomBy_class->convert = JS_ConvertStub; + jsb_cocos2d_CatmullRomBy_class->finalize = js_cocos2d_CatmullRomBy_finalize; + jsb_cocos2d_CatmullRomBy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_CatmullRomBy_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_CardinalSplineBy_prototype), + jsb_cocos2d_CatmullRomBy_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, "CatmullRomBy", 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_CatmullRomBy_class; + p->proto = jsb_cocos2d_CatmullRomBy_prototype; + p->parentProto = jsb_cocos2d_CardinalSplineBy_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ProtectedNode_class; +JSObject *jsb_cocos2d_ProtectedNode_prototype; + +bool js_cocos2dx_ProtectedNode_addProtectedChild(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ProtectedNode* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ProtectedNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProtectedNode_addProtectedChild : Invalid Native Object"); + do { + if (argc == 2) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cobj->addProtectedChild(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cobj->addProtectedChild(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 3) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + int arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + cobj->addProtectedChild(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ProtectedNode_addProtectedChild : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ProtectedNode_disableCascadeColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProtectedNode* cobj = (cocos2d::ProtectedNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProtectedNode_disableCascadeColor : Invalid Native Object"); + if (argc == 0) { + cobj->disableCascadeColor(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProtectedNode_disableCascadeColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ProtectedNode_removeProtectedChildByTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProtectedNode* cobj = (cocos2d::ProtectedNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProtectedNode_removeProtectedChildByTag : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ProtectedNode_removeProtectedChildByTag : Error processing arguments"); + cobj->removeProtectedChildByTag(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + int arg0; + bool arg1; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ProtectedNode_removeProtectedChildByTag : Error processing arguments"); + cobj->removeProtectedChildByTag(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProtectedNode_removeProtectedChildByTag : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ProtectedNode_reorderProtectedChild(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProtectedNode* cobj = (cocos2d::ProtectedNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProtectedNode_reorderProtectedChild : Invalid Native Object"); + if (argc == 2) { + cocos2d::Node* arg0; + int arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ProtectedNode_reorderProtectedChild : Error processing arguments"); + cobj->reorderProtectedChild(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProtectedNode_reorderProtectedChild : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ProtectedNode_removeAllProtectedChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProtectedNode* cobj = (cocos2d::ProtectedNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProtectedNode_removeAllProtectedChildrenWithCleanup : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ProtectedNode_removeAllProtectedChildrenWithCleanup : Error processing arguments"); + cobj->removeAllProtectedChildrenWithCleanup(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProtectedNode_removeAllProtectedChildrenWithCleanup : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ProtectedNode_disableCascadeOpacity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProtectedNode* cobj = (cocos2d::ProtectedNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProtectedNode_disableCascadeOpacity : Invalid Native Object"); + if (argc == 0) { + cobj->disableCascadeOpacity(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProtectedNode_disableCascadeOpacity : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ProtectedNode_sortAllProtectedChildren(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProtectedNode* cobj = (cocos2d::ProtectedNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProtectedNode_sortAllProtectedChildren : Invalid Native Object"); + if (argc == 0) { + cobj->sortAllProtectedChildren(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProtectedNode_sortAllProtectedChildren : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ProtectedNode_getProtectedChildByTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProtectedNode* cobj = (cocos2d::ProtectedNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProtectedNode_getProtectedChildByTag : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ProtectedNode_getProtectedChildByTag : Error processing arguments"); + cocos2d::Node* ret = cobj->getProtectedChildByTag(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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProtectedNode_getProtectedChildByTag : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ProtectedNode_removeProtectedChild(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProtectedNode* cobj = (cocos2d::ProtectedNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProtectedNode_removeProtectedChild : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ProtectedNode_removeProtectedChild : Error processing arguments"); + cobj->removeProtectedChild(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + cocos2d::Node* arg0; + bool arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ProtectedNode_removeProtectedChild : Error processing arguments"); + cobj->removeProtectedChild(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProtectedNode_removeProtectedChild : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ProtectedNode_removeAllProtectedChildren(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProtectedNode* cobj = (cocos2d::ProtectedNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProtectedNode_removeAllProtectedChildren : Invalid Native Object"); + if (argc == 0) { + cobj->removeAllProtectedChildren(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProtectedNode_removeAllProtectedChildren : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ProtectedNode_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ProtectedNode* ret = cocos2d::ProtectedNode::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ProtectedNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ProtectedNode_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ProtectedNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ProtectedNode* cobj = new (std::nothrow) cocos2d::ProtectedNode(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ProtectedNode"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_ProtectedNode_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ProtectedNode)", obj); +} + +void js_register_cocos2dx_ProtectedNode(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ProtectedNode_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ProtectedNode_class->name = "ProtectedNode"; + jsb_cocos2d_ProtectedNode_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ProtectedNode_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ProtectedNode_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ProtectedNode_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ProtectedNode_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ProtectedNode_class->resolve = JS_ResolveStub; + jsb_cocos2d_ProtectedNode_class->convert = JS_ConvertStub; + jsb_cocos2d_ProtectedNode_class->finalize = js_cocos2d_ProtectedNode_finalize; + jsb_cocos2d_ProtectedNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("addProtectedChild", js_cocos2dx_ProtectedNode_addProtectedChild, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("disableCascadeColor", js_cocos2dx_ProtectedNode_disableCascadeColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeProtectedChildByTag", js_cocos2dx_ProtectedNode_removeProtectedChildByTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("reorderProtectedChild", js_cocos2dx_ProtectedNode_reorderProtectedChild, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllProtectedChildrenWithCleanup", js_cocos2dx_ProtectedNode_removeAllProtectedChildrenWithCleanup, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("disableCascadeOpacity", js_cocos2dx_ProtectedNode_disableCascadeOpacity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("sortAllProtectedChildren", js_cocos2dx_ProtectedNode_sortAllProtectedChildren, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getProtectedChildByTag", js_cocos2dx_ProtectedNode_getProtectedChildByTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeProtectedChild", js_cocos2dx_ProtectedNode_removeProtectedChild, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllProtectedChildren", js_cocos2dx_ProtectedNode_removeAllProtectedChildren, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ProtectedNode_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ProtectedNode_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_ProtectedNode_class, + js_cocos2dx_ProtectedNode_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, "ProtectedNode", 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_ProtectedNode_class; + p->proto = jsb_cocos2d_ProtectedNode_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_GLProgramState_class; +JSObject *jsb_cocos2d_GLProgramState_prototype; + +bool js_cocos2dx_GLProgramState_setUniformCallback(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::GLProgramState* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + 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, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + std::function arg1; + do { + if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + auto lambda = [=](cocos2d::GLProgram* larg0, cocos2d::Uniform* larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + JS::RootedValue rval(cx); + 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); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::function arg1; + do { + if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + auto lambda = [=](cocos2d::GLProgram* larg0, cocos2d::Uniform* larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + JS::RootedValue rval(cx); + 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); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setUniformCallback : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgramState_getVertexAttribsFlags(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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_setUniformVec2(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::GLProgramState* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + 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, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec2 arg1; + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformVec2(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec2 arg1; + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformVec2(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setUniformVec2 : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgramState_setUniformVec3(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::GLProgramState* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + 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, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec3 arg1; + ok &= jsval_to_vector3(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformVec3(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec3 arg1; + ok &= jsval_to_vector3(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformVec3(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setUniformVec3 : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgramState_setVertexAttribCallback(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), &arg0); + do { + if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + auto lambda = [=](cocos2d::VertexAttrib* larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + JS::RootedValue rval(cx); + 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); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgramState_apply : Error processing arguments"); + cobj->apply(arg0); + args.rval().setUndefined(); + 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_applyGLProgram(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgramState_applyGLProgram : Error processing arguments"); + cobj->applyGLProgram(arg0); + args.rval().setUndefined(); + 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_setUniformInt(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::GLProgramState* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + 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, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cobj->setUniformInt(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cobj->setUniformInt(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setUniformInt : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgramState_setUniformVec2v(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::GLProgramState* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformVec2v : Invalid Native Object"); + do { + if (argc == 3) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + const cocos2d::Vec2* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (const cocos2d::Vec2*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + ssize_t arg2; + ok &= jsval_to_ssize(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cobj->setUniformVec2v(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + const cocos2d::Vec2* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (const cocos2d::Vec2*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + ssize_t arg2; + ok &= jsval_to_ssize(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cobj->setUniformVec2v(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setUniformVec2v : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgramState_getUniformCount(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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(); + args.rval().setUndefined(); + return true; + } + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgramState_applyAttributes : Error processing arguments"); + cobj->applyAttributes(arg0); + args.rval().setUndefined(); + 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_clone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_clone : Invalid Native Object"); + if (argc == 0) { + cocos2d::GLProgramState* ret = cobj->clone(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_clone : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLProgramState_setGLProgram(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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 (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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); + args.rval().setUndefined(); + 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_setUniformFloatv(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::GLProgramState* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformFloatv : Invalid Native Object"); + do { + if (argc == 3) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + const float* arg1; + #pragma warning NO CONVERSION TO NATIVE FOR float* + ok = false; + if (!ok) { ok = true; break; } + ssize_t arg2; + ok &= jsval_to_ssize(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cobj->setUniformFloatv(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + const float* arg1; + #pragma warning NO CONVERSION TO NATIVE FOR float* + ok = false; + if (!ok) { ok = true; break; } + ssize_t arg2; + ok &= jsval_to_ssize(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cobj->setUniformFloatv(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setUniformFloatv : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgramState_getGLProgram(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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_setUniformTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::GLProgramState* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + 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, args.get(0), &arg0); + if (!ok) { ok = true; break; } + unsigned int arg1; + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformTexture(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Texture2D* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + 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); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 2) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + cocos2d::Texture2D* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + 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); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 2) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + unsigned int arg1; + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformTexture(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setUniformTexture : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgramState_applyUniforms(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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(); + args.rval().setUndefined(); + 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_setUniformFloat(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::GLProgramState* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + 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, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + cobj->setUniformFloat(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + cobj->setUniformFloat(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setUniformFloat : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgramState_setUniformMat4(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::GLProgramState* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + 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, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + cocos2d::Mat4 arg1; + ok &= jsval_to_matrix(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformMat4(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Mat4 arg1; + ok &= jsval_to_matrix(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformMat4(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setUniformMat4 : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgramState_setUniformVec3v(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::GLProgramState* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformVec3v : Invalid Native Object"); + do { + if (argc == 3) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + const cocos2d::Vec3* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (const cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + ssize_t arg2; + ok &= jsval_to_ssize(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cobj->setUniformVec3v(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + const cocos2d::Vec3* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (const cocos2d::Vec3*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + ssize_t arg2; + ok &= jsval_to_ssize(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cobj->setUniformVec3v(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setUniformVec3v : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgramState_getVertexAttribCount(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::GLProgram* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::GLProgram* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_GLProgramState_getOrCreateWithGLProgram : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_GLProgramState_getOrCreateWithShaders(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 3) { + std::string arg0; + std::string arg1; + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgramState_getOrCreateWithShaders : Error processing arguments"); + cocos2d::GLProgramState* ret = cocos2d::GLProgramState::getOrCreateWithShaders(arg0, arg1, arg2); + 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); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_GLProgramState_getOrCreateWithShaders : 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, JS::HandleObject 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[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setUniformCallback", js_cocos2dx_GLProgramState_setUniformCallback, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVertexAttribsFlags", js_cocos2dx_GLProgramState_getVertexAttribsFlags, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUniformVec2", js_cocos2dx_GLProgramState_setUniformVec2, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUniformVec3", js_cocos2dx_GLProgramState_setUniformVec3, 2, 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("applyGLProgram", js_cocos2dx_GLProgramState_applyGLProgram, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUniformInt", js_cocos2dx_GLProgramState_setUniformInt, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUniformVec2v", js_cocos2dx_GLProgramState_setUniformVec2v, 3, 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("clone", js_cocos2dx_GLProgramState_clone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setGLProgram", js_cocos2dx_GLProgramState_setGLProgram, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUniformFloatv", js_cocos2dx_GLProgramState_setUniformFloatv, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getGLProgram", js_cocos2dx_GLProgramState_getGLProgram, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUniformTexture", js_cocos2dx_GLProgramState_setUniformTexture, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("applyUniforms", js_cocos2dx_GLProgramState_applyUniforms, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUniformFloat", js_cocos2dx_GLProgramState_setUniformFloat, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUniformMat4", js_cocos2dx_GLProgramState_setUniformMat4, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUniformVec3v", js_cocos2dx_GLProgramState_setUniformVec3v, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVertexAttribCount", js_cocos2dx_GLProgramState_getVertexAttribCount, 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_FN("getOrCreateWithShaders", js_cocos2dx_GLProgramState_getOrCreateWithShaders, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_GLProgramState_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // 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; + +bool js_cocos2dx_AtlasNode_updateAtlasValues(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AtlasNode* cobj = (cocos2d::AtlasNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AtlasNode_updateAtlasValues : Invalid Native Object"); + if (argc == 0) { + cobj->updateAtlasValues(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AtlasNode_updateAtlasValues : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_AtlasNode_initWithTileFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AtlasNode* cobj = (cocos2d::AtlasNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AtlasNode_initWithTileFile : Invalid Native Object"); + if (argc == 4) { + std::string arg0; + int arg1; + int arg2; + int arg3; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AtlasNode_initWithTileFile : Error processing arguments"); + bool ret = cobj->initWithTileFile(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AtlasNode_initWithTileFile : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_AtlasNode_getTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AtlasNode* cobj = (cocos2d::AtlasNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AtlasNode_getTexture : Invalid Native Object"); + if (argc == 0) { + cocos2d::Texture2D* ret = cobj->getTexture(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AtlasNode_getTexture : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_AtlasNode_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AtlasNode* cobj = (cocos2d::AtlasNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AtlasNode_setTextureAtlas : Invalid Native Object"); + if (argc == 1) { + cocos2d::TextureAtlas* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::TextureAtlas*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AtlasNode_setTextureAtlas : Error processing arguments"); + cobj->setTextureAtlas(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AtlasNode_setTextureAtlas : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_AtlasNode_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AtlasNode* cobj = (cocos2d::AtlasNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AtlasNode_setBlendFunc : Invalid Native Object"); + if (argc == 1) { + cocos2d::BlendFunc arg0; + ok &= jsval_to_blendfunc(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AtlasNode_setBlendFunc : Error processing arguments"); + cobj->setBlendFunc(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AtlasNode_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_AtlasNode_getTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AtlasNode* cobj = (cocos2d::AtlasNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AtlasNode_getTextureAtlas : Invalid Native Object"); + if (argc == 0) { + cocos2d::TextureAtlas* ret = cobj->getTextureAtlas(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TextureAtlas*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AtlasNode_getTextureAtlas : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_AtlasNode_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AtlasNode* cobj = (cocos2d::AtlasNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AtlasNode_getBlendFunc : Invalid Native Object"); + if (argc == 0) { + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AtlasNode_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_AtlasNode_getQuadsToDraw(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AtlasNode* cobj = (cocos2d::AtlasNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AtlasNode_getQuadsToDraw : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getQuadsToDraw(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AtlasNode_getQuadsToDraw : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_AtlasNode_setTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AtlasNode* cobj = (cocos2d::AtlasNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AtlasNode_setTexture : Invalid Native Object"); + if (argc == 1) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AtlasNode_setTexture : Error processing arguments"); + cobj->setTexture(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AtlasNode_setTexture : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_AtlasNode_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AtlasNode* cobj = (cocos2d::AtlasNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AtlasNode_initWithTexture : Invalid Native Object"); + if (argc == 4) { + cocos2d::Texture2D* arg0; + int arg1; + int arg2; + int arg3; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AtlasNode_initWithTexture : Error processing arguments"); + bool ret = cobj->initWithTexture(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AtlasNode_initWithTexture : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_AtlasNode_setQuadsToDraw(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AtlasNode* cobj = (cocos2d::AtlasNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AtlasNode_setQuadsToDraw : Invalid Native Object"); + if (argc == 1) { + ssize_t arg0; + ok &= jsval_to_ssize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AtlasNode_setQuadsToDraw : Error processing arguments"); + cobj->setQuadsToDraw(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AtlasNode_setQuadsToDraw : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_AtlasNode_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 4) { + std::string arg0; + int arg1; + int arg2; + int arg3; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AtlasNode_create : Error processing arguments"); + cocos2d::AtlasNode* ret = cocos2d::AtlasNode::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::AtlasNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_AtlasNode_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_AtlasNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::AtlasNode* cobj = new (std::nothrow) cocos2d::AtlasNode(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::AtlasNode"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_AtlasNode_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (AtlasNode)", obj); +} + +void js_register_cocos2dx_AtlasNode(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_AtlasNode_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_AtlasNode_class->name = "AtlasNode"; + jsb_cocos2d_AtlasNode_class->addProperty = JS_PropertyStub; + jsb_cocos2d_AtlasNode_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_AtlasNode_class->getProperty = JS_PropertyStub; + jsb_cocos2d_AtlasNode_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_AtlasNode_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_AtlasNode_class->resolve = JS_ResolveStub; + jsb_cocos2d_AtlasNode_class->convert = JS_ConvertStub; + jsb_cocos2d_AtlasNode_class->finalize = js_cocos2d_AtlasNode_finalize; + jsb_cocos2d_AtlasNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("updateAtlasValues", js_cocos2dx_AtlasNode_updateAtlasValues, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTileFile", js_cocos2dx_AtlasNode_initWithTileFile, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTexture", js_cocos2dx_AtlasNode_getTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTextureAtlas", js_cocos2dx_AtlasNode_setTextureAtlas, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBlendFunc", js_cocos2dx_AtlasNode_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTextureAtlas", js_cocos2dx_AtlasNode_getTextureAtlas, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBlendFunc", js_cocos2dx_AtlasNode_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getQuadsToDraw", js_cocos2dx_AtlasNode_getQuadsToDraw, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTexture", js_cocos2dx_AtlasNode_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTexture", js_cocos2dx_AtlasNode_initWithTexture, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setQuadsToDraw", js_cocos2dx_AtlasNode_setQuadsToDraw, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_AtlasNode_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_AtlasNode_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_AtlasNode_class, + js_cocos2dx_AtlasNode_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, "AtlasNode", 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_AtlasNode_class; + p->proto = jsb_cocos2d_AtlasNode_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_DrawNode_class; +JSObject *jsb_cocos2d_DrawNode_prototype; + +bool js_cocos2dx_DrawNode_drawLine(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawLine : Invalid Native Object"); + if (argc == 3) { + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; + cocos2d::Color4F arg2; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + ok &= jsval_to_cccolor4f(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode_drawLine : Error processing arguments"); + cobj->drawLine(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode_drawLine : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_DrawNode_drawPoints(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::DrawNode* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawPoints : Invalid Native Object"); + do { + if (argc == 4) { + const cocos2d::Vec2* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (const cocos2d::Vec2*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + unsigned int arg1; + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::Color4F arg3; + ok &= jsval_to_cccolor4f(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + cobj->drawPoints(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 3) { + const cocos2d::Vec2* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (const cocos2d::Vec2*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + unsigned int arg1; + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::Color4F arg2; + ok &= jsval_to_cccolor4f(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cobj->drawPoints(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_DrawNode_drawPoints : wrong number of arguments"); + return false; +} +bool js_cocos2dx_DrawNode_drawRect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::DrawNode* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawRect : Invalid Native Object"); + do { + if (argc == 5) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec2 arg1; + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::Vec2 arg2; + ok &= jsval_to_vector2(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cocos2d::Vec2 arg3; + ok &= jsval_to_vector2(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + cocos2d::Color4F arg4; + ok &= jsval_to_cccolor4f(cx, args.get(4), &arg4); + if (!ok) { ok = true; break; } + cobj->drawRect(arg0, arg1, arg2, arg3, arg4); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 3) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec2 arg1; + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::Color4F arg2; + ok &= jsval_to_cccolor4f(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cobj->drawRect(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_DrawNode_drawRect : wrong number of arguments"); + return false; +} +bool js_cocos2dx_DrawNode_drawSolidCircle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::DrawNode* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawSolidCircle : Invalid Native Object"); + do { + if (argc == 5) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + unsigned int arg3; + ok &= jsval_to_uint32(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + cocos2d::Color4F arg4; + ok &= jsval_to_cccolor4f(cx, args.get(4), &arg4); + if (!ok) { ok = true; break; } + cobj->drawSolidCircle(arg0, arg1, arg2, arg3, arg4); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 7) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + unsigned int arg3; + ok &= jsval_to_uint32(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + double arg4; + ok &= JS::ToNumber( cx, args.get(4), &arg4) && !isnan(arg4); + if (!ok) { ok = true; break; } + double arg5; + ok &= JS::ToNumber( cx, args.get(5), &arg5) && !isnan(arg5); + if (!ok) { ok = true; break; } + cocos2d::Color4F arg6; + ok &= jsval_to_cccolor4f(cx, args.get(6), &arg6); + if (!ok) { ok = true; break; } + cobj->drawSolidCircle(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_DrawNode_drawSolidCircle : wrong number of arguments"); + return false; +} +bool js_cocos2dx_DrawNode_onDrawGLPoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_onDrawGLPoint : Invalid Native Object"); + if (argc == 2) { + cocos2d::Mat4 arg0; + unsigned int arg1; + ok &= jsval_to_matrix(cx, args.get(0), &arg0); + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode_onDrawGLPoint : Error processing arguments"); + cobj->onDrawGLPoint(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode_onDrawGLPoint : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_DrawNode_drawDot(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawDot : Invalid Native Object"); + if (argc == 3) { + cocos2d::Vec2 arg0; + double arg1; + cocos2d::Color4F arg2; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= jsval_to_cccolor4f(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode_drawDot : Error processing arguments"); + cobj->drawDot(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode_drawDot : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_DrawNode_drawCatmullRom(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawCatmullRom : Invalid Native Object"); + if (argc == 3) { + cocos2d::PointArray* arg0; + unsigned int arg1; + cocos2d::Color4F arg2; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::PointArray*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + ok &= jsval_to_cccolor4f(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode_drawCatmullRom : Error processing arguments"); + cobj->drawCatmullRom(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode_drawCatmullRom : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_DrawNode_drawSegment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawSegment : Invalid Native Object"); + if (argc == 4) { + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; + double arg2; + cocos2d::Color4F arg3; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= jsval_to_cccolor4f(cx, args.get(3), &arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode_drawSegment : Error processing arguments"); + cobj->drawSegment(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode_drawSegment : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_DrawNode_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_getBlendFunc : Invalid Native Object"); + if (argc == 0) { + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_DrawNode_onDraw(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_onDraw : Invalid Native Object"); + if (argc == 2) { + cocos2d::Mat4 arg0; + unsigned int arg1; + ok &= jsval_to_matrix(cx, args.get(0), &arg0); + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode_onDraw : Error processing arguments"); + cobj->onDraw(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode_onDraw : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_DrawNode_drawCircle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::DrawNode* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawCircle : Invalid Native Object"); + do { + if (argc == 6) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + unsigned int arg3; + ok &= jsval_to_uint32(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + bool arg4; + arg4 = JS::ToBoolean(args.get(4)); + cocos2d::Color4F arg5; + ok &= jsval_to_cccolor4f(cx, args.get(5), &arg5); + if (!ok) { ok = true; break; } + cobj->drawCircle(arg0, arg1, arg2, arg3, arg4, arg5); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 8) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + unsigned int arg3; + ok &= jsval_to_uint32(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + bool arg4; + arg4 = JS::ToBoolean(args.get(4)); + double arg5; + ok &= JS::ToNumber( cx, args.get(5), &arg5) && !isnan(arg5); + if (!ok) { ok = true; break; } + double arg6; + ok &= JS::ToNumber( cx, args.get(6), &arg6) && !isnan(arg6); + if (!ok) { ok = true; break; } + cocos2d::Color4F arg7; + ok &= jsval_to_cccolor4f(cx, args.get(7), &arg7); + if (!ok) { ok = true; break; } + cobj->drawCircle(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_DrawNode_drawCircle : wrong number of arguments"); + return false; +} +bool js_cocos2dx_DrawNode_drawQuadBezier(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawQuadBezier : Invalid Native Object"); + if (argc == 5) { + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; + cocos2d::Vec2 arg2; + unsigned int arg3; + cocos2d::Color4F arg4; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + ok &= jsval_to_vector2(cx, args.get(2), &arg2); + ok &= jsval_to_uint32(cx, args.get(3), &arg3); + ok &= jsval_to_cccolor4f(cx, args.get(4), &arg4); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode_drawQuadBezier : Error processing arguments"); + cobj->drawQuadBezier(arg0, arg1, arg2, arg3, arg4); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode_drawQuadBezier : wrong number of arguments: %d, was expecting %d", argc, 5); + return false; +} +bool js_cocos2dx_DrawNode_onDrawGLLine(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_onDrawGLLine : Invalid Native Object"); + if (argc == 2) { + cocos2d::Mat4 arg0; + unsigned int arg1; + ok &= jsval_to_matrix(cx, args.get(0), &arg0); + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode_onDrawGLLine : Error processing arguments"); + cobj->onDrawGLLine(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode_onDrawGLLine : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_DrawNode_drawSolidPoly(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawSolidPoly : Invalid Native Object"); + if (argc == 3) { + const cocos2d::Vec2* arg0; + unsigned int arg1; + cocos2d::Color4F arg2; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (const cocos2d::Vec2*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + ok &= jsval_to_cccolor4f(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode_drawSolidPoly : Error processing arguments"); + cobj->drawSolidPoly(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode_drawSolidPoly : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_DrawNode_drawTriangle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawTriangle : Invalid Native Object"); + if (argc == 4) { + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; + cocos2d::Vec2 arg2; + cocos2d::Color4F arg3; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + ok &= jsval_to_vector2(cx, args.get(2), &arg2); + ok &= jsval_to_cccolor4f(cx, args.get(3), &arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode_drawTriangle : Error processing arguments"); + cobj->drawTriangle(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode_drawTriangle : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_DrawNode_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_setBlendFunc : Invalid Native Object"); + if (argc == 1) { + cocos2d::BlendFunc arg0; + ok &= jsval_to_blendfunc(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode_setBlendFunc : Error processing arguments"); + cobj->setBlendFunc(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_DrawNode_clear(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_clear : Invalid Native Object"); + if (argc == 0) { + cobj->clear(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode_clear : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_DrawNode_drawCardinalSpline(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawCardinalSpline : Invalid Native Object"); + if (argc == 4) { + cocos2d::PointArray* arg0; + double arg1; + unsigned int arg2; + cocos2d::Color4F arg3; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::PointArray*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + ok &= jsval_to_cccolor4f(cx, args.get(3), &arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode_drawCardinalSpline : Error processing arguments"); + cobj->drawCardinalSpline(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode_drawCardinalSpline : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_DrawNode_drawSolidRect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawSolidRect : Invalid Native Object"); + if (argc == 3) { + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; + cocos2d::Color4F arg2; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + ok &= jsval_to_cccolor4f(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode_drawSolidRect : Error processing arguments"); + cobj->drawSolidRect(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode_drawSolidRect : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_DrawNode_drawPoly(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawPoly : Invalid Native Object"); + if (argc == 4) { + const cocos2d::Vec2* arg0; + unsigned int arg1; + bool arg2; + cocos2d::Color4F arg3; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (const cocos2d::Vec2*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + arg2 = JS::ToBoolean(args.get(2)); + ok &= jsval_to_cccolor4f(cx, args.get(3), &arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode_drawPoly : Error processing arguments"); + cobj->drawPoly(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode_drawPoly : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_DrawNode_drawPoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawPoint : Invalid Native Object"); + if (argc == 3) { + cocos2d::Vec2 arg0; + double arg1; + cocos2d::Color4F arg2; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= jsval_to_cccolor4f(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode_drawPoint : Error processing arguments"); + cobj->drawPoint(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode_drawPoint : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_DrawNode_drawCubicBezier(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode* cobj = (cocos2d::DrawNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode_drawCubicBezier : Invalid Native Object"); + if (argc == 6) { + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; + cocos2d::Vec2 arg2; + cocos2d::Vec2 arg3; + unsigned int arg4; + cocos2d::Color4F arg5; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + ok &= jsval_to_vector2(cx, args.get(2), &arg2); + ok &= jsval_to_vector2(cx, args.get(3), &arg3); + ok &= jsval_to_uint32(cx, args.get(4), &arg4); + ok &= jsval_to_cccolor4f(cx, args.get(5), &arg5); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode_drawCubicBezier : Error processing arguments"); + cobj->drawCubicBezier(arg0, arg1, arg2, arg3, arg4, arg5); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode_drawCubicBezier : wrong number of arguments: %d, was expecting %d", argc, 6); + return false; +} +bool js_cocos2dx_DrawNode_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::DrawNode* ret = cocos2d::DrawNode::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::DrawNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_DrawNode_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_DrawNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::DrawNode* cobj = new (std::nothrow) cocos2d::DrawNode(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::DrawNode"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_DrawNode_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (DrawNode)", obj); +} + +static bool js_cocos2d_DrawNode_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::DrawNode *nobj = new (std::nothrow) cocos2d::DrawNode(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::DrawNode"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_DrawNode(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_DrawNode_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_DrawNode_class->name = "DrawNode"; + jsb_cocos2d_DrawNode_class->addProperty = JS_PropertyStub; + jsb_cocos2d_DrawNode_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_DrawNode_class->getProperty = JS_PropertyStub; + jsb_cocos2d_DrawNode_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_DrawNode_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_DrawNode_class->resolve = JS_ResolveStub; + jsb_cocos2d_DrawNode_class->convert = JS_ConvertStub; + jsb_cocos2d_DrawNode_class->finalize = js_cocos2d_DrawNode_finalize; + jsb_cocos2d_DrawNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("drawLine", js_cocos2dx_DrawNode_drawLine, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawPoints", js_cocos2dx_DrawNode_drawPoints, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawRect", js_cocos2dx_DrawNode_drawRect, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawSolidCircle", js_cocos2dx_DrawNode_drawSolidCircle, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("onDrawGLPoint", js_cocos2dx_DrawNode_onDrawGLPoint, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawDot", js_cocos2dx_DrawNode_drawDot, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawCatmullRom", js_cocos2dx_DrawNode_drawCatmullRom, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawSegment", js_cocos2dx_DrawNode_drawSegment, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBlendFunc", js_cocos2dx_DrawNode_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("onDraw", js_cocos2dx_DrawNode_onDraw, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawCircle", js_cocos2dx_DrawNode_drawCircle, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawQuadBezier", js_cocos2dx_DrawNode_drawQuadBezier, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("onDrawGLLine", js_cocos2dx_DrawNode_onDrawGLLine, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawSolidPoly", js_cocos2dx_DrawNode_drawSolidPoly, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawTriangle", js_cocos2dx_DrawNode_drawTriangle, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBlendFunc", js_cocos2dx_DrawNode_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("clear", js_cocos2dx_DrawNode_clear, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawCardinalSpline", js_cocos2dx_DrawNode_drawCardinalSpline, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawSolidRect", js_cocos2dx_DrawNode_drawSolidRect, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawPoly", js_cocos2dx_DrawNode_drawPoly, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawPoint", js_cocos2dx_DrawNode_drawPoint, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawCubicBezier", js_cocos2dx_DrawNode_drawCubicBezier, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_DrawNode_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_DrawNode_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_DrawNode_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_DrawNode_class, + js_cocos2dx_DrawNode_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, "DrawNode", 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_DrawNode_class; + p->proto = jsb_cocos2d_DrawNode_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_LabelAtlas_class; +JSObject *jsb_cocos2d_LabelAtlas_prototype; + +bool js_cocos2dx_LabelAtlas_setString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelAtlas* cobj = (cocos2d::LabelAtlas *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelAtlas_setString : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelAtlas_setString : Error processing arguments"); + cobj->setString(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelAtlas_setString : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LabelAtlas_initWithString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::LabelAtlas* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::LabelAtlas *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelAtlas_initWithString : Invalid Native Object"); + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithString(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 5) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + int arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + int arg3; + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + if (!ok) { ok = true; break; } + int arg4; + ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 5) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Texture2D* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + 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; } + int arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + int arg3; + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + if (!ok) { ok = true; break; } + int arg4; + ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_LabelAtlas_initWithString : wrong number of arguments"); + return false; +} +bool js_cocos2dx_LabelAtlas_getString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelAtlas* cobj = (cocos2d::LabelAtlas *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelAtlas_getString : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getString(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelAtlas_getString : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LabelAtlas_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 5) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + int arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + int arg3; + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + if (!ok) { ok = true; break; } + int arg4; + ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); + if (!ok) { ok = true; break; } + cocos2d::LabelAtlas* ret = cocos2d::LabelAtlas::create(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LabelAtlas*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::LabelAtlas* ret = cocos2d::LabelAtlas::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LabelAtlas*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::LabelAtlas* ret = cocos2d::LabelAtlas::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LabelAtlas*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_LabelAtlas_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_LabelAtlas_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::LabelAtlas* cobj = new (std::nothrow) cocos2d::LabelAtlas(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::LabelAtlas"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_AtlasNode_prototype; + +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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::LabelAtlas *nobj = new (std::nothrow) cocos2d::LabelAtlas(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + 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", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_LabelAtlas(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_LabelAtlas_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_LabelAtlas_class->name = "LabelAtlas"; + jsb_cocos2d_LabelAtlas_class->addProperty = JS_PropertyStub; + jsb_cocos2d_LabelAtlas_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_LabelAtlas_class->getProperty = JS_PropertyStub; + jsb_cocos2d_LabelAtlas_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_LabelAtlas_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_LabelAtlas_class->resolve = JS_ResolveStub; + jsb_cocos2d_LabelAtlas_class->convert = JS_ConvertStub; + jsb_cocos2d_LabelAtlas_class->finalize = js_cocos2d_LabelAtlas_finalize; + jsb_cocos2d_LabelAtlas_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setString", js_cocos2dx_LabelAtlas_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithString", js_cocos2dx_LabelAtlas_initWithString, 2, 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 + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("_create", js_cocos2dx_LabelAtlas_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_LabelAtlas_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_AtlasNode_prototype), + jsb_cocos2d_LabelAtlas_class, + js_cocos2dx_LabelAtlas_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, "LabelAtlas", 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_LabelAtlas_class; + p->proto = jsb_cocos2d_LabelAtlas_prototype; + p->parentProto = jsb_cocos2d_AtlasNode_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_LabelTTF_class; +JSObject *jsb_cocos2d_LabelTTF_prototype; + +bool js_cocos2dx_LabelTTF_enableShadow(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_enableShadow : Invalid Native Object"); + if (argc == 3) { + cocos2d::Size arg0; + double arg1; + double arg2; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_enableShadow : Error processing arguments"); + cobj->enableShadow(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + if (argc == 4) { + cocos2d::Size arg0; + double arg1; + double arg2; + bool arg3; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + arg3 = JS::ToBoolean(args.get(3)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_enableShadow : Error processing arguments"); + cobj->enableShadow(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_enableShadow : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_LabelTTF_setDimensions(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_setDimensions : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_setDimensions : Error processing arguments"); + cobj->setDimensions(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_setDimensions : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LabelTTF_getFontSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_getFontSize : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getFontSize(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_getFontSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LabelTTF_getString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_getString : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getString(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_getString : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LabelTTF_setFlippedY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_setFlippedY : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_setFlippedY : Error processing arguments"); + cobj->setFlippedY(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_setFlippedY : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LabelTTF_setFlippedX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_setFlippedX : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_setFlippedX : Error processing arguments"); + cobj->setFlippedX(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_setFlippedX : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LabelTTF_setTextDefinition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_setTextDefinition : Invalid Native Object"); + if (argc == 1) { + cocos2d::FontDefinition arg0; + ok &= jsval_to_FontDefinition(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_setTextDefinition : Error processing arguments"); + cobj->setTextDefinition(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_setTextDefinition : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LabelTTF_setFontName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_setFontName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_setFontName : Error processing arguments"); + cobj->setFontName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_setFontName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LabelTTF_getHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_getHorizontalAlignment : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getHorizontalAlignment(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_getHorizontalAlignment : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LabelTTF_initWithStringAndTextDefinition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_initWithStringAndTextDefinition : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + cocos2d::FontDefinition arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_FontDefinition(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_initWithStringAndTextDefinition : Error processing arguments"); + bool ret = cobj->initWithStringAndTextDefinition(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_initWithStringAndTextDefinition : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_LabelTTF_setString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_setString : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_setString : Error processing arguments"); + cobj->setString(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_setString : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LabelTTF_initWithString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_initWithString : Invalid Native Object"); + if (argc == 3) { + std::string arg0; + std::string arg1; + double arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_initWithString : Error processing arguments"); + bool ret = cobj->initWithString(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 4) { + std::string arg0; + std::string arg1; + double arg2; + cocos2d::Size arg3; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= jsval_to_ccsize(cx, args.get(3), &arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_initWithString : Error processing arguments"); + bool ret = cobj->initWithString(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 5) { + std::string arg0; + std::string arg1; + double arg2; + cocos2d::Size arg3; + cocos2d::TextHAlignment arg4; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= jsval_to_ccsize(cx, args.get(3), &arg3); + ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_initWithString : Error processing arguments"); + bool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 6) { + std::string arg0; + std::string arg1; + double arg2; + cocos2d::Size arg3; + cocos2d::TextHAlignment arg4; + cocos2d::TextVAlignment arg5; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= jsval_to_ccsize(cx, args.get(3), &arg3); + ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); + ok &= jsval_to_int32(cx, args.get(5), (int32_t *)&arg5); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_initWithString : Error processing arguments"); + bool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_initWithString : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_LabelTTF_setFontFillColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_setFontFillColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color3B arg0; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_setFontFillColor : Error processing arguments"); + cobj->setFontFillColor(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + cocos2d::Color3B arg0; + bool arg1; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_setFontFillColor : Error processing arguments"); + cobj->setFontFillColor(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_setFontFillColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LabelTTF_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_getBlendFunc : Invalid Native Object"); + if (argc == 0) { + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LabelTTF_enableStroke(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_enableStroke : Invalid Native Object"); + if (argc == 2) { + cocos2d::Color3B arg0; + double arg1; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_enableStroke : Error processing arguments"); + cobj->enableStroke(arg0, arg1); + args.rval().setUndefined(); + return true; + } + if (argc == 3) { + cocos2d::Color3B arg0; + double arg1; + bool arg2; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + arg2 = JS::ToBoolean(args.get(2)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_enableStroke : Error processing arguments"); + cobj->enableStroke(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_enableStroke : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_LabelTTF_getDimensions(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_getDimensions : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getDimensions(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_getDimensions : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LabelTTF_setVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_setVerticalAlignment : Invalid Native Object"); + if (argc == 1) { + cocos2d::TextVAlignment arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_setVerticalAlignment : Error processing arguments"); + cobj->setVerticalAlignment(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_setVerticalAlignment : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LabelTTF_setFontSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_setFontSize : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_setFontSize : Error processing arguments"); + cobj->setFontSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_setFontSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LabelTTF_getVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_getVerticalAlignment : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getVerticalAlignment(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_getVerticalAlignment : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LabelTTF_getTextDefinition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_getTextDefinition : Invalid Native Object"); + if (argc == 0) { + const cocos2d::FontDefinition& ret = cobj->getTextDefinition(); + jsval jsret = JSVAL_NULL; + jsret = FontDefinition_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_getTextDefinition : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LabelTTF_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_setBlendFunc : Invalid Native Object"); + if (argc == 1) { + cocos2d::BlendFunc arg0; + ok &= jsval_to_blendfunc(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_setBlendFunc : Error processing arguments"); + cobj->setBlendFunc(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LabelTTF_getFontName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_getFontName : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getFontName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_getFontName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LabelTTF_setHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_setHorizontalAlignment : Invalid Native Object"); + if (argc == 1) { + cocos2d::TextHAlignment arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_setHorizontalAlignment : Error processing arguments"); + cobj->setHorizontalAlignment(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_setHorizontalAlignment : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LabelTTF_disableShadow(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_disableShadow : Invalid Native Object"); + if (argc == 0) { + cobj->disableShadow(); + args.rval().setUndefined(); + return true; + } + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_disableShadow : Error processing arguments"); + cobj->disableShadow(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_disableShadow : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LabelTTF_disableStroke(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelTTF* cobj = (cocos2d::LabelTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelTTF_disableStroke : Invalid Native Object"); + if (argc == 0) { + cobj->disableStroke(); + args.rval().setUndefined(); + return true; + } + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_disableStroke : Error processing arguments"); + cobj->disableStroke(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelTTF_disableStroke : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LabelTTF_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 0) { + cocos2d::LabelTTF* ret = cocos2d::LabelTTF::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LabelTTF*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::LabelTTF* ret = cocos2d::LabelTTF::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LabelTTF*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 4) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::Size arg3; + ok &= jsval_to_ccsize(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + cocos2d::LabelTTF* ret = cocos2d::LabelTTF::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LabelTTF*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 5) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::Size arg3; + ok &= jsval_to_ccsize(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + cocos2d::TextHAlignment arg4; + ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); + if (!ok) { ok = true; break; } + cocos2d::LabelTTF* ret = cocos2d::LabelTTF::create(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LabelTTF*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 6) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::Size arg3; + ok &= jsval_to_ccsize(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + cocos2d::TextHAlignment arg4; + ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); + if (!ok) { ok = true; break; } + cocos2d::TextVAlignment arg5; + ok &= jsval_to_int32(cx, args.get(5), (int32_t *)&arg5); + if (!ok) { ok = true; break; } + cocos2d::LabelTTF* ret = cocos2d::LabelTTF::create(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LabelTTF*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_LabelTTF_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_LabelTTF_createWithFontDefinition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + std::string arg0; + cocos2d::FontDefinition arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_FontDefinition(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelTTF_createWithFontDefinition : Error processing arguments"); + cocos2d::LabelTTF* ret = cocos2d::LabelTTF::createWithFontDefinition(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LabelTTF*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_LabelTTF_createWithFontDefinition : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_LabelTTF_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::LabelTTF* cobj = new (std::nothrow) cocos2d::LabelTTF(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::LabelTTF"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::LabelTTF *nobj = new (std::nothrow) cocos2d::LabelTTF(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + 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", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_LabelTTF(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_LabelTTF_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_LabelTTF_class->name = "LabelTTF"; + jsb_cocos2d_LabelTTF_class->addProperty = JS_PropertyStub; + jsb_cocos2d_LabelTTF_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_LabelTTF_class->getProperty = JS_PropertyStub; + jsb_cocos2d_LabelTTF_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_LabelTTF_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_LabelTTF_class->resolve = JS_ResolveStub; + jsb_cocos2d_LabelTTF_class->convert = JS_ConvertStub; + jsb_cocos2d_LabelTTF_class->finalize = js_cocos2d_LabelTTF_finalize; + jsb_cocos2d_LabelTTF_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("enableShadow", js_cocos2dx_LabelTTF_enableShadow, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDimensions", js_cocos2dx_LabelTTF_setDimensions, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFontSize", js_cocos2dx_LabelTTF_getFontSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getString", js_cocos2dx_LabelTTF_getString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFlippedY", js_cocos2dx_LabelTTF_setFlippedY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFlippedX", js_cocos2dx_LabelTTF_setFlippedX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTextDefinition", js_cocos2dx_LabelTTF_setTextDefinition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFontName", js_cocos2dx_LabelTTF_setFontName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getHorizontalAlignment", js_cocos2dx_LabelTTF_getHorizontalAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithStringAndTextDefinition", js_cocos2dx_LabelTTF_initWithStringAndTextDefinition, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setString", js_cocos2dx_LabelTTF_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithString", js_cocos2dx_LabelTTF_initWithString, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFontFillColor", js_cocos2dx_LabelTTF_setFontFillColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBlendFunc", js_cocos2dx_LabelTTF_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("enableStroke", js_cocos2dx_LabelTTF_enableStroke, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDimensions", js_cocos2dx_LabelTTF_getDimensions, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setVerticalAlignment", js_cocos2dx_LabelTTF_setVerticalAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFontSize", js_cocos2dx_LabelTTF_setFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVerticalAlignment", js_cocos2dx_LabelTTF_getVerticalAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTextDefinition", js_cocos2dx_LabelTTF_getTextDefinition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBlendFunc", js_cocos2dx_LabelTTF_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFontName", js_cocos2dx_LabelTTF_getFontName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + 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 + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_LabelTTF_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithFontDefinition", js_cocos2dx_LabelTTF_createWithFontDefinition, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_LabelTTF_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_LabelTTF_class, + js_cocos2dx_LabelTTF_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, "LabelTTF", 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_LabelTTF_class; + p->proto = jsb_cocos2d_LabelTTF_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_SpriteBatchNode_class; +JSObject *jsb_cocos2d_SpriteBatchNode_prototype; + +bool js_cocos2dx_SpriteBatchNode_appendChild(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_appendChild : Invalid Native Object"); + if (argc == 1) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_appendChild : Error processing arguments"); + cobj->appendChild(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_appendChild : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteBatchNode_addSpriteWithoutQuad(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_addSpriteWithoutQuad : Invalid Native Object"); + if (argc == 3) { + cocos2d::Sprite* arg0; + int arg1; + int arg2; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_addSpriteWithoutQuad : Error processing arguments"); + cocos2d::SpriteBatchNode* ret = cobj->addSpriteWithoutQuad(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SpriteBatchNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_addSpriteWithoutQuad : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_SpriteBatchNode_reorderBatch(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_reorderBatch : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_reorderBatch : Error processing arguments"); + cobj->reorderBatch(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_reorderBatch : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteBatchNode_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_initWithTexture : Invalid Native Object"); + if (argc == 1) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_initWithTexture : Error processing arguments"); + bool ret = cobj->initWithTexture(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + cocos2d::Texture2D* arg0; + ssize_t arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_ssize(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_initWithTexture : Error processing arguments"); + bool ret = cobj->initWithTexture(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_initWithTexture : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteBatchNode_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_getBlendFunc : Invalid Native Object"); + if (argc == 0) { + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild : Invalid Native Object"); + if (argc == 1) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild : Error processing arguments"); + ssize_t ret = cobj->lowestAtlasIndexInChild(arg0); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteBatchNode_atlasIndexForChild(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_atlasIndexForChild : Invalid Native Object"); + if (argc == 2) { + cocos2d::Sprite* arg0; + int arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_atlasIndexForChild : Error processing arguments"); + ssize_t ret = cobj->atlasIndexForChild(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_atlasIndexForChild : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_SpriteBatchNode_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_setTextureAtlas : Invalid Native Object"); + if (argc == 1) { + cocos2d::TextureAtlas* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::TextureAtlas*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_setTextureAtlas : Error processing arguments"); + cobj->setTextureAtlas(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_setTextureAtlas : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteBatchNode_initWithFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_initWithFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_initWithFile : Error processing arguments"); + bool ret = cobj->initWithFile(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + std::string arg0; + ssize_t arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_ssize(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_initWithFile : Error processing arguments"); + bool ret = cobj->initWithFile(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_initWithFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteBatchNode_getTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_getTexture : Invalid Native Object"); + if (argc == 0) { + cocos2d::Texture2D* ret = cobj->getTexture(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_getTexture : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpriteBatchNode_increaseAtlasCapacity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_increaseAtlasCapacity : Invalid Native Object"); + if (argc == 0) { + cobj->increaseAtlasCapacity(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_increaseAtlasCapacity : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpriteBatchNode_getTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_getTextureAtlas : Invalid Native Object"); + if (argc == 0) { + cocos2d::TextureAtlas* ret = cobj->getTextureAtlas(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TextureAtlas*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_getTextureAtlas : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpriteBatchNode_insertQuadFromSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_insertQuadFromSprite : Invalid Native Object"); + if (argc == 2) { + cocos2d::Sprite* arg0; + ssize_t arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_ssize(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_insertQuadFromSprite : Error processing arguments"); + cobj->insertQuadFromSprite(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_insertQuadFromSprite : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_SpriteBatchNode_setTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_setTexture : Invalid Native Object"); + if (argc == 1) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_setTexture : Error processing arguments"); + cobj->setTexture(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_setTexture : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteBatchNode_rebuildIndexInOrder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_rebuildIndexInOrder : Invalid Native Object"); + if (argc == 2) { + cocos2d::Sprite* arg0; + ssize_t arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_ssize(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_rebuildIndexInOrder : Error processing arguments"); + ssize_t ret = cobj->rebuildIndexInOrder(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_rebuildIndexInOrder : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild : Invalid Native Object"); + if (argc == 1) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild : Error processing arguments"); + ssize_t ret = cobj->highestAtlasIndexInChild(arg0); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteBatchNode_removeChildAtIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_removeChildAtIndex : Invalid Native Object"); + if (argc == 2) { + ssize_t arg0; + bool arg1; + ok &= jsval_to_ssize(cx, args.get(0), &arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_removeChildAtIndex : Error processing arguments"); + cobj->removeChildAtIndex(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_removeChildAtIndex : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas : Invalid Native Object"); + if (argc == 1) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas : Error processing arguments"); + cobj->removeSpriteFromAtlas(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteBatchNode_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_setBlendFunc : Invalid Native Object"); + if (argc == 1) { + cocos2d::BlendFunc arg0; + ok &= jsval_to_blendfunc(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_setBlendFunc : Error processing arguments"); + cobj->setBlendFunc(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteBatchNode_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_create : Error processing arguments"); + cocos2d::SpriteBatchNode* ret = cocos2d::SpriteBatchNode::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SpriteBatchNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + std::string arg0; + ssize_t arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_ssize(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_create : Error processing arguments"); + cocos2d::SpriteBatchNode* ret = cocos2d::SpriteBatchNode::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SpriteBatchNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_SpriteBatchNode_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_createWithTexture : Error processing arguments"); + cocos2d::SpriteBatchNode* ret = cocos2d::SpriteBatchNode::createWithTexture(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SpriteBatchNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + cocos2d::Texture2D* arg0; + ssize_t arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_ssize(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteBatchNode_createWithTexture : Error processing arguments"); + cocos2d::SpriteBatchNode* ret = cocos2d::SpriteBatchNode::createWithTexture(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SpriteBatchNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_createWithTexture : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_SpriteBatchNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::SpriteBatchNode* cobj = new (std::nothrow) cocos2d::SpriteBatchNode(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::SpriteBatchNode"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_SpriteBatchNode_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (SpriteBatchNode)", obj); +} + +static bool js_cocos2d_SpriteBatchNode_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::SpriteBatchNode *nobj = new (std::nothrow) cocos2d::SpriteBatchNode(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::SpriteBatchNode"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_SpriteBatchNode(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_SpriteBatchNode_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_SpriteBatchNode_class->name = "SpriteBatchNode"; + jsb_cocos2d_SpriteBatchNode_class->addProperty = JS_PropertyStub; + jsb_cocos2d_SpriteBatchNode_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_SpriteBatchNode_class->getProperty = JS_PropertyStub; + jsb_cocos2d_SpriteBatchNode_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_SpriteBatchNode_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_SpriteBatchNode_class->resolve = JS_ResolveStub; + jsb_cocos2d_SpriteBatchNode_class->convert = JS_ConvertStub; + jsb_cocos2d_SpriteBatchNode_class->finalize = js_cocos2d_SpriteBatchNode_finalize; + jsb_cocos2d_SpriteBatchNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("appendChild", js_cocos2dx_SpriteBatchNode_appendChild, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addSpriteWithoutQuad", js_cocos2dx_SpriteBatchNode_addSpriteWithoutQuad, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("reorderBatch", js_cocos2dx_SpriteBatchNode_reorderBatch, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTexture", js_cocos2dx_SpriteBatchNode_initWithTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBlendFunc", js_cocos2dx_SpriteBatchNode_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("lowestAtlasIndexInChild", js_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("atlasIndexForChild", js_cocos2dx_SpriteBatchNode_atlasIndexForChild, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTextureAtlas", js_cocos2dx_SpriteBatchNode_setTextureAtlas, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithFile", js_cocos2dx_SpriteBatchNode_initWithFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTexture", js_cocos2dx_SpriteBatchNode_getTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("increaseAtlasCapacity", js_cocos2dx_SpriteBatchNode_increaseAtlasCapacity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTextureAtlas", js_cocos2dx_SpriteBatchNode_getTextureAtlas, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("insertQuadFromSprite", js_cocos2dx_SpriteBatchNode_insertQuadFromSprite, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTexture", js_cocos2dx_SpriteBatchNode_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("rebuildIndexInOrder", js_cocos2dx_SpriteBatchNode_rebuildIndexInOrder, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("highestAtlasIndexInChild", js_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeChildAtIndex", js_cocos2dx_SpriteBatchNode_removeChildAtIndex, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeSpriteFromAtlas", js_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBlendFunc", js_cocos2dx_SpriteBatchNode_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_SpriteBatchNode_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_SpriteBatchNode_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithTexture", js_cocos2dx_SpriteBatchNode_createWithTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_SpriteBatchNode_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_SpriteBatchNode_class, + js_cocos2dx_SpriteBatchNode_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, "SpriteBatchNode", 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_SpriteBatchNode_class; + p->proto = jsb_cocos2d_SpriteBatchNode_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Label_class; +JSObject *jsb_cocos2d_Label_prototype; + +bool js_cocos2dx_Label_isClipMarginEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_isClipMarginEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isClipMarginEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_isClipMarginEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_enableShadow(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_enableShadow : Invalid Native Object"); + if (argc == 0) { + cobj->enableShadow(); + args.rval().setUndefined(); + return true; + } + if (argc == 1) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_enableShadow : Error processing arguments"); + cobj->enableShadow(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + cocos2d::Color4B arg0; + cocos2d::Size arg1; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_enableShadow : Error processing arguments"); + cobj->enableShadow(arg0, arg1); + args.rval().setUndefined(); + return true; + } + if (argc == 3) { + cocos2d::Color4B arg0; + cocos2d::Size arg1; + int arg2; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_enableShadow : Error processing arguments"); + cobj->enableShadow(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_enableShadow : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_setDimensions(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setDimensions : Invalid Native Object"); + if (argc == 2) { + double arg0; + double arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setDimensions : Error processing arguments"); + cobj->setDimensions(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setDimensions : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_Label_getString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getString : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getString(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getString : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_getHeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getHeight : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getHeight(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getHeight : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_disableEffect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Label* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_disableEffect : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::LabelEffect arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + cobj->disableEffect(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 0) { + cobj->disableEffect(); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Label_disableEffect : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Label_getTextColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getTextColor : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color4B& ret = cobj->getTextColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor4b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getTextColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_setWidth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setWidth : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setWidth : Error processing arguments"); + cobj->setWidth(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setWidth : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Label_getMaxLineWidth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getMaxLineWidth : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getMaxLineWidth(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getMaxLineWidth : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_getHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getHorizontalAlignment : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getHorizontalAlignment(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getHorizontalAlignment : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_setClipMarginEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setClipMarginEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setClipMarginEnabled : Error processing arguments"); + cobj->setClipMarginEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setClipMarginEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Label_setString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setString : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setString : Error processing arguments"); + cobj->setString(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setString : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Label_setSystemFontName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setSystemFontName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setSystemFontName : Error processing arguments"); + cobj->setSystemFontName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setSystemFontName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Label_setBMFontFilePath(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setBMFontFilePath : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setBMFontFilePath : Error processing arguments"); + bool ret = cobj->setBMFontFilePath(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::Vec2 arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setBMFontFilePath : Error processing arguments"); + bool ret = cobj->setBMFontFilePath(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setBMFontFilePath : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Label_setLineHeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setLineHeight : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setLineHeight : Error processing arguments"); + cobj->setLineHeight(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setLineHeight : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Label_setSystemFontSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setSystemFontSize : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setSystemFontSize : Error processing arguments"); + cobj->setSystemFontSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setSystemFontSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Label_updateContent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_updateContent : Invalid Native Object"); + if (argc == 0) { + cobj->updateContent(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_updateContent : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_getStringLength(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getStringLength : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getStringLength(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getStringLength : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_setLineBreakWithoutSpace(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setLineBreakWithoutSpace : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setLineBreakWithoutSpace : Error processing arguments"); + cobj->setLineBreakWithoutSpace(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setLineBreakWithoutSpace : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Label_getStringNumLines(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getStringNumLines : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getStringNumLines(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getStringNumLines : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_enableOutline(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_enableOutline : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_enableOutline : Error processing arguments"); + cobj->enableOutline(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + cocos2d::Color4B arg0; + int arg1; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_enableOutline : Error processing arguments"); + cobj->enableOutline(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_enableOutline : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Label_getAdditionalKerning(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getAdditionalKerning : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAdditionalKerning(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getAdditionalKerning : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_setCharMap(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Label* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setCharMap : Invalid Native Object"); + do { + if (argc == 4) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + int arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + int arg3; + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + if (!ok) { ok = true; break; } + bool ret = cobj->setCharMap(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 4) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + int arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + int arg3; + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + if (!ok) { ok = true; break; } + bool ret = cobj->setCharMap(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + bool ret = cobj->setCharMap(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Label_setCharMap : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Label_getDimensions(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getDimensions : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getDimensions(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getDimensions : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_setMaxLineWidth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setMaxLineWidth : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setMaxLineWidth : Error processing arguments"); + cobj->setMaxLineWidth(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setMaxLineWidth : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Label_getSystemFontName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getSystemFontName : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getSystemFontName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getSystemFontName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_setVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setVerticalAlignment : Invalid Native Object"); + if (argc == 1) { + cocos2d::TextVAlignment arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setVerticalAlignment : Error processing arguments"); + cobj->setVerticalAlignment(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setVerticalAlignment : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Label_getLineHeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getLineHeight : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getLineHeight(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getLineHeight : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_getTTFConfig(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getTTFConfig : Invalid Native Object"); + if (argc == 0) { + const cocos2d::_ttfConfig& ret = cobj->getTTFConfig(); + jsval jsret = JSVAL_NULL; + #pragma warning NO CONVERSION FROM NATIVE FOR _ttfConfig; + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getTTFConfig : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_getVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getVerticalAlignment : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getVerticalAlignment(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getVerticalAlignment : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_setTextColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setTextColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setTextColor : Error processing arguments"); + cobj->setTextColor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setTextColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Label_setHeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setHeight : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setHeight : Error processing arguments"); + cobj->setHeight(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setHeight : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Label_getWidth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getWidth : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getWidth(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getWidth : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_enableGlow(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_enableGlow : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_enableGlow : Error processing arguments"); + cobj->enableGlow(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_enableGlow : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Label_getLetter(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getLetter : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_getLetter : Error processing arguments"); + cocos2d::Sprite* ret = cobj->getLetter(arg0); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getLetter : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Label_setAdditionalKerning(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setAdditionalKerning : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setAdditionalKerning : Error processing arguments"); + cobj->setAdditionalKerning(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setAdditionalKerning : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Label_getSystemFontSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getSystemFontSize : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getSystemFontSize(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getSystemFontSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_getTextAlignment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getTextAlignment : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getTextAlignment(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getTextAlignment : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_getBMFontFilePath(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getBMFontFilePath : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getBMFontFilePath(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getBMFontFilePath : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_setHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setHorizontalAlignment : Invalid Native Object"); + if (argc == 1) { + cocos2d::TextHAlignment arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setHorizontalAlignment : Error processing arguments"); + cobj->setHorizontalAlignment(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setHorizontalAlignment : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Label_setAlignment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Label* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setAlignment : Invalid Native Object"); + do { + if (argc == 2) { + cocos2d::TextHAlignment arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + cocos2d::TextVAlignment arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cobj->setAlignment(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::TextHAlignment arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + cobj->setAlignment(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Label_setAlignment : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Label_requestSystemFontRefresh(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_requestSystemFontRefresh : Invalid Native Object"); + if (argc == 0) { + cobj->requestSystemFontRefresh(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_requestSystemFontRefresh : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_createWithBMFont(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_createWithBMFont : Error processing arguments"); + cocos2d::Label* ret = cocos2d::Label::createWithBMFont(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 3) { + std::string arg0; + std::string arg1; + cocos2d::TextHAlignment arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_createWithBMFont : Error processing arguments"); + cocos2d::Label* ret = cocos2d::Label::createWithBMFont(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 4) { + std::string arg0; + std::string arg1; + cocos2d::TextHAlignment arg2; + int arg3; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_createWithBMFont : Error processing arguments"); + cocos2d::Label* ret = cocos2d::Label::createWithBMFont(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 5) { + std::string arg0; + std::string arg1; + cocos2d::TextHAlignment arg2; + int arg3; + cocos2d::Vec2 arg4; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + ok &= jsval_to_vector2(cx, args.get(4), &arg4); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_createWithBMFont : Error processing arguments"); + cocos2d::Label* ret = cocos2d::Label::createWithBMFont(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Label_createWithBMFont : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Label_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Label* ret = cocos2d::Label::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Label_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Label_createWithCharMap(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 4) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + int arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + int arg3; + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + if (!ok) { ok = true; break; } + cocos2d::Label* ret = cocos2d::Label::createWithCharMap(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 4) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + int arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + int arg3; + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + if (!ok) { ok = true; break; } + cocos2d::Label* ret = cocos2d::Label::createWithCharMap(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Label* ret = cocos2d::Label::createWithCharMap(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_Label_createWithCharMap : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Label_createWithSystemFont(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 3) { + std::string arg0; + std::string arg1; + double arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_createWithSystemFont : Error processing arguments"); + cocos2d::Label* ret = cocos2d::Label::createWithSystemFont(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 4) { + std::string arg0; + std::string arg1; + double arg2; + cocos2d::Size arg3; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= jsval_to_ccsize(cx, args.get(3), &arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_createWithSystemFont : Error processing arguments"); + cocos2d::Label* ret = cocos2d::Label::createWithSystemFont(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 5) { + std::string arg0; + std::string arg1; + double arg2; + cocos2d::Size arg3; + cocos2d::TextHAlignment arg4; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= jsval_to_ccsize(cx, args.get(3), &arg3); + ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_createWithSystemFont : Error processing arguments"); + cocos2d::Label* ret = cocos2d::Label::createWithSystemFont(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 6) { + std::string arg0; + std::string arg1; + double arg2; + cocos2d::Size arg3; + cocos2d::TextHAlignment arg4; + cocos2d::TextVAlignment arg5; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= jsval_to_ccsize(cx, args.get(3), &arg3); + ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); + ok &= jsval_to_int32(cx, args.get(5), (int32_t *)&arg5); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_createWithSystemFont : Error processing arguments"); + cocos2d::Label* ret = cocos2d::Label::createWithSystemFont(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Label_createWithSystemFont : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Label_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Label* cobj = new (std::nothrow) cocos2d::Label(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Label"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_SpriteBatchNode_prototype; + +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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Label *nobj = new (std::nothrow) cocos2d::Label(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + 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", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_Label(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Label_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Label_class->name = "Label"; + jsb_cocos2d_Label_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Label_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Label_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Label_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Label_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Label_class->resolve = JS_ResolveStub; + jsb_cocos2d_Label_class->convert = JS_ConvertStub; + jsb_cocos2d_Label_class->finalize = js_cocos2d_Label_finalize; + jsb_cocos2d_Label_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("isClipMarginEnabled", js_cocos2dx_Label_isClipMarginEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("enableShadow", js_cocos2dx_Label_enableShadow, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDimensions", js_cocos2dx_Label_setDimensions, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getString", js_cocos2dx_Label_getString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getHeight", js_cocos2dx_Label_getHeight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("disableEffect", js_cocos2dx_Label_disableEffect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTextColor", js_cocos2dx_Label_getTextColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setWidth", js_cocos2dx_Label_setWidth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaxLineWidth", js_cocos2dx_Label_getMaxLineWidth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getHorizontalAlignment", js_cocos2dx_Label_getHorizontalAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setClipMarginEnabled", js_cocos2dx_Label_setClipMarginEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setString", js_cocos2dx_Label_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSystemFontName", js_cocos2dx_Label_setSystemFontName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBMFontFilePath", js_cocos2dx_Label_setBMFontFilePath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLineHeight", js_cocos2dx_Label_setLineHeight, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSystemFontSize", js_cocos2dx_Label_setSystemFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateContent", js_cocos2dx_Label_updateContent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStringLength", js_cocos2dx_Label_getStringLength, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLineBreakWithoutSpace", js_cocos2dx_Label_setLineBreakWithoutSpace, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStringNumLines", js_cocos2dx_Label_getStringNumLines, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("enableOutline", js_cocos2dx_Label_enableOutline, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAdditionalKerning", js_cocos2dx_Label_getAdditionalKerning, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCharMap", js_cocos2dx_Label_setCharMap, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDimensions", js_cocos2dx_Label_getDimensions, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaxLineWidth", js_cocos2dx_Label_setMaxLineWidth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSystemFontName", js_cocos2dx_Label_getSystemFontName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setVerticalAlignment", js_cocos2dx_Label_setVerticalAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLineHeight", js_cocos2dx_Label_getLineHeight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTTFConfig", js_cocos2dx_Label_getTTFConfig, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVerticalAlignment", js_cocos2dx_Label_getVerticalAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTextColor", js_cocos2dx_Label_setTextColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setHeight", js_cocos2dx_Label_setHeight, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getWidth", js_cocos2dx_Label_getWidth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("enableGlow", js_cocos2dx_Label_enableGlow, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLetter", js_cocos2dx_Label_getLetter, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAdditionalKerning", js_cocos2dx_Label_setAdditionalKerning, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSystemFontSize", js_cocos2dx_Label_getSystemFontSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTextAlignment", js_cocos2dx_Label_getTextAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBMFontFilePath", js_cocos2dx_Label_getBMFontFilePath, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + 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 + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("createWithBMFont", js_cocos2dx_Label_createWithBMFont, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("create", js_cocos2dx_Label_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithCharMap", js_cocos2dx_Label_createWithCharMap, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithSystemFont", js_cocos2dx_Label_createWithSystemFont, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Label_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_SpriteBatchNode_prototype), + jsb_cocos2d_Label_class, + js_cocos2dx_Label_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, "Label", 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_Label_class; + p->proto = jsb_cocos2d_Label_prototype; + p->parentProto = jsb_cocos2d_SpriteBatchNode_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_LabelBMFont_class; +JSObject *jsb_cocos2d_LabelBMFont_prototype; + +bool js_cocos2dx_LabelBMFont_setLineBreakWithoutSpace(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelBMFont_setLineBreakWithoutSpace : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelBMFont_setLineBreakWithoutSpace : Error processing arguments"); + cobj->setLineBreakWithoutSpace(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelBMFont_setLineBreakWithoutSpace : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LabelBMFont_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelBMFont_getBlendFunc : Invalid Native Object"); + if (argc == 0) { + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelBMFont_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LabelBMFont_getLetter(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelBMFont_getLetter : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelBMFont_getLetter : Error processing arguments"); + cocos2d::Sprite* ret = cobj->getLetter(arg0); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelBMFont_getLetter : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LabelBMFont_getString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelBMFont_getString : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getString(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelBMFont_getString : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LabelBMFont_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelBMFont_setBlendFunc : Invalid Native Object"); + if (argc == 1) { + cocos2d::BlendFunc arg0; + ok &= jsval_to_blendfunc(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelBMFont_setBlendFunc : Error processing arguments"); + cobj->setBlendFunc(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelBMFont_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LabelBMFont_setString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelBMFont_setString : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelBMFont_setString : Error processing arguments"); + cobj->setString(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelBMFont_setString : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LabelBMFont_initWithString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelBMFont_initWithString : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelBMFont_initWithString : Error processing arguments"); + bool ret = cobj->initWithString(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 3) { + std::string arg0; + std::string arg1; + double arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelBMFont_initWithString : Error processing arguments"); + bool ret = cobj->initWithString(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 4) { + std::string arg0; + std::string arg1; + double arg2; + cocos2d::TextHAlignment arg3; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelBMFont_initWithString : Error processing arguments"); + bool ret = cobj->initWithString(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 5) { + std::string arg0; + std::string arg1; + double arg2; + cocos2d::TextHAlignment arg3; + cocos2d::Vec2 arg4; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + ok &= jsval_to_vector2(cx, args.get(4), &arg4); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelBMFont_initWithString : Error processing arguments"); + bool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelBMFont_initWithString : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_LabelBMFont_getFntFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelBMFont_getFntFile : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getFntFile(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelBMFont_getFntFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LabelBMFont_setFntFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelBMFont_setFntFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelBMFont_setFntFile : Error processing arguments"); + cobj->setFntFile(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::Vec2 arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelBMFont_setFntFile : Error processing arguments"); + cobj->setFntFile(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelBMFont_setFntFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LabelBMFont_setAlignment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelBMFont_setAlignment : Invalid Native Object"); + if (argc == 1) { + cocos2d::TextHAlignment arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelBMFont_setAlignment : Error processing arguments"); + cobj->setAlignment(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelBMFont_setAlignment : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LabelBMFont_setWidth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LabelBMFont* cobj = (cocos2d::LabelBMFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LabelBMFont_setWidth : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LabelBMFont_setWidth : Error processing arguments"); + cobj->setWidth(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LabelBMFont_setWidth : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LabelBMFont_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 0) { + cocos2d::LabelBMFont* ret = cocos2d::LabelBMFont::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LabelBMFont*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::LabelBMFont* ret = cocos2d::LabelBMFont::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LabelBMFont*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::LabelBMFont* ret = cocos2d::LabelBMFont::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LabelBMFont*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 4) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::TextHAlignment arg3; + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + if (!ok) { ok = true; break; } + cocos2d::LabelBMFont* ret = cocos2d::LabelBMFont::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LabelBMFont*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 5) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::TextHAlignment arg3; + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + if (!ok) { ok = true; break; } + cocos2d::Vec2 arg4; + ok &= jsval_to_vector2(cx, args.get(4), &arg4); + if (!ok) { ok = true; break; } + cocos2d::LabelBMFont* ret = cocos2d::LabelBMFont::create(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LabelBMFont*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_LabelBMFont_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_LabelBMFont_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::LabelBMFont* cobj = new (std::nothrow) cocos2d::LabelBMFont(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::LabelBMFont"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::LabelBMFont *nobj = new (std::nothrow) cocos2d::LabelBMFont(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + 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", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_LabelBMFont(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_LabelBMFont_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_LabelBMFont_class->name = "LabelBMFont"; + jsb_cocos2d_LabelBMFont_class->addProperty = JS_PropertyStub; + jsb_cocos2d_LabelBMFont_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_LabelBMFont_class->getProperty = JS_PropertyStub; + jsb_cocos2d_LabelBMFont_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_LabelBMFont_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_LabelBMFont_class->resolve = JS_ResolveStub; + jsb_cocos2d_LabelBMFont_class->convert = JS_ConvertStub; + jsb_cocos2d_LabelBMFont_class->finalize = js_cocos2d_LabelBMFont_finalize; + jsb_cocos2d_LabelBMFont_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setLineBreakWithoutSpace", js_cocos2dx_LabelBMFont_setLineBreakWithoutSpace, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBlendFunc", js_cocos2dx_LabelBMFont_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLetter", js_cocos2dx_LabelBMFont_getLetter, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getString", js_cocos2dx_LabelBMFont_getString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBlendFunc", js_cocos2dx_LabelBMFont_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setString", js_cocos2dx_LabelBMFont_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithString", js_cocos2dx_LabelBMFont_initWithString, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFntFile", js_cocos2dx_LabelBMFont_getFntFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + 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 + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_LabelBMFont_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_LabelBMFont_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_LabelBMFont_class, + js_cocos2dx_LabelBMFont_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, "LabelBMFont", 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_LabelBMFont_class; + p->proto = jsb_cocos2d_LabelBMFont_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Layer_class; +JSObject *jsb_cocos2d_Layer_prototype; + +bool js_cocos2dx_Layer_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Layer* ret = cocos2d::Layer::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Layer*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Layer_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Layer_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Layer* cobj = new (std::nothrow) cocos2d::Layer(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Layer"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_Layer_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Layer)", obj); +} + +static bool js_cocos2d_Layer_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Layer *nobj = new (std::nothrow) cocos2d::Layer(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Layer"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_Layer(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Layer_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Layer_class->name = "Layer"; + jsb_cocos2d_Layer_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Layer_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Layer_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Layer_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Layer_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Layer_class->resolve = JS_ResolveStub; + jsb_cocos2d_Layer_class->convert = JS_ConvertStub; + jsb_cocos2d_Layer_class->finalize = js_cocos2d_Layer_finalize; + jsb_cocos2d_Layer_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2d_Layer_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Layer_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Layer_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_Layer_class, + js_cocos2dx_Layer_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, "Layer", 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_Layer_class; + p->proto = jsb_cocos2d_Layer_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d___LayerRGBA_class; +JSObject *jsb_cocos2d___LayerRGBA_prototype; + +bool js_cocos2dx___LayerRGBA_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::__LayerRGBA* ret = cocos2d::__LayerRGBA::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::__LayerRGBA*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx___LayerRGBA_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx___LayerRGBA_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::__LayerRGBA* cobj = new (std::nothrow) cocos2d::__LayerRGBA(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::__LayerRGBA"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Layer_prototype; + +void js_cocos2d___LayerRGBA_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (__LayerRGBA)", obj); +} + +void js_register_cocos2dx___LayerRGBA(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d___LayerRGBA_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d___LayerRGBA_class->name = "LayerRGBA"; + jsb_cocos2d___LayerRGBA_class->addProperty = JS_PropertyStub; + jsb_cocos2d___LayerRGBA_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d___LayerRGBA_class->getProperty = JS_PropertyStub; + jsb_cocos2d___LayerRGBA_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d___LayerRGBA_class->enumerate = JS_EnumerateStub; + jsb_cocos2d___LayerRGBA_class->resolve = JS_ResolveStub; + jsb_cocos2d___LayerRGBA_class->convert = JS_ConvertStub; + jsb_cocos2d___LayerRGBA_class->finalize = js_cocos2d___LayerRGBA_finalize; + jsb_cocos2d___LayerRGBA_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx___LayerRGBA_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d___LayerRGBA_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Layer_prototype), + jsb_cocos2d___LayerRGBA_class, + js_cocos2dx___LayerRGBA_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, "LayerRGBA", 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___LayerRGBA_class; + p->proto = jsb_cocos2d___LayerRGBA_prototype; + p->parentProto = jsb_cocos2d_Layer_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_LayerColor_class; +JSObject *jsb_cocos2d_LayerColor_prototype; + +bool js_cocos2dx_LayerColor_changeWidthAndHeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerColor* cobj = (cocos2d::LayerColor *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerColor_changeWidthAndHeight : Invalid Native Object"); + if (argc == 2) { + double arg0; + double arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LayerColor_changeWidthAndHeight : Error processing arguments"); + cobj->changeWidthAndHeight(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerColor_changeWidthAndHeight : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_LayerColor_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerColor* cobj = (cocos2d::LayerColor *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerColor_getBlendFunc : Invalid Native Object"); + if (argc == 0) { + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerColor_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LayerColor_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerColor* cobj = (cocos2d::LayerColor *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerColor_setBlendFunc : Invalid Native Object"); + if (argc == 1) { + cocos2d::BlendFunc arg0; + ok &= jsval_to_blendfunc(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LayerColor_setBlendFunc : Error processing arguments"); + cobj->setBlendFunc(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerColor_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LayerColor_changeWidth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerColor* cobj = (cocos2d::LayerColor *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerColor_changeWidth : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LayerColor_changeWidth : Error processing arguments"); + cobj->changeWidth(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerColor_changeWidth : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LayerColor_initWithColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::LayerColor* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::LayerColor *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerColor_initWithColor : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithColor(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 3) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithColor(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_LayerColor_initWithColor : wrong number of arguments"); + return false; +} +bool js_cocos2dx_LayerColor_changeHeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerColor* cobj = (cocos2d::LayerColor *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerColor_changeHeight : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LayerColor_changeHeight : Error processing arguments"); + cobj->changeHeight(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerColor_changeHeight : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LayerColor_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 3) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::LayerColor* ret = cocos2d::LayerColor::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LayerColor*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::LayerColor* ret = cocos2d::LayerColor::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LayerColor*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 1) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::LayerColor* ret = cocos2d::LayerColor::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LayerColor*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_LayerColor_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_LayerColor_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::LayerColor* cobj = new (std::nothrow) cocos2d::LayerColor(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::LayerColor"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Layer_prototype; + +void js_cocos2d_LayerColor_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (LayerColor)", obj); +} + +static bool js_cocos2d_LayerColor_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::LayerColor *nobj = new (std::nothrow) cocos2d::LayerColor(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::LayerColor"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_LayerColor(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_LayerColor_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_LayerColor_class->name = "LayerColor"; + jsb_cocos2d_LayerColor_class->addProperty = JS_PropertyStub; + jsb_cocos2d_LayerColor_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_LayerColor_class->getProperty = JS_PropertyStub; + jsb_cocos2d_LayerColor_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_LayerColor_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_LayerColor_class->resolve = JS_ResolveStub; + jsb_cocos2d_LayerColor_class->convert = JS_ConvertStub; + jsb_cocos2d_LayerColor_class->finalize = js_cocos2d_LayerColor_finalize; + jsb_cocos2d_LayerColor_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("changeWidthAndHeight", js_cocos2dx_LayerColor_changeWidthAndHeight, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBlendFunc", js_cocos2dx_LayerColor_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBlendFunc", js_cocos2dx_LayerColor_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("changeWidth", js_cocos2dx_LayerColor_changeWidth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_LayerColor_initWithColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("changeHeight", js_cocos2dx_LayerColor_changeHeight, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_LayerColor_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_LayerColor_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_LayerColor_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Layer_prototype), + jsb_cocos2d_LayerColor_class, + js_cocos2dx_LayerColor_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, "LayerColor", 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_LayerColor_class; + p->proto = jsb_cocos2d_LayerColor_prototype; + p->parentProto = jsb_cocos2d_Layer_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_LayerGradient_class; +JSObject *jsb_cocos2d_LayerGradient_prototype; + +bool js_cocos2dx_LayerGradient_getStartColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerGradient_getStartColor : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color3B& ret = cobj->getStartColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor3b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerGradient_getStartColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LayerGradient_isCompressedInterpolation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerGradient_isCompressedInterpolation : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isCompressedInterpolation(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerGradient_isCompressedInterpolation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LayerGradient_getStartOpacity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerGradient_getStartOpacity : Invalid Native Object"); + if (argc == 0) { + uint16_t ret = cobj->getStartOpacity(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerGradient_getStartOpacity : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LayerGradient_setVector(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerGradient_setVector : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LayerGradient_setVector : Error processing arguments"); + cobj->setVector(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerGradient_setVector : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LayerGradient_setStartOpacity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerGradient_setStartOpacity : Invalid Native Object"); + if (argc == 1) { + uint16_t arg0; + ok &= jsval_to_uint16(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LayerGradient_setStartOpacity : Error processing arguments"); + cobj->setStartOpacity(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerGradient_setStartOpacity : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LayerGradient_setCompressedInterpolation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerGradient_setCompressedInterpolation : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LayerGradient_setCompressedInterpolation : Error processing arguments"); + cobj->setCompressedInterpolation(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerGradient_setCompressedInterpolation : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LayerGradient_setEndOpacity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerGradient_setEndOpacity : Invalid Native Object"); + if (argc == 1) { + uint16_t arg0; + ok &= jsval_to_uint16(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LayerGradient_setEndOpacity : Error processing arguments"); + cobj->setEndOpacity(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerGradient_setEndOpacity : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LayerGradient_getVector(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerGradient_getVector : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getVector(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerGradient_getVector : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LayerGradient_setEndColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerGradient_setEndColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color3B arg0; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LayerGradient_setEndColor : Error processing arguments"); + cobj->setEndColor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerGradient_setEndColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LayerGradient_initWithColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::LayerGradient* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerGradient_initWithColor : Invalid Native Object"); + do { + if (argc == 3) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Color4B arg1; + ok &= jsval_to_cccolor4b(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::Vec2 arg2; + ok &= jsval_to_vector2(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithColor(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Color4B arg1; + ok &= jsval_to_cccolor4b(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithColor(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_LayerGradient_initWithColor : wrong number of arguments"); + return false; +} +bool js_cocos2dx_LayerGradient_getEndColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerGradient_getEndColor : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color3B& ret = cobj->getEndColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor3b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerGradient_getEndColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LayerGradient_getEndOpacity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerGradient_getEndOpacity : Invalid Native Object"); + if (argc == 0) { + uint16_t ret = cobj->getEndOpacity(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerGradient_getEndOpacity : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_LayerGradient_setStartColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerGradient* cobj = (cocos2d::LayerGradient *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerGradient_setStartColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color3B arg0; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LayerGradient_setStartColor : Error processing arguments"); + cobj->setStartColor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerGradient_setStartColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LayerGradient_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Color4B arg1; + ok &= jsval_to_cccolor4b(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::LayerGradient* ret = cocos2d::LayerGradient::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LayerGradient*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::LayerGradient* ret = cocos2d::LayerGradient::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LayerGradient*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 3) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Color4B arg1; + ok &= jsval_to_cccolor4b(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::Vec2 arg2; + ok &= jsval_to_vector2(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cocos2d::LayerGradient* ret = cocos2d::LayerGradient::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::LayerGradient*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_LayerGradient_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_LayerGradient_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::LayerGradient* cobj = new (std::nothrow) cocos2d::LayerGradient(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::LayerGradient"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_LayerColor_prototype; + +void js_cocos2d_LayerGradient_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (LayerGradient)", obj); +} + +static bool js_cocos2d_LayerGradient_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::LayerGradient *nobj = new (std::nothrow) cocos2d::LayerGradient(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::LayerGradient"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_LayerGradient(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_LayerGradient_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_LayerGradient_class->name = "LayerGradient"; + jsb_cocos2d_LayerGradient_class->addProperty = JS_PropertyStub; + jsb_cocos2d_LayerGradient_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_LayerGradient_class->getProperty = JS_PropertyStub; + jsb_cocos2d_LayerGradient_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_LayerGradient_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_LayerGradient_class->resolve = JS_ResolveStub; + jsb_cocos2d_LayerGradient_class->convert = JS_ConvertStub; + jsb_cocos2d_LayerGradient_class->finalize = js_cocos2d_LayerGradient_finalize; + jsb_cocos2d_LayerGradient_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getStartColor", js_cocos2dx_LayerGradient_getStartColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isCompressedInterpolation", js_cocos2dx_LayerGradient_isCompressedInterpolation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStartOpacity", js_cocos2dx_LayerGradient_getStartOpacity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setVector", js_cocos2dx_LayerGradient_setVector, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setStartOpacity", js_cocos2dx_LayerGradient_setStartOpacity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCompressedInterpolation", js_cocos2dx_LayerGradient_setCompressedInterpolation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEndOpacity", js_cocos2dx_LayerGradient_setEndOpacity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVector", js_cocos2dx_LayerGradient_getVector, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEndColor", js_cocos2dx_LayerGradient_setEndColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithColor", js_cocos2dx_LayerGradient_initWithColor, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEndColor", js_cocos2dx_LayerGradient_getEndColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEndOpacity", js_cocos2dx_LayerGradient_getEndOpacity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setStartColor", js_cocos2dx_LayerGradient_setStartColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_LayerGradient_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_LayerGradient_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_LayerGradient_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_LayerColor_prototype), + jsb_cocos2d_LayerGradient_class, + js_cocos2dx_LayerGradient_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, "LayerGradient", 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_LayerGradient_class; + p->proto = jsb_cocos2d_LayerGradient_prototype; + p->parentProto = jsb_cocos2d_LayerColor_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_LayerMultiplex_class; +JSObject *jsb_cocos2d_LayerMultiplex_prototype; + +bool js_cocos2dx_LayerMultiplex_initWithArray(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerMultiplex* cobj = (cocos2d::LayerMultiplex *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerMultiplex_initWithArray : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vector arg0; + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LayerMultiplex_initWithArray : Error processing arguments"); + bool ret = cobj->initWithArray(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerMultiplex_initWithArray : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LayerMultiplex_switchToAndReleaseMe(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerMultiplex* cobj = (cocos2d::LayerMultiplex *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerMultiplex_switchToAndReleaseMe : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LayerMultiplex_switchToAndReleaseMe : Error processing arguments"); + cobj->switchToAndReleaseMe(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerMultiplex_switchToAndReleaseMe : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LayerMultiplex_addLayer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerMultiplex* cobj = (cocos2d::LayerMultiplex *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerMultiplex_addLayer : Invalid Native Object"); + if (argc == 1) { + cocos2d::Layer* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Layer*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LayerMultiplex_addLayer : Error processing arguments"); + cobj->addLayer(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerMultiplex_addLayer : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LayerMultiplex_switchTo(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::LayerMultiplex* cobj = (cocos2d::LayerMultiplex *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_LayerMultiplex_switchTo : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_LayerMultiplex_switchTo : Error processing arguments"); + cobj->switchTo(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_LayerMultiplex_switchTo : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_LayerMultiplex_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::LayerMultiplex* cobj = new (std::nothrow) cocos2d::LayerMultiplex(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::LayerMultiplex"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Layer_prototype; + +void js_cocos2d_LayerMultiplex_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (LayerMultiplex)", obj); +} + +static bool js_cocos2d_LayerMultiplex_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::LayerMultiplex *nobj = new (std::nothrow) cocos2d::LayerMultiplex(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::LayerMultiplex"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_LayerMultiplex(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_LayerMultiplex_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_LayerMultiplex_class->name = "LayerMultiplex"; + jsb_cocos2d_LayerMultiplex_class->addProperty = JS_PropertyStub; + jsb_cocos2d_LayerMultiplex_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_LayerMultiplex_class->getProperty = JS_PropertyStub; + jsb_cocos2d_LayerMultiplex_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_LayerMultiplex_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_LayerMultiplex_class->resolve = JS_ResolveStub; + jsb_cocos2d_LayerMultiplex_class->convert = JS_ConvertStub; + jsb_cocos2d_LayerMultiplex_class->finalize = js_cocos2d_LayerMultiplex_finalize; + jsb_cocos2d_LayerMultiplex_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithArray", js_cocos2dx_LayerMultiplex_initWithArray, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("switchToAndReleaseMe", js_cocos2dx_LayerMultiplex_switchToAndReleaseMe, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addLayer", js_cocos2dx_LayerMultiplex_addLayer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("switchTo", js_cocos2dx_LayerMultiplex_switchTo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_LayerMultiplex_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_LayerMultiplex_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Layer_prototype), + jsb_cocos2d_LayerMultiplex_class, + js_cocos2dx_LayerMultiplex_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, "LayerMultiplex", 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_LayerMultiplex_class; + p->proto = jsb_cocos2d_LayerMultiplex_prototype; + p->parentProto = jsb_cocos2d_Layer_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionEaseScene_class; +JSObject *jsb_cocos2d_TransitionEaseScene_prototype; + +bool js_cocos2dx_TransitionEaseScene_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TransitionEaseScene* cobj = (cocos2d::TransitionEaseScene *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionEaseScene_easeActionWithAction : Invalid Native Object"); + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionEaseScene_easeActionWithAction : Error processing arguments"); + cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TransitionEaseScene_easeActionWithAction : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + + +void js_cocos2d_TransitionEaseScene_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionEaseScene)", obj); +} + +void js_register_cocos2dx_TransitionEaseScene(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionEaseScene_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionEaseScene_class->name = "TransitionEaseScene"; + jsb_cocos2d_TransitionEaseScene_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionEaseScene_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionEaseScene_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionEaseScene_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionEaseScene_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionEaseScene_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionEaseScene_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionEaseScene_class->finalize = js_cocos2d_TransitionEaseScene_finalize; + jsb_cocos2d_TransitionEaseScene_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("easeActionWithAction", js_cocos2dx_TransitionEaseScene_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_TransitionEaseScene_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_TransitionEaseScene_class, + empty_constructor, 0, + 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, "TransitionEaseScene", 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_TransitionEaseScene_class; + p->proto = jsb_cocos2d_TransitionEaseScene_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionScene_class; +JSObject *jsb_cocos2d_TransitionScene_prototype; + +bool js_cocos2dx_TransitionScene_getInScene(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TransitionScene* cobj = (cocos2d::TransitionScene *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionScene_getInScene : Invalid Native Object"); + if (argc == 0) { + cocos2d::Scene* ret = cobj->getInScene(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Scene*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TransitionScene_getInScene : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TransitionScene_finish(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TransitionScene* cobj = (cocos2d::TransitionScene *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionScene_finish : Invalid Native Object"); + if (argc == 0) { + cobj->finish(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TransitionScene_finish : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TransitionScene_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TransitionScene* cobj = (cocos2d::TransitionScene *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionScene_initWithDuration : Invalid Native Object"); + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionScene_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TransitionScene_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_TransitionScene_getDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TransitionScene* cobj = (cocos2d::TransitionScene *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionScene_getDuration : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getDuration(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TransitionScene_getDuration : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TransitionScene_hideOutShowIn(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TransitionScene* cobj = (cocos2d::TransitionScene *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionScene_hideOutShowIn : Invalid Native Object"); + if (argc == 0) { + cobj->hideOutShowIn(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TransitionScene_hideOutShowIn : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TransitionScene_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionScene_create : Error processing arguments"); + cocos2d::TransitionScene* ret = cocos2d::TransitionScene::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionScene*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionScene_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionScene_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionScene* cobj = new (std::nothrow) cocos2d::TransitionScene(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionScene"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Scene_prototype; + +void js_cocos2d_TransitionScene_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionScene)", obj); +} + +static bool js_cocos2d_TransitionScene_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TransitionScene *nobj = new (std::nothrow) cocos2d::TransitionScene(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionScene"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_TransitionScene(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionScene_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionScene_class->name = "TransitionScene"; + jsb_cocos2d_TransitionScene_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionScene_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionScene_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionScene_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionScene_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionScene_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionScene_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionScene_class->finalize = js_cocos2d_TransitionScene_finalize; + jsb_cocos2d_TransitionScene_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getInScene", js_cocos2dx_TransitionScene_getInScene, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("finish", js_cocos2dx_TransitionScene_finish, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithDuration", js_cocos2dx_TransitionScene_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDuration", js_cocos2dx_TransitionScene_getDuration, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("hideOutShowIn", js_cocos2dx_TransitionScene_hideOutShowIn, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_TransitionScene_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionScene_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionScene_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Scene_prototype), + jsb_cocos2d_TransitionScene_class, + js_cocos2dx_TransitionScene_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, "TransitionScene", 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_TransitionScene_class; + p->proto = jsb_cocos2d_TransitionScene_prototype; + p->parentProto = jsb_cocos2d_Scene_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionSceneOriented_class; +JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; + +bool js_cocos2dx_TransitionSceneOriented_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TransitionSceneOriented* cobj = (cocos2d::TransitionSceneOriented *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionSceneOriented_initWithDuration : Invalid Native Object"); + if (argc == 3) { + double arg0; + cocos2d::Scene* arg1; + cocos2d::TransitionScene::Orientation arg2; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionSceneOriented_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TransitionSceneOriented_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_TransitionSceneOriented_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 3) { + double arg0; + cocos2d::Scene* arg1; + cocos2d::TransitionScene::Orientation arg2; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionSceneOriented_create : Error processing arguments"); + cocos2d::TransitionSceneOriented* ret = cocos2d::TransitionSceneOriented::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionSceneOriented*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionSceneOriented_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionSceneOriented_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionSceneOriented* cobj = new (std::nothrow) cocos2d::TransitionSceneOriented(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionSceneOriented"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionScene_prototype; + +void js_cocos2d_TransitionSceneOriented_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSceneOriented)", obj); +} + +void js_register_cocos2dx_TransitionSceneOriented(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionSceneOriented_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionSceneOriented_class->name = "TransitionSceneOriented"; + jsb_cocos2d_TransitionSceneOriented_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionSceneOriented_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionSceneOriented_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionSceneOriented_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionSceneOriented_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionSceneOriented_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionSceneOriented_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionSceneOriented_class->finalize = js_cocos2d_TransitionSceneOriented_finalize; + jsb_cocos2d_TransitionSceneOriented_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_TransitionSceneOriented_initWithDuration, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionSceneOriented_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionSceneOriented_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + jsb_cocos2d_TransitionSceneOriented_class, + js_cocos2dx_TransitionSceneOriented_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, "TransitionSceneOriented", 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_TransitionSceneOriented_class; + p->proto = jsb_cocos2d_TransitionSceneOriented_prototype; + p->parentProto = jsb_cocos2d_TransitionScene_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionRotoZoom_class; +JSObject *jsb_cocos2d_TransitionRotoZoom_prototype; + +bool js_cocos2dx_TransitionRotoZoom_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionRotoZoom_create : Error processing arguments"); + cocos2d::TransitionRotoZoom* ret = cocos2d::TransitionRotoZoom::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionRotoZoom*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionRotoZoom_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionRotoZoom_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionRotoZoom* cobj = new (std::nothrow) cocos2d::TransitionRotoZoom(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionRotoZoom"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionScene_prototype; + +void js_cocos2d_TransitionRotoZoom_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionRotoZoom)", obj); +} + +void js_register_cocos2dx_TransitionRotoZoom(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionRotoZoom_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionRotoZoom_class->name = "TransitionRotoZoom"; + jsb_cocos2d_TransitionRotoZoom_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionRotoZoom_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionRotoZoom_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionRotoZoom_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionRotoZoom_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionRotoZoom_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionRotoZoom_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionRotoZoom_class->finalize = js_cocos2d_TransitionRotoZoom_finalize; + jsb_cocos2d_TransitionRotoZoom_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionRotoZoom_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionRotoZoom_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + jsb_cocos2d_TransitionRotoZoom_class, + js_cocos2dx_TransitionRotoZoom_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, "TransitionRotoZoom", 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_TransitionRotoZoom_class; + p->proto = jsb_cocos2d_TransitionRotoZoom_prototype; + p->parentProto = jsb_cocos2d_TransitionScene_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionJumpZoom_class; +JSObject *jsb_cocos2d_TransitionJumpZoom_prototype; + +bool js_cocos2dx_TransitionJumpZoom_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionJumpZoom_create : Error processing arguments"); + cocos2d::TransitionJumpZoom* ret = cocos2d::TransitionJumpZoom::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionJumpZoom*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionJumpZoom_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionJumpZoom_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionJumpZoom* cobj = new (std::nothrow) cocos2d::TransitionJumpZoom(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionJumpZoom"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionScene_prototype; + +void js_cocos2d_TransitionJumpZoom_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionJumpZoom)", obj); +} + +void js_register_cocos2dx_TransitionJumpZoom(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionJumpZoom_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionJumpZoom_class->name = "TransitionJumpZoom"; + jsb_cocos2d_TransitionJumpZoom_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionJumpZoom_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionJumpZoom_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionJumpZoom_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionJumpZoom_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionJumpZoom_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionJumpZoom_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionJumpZoom_class->finalize = js_cocos2d_TransitionJumpZoom_finalize; + jsb_cocos2d_TransitionJumpZoom_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionJumpZoom_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionJumpZoom_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + jsb_cocos2d_TransitionJumpZoom_class, + js_cocos2dx_TransitionJumpZoom_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, "TransitionJumpZoom", 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_TransitionJumpZoom_class; + p->proto = jsb_cocos2d_TransitionJumpZoom_prototype; + p->parentProto = jsb_cocos2d_TransitionScene_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionMoveInL_class; +JSObject *jsb_cocos2d_TransitionMoveInL_prototype; + +bool js_cocos2dx_TransitionMoveInL_action(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TransitionMoveInL* cobj = (cocos2d::TransitionMoveInL *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionMoveInL_action : Invalid Native Object"); + if (argc == 0) { + cocos2d::ActionInterval* ret = cobj->action(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TransitionMoveInL_action : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TransitionMoveInL_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TransitionMoveInL* cobj = (cocos2d::TransitionMoveInL *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionMoveInL_easeActionWithAction : Invalid Native Object"); + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionMoveInL_easeActionWithAction : Error processing arguments"); + cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TransitionMoveInL_easeActionWithAction : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TransitionMoveInL_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionMoveInL_create : Error processing arguments"); + cocos2d::TransitionMoveInL* ret = cocos2d::TransitionMoveInL::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionMoveInL*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionMoveInL_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionMoveInL_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionMoveInL* cobj = new (std::nothrow) cocos2d::TransitionMoveInL(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionMoveInL"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionScene_prototype; + +void js_cocos2d_TransitionMoveInL_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionMoveInL)", obj); +} + +void js_register_cocos2dx_TransitionMoveInL(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionMoveInL_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionMoveInL_class->name = "TransitionMoveInL"; + jsb_cocos2d_TransitionMoveInL_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionMoveInL_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionMoveInL_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionMoveInL_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionMoveInL_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionMoveInL_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionMoveInL_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionMoveInL_class->finalize = js_cocos2d_TransitionMoveInL_finalize; + jsb_cocos2d_TransitionMoveInL_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("action", js_cocos2dx_TransitionMoveInL_action, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("easeActionWithAction", js_cocos2dx_TransitionMoveInL_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionMoveInL_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionMoveInL_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + jsb_cocos2d_TransitionMoveInL_class, + js_cocos2dx_TransitionMoveInL_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, "TransitionMoveInL", 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_TransitionMoveInL_class; + p->proto = jsb_cocos2d_TransitionMoveInL_prototype; + p->parentProto = jsb_cocos2d_TransitionScene_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionMoveInR_class; +JSObject *jsb_cocos2d_TransitionMoveInR_prototype; + +bool js_cocos2dx_TransitionMoveInR_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionMoveInR_create : Error processing arguments"); + cocos2d::TransitionMoveInR* ret = cocos2d::TransitionMoveInR::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionMoveInR*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionMoveInR_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionMoveInR_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionMoveInR* cobj = new (std::nothrow) cocos2d::TransitionMoveInR(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionMoveInR"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionMoveInL_prototype; + +void js_cocos2d_TransitionMoveInR_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionMoveInR)", obj); +} + +void js_register_cocos2dx_TransitionMoveInR(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionMoveInR_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionMoveInR_class->name = "TransitionMoveInR"; + jsb_cocos2d_TransitionMoveInR_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionMoveInR_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionMoveInR_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionMoveInR_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionMoveInR_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionMoveInR_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionMoveInR_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionMoveInR_class->finalize = js_cocos2d_TransitionMoveInR_finalize; + jsb_cocos2d_TransitionMoveInR_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionMoveInR_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionMoveInR_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionMoveInL_prototype), + jsb_cocos2d_TransitionMoveInR_class, + js_cocos2dx_TransitionMoveInR_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, "TransitionMoveInR", 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_TransitionMoveInR_class; + p->proto = jsb_cocos2d_TransitionMoveInR_prototype; + p->parentProto = jsb_cocos2d_TransitionMoveInL_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionMoveInT_class; +JSObject *jsb_cocos2d_TransitionMoveInT_prototype; + +bool js_cocos2dx_TransitionMoveInT_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionMoveInT_create : Error processing arguments"); + cocos2d::TransitionMoveInT* ret = cocos2d::TransitionMoveInT::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionMoveInT*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionMoveInT_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionMoveInT_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionMoveInT* cobj = new (std::nothrow) cocos2d::TransitionMoveInT(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionMoveInT"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionMoveInL_prototype; + +void js_cocos2d_TransitionMoveInT_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionMoveInT)", obj); +} + +void js_register_cocos2dx_TransitionMoveInT(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionMoveInT_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionMoveInT_class->name = "TransitionMoveInT"; + jsb_cocos2d_TransitionMoveInT_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionMoveInT_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionMoveInT_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionMoveInT_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionMoveInT_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionMoveInT_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionMoveInT_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionMoveInT_class->finalize = js_cocos2d_TransitionMoveInT_finalize; + jsb_cocos2d_TransitionMoveInT_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionMoveInT_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionMoveInT_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionMoveInL_prototype), + jsb_cocos2d_TransitionMoveInT_class, + js_cocos2dx_TransitionMoveInT_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, "TransitionMoveInT", 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_TransitionMoveInT_class; + p->proto = jsb_cocos2d_TransitionMoveInT_prototype; + p->parentProto = jsb_cocos2d_TransitionMoveInL_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionMoveInB_class; +JSObject *jsb_cocos2d_TransitionMoveInB_prototype; + +bool js_cocos2dx_TransitionMoveInB_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionMoveInB_create : Error processing arguments"); + cocos2d::TransitionMoveInB* ret = cocos2d::TransitionMoveInB::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionMoveInB*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionMoveInB_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionMoveInB_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionMoveInB* cobj = new (std::nothrow) cocos2d::TransitionMoveInB(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionMoveInB"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionMoveInL_prototype; + +void js_cocos2d_TransitionMoveInB_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionMoveInB)", obj); +} + +void js_register_cocos2dx_TransitionMoveInB(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionMoveInB_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionMoveInB_class->name = "TransitionMoveInB"; + jsb_cocos2d_TransitionMoveInB_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionMoveInB_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionMoveInB_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionMoveInB_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionMoveInB_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionMoveInB_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionMoveInB_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionMoveInB_class->finalize = js_cocos2d_TransitionMoveInB_finalize; + jsb_cocos2d_TransitionMoveInB_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionMoveInB_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionMoveInB_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionMoveInL_prototype), + jsb_cocos2d_TransitionMoveInB_class, + js_cocos2dx_TransitionMoveInB_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, "TransitionMoveInB", 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_TransitionMoveInB_class; + p->proto = jsb_cocos2d_TransitionMoveInB_prototype; + p->parentProto = jsb_cocos2d_TransitionMoveInL_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionSlideInL_class; +JSObject *jsb_cocos2d_TransitionSlideInL_prototype; + +bool js_cocos2dx_TransitionSlideInL_action(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TransitionSlideInL* cobj = (cocos2d::TransitionSlideInL *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionSlideInL_action : Invalid Native Object"); + if (argc == 0) { + cocos2d::ActionInterval* ret = cobj->action(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TransitionSlideInL_action : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TransitionSlideInL_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TransitionSlideInL* cobj = (cocos2d::TransitionSlideInL *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionSlideInL_easeActionWithAction : Invalid Native Object"); + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionSlideInL_easeActionWithAction : Error processing arguments"); + cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TransitionSlideInL_easeActionWithAction : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TransitionSlideInL_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionSlideInL_create : Error processing arguments"); + cocos2d::TransitionSlideInL* ret = cocos2d::TransitionSlideInL::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionSlideInL*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionSlideInL_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionSlideInL_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionSlideInL* cobj = new (std::nothrow) cocos2d::TransitionSlideInL(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionSlideInL"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionScene_prototype; + +void js_cocos2d_TransitionSlideInL_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSlideInL)", obj); +} + +void js_register_cocos2dx_TransitionSlideInL(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionSlideInL_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionSlideInL_class->name = "TransitionSlideInL"; + jsb_cocos2d_TransitionSlideInL_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionSlideInL_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionSlideInL_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionSlideInL_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionSlideInL_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionSlideInL_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionSlideInL_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionSlideInL_class->finalize = js_cocos2d_TransitionSlideInL_finalize; + jsb_cocos2d_TransitionSlideInL_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("action", js_cocos2dx_TransitionSlideInL_action, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("easeActionWithAction", js_cocos2dx_TransitionSlideInL_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionSlideInL_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionSlideInL_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + jsb_cocos2d_TransitionSlideInL_class, + js_cocos2dx_TransitionSlideInL_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, "TransitionSlideInL", 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_TransitionSlideInL_class; + p->proto = jsb_cocos2d_TransitionSlideInL_prototype; + p->parentProto = jsb_cocos2d_TransitionScene_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionSlideInR_class; +JSObject *jsb_cocos2d_TransitionSlideInR_prototype; + +bool js_cocos2dx_TransitionSlideInR_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionSlideInR_create : Error processing arguments"); + cocos2d::TransitionSlideInR* ret = cocos2d::TransitionSlideInR::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionSlideInR*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionSlideInR_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionSlideInR_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionSlideInR* cobj = new (std::nothrow) cocos2d::TransitionSlideInR(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionSlideInR"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionSlideInL_prototype; + +void js_cocos2d_TransitionSlideInR_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSlideInR)", obj); +} + +void js_register_cocos2dx_TransitionSlideInR(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionSlideInR_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionSlideInR_class->name = "TransitionSlideInR"; + jsb_cocos2d_TransitionSlideInR_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionSlideInR_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionSlideInR_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionSlideInR_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionSlideInR_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionSlideInR_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionSlideInR_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionSlideInR_class->finalize = js_cocos2d_TransitionSlideInR_finalize; + jsb_cocos2d_TransitionSlideInR_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionSlideInR_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionSlideInR_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionSlideInL_prototype), + jsb_cocos2d_TransitionSlideInR_class, + js_cocos2dx_TransitionSlideInR_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, "TransitionSlideInR", 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_TransitionSlideInR_class; + p->proto = jsb_cocos2d_TransitionSlideInR_prototype; + p->parentProto = jsb_cocos2d_TransitionSlideInL_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionSlideInB_class; +JSObject *jsb_cocos2d_TransitionSlideInB_prototype; + +bool js_cocos2dx_TransitionSlideInB_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionSlideInB_create : Error processing arguments"); + cocos2d::TransitionSlideInB* ret = cocos2d::TransitionSlideInB::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionSlideInB*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionSlideInB_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionSlideInB_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionSlideInB* cobj = new (std::nothrow) cocos2d::TransitionSlideInB(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionSlideInB"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionSlideInL_prototype; + +void js_cocos2d_TransitionSlideInB_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSlideInB)", obj); +} + +void js_register_cocos2dx_TransitionSlideInB(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionSlideInB_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionSlideInB_class->name = "TransitionSlideInB"; + jsb_cocos2d_TransitionSlideInB_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionSlideInB_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionSlideInB_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionSlideInB_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionSlideInB_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionSlideInB_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionSlideInB_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionSlideInB_class->finalize = js_cocos2d_TransitionSlideInB_finalize; + jsb_cocos2d_TransitionSlideInB_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionSlideInB_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionSlideInB_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionSlideInL_prototype), + jsb_cocos2d_TransitionSlideInB_class, + js_cocos2dx_TransitionSlideInB_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, "TransitionSlideInB", 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_TransitionSlideInB_class; + p->proto = jsb_cocos2d_TransitionSlideInB_prototype; + p->parentProto = jsb_cocos2d_TransitionSlideInL_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionSlideInT_class; +JSObject *jsb_cocos2d_TransitionSlideInT_prototype; + +bool js_cocos2dx_TransitionSlideInT_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionSlideInT_create : Error processing arguments"); + cocos2d::TransitionSlideInT* ret = cocos2d::TransitionSlideInT::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionSlideInT*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionSlideInT_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionSlideInT_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionSlideInT* cobj = new (std::nothrow) cocos2d::TransitionSlideInT(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionSlideInT"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionSlideInL_prototype; + +void js_cocos2d_TransitionSlideInT_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSlideInT)", obj); +} + +void js_register_cocos2dx_TransitionSlideInT(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionSlideInT_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionSlideInT_class->name = "TransitionSlideInT"; + jsb_cocos2d_TransitionSlideInT_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionSlideInT_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionSlideInT_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionSlideInT_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionSlideInT_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionSlideInT_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionSlideInT_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionSlideInT_class->finalize = js_cocos2d_TransitionSlideInT_finalize; + jsb_cocos2d_TransitionSlideInT_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionSlideInT_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionSlideInT_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionSlideInL_prototype), + jsb_cocos2d_TransitionSlideInT_class, + js_cocos2dx_TransitionSlideInT_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, "TransitionSlideInT", 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_TransitionSlideInT_class; + p->proto = jsb_cocos2d_TransitionSlideInT_prototype; + p->parentProto = jsb_cocos2d_TransitionSlideInL_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionShrinkGrow_class; +JSObject *jsb_cocos2d_TransitionShrinkGrow_prototype; + +bool js_cocos2dx_TransitionShrinkGrow_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TransitionShrinkGrow* cobj = (cocos2d::TransitionShrinkGrow *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionShrinkGrow_easeActionWithAction : Invalid Native Object"); + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionShrinkGrow_easeActionWithAction : Error processing arguments"); + cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TransitionShrinkGrow_easeActionWithAction : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TransitionShrinkGrow_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionShrinkGrow_create : Error processing arguments"); + cocos2d::TransitionShrinkGrow* ret = cocos2d::TransitionShrinkGrow::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionShrinkGrow*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionShrinkGrow_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionShrinkGrow_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionShrinkGrow* cobj = new (std::nothrow) cocos2d::TransitionShrinkGrow(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionShrinkGrow"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionScene_prototype; + +void js_cocos2d_TransitionShrinkGrow_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionShrinkGrow)", obj); +} + +void js_register_cocos2dx_TransitionShrinkGrow(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionShrinkGrow_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionShrinkGrow_class->name = "TransitionShrinkGrow"; + jsb_cocos2d_TransitionShrinkGrow_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionShrinkGrow_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionShrinkGrow_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionShrinkGrow_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionShrinkGrow_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionShrinkGrow_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionShrinkGrow_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionShrinkGrow_class->finalize = js_cocos2d_TransitionShrinkGrow_finalize; + jsb_cocos2d_TransitionShrinkGrow_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("easeActionWithAction", js_cocos2dx_TransitionShrinkGrow_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionShrinkGrow_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionShrinkGrow_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + jsb_cocos2d_TransitionShrinkGrow_class, + js_cocos2dx_TransitionShrinkGrow_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, "TransitionShrinkGrow", 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_TransitionShrinkGrow_class; + p->proto = jsb_cocos2d_TransitionShrinkGrow_prototype; + p->parentProto = jsb_cocos2d_TransitionScene_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionFlipX_class; +JSObject *jsb_cocos2d_TransitionFlipX_prototype; + +bool js_cocos2dx_TransitionFlipX_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Scene* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::TransitionFlipX* ret = cocos2d::TransitionFlipX::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFlipX*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 3) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Scene* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::TransitionScene::Orientation arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + cocos2d::TransitionFlipX* ret = cocos2d::TransitionFlipX::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFlipX*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_TransitionFlipX_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TransitionFlipX_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionFlipX* cobj = new (std::nothrow) cocos2d::TransitionFlipX(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionFlipX"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; + +void js_cocos2d_TransitionFlipX_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFlipX)", obj); +} + +void js_register_cocos2dx_TransitionFlipX(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionFlipX_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionFlipX_class->name = "TransitionFlipX"; + jsb_cocos2d_TransitionFlipX_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionFlipX_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionFlipX_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionFlipX_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionFlipX_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionFlipX_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionFlipX_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionFlipX_class->finalize = js_cocos2d_TransitionFlipX_finalize; + jsb_cocos2d_TransitionFlipX_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionFlipX_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionFlipX_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionSceneOriented_prototype), + jsb_cocos2d_TransitionFlipX_class, + js_cocos2dx_TransitionFlipX_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, "TransitionFlipX", 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_TransitionFlipX_class; + p->proto = jsb_cocos2d_TransitionFlipX_prototype; + p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionFlipY_class; +JSObject *jsb_cocos2d_TransitionFlipY_prototype; + +bool js_cocos2dx_TransitionFlipY_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Scene* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::TransitionFlipY* ret = cocos2d::TransitionFlipY::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFlipY*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 3) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Scene* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::TransitionScene::Orientation arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + cocos2d::TransitionFlipY* ret = cocos2d::TransitionFlipY::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFlipY*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_TransitionFlipY_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TransitionFlipY_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionFlipY* cobj = new (std::nothrow) cocos2d::TransitionFlipY(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionFlipY"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; + +void js_cocos2d_TransitionFlipY_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFlipY)", obj); +} + +void js_register_cocos2dx_TransitionFlipY(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionFlipY_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionFlipY_class->name = "TransitionFlipY"; + jsb_cocos2d_TransitionFlipY_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionFlipY_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionFlipY_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionFlipY_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionFlipY_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionFlipY_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionFlipY_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionFlipY_class->finalize = js_cocos2d_TransitionFlipY_finalize; + jsb_cocos2d_TransitionFlipY_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionFlipY_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionFlipY_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionSceneOriented_prototype), + jsb_cocos2d_TransitionFlipY_class, + js_cocos2dx_TransitionFlipY_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, "TransitionFlipY", 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_TransitionFlipY_class; + p->proto = jsb_cocos2d_TransitionFlipY_prototype; + p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionFlipAngular_class; +JSObject *jsb_cocos2d_TransitionFlipAngular_prototype; + +bool js_cocos2dx_TransitionFlipAngular_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Scene* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::TransitionFlipAngular* ret = cocos2d::TransitionFlipAngular::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFlipAngular*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 3) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Scene* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::TransitionScene::Orientation arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + cocos2d::TransitionFlipAngular* ret = cocos2d::TransitionFlipAngular::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFlipAngular*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_TransitionFlipAngular_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TransitionFlipAngular_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionFlipAngular* cobj = new (std::nothrow) cocos2d::TransitionFlipAngular(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionFlipAngular"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; + +void js_cocos2d_TransitionFlipAngular_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFlipAngular)", obj); +} + +void js_register_cocos2dx_TransitionFlipAngular(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionFlipAngular_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionFlipAngular_class->name = "TransitionFlipAngular"; + jsb_cocos2d_TransitionFlipAngular_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionFlipAngular_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionFlipAngular_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionFlipAngular_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionFlipAngular_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionFlipAngular_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionFlipAngular_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionFlipAngular_class->finalize = js_cocos2d_TransitionFlipAngular_finalize; + jsb_cocos2d_TransitionFlipAngular_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionFlipAngular_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionFlipAngular_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionSceneOriented_prototype), + jsb_cocos2d_TransitionFlipAngular_class, + js_cocos2dx_TransitionFlipAngular_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, "TransitionFlipAngular", 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_TransitionFlipAngular_class; + p->proto = jsb_cocos2d_TransitionFlipAngular_prototype; + p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionZoomFlipX_class; +JSObject *jsb_cocos2d_TransitionZoomFlipX_prototype; + +bool js_cocos2dx_TransitionZoomFlipX_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Scene* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::TransitionZoomFlipX* ret = cocos2d::TransitionZoomFlipX::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionZoomFlipX*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 3) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Scene* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::TransitionScene::Orientation arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + cocos2d::TransitionZoomFlipX* ret = cocos2d::TransitionZoomFlipX::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionZoomFlipX*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_TransitionZoomFlipX_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TransitionZoomFlipX_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionZoomFlipX* cobj = new (std::nothrow) cocos2d::TransitionZoomFlipX(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionZoomFlipX"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; + +void js_cocos2d_TransitionZoomFlipX_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionZoomFlipX)", obj); +} + +void js_register_cocos2dx_TransitionZoomFlipX(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionZoomFlipX_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionZoomFlipX_class->name = "TransitionZoomFlipX"; + jsb_cocos2d_TransitionZoomFlipX_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionZoomFlipX_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionZoomFlipX_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionZoomFlipX_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionZoomFlipX_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionZoomFlipX_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionZoomFlipX_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionZoomFlipX_class->finalize = js_cocos2d_TransitionZoomFlipX_finalize; + jsb_cocos2d_TransitionZoomFlipX_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionZoomFlipX_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionZoomFlipX_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionSceneOriented_prototype), + jsb_cocos2d_TransitionZoomFlipX_class, + js_cocos2dx_TransitionZoomFlipX_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, "TransitionZoomFlipX", 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_TransitionZoomFlipX_class; + p->proto = jsb_cocos2d_TransitionZoomFlipX_prototype; + p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionZoomFlipY_class; +JSObject *jsb_cocos2d_TransitionZoomFlipY_prototype; + +bool js_cocos2dx_TransitionZoomFlipY_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Scene* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::TransitionZoomFlipY* ret = cocos2d::TransitionZoomFlipY::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionZoomFlipY*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 3) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Scene* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::TransitionScene::Orientation arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + cocos2d::TransitionZoomFlipY* ret = cocos2d::TransitionZoomFlipY::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionZoomFlipY*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_TransitionZoomFlipY_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TransitionZoomFlipY_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionZoomFlipY* cobj = new (std::nothrow) cocos2d::TransitionZoomFlipY(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionZoomFlipY"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; + +void js_cocos2d_TransitionZoomFlipY_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionZoomFlipY)", obj); +} + +void js_register_cocos2dx_TransitionZoomFlipY(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionZoomFlipY_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionZoomFlipY_class->name = "TransitionZoomFlipY"; + jsb_cocos2d_TransitionZoomFlipY_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionZoomFlipY_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionZoomFlipY_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionZoomFlipY_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionZoomFlipY_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionZoomFlipY_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionZoomFlipY_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionZoomFlipY_class->finalize = js_cocos2d_TransitionZoomFlipY_finalize; + jsb_cocos2d_TransitionZoomFlipY_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionZoomFlipY_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionZoomFlipY_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionSceneOriented_prototype), + jsb_cocos2d_TransitionZoomFlipY_class, + js_cocos2dx_TransitionZoomFlipY_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, "TransitionZoomFlipY", 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_TransitionZoomFlipY_class; + p->proto = jsb_cocos2d_TransitionZoomFlipY_prototype; + p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionZoomFlipAngular_class; +JSObject *jsb_cocos2d_TransitionZoomFlipAngular_prototype; + +bool js_cocos2dx_TransitionZoomFlipAngular_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Scene* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::TransitionZoomFlipAngular* ret = cocos2d::TransitionZoomFlipAngular::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionZoomFlipAngular*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 3) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Scene* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::TransitionScene::Orientation arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + cocos2d::TransitionZoomFlipAngular* ret = cocos2d::TransitionZoomFlipAngular::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionZoomFlipAngular*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_TransitionZoomFlipAngular_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TransitionZoomFlipAngular_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionZoomFlipAngular* cobj = new (std::nothrow) cocos2d::TransitionZoomFlipAngular(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionZoomFlipAngular"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; + +void js_cocos2d_TransitionZoomFlipAngular_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionZoomFlipAngular)", obj); +} + +void js_register_cocos2dx_TransitionZoomFlipAngular(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionZoomFlipAngular_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionZoomFlipAngular_class->name = "TransitionZoomFlipAngular"; + jsb_cocos2d_TransitionZoomFlipAngular_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionZoomFlipAngular_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionZoomFlipAngular_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionZoomFlipAngular_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionZoomFlipAngular_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionZoomFlipAngular_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionZoomFlipAngular_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionZoomFlipAngular_class->finalize = js_cocos2d_TransitionZoomFlipAngular_finalize; + jsb_cocos2d_TransitionZoomFlipAngular_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionZoomFlipAngular_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionZoomFlipAngular_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionSceneOriented_prototype), + jsb_cocos2d_TransitionZoomFlipAngular_class, + js_cocos2dx_TransitionZoomFlipAngular_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, "TransitionZoomFlipAngular", 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_TransitionZoomFlipAngular_class; + p->proto = jsb_cocos2d_TransitionZoomFlipAngular_prototype; + p->parentProto = jsb_cocos2d_TransitionSceneOriented_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionFade_class; +JSObject *jsb_cocos2d_TransitionFade_prototype; + +bool js_cocos2dx_TransitionFade_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::TransitionFade* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::TransitionFade *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionFade_initWithDuration : Invalid Native Object"); + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Scene* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithDuration(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 3) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Scene* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Color3B arg2; + ok &= jsval_to_cccolor3b(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithDuration(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_TransitionFade_initWithDuration : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TransitionFade_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Scene* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::TransitionFade* ret = cocos2d::TransitionFade::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFade*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 3) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cocos2d::Scene* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Color3B arg2; + ok &= jsval_to_cccolor3b(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cocos2d::TransitionFade* ret = cocos2d::TransitionFade::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFade*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_TransitionFade_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TransitionFade_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionFade* cobj = new (std::nothrow) cocos2d::TransitionFade(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionFade"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionScene_prototype; + +void js_cocos2d_TransitionFade_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFade)", obj); +} + +void js_register_cocos2dx_TransitionFade(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionFade_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionFade_class->name = "TransitionFade"; + jsb_cocos2d_TransitionFade_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionFade_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionFade_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionFade_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionFade_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionFade_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionFade_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionFade_class->finalize = js_cocos2d_TransitionFade_finalize; + jsb_cocos2d_TransitionFade_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithDuration", js_cocos2dx_TransitionFade_initWithDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionFade_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionFade_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + jsb_cocos2d_TransitionFade_class, + js_cocos2dx_TransitionFade_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, "TransitionFade", 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_TransitionFade_class; + p->proto = jsb_cocos2d_TransitionFade_prototype; + p->parentProto = jsb_cocos2d_TransitionScene_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionCrossFade_class; +JSObject *jsb_cocos2d_TransitionCrossFade_prototype; + +bool js_cocos2dx_TransitionCrossFade_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionCrossFade_create : Error processing arguments"); + cocos2d::TransitionCrossFade* ret = cocos2d::TransitionCrossFade::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionCrossFade*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionCrossFade_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionCrossFade_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionCrossFade* cobj = new (std::nothrow) cocos2d::TransitionCrossFade(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionCrossFade"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionScene_prototype; + +void js_cocos2d_TransitionCrossFade_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionCrossFade)", obj); +} + +void js_register_cocos2dx_TransitionCrossFade(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionCrossFade_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionCrossFade_class->name = "TransitionCrossFade"; + jsb_cocos2d_TransitionCrossFade_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionCrossFade_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionCrossFade_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionCrossFade_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionCrossFade_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionCrossFade_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionCrossFade_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionCrossFade_class->finalize = js_cocos2d_TransitionCrossFade_finalize; + jsb_cocos2d_TransitionCrossFade_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionCrossFade_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionCrossFade_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + jsb_cocos2d_TransitionCrossFade_class, + js_cocos2dx_TransitionCrossFade_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, "TransitionCrossFade", 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_TransitionCrossFade_class; + p->proto = jsb_cocos2d_TransitionCrossFade_prototype; + p->parentProto = jsb_cocos2d_TransitionScene_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionTurnOffTiles_class; +JSObject *jsb_cocos2d_TransitionTurnOffTiles_prototype; + +bool js_cocos2dx_TransitionTurnOffTiles_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TransitionTurnOffTiles* cobj = (cocos2d::TransitionTurnOffTiles *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionTurnOffTiles_easeActionWithAction : Invalid Native Object"); + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionTurnOffTiles_easeActionWithAction : Error processing arguments"); + cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TransitionTurnOffTiles_easeActionWithAction : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TransitionTurnOffTiles_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionTurnOffTiles_create : Error processing arguments"); + cocos2d::TransitionTurnOffTiles* ret = cocos2d::TransitionTurnOffTiles::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionTurnOffTiles*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionTurnOffTiles_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionTurnOffTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionTurnOffTiles* cobj = new (std::nothrow) cocos2d::TransitionTurnOffTiles(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionTurnOffTiles"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionScene_prototype; + +void js_cocos2d_TransitionTurnOffTiles_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionTurnOffTiles)", obj); +} + +void js_register_cocos2dx_TransitionTurnOffTiles(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionTurnOffTiles_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionTurnOffTiles_class->name = "TransitionTurnOffTiles"; + jsb_cocos2d_TransitionTurnOffTiles_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionTurnOffTiles_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionTurnOffTiles_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionTurnOffTiles_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionTurnOffTiles_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionTurnOffTiles_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionTurnOffTiles_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionTurnOffTiles_class->finalize = js_cocos2d_TransitionTurnOffTiles_finalize; + jsb_cocos2d_TransitionTurnOffTiles_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("easeActionWithAction", js_cocos2dx_TransitionTurnOffTiles_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionTurnOffTiles_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionTurnOffTiles_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + jsb_cocos2d_TransitionTurnOffTiles_class, + js_cocos2dx_TransitionTurnOffTiles_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, "TransitionTurnOffTiles", 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_TransitionTurnOffTiles_class; + p->proto = jsb_cocos2d_TransitionTurnOffTiles_prototype; + p->parentProto = jsb_cocos2d_TransitionScene_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionSplitCols_class; +JSObject *jsb_cocos2d_TransitionSplitCols_prototype; + +bool js_cocos2dx_TransitionSplitCols_action(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TransitionSplitCols* cobj = (cocos2d::TransitionSplitCols *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionSplitCols_action : Invalid Native Object"); + if (argc == 0) { + cocos2d::ActionInterval* ret = cobj->action(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TransitionSplitCols_action : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TransitionSplitCols_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TransitionSplitCols* cobj = (cocos2d::TransitionSplitCols *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionSplitCols_easeActionWithAction : Invalid Native Object"); + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionSplitCols_easeActionWithAction : Error processing arguments"); + cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TransitionSplitCols_easeActionWithAction : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TransitionSplitCols_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionSplitCols_create : Error processing arguments"); + cocos2d::TransitionSplitCols* ret = cocos2d::TransitionSplitCols::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionSplitCols*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionSplitCols_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionSplitCols_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionSplitCols* cobj = new (std::nothrow) cocos2d::TransitionSplitCols(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionSplitCols"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionScene_prototype; + +void js_cocos2d_TransitionSplitCols_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSplitCols)", obj); +} + +void js_register_cocos2dx_TransitionSplitCols(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionSplitCols_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionSplitCols_class->name = "TransitionSplitCols"; + jsb_cocos2d_TransitionSplitCols_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionSplitCols_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionSplitCols_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionSplitCols_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionSplitCols_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionSplitCols_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionSplitCols_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionSplitCols_class->finalize = js_cocos2d_TransitionSplitCols_finalize; + jsb_cocos2d_TransitionSplitCols_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("action", js_cocos2dx_TransitionSplitCols_action, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("easeActionWithAction", js_cocos2dx_TransitionSplitCols_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionSplitCols_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionSplitCols_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + jsb_cocos2d_TransitionSplitCols_class, + js_cocos2dx_TransitionSplitCols_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, "TransitionSplitCols", 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_TransitionSplitCols_class; + p->proto = jsb_cocos2d_TransitionSplitCols_prototype; + p->parentProto = jsb_cocos2d_TransitionScene_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionSplitRows_class; +JSObject *jsb_cocos2d_TransitionSplitRows_prototype; + +bool js_cocos2dx_TransitionSplitRows_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionSplitRows_create : Error processing arguments"); + cocos2d::TransitionSplitRows* ret = cocos2d::TransitionSplitRows::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionSplitRows*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionSplitRows_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionSplitRows_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionSplitRows* cobj = new (std::nothrow) cocos2d::TransitionSplitRows(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionSplitRows"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionSplitCols_prototype; + +void js_cocos2d_TransitionSplitRows_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionSplitRows)", obj); +} + +void js_register_cocos2dx_TransitionSplitRows(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionSplitRows_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionSplitRows_class->name = "TransitionSplitRows"; + jsb_cocos2d_TransitionSplitRows_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionSplitRows_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionSplitRows_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionSplitRows_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionSplitRows_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionSplitRows_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionSplitRows_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionSplitRows_class->finalize = js_cocos2d_TransitionSplitRows_finalize; + jsb_cocos2d_TransitionSplitRows_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionSplitRows_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionSplitRows_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionSplitCols_prototype), + jsb_cocos2d_TransitionSplitRows_class, + js_cocos2dx_TransitionSplitRows_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, "TransitionSplitRows", 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_TransitionSplitRows_class; + p->proto = jsb_cocos2d_TransitionSplitRows_prototype; + p->parentProto = jsb_cocos2d_TransitionSplitCols_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionFadeTR_class; +JSObject *jsb_cocos2d_TransitionFadeTR_prototype; + +bool js_cocos2dx_TransitionFadeTR_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TransitionFadeTR* cobj = (cocos2d::TransitionFadeTR *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionFadeTR_easeActionWithAction : Invalid Native Object"); + if (argc == 1) { + cocos2d::ActionInterval* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ActionInterval*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionFadeTR_easeActionWithAction : Error processing arguments"); + cocos2d::ActionInterval* ret = cobj->easeActionWithAction(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TransitionFadeTR_easeActionWithAction : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TransitionFadeTR_actionWithSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TransitionFadeTR* cobj = (cocos2d::TransitionFadeTR *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionFadeTR_actionWithSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionFadeTR_actionWithSize : Error processing arguments"); + cocos2d::ActionInterval* ret = cobj->actionWithSize(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TransitionFadeTR_actionWithSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TransitionFadeTR_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionFadeTR_create : Error processing arguments"); + cocos2d::TransitionFadeTR* ret = cocos2d::TransitionFadeTR::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFadeTR*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionFadeTR_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionFadeTR_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionFadeTR* cobj = new (std::nothrow) cocos2d::TransitionFadeTR(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionFadeTR"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionScene_prototype; + +void js_cocos2d_TransitionFadeTR_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFadeTR)", obj); +} + +void js_register_cocos2dx_TransitionFadeTR(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionFadeTR_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionFadeTR_class->name = "TransitionFadeTR"; + jsb_cocos2d_TransitionFadeTR_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionFadeTR_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionFadeTR_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionFadeTR_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionFadeTR_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionFadeTR_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionFadeTR_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionFadeTR_class->finalize = js_cocos2d_TransitionFadeTR_finalize; + jsb_cocos2d_TransitionFadeTR_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("easeActionWithAction", js_cocos2dx_TransitionFadeTR_easeActionWithAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("actionWithSize", js_cocos2dx_TransitionFadeTR_actionWithSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionFadeTR_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionFadeTR_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + jsb_cocos2d_TransitionFadeTR_class, + js_cocos2dx_TransitionFadeTR_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, "TransitionFadeTR", 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_TransitionFadeTR_class; + p->proto = jsb_cocos2d_TransitionFadeTR_prototype; + p->parentProto = jsb_cocos2d_TransitionScene_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionFadeBL_class; +JSObject *jsb_cocos2d_TransitionFadeBL_prototype; + +bool js_cocos2dx_TransitionFadeBL_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionFadeBL_create : Error processing arguments"); + cocos2d::TransitionFadeBL* ret = cocos2d::TransitionFadeBL::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFadeBL*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionFadeBL_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionFadeBL_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionFadeBL* cobj = new (std::nothrow) cocos2d::TransitionFadeBL(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionFadeBL"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionFadeTR_prototype; + +void js_cocos2d_TransitionFadeBL_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFadeBL)", obj); +} + +void js_register_cocos2dx_TransitionFadeBL(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionFadeBL_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionFadeBL_class->name = "TransitionFadeBL"; + jsb_cocos2d_TransitionFadeBL_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionFadeBL_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionFadeBL_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionFadeBL_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionFadeBL_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionFadeBL_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionFadeBL_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionFadeBL_class->finalize = js_cocos2d_TransitionFadeBL_finalize; + jsb_cocos2d_TransitionFadeBL_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionFadeBL_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionFadeBL_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionFadeTR_prototype), + jsb_cocos2d_TransitionFadeBL_class, + js_cocos2dx_TransitionFadeBL_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, "TransitionFadeBL", 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_TransitionFadeBL_class; + p->proto = jsb_cocos2d_TransitionFadeBL_prototype; + p->parentProto = jsb_cocos2d_TransitionFadeTR_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionFadeUp_class; +JSObject *jsb_cocos2d_TransitionFadeUp_prototype; + +bool js_cocos2dx_TransitionFadeUp_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionFadeUp_create : Error processing arguments"); + cocos2d::TransitionFadeUp* ret = cocos2d::TransitionFadeUp::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFadeUp*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionFadeUp_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionFadeUp_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionFadeUp* cobj = new (std::nothrow) cocos2d::TransitionFadeUp(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionFadeUp"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionFadeTR_prototype; + +void js_cocos2d_TransitionFadeUp_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFadeUp)", obj); +} + +void js_register_cocos2dx_TransitionFadeUp(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionFadeUp_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionFadeUp_class->name = "TransitionFadeUp"; + jsb_cocos2d_TransitionFadeUp_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionFadeUp_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionFadeUp_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionFadeUp_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionFadeUp_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionFadeUp_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionFadeUp_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionFadeUp_class->finalize = js_cocos2d_TransitionFadeUp_finalize; + jsb_cocos2d_TransitionFadeUp_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionFadeUp_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionFadeUp_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionFadeTR_prototype), + jsb_cocos2d_TransitionFadeUp_class, + js_cocos2dx_TransitionFadeUp_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, "TransitionFadeUp", 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_TransitionFadeUp_class; + p->proto = jsb_cocos2d_TransitionFadeUp_prototype; + p->parentProto = jsb_cocos2d_TransitionFadeTR_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionFadeDown_class; +JSObject *jsb_cocos2d_TransitionFadeDown_prototype; + +bool js_cocos2dx_TransitionFadeDown_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionFadeDown_create : Error processing arguments"); + cocos2d::TransitionFadeDown* ret = cocos2d::TransitionFadeDown::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionFadeDown*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionFadeDown_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionFadeDown_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionFadeDown* cobj = new (std::nothrow) cocos2d::TransitionFadeDown(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionFadeDown"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionFadeTR_prototype; + +void js_cocos2d_TransitionFadeDown_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionFadeDown)", obj); +} + +void js_register_cocos2dx_TransitionFadeDown(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionFadeDown_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionFadeDown_class->name = "TransitionFadeDown"; + jsb_cocos2d_TransitionFadeDown_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionFadeDown_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionFadeDown_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionFadeDown_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionFadeDown_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionFadeDown_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionFadeDown_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionFadeDown_class->finalize = js_cocos2d_TransitionFadeDown_finalize; + jsb_cocos2d_TransitionFadeDown_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionFadeDown_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionFadeDown_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionFadeTR_prototype), + jsb_cocos2d_TransitionFadeDown_class, + js_cocos2dx_TransitionFadeDown_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, "TransitionFadeDown", 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_TransitionFadeDown_class; + p->proto = jsb_cocos2d_TransitionFadeDown_prototype; + p->parentProto = jsb_cocos2d_TransitionFadeTR_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionPageTurn_class; +JSObject *jsb_cocos2d_TransitionPageTurn_prototype; + +bool js_cocos2dx_TransitionPageTurn_actionWithSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TransitionPageTurn* cobj = (cocos2d::TransitionPageTurn *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionPageTurn_actionWithSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionPageTurn_actionWithSize : Error processing arguments"); + cocos2d::ActionInterval* ret = cobj->actionWithSize(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ActionInterval*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TransitionPageTurn_actionWithSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TransitionPageTurn_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TransitionPageTurn* cobj = (cocos2d::TransitionPageTurn *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TransitionPageTurn_initWithDuration : Invalid Native Object"); + if (argc == 3) { + double arg0; + cocos2d::Scene* arg1; + bool arg2; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + arg2 = JS::ToBoolean(args.get(2)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionPageTurn_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TransitionPageTurn_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_TransitionPageTurn_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 3) { + double arg0; + cocos2d::Scene* arg1; + bool arg2; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + arg2 = JS::ToBoolean(args.get(2)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionPageTurn_create : Error processing arguments"); + cocos2d::TransitionPageTurn* ret = cocos2d::TransitionPageTurn::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionPageTurn*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionPageTurn_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionPageTurn_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionPageTurn* cobj = new (std::nothrow) cocos2d::TransitionPageTurn(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionPageTurn"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionScene_prototype; + +void js_cocos2d_TransitionPageTurn_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionPageTurn)", obj); +} + +void js_register_cocos2dx_TransitionPageTurn(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionPageTurn_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionPageTurn_class->name = "TransitionPageTurn"; + jsb_cocos2d_TransitionPageTurn_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionPageTurn_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionPageTurn_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionPageTurn_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionPageTurn_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionPageTurn_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionPageTurn_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionPageTurn_class->finalize = js_cocos2d_TransitionPageTurn_finalize; + jsb_cocos2d_TransitionPageTurn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("actionWithSize", js_cocos2dx_TransitionPageTurn_actionWithSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithDuration", js_cocos2dx_TransitionPageTurn_initWithDuration, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionPageTurn_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionPageTurn_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + jsb_cocos2d_TransitionPageTurn_class, + js_cocos2dx_TransitionPageTurn_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, "TransitionPageTurn", 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_TransitionPageTurn_class; + p->proto = jsb_cocos2d_TransitionPageTurn_prototype; + p->parentProto = jsb_cocos2d_TransitionScene_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionProgress_class; +JSObject *jsb_cocos2d_TransitionProgress_prototype; + +bool js_cocos2dx_TransitionProgress_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionProgress_create : Error processing arguments"); + cocos2d::TransitionProgress* ret = cocos2d::TransitionProgress::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionProgress*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionProgress_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionProgress_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionProgress* cobj = new (std::nothrow) cocos2d::TransitionProgress(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionProgress"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionScene_prototype; + +void js_cocos2d_TransitionProgress_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgress)", obj); +} + +void js_register_cocos2dx_TransitionProgress(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionProgress_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionProgress_class->name = "TransitionProgress"; + jsb_cocos2d_TransitionProgress_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionProgress_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionProgress_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionProgress_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionProgress_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionProgress_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionProgress_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionProgress_class->finalize = js_cocos2d_TransitionProgress_finalize; + jsb_cocos2d_TransitionProgress_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionProgress_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionProgress_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionScene_prototype), + jsb_cocos2d_TransitionProgress_class, + js_cocos2dx_TransitionProgress_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, "TransitionProgress", 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_TransitionProgress_class; + p->proto = jsb_cocos2d_TransitionProgress_prototype; + p->parentProto = jsb_cocos2d_TransitionScene_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionProgressRadialCCW_class; +JSObject *jsb_cocos2d_TransitionProgressRadialCCW_prototype; + +bool js_cocos2dx_TransitionProgressRadialCCW_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionProgressRadialCCW_create : Error processing arguments"); + cocos2d::TransitionProgressRadialCCW* ret = cocos2d::TransitionProgressRadialCCW::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionProgressRadialCCW*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionProgressRadialCCW_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionProgressRadialCCW_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionProgressRadialCCW* cobj = new (std::nothrow) cocos2d::TransitionProgressRadialCCW(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionProgressRadialCCW"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionProgress_prototype; + +void js_cocos2d_TransitionProgressRadialCCW_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgressRadialCCW)", obj); +} + +void js_register_cocos2dx_TransitionProgressRadialCCW(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionProgressRadialCCW_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionProgressRadialCCW_class->name = "TransitionProgressRadialCCW"; + jsb_cocos2d_TransitionProgressRadialCCW_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionProgressRadialCCW_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionProgressRadialCCW_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionProgressRadialCCW_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionProgressRadialCCW_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionProgressRadialCCW_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionProgressRadialCCW_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionProgressRadialCCW_class->finalize = js_cocos2d_TransitionProgressRadialCCW_finalize; + jsb_cocos2d_TransitionProgressRadialCCW_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionProgressRadialCCW_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionProgressRadialCCW_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionProgress_prototype), + jsb_cocos2d_TransitionProgressRadialCCW_class, + js_cocos2dx_TransitionProgressRadialCCW_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, "TransitionProgressRadialCCW", 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_TransitionProgressRadialCCW_class; + p->proto = jsb_cocos2d_TransitionProgressRadialCCW_prototype; + p->parentProto = jsb_cocos2d_TransitionProgress_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionProgressRadialCW_class; +JSObject *jsb_cocos2d_TransitionProgressRadialCW_prototype; + +bool js_cocos2dx_TransitionProgressRadialCW_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionProgressRadialCW_create : Error processing arguments"); + cocos2d::TransitionProgressRadialCW* ret = cocos2d::TransitionProgressRadialCW::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionProgressRadialCW*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionProgressRadialCW_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionProgressRadialCW_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionProgressRadialCW* cobj = new (std::nothrow) cocos2d::TransitionProgressRadialCW(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionProgressRadialCW"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionProgress_prototype; + +void js_cocos2d_TransitionProgressRadialCW_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgressRadialCW)", obj); +} + +void js_register_cocos2dx_TransitionProgressRadialCW(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionProgressRadialCW_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionProgressRadialCW_class->name = "TransitionProgressRadialCW"; + jsb_cocos2d_TransitionProgressRadialCW_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionProgressRadialCW_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionProgressRadialCW_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionProgressRadialCW_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionProgressRadialCW_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionProgressRadialCW_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionProgressRadialCW_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionProgressRadialCW_class->finalize = js_cocos2d_TransitionProgressRadialCW_finalize; + jsb_cocos2d_TransitionProgressRadialCW_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionProgressRadialCW_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionProgressRadialCW_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionProgress_prototype), + jsb_cocos2d_TransitionProgressRadialCW_class, + js_cocos2dx_TransitionProgressRadialCW_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, "TransitionProgressRadialCW", 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_TransitionProgressRadialCW_class; + p->proto = jsb_cocos2d_TransitionProgressRadialCW_prototype; + p->parentProto = jsb_cocos2d_TransitionProgress_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionProgressHorizontal_class; +JSObject *jsb_cocos2d_TransitionProgressHorizontal_prototype; + +bool js_cocos2dx_TransitionProgressHorizontal_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionProgressHorizontal_create : Error processing arguments"); + cocos2d::TransitionProgressHorizontal* ret = cocos2d::TransitionProgressHorizontal::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionProgressHorizontal*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionProgressHorizontal_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionProgressHorizontal_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionProgressHorizontal* cobj = new (std::nothrow) cocos2d::TransitionProgressHorizontal(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionProgressHorizontal"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionProgress_prototype; + +void js_cocos2d_TransitionProgressHorizontal_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgressHorizontal)", obj); +} + +void js_register_cocos2dx_TransitionProgressHorizontal(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionProgressHorizontal_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionProgressHorizontal_class->name = "TransitionProgressHorizontal"; + jsb_cocos2d_TransitionProgressHorizontal_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionProgressHorizontal_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionProgressHorizontal_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionProgressHorizontal_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionProgressHorizontal_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionProgressHorizontal_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionProgressHorizontal_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionProgressHorizontal_class->finalize = js_cocos2d_TransitionProgressHorizontal_finalize; + jsb_cocos2d_TransitionProgressHorizontal_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionProgressHorizontal_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionProgressHorizontal_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionProgress_prototype), + jsb_cocos2d_TransitionProgressHorizontal_class, + js_cocos2dx_TransitionProgressHorizontal_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, "TransitionProgressHorizontal", 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_TransitionProgressHorizontal_class; + p->proto = jsb_cocos2d_TransitionProgressHorizontal_prototype; + p->parentProto = jsb_cocos2d_TransitionProgress_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionProgressVertical_class; +JSObject *jsb_cocos2d_TransitionProgressVertical_prototype; + +bool js_cocos2dx_TransitionProgressVertical_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionProgressVertical_create : Error processing arguments"); + cocos2d::TransitionProgressVertical* ret = cocos2d::TransitionProgressVertical::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionProgressVertical*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionProgressVertical_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionProgressVertical_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionProgressVertical* cobj = new (std::nothrow) cocos2d::TransitionProgressVertical(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionProgressVertical"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionProgress_prototype; + +void js_cocos2d_TransitionProgressVertical_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgressVertical)", obj); +} + +void js_register_cocos2dx_TransitionProgressVertical(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionProgressVertical_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionProgressVertical_class->name = "TransitionProgressVertical"; + jsb_cocos2d_TransitionProgressVertical_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionProgressVertical_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionProgressVertical_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionProgressVertical_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionProgressVertical_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionProgressVertical_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionProgressVertical_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionProgressVertical_class->finalize = js_cocos2d_TransitionProgressVertical_finalize; + jsb_cocos2d_TransitionProgressVertical_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionProgressVertical_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionProgressVertical_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionProgress_prototype), + jsb_cocos2d_TransitionProgressVertical_class, + js_cocos2dx_TransitionProgressVertical_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, "TransitionProgressVertical", 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_TransitionProgressVertical_class; + p->proto = jsb_cocos2d_TransitionProgressVertical_prototype; + p->parentProto = jsb_cocos2d_TransitionProgress_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionProgressInOut_class; +JSObject *jsb_cocos2d_TransitionProgressInOut_prototype; + +bool js_cocos2dx_TransitionProgressInOut_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionProgressInOut_create : Error processing arguments"); + cocos2d::TransitionProgressInOut* ret = cocos2d::TransitionProgressInOut::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionProgressInOut*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionProgressInOut_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionProgressInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionProgressInOut* cobj = new (std::nothrow) cocos2d::TransitionProgressInOut(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionProgressInOut"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionProgress_prototype; + +void js_cocos2d_TransitionProgressInOut_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgressInOut)", obj); +} + +void js_register_cocos2dx_TransitionProgressInOut(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionProgressInOut_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionProgressInOut_class->name = "TransitionProgressInOut"; + jsb_cocos2d_TransitionProgressInOut_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionProgressInOut_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionProgressInOut_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionProgressInOut_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionProgressInOut_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionProgressInOut_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionProgressInOut_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionProgressInOut_class->finalize = js_cocos2d_TransitionProgressInOut_finalize; + jsb_cocos2d_TransitionProgressInOut_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionProgressInOut_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionProgressInOut_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionProgress_prototype), + jsb_cocos2d_TransitionProgressInOut_class, + js_cocos2dx_TransitionProgressInOut_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, "TransitionProgressInOut", 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_TransitionProgressInOut_class; + p->proto = jsb_cocos2d_TransitionProgressInOut_prototype; + p->parentProto = jsb_cocos2d_TransitionProgress_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TransitionProgressOutIn_class; +JSObject *jsb_cocos2d_TransitionProgressOutIn_prototype; + +bool js_cocos2dx_TransitionProgressOutIn_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + double arg0; + cocos2d::Scene* arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TransitionProgressOutIn_create : Error processing arguments"); + cocos2d::TransitionProgressOutIn* ret = cocos2d::TransitionProgressOutIn::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TransitionProgressOutIn*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TransitionProgressOutIn_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TransitionProgressOutIn_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TransitionProgressOutIn* cobj = new (std::nothrow) cocos2d::TransitionProgressOutIn(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TransitionProgressOutIn"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TransitionProgress_prototype; + +void js_cocos2d_TransitionProgressOutIn_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TransitionProgressOutIn)", obj); +} + +void js_register_cocos2dx_TransitionProgressOutIn(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TransitionProgressOutIn_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TransitionProgressOutIn_class->name = "TransitionProgressOutIn"; + jsb_cocos2d_TransitionProgressOutIn_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TransitionProgressOutIn_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TransitionProgressOutIn_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TransitionProgressOutIn_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TransitionProgressOutIn_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TransitionProgressOutIn_class->resolve = JS_ResolveStub; + jsb_cocos2d_TransitionProgressOutIn_class->convert = JS_ConvertStub; + jsb_cocos2d_TransitionProgressOutIn_class->finalize = js_cocos2d_TransitionProgressOutIn_finalize; + jsb_cocos2d_TransitionProgressOutIn_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TransitionProgressOutIn_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TransitionProgressOutIn_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TransitionProgress_prototype), + jsb_cocos2d_TransitionProgressOutIn_class, + js_cocos2dx_TransitionProgressOutIn_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, "TransitionProgressOutIn", 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_TransitionProgressOutIn_class; + p->proto = jsb_cocos2d_TransitionProgressOutIn_prototype; + p->parentProto = jsb_cocos2d_TransitionProgress_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_MenuItem_class; +JSObject *jsb_cocos2d_MenuItem_prototype; + +bool js_cocos2dx_MenuItem_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItem* cobj = (cocos2d::MenuItem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItem_setEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItem_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItem_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MenuItem_activate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItem* cobj = (cocos2d::MenuItem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItem_activate : Invalid Native Object"); + if (argc == 0) { + cobj->activate(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItem_activate : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MenuItem_initWithCallback(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItem* cobj = (cocos2d::MenuItem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItem_initWithCallback : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + auto lambda = [=](cocos2d::Ref* larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + JS::RootedValue rval(cx); + 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"); + bool ret = cobj->initWithCallback(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItem_initWithCallback : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MenuItem_isEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItem* cobj = (cocos2d::MenuItem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItem_isEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItem_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MenuItem_selected(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItem* cobj = (cocos2d::MenuItem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItem_selected : Invalid Native Object"); + if (argc == 0) { + cobj->selected(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItem_selected : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MenuItem_isSelected(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItem* cobj = (cocos2d::MenuItem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItem_isSelected : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isSelected(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItem_isSelected : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MenuItem_unselected(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItem* cobj = (cocos2d::MenuItem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItem_unselected : Invalid Native Object"); + if (argc == 0) { + cobj->unselected(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItem_unselected : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MenuItem_rect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItem* cobj = (cocos2d::MenuItem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItem_rect : Invalid Native Object"); + if (argc == 0) { + cocos2d::Rect ret = cobj->rect(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItem_rect : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MenuItem_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::MenuItem* cobj = new (std::nothrow) cocos2d::MenuItem(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MenuItem"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_MenuItem_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (MenuItem)", obj); +} + +static bool js_cocos2d_MenuItem_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::MenuItem *nobj = new (std::nothrow) cocos2d::MenuItem(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MenuItem"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_MenuItem(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_MenuItem_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_MenuItem_class->name = "MenuItem"; + jsb_cocos2d_MenuItem_class->addProperty = JS_PropertyStub; + jsb_cocos2d_MenuItem_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_MenuItem_class->getProperty = JS_PropertyStub; + jsb_cocos2d_MenuItem_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_MenuItem_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_MenuItem_class->resolve = JS_ResolveStub; + jsb_cocos2d_MenuItem_class->convert = JS_ConvertStub; + jsb_cocos2d_MenuItem_class->finalize = js_cocos2d_MenuItem_finalize; + jsb_cocos2d_MenuItem_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setEnabled", js_cocos2dx_MenuItem_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("activate", js_cocos2dx_MenuItem_activate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithCallback", js_cocos2dx_MenuItem_initWithCallback, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isEnabled", js_cocos2dx_MenuItem_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("selected", js_cocos2dx_MenuItem_selected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isSelected", js_cocos2dx_MenuItem_isSelected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("unselected", js_cocos2dx_MenuItem_unselected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("rect", js_cocos2dx_MenuItem_rect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_MenuItem_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_MenuItem_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_MenuItem_class, + js_cocos2dx_MenuItem_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, "MenuItem", 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_MenuItem_class; + p->proto = jsb_cocos2d_MenuItem_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_MenuItemLabel_class; +JSObject *jsb_cocos2d_MenuItemLabel_prototype; + +bool js_cocos2dx_MenuItemLabel_setLabel(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemLabel* cobj = (cocos2d::MenuItemLabel *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemLabel_setLabel : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemLabel_setLabel : Error processing arguments"); + cobj->setLabel(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemLabel_setLabel : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MenuItemLabel_getDisabledColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemLabel* cobj = (cocos2d::MenuItemLabel *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemLabel_getDisabledColor : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color3B& ret = cobj->getDisabledColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor3b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemLabel_getDisabledColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MenuItemLabel_setString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemLabel* cobj = (cocos2d::MenuItemLabel *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemLabel_setString : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemLabel_setString : Error processing arguments"); + cobj->setString(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemLabel_setString : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MenuItemLabel_initWithLabel(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemLabel* cobj = (cocos2d::MenuItemLabel *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemLabel_initWithLabel : Invalid Native Object"); + if (argc == 2) { + cocos2d::Node* arg0; + std::function arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + do { + if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + auto lambda = [=](cocos2d::Ref* larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + JS::RootedValue rval(cx); + 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"); + bool ret = cobj->initWithLabel(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemLabel_initWithLabel : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_MenuItemLabel_setDisabledColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemLabel* cobj = (cocos2d::MenuItemLabel *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemLabel_setDisabledColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color3B arg0; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemLabel_setDisabledColor : Error processing arguments"); + cobj->setDisabledColor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemLabel_setDisabledColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MenuItemLabel_getLabel(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemLabel* cobj = (cocos2d::MenuItemLabel *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemLabel_getLabel : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getLabel(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemLabel_getLabel : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MenuItemLabel_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::MenuItemLabel* cobj = new (std::nothrow) cocos2d::MenuItemLabel(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MenuItemLabel"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_MenuItem_prototype; + +void js_cocos2d_MenuItemLabel_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (MenuItemLabel)", obj); +} + +static bool js_cocos2d_MenuItemLabel_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::MenuItemLabel *nobj = new (std::nothrow) cocos2d::MenuItemLabel(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MenuItemLabel"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_MenuItemLabel(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_MenuItemLabel_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_MenuItemLabel_class->name = "MenuItemLabel"; + jsb_cocos2d_MenuItemLabel_class->addProperty = JS_PropertyStub; + jsb_cocos2d_MenuItemLabel_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_MenuItemLabel_class->getProperty = JS_PropertyStub; + jsb_cocos2d_MenuItemLabel_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_MenuItemLabel_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_MenuItemLabel_class->resolve = JS_ResolveStub; + jsb_cocos2d_MenuItemLabel_class->convert = JS_ConvertStub; + jsb_cocos2d_MenuItemLabel_class->finalize = js_cocos2d_MenuItemLabel_finalize; + jsb_cocos2d_MenuItemLabel_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setLabel", js_cocos2dx_MenuItemLabel_setLabel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDisabledColor", js_cocos2dx_MenuItemLabel_getDisabledColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setString", js_cocos2dx_MenuItemLabel_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithLabel", js_cocos2dx_MenuItemLabel_initWithLabel, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDisabledColor", js_cocos2dx_MenuItemLabel_setDisabledColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLabel", js_cocos2dx_MenuItemLabel_getLabel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_MenuItemLabel_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_MenuItemLabel_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_MenuItem_prototype), + jsb_cocos2d_MenuItemLabel_class, + js_cocos2dx_MenuItemLabel_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, "MenuItemLabel", 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_MenuItemLabel_class; + p->proto = jsb_cocos2d_MenuItemLabel_prototype; + p->parentProto = jsb_cocos2d_MenuItem_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_MenuItemAtlasFont_class; +JSObject *jsb_cocos2d_MenuItemAtlasFont_prototype; + +bool js_cocos2dx_MenuItemAtlasFont_initWithString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemAtlasFont* cobj = (cocos2d::MenuItemAtlasFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemAtlasFont_initWithString : Invalid Native Object"); + if (argc == 6) { + std::string arg0; + std::string arg1; + int arg2; + int arg3; + int32_t arg4; + std::function arg5; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + ok &= jsval_to_int32(cx, args.get(4), &arg4); + do { + if(JS_TypeOfValue(cx, args.get(5)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(5))); + auto lambda = [=](cocos2d::Ref* larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + JS::RootedValue rval(cx); + 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"); + bool ret = cobj->initWithString(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemAtlasFont_initWithString : wrong number of arguments: %d, was expecting %d", argc, 6); + return false; +} +bool js_cocos2dx_MenuItemAtlasFont_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::MenuItemAtlasFont* cobj = new (std::nothrow) cocos2d::MenuItemAtlasFont(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MenuItemAtlasFont"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_MenuItemLabel_prototype; + +void js_cocos2d_MenuItemAtlasFont_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (MenuItemAtlasFont)", obj); +} + +static bool js_cocos2d_MenuItemAtlasFont_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::MenuItemAtlasFont *nobj = new (std::nothrow) cocos2d::MenuItemAtlasFont(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MenuItemAtlasFont"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_MenuItemAtlasFont(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_MenuItemAtlasFont_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_MenuItemAtlasFont_class->name = "MenuItemAtlasFont"; + jsb_cocos2d_MenuItemAtlasFont_class->addProperty = JS_PropertyStub; + jsb_cocos2d_MenuItemAtlasFont_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_MenuItemAtlasFont_class->getProperty = JS_PropertyStub; + jsb_cocos2d_MenuItemAtlasFont_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_MenuItemAtlasFont_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_MenuItemAtlasFont_class->resolve = JS_ResolveStub; + jsb_cocos2d_MenuItemAtlasFont_class->convert = JS_ConvertStub; + jsb_cocos2d_MenuItemAtlasFont_class->finalize = js_cocos2d_MenuItemAtlasFont_finalize; + jsb_cocos2d_MenuItemAtlasFont_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithString", js_cocos2dx_MenuItemAtlasFont_initWithString, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_MenuItemAtlasFont_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_MenuItemAtlasFont_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_MenuItemLabel_prototype), + jsb_cocos2d_MenuItemAtlasFont_class, + js_cocos2dx_MenuItemAtlasFont_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, "MenuItemAtlasFont", 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_MenuItemAtlasFont_class; + p->proto = jsb_cocos2d_MenuItemAtlasFont_prototype; + p->parentProto = jsb_cocos2d_MenuItemLabel_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_MenuItemFont_class; +JSObject *jsb_cocos2d_MenuItemFont_prototype; + +bool js_cocos2dx_MenuItemFont_setFontNameObj(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemFont* cobj = (cocos2d::MenuItemFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemFont_setFontNameObj : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemFont_setFontNameObj : Error processing arguments"); + cobj->setFontNameObj(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemFont_setFontNameObj : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MenuItemFont_getFontSizeObj(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemFont* cobj = (cocos2d::MenuItemFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemFont_getFontSizeObj : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getFontSizeObj(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemFont_getFontSizeObj : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MenuItemFont_setFontSizeObj(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemFont* cobj = (cocos2d::MenuItemFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemFont_setFontSizeObj : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemFont_setFontSizeObj : Error processing arguments"); + cobj->setFontSizeObj(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemFont_setFontSizeObj : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MenuItemFont_initWithString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemFont* cobj = (cocos2d::MenuItemFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemFont_initWithString : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + std::function arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + do { + if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + auto lambda = [=](cocos2d::Ref* larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + JS::RootedValue rval(cx); + 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"); + bool ret = cobj->initWithString(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemFont_initWithString : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_MenuItemFont_getFontNameObj(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemFont* cobj = (cocos2d::MenuItemFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemFont_getFontNameObj : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getFontNameObj(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemFont_getFontNameObj : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MenuItemFont_setFontName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemFont_setFontName : Error processing arguments"); + cocos2d::MenuItemFont::setFontName(arg0); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_MenuItemFont_setFontName : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_MenuItemFont_getFontSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + int ret = cocos2d::MenuItemFont::getFontSize(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_MenuItemFont_getFontSize : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_MenuItemFont_getFontName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + const std::string& ret = cocos2d::MenuItemFont::getFontName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_MenuItemFont_getFontName : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_MenuItemFont_setFontSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemFont_setFontSize : Error processing arguments"); + cocos2d::MenuItemFont::setFontSize(arg0); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_MenuItemFont_setFontSize : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_MenuItemFont_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::MenuItemFont* cobj = new (std::nothrow) cocos2d::MenuItemFont(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MenuItemFont"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_MenuItemLabel_prototype; + +void js_cocos2d_MenuItemFont_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (MenuItemFont)", obj); +} + +static bool js_cocos2d_MenuItemFont_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::MenuItemFont *nobj = new (std::nothrow) cocos2d::MenuItemFont(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MenuItemFont"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_MenuItemFont(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_MenuItemFont_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_MenuItemFont_class->name = "MenuItemFont"; + jsb_cocos2d_MenuItemFont_class->addProperty = JS_PropertyStub; + jsb_cocos2d_MenuItemFont_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_MenuItemFont_class->getProperty = JS_PropertyStub; + jsb_cocos2d_MenuItemFont_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_MenuItemFont_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_MenuItemFont_class->resolve = JS_ResolveStub; + jsb_cocos2d_MenuItemFont_class->convert = JS_ConvertStub; + jsb_cocos2d_MenuItemFont_class->finalize = js_cocos2d_MenuItemFont_finalize; + jsb_cocos2d_MenuItemFont_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setFontName", js_cocos2dx_MenuItemFont_setFontNameObj, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFontSize", js_cocos2dx_MenuItemFont_getFontSizeObj, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFontSize", js_cocos2dx_MenuItemFont_setFontSizeObj, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithString", js_cocos2dx_MenuItemFont_initWithString, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFontName", js_cocos2dx_MenuItemFont_getFontNameObj, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_MenuItemFont_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("setFontName", js_cocos2dx_MenuItemFont_setFontName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFontSize", js_cocos2dx_MenuItemFont_getFontSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFontName", js_cocos2dx_MenuItemFont_getFontName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFontSize", js_cocos2dx_MenuItemFont_setFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_MenuItemFont_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_MenuItemLabel_prototype), + jsb_cocos2d_MenuItemFont_class, + js_cocos2dx_MenuItemFont_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, "MenuItemFont", 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_MenuItemFont_class; + p->proto = jsb_cocos2d_MenuItemFont_prototype; + p->parentProto = jsb_cocos2d_MenuItemLabel_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_MenuItemSprite_class; +JSObject *jsb_cocos2d_MenuItemSprite_prototype; + +bool js_cocos2dx_MenuItemSprite_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemSprite* cobj = (cocos2d::MenuItemSprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemSprite_setEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemSprite_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemSprite_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MenuItemSprite_selected(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemSprite* cobj = (cocos2d::MenuItemSprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemSprite_selected : Invalid Native Object"); + if (argc == 0) { + cobj->selected(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemSprite_selected : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MenuItemSprite_setNormalImage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemSprite* cobj = (cocos2d::MenuItemSprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemSprite_setNormalImage : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemSprite_setNormalImage : Error processing arguments"); + cobj->setNormalImage(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemSprite_setNormalImage : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MenuItemSprite_setDisabledImage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemSprite* cobj = (cocos2d::MenuItemSprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemSprite_setDisabledImage : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemSprite_setDisabledImage : Error processing arguments"); + cobj->setDisabledImage(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemSprite_setDisabledImage : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MenuItemSprite_initWithNormalSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemSprite* cobj = (cocos2d::MenuItemSprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemSprite_initWithNormalSprite : Invalid Native Object"); + if (argc == 4) { + cocos2d::Node* arg0; + cocos2d::Node* arg1; + cocos2d::Node* arg2; + std::function arg3; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + do { + if(JS_TypeOfValue(cx, args.get(3)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(3))); + auto lambda = [=](cocos2d::Ref* larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + JS::RootedValue rval(cx); + 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"); + bool ret = cobj->initWithNormalSprite(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemSprite_initWithNormalSprite : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_MenuItemSprite_setSelectedImage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemSprite* cobj = (cocos2d::MenuItemSprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemSprite_setSelectedImage : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemSprite_setSelectedImage : Error processing arguments"); + cobj->setSelectedImage(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemSprite_setSelectedImage : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MenuItemSprite_getDisabledImage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemSprite* cobj = (cocos2d::MenuItemSprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemSprite_getDisabledImage : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getDisabledImage(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemSprite_getDisabledImage : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MenuItemSprite_getSelectedImage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemSprite* cobj = (cocos2d::MenuItemSprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemSprite_getSelectedImage : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getSelectedImage(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemSprite_getSelectedImage : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MenuItemSprite_getNormalImage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemSprite* cobj = (cocos2d::MenuItemSprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemSprite_getNormalImage : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getNormalImage(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemSprite_getNormalImage : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MenuItemSprite_unselected(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemSprite* cobj = (cocos2d::MenuItemSprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemSprite_unselected : Invalid Native Object"); + if (argc == 0) { + cobj->unselected(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemSprite_unselected : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MenuItemSprite_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::MenuItemSprite* cobj = new (std::nothrow) cocos2d::MenuItemSprite(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MenuItemSprite"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_MenuItem_prototype; + +void js_cocos2d_MenuItemSprite_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (MenuItemSprite)", obj); +} + +static bool js_cocos2d_MenuItemSprite_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::MenuItemSprite *nobj = new (std::nothrow) cocos2d::MenuItemSprite(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MenuItemSprite"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_MenuItemSprite(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_MenuItemSprite_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_MenuItemSprite_class->name = "MenuItemSprite"; + jsb_cocos2d_MenuItemSprite_class->addProperty = JS_PropertyStub; + jsb_cocos2d_MenuItemSprite_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_MenuItemSprite_class->getProperty = JS_PropertyStub; + jsb_cocos2d_MenuItemSprite_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_MenuItemSprite_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_MenuItemSprite_class->resolve = JS_ResolveStub; + jsb_cocos2d_MenuItemSprite_class->convert = JS_ConvertStub; + jsb_cocos2d_MenuItemSprite_class->finalize = js_cocos2d_MenuItemSprite_finalize; + jsb_cocos2d_MenuItemSprite_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setEnabled", js_cocos2dx_MenuItemSprite_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("selected", js_cocos2dx_MenuItemSprite_selected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setNormalImage", js_cocos2dx_MenuItemSprite_setNormalImage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDisabledImage", js_cocos2dx_MenuItemSprite_setDisabledImage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithNormalSprite", js_cocos2dx_MenuItemSprite_initWithNormalSprite, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSelectedImage", js_cocos2dx_MenuItemSprite_setSelectedImage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDisabledImage", js_cocos2dx_MenuItemSprite_getDisabledImage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSelectedImage", js_cocos2dx_MenuItemSprite_getSelectedImage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNormalImage", js_cocos2dx_MenuItemSprite_getNormalImage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("unselected", js_cocos2dx_MenuItemSprite_unselected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_MenuItemSprite_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_MenuItemSprite_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_MenuItem_prototype), + jsb_cocos2d_MenuItemSprite_class, + js_cocos2dx_MenuItemSprite_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, "MenuItemSprite", 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_MenuItemSprite_class; + p->proto = jsb_cocos2d_MenuItemSprite_prototype; + p->parentProto = jsb_cocos2d_MenuItem_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_MenuItemImage_class; +JSObject *jsb_cocos2d_MenuItemImage_prototype; + +bool js_cocos2dx_MenuItemImage_setDisabledSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemImage* cobj = (cocos2d::MenuItemImage *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemImage_setDisabledSpriteFrame : Invalid Native Object"); + if (argc == 1) { + cocos2d::SpriteFrame* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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_MenuItemImage_setDisabledSpriteFrame : Error processing arguments"); + cobj->setDisabledSpriteFrame(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemImage_setDisabledSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MenuItemImage_setSelectedSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemImage* cobj = (cocos2d::MenuItemImage *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemImage_setSelectedSpriteFrame : Invalid Native Object"); + if (argc == 1) { + cocos2d::SpriteFrame* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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_MenuItemImage_setSelectedSpriteFrame : Error processing arguments"); + cobj->setSelectedSpriteFrame(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemImage_setSelectedSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MenuItemImage_setNormalSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemImage* cobj = (cocos2d::MenuItemImage *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemImage_setNormalSpriteFrame : Invalid Native Object"); + if (argc == 1) { + cocos2d::SpriteFrame* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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_MenuItemImage_setNormalSpriteFrame : Error processing arguments"); + cobj->setNormalSpriteFrame(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemImage_setNormalSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MenuItemImage_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemImage* cobj = (cocos2d::MenuItemImage *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemImage_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemImage_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MenuItemImage_initWithNormalImage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemImage* cobj = (cocos2d::MenuItemImage *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemImage_initWithNormalImage : Invalid Native Object"); + if (argc == 4) { + std::string arg0; + std::string arg1; + std::string arg2; + std::function arg3; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + do { + if(JS_TypeOfValue(cx, args.get(3)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(3))); + auto lambda = [=](cocos2d::Ref* larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + JS::RootedValue rval(cx); + 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"); + bool ret = cobj->initWithNormalImage(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemImage_initWithNormalImage : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_MenuItemImage_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::MenuItemImage* cobj = new (std::nothrow) cocos2d::MenuItemImage(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MenuItemImage"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_MenuItemSprite_prototype; + +void js_cocos2d_MenuItemImage_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (MenuItemImage)", obj); +} + +static bool js_cocos2d_MenuItemImage_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::MenuItemImage *nobj = new (std::nothrow) cocos2d::MenuItemImage(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MenuItemImage"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_MenuItemImage(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_MenuItemImage_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_MenuItemImage_class->name = "MenuItemImage"; + jsb_cocos2d_MenuItemImage_class->addProperty = JS_PropertyStub; + jsb_cocos2d_MenuItemImage_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_MenuItemImage_class->getProperty = JS_PropertyStub; + jsb_cocos2d_MenuItemImage_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_MenuItemImage_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_MenuItemImage_class->resolve = JS_ResolveStub; + jsb_cocos2d_MenuItemImage_class->convert = JS_ConvertStub; + jsb_cocos2d_MenuItemImage_class->finalize = js_cocos2d_MenuItemImage_finalize; + jsb_cocos2d_MenuItemImage_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setDisabledSpriteFrame", js_cocos2dx_MenuItemImage_setDisabledSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSelectedSpriteFrame", js_cocos2dx_MenuItemImage_setSelectedSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setNormalSpriteFrame", js_cocos2dx_MenuItemImage_setNormalSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_MenuItemImage_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithNormalImage", js_cocos2dx_MenuItemImage_initWithNormalImage, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_MenuItemImage_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_MenuItemImage_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_MenuItemSprite_prototype), + jsb_cocos2d_MenuItemImage_class, + js_cocos2dx_MenuItemImage_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, "MenuItemImage", 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_MenuItemImage_class; + p->proto = jsb_cocos2d_MenuItemImage_prototype; + p->parentProto = jsb_cocos2d_MenuItemSprite_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_MenuItemToggle_class; +JSObject *jsb_cocos2d_MenuItemToggle_prototype; + +bool js_cocos2dx_MenuItemToggle_setSubItems(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemToggle* cobj = (cocos2d::MenuItemToggle *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemToggle_setSubItems : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vector arg0; + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemToggle_setSubItems : Error processing arguments"); + cobj->setSubItems(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemToggle_setSubItems : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MenuItemToggle_initWithItem(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemToggle* cobj = (cocos2d::MenuItemToggle *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemToggle_initWithItem : Invalid Native Object"); + if (argc == 1) { + cocos2d::MenuItem* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::MenuItem*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemToggle_initWithItem : Error processing arguments"); + bool ret = cobj->initWithItem(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemToggle_initWithItem : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MenuItemToggle_getSelectedIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemToggle* cobj = (cocos2d::MenuItemToggle *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemToggle_getSelectedIndex : Invalid Native Object"); + if (argc == 0) { + unsigned int ret = cobj->getSelectedIndex(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemToggle_getSelectedIndex : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MenuItemToggle_addSubItem(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemToggle* cobj = (cocos2d::MenuItemToggle *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemToggle_addSubItem : Invalid Native Object"); + if (argc == 1) { + cocos2d::MenuItem* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::MenuItem*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemToggle_addSubItem : Error processing arguments"); + cobj->addSubItem(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemToggle_addSubItem : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MenuItemToggle_getSelectedItem(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemToggle* cobj = (cocos2d::MenuItemToggle *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemToggle_getSelectedItem : Invalid Native Object"); + if (argc == 0) { + cocos2d::MenuItem* ret = cobj->getSelectedItem(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::MenuItem*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemToggle_getSelectedItem : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MenuItemToggle_setSelectedIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItemToggle* cobj = (cocos2d::MenuItemToggle *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItemToggle_setSelectedIndex : Invalid Native Object"); + if (argc == 1) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemToggle_setSelectedIndex : Error processing arguments"); + cobj->setSelectedIndex(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItemToggle_setSelectedIndex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MenuItemToggle_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::MenuItemToggle* cobj = new (std::nothrow) cocos2d::MenuItemToggle(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MenuItemToggle"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_MenuItem_prototype; + +void js_cocos2d_MenuItemToggle_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (MenuItemToggle)", obj); +} + +static bool js_cocos2d_MenuItemToggle_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::MenuItemToggle *nobj = new (std::nothrow) cocos2d::MenuItemToggle(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MenuItemToggle"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_MenuItemToggle(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_MenuItemToggle_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_MenuItemToggle_class->name = "MenuItemToggle"; + jsb_cocos2d_MenuItemToggle_class->addProperty = JS_PropertyStub; + jsb_cocos2d_MenuItemToggle_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_MenuItemToggle_class->getProperty = JS_PropertyStub; + jsb_cocos2d_MenuItemToggle_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_MenuItemToggle_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_MenuItemToggle_class->resolve = JS_ResolveStub; + jsb_cocos2d_MenuItemToggle_class->convert = JS_ConvertStub; + jsb_cocos2d_MenuItemToggle_class->finalize = js_cocos2d_MenuItemToggle_finalize; + jsb_cocos2d_MenuItemToggle_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setSubItems", js_cocos2dx_MenuItemToggle_setSubItems, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithItem", js_cocos2dx_MenuItemToggle_initWithItem, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSelectedIndex", js_cocos2dx_MenuItemToggle_getSelectedIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addSubItem", js_cocos2dx_MenuItemToggle_addSubItem, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSelectedItem", js_cocos2dx_MenuItemToggle_getSelectedItem, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSelectedIndex", js_cocos2dx_MenuItemToggle_setSelectedIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_MenuItemToggle_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_MenuItemToggle_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_MenuItem_prototype), + jsb_cocos2d_MenuItemToggle_class, + js_cocos2dx_MenuItemToggle_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, "MenuItemToggle", 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_MenuItemToggle_class; + p->proto = jsb_cocos2d_MenuItemToggle_prototype; + p->parentProto = jsb_cocos2d_MenuItem_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Menu_class; +JSObject *jsb_cocos2d_Menu_prototype; + +bool js_cocos2dx_Menu_initWithArray(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Menu* cobj = (cocos2d::Menu *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Menu_initWithArray : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vector arg0; + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Menu_initWithArray : Error processing arguments"); + bool ret = cobj->initWithArray(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Menu_initWithArray : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Menu_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Menu* cobj = (cocos2d::Menu *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Menu_setEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Menu_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Menu_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Menu_alignItemsVertically(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Menu* cobj = (cocos2d::Menu *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Menu_alignItemsVertically : Invalid Native Object"); + if (argc == 0) { + cobj->alignItemsVertically(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Menu_alignItemsVertically : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Menu_isEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Menu* cobj = (cocos2d::Menu *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Menu_isEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Menu_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Menu_alignItemsHorizontallyWithPadding(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Menu* cobj = (cocos2d::Menu *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Menu_alignItemsHorizontallyWithPadding : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Menu_alignItemsHorizontallyWithPadding : Error processing arguments"); + cobj->alignItemsHorizontallyWithPadding(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Menu_alignItemsHorizontallyWithPadding : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Menu_alignItemsVerticallyWithPadding(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Menu* cobj = (cocos2d::Menu *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Menu_alignItemsVerticallyWithPadding : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Menu_alignItemsVerticallyWithPadding : Error processing arguments"); + cobj->alignItemsVerticallyWithPadding(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Menu_alignItemsVerticallyWithPadding : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Menu_alignItemsHorizontally(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Menu* cobj = (cocos2d::Menu *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Menu_alignItemsHorizontally : Invalid Native Object"); + if (argc == 0) { + cobj->alignItemsHorizontally(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Menu_alignItemsHorizontally : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Menu_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Menu* cobj = new (std::nothrow) cocos2d::Menu(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Menu"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Layer_prototype; + +void js_cocos2d_Menu_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Menu)", obj); +} + +static bool js_cocos2d_Menu_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Menu *nobj = new (std::nothrow) cocos2d::Menu(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Menu"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_Menu(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Menu_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Menu_class->name = "Menu"; + jsb_cocos2d_Menu_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Menu_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Menu_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Menu_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Menu_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Menu_class->resolve = JS_ResolveStub; + jsb_cocos2d_Menu_class->convert = JS_ConvertStub; + jsb_cocos2d_Menu_class->finalize = js_cocos2d_Menu_finalize; + jsb_cocos2d_Menu_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithArray", js_cocos2dx_Menu_initWithArray, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEnabled", js_cocos2dx_Menu_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("alignItemsVertically", js_cocos2dx_Menu_alignItemsVertically, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isEnabled", js_cocos2dx_Menu_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("alignItemsHorizontallyWithPadding", js_cocos2dx_Menu_alignItemsHorizontallyWithPadding, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("alignItemsVerticallyWithPadding", js_cocos2dx_Menu_alignItemsVerticallyWithPadding, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("alignItemsHorizontally", js_cocos2dx_Menu_alignItemsHorizontally, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_Menu_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_Menu_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Layer_prototype), + jsb_cocos2d_Menu_class, + js_cocos2dx_Menu_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, "Menu", 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_Menu_class; + p->proto = jsb_cocos2d_Menu_prototype; + p->parentProto = jsb_cocos2d_Layer_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ClippingNode_class; +JSObject *jsb_cocos2d_ClippingNode_prototype; + +bool js_cocos2dx_ClippingNode_hasContent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_hasContent : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->hasContent(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setInverted : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ClippingNode_setInverted : Error processing arguments"); + cobj->setInverted(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ClippingNode_setInverted : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ClippingNode_setStencil(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setStencil : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ClippingNode_setStencil : Error processing arguments"); + cobj->setStencil(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ClippingNode_setStencil : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ClippingNode_getAlphaThreshold(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getAlphaThreshold : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAlphaThreshold(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ClippingNode_getAlphaThreshold : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ClippingNode_getStencil(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getStencil : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getStencil(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ClippingNode_getStencil : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ClippingNode_setAlphaThreshold(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setAlphaThreshold : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ClippingNode_setAlphaThreshold : Error processing arguments"); + cobj->setAlphaThreshold(arg0); + args.rval().setUndefined(); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::ClippingNode* ret = cocos2d::ClippingNode::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ClippingNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::ClippingNode* ret = cocos2d::ClippingNode::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ClippingNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ClippingNode_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ClippingNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ClippingNode* cobj = new (std::nothrow) cocos2d::ClippingNode(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ClippingNode"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_ClippingNode_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ClippingNode)", obj); +} + +void js_register_cocos2dx_ClippingNode(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ClippingNode_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ClippingNode_class->name = "ClippingNode"; + jsb_cocos2d_ClippingNode_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ClippingNode_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ClippingNode_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ClippingNode_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ClippingNode_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ClippingNode_class->resolve = JS_ResolveStub; + jsb_cocos2d_ClippingNode_class->convert = JS_ConvertStub; + jsb_cocos2d_ClippingNode_class->finalize = js_cocos2d_ClippingNode_finalize; + jsb_cocos2d_ClippingNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + 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("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 + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ClippingNode_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ClippingNode_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_ClippingNode_class, + js_cocos2dx_ClippingNode_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, "ClippingNode", 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_ClippingNode_class; + p->proto = jsb_cocos2d_ClippingNode_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_MotionStreak_class; +JSObject *jsb_cocos2d_MotionStreak_prototype; + +bool js_cocos2dx_MotionStreak_reset(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MotionStreak_reset : Invalid Native Object"); + if (argc == 0) { + cobj->reset(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MotionStreak_reset : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MotionStreak_setTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MotionStreak_setTexture : Invalid Native Object"); + if (argc == 1) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MotionStreak_setTexture : Error processing arguments"); + cobj->setTexture(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MotionStreak_setTexture : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MotionStreak_getTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MotionStreak_getTexture : Invalid Native Object"); + if (argc == 0) { + cocos2d::Texture2D* ret = cobj->getTexture(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MotionStreak_getTexture : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MotionStreak_tintWithColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MotionStreak_tintWithColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color3B arg0; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MotionStreak_tintWithColor : Error processing arguments"); + cobj->tintWithColor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MotionStreak_tintWithColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MotionStreak_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MotionStreak_setBlendFunc : Invalid Native Object"); + if (argc == 1) { + cocos2d::BlendFunc arg0; + ok &= jsval_to_blendfunc(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MotionStreak_setBlendFunc : Error processing arguments"); + cobj->setBlendFunc(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MotionStreak_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MotionStreak_setStartingPositionInitialized(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MotionStreak_setStartingPositionInitialized : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MotionStreak_setStartingPositionInitialized : Error processing arguments"); + cobj->setStartingPositionInitialized(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MotionStreak_setStartingPositionInitialized : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MotionStreak_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MotionStreak_getBlendFunc : Invalid Native Object"); + if (argc == 0) { + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MotionStreak_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MotionStreak_isStartingPositionInitialized(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MotionStreak_isStartingPositionInitialized : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isStartingPositionInitialized(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MotionStreak_isStartingPositionInitialized : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MotionStreak_isFastMode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MotionStreak_isFastMode : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isFastMode(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MotionStreak_isFastMode : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MotionStreak_getStroke(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MotionStreak_getStroke : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getStroke(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MotionStreak_getStroke : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_MotionStreak_initWithFade(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::MotionStreak* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MotionStreak_initWithFade : Invalid Native Object"); + do { + if (argc == 5) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::Color3B arg3; + ok &= jsval_to_cccolor3b(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + cocos2d::Texture2D* arg4; + do { + if (!args.get(4).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(4).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg4 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg4, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithFade(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 5) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::Color3B arg3; + ok &= jsval_to_cccolor3b(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + std::string arg4; + ok &= jsval_to_std_string(cx, args.get(4), &arg4); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithFade(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_MotionStreak_initWithFade : wrong number of arguments"); + return false; +} +bool js_cocos2dx_MotionStreak_setFastMode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MotionStreak_setFastMode : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MotionStreak_setFastMode : Error processing arguments"); + cobj->setFastMode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MotionStreak_setFastMode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MotionStreak_setStroke(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MotionStreak* cobj = (cocos2d::MotionStreak *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MotionStreak_setStroke : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MotionStreak_setStroke : Error processing arguments"); + cobj->setStroke(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MotionStreak_setStroke : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_MotionStreak_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 5) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::Color3B arg3; + ok &= jsval_to_cccolor3b(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + cocos2d::Texture2D* arg4; + do { + if (!args.get(4).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(4).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg4 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg4, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::MotionStreak* ret = cocos2d::MotionStreak::create(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::MotionStreak*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 5) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::Color3B arg3; + ok &= jsval_to_cccolor3b(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + std::string arg4; + ok &= jsval_to_std_string(cx, args.get(4), &arg4); + if (!ok) { ok = true; break; } + cocos2d::MotionStreak* ret = cocos2d::MotionStreak::create(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::MotionStreak*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_MotionStreak_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_MotionStreak_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::MotionStreak* cobj = new (std::nothrow) cocos2d::MotionStreak(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MotionStreak"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_MotionStreak_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (MotionStreak)", obj); +} + +static bool js_cocos2d_MotionStreak_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::MotionStreak *nobj = new (std::nothrow) cocos2d::MotionStreak(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::MotionStreak"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_MotionStreak(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_MotionStreak_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_MotionStreak_class->name = "MotionStreak"; + jsb_cocos2d_MotionStreak_class->addProperty = JS_PropertyStub; + jsb_cocos2d_MotionStreak_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_MotionStreak_class->getProperty = JS_PropertyStub; + jsb_cocos2d_MotionStreak_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_MotionStreak_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_MotionStreak_class->resolve = JS_ResolveStub; + jsb_cocos2d_MotionStreak_class->convert = JS_ConvertStub; + jsb_cocos2d_MotionStreak_class->finalize = js_cocos2d_MotionStreak_finalize; + jsb_cocos2d_MotionStreak_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("reset", js_cocos2dx_MotionStreak_reset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTexture", js_cocos2dx_MotionStreak_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTexture", js_cocos2dx_MotionStreak_getTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("tintWithColor", js_cocos2dx_MotionStreak_tintWithColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBlendFunc", js_cocos2dx_MotionStreak_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setStartingPositionInitialized", js_cocos2dx_MotionStreak_setStartingPositionInitialized, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBlendFunc", js_cocos2dx_MotionStreak_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isStartingPositionInitialized", js_cocos2dx_MotionStreak_isStartingPositionInitialized, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isFastMode", js_cocos2dx_MotionStreak_isFastMode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStroke", js_cocos2dx_MotionStreak_getStroke, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithFade", js_cocos2dx_MotionStreak_initWithFade, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFastMode", js_cocos2dx_MotionStreak_setFastMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setStroke", js_cocos2dx_MotionStreak_setStroke, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_MotionStreak_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_MotionStreak_create, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_MotionStreak_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_MotionStreak_class, + js_cocos2dx_MotionStreak_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, "MotionStreak", 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_MotionStreak_class; + p->proto = jsb_cocos2d_MotionStreak_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ProgressTimer_class; +JSObject *jsb_cocos2d_ProgressTimer_prototype; + +bool js_cocos2dx_ProgressTimer_initWithSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProgressTimer_initWithSprite : Invalid Native Object"); + if (argc == 1) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ProgressTimer_initWithSprite : Error processing arguments"); + bool ret = cobj->initWithSprite(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProgressTimer_initWithSprite : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ProgressTimer_isReverseDirection(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProgressTimer_isReverseDirection : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isReverseDirection(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProgressTimer_isReverseDirection : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ProgressTimer_setBarChangeRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProgressTimer_setBarChangeRate : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ProgressTimer_setBarChangeRate : Error processing arguments"); + cobj->setBarChangeRate(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProgressTimer_setBarChangeRate : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ProgressTimer_getPercentage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProgressTimer_getPercentage : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getPercentage(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProgressTimer_getPercentage : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ProgressTimer_setSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProgressTimer_setSprite : Invalid Native Object"); + if (argc == 1) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ProgressTimer_setSprite : Error processing arguments"); + cobj->setSprite(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProgressTimer_setSprite : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ProgressTimer_getType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProgressTimer_getType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProgressTimer_getType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ProgressTimer_getSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProgressTimer_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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProgressTimer_getSprite : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ProgressTimer_setMidpoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProgressTimer_setMidpoint : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ProgressTimer_setMidpoint : Error processing arguments"); + cobj->setMidpoint(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProgressTimer_setMidpoint : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ProgressTimer_getBarChangeRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProgressTimer_getBarChangeRate : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getBarChangeRate(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProgressTimer_getBarChangeRate : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ProgressTimer_setReverseDirection(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ProgressTimer* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProgressTimer_setReverseDirection : Invalid Native Object"); + do { + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + cobj->setReverseDirection(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + cobj->setReverseProgress(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ProgressTimer_setReverseDirection : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ProgressTimer_getMidpoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProgressTimer_getMidpoint : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getMidpoint(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProgressTimer_getMidpoint : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ProgressTimer_setPercentage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProgressTimer_setPercentage : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ProgressTimer_setPercentage : Error processing arguments"); + cobj->setPercentage(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProgressTimer_setPercentage : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ProgressTimer_setType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ProgressTimer* cobj = (cocos2d::ProgressTimer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ProgressTimer_setType : Invalid Native Object"); + if (argc == 1) { + cocos2d::ProgressTimer::Type arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ProgressTimer_setType : Error processing arguments"); + cobj->setType(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ProgressTimer_setType : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ProgressTimer_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ProgressTimer_create : Error processing arguments"); + cocos2d::ProgressTimer* ret = cocos2d::ProgressTimer::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ProgressTimer*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ProgressTimer_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ProgressTimer_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ProgressTimer* cobj = new (std::nothrow) cocos2d::ProgressTimer(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ProgressTimer"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_ProgressTimer_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ProgressTimer)", obj); +} + +static bool js_cocos2d_ProgressTimer_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ProgressTimer *nobj = new (std::nothrow) cocos2d::ProgressTimer(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ProgressTimer"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ProgressTimer(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ProgressTimer_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ProgressTimer_class->name = "ProgressTimer"; + jsb_cocos2d_ProgressTimer_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ProgressTimer_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ProgressTimer_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ProgressTimer_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ProgressTimer_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ProgressTimer_class->resolve = JS_ResolveStub; + jsb_cocos2d_ProgressTimer_class->convert = JS_ConvertStub; + jsb_cocos2d_ProgressTimer_class->finalize = js_cocos2d_ProgressTimer_finalize; + jsb_cocos2d_ProgressTimer_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithSprite", js_cocos2dx_ProgressTimer_initWithSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isReverseDirection", js_cocos2dx_ProgressTimer_isReverseDirection, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBarChangeRate", js_cocos2dx_ProgressTimer_setBarChangeRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPercentage", js_cocos2dx_ProgressTimer_getPercentage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSprite", js_cocos2dx_ProgressTimer_setSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getType", js_cocos2dx_ProgressTimer_getType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSprite", js_cocos2dx_ProgressTimer_getSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMidpoint", js_cocos2dx_ProgressTimer_setMidpoint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBarChangeRate", js_cocos2dx_ProgressTimer_getBarChangeRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setReverseDirection", js_cocos2dx_ProgressTimer_setReverseDirection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMidpoint", js_cocos2dx_ProgressTimer_getMidpoint, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPercentage", js_cocos2dx_ProgressTimer_setPercentage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setType", js_cocos2dx_ProgressTimer_setType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ProgressTimer_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ProgressTimer_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ProgressTimer_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_ProgressTimer_class, + js_cocos2dx_ProgressTimer_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, "ProgressTimer", 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_ProgressTimer_class; + p->proto = jsb_cocos2d_ProgressTimer_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Sprite_class; +JSObject *jsb_cocos2d_Sprite_prototype; + +bool js_cocos2dx_Sprite_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Sprite* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setSpriteFrame : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::SpriteFrame* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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; } + cobj->setSpriteFrame(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->setSpriteFrame(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Sprite_setSpriteFrame : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Sprite_setTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Sprite* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setTexture : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cobj->setTexture(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->setTexture(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Sprite_setTexture : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Sprite_getTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_getTexture : Invalid Native Object"); + if (argc == 0) { + cocos2d::Texture2D* ret = cobj->getTexture(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_getTexture : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Sprite_setFlippedY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setFlippedY : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sprite_setFlippedY : Error processing arguments"); + cobj->setFlippedY(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_setFlippedY : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Sprite_setFlippedX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setFlippedX : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sprite_setFlippedX : Error processing arguments"); + cobj->setFlippedX(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_setFlippedX : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Sprite_setRotationSkewX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setRotationSkewX : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sprite_setRotationSkewX : Error processing arguments"); + cobj->setRotationSkewX(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_setRotationSkewX : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Sprite_setRotationSkewY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setRotationSkewY : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sprite_setRotationSkewY : Error processing arguments"); + cobj->setRotationSkewY(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_setRotationSkewY : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Sprite_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Sprite* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_initWithTexture : Invalid Native Object"); + do { + if (argc == 2) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(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, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithTexture(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithTexture(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 3) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(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, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool arg2; + arg2 = JS::ToBoolean(args.get(2)); + bool ret = cobj->initWithTexture(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Sprite_initWithTexture : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Sprite_getBatchNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_getBatchNode : Invalid Native Object"); + if (argc == 0) { + cocos2d::SpriteBatchNode* ret = cobj->getBatchNode(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SpriteBatchNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_getBatchNode : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Sprite_getOffsetPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_getOffsetPosition : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getOffsetPosition(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_getOffsetPosition : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Sprite_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_removeAllChildrenWithCleanup : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sprite_removeAllChildrenWithCleanup : Error processing arguments"); + cobj->removeAllChildrenWithCleanup(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_removeAllChildrenWithCleanup : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Sprite_setTextureRect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Sprite* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setTextureRect : Invalid Native Object"); + do { + if (argc == 3) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + bool arg1; + arg1 = JS::ToBoolean(args.get(1)); + cocos2d::Size arg2; + ok &= jsval_to_ccsize(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cobj->setTextureRect(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->setTextureRect(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Sprite_setTextureRect : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Sprite_initWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_initWithSpriteFrameName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sprite_initWithSpriteFrameName : Error processing arguments"); + bool ret = cobj->initWithSpriteFrameName(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_initWithSpriteFrameName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Sprite_isFrameDisplayed(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_isFrameDisplayed : Invalid Native Object"); + if (argc == 1) { + cocos2d::SpriteFrame* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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_Sprite_isFrameDisplayed : Error processing arguments"); + bool ret = cobj->isFrameDisplayed(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_isFrameDisplayed : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Sprite_getAtlasIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_getAtlasIndex : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getAtlasIndex(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_getAtlasIndex : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Sprite_setBatchNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setBatchNode : Invalid Native Object"); + if (argc == 1) { + cocos2d::SpriteBatchNode* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::SpriteBatchNode*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sprite_setBatchNode : Error processing arguments"); + cobj->setBatchNode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_setBatchNode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Sprite_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_getBlendFunc : Invalid Native Object"); + if (argc == 0) { + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Sprite_setDisplayFrameWithAnimationName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setDisplayFrameWithAnimationName : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + ssize_t arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_ssize(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sprite_setDisplayFrameWithAnimationName : Error processing arguments"); + cobj->setDisplayFrameWithAnimationName(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_setDisplayFrameWithAnimationName : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_Sprite_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setTextureAtlas : Invalid Native Object"); + if (argc == 1) { + cocos2d::TextureAtlas* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::TextureAtlas*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sprite_setTextureAtlas : Error processing arguments"); + cobj->setTextureAtlas(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_setTextureAtlas : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Sprite_getSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_getSpriteFrame : Invalid Native Object"); + if (argc == 0) { + cocos2d::SpriteFrame* ret = cobj->getSpriteFrame(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SpriteFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_getSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Sprite_isDirty(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_isDirty : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isDirty(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_isDirty : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Sprite_setAtlasIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setAtlasIndex : Invalid Native Object"); + if (argc == 1) { + ssize_t arg0; + ok &= jsval_to_ssize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sprite_setAtlasIndex : Error processing arguments"); + cobj->setAtlasIndex(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_setAtlasIndex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Sprite_setDirty(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setDirty : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sprite_setDirty : Error processing arguments"); + cobj->setDirty(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_setDirty : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Sprite_isTextureRectRotated(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_isTextureRectRotated : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isTextureRectRotated(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_isTextureRectRotated : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Sprite_getTextureRect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_getTextureRect : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Rect& ret = cobj->getTextureRect(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_getTextureRect : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Sprite_initWithFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Sprite* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_initWithFile : Invalid Native Object"); + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithFile(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithFile(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Sprite_initWithFile : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Sprite_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setBlendFunc : Invalid Native Object"); + if (argc == 1) { + cocos2d::BlendFunc arg0; + ok &= jsval_to_blendfunc(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sprite_setBlendFunc : Error processing arguments"); + cobj->setBlendFunc(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Sprite_getTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_getTextureAtlas : Invalid Native Object"); + if (argc == 0) { + cocos2d::TextureAtlas* ret = cobj->getTextureAtlas(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TextureAtlas*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_getTextureAtlas : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Sprite_initWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_initWithSpriteFrame : Invalid Native Object"); + if (argc == 1) { + cocos2d::SpriteFrame* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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_Sprite_initWithSpriteFrame : Error processing arguments"); + bool ret = cobj->initWithSpriteFrame(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_initWithSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Sprite_isFlippedX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_isFlippedX : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isFlippedX(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_isFlippedX : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Sprite_isFlippedY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_isFlippedY : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isFlippedY(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_isFlippedY : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Sprite_setVertexRect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setVertexRect : Invalid Native Object"); + if (argc == 1) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sprite_setVertexRect : Error processing arguments"); + cobj->setVertexRect(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_setVertexRect : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Sprite_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Sprite* ret = cocos2d::Sprite::create(arg0); + 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); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::Sprite* ret = cocos2d::Sprite::create(); + 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); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::Sprite* ret = cocos2d::Sprite::create(arg0, arg1); + 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); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_Sprite_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Sprite_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(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, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::Sprite* ret = cocos2d::Sprite::createWithTexture(arg0, arg1); + 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); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 3) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(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, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool arg2; + arg2 = JS::ToBoolean(args.get(2)); + if (!ok) { ok = true; break; } + cocos2d::Sprite* ret = cocos2d::Sprite::createWithTexture(arg0, arg1, arg2); + 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); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 1) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Sprite* ret = cocos2d::Sprite::createWithTexture(arg0); + 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); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_Sprite_createWithTexture : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Sprite_createWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sprite_createWithSpriteFrameName : Error processing arguments"); + cocos2d::Sprite* ret = cocos2d::Sprite::createWithSpriteFrameName(arg0); + 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); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Sprite_createWithSpriteFrameName : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Sprite_createWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::SpriteFrame* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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_Sprite_createWithSpriteFrame : Error processing arguments"); + cocos2d::Sprite* ret = cocos2d::Sprite::createWithSpriteFrame(arg0); + 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); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Sprite_createWithSpriteFrame : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Sprite_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Sprite* cobj = new (std::nothrow) cocos2d::Sprite(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Sprite"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_Sprite_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Sprite)", obj); +} + +static bool js_cocos2d_Sprite_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Sprite *nobj = new (std::nothrow) cocos2d::Sprite(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Sprite"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_Sprite(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Sprite_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Sprite_class->name = "Sprite"; + jsb_cocos2d_Sprite_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Sprite_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Sprite_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Sprite_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Sprite_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Sprite_class->resolve = JS_ResolveStub; + jsb_cocos2d_Sprite_class->convert = JS_ConvertStub; + jsb_cocos2d_Sprite_class->finalize = js_cocos2d_Sprite_finalize; + jsb_cocos2d_Sprite_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setSpriteFrame", js_cocos2dx_Sprite_setSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTexture", js_cocos2dx_Sprite_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTexture", js_cocos2dx_Sprite_getTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFlippedY", js_cocos2dx_Sprite_setFlippedY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFlippedX", js_cocos2dx_Sprite_setFlippedX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRotationSkewX", js_cocos2dx_Sprite_setRotationSkewX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRotationSkewY", js_cocos2dx_Sprite_setRotationSkewY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTexture", js_cocos2dx_Sprite_initWithTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBatchNode", js_cocos2dx_Sprite_getBatchNode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOffsetPosition", js_cocos2dx_Sprite_getOffsetPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllChildrenWithCleanup", js_cocos2dx_Sprite_removeAllChildrenWithCleanup, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTextureRect", js_cocos2dx_Sprite_setTextureRect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithSpriteFrameName", js_cocos2dx_Sprite_initWithSpriteFrameName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isFrameDisplayed", js_cocos2dx_Sprite_isFrameDisplayed, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAtlasIndex", js_cocos2dx_Sprite_getAtlasIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBatchNode", js_cocos2dx_Sprite_setBatchNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBlendFunc", js_cocos2dx_Sprite_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDisplayFrameWithAnimationName", js_cocos2dx_Sprite_setDisplayFrameWithAnimationName, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTextureAtlas", js_cocos2dx_Sprite_setTextureAtlas, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSpriteFrame", js_cocos2dx_Sprite_getSpriteFrame, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isDirty", js_cocos2dx_Sprite_isDirty, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAtlasIndex", js_cocos2dx_Sprite_setAtlasIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDirty", js_cocos2dx_Sprite_setDirty, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isTextureRectRotated", js_cocos2dx_Sprite_isTextureRectRotated, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTextureRect", js_cocos2dx_Sprite_getTextureRect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithFile", js_cocos2dx_Sprite_initWithFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBlendFunc", js_cocos2dx_Sprite_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTextureAtlas", js_cocos2dx_Sprite_getTextureAtlas, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithSpriteFrame", js_cocos2dx_Sprite_initWithSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isFlippedX", js_cocos2dx_Sprite_isFlippedX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isFlippedY", js_cocos2dx_Sprite_isFlippedY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setVertexRect", js_cocos2dx_Sprite_setVertexRect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_Sprite_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Sprite_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithTexture", js_cocos2dx_Sprite_createWithTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithSpriteFrameName", js_cocos2dx_Sprite_createWithSpriteFrameName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithSpriteFrame", js_cocos2dx_Sprite_createWithSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Sprite_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_Sprite_class, + js_cocos2dx_Sprite_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, "Sprite", 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_Sprite_class; + p->proto = jsb_cocos2d_Sprite_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Image_class; +JSObject *jsb_cocos2d_Image_prototype; + +bool js_cocos2dx_Image_hasPremultipliedAlpha(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_hasPremultipliedAlpha : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->hasPremultipliedAlpha(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_hasPremultipliedAlpha : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_getDataLen(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getDataLen : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getDataLen(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_getDataLen : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_saveToFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_saveToFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Image_saveToFile : Error processing arguments"); + bool ret = cobj->saveToFile(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + std::string arg0; + bool arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Image_saveToFile : Error processing arguments"); + bool ret = cobj->saveToFile(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_saveToFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Image_hasAlpha(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_hasAlpha : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->hasAlpha(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_hasAlpha : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_isCompressed(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_isCompressed : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isCompressed(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_isCompressed : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_getHeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getHeight : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getHeight(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_getHeight : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_initWithImageFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_initWithImageFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Image_initWithImageFile : Error processing arguments"); + bool ret = cobj->initWithImageFile(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_initWithImageFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Image_getWidth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getWidth : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getWidth(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_getWidth : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_getBitPerPixel(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getBitPerPixel : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getBitPerPixel(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_getBitPerPixel : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_getFileType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getFileType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getFileType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_getFileType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_getNumberOfMipmaps(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getNumberOfMipmaps : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getNumberOfMipmaps(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_getNumberOfMipmaps : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_getRenderFormat(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getRenderFormat : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getRenderFormat(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_getRenderFormat : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_getData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getData : Invalid Native Object"); + if (argc == 0) { + unsigned char* ret = cobj->getData(); + jsval jsret = JSVAL_NULL; + #pragma warning NO CONVERSION FROM NATIVE FOR unsigned char*; + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_getData : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_getMipmaps(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getMipmaps : Invalid Native Object"); + if (argc == 0) { + cocos2d::_MipmapInfo* ret = cobj->getMipmaps(); + jsval jsret = JSVAL_NULL; + #pragma warning NO CONVERSION FROM NATIVE FOR _MipmapInfo*; + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_getMipmaps : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_initWithRawData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_initWithRawData : Invalid Native Object"); + if (argc == 5) { + const unsigned char* arg0; + ssize_t arg1; + int arg2; + int arg3; + int arg4; + #pragma warning NO CONVERSION TO NATIVE FOR unsigned char* + ok = false; + ok &= jsval_to_ssize(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Image_initWithRawData : Error processing arguments"); + bool ret = cobj->initWithRawData(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 6) { + const unsigned char* arg0; + ssize_t arg1; + int arg2; + int arg3; + int arg4; + bool arg5; + #pragma warning NO CONVERSION TO NATIVE FOR unsigned char* + ok = false; + ok &= jsval_to_ssize(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); + arg5 = JS::ToBoolean(args.get(5)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Image_initWithRawData : Error processing arguments"); + bool ret = cobj->initWithRawData(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_initWithRawData : wrong number of arguments: %d, was expecting %d", argc, 5); + return false; +} +bool js_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha : Error processing arguments"); + cocos2d::Image::setPVRImagesHavePremultipliedAlpha(arg0); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Image_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Image* cobj = new (std::nothrow) cocos2d::Image(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Image"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_Image_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Image)", obj); +} + +void js_register_cocos2dx_Image(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Image_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Image_class->name = "Image"; + jsb_cocos2d_Image_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Image_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Image_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Image_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Image_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Image_class->resolve = JS_ResolveStub; + jsb_cocos2d_Image_class->convert = JS_ConvertStub; + jsb_cocos2d_Image_class->finalize = js_cocos2d_Image_finalize; + jsb_cocos2d_Image_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("hasPremultipliedAlpha", js_cocos2dx_Image_hasPremultipliedAlpha, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDataLen", js_cocos2dx_Image_getDataLen, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("saveToFile", js_cocos2dx_Image_saveToFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("hasAlpha", js_cocos2dx_Image_hasAlpha, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isCompressed", js_cocos2dx_Image_isCompressed, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getHeight", js_cocos2dx_Image_getHeight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithImageFile", js_cocos2dx_Image_initWithImageFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getWidth", js_cocos2dx_Image_getWidth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBitPerPixel", js_cocos2dx_Image_getBitPerPixel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFileType", js_cocos2dx_Image_getFileType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNumberOfMipmaps", js_cocos2dx_Image_getNumberOfMipmaps, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRenderFormat", js_cocos2dx_Image_getRenderFormat, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getData", js_cocos2dx_Image_getData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMipmaps", js_cocos2dx_Image_getMipmaps, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithRawData", js_cocos2dx_Image_initWithRawData, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("setPVRImagesHavePremultipliedAlpha", js_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Image_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_Image_class, + js_cocos2dx_Image_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, "Image", 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_Image_class; + p->proto = jsb_cocos2d_Image_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_RenderTexture_class; +JSObject *jsb_cocos2d_RenderTexture_prototype; + +bool js_cocos2dx_RenderTexture_setVirtualViewport(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_setVirtualViewport : Invalid Native Object"); + if (argc == 3) { + cocos2d::Vec2 arg0; + cocos2d::Rect arg1; + cocos2d::Rect arg2; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + ok &= jsval_to_ccrect(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_RenderTexture_setVirtualViewport : Error processing arguments"); + cobj->setVirtualViewport(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_setVirtualViewport : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_RenderTexture_clearStencil(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_clearStencil : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_RenderTexture_clearStencil : Error processing arguments"); + cobj->clearStencil(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_clearStencil : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_RenderTexture_getClearDepth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_getClearDepth : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getClearDepth(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_getClearDepth : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_RenderTexture_getClearStencil(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_getClearStencil : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getClearStencil(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_getClearStencil : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_RenderTexture_end(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_end : Invalid Native Object"); + if (argc == 0) { + cobj->end(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_end : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_RenderTexture_setClearStencil(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_setClearStencil : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_RenderTexture_setClearStencil : Error processing arguments"); + cobj->setClearStencil(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_setClearStencil : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_RenderTexture_setSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_setSprite : Invalid Native Object"); + if (argc == 1) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_RenderTexture_setSprite : Error processing arguments"); + cobj->setSprite(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_setSprite : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_RenderTexture_getSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_getSprite : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_RenderTexture_isAutoDraw(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_isAutoDraw : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isAutoDraw(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_isAutoDraw : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_RenderTexture_setKeepMatrix(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_setKeepMatrix : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_RenderTexture_setKeepMatrix : Error processing arguments"); + cobj->setKeepMatrix(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_setKeepMatrix : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_RenderTexture_setClearFlags(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_setClearFlags : Invalid Native Object"); + if (argc == 1) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_RenderTexture_setClearFlags : Error processing arguments"); + cobj->setClearFlags(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_setClearFlags : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_RenderTexture_begin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_begin : Invalid Native Object"); + if (argc == 0) { + cobj->begin(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_begin : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_RenderTexture_setAutoDraw(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_setAutoDraw : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_RenderTexture_setAutoDraw : Error processing arguments"); + cobj->setAutoDraw(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_setAutoDraw : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_RenderTexture_setClearColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_setClearColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color4F arg0; + ok &= jsval_to_cccolor4f(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_RenderTexture_setClearColor : Error processing arguments"); + cobj->setClearColor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_setClearColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_RenderTexture_endToLua(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_endToLua : Invalid Native Object"); + if (argc == 0) { + cobj->endToLua(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_endToLua : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_RenderTexture_beginWithClear(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::RenderTexture* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_beginWithClear : Invalid Native Object"); + do { + if (argc == 5) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + double arg3; + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + if (!ok) { ok = true; break; } + double arg4; + ok &= JS::ToNumber( cx, args.get(4), &arg4) && !isnan(arg4); + if (!ok) { ok = true; break; } + cobj->beginWithClear(arg0, arg1, arg2, arg3, arg4); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 4) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + double arg3; + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + if (!ok) { ok = true; break; } + cobj->beginWithClear(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 6) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + double arg3; + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + if (!ok) { ok = true; break; } + double arg4; + ok &= JS::ToNumber( cx, args.get(4), &arg4) && !isnan(arg4); + if (!ok) { ok = true; break; } + int arg5; + ok &= jsval_to_int32(cx, args.get(5), (int32_t *)&arg5); + if (!ok) { ok = true; break; } + cobj->beginWithClear(arg0, arg1, arg2, arg3, arg4, arg5); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_beginWithClear : wrong number of arguments"); + return false; +} +bool js_cocos2dx_RenderTexture_clearDepth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_clearDepth : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_RenderTexture_clearDepth : Error processing arguments"); + cobj->clearDepth(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_clearDepth : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_RenderTexture_getClearColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_getClearColor : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color4F& ret = cobj->getClearColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor4f_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_getClearColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_RenderTexture_clear(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_clear : Invalid Native Object"); + if (argc == 4) { + double arg0; + double arg1; + double arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_RenderTexture_clear : Error processing arguments"); + cobj->clear(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_clear : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_RenderTexture_getClearFlags(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_getClearFlags : Invalid Native Object"); + if (argc == 0) { + unsigned int ret = cobj->getClearFlags(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_getClearFlags : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_RenderTexture_newImage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_newImage : Invalid Native Object"); + if (argc == 0) { + cocos2d::Image* ret = cobj->newImage(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Image*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_RenderTexture_newImage : Error processing arguments"); + cocos2d::Image* ret = cobj->newImage(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Image*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_newImage : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_RenderTexture_setClearDepth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::RenderTexture* cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_setClearDepth : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_RenderTexture_setClearDepth : Error processing arguments"); + cobj->setClearDepth(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_setClearDepth : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_RenderTexture_initWithWidthAndHeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::RenderTexture* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_initWithWidthAndHeight : Invalid Native Object"); + do { + if (argc == 4) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cocos2d::Texture2D::PixelFormat arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + unsigned int arg3; + ok &= jsval_to_uint32(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithWidthAndHeight(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 3) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cocos2d::Texture2D::PixelFormat arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithWidthAndHeight(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_initWithWidthAndHeight : wrong number of arguments"); + return false; +} +bool js_cocos2dx_RenderTexture_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 3) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cocos2d::Texture2D::PixelFormat arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + cocos2d::RenderTexture* ret = cocos2d::RenderTexture::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::RenderTexture*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 4) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cocos2d::Texture2D::PixelFormat arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + unsigned int arg3; + ok &= jsval_to_uint32(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + cocos2d::RenderTexture* ret = cocos2d::RenderTexture::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::RenderTexture*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cocos2d::RenderTexture* ret = cocos2d::RenderTexture::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::RenderTexture*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_RenderTexture_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_RenderTexture_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::RenderTexture* cobj = new (std::nothrow) cocos2d::RenderTexture(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::RenderTexture"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_RenderTexture_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (RenderTexture)", obj); +} + +static bool js_cocos2d_RenderTexture_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::RenderTexture *nobj = new (std::nothrow) cocos2d::RenderTexture(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::RenderTexture"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_RenderTexture(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_RenderTexture_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_RenderTexture_class->name = "RenderTexture"; + jsb_cocos2d_RenderTexture_class->addProperty = JS_PropertyStub; + jsb_cocos2d_RenderTexture_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_RenderTexture_class->getProperty = JS_PropertyStub; + jsb_cocos2d_RenderTexture_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_RenderTexture_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_RenderTexture_class->resolve = JS_ResolveStub; + jsb_cocos2d_RenderTexture_class->convert = JS_ConvertStub; + jsb_cocos2d_RenderTexture_class->finalize = js_cocos2d_RenderTexture_finalize; + jsb_cocos2d_RenderTexture_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setVirtualViewport", js_cocos2dx_RenderTexture_setVirtualViewport, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("clearStencil", js_cocos2dx_RenderTexture_clearStencil, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getClearDepth", js_cocos2dx_RenderTexture_getClearDepth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getClearStencil", js_cocos2dx_RenderTexture_getClearStencil, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("end", js_cocos2dx_RenderTexture_end, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setClearStencil", js_cocos2dx_RenderTexture_setClearStencil, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSprite", js_cocos2dx_RenderTexture_setSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSprite", js_cocos2dx_RenderTexture_getSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isAutoDraw", js_cocos2dx_RenderTexture_isAutoDraw, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setKeepMatrix", js_cocos2dx_RenderTexture_setKeepMatrix, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setClearFlags", js_cocos2dx_RenderTexture_setClearFlags, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("begin", js_cocos2dx_RenderTexture_begin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAutoDraw", js_cocos2dx_RenderTexture_setAutoDraw, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setClearColor", js_cocos2dx_RenderTexture_setClearColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("endToLua", js_cocos2dx_RenderTexture_endToLua, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("beginWithClear", js_cocos2dx_RenderTexture_beginWithClear, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("clearDepth", js_cocos2dx_RenderTexture_clearDepth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getClearColor", js_cocos2dx_RenderTexture_getClearColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("clear", js_cocos2dx_RenderTexture_clear, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getClearFlags", js_cocos2dx_RenderTexture_getClearFlags, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("newImage", js_cocos2dx_RenderTexture_newImage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setClearDepth", js_cocos2dx_RenderTexture_setClearDepth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithWidthAndHeight", js_cocos2dx_RenderTexture_initWithWidthAndHeight, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_RenderTexture_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_RenderTexture_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_RenderTexture_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_RenderTexture_class, + js_cocos2dx_RenderTexture_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, "RenderTexture", 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_RenderTexture_class; + p->proto = jsb_cocos2d_RenderTexture_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_NodeGrid_class; +JSObject *jsb_cocos2d_NodeGrid_prototype; + +bool js_cocos2dx_NodeGrid_setTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::NodeGrid* cobj = (cocos2d::NodeGrid *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_NodeGrid_setTarget : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_NodeGrid_setTarget : Error processing arguments"); + cobj->setTarget(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_NodeGrid_setTarget : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_NodeGrid_getGrid(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::NodeGrid* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::NodeGrid *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_NodeGrid_getGrid : Invalid Native Object"); + do { + if (argc == 0) { + const cocos2d::GridBase* ret = cobj->getGrid(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::GridBase*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + cocos2d::GridBase* ret = cobj->getGrid(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::GridBase*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_NodeGrid_getGrid : wrong number of arguments"); + return false; +} +bool js_cocos2dx_NodeGrid_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::NodeGrid* ret = cocos2d::NodeGrid::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::NodeGrid*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_NodeGrid_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_NodeGrid_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::NodeGrid* cobj = new (std::nothrow) cocos2d::NodeGrid(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::NodeGrid"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_NodeGrid_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (NodeGrid)", obj); +} + +void js_register_cocos2dx_NodeGrid(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_NodeGrid_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_NodeGrid_class->name = "NodeGrid"; + jsb_cocos2d_NodeGrid_class->addProperty = JS_PropertyStub; + jsb_cocos2d_NodeGrid_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_NodeGrid_class->getProperty = JS_PropertyStub; + jsb_cocos2d_NodeGrid_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_NodeGrid_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_NodeGrid_class->resolve = JS_ResolveStub; + jsb_cocos2d_NodeGrid_class->convert = JS_ConvertStub; + jsb_cocos2d_NodeGrid_class->finalize = js_cocos2d_NodeGrid_finalize; + jsb_cocos2d_NodeGrid_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setTarget", js_cocos2dx_NodeGrid_setTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getGrid", js_cocos2dx_NodeGrid_getGrid, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_NodeGrid_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_NodeGrid_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_NodeGrid_class, + js_cocos2dx_NodeGrid_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, "NodeGrid", 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_NodeGrid_class; + p->proto = jsb_cocos2d_NodeGrid_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ParticleBatchNode_class; +JSObject *jsb_cocos2d_ParticleBatchNode_prototype; + +bool js_cocos2dx_ParticleBatchNode_setTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleBatchNode_setTexture : Invalid Native Object"); + if (argc == 1) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleBatchNode_setTexture : Error processing arguments"); + cobj->setTexture(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_setTexture : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleBatchNode_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleBatchNode_initWithTexture : Invalid Native Object"); + if (argc == 2) { + cocos2d::Texture2D* arg0; + int arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleBatchNode_initWithTexture : Error processing arguments"); + bool ret = cobj->initWithTexture(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_initWithTexture : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ParticleBatchNode_disableParticle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleBatchNode_disableParticle : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleBatchNode_disableParticle : Error processing arguments"); + cobj->disableParticle(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_disableParticle : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleBatchNode_getTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleBatchNode_getTexture : Invalid Native Object"); + if (argc == 0) { + cocos2d::Texture2D* ret = cobj->getTexture(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_getTexture : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleBatchNode_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleBatchNode_setTextureAtlas : Invalid Native Object"); + if (argc == 1) { + cocos2d::TextureAtlas* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::TextureAtlas*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleBatchNode_setTextureAtlas : Error processing arguments"); + cobj->setTextureAtlas(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_setTextureAtlas : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleBatchNode_initWithFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleBatchNode_initWithFile : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + int arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleBatchNode_initWithFile : Error processing arguments"); + bool ret = cobj->initWithFile(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_initWithFile : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ParticleBatchNode_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleBatchNode_setBlendFunc : Invalid Native Object"); + if (argc == 1) { + cocos2d::BlendFunc arg0; + ok &= jsval_to_blendfunc(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleBatchNode_setBlendFunc : Error processing arguments"); + cobj->setBlendFunc(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleBatchNode_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleBatchNode_removeAllChildrenWithCleanup : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleBatchNode_removeAllChildrenWithCleanup : Error processing arguments"); + cobj->removeAllChildrenWithCleanup(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_removeAllChildrenWithCleanup : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleBatchNode_getTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleBatchNode_getTextureAtlas : Invalid Native Object"); + if (argc == 0) { + cocos2d::TextureAtlas* ret = cobj->getTextureAtlas(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TextureAtlas*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_getTextureAtlas : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleBatchNode_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleBatchNode_getBlendFunc : Invalid Native Object"); + if (argc == 0) { + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleBatchNode_insertChild(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleBatchNode_insertChild : Invalid Native Object"); + if (argc == 2) { + cocos2d::ParticleSystem* arg0; + int arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ParticleSystem*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleBatchNode_insertChild : Error processing arguments"); + cobj->insertChild(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_insertChild : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ParticleBatchNode_removeChildAtIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleBatchNode* cobj = (cocos2d::ParticleBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleBatchNode_removeChildAtIndex : Invalid Native Object"); + if (argc == 2) { + int arg0; + bool arg1; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleBatchNode_removeChildAtIndex : Error processing arguments"); + cobj->removeChildAtIndex(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_removeChildAtIndex : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ParticleBatchNode_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleBatchNode_create : Error processing arguments"); + cocos2d::ParticleBatchNode* ret = cocos2d::ParticleBatchNode::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleBatchNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + std::string arg0; + int arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleBatchNode_create : Error processing arguments"); + cocos2d::ParticleBatchNode* ret = cocos2d::ParticleBatchNode::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleBatchNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleBatchNode_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleBatchNode_createWithTexture : Error processing arguments"); + cocos2d::ParticleBatchNode* ret = cocos2d::ParticleBatchNode::createWithTexture(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleBatchNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + cocos2d::Texture2D* arg0; + int arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleBatchNode_createWithTexture : Error processing arguments"); + cocos2d::ParticleBatchNode* ret = cocos2d::ParticleBatchNode::createWithTexture(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleBatchNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleBatchNode_createWithTexture : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleBatchNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ParticleBatchNode* cobj = new (std::nothrow) cocos2d::ParticleBatchNode(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ParticleBatchNode"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_ParticleBatchNode_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ParticleBatchNode)", obj); +} + +static bool js_cocos2d_ParticleBatchNode_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ParticleBatchNode *nobj = new (std::nothrow) cocos2d::ParticleBatchNode(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ParticleBatchNode"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ParticleBatchNode(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ParticleBatchNode_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ParticleBatchNode_class->name = "ParticleBatchNode"; + jsb_cocos2d_ParticleBatchNode_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ParticleBatchNode_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ParticleBatchNode_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ParticleBatchNode_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ParticleBatchNode_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ParticleBatchNode_class->resolve = JS_ResolveStub; + jsb_cocos2d_ParticleBatchNode_class->convert = JS_ConvertStub; + jsb_cocos2d_ParticleBatchNode_class->finalize = js_cocos2d_ParticleBatchNode_finalize; + jsb_cocos2d_ParticleBatchNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setTexture", js_cocos2dx_ParticleBatchNode_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTexture", js_cocos2dx_ParticleBatchNode_initWithTexture, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("disableParticle", js_cocos2dx_ParticleBatchNode_disableParticle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTexture", js_cocos2dx_ParticleBatchNode_getTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTextureAtlas", js_cocos2dx_ParticleBatchNode_setTextureAtlas, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithFile", js_cocos2dx_ParticleBatchNode_initWithFile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBlendFunc", js_cocos2dx_ParticleBatchNode_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllChildrenWithCleanup", js_cocos2dx_ParticleBatchNode_removeAllChildrenWithCleanup, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTextureAtlas", js_cocos2dx_ParticleBatchNode_getTextureAtlas, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBlendFunc", js_cocos2dx_ParticleBatchNode_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("insertChild", js_cocos2dx_ParticleBatchNode_insertChild, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeChildAtIndex", js_cocos2dx_ParticleBatchNode_removeChildAtIndex, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ParticleBatchNode_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ParticleBatchNode_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithTexture", js_cocos2dx_ParticleBatchNode_createWithTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ParticleBatchNode_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_ParticleBatchNode_class, + js_cocos2dx_ParticleBatchNode_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, "ParticleBatchNode", 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_ParticleBatchNode_class; + p->proto = jsb_cocos2d_ParticleBatchNode_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ParticleSystem_class; +JSObject *jsb_cocos2d_ParticleSystem_prototype; + +bool js_cocos2dx_ParticleSystem_getStartSizeVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getStartSizeVar : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getStartSizeVar(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getStartSizeVar : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getTexture : Invalid Native Object"); + if (argc == 0) { + cocos2d::Texture2D* ret = cobj->getTexture(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getTexture : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_isFull(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_isFull : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isFull(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_isFull : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getBatchNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getBatchNode : Invalid Native Object"); + if (argc == 0) { + cocos2d::ParticleBatchNode* ret = cobj->getBatchNode(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleBatchNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getBatchNode : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getStartColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getStartColor : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color4F& ret = cobj->getStartColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor4f_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getStartColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getPositionType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getPositionType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getPositionType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getPositionType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setPosVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setPosVar : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setPosVar : Error processing arguments"); + cobj->setPosVar(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setPosVar : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_getEndSpin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getEndSpin : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getEndSpin(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEndSpin : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setRotatePerSecondVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setRotatePerSecondVar : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setRotatePerSecondVar : Error processing arguments"); + cobj->setRotatePerSecondVar(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setRotatePerSecondVar : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_getStartSpinVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getStartSpinVar : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getStartSpinVar(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getStartSpinVar : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getRadialAccelVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getRadialAccelVar : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getRadialAccelVar(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getRadialAccelVar : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getEndSizeVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getEndSizeVar : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getEndSizeVar(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEndSizeVar : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setTangentialAccel(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setTangentialAccel : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setTangentialAccel : Error processing arguments"); + cobj->setTangentialAccel(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setTangentialAccel : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_getRadialAccel(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getRadialAccel : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getRadialAccel(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getRadialAccel : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setStartRadius(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setStartRadius : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setStartRadius : Error processing arguments"); + cobj->setStartRadius(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setStartRadius : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setRotatePerSecond(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setRotatePerSecond : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setRotatePerSecond : Error processing arguments"); + cobj->setRotatePerSecond(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setRotatePerSecond : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setEndSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setEndSize : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setEndSize : Error processing arguments"); + cobj->setEndSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEndSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_getGravity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getGravity : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getGravity(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getGravity : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getTangentialAccel(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getTangentialAccel : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getTangentialAccel(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getTangentialAccel : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setEndRadius(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setEndRadius : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setEndRadius : Error processing arguments"); + cobj->setEndRadius(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEndRadius : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_getSpeed(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getSpeed : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getSpeed(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getSpeed : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getAngle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getAngle : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAngle(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getAngle : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setEndColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setEndColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color4F arg0; + ok &= jsval_to_cccolor4f(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setEndColor : Error processing arguments"); + cobj->setEndColor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEndColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setStartSpin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setStartSpin : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setStartSpin : Error processing arguments"); + cobj->setStartSpin(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setStartSpin : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setDuration : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setDuration : Error processing arguments"); + cobj->setDuration(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setDuration : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_initWithTotalParticles : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_initWithTotalParticles : Error processing arguments"); + bool ret = cobj->initWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_initWithTotalParticles : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setTexture : Invalid Native Object"); + if (argc == 1) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setTexture : Error processing arguments"); + cobj->setTexture(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setTexture : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_getPosVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getPosVar : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getPosVar(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getPosVar : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_updateWithNoTime(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_updateWithNoTime : Invalid Native Object"); + if (argc == 0) { + cobj->updateWithNoTime(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_updateWithNoTime : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_isBlendAdditive(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_isBlendAdditive : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isBlendAdditive(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_isBlendAdditive : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getSpeedVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getSpeedVar : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getSpeedVar(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getSpeedVar : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setPositionType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setPositionType : Invalid Native Object"); + if (argc == 1) { + cocos2d::ParticleSystem::PositionType arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setPositionType : Error processing arguments"); + cobj->setPositionType(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setPositionType : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_stopSystem(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_stopSystem : Invalid Native Object"); + if (argc == 0) { + cobj->stopSystem(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_stopSystem : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getSourcePosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getSourcePosition : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getSourcePosition(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getSourcePosition : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setLifeVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setLifeVar : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setLifeVar : Error processing arguments"); + cobj->setLifeVar(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setLifeVar : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setTotalParticles : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setTotalParticles : Error processing arguments"); + cobj->setTotalParticles(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setTotalParticles : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setEndColorVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setEndColorVar : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color4F arg0; + ok &= jsval_to_cccolor4f(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setEndColorVar : Error processing arguments"); + cobj->setEndColorVar(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEndColorVar : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_updateQuadWithParticle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_updateQuadWithParticle : Invalid Native Object"); + if (argc == 2) { + cocos2d::sParticle* arg0; + cocos2d::Vec2 arg1; + #pragma warning NO CONVERSION TO NATIVE FOR sParticle* + ok = false; + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_updateQuadWithParticle : Error processing arguments"); + cobj->updateQuadWithParticle(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_updateQuadWithParticle : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ParticleSystem_getAtlasIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getAtlasIndex : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getAtlasIndex(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getAtlasIndex : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getStartSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getStartSize : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getStartSize(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getStartSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setStartSpinVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setStartSpinVar : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setStartSpinVar : Error processing arguments"); + cobj->setStartSpinVar(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setStartSpinVar : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_resetSystem(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_resetSystem : Invalid Native Object"); + if (argc == 0) { + cobj->resetSystem(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_resetSystem : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setAtlasIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setAtlasIndex : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setAtlasIndex : Error processing arguments"); + cobj->setAtlasIndex(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setAtlasIndex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setTangentialAccelVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setTangentialAccelVar : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setTangentialAccelVar : Error processing arguments"); + cobj->setTangentialAccelVar(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setTangentialAccelVar : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setEndRadiusVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setEndRadiusVar : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setEndRadiusVar : Error processing arguments"); + cobj->setEndRadiusVar(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEndRadiusVar : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_getEndRadius(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getEndRadius : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getEndRadius(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEndRadius : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_isActive(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_isActive : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isActive(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_isActive : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setRadialAccelVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setRadialAccelVar : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setRadialAccelVar : Error processing arguments"); + cobj->setRadialAccelVar(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setRadialAccelVar : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setStartSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setStartSize : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setStartSize : Error processing arguments"); + cobj->setStartSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setStartSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setSpeed(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setSpeed : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setSpeed : Error processing arguments"); + cobj->setSpeed(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setSpeed : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_getStartSpin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getStartSpin : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getStartSpin(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getStartSpin : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getRotatePerSecond(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getRotatePerSecond : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getRotatePerSecond(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getRotatePerSecond : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_initParticle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_initParticle : Invalid Native Object"); + if (argc == 1) { + cocos2d::sParticle* arg0; + #pragma warning NO CONVERSION TO NATIVE FOR sParticle* + ok = false; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_initParticle : Error processing arguments"); + cobj->initParticle(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_initParticle : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setEmitterMode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setEmitterMode : Invalid Native Object"); + if (argc == 1) { + cocos2d::ParticleSystem::Mode arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setEmitterMode : Error processing arguments"); + cobj->setEmitterMode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEmitterMode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_getDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getDuration : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getDuration(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getDuration : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setSourcePosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setSourcePosition : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setSourcePosition : Error processing arguments"); + cobj->setSourcePosition(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setSourcePosition : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_getEndSpinVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getEndSpinVar : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getEndSpinVar(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEndSpinVar : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setBlendAdditive(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setBlendAdditive : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setBlendAdditive : Error processing arguments"); + cobj->setBlendAdditive(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setBlendAdditive : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setLife(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setLife : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setLife : Error processing arguments"); + cobj->setLife(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setLife : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setAngleVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setAngleVar : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setAngleVar : Error processing arguments"); + cobj->setAngleVar(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setAngleVar : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setRotationIsDir(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setRotationIsDir : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setRotationIsDir : Error processing arguments"); + cobj->setRotationIsDir(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setRotationIsDir : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setEndSizeVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setEndSizeVar : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setEndSizeVar : Error processing arguments"); + cobj->setEndSizeVar(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEndSizeVar : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setAngle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setAngle : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setAngle : Error processing arguments"); + cobj->setAngle(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setAngle : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setBatchNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setBatchNode : Invalid Native Object"); + if (argc == 1) { + cocos2d::ParticleBatchNode* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ParticleBatchNode*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setBatchNode : Error processing arguments"); + cobj->setBatchNode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setBatchNode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_getTangentialAccelVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getTangentialAccelVar : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getTangentialAccelVar(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getTangentialAccelVar : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getEmitterMode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getEmitterMode : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getEmitterMode(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEmitterMode : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setEndSpinVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setEndSpinVar : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setEndSpinVar : Error processing arguments"); + cobj->setEndSpinVar(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEndSpinVar : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_initWithFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_initWithFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_initWithFile : Error processing arguments"); + bool ret = cobj->initWithFile(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_initWithFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_getAngleVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getAngleVar : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAngleVar(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getAngleVar : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setStartColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setStartColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color4F arg0; + ok &= jsval_to_cccolor4f(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setStartColor : Error processing arguments"); + cobj->setStartColor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setStartColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_getRotatePerSecondVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getRotatePerSecondVar : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getRotatePerSecondVar(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getRotatePerSecondVar : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getEndSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getEndSize : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getEndSize(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEndSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getLife(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getLife : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getLife(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getLife : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setSpeedVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setSpeedVar : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setSpeedVar : Error processing arguments"); + cobj->setSpeedVar(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setSpeedVar : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setAutoRemoveOnFinish(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setAutoRemoveOnFinish : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setAutoRemoveOnFinish : Error processing arguments"); + cobj->setAutoRemoveOnFinish(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setAutoRemoveOnFinish : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setGravity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setGravity : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setGravity : Error processing arguments"); + cobj->setGravity(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setGravity : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_postStep(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_postStep : Invalid Native Object"); + if (argc == 0) { + cobj->postStep(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_postStep : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setEmissionRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setEmissionRate : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setEmissionRate : Error processing arguments"); + cobj->setEmissionRate(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEmissionRate : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_getEndColorVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getEndColorVar : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color4F& ret = cobj->getEndColorVar(); + jsval jsret = JSVAL_NULL; + jsret = cccolor4f_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEndColorVar : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getRotationIsDir(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getRotationIsDir : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->getRotationIsDir(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getRotationIsDir : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getEmissionRate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getEmissionRate : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getEmissionRate(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEmissionRate : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getEndColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getEndColor : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color4F& ret = cobj->getEndColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor4f_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEndColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getLifeVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getLifeVar : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getLifeVar(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getLifeVar : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setStartSizeVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setStartSizeVar : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setStartSizeVar : Error processing arguments"); + cobj->setStartSizeVar(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setStartSizeVar : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_addParticle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_addParticle : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->addParticle(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_addParticle : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getStartRadius(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getStartRadius : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getStartRadius(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getStartRadius : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getParticleCount(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getParticleCount : Invalid Native Object"); + if (argc == 0) { + unsigned int ret = cobj->getParticleCount(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getParticleCount : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getStartRadiusVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getStartRadiusVar : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getStartRadiusVar(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getStartRadiusVar : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getBlendFunc : Invalid Native Object"); + if (argc == 0) { + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setStartColorVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setStartColorVar : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color4F arg0; + ok &= jsval_to_cccolor4f(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setStartColorVar : Error processing arguments"); + cobj->setStartColorVar(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setStartColorVar : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setEndSpin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setEndSpin : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setEndSpin : Error processing arguments"); + cobj->setEndSpin(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setEndSpin : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setRadialAccel(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setRadialAccel : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setRadialAccel : Error processing arguments"); + cobj->setRadialAccel(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setRadialAccel : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_initWithDictionary(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ParticleSystem* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_initWithDictionary : Invalid Native Object"); + do { + if (argc == 2) { + cocos2d::ValueMap arg0; + ok &= jsval_to_ccvaluemap(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithDictionary(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::ValueMap arg0; + ok &= jsval_to_ccvaluemap(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithDictionary(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_initWithDictionary : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ParticleSystem_isAutoRemoveOnFinish(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_isAutoRemoveOnFinish : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isAutoRemoveOnFinish(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_isAutoRemoveOnFinish : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getTotalParticles : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getTotalParticles(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getTotalParticles : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_setStartRadiusVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setStartRadiusVar : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setStartRadiusVar : Error processing arguments"); + cobj->setStartRadiusVar(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setStartRadiusVar : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_setBlendFunc : Invalid Native Object"); + if (argc == 1) { + cocos2d::BlendFunc arg0; + ok &= jsval_to_blendfunc(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_setBlendFunc : Error processing arguments"); + cobj->setBlendFunc(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystem_getEndRadiusVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getEndRadiusVar : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getEndRadiusVar(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getEndRadiusVar : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_getStartColorVar(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem* cobj = (cocos2d::ParticleSystem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystem_getStartColorVar : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color4F& ret = cobj->getStartColorVar(); + jsval jsret = JSVAL_NULL; + jsret = cccolor4f_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_getStartColorVar : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSystem_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_create : Error processing arguments"); + cocos2d::ParticleSystem* ret = cocos2d::ParticleSystem::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSystem*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleSystem_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystem_createWithTotalParticles : Error processing arguments"); + cocos2d::ParticleSystem* ret = cocos2d::ParticleSystem::createWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSystem*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleSystem_createWithTotalParticles : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleSystem_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ParticleSystem* cobj = new (std::nothrow) cocos2d::ParticleSystem(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ParticleSystem"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_ParticleSystem_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ParticleSystem)", obj); +} + +static bool js_cocos2d_ParticleSystem_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ParticleSystem *nobj = new (std::nothrow) cocos2d::ParticleSystem(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ParticleSystem"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ParticleSystem(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ParticleSystem_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ParticleSystem_class->name = "ParticleSystem"; + jsb_cocos2d_ParticleSystem_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ParticleSystem_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ParticleSystem_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ParticleSystem_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ParticleSystem_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ParticleSystem_class->resolve = JS_ResolveStub; + jsb_cocos2d_ParticleSystem_class->convert = JS_ConvertStub; + jsb_cocos2d_ParticleSystem_class->finalize = js_cocos2d_ParticleSystem_finalize; + jsb_cocos2d_ParticleSystem_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getStartSizeVar", js_cocos2dx_ParticleSystem_getStartSizeVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTexture", js_cocos2dx_ParticleSystem_getTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isFull", js_cocos2dx_ParticleSystem_isFull, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBatchNode", js_cocos2dx_ParticleSystem_getBatchNode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStartColor", js_cocos2dx_ParticleSystem_getStartColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPositionType", js_cocos2dx_ParticleSystem_getPositionType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPosVar", js_cocos2dx_ParticleSystem_setPosVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEndSpin", js_cocos2dx_ParticleSystem_getEndSpin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRotatePerSecondVar", js_cocos2dx_ParticleSystem_setRotatePerSecondVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStartSpinVar", js_cocos2dx_ParticleSystem_getStartSpinVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRadialAccelVar", js_cocos2dx_ParticleSystem_getRadialAccelVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEndSizeVar", js_cocos2dx_ParticleSystem_getEndSizeVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTangentialAccel", js_cocos2dx_ParticleSystem_setTangentialAccel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRadialAccel", js_cocos2dx_ParticleSystem_getRadialAccel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setStartRadius", js_cocos2dx_ParticleSystem_setStartRadius, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRotatePerSecond", js_cocos2dx_ParticleSystem_setRotatePerSecond, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEndSize", js_cocos2dx_ParticleSystem_setEndSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getGravity", js_cocos2dx_ParticleSystem_getGravity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTangentialAccel", js_cocos2dx_ParticleSystem_getTangentialAccel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEndRadius", js_cocos2dx_ParticleSystem_setEndRadius, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSpeed", js_cocos2dx_ParticleSystem_getSpeed, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAngle", js_cocos2dx_ParticleSystem_getAngle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEndColor", js_cocos2dx_ParticleSystem_setEndColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setStartSpin", js_cocos2dx_ParticleSystem_setStartSpin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDuration", js_cocos2dx_ParticleSystem_setDuration, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTotalParticles", js_cocos2dx_ParticleSystem_initWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTexture", js_cocos2dx_ParticleSystem_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPosVar", js_cocos2dx_ParticleSystem_getPosVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateWithNoTime", js_cocos2dx_ParticleSystem_updateWithNoTime, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isBlendAdditive", js_cocos2dx_ParticleSystem_isBlendAdditive, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSpeedVar", js_cocos2dx_ParticleSystem_getSpeedVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPositionType", js_cocos2dx_ParticleSystem_setPositionType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("stopSystem", js_cocos2dx_ParticleSystem_stopSystem, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSourcePosition", js_cocos2dx_ParticleSystem_getSourcePosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLifeVar", js_cocos2dx_ParticleSystem_setLifeVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTotalParticles", js_cocos2dx_ParticleSystem_setTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEndColorVar", js_cocos2dx_ParticleSystem_setEndColorVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateQuadWithParticle", js_cocos2dx_ParticleSystem_updateQuadWithParticle, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAtlasIndex", js_cocos2dx_ParticleSystem_getAtlasIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStartSize", js_cocos2dx_ParticleSystem_getStartSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setStartSpinVar", js_cocos2dx_ParticleSystem_setStartSpinVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resetSystem", js_cocos2dx_ParticleSystem_resetSystem, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAtlasIndex", js_cocos2dx_ParticleSystem_setAtlasIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTangentialAccelVar", js_cocos2dx_ParticleSystem_setTangentialAccelVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEndRadiusVar", js_cocos2dx_ParticleSystem_setEndRadiusVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEndRadius", js_cocos2dx_ParticleSystem_getEndRadius, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isActive", js_cocos2dx_ParticleSystem_isActive, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRadialAccelVar", js_cocos2dx_ParticleSystem_setRadialAccelVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setStartSize", js_cocos2dx_ParticleSystem_setStartSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSpeed", js_cocos2dx_ParticleSystem_setSpeed, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStartSpin", js_cocos2dx_ParticleSystem_getStartSpin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRotatePerSecond", js_cocos2dx_ParticleSystem_getRotatePerSecond, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initParticle", js_cocos2dx_ParticleSystem_initParticle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEmitterMode", js_cocos2dx_ParticleSystem_setEmitterMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDuration", js_cocos2dx_ParticleSystem_getDuration, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSourcePosition", js_cocos2dx_ParticleSystem_setSourcePosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEndSpinVar", js_cocos2dx_ParticleSystem_getEndSpinVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBlendAdditive", js_cocos2dx_ParticleSystem_setBlendAdditive, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLife", js_cocos2dx_ParticleSystem_setLife, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAngleVar", js_cocos2dx_ParticleSystem_setAngleVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRotationIsDir", js_cocos2dx_ParticleSystem_setRotationIsDir, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEndSizeVar", js_cocos2dx_ParticleSystem_setEndSizeVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAngle", js_cocos2dx_ParticleSystem_setAngle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBatchNode", js_cocos2dx_ParticleSystem_setBatchNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTangentialAccelVar", js_cocos2dx_ParticleSystem_getTangentialAccelVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEmitterMode", js_cocos2dx_ParticleSystem_getEmitterMode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEndSpinVar", js_cocos2dx_ParticleSystem_setEndSpinVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithFile", js_cocos2dx_ParticleSystem_initWithFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAngleVar", js_cocos2dx_ParticleSystem_getAngleVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setStartColor", js_cocos2dx_ParticleSystem_setStartColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRotatePerSecondVar", js_cocos2dx_ParticleSystem_getRotatePerSecondVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEndSize", js_cocos2dx_ParticleSystem_getEndSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLife", js_cocos2dx_ParticleSystem_getLife, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSpeedVar", js_cocos2dx_ParticleSystem_setSpeedVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAutoRemoveOnFinish", js_cocos2dx_ParticleSystem_setAutoRemoveOnFinish, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setGravity", js_cocos2dx_ParticleSystem_setGravity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("postStep", js_cocos2dx_ParticleSystem_postStep, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEmissionRate", js_cocos2dx_ParticleSystem_setEmissionRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEndColorVar", js_cocos2dx_ParticleSystem_getEndColorVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRotationIsDir", js_cocos2dx_ParticleSystem_getRotationIsDir, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEmissionRate", js_cocos2dx_ParticleSystem_getEmissionRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEndColor", js_cocos2dx_ParticleSystem_getEndColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLifeVar", js_cocos2dx_ParticleSystem_getLifeVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setStartSizeVar", js_cocos2dx_ParticleSystem_setStartSizeVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addParticle", js_cocos2dx_ParticleSystem_addParticle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStartRadius", js_cocos2dx_ParticleSystem_getStartRadius, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getParticleCount", js_cocos2dx_ParticleSystem_getParticleCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStartRadiusVar", js_cocos2dx_ParticleSystem_getStartRadiusVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBlendFunc", js_cocos2dx_ParticleSystem_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setStartColorVar", js_cocos2dx_ParticleSystem_setStartColorVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEndSpin", js_cocos2dx_ParticleSystem_setEndSpin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRadialAccel", js_cocos2dx_ParticleSystem_setRadialAccel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithDictionary", js_cocos2dx_ParticleSystem_initWithDictionary, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isAutoRemoveOnFinish", js_cocos2dx_ParticleSystem_isAutoRemoveOnFinish, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTotalParticles", js_cocos2dx_ParticleSystem_getTotalParticles, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setStartRadiusVar", js_cocos2dx_ParticleSystem_setStartRadiusVar, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBlendFunc", js_cocos2dx_ParticleSystem_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEndRadiusVar", js_cocos2dx_ParticleSystem_getEndRadiusVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStartColorVar", js_cocos2dx_ParticleSystem_getStartColorVar, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ParticleSystem_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ParticleSystem_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithTotalParticles", js_cocos2dx_ParticleSystem_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ParticleSystem_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_ParticleSystem_class, + js_cocos2dx_ParticleSystem_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, "ParticleSystem", 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_ParticleSystem_class; + p->proto = jsb_cocos2d_ParticleSystem_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ParticleSystemQuad_class; +JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; + +bool js_cocos2dx_ParticleSystemQuad_setDisplayFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystemQuad* cobj = (cocos2d::ParticleSystemQuad *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystemQuad_setDisplayFrame : Invalid Native Object"); + if (argc == 1) { + cocos2d::SpriteFrame* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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_ParticleSystemQuad_setDisplayFrame : Error processing arguments"); + cobj->setDisplayFrame(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystemQuad_setDisplayFrame : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystemQuad_setTextureWithRect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystemQuad* cobj = (cocos2d::ParticleSystemQuad *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystemQuad_setTextureWithRect : Invalid Native Object"); + if (argc == 2) { + cocos2d::Texture2D* arg0; + cocos2d::Rect arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystemQuad_setTextureWithRect : Error processing arguments"); + cobj->setTextureWithRect(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystemQuad_setTextureWithRect : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ParticleSystemQuad_listenRendererRecreated(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystemQuad* cobj = (cocos2d::ParticleSystemQuad *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSystemQuad_listenRendererRecreated : Invalid Native Object"); + if (argc == 1) { + cocos2d::EventCustom* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::EventCustom*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystemQuad_listenRendererRecreated : Error processing arguments"); + cobj->listenRendererRecreated(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSystemQuad_listenRendererRecreated : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSystemQuad_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::ParticleSystemQuad* ret = cocos2d::ParticleSystemQuad::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSystemQuad*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::ParticleSystemQuad* ret = cocos2d::ParticleSystemQuad::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSystemQuad*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 1) { + cocos2d::ValueMap arg0; + ok &= jsval_to_ccvaluemap(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::ParticleSystemQuad* ret = cocos2d::ParticleSystemQuad::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSystemQuad*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ParticleSystemQuad_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ParticleSystemQuad_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSystemQuad_createWithTotalParticles : Error processing arguments"); + cocos2d::ParticleSystemQuad* ret = cocos2d::ParticleSystemQuad::createWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSystemQuad*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleSystemQuad_createWithTotalParticles : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleSystemQuad_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ParticleSystemQuad* cobj = new (std::nothrow) cocos2d::ParticleSystemQuad(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ParticleSystemQuad"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ParticleSystem_prototype; + +void js_cocos2d_ParticleSystemQuad_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ParticleSystemQuad)", obj); +} + +void js_register_cocos2dx_ParticleSystemQuad(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ParticleSystemQuad_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ParticleSystemQuad_class->name = "ParticleSystem"; + jsb_cocos2d_ParticleSystemQuad_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ParticleSystemQuad_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ParticleSystemQuad_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ParticleSystemQuad_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ParticleSystemQuad_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ParticleSystemQuad_class->resolve = JS_ResolveStub; + jsb_cocos2d_ParticleSystemQuad_class->convert = JS_ConvertStub; + jsb_cocos2d_ParticleSystemQuad_class->finalize = js_cocos2d_ParticleSystemQuad_finalize; + jsb_cocos2d_ParticleSystemQuad_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setDisplayFrame", js_cocos2dx_ParticleSystemQuad_setDisplayFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTextureWithRect", js_cocos2dx_ParticleSystemQuad_setTextureWithRect, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("listenRendererRecreated", js_cocos2dx_ParticleSystemQuad_listenRendererRecreated, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ParticleSystemQuad_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithTotalParticles", js_cocos2dx_ParticleSystemQuad_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ParticleSystemQuad_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ParticleSystem_prototype), + jsb_cocos2d_ParticleSystemQuad_class, + js_cocos2dx_ParticleSystemQuad_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, "ParticleSystem", 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_ParticleSystemQuad_class; + p->proto = jsb_cocos2d_ParticleSystemQuad_prototype; + p->parentProto = jsb_cocos2d_ParticleSystem_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ParticleFire_class; +JSObject *jsb_cocos2d_ParticleFire_prototype; + +bool js_cocos2dx_ParticleFire_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ParticleFire* ret = cocos2d::ParticleFire::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleFire*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleFire_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleFire_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleFire_createWithTotalParticles : Error processing arguments"); + cocos2d::ParticleFire* ret = cocos2d::ParticleFire::createWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleFire*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleFire_createWithTotalParticles : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleFire_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ParticleFire* cobj = new (std::nothrow) cocos2d::ParticleFire(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ParticleFire"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; + +void js_cocos2d_ParticleFire_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ParticleFire)", obj); +} + +void js_register_cocos2dx_ParticleFire(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ParticleFire_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ParticleFire_class->name = "ParticleFire"; + jsb_cocos2d_ParticleFire_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ParticleFire_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ParticleFire_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ParticleFire_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ParticleFire_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ParticleFire_class->resolve = JS_ResolveStub; + jsb_cocos2d_ParticleFire_class->convert = JS_ConvertStub; + jsb_cocos2d_ParticleFire_class->finalize = js_cocos2d_ParticleFire_finalize; + jsb_cocos2d_ParticleFire_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ParticleFire_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithTotalParticles", js_cocos2dx_ParticleFire_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ParticleFire_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + jsb_cocos2d_ParticleFire_class, + js_cocos2dx_ParticleFire_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, "ParticleFire", 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_ParticleFire_class; + p->proto = jsb_cocos2d_ParticleFire_prototype; + p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ParticleFireworks_class; +JSObject *jsb_cocos2d_ParticleFireworks_prototype; + +bool js_cocos2dx_ParticleFireworks_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleFireworks* cobj = (cocos2d::ParticleFireworks *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleFireworks_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleFireworks_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleFireworks_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleFireworks* cobj = (cocos2d::ParticleFireworks *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleFireworks_initWithTotalParticles : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleFireworks_initWithTotalParticles : Error processing arguments"); + bool ret = cobj->initWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleFireworks_initWithTotalParticles : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleFireworks_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ParticleFireworks* ret = cocos2d::ParticleFireworks::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleFireworks*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleFireworks_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleFireworks_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleFireworks_createWithTotalParticles : Error processing arguments"); + cocos2d::ParticleFireworks* ret = cocos2d::ParticleFireworks::createWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleFireworks*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleFireworks_createWithTotalParticles : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleFireworks_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ParticleFireworks* cobj = new (std::nothrow) cocos2d::ParticleFireworks(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ParticleFireworks"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; + +void js_cocos2d_ParticleFireworks_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ParticleFireworks)", obj); +} + +void js_register_cocos2dx_ParticleFireworks(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ParticleFireworks_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ParticleFireworks_class->name = "ParticleFireworks"; + jsb_cocos2d_ParticleFireworks_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ParticleFireworks_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ParticleFireworks_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ParticleFireworks_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ParticleFireworks_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ParticleFireworks_class->resolve = JS_ResolveStub; + jsb_cocos2d_ParticleFireworks_class->convert = JS_ConvertStub; + jsb_cocos2d_ParticleFireworks_class->finalize = js_cocos2d_ParticleFireworks_finalize; + jsb_cocos2d_ParticleFireworks_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_ParticleFireworks_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTotalParticles", js_cocos2dx_ParticleFireworks_initWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ParticleFireworks_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithTotalParticles", js_cocos2dx_ParticleFireworks_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ParticleFireworks_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + jsb_cocos2d_ParticleFireworks_class, + js_cocos2dx_ParticleFireworks_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, "ParticleFireworks", 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_ParticleFireworks_class; + p->proto = jsb_cocos2d_ParticleFireworks_prototype; + p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ParticleSun_class; +JSObject *jsb_cocos2d_ParticleSun_prototype; + +bool js_cocos2dx_ParticleSun_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSun* cobj = (cocos2d::ParticleSun *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSun_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSun_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSun_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSun* cobj = (cocos2d::ParticleSun *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSun_initWithTotalParticles : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSun_initWithTotalParticles : Error processing arguments"); + bool ret = cobj->initWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSun_initWithTotalParticles : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSun_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ParticleSun* ret = cocos2d::ParticleSun::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSun*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleSun_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleSun_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSun_createWithTotalParticles : Error processing arguments"); + cocos2d::ParticleSun* ret = cocos2d::ParticleSun::createWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSun*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleSun_createWithTotalParticles : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleSun_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ParticleSun* cobj = new (std::nothrow) cocos2d::ParticleSun(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ParticleSun"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; + +void js_cocos2d_ParticleSun_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ParticleSun)", obj); +} + +void js_register_cocos2dx_ParticleSun(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ParticleSun_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ParticleSun_class->name = "ParticleSun"; + jsb_cocos2d_ParticleSun_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ParticleSun_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ParticleSun_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ParticleSun_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ParticleSun_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ParticleSun_class->resolve = JS_ResolveStub; + jsb_cocos2d_ParticleSun_class->convert = JS_ConvertStub; + jsb_cocos2d_ParticleSun_class->finalize = js_cocos2d_ParticleSun_finalize; + jsb_cocos2d_ParticleSun_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_ParticleSun_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTotalParticles", js_cocos2dx_ParticleSun_initWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ParticleSun_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithTotalParticles", js_cocos2dx_ParticleSun_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ParticleSun_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + jsb_cocos2d_ParticleSun_class, + js_cocos2dx_ParticleSun_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, "ParticleSun", 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_ParticleSun_class; + p->proto = jsb_cocos2d_ParticleSun_prototype; + p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ParticleGalaxy_class; +JSObject *jsb_cocos2d_ParticleGalaxy_prototype; + +bool js_cocos2dx_ParticleGalaxy_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleGalaxy* cobj = (cocos2d::ParticleGalaxy *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleGalaxy_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleGalaxy_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleGalaxy_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleGalaxy* cobj = (cocos2d::ParticleGalaxy *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleGalaxy_initWithTotalParticles : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleGalaxy_initWithTotalParticles : Error processing arguments"); + bool ret = cobj->initWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleGalaxy_initWithTotalParticles : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleGalaxy_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ParticleGalaxy* ret = cocos2d::ParticleGalaxy::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleGalaxy*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleGalaxy_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleGalaxy_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleGalaxy_createWithTotalParticles : Error processing arguments"); + cocos2d::ParticleGalaxy* ret = cocos2d::ParticleGalaxy::createWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleGalaxy*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleGalaxy_createWithTotalParticles : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleGalaxy_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ParticleGalaxy* cobj = new (std::nothrow) cocos2d::ParticleGalaxy(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ParticleGalaxy"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; + +void js_cocos2d_ParticleGalaxy_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ParticleGalaxy)", obj); +} + +void js_register_cocos2dx_ParticleGalaxy(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ParticleGalaxy_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ParticleGalaxy_class->name = "ParticleGalaxy"; + jsb_cocos2d_ParticleGalaxy_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ParticleGalaxy_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ParticleGalaxy_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ParticleGalaxy_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ParticleGalaxy_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ParticleGalaxy_class->resolve = JS_ResolveStub; + jsb_cocos2d_ParticleGalaxy_class->convert = JS_ConvertStub; + jsb_cocos2d_ParticleGalaxy_class->finalize = js_cocos2d_ParticleGalaxy_finalize; + jsb_cocos2d_ParticleGalaxy_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_ParticleGalaxy_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTotalParticles", js_cocos2dx_ParticleGalaxy_initWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ParticleGalaxy_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithTotalParticles", js_cocos2dx_ParticleGalaxy_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ParticleGalaxy_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + jsb_cocos2d_ParticleGalaxy_class, + js_cocos2dx_ParticleGalaxy_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, "ParticleGalaxy", 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_ParticleGalaxy_class; + p->proto = jsb_cocos2d_ParticleGalaxy_prototype; + p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ParticleFlower_class; +JSObject *jsb_cocos2d_ParticleFlower_prototype; + +bool js_cocos2dx_ParticleFlower_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleFlower* cobj = (cocos2d::ParticleFlower *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleFlower_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleFlower_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleFlower_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleFlower* cobj = (cocos2d::ParticleFlower *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleFlower_initWithTotalParticles : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleFlower_initWithTotalParticles : Error processing arguments"); + bool ret = cobj->initWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleFlower_initWithTotalParticles : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleFlower_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ParticleFlower* ret = cocos2d::ParticleFlower::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleFlower*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleFlower_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleFlower_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleFlower_createWithTotalParticles : Error processing arguments"); + cocos2d::ParticleFlower* ret = cocos2d::ParticleFlower::createWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleFlower*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleFlower_createWithTotalParticles : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleFlower_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ParticleFlower* cobj = new (std::nothrow) cocos2d::ParticleFlower(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ParticleFlower"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; + +void js_cocos2d_ParticleFlower_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ParticleFlower)", obj); +} + +void js_register_cocos2dx_ParticleFlower(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ParticleFlower_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ParticleFlower_class->name = "ParticleFlower"; + jsb_cocos2d_ParticleFlower_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ParticleFlower_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ParticleFlower_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ParticleFlower_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ParticleFlower_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ParticleFlower_class->resolve = JS_ResolveStub; + jsb_cocos2d_ParticleFlower_class->convert = JS_ConvertStub; + jsb_cocos2d_ParticleFlower_class->finalize = js_cocos2d_ParticleFlower_finalize; + jsb_cocos2d_ParticleFlower_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_ParticleFlower_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTotalParticles", js_cocos2dx_ParticleFlower_initWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ParticleFlower_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithTotalParticles", js_cocos2dx_ParticleFlower_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ParticleFlower_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + jsb_cocos2d_ParticleFlower_class, + js_cocos2dx_ParticleFlower_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, "ParticleFlower", 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_ParticleFlower_class; + p->proto = jsb_cocos2d_ParticleFlower_prototype; + p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ParticleMeteor_class; +JSObject *jsb_cocos2d_ParticleMeteor_prototype; + +bool js_cocos2dx_ParticleMeteor_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleMeteor* cobj = (cocos2d::ParticleMeteor *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleMeteor_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleMeteor_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleMeteor_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleMeteor* cobj = (cocos2d::ParticleMeteor *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleMeteor_initWithTotalParticles : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleMeteor_initWithTotalParticles : Error processing arguments"); + bool ret = cobj->initWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleMeteor_initWithTotalParticles : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleMeteor_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ParticleMeteor* ret = cocos2d::ParticleMeteor::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleMeteor*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleMeteor_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleMeteor_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleMeteor_createWithTotalParticles : Error processing arguments"); + cocos2d::ParticleMeteor* ret = cocos2d::ParticleMeteor::createWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleMeteor*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleMeteor_createWithTotalParticles : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleMeteor_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ParticleMeteor* cobj = new (std::nothrow) cocos2d::ParticleMeteor(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ParticleMeteor"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; + +void js_cocos2d_ParticleMeteor_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ParticleMeteor)", obj); +} + +void js_register_cocos2dx_ParticleMeteor(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ParticleMeteor_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ParticleMeteor_class->name = "ParticleMeteor"; + jsb_cocos2d_ParticleMeteor_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ParticleMeteor_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ParticleMeteor_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ParticleMeteor_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ParticleMeteor_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ParticleMeteor_class->resolve = JS_ResolveStub; + jsb_cocos2d_ParticleMeteor_class->convert = JS_ConvertStub; + jsb_cocos2d_ParticleMeteor_class->finalize = js_cocos2d_ParticleMeteor_finalize; + jsb_cocos2d_ParticleMeteor_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_ParticleMeteor_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTotalParticles", js_cocos2dx_ParticleMeteor_initWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ParticleMeteor_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithTotalParticles", js_cocos2dx_ParticleMeteor_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ParticleMeteor_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + jsb_cocos2d_ParticleMeteor_class, + js_cocos2dx_ParticleMeteor_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, "ParticleMeteor", 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_ParticleMeteor_class; + p->proto = jsb_cocos2d_ParticleMeteor_prototype; + p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ParticleSpiral_class; +JSObject *jsb_cocos2d_ParticleSpiral_prototype; + +bool js_cocos2dx_ParticleSpiral_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSpiral* cobj = (cocos2d::ParticleSpiral *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSpiral_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSpiral_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSpiral_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSpiral* cobj = (cocos2d::ParticleSpiral *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSpiral_initWithTotalParticles : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSpiral_initWithTotalParticles : Error processing arguments"); + bool ret = cobj->initWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSpiral_initWithTotalParticles : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSpiral_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ParticleSpiral* ret = cocos2d::ParticleSpiral::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSpiral*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleSpiral_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleSpiral_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSpiral_createWithTotalParticles : Error processing arguments"); + cocos2d::ParticleSpiral* ret = cocos2d::ParticleSpiral::createWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSpiral*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleSpiral_createWithTotalParticles : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleSpiral_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ParticleSpiral* cobj = new (std::nothrow) cocos2d::ParticleSpiral(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ParticleSpiral"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; + +void js_cocos2d_ParticleSpiral_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ParticleSpiral)", obj); +} + +void js_register_cocos2dx_ParticleSpiral(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ParticleSpiral_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ParticleSpiral_class->name = "ParticleSpiral"; + jsb_cocos2d_ParticleSpiral_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ParticleSpiral_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ParticleSpiral_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ParticleSpiral_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ParticleSpiral_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ParticleSpiral_class->resolve = JS_ResolveStub; + jsb_cocos2d_ParticleSpiral_class->convert = JS_ConvertStub; + jsb_cocos2d_ParticleSpiral_class->finalize = js_cocos2d_ParticleSpiral_finalize; + jsb_cocos2d_ParticleSpiral_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_ParticleSpiral_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTotalParticles", js_cocos2dx_ParticleSpiral_initWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ParticleSpiral_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithTotalParticles", js_cocos2dx_ParticleSpiral_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ParticleSpiral_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + jsb_cocos2d_ParticleSpiral_class, + js_cocos2dx_ParticleSpiral_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, "ParticleSpiral", 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_ParticleSpiral_class; + p->proto = jsb_cocos2d_ParticleSpiral_prototype; + p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ParticleExplosion_class; +JSObject *jsb_cocos2d_ParticleExplosion_prototype; + +bool js_cocos2dx_ParticleExplosion_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleExplosion* cobj = (cocos2d::ParticleExplosion *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleExplosion_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleExplosion_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleExplosion_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleExplosion* cobj = (cocos2d::ParticleExplosion *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleExplosion_initWithTotalParticles : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleExplosion_initWithTotalParticles : Error processing arguments"); + bool ret = cobj->initWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleExplosion_initWithTotalParticles : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleExplosion_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ParticleExplosion* ret = cocos2d::ParticleExplosion::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleExplosion*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleExplosion_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleExplosion_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleExplosion_createWithTotalParticles : Error processing arguments"); + cocos2d::ParticleExplosion* ret = cocos2d::ParticleExplosion::createWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleExplosion*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleExplosion_createWithTotalParticles : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleExplosion_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ParticleExplosion* cobj = new (std::nothrow) cocos2d::ParticleExplosion(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ParticleExplosion"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; + +void js_cocos2d_ParticleExplosion_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ParticleExplosion)", obj); +} + +void js_register_cocos2dx_ParticleExplosion(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ParticleExplosion_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ParticleExplosion_class->name = "ParticleExplosion"; + jsb_cocos2d_ParticleExplosion_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ParticleExplosion_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ParticleExplosion_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ParticleExplosion_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ParticleExplosion_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ParticleExplosion_class->resolve = JS_ResolveStub; + jsb_cocos2d_ParticleExplosion_class->convert = JS_ConvertStub; + jsb_cocos2d_ParticleExplosion_class->finalize = js_cocos2d_ParticleExplosion_finalize; + jsb_cocos2d_ParticleExplosion_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_ParticleExplosion_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTotalParticles", js_cocos2dx_ParticleExplosion_initWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ParticleExplosion_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithTotalParticles", js_cocos2dx_ParticleExplosion_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ParticleExplosion_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + jsb_cocos2d_ParticleExplosion_class, + js_cocos2dx_ParticleExplosion_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, "ParticleExplosion", 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_ParticleExplosion_class; + p->proto = jsb_cocos2d_ParticleExplosion_prototype; + p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ParticleSmoke_class; +JSObject *jsb_cocos2d_ParticleSmoke_prototype; + +bool js_cocos2dx_ParticleSmoke_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSmoke* cobj = (cocos2d::ParticleSmoke *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSmoke_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSmoke_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSmoke_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSmoke* cobj = (cocos2d::ParticleSmoke *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSmoke_initWithTotalParticles : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSmoke_initWithTotalParticles : Error processing arguments"); + bool ret = cobj->initWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSmoke_initWithTotalParticles : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSmoke_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ParticleSmoke* ret = cocos2d::ParticleSmoke::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSmoke*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleSmoke_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleSmoke_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSmoke_createWithTotalParticles : Error processing arguments"); + cocos2d::ParticleSmoke* ret = cocos2d::ParticleSmoke::createWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSmoke*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleSmoke_createWithTotalParticles : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleSmoke_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ParticleSmoke* cobj = new (std::nothrow) cocos2d::ParticleSmoke(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ParticleSmoke"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; + +void js_cocos2d_ParticleSmoke_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ParticleSmoke)", obj); +} + +void js_register_cocos2dx_ParticleSmoke(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ParticleSmoke_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ParticleSmoke_class->name = "ParticleSmoke"; + jsb_cocos2d_ParticleSmoke_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ParticleSmoke_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ParticleSmoke_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ParticleSmoke_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ParticleSmoke_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ParticleSmoke_class->resolve = JS_ResolveStub; + jsb_cocos2d_ParticleSmoke_class->convert = JS_ConvertStub; + jsb_cocos2d_ParticleSmoke_class->finalize = js_cocos2d_ParticleSmoke_finalize; + jsb_cocos2d_ParticleSmoke_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_ParticleSmoke_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTotalParticles", js_cocos2dx_ParticleSmoke_initWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ParticleSmoke_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithTotalParticles", js_cocos2dx_ParticleSmoke_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ParticleSmoke_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + jsb_cocos2d_ParticleSmoke_class, + js_cocos2dx_ParticleSmoke_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, "ParticleSmoke", 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_ParticleSmoke_class; + p->proto = jsb_cocos2d_ParticleSmoke_prototype; + p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ParticleSnow_class; +JSObject *jsb_cocos2d_ParticleSnow_prototype; + +bool js_cocos2dx_ParticleSnow_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSnow* cobj = (cocos2d::ParticleSnow *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSnow_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSnow_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleSnow_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSnow* cobj = (cocos2d::ParticleSnow *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleSnow_initWithTotalParticles : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSnow_initWithTotalParticles : Error processing arguments"); + bool ret = cobj->initWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleSnow_initWithTotalParticles : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleSnow_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ParticleSnow* ret = cocos2d::ParticleSnow::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSnow*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleSnow_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleSnow_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleSnow_createWithTotalParticles : Error processing arguments"); + cocos2d::ParticleSnow* ret = cocos2d::ParticleSnow::createWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleSnow*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleSnow_createWithTotalParticles : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleSnow_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ParticleSnow* cobj = new (std::nothrow) cocos2d::ParticleSnow(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ParticleSnow"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; + +void js_cocos2d_ParticleSnow_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ParticleSnow)", obj); +} + +void js_register_cocos2dx_ParticleSnow(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ParticleSnow_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ParticleSnow_class->name = "ParticleSnow"; + jsb_cocos2d_ParticleSnow_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ParticleSnow_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ParticleSnow_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ParticleSnow_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ParticleSnow_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ParticleSnow_class->resolve = JS_ResolveStub; + jsb_cocos2d_ParticleSnow_class->convert = JS_ConvertStub; + jsb_cocos2d_ParticleSnow_class->finalize = js_cocos2d_ParticleSnow_finalize; + jsb_cocos2d_ParticleSnow_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_ParticleSnow_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTotalParticles", js_cocos2dx_ParticleSnow_initWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ParticleSnow_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithTotalParticles", js_cocos2dx_ParticleSnow_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ParticleSnow_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + jsb_cocos2d_ParticleSnow_class, + js_cocos2dx_ParticleSnow_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, "ParticleSnow", 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_ParticleSnow_class; + p->proto = jsb_cocos2d_ParticleSnow_prototype; + p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ParticleRain_class; +JSObject *jsb_cocos2d_ParticleRain_prototype; + +bool js_cocos2dx_ParticleRain_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleRain* cobj = (cocos2d::ParticleRain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleRain_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleRain_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ParticleRain_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleRain* cobj = (cocos2d::ParticleRain *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParticleRain_initWithTotalParticles : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleRain_initWithTotalParticles : Error processing arguments"); + bool ret = cobj->initWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParticleRain_initWithTotalParticles : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParticleRain_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ParticleRain* ret = cocos2d::ParticleRain::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleRain*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleRain_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleRain_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParticleRain_createWithTotalParticles : Error processing arguments"); + cocos2d::ParticleRain* ret = cocos2d::ParticleRain::createWithTotalParticles(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParticleRain*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParticleRain_createWithTotalParticles : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParticleRain_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ParticleRain* cobj = new (std::nothrow) cocos2d::ParticleRain(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ParticleRain"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; + +void js_cocos2d_ParticleRain_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ParticleRain)", obj); +} + +void js_register_cocos2dx_ParticleRain(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ParticleRain_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ParticleRain_class->name = "ParticleRain"; + jsb_cocos2d_ParticleRain_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ParticleRain_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ParticleRain_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ParticleRain_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ParticleRain_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ParticleRain_class->resolve = JS_ResolveStub; + jsb_cocos2d_ParticleRain_class->convert = JS_ConvertStub; + jsb_cocos2d_ParticleRain_class->finalize = js_cocos2d_ParticleRain_finalize; + jsb_cocos2d_ParticleRain_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_ParticleRain_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTotalParticles", js_cocos2dx_ParticleRain_initWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ParticleRain_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithTotalParticles", js_cocos2dx_ParticleRain_createWithTotalParticles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ParticleRain_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ParticleSystemQuad_prototype), + jsb_cocos2d_ParticleRain_class, + js_cocos2dx_ParticleRain_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, "ParticleRain", 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_ParticleRain_class; + p->proto = jsb_cocos2d_ParticleRain_prototype; + p->parentProto = jsb_cocos2d_ParticleSystemQuad_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_GridBase_class; +JSObject *jsb_cocos2d_GridBase_prototype; + +bool js_cocos2dx_GridBase_setGridSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_setGridSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GridBase_setGridSize : Error processing arguments"); + cobj->setGridSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridBase_setGridSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_GridBase_afterBlit(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_afterBlit : Invalid Native Object"); + if (argc == 0) { + cobj->afterBlit(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridBase_afterBlit : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GridBase_afterDraw(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_afterDraw : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GridBase_afterDraw : Error processing arguments"); + cobj->afterDraw(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridBase_afterDraw : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_GridBase_beforeDraw(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_beforeDraw : Invalid Native Object"); + if (argc == 0) { + cobj->beforeDraw(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridBase_beforeDraw : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GridBase_calculateVertexPoints(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_calculateVertexPoints : Invalid Native Object"); + if (argc == 0) { + cobj->calculateVertexPoints(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridBase_calculateVertexPoints : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GridBase_isTextureFlipped(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_isTextureFlipped : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isTextureFlipped(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridBase_isTextureFlipped : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GridBase_getGridSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_getGridSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getGridSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridBase_getGridSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GridBase_getStep(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_getStep : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getStep(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridBase_getStep : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GridBase_set2DProjection(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_set2DProjection : Invalid Native Object"); + if (argc == 0) { + cobj->set2DProjection(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridBase_set2DProjection : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GridBase_setStep(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_setStep : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GridBase_setStep : Error processing arguments"); + cobj->setStep(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridBase_setStep : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_GridBase_setTextureFlipped(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_setTextureFlipped : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GridBase_setTextureFlipped : Error processing arguments"); + cobj->setTextureFlipped(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridBase_setTextureFlipped : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_GridBase_blit(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_blit : Invalid Native Object"); + if (argc == 0) { + cobj->blit(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridBase_blit : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GridBase_setActive(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_setActive : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GridBase_setActive : Error processing arguments"); + cobj->setActive(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridBase_setActive : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_GridBase_getReuseGrid(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_getReuseGrid : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getReuseGrid(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridBase_getReuseGrid : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GridBase_initWithSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::GridBase* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_initWithSize : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithSize(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 3) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Texture2D* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + 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; } + bool arg2; + arg2 = JS::ToBoolean(args.get(2)); + bool ret = cobj->initWithSize(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GridBase_initWithSize : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GridBase_beforeBlit(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_beforeBlit : Invalid Native Object"); + if (argc == 0) { + cobj->beforeBlit(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridBase_beforeBlit : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GridBase_setReuseGrid(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_setReuseGrid : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GridBase_setReuseGrid : Error processing arguments"); + cobj->setReuseGrid(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridBase_setReuseGrid : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_GridBase_isActive(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_isActive : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isActive(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridBase_isActive : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GridBase_reuse(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GridBase* cobj = (cocos2d::GridBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GridBase_reuse : Invalid Native Object"); + if (argc == 0) { + cobj->reuse(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GridBase_reuse : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GridBase_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::GridBase* ret = cocos2d::GridBase::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::GridBase*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 3) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Texture2D* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + 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; } + bool arg2; + arg2 = JS::ToBoolean(args.get(2)); + if (!ok) { ok = true; break; } + cocos2d::GridBase* ret = cocos2d::GridBase::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::GridBase*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_GridBase_create : wrong number of arguments"); + return false; +} + + +void js_cocos2d_GridBase_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (GridBase)", obj); +} + +static bool js_cocos2d_GridBase_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::GridBase *nobj = new (std::nothrow) cocos2d::GridBase(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::GridBase"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_GridBase(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_GridBase_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_GridBase_class->name = "GridBase"; + jsb_cocos2d_GridBase_class->addProperty = JS_PropertyStub; + jsb_cocos2d_GridBase_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_GridBase_class->getProperty = JS_PropertyStub; + jsb_cocos2d_GridBase_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_GridBase_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_GridBase_class->resolve = JS_ResolveStub; + jsb_cocos2d_GridBase_class->convert = JS_ConvertStub; + jsb_cocos2d_GridBase_class->finalize = js_cocos2d_GridBase_finalize; + jsb_cocos2d_GridBase_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setGridSize", js_cocos2dx_GridBase_setGridSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("afterBlit", js_cocos2dx_GridBase_afterBlit, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("afterDraw", js_cocos2dx_GridBase_afterDraw, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("beforeDraw", js_cocos2dx_GridBase_beforeDraw, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("calculateVertexPoints", js_cocos2dx_GridBase_calculateVertexPoints, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isTextureFlipped", js_cocos2dx_GridBase_isTextureFlipped, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getGridSize", js_cocos2dx_GridBase_getGridSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStep", js_cocos2dx_GridBase_getStep, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("set2DProjection", js_cocos2dx_GridBase_set2DProjection, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setStep", js_cocos2dx_GridBase_setStep, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTextureFlipped", js_cocos2dx_GridBase_setTextureFlipped, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("blit", js_cocos2dx_GridBase_blit, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setActive", js_cocos2dx_GridBase_setActive, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getReuseGrid", js_cocos2dx_GridBase_getReuseGrid, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithSize", js_cocos2dx_GridBase_initWithSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("beforeBlit", js_cocos2dx_GridBase_beforeBlit, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setReuseGrid", js_cocos2dx_GridBase_setReuseGrid, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isActive", js_cocos2dx_GridBase_isActive, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("reuse", js_cocos2dx_GridBase_reuse, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_GridBase_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_GridBase_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_GridBase_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_GridBase_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, "GridBase", 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_GridBase_class; + p->proto = jsb_cocos2d_GridBase_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Grid3D_class; +JSObject *jsb_cocos2d_Grid3D_prototype; + +bool js_cocos2dx_Grid3D_getNeedDepthTestForBlit(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Grid3D* cobj = (cocos2d::Grid3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Grid3D_getNeedDepthTestForBlit : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->getNeedDepthTestForBlit(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Grid3D_getNeedDepthTestForBlit : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Grid3D_setNeedDepthTestForBlit(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Grid3D* cobj = (cocos2d::Grid3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Grid3D_setNeedDepthTestForBlit : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Grid3D_setNeedDepthTestForBlit : Error processing arguments"); + cobj->setNeedDepthTestForBlit(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Grid3D_setNeedDepthTestForBlit : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Grid3D_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Grid3D* ret = cocos2d::Grid3D::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Grid3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 3) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Texture2D* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + 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; } + bool arg2; + arg2 = JS::ToBoolean(args.get(2)); + if (!ok) { ok = true; break; } + cocos2d::Grid3D* ret = cocos2d::Grid3D::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Grid3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_Grid3D_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_Grid3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Grid3D* cobj = new (std::nothrow) cocos2d::Grid3D(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Grid3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_GridBase_prototype; + +void js_cocos2d_Grid3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Grid3D)", obj); +} + +static bool js_cocos2d_Grid3D_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Grid3D *nobj = new (std::nothrow) cocos2d::Grid3D(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Grid3D"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_Grid3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Grid3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Grid3D_class->name = "Grid3D"; + jsb_cocos2d_Grid3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Grid3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Grid3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Grid3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Grid3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Grid3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_Grid3D_class->convert = JS_ConvertStub; + jsb_cocos2d_Grid3D_class->finalize = js_cocos2d_Grid3D_finalize; + jsb_cocos2d_Grid3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getNeedDepthTestForBlit", js_cocos2dx_Grid3D_getNeedDepthTestForBlit, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setNeedDepthTestForBlit", js_cocos2dx_Grid3D_setNeedDepthTestForBlit, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_Grid3D_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Grid3D_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Grid3D_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_GridBase_prototype), + jsb_cocos2d_Grid3D_class, + js_cocos2dx_Grid3D_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, "Grid3D", 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_Grid3D_class; + p->proto = jsb_cocos2d_Grid3D_prototype; + p->parentProto = jsb_cocos2d_GridBase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TiledGrid3D_class; +JSObject *jsb_cocos2d_TiledGrid3D_prototype; + +bool js_cocos2dx_TiledGrid3D_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::TiledGrid3D* ret = cocos2d::TiledGrid3D::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TiledGrid3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 3) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Texture2D* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + 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; } + bool arg2; + arg2 = JS::ToBoolean(args.get(2)); + if (!ok) { ok = true; break; } + cocos2d::TiledGrid3D* ret = cocos2d::TiledGrid3D::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TiledGrid3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_TiledGrid3D_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TiledGrid3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TiledGrid3D* cobj = new (std::nothrow) cocos2d::TiledGrid3D(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TiledGrid3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_GridBase_prototype; + +void js_cocos2d_TiledGrid3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TiledGrid3D)", obj); +} + +static bool js_cocos2d_TiledGrid3D_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TiledGrid3D *nobj = new (std::nothrow) cocos2d::TiledGrid3D(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TiledGrid3D"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_TiledGrid3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TiledGrid3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TiledGrid3D_class->name = "TiledGrid3D"; + jsb_cocos2d_TiledGrid3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TiledGrid3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TiledGrid3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TiledGrid3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TiledGrid3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TiledGrid3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_TiledGrid3D_class->convert = JS_ConvertStub; + jsb_cocos2d_TiledGrid3D_class->finalize = js_cocos2d_TiledGrid3D_finalize; + jsb_cocos2d_TiledGrid3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2d_TiledGrid3D_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TiledGrid3D_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TiledGrid3D_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_GridBase_prototype), + jsb_cocos2d_TiledGrid3D_class, + js_cocos2dx_TiledGrid3D_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, "TiledGrid3D", 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_TiledGrid3D_class; + p->proto = jsb_cocos2d_TiledGrid3D_prototype; + p->parentProto = jsb_cocos2d_GridBase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Camera_class; +JSObject *jsb_cocos2d_Camera_prototype; + +bool js_cocos2dx_Camera_setScene(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_setScene : Invalid Native Object"); + if (argc == 1) { + cocos2d::Scene* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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_Camera_setScene : Error processing arguments"); + cobj->setScene(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Camera_setScene : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Camera_initPerspective(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_initPerspective : Invalid Native Object"); + if (argc == 4) { + double arg0; + double arg1; + double arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Camera_initPerspective : Error processing arguments"); + bool ret = cobj->initPerspective(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Camera_initPerspective : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_Camera_getProjectionMatrix(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_getProjectionMatrix : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Mat4& ret = cobj->getProjectionMatrix(); + jsval jsret = JSVAL_NULL; + jsret = matrix_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Camera_getProjectionMatrix : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Camera_getViewProjectionMatrix(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_getViewProjectionMatrix : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Mat4& ret = cobj->getViewProjectionMatrix(); + jsval jsret = JSVAL_NULL; + jsret = matrix_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Camera_getViewProjectionMatrix : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Camera_getViewMatrix(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_getViewMatrix : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Mat4& ret = cobj->getViewMatrix(); + jsval jsret = JSVAL_NULL; + jsret = matrix_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Camera_getViewMatrix : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Camera_getCameraFlag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_getCameraFlag : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getCameraFlag(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Camera_getCameraFlag : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Camera_getType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_getType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Camera_getType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Camera_initDefault(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_initDefault : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->initDefault(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Camera_initDefault : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Camera_project(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_project : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec3 arg0; + ok &= jsval_to_vector3(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Camera_project : Error processing arguments"); + cocos2d::Vec2 ret = cobj->project(arg0); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Camera_project : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Camera_getDepthInView(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_getDepthInView : Invalid Native Object"); + if (argc == 1) { + cocos2d::Mat4 arg0; + ok &= jsval_to_matrix(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Camera_getDepthInView : Error processing arguments"); + double ret = cobj->getDepthInView(arg0); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Camera_getDepthInView : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Camera_lookAt(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_lookAt : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec3 arg0; + ok &= jsval_to_vector3(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Camera_lookAt : Error processing arguments"); + cobj->lookAt(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + cocos2d::Vec3 arg0; + cocos2d::Vec3 arg1; + ok &= jsval_to_vector3(cx, args.get(0), &arg0); + ok &= jsval_to_vector3(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Camera_lookAt : Error processing arguments"); + cobj->lookAt(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Camera_lookAt : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Camera_setCameraFlag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_setCameraFlag : Invalid Native Object"); + if (argc == 1) { + cocos2d::CameraFlag arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Camera_setCameraFlag : Error processing arguments"); + cobj->setCameraFlag(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Camera_setCameraFlag : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Camera_initOrthographic(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_initOrthographic : Invalid Native Object"); + if (argc == 4) { + double arg0; + double arg1; + double arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Camera_initOrthographic : Error processing arguments"); + bool ret = cobj->initOrthographic(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Camera_initOrthographic : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_Camera_setAdditionalProjection(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_setAdditionalProjection : Invalid Native Object"); + if (argc == 1) { + cocos2d::Mat4 arg0; + ok &= jsval_to_matrix(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Camera_setAdditionalProjection : Error processing arguments"); + cobj->setAdditionalProjection(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Camera_setAdditionalProjection : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Camera_getDepth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_getDepth : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getDepth(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Camera_getDepth : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Camera_setDepth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_setDepth : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Camera_setDepth : Error processing arguments"); + cobj->setDepth(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Camera_setDepth : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Camera_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Camera* ret = cocos2d::Camera::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Camera*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Camera_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Camera_createPerspective(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 4) { + double arg0; + double arg1; + double arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Camera_createPerspective : Error processing arguments"); + cocos2d::Camera* ret = cocos2d::Camera::createPerspective(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Camera*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Camera_createPerspective : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Camera_createOrthographic(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 4) { + double arg0; + double arg1; + double arg2; + double arg3; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Camera_createOrthographic : Error processing arguments"); + cocos2d::Camera* ret = cocos2d::Camera::createOrthographic(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Camera*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Camera_createOrthographic : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Camera_getDefaultCamera(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Camera* ret = cocos2d::Camera::getDefaultCamera(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Camera*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Camera_getDefaultCamera : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Camera_getVisitingCamera(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + const cocos2d::Camera* ret = cocos2d::Camera::getVisitingCamera(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Camera*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Camera_getVisitingCamera : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Camera_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Camera* cobj = new (std::nothrow) cocos2d::Camera(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Camera"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_Camera_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Camera)", obj); +} + +void js_register_cocos2dx_Camera(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Camera_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Camera_class->name = "Camera"; + jsb_cocos2d_Camera_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Camera_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Camera_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Camera_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Camera_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Camera_class->resolve = JS_ResolveStub; + jsb_cocos2d_Camera_class->convert = JS_ConvertStub; + jsb_cocos2d_Camera_class->finalize = js_cocos2d_Camera_finalize; + jsb_cocos2d_Camera_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setScene", js_cocos2dx_Camera_setScene, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initPerspective", js_cocos2dx_Camera_initPerspective, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getProjectionMatrix", js_cocos2dx_Camera_getProjectionMatrix, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getViewProjectionMatrix", js_cocos2dx_Camera_getViewProjectionMatrix, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getViewMatrix", js_cocos2dx_Camera_getViewMatrix, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCameraFlag", js_cocos2dx_Camera_getCameraFlag, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getType", js_cocos2dx_Camera_getType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initDefault", js_cocos2dx_Camera_initDefault, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("project", js_cocos2dx_Camera_project, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDepthInView", js_cocos2dx_Camera_getDepthInView, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("lookAt", js_cocos2dx_Camera_lookAt, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCameraFlag", js_cocos2dx_Camera_setCameraFlag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initOrthographic", js_cocos2dx_Camera_initOrthographic, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAdditionalProjection", js_cocos2dx_Camera_setAdditionalProjection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDepth", js_cocos2dx_Camera_getDepth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDepth", js_cocos2dx_Camera_setDepth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Camera_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createPerspective", js_cocos2dx_Camera_createPerspective, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createOrthographic", js_cocos2dx_Camera_createOrthographic, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDefaultCamera", js_cocos2dx_Camera_getDefaultCamera, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVisitingCamera", js_cocos2dx_Camera_getVisitingCamera, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Camera_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_Camera_class, + js_cocos2dx_Camera_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, "Camera", 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_Camera_class; + p->proto = jsb_cocos2d_Camera_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_BaseLight_class; +JSObject *jsb_cocos2d_BaseLight_prototype; + +bool js_cocos2dx_BaseLight_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::BaseLight* cobj = (cocos2d::BaseLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_BaseLight_setEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_BaseLight_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_BaseLight_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_BaseLight_getIntensity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::BaseLight* cobj = (cocos2d::BaseLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_BaseLight_getIntensity : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getIntensity(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_BaseLight_getIntensity : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_BaseLight_isEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::BaseLight* cobj = (cocos2d::BaseLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_BaseLight_isEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_BaseLight_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_BaseLight_getLightType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::BaseLight* cobj = (cocos2d::BaseLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_BaseLight_getLightType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getLightType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_BaseLight_getLightType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_BaseLight_setLightFlag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::BaseLight* cobj = (cocos2d::BaseLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_BaseLight_setLightFlag : Invalid Native Object"); + if (argc == 1) { + cocos2d::LightFlag arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_BaseLight_setLightFlag : Error processing arguments"); + cobj->setLightFlag(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_BaseLight_setLightFlag : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_BaseLight_setIntensity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::BaseLight* cobj = (cocos2d::BaseLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_BaseLight_setIntensity : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_BaseLight_setIntensity : Error processing arguments"); + cobj->setIntensity(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_BaseLight_setIntensity : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_BaseLight_getLightFlag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::BaseLight* cobj = (cocos2d::BaseLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_BaseLight_getLightFlag : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getLightFlag(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_BaseLight_getLightFlag : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_BaseLight_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (BaseLight)", obj); +} + +void js_register_cocos2dx_BaseLight(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_BaseLight_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_BaseLight_class->name = "BaseLight"; + jsb_cocos2d_BaseLight_class->addProperty = JS_PropertyStub; + jsb_cocos2d_BaseLight_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_BaseLight_class->getProperty = JS_PropertyStub; + jsb_cocos2d_BaseLight_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_BaseLight_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_BaseLight_class->resolve = JS_ResolveStub; + jsb_cocos2d_BaseLight_class->convert = JS_ConvertStub; + jsb_cocos2d_BaseLight_class->finalize = js_cocos2d_BaseLight_finalize; + jsb_cocos2d_BaseLight_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setEnabled", js_cocos2dx_BaseLight_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getIntensity", js_cocos2dx_BaseLight_getIntensity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isEnabled", js_cocos2dx_BaseLight_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLightType", js_cocos2dx_BaseLight_getLightType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLightFlag", js_cocos2dx_BaseLight_setLightFlag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setIntensity", js_cocos2dx_BaseLight_setIntensity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLightFlag", js_cocos2dx_BaseLight_getLightFlag, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_BaseLight_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_BaseLight_class, + empty_constructor, 0, + 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, "BaseLight", 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_BaseLight_class; + p->proto = jsb_cocos2d_BaseLight_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_DirectionLight_class; +JSObject *jsb_cocos2d_DirectionLight_prototype; + +bool js_cocos2dx_DirectionLight_getDirection(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DirectionLight* cobj = (cocos2d::DirectionLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DirectionLight_getDirection : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec3 ret = cobj->getDirection(); + jsval jsret = JSVAL_NULL; + jsret = vector3_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DirectionLight_getDirection : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_DirectionLight_getDirectionInWorld(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DirectionLight* cobj = (cocos2d::DirectionLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DirectionLight_getDirectionInWorld : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec3 ret = cobj->getDirectionInWorld(); + jsval jsret = JSVAL_NULL; + jsret = vector3_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DirectionLight_getDirectionInWorld : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_DirectionLight_setDirection(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DirectionLight* cobj = (cocos2d::DirectionLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DirectionLight_setDirection : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec3 arg0; + ok &= jsval_to_vector3(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DirectionLight_setDirection : Error processing arguments"); + cobj->setDirection(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DirectionLight_setDirection : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_DirectionLight_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::Vec3 arg0; + cocos2d::Color3B arg1; + ok &= jsval_to_vector3(cx, args.get(0), &arg0); + ok &= jsval_to_cccolor3b(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DirectionLight_create : Error processing arguments"); + cocos2d::DirectionLight* ret = cocos2d::DirectionLight::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::DirectionLight*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_DirectionLight_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_DirectionLight_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::DirectionLight* cobj = new (std::nothrow) cocos2d::DirectionLight(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::DirectionLight"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_BaseLight_prototype; + +void js_cocos2d_DirectionLight_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (DirectionLight)", obj); +} + +void js_register_cocos2dx_DirectionLight(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_DirectionLight_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_DirectionLight_class->name = "DirectionLight"; + jsb_cocos2d_DirectionLight_class->addProperty = JS_PropertyStub; + jsb_cocos2d_DirectionLight_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_DirectionLight_class->getProperty = JS_PropertyStub; + jsb_cocos2d_DirectionLight_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_DirectionLight_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_DirectionLight_class->resolve = JS_ResolveStub; + jsb_cocos2d_DirectionLight_class->convert = JS_ConvertStub; + jsb_cocos2d_DirectionLight_class->finalize = js_cocos2d_DirectionLight_finalize; + jsb_cocos2d_DirectionLight_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getDirection", js_cocos2dx_DirectionLight_getDirection, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDirectionInWorld", js_cocos2dx_DirectionLight_getDirectionInWorld, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDirection", js_cocos2dx_DirectionLight_setDirection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_DirectionLight_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_DirectionLight_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_BaseLight_prototype), + jsb_cocos2d_DirectionLight_class, + js_cocos2dx_DirectionLight_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, "DirectionLight", 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_DirectionLight_class; + p->proto = jsb_cocos2d_DirectionLight_prototype; + p->parentProto = jsb_cocos2d_BaseLight_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_PointLight_class; +JSObject *jsb_cocos2d_PointLight_prototype; + +bool js_cocos2dx_PointLight_getRange(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PointLight* cobj = (cocos2d::PointLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_PointLight_getRange : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getRange(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_PointLight_getRange : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_PointLight_setRange(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PointLight* cobj = (cocos2d::PointLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_PointLight_setRange : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_PointLight_setRange : Error processing arguments"); + cobj->setRange(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_PointLight_setRange : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_PointLight_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 3) { + cocos2d::Vec3 arg0; + cocos2d::Color3B arg1; + double arg2; + ok &= jsval_to_vector3(cx, args.get(0), &arg0); + ok &= jsval_to_cccolor3b(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_PointLight_create : Error processing arguments"); + cocos2d::PointLight* ret = cocos2d::PointLight::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::PointLight*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_PointLight_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_PointLight_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::PointLight* cobj = new (std::nothrow) cocos2d::PointLight(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::PointLight"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_BaseLight_prototype; + +void js_cocos2d_PointLight_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (PointLight)", obj); +} + +void js_register_cocos2dx_PointLight(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_PointLight_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_PointLight_class->name = "PointLight"; + jsb_cocos2d_PointLight_class->addProperty = JS_PropertyStub; + jsb_cocos2d_PointLight_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_PointLight_class->getProperty = JS_PropertyStub; + jsb_cocos2d_PointLight_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_PointLight_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_PointLight_class->resolve = JS_ResolveStub; + jsb_cocos2d_PointLight_class->convert = JS_ConvertStub; + jsb_cocos2d_PointLight_class->finalize = js_cocos2d_PointLight_finalize; + jsb_cocos2d_PointLight_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getRange", js_cocos2dx_PointLight_getRange, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRange", js_cocos2dx_PointLight_setRange, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_PointLight_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_PointLight_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_BaseLight_prototype), + jsb_cocos2d_PointLight_class, + js_cocos2dx_PointLight_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, "PointLight", 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_PointLight_class; + p->proto = jsb_cocos2d_PointLight_prototype; + p->parentProto = jsb_cocos2d_BaseLight_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_SpotLight_class; +JSObject *jsb_cocos2d_SpotLight_prototype; + +bool js_cocos2dx_SpotLight_getRange(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpotLight* cobj = (cocos2d::SpotLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpotLight_getRange : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getRange(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpotLight_getRange : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpotLight_setDirection(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpotLight* cobj = (cocos2d::SpotLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpotLight_setDirection : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec3 arg0; + ok &= jsval_to_vector3(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpotLight_setDirection : Error processing arguments"); + cobj->setDirection(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpotLight_setDirection : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpotLight_getCosInnerAngle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpotLight* cobj = (cocos2d::SpotLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpotLight_getCosInnerAngle : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getCosInnerAngle(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpotLight_getCosInnerAngle : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpotLight_getOuterAngle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpotLight* cobj = (cocos2d::SpotLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpotLight_getOuterAngle : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getOuterAngle(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpotLight_getOuterAngle : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpotLight_getInnerAngle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpotLight* cobj = (cocos2d::SpotLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpotLight_getInnerAngle : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getInnerAngle(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpotLight_getInnerAngle : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpotLight_getDirection(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpotLight* cobj = (cocos2d::SpotLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpotLight_getDirection : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec3 ret = cobj->getDirection(); + jsval jsret = JSVAL_NULL; + jsret = vector3_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpotLight_getDirection : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpotLight_getCosOuterAngle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpotLight* cobj = (cocos2d::SpotLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpotLight_getCosOuterAngle : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getCosOuterAngle(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpotLight_getCosOuterAngle : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpotLight_setOuterAngle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpotLight* cobj = (cocos2d::SpotLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpotLight_setOuterAngle : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpotLight_setOuterAngle : Error processing arguments"); + cobj->setOuterAngle(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpotLight_setOuterAngle : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpotLight_setInnerAngle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpotLight* cobj = (cocos2d::SpotLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpotLight_setInnerAngle : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpotLight_setInnerAngle : Error processing arguments"); + cobj->setInnerAngle(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpotLight_setInnerAngle : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpotLight_getDirectionInWorld(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpotLight* cobj = (cocos2d::SpotLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpotLight_getDirectionInWorld : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec3 ret = cobj->getDirectionInWorld(); + jsval jsret = JSVAL_NULL; + jsret = vector3_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpotLight_getDirectionInWorld : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpotLight_setRange(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpotLight* cobj = (cocos2d::SpotLight *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpotLight_setRange : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpotLight_setRange : Error processing arguments"); + cobj->setRange(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpotLight_setRange : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpotLight_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 6) { + cocos2d::Vec3 arg0; + cocos2d::Vec3 arg1; + cocos2d::Color3B arg2; + double arg3; + double arg4; + double arg5; + ok &= jsval_to_vector3(cx, args.get(0), &arg0); + ok &= jsval_to_vector3(cx, args.get(1), &arg1); + ok &= jsval_to_cccolor3b(cx, args.get(2), &arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + ok &= JS::ToNumber( cx, args.get(4), &arg4) && !isnan(arg4); + ok &= JS::ToNumber( cx, args.get(5), &arg5) && !isnan(arg5); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpotLight_create : Error processing arguments"); + cocos2d::SpotLight* ret = cocos2d::SpotLight::create(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SpotLight*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_SpotLight_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_SpotLight_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::SpotLight* cobj = new (std::nothrow) cocos2d::SpotLight(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::SpotLight"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_BaseLight_prototype; + +void js_cocos2d_SpotLight_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (SpotLight)", obj); +} + +void js_register_cocos2dx_SpotLight(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_SpotLight_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_SpotLight_class->name = "SpotLight"; + jsb_cocos2d_SpotLight_class->addProperty = JS_PropertyStub; + jsb_cocos2d_SpotLight_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_SpotLight_class->getProperty = JS_PropertyStub; + jsb_cocos2d_SpotLight_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_SpotLight_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_SpotLight_class->resolve = JS_ResolveStub; + jsb_cocos2d_SpotLight_class->convert = JS_ConvertStub; + jsb_cocos2d_SpotLight_class->finalize = js_cocos2d_SpotLight_finalize; + jsb_cocos2d_SpotLight_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getRange", js_cocos2dx_SpotLight_getRange, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDirection", js_cocos2dx_SpotLight_setDirection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCosInnerAngle", js_cocos2dx_SpotLight_getCosInnerAngle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOuterAngle", js_cocos2dx_SpotLight_getOuterAngle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInnerAngle", js_cocos2dx_SpotLight_getInnerAngle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDirection", js_cocos2dx_SpotLight_getDirection, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCosOuterAngle", js_cocos2dx_SpotLight_getCosOuterAngle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setOuterAngle", js_cocos2dx_SpotLight_setOuterAngle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setInnerAngle", js_cocos2dx_SpotLight_setInnerAngle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDirectionInWorld", js_cocos2dx_SpotLight_getDirectionInWorld, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRange", js_cocos2dx_SpotLight_setRange, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_SpotLight_create, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_SpotLight_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_BaseLight_prototype), + jsb_cocos2d_SpotLight_class, + js_cocos2dx_SpotLight_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, "SpotLight", 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_SpotLight_class; + p->proto = jsb_cocos2d_SpotLight_prototype; + p->parentProto = jsb_cocos2d_BaseLight_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_AmbientLight_class; +JSObject *jsb_cocos2d_AmbientLight_prototype; + +bool js_cocos2dx_AmbientLight_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Color3B arg0; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AmbientLight_create : Error processing arguments"); + cocos2d::AmbientLight* ret = cocos2d::AmbientLight::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::AmbientLight*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_AmbientLight_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_AmbientLight_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::AmbientLight* cobj = new (std::nothrow) cocos2d::AmbientLight(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::AmbientLight"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_BaseLight_prototype; + +void js_cocos2d_AmbientLight_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (AmbientLight)", obj); +} + +void js_register_cocos2dx_AmbientLight(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_AmbientLight_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_AmbientLight_class->name = "AmbientLight"; + jsb_cocos2d_AmbientLight_class->addProperty = JS_PropertyStub; + jsb_cocos2d_AmbientLight_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_AmbientLight_class->getProperty = JS_PropertyStub; + jsb_cocos2d_AmbientLight_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_AmbientLight_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_AmbientLight_class->resolve = JS_ResolveStub; + jsb_cocos2d_AmbientLight_class->convert = JS_ConvertStub; + jsb_cocos2d_AmbientLight_class->finalize = js_cocos2d_AmbientLight_finalize; + jsb_cocos2d_AmbientLight_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_AmbientLight_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_AmbientLight_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_BaseLight_prototype), + jsb_cocos2d_AmbientLight_class, + js_cocos2dx_AmbientLight_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, "AmbientLight", 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_AmbientLight_class; + p->proto = jsb_cocos2d_AmbientLight_prototype; + p->parentProto = jsb_cocos2d_BaseLight_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_GLProgram_class; +JSObject *jsb_cocos2d_GLProgram_prototype; + +bool js_cocos2dx_GLProgram_getFragmentShaderLog(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getFragmentShaderLog : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getFragmentShaderLog(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgram_getFragmentShaderLog : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLProgram_bindAttribLocation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_bindAttribLocation : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + unsigned int arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_bindAttribLocation : Error processing arguments"); + cobj->bindAttribLocation(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgram_bindAttribLocation : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_GLProgram_getUniformLocationForName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getUniformLocationForName : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_getUniformLocationForName : Error processing arguments"); + int ret = cobj->getUniformLocationForName(arg0); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgram_getUniformLocationForName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_GLProgram_use(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_use : Invalid Native Object"); + if (argc == 0) { + cobj->use(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgram_use : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLProgram_getVertexShaderLog(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getVertexShaderLog : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getVertexShaderLog(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgram_getVertexShaderLog : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLProgram_getUniform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getUniform : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_getUniform : Error processing arguments"); + cocos2d::Uniform* ret = cobj->getUniform(arg0); + jsval jsret = JSVAL_NULL; + #pragma warning NO CONVERSION FROM NATIVE FOR Uniform*; + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgram_getUniform : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_GLProgram_initWithByteArrays(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::GLProgram* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgram_initWithByteArrays : Invalid Native Object"); + do { + if (argc == 3) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(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, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + if (!ok) { ok = true; break; } + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithByteArrays(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(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, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithByteArrays(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgram_initWithByteArrays : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgram_setUniformLocationWith1f(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), (int32_t *)&arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith1f : Error processing arguments"); + cobj->setUniformLocationWith1f(arg0, arg1); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::GLProgram* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgram_initWithFilenames : Invalid Native Object"); + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithFilenames(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithFilenames(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgram_initWithFilenames : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgram_setUniformLocationWith3f(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), (int32_t *)&arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith3f : Error processing arguments"); + cobj->setUniformLocationWith3f(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::GLProgram* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgram_setUniformsForBuiltins : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::Mat4 arg0; + ok &= jsval_to_matrix(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->setUniformsForBuiltins(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 0) { + cobj->setUniformsForBuiltins(); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformsForBuiltins : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgram_setUniformLocationWith3i(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setUniformLocationWith3i : Invalid Native Object"); + if (argc == 4) { + int arg0; + int arg1; + int arg2; + int arg3; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith3i : Error processing arguments"); + cobj->setUniformLocationWith3i(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWith3i : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_GLProgram_setUniformLocationWith4f(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setUniformLocationWith4f : Invalid Native Object"); + if (argc == 5) { + int arg0; + double arg1; + double arg2; + double arg3; + double arg4; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + ok &= JS::ToNumber( cx, args.get(4), &arg4) && !isnan(arg4); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith4f : Error processing arguments"); + cobj->setUniformLocationWith4f(arg0, arg1, arg2, arg3, arg4); + args.rval().setUndefined(); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_updateUniforms : Invalid Native Object"); + if (argc == 0) { + cobj->updateUniforms(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgram_updateUniforms : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLProgram_getUniformLocation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getUniformLocation : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_getUniformLocation : Error processing arguments"); + int ret = cobj->getUniformLocation(arg0); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgram_getUniformLocation : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_GLProgram_link(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_link : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->link(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgram_link : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLProgram_reset(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_reset : Invalid Native Object"); + if (argc == 0) { + cobj->reset(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgram_reset : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLProgram_getAttribLocation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getAttribLocation : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_getAttribLocation : Error processing arguments"); + int ret = cobj->getAttribLocation(arg0); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgram_getAttribLocation : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_GLProgram_getVertexAttrib(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getVertexAttrib : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_getVertexAttrib : Error processing arguments"); + cocos2d::VertexAttrib* ret = cobj->getVertexAttrib(arg0); + jsval jsret = JSVAL_NULL; + #pragma warning NO CONVERSION FROM NATIVE FOR VertexAttrib*; + args.rval().set(jsret); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), (int32_t *)&arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith2f : Error processing arguments"); + cobj->setUniformLocationWith2f(arg0, arg1, arg2); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setUniformLocationWith4i : Invalid Native Object"); + if (argc == 5) { + int arg0; + int arg1; + int arg2; + int arg3; + int arg4; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith4i : Error processing arguments"); + cobj->setUniformLocationWith4i(arg0, arg1, arg2, arg3, arg4); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWith4i : wrong number of arguments: %d, was expecting %d", argc, 5); + return false; +} +bool js_cocos2dx_GLProgram_setUniformLocationWith1i(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setUniformLocationWith1i : Invalid Native Object"); + if (argc == 2) { + int arg0; + int arg1; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith1i : Error processing arguments"); + cobj->setUniformLocationWith1i(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWith1i : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_GLProgram_setUniformLocationWith2i(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setUniformLocationWith2i : Invalid Native Object"); + if (argc == 3) { + int arg0; + int arg1; + int arg2; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith2i : Error processing arguments"); + cobj->setUniformLocationWith2i(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWith2i : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_GLProgram_createWithByteArrays(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 3) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(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, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + if (!ok) { ok = true; break; } + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cocos2d::GLProgram* ret = cocos2d::GLProgram::createWithByteArrays(arg0, arg1, arg2); + 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); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(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, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + if (!ok) { ok = true; break; } + cocos2d::GLProgram* ret = cocos2d::GLProgram::createWithByteArrays(arg0, arg1); + 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); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_GLProgram_createWithByteArrays : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgram_createWithFilenames(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cocos2d::GLProgram* ret = cocos2d::GLProgram::createWithFilenames(arg0, arg1, arg2); + 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); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::GLProgram* ret = cocos2d::GLProgram::createWithFilenames(arg0, arg1); + 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); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_GLProgram_createWithFilenames : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgram_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::GLProgram* cobj = new (std::nothrow) cocos2d::GLProgram(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::GLProgram"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_GLProgram_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (GLProgram)", obj); +} + +static bool js_cocos2d_GLProgram_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::GLProgram *nobj = new (std::nothrow) cocos2d::GLProgram(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::GLProgram"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_GLProgram(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_GLProgram_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_GLProgram_class->name = "GLProgram"; + jsb_cocos2d_GLProgram_class->addProperty = JS_PropertyStub; + jsb_cocos2d_GLProgram_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_GLProgram_class->getProperty = JS_PropertyStub; + jsb_cocos2d_GLProgram_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_GLProgram_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_GLProgram_class->resolve = JS_ResolveStub; + jsb_cocos2d_GLProgram_class->convert = JS_ConvertStub; + jsb_cocos2d_GLProgram_class->finalize = js_cocos2d_GLProgram_finalize; + jsb_cocos2d_GLProgram_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getFragmentShaderLog", js_cocos2dx_GLProgram_getFragmentShaderLog, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addAttribute", js_cocos2dx_GLProgram_bindAttribLocation, 2, 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("setUniformLocationWith4f", js_cocos2dx_GLProgram_setUniformLocationWith4f, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateUniforms", js_cocos2dx_GLProgram_updateUniforms, 0, 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("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), + JS_FN("ctor", js_cocos2d_GLProgram_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("createWithByteArrays", js_cocos2dx_GLProgram_createWithByteArrays, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithFilenames", js_cocos2dx_GLProgram_createWithFilenames, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_GLProgram_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_GLProgram_class, + js_cocos2dx_GLProgram_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, "GLProgram", 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_GLProgram_class; + p->proto = jsb_cocos2d_GLProgram_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_GLProgramCache_class; +JSObject *jsb_cocos2d_GLProgramCache_prototype; + +bool js_cocos2dx_GLProgramCache_reloadDefaultGLPrograms(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLProgramCache* cobj = (cocos2d::GLProgramCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramCache_reloadDefaultGLPrograms : Invalid Native Object"); + if (argc == 0) { + cobj->reloadDefaultGLPrograms(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgramCache_reloadDefaultGLPrograms : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLProgramCache_addGLProgram(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLProgramCache* cobj = (cocos2d::GLProgramCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramCache_addGLProgram : Invalid Native Object"); + if (argc == 2) { + cocos2d::GLProgram* arg0; + std::string arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::GLProgram*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgramCache_addGLProgram : Error processing arguments"); + cobj->addGLProgram(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgramCache_addGLProgram : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_GLProgramCache_getGLProgram(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLProgramCache* cobj = (cocos2d::GLProgramCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramCache_getGLProgram : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgramCache_getGLProgram : Error processing arguments"); + cocos2d::GLProgram* ret = cobj->getGLProgram(arg0); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgramCache_getGLProgram : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_GLProgramCache_loadDefaultGLPrograms(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLProgramCache* cobj = (cocos2d::GLProgramCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramCache_loadDefaultGLPrograms : Invalid Native Object"); + if (argc == 0) { + cobj->loadDefaultGLPrograms(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgramCache_loadDefaultGLPrograms : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLProgramCache_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::GLProgramCache::destroyInstance(); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_GLProgramCache_destroyInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_GLProgramCache_getInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::GLProgramCache* ret = cocos2d::GLProgramCache::getInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::GLProgramCache*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_GLProgramCache_getInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_GLProgramCache_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::GLProgramCache* cobj = new (std::nothrow) cocos2d::GLProgramCache(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::GLProgramCache"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_GLProgramCache_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (GLProgramCache)", obj); +} + +void js_register_cocos2dx_GLProgramCache(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_GLProgramCache_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_GLProgramCache_class->name = "ShaderCache"; + jsb_cocos2d_GLProgramCache_class->addProperty = JS_PropertyStub; + jsb_cocos2d_GLProgramCache_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_GLProgramCache_class->getProperty = JS_PropertyStub; + jsb_cocos2d_GLProgramCache_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_GLProgramCache_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_GLProgramCache_class->resolve = JS_ResolveStub; + jsb_cocos2d_GLProgramCache_class->convert = JS_ConvertStub; + jsb_cocos2d_GLProgramCache_class->finalize = js_cocos2d_GLProgramCache_finalize; + jsb_cocos2d_GLProgramCache_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("reloadDefaultShaders", js_cocos2dx_GLProgramCache_reloadDefaultGLPrograms, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addProgram", js_cocos2dx_GLProgramCache_addGLProgram, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getProgram", js_cocos2dx_GLProgramCache_getGLProgram, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadDefaultShaders", js_cocos2dx_GLProgramCache_loadDefaultGLPrograms, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("destroyInstance", js_cocos2dx_GLProgramCache_destroyInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInstance", js_cocos2dx_GLProgramCache_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_GLProgramCache_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_GLProgramCache_class, + js_cocos2dx_GLProgramCache_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, "ShaderCache", 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_GLProgramCache_class; + p->proto = jsb_cocos2d_GLProgramCache_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TextureCache_class; +JSObject *jsb_cocos2d_TextureCache_prototype; + +bool js_cocos2dx_TextureCache_reloadTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextureCache_reloadTexture : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TextureCache_reloadTexture : Error processing arguments"); + bool ret = cobj->reloadTexture(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextureCache_reloadTexture : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TextureCache_unbindAllImageAsync(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextureCache_unbindAllImageAsync : Invalid Native Object"); + if (argc == 0) { + cobj->unbindAllImageAsync(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextureCache_unbindAllImageAsync : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TextureCache_removeTextureForKey(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextureCache_removeTextureForKey : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TextureCache_removeTextureForKey : Error processing arguments"); + cobj->removeTextureForKey(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextureCache_removeTextureForKey : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TextureCache_removeAllTextures(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextureCache_removeAllTextures : Invalid Native Object"); + if (argc == 0) { + cobj->removeAllTextures(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextureCache_removeAllTextures : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TextureCache_addImageAsync(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextureCache_addImageAsync : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + std::function arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + do { + if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + auto lambda = [=](cocos2d::Texture2D* larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + JS::RootedValue rval(cx); + 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"); + cobj->addImageAsync(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextureCache_addImageAsync : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_TextureCache_getDescription(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextureCache_getDescription : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getDescription(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextureCache_getDescription : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TextureCache_getCachedTextureInfo(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextureCache_getCachedTextureInfo : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getCachedTextureInfo(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextureCache_getCachedTextureInfo : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TextureCache_addImage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::TextureCache* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextureCache_addImage : Invalid Native Object"); + do { + if (argc == 2) { + cocos2d::Image* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Image*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::Texture2D* ret = cobj->addImage(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Texture2D* ret = cobj->addImage(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_TextureCache_addImage : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TextureCache_unbindImageAsync(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextureCache_unbindImageAsync : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TextureCache_unbindImageAsync : Error processing arguments"); + cobj->unbindImageAsync(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextureCache_unbindImageAsync : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TextureCache_getTextureForKey(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextureCache_getTextureForKey : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TextureCache_getTextureForKey : Error processing arguments"); + cocos2d::Texture2D* ret = cobj->getTextureForKey(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextureCache_getTextureForKey : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TextureCache_removeUnusedTextures(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextureCache_removeUnusedTextures : Invalid Native Object"); + if (argc == 0) { + cobj->removeUnusedTextures(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextureCache_removeUnusedTextures : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TextureCache_removeTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextureCache_removeTexture : Invalid Native Object"); + if (argc == 1) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TextureCache_removeTexture : Error processing arguments"); + cobj->removeTexture(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextureCache_removeTexture : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TextureCache_waitForQuit(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextureCache_waitForQuit : Invalid Native Object"); + if (argc == 0) { + cobj->waitForQuit(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextureCache_waitForQuit : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TextureCache_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TextureCache* cobj = new (std::nothrow) cocos2d::TextureCache(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TextureCache"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_TextureCache_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TextureCache)", obj); +} + +void js_register_cocos2dx_TextureCache(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TextureCache_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TextureCache_class->name = "TextureCache"; + jsb_cocos2d_TextureCache_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TextureCache_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TextureCache_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TextureCache_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TextureCache_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TextureCache_class->resolve = JS_ResolveStub; + jsb_cocos2d_TextureCache_class->convert = JS_ConvertStub; + jsb_cocos2d_TextureCache_class->finalize = js_cocos2d_TextureCache_finalize; + jsb_cocos2d_TextureCache_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("reloadTexture", js_cocos2dx_TextureCache_reloadTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("unbindAllImageAsync", js_cocos2dx_TextureCache_unbindAllImageAsync, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeTextureForKey", js_cocos2dx_TextureCache_removeTextureForKey, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllTextures", js_cocos2dx_TextureCache_removeAllTextures, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addImageAsync", js_cocos2dx_TextureCache_addImageAsync, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDescription", js_cocos2dx_TextureCache_getDescription, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCachedTextureInfo", js_cocos2dx_TextureCache_getCachedTextureInfo, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addImage", js_cocos2dx_TextureCache_addImage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("unbindImageAsync", js_cocos2dx_TextureCache_unbindImageAsync, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTextureForKey", js_cocos2dx_TextureCache_getTextureForKey, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeUnusedTextures", js_cocos2dx_TextureCache_removeUnusedTextures, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeTexture", js_cocos2dx_TextureCache_removeTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("waitForQuit", js_cocos2dx_TextureCache_waitForQuit, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_TextureCache_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_TextureCache_class, + js_cocos2dx_TextureCache_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, "TextureCache", 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_TextureCache_class; + p->proto = jsb_cocos2d_TextureCache_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Device_class; +JSObject *jsb_cocos2d_Device_prototype; + +bool js_cocos2dx_Device_setAccelerometerEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Device_setAccelerometerEnabled : Error processing arguments"); + cocos2d::Device::setAccelerometerEnabled(arg0); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Device_setAccelerometerEnabled : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Device_setKeepScreenOn(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Device_setKeepScreenOn : Error processing arguments"); + cocos2d::Device::setKeepScreenOn(arg0); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Device_setKeepScreenOn : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Device_setAccelerometerInterval(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Device_setAccelerometerInterval : Error processing arguments"); + cocos2d::Device::setAccelerometerInterval(arg0); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Device_setAccelerometerInterval : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Device_getDPI(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + int ret = cocos2d::Device::getDPI(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Device_getDPI : wrong number of arguments"); + return false; +} + + + +void js_cocos2d_Device_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Device)", obj); +} + +void js_register_cocos2dx_Device(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Device_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Device_class->name = "Device"; + jsb_cocos2d_Device_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Device_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Device_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Device_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Device_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Device_class->resolve = JS_ResolveStub; + jsb_cocos2d_Device_class->convert = JS_ConvertStub; + jsb_cocos2d_Device_class->finalize = js_cocos2d_Device_finalize; + jsb_cocos2d_Device_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("setAccelerometerEnabled", js_cocos2dx_Device_setAccelerometerEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setKeepScreenOn", js_cocos2dx_Device_setKeepScreenOn, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAccelerometerInterval", js_cocos2dx_Device_setAccelerometerInterval, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDPI", js_cocos2dx_Device_getDPI, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Device_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_Device_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, "Device", 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_Device_class; + p->proto = jsb_cocos2d_Device_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_SAXParser_class; +JSObject *jsb_cocos2d_SAXParser_prototype; + +bool js_cocos2dx_SAXParser_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SAXParser* cobj = (cocos2d::SAXParser *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SAXParser_init : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SAXParser_init : Error processing arguments"); + bool ret = cobj->init(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SAXParser_init : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + + +void js_cocos2d_SAXParser_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (SAXParser)", obj); +} + +void js_register_cocos2dx_SAXParser(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_SAXParser_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_SAXParser_class->name = "PlistParser"; + jsb_cocos2d_SAXParser_class->addProperty = JS_PropertyStub; + jsb_cocos2d_SAXParser_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_SAXParser_class->getProperty = JS_PropertyStub; + jsb_cocos2d_SAXParser_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_SAXParser_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_SAXParser_class->resolve = JS_ResolveStub; + jsb_cocos2d_SAXParser_class->convert = JS_ConvertStub; + jsb_cocos2d_SAXParser_class->finalize = js_cocos2d_SAXParser_finalize; + jsb_cocos2d_SAXParser_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_SAXParser_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_SAXParser_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_SAXParser_class, + empty_constructor, 0, + 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, "PlistParser", 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_SAXParser_class; + p->proto = jsb_cocos2d_SAXParser_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Application_class; +JSObject *jsb_cocos2d_Application_prototype; + +bool js_cocos2dx_Application_openURL(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Application* cobj = (cocos2d::Application *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Application_openURL : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Application_openURL : Error processing arguments"); + bool ret = cobj->openURL(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Application_openURL : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Application_getTargetPlatform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Application* cobj = (cocos2d::Application *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Application_getTargetPlatform : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getTargetPlatform(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Application_getTargetPlatform : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Application_getCurrentLanguage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Application* cobj = (cocos2d::Application *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Application_getCurrentLanguage : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getCurrentLanguage(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Application_getCurrentLanguage : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Application_getInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Application* ret = cocos2d::Application::getInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Application*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Application_getInstance : wrong number of arguments"); + return false; +} + + + +void js_cocos2d_Application_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Application)", obj); +} + +void js_register_cocos2dx_Application(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Application_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Application_class->name = "Application"; + jsb_cocos2d_Application_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Application_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Application_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Application_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Application_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Application_class->resolve = JS_ResolveStub; + jsb_cocos2d_Application_class->convert = JS_ConvertStub; + jsb_cocos2d_Application_class->finalize = js_cocos2d_Application_finalize; + jsb_cocos2d_Application_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("openURL", js_cocos2dx_Application_openURL, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTargetPlatform", js_cocos2dx_Application_getTargetPlatform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCurrentLanguage", js_cocos2dx_Application_getCurrentLanguage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("getInstance", js_cocos2dx_Application_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Application_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_Application_class, + empty_constructor, 0, + 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, "Application", 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_Application_class; + p->proto = jsb_cocos2d_Application_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_AnimationCache_class; +JSObject *jsb_cocos2d_AnimationCache_prototype; + +bool js_cocos2dx_AnimationCache_getAnimation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AnimationCache* cobj = (cocos2d::AnimationCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AnimationCache_getAnimation : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AnimationCache_getAnimation : Error processing arguments"); + cocos2d::Animation* ret = cobj->getAnimation(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Animation*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AnimationCache_getAnimation : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_AnimationCache_addAnimation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AnimationCache* cobj = (cocos2d::AnimationCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AnimationCache_addAnimation : Invalid Native Object"); + if (argc == 2) { + cocos2d::Animation* arg0; + std::string arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Animation*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AnimationCache_addAnimation : Error processing arguments"); + cobj->addAnimation(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AnimationCache_addAnimation : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_AnimationCache_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AnimationCache* cobj = (cocos2d::AnimationCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AnimationCache_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AnimationCache_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_AnimationCache_addAnimationsWithDictionary(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AnimationCache* cobj = (cocos2d::AnimationCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AnimationCache_addAnimationsWithDictionary : Invalid Native Object"); + if (argc == 2) { + cocos2d::ValueMap arg0; + std::string arg1; + ok &= jsval_to_ccvaluemap(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AnimationCache_addAnimationsWithDictionary : Error processing arguments"); + cobj->addAnimationsWithDictionary(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AnimationCache_addAnimationsWithDictionary : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_AnimationCache_removeAnimation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AnimationCache* cobj = (cocos2d::AnimationCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AnimationCache_removeAnimation : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AnimationCache_removeAnimation : Error processing arguments"); + cobj->removeAnimation(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AnimationCache_removeAnimation : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_AnimationCache_addAnimationsWithFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::AnimationCache* cobj = (cocos2d::AnimationCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_AnimationCache_addAnimationsWithFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AnimationCache_addAnimationsWithFile : Error processing arguments"); + cobj->addAnimationsWithFile(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_AnimationCache_addAnimationsWithFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_AnimationCache_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::AnimationCache::destroyInstance(); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_AnimationCache_destroyInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_AnimationCache_getInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::AnimationCache* ret = cocos2d::AnimationCache::getInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::AnimationCache*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_AnimationCache_getInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_AnimationCache_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::AnimationCache* cobj = new (std::nothrow) cocos2d::AnimationCache(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::AnimationCache"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_AnimationCache_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (AnimationCache)", obj); +} + +void js_register_cocos2dx_AnimationCache(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_AnimationCache_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_AnimationCache_class->name = "AnimationCache"; + jsb_cocos2d_AnimationCache_class->addProperty = JS_PropertyStub; + jsb_cocos2d_AnimationCache_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_AnimationCache_class->getProperty = JS_PropertyStub; + jsb_cocos2d_AnimationCache_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_AnimationCache_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_AnimationCache_class->resolve = JS_ResolveStub; + jsb_cocos2d_AnimationCache_class->convert = JS_ConvertStub; + jsb_cocos2d_AnimationCache_class->finalize = js_cocos2d_AnimationCache_finalize; + jsb_cocos2d_AnimationCache_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getAnimation", js_cocos2dx_AnimationCache_getAnimation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addAnimation", js_cocos2dx_AnimationCache_addAnimation, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_AnimationCache_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addAnimationsWithDictionary", js_cocos2dx_AnimationCache_addAnimationsWithDictionary, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAnimation", js_cocos2dx_AnimationCache_removeAnimation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addAnimations", js_cocos2dx_AnimationCache_addAnimationsWithFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("destroyInstance", js_cocos2dx_AnimationCache_destroyInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInstance", js_cocos2dx_AnimationCache_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_AnimationCache_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_AnimationCache_class, + js_cocos2dx_AnimationCache_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, "AnimationCache", 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_AnimationCache_class; + p->proto = jsb_cocos2d_AnimationCache_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_SpriteFrameCache_class; +JSObject *jsb_cocos2d_SpriteFrameCache_prototype; + +bool js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFileContent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrameCache* cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFileContent : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + cocos2d::Texture2D* arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFileContent : Error processing arguments"); + cobj->addSpriteFramesWithFileContent(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFileContent : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_SpriteFrameCache_addSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrameCache* cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrameCache_addSpriteFrame : Invalid Native Object"); + if (argc == 2) { + cocos2d::SpriteFrame* arg0; + std::string arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteFrameCache_addSpriteFrame : Error processing arguments"); + cobj->addSpriteFrame(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_addSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::SpriteFrameCache* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile : Invalid Native Object"); + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cobj->addSpriteFramesWithFile(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->addSpriteFramesWithFile(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Texture2D* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + 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->addSpriteFramesWithFile(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile : wrong number of arguments"); + return false; +} +bool js_cocos2dx_SpriteFrameCache_getSpriteFrameByName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrameCache* cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrameCache_getSpriteFrameByName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteFrameCache_getSpriteFrameByName : Error processing arguments"); + cocos2d::SpriteFrame* ret = cobj->getSpriteFrameByName(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SpriteFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_getSpriteFrameByName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrameCache* cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFile : Error processing arguments"); + cobj->removeSpriteFramesFromFile(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteFrameCache_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrameCache* cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrameCache_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpriteFrameCache_removeSpriteFrames(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrameCache* cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrameCache_removeSpriteFrames : Invalid Native Object"); + if (argc == 0) { + cobj->removeSpriteFrames(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_removeSpriteFrames : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpriteFrameCache_removeUnusedSpriteFrames(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrameCache* cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrameCache_removeUnusedSpriteFrames : Invalid Native Object"); + if (argc == 0) { + cobj->removeUnusedSpriteFrames(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_removeUnusedSpriteFrames : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFileContent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrameCache* cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFileContent : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFileContent : Error processing arguments"); + cobj->removeSpriteFramesFromFileContent(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFileContent : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteFrameCache_removeSpriteFrameByName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrameCache* cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrameCache_removeSpriteFrameByName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteFrameCache_removeSpriteFrameByName : Error processing arguments"); + cobj->removeSpriteFrameByName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_removeSpriteFrameByName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteFrameCache_isSpriteFramesWithFileLoaded(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrameCache* cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrameCache_isSpriteFramesWithFileLoaded : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteFrameCache_isSpriteFramesWithFileLoaded : Error processing arguments"); + bool ret = cobj->isSpriteFramesWithFileLoaded(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_isSpriteFramesWithFileLoaded : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteFrameCache* cobj = (cocos2d::SpriteFrameCache *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromTexture : Invalid Native Object"); + if (argc == 1) { + cocos2d::Texture2D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromTexture : Error processing arguments"); + cobj->removeSpriteFramesFromTexture(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromTexture : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SpriteFrameCache_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::SpriteFrameCache::destroyInstance(); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_destroyInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_SpriteFrameCache_getInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::SpriteFrameCache* ret = cocos2d::SpriteFrameCache::getInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SpriteFrameCache*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_SpriteFrameCache_getInstance : wrong number of arguments"); + return false; +} + + + +void js_cocos2d_SpriteFrameCache_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (SpriteFrameCache)", obj); +} + +void js_register_cocos2dx_SpriteFrameCache(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_SpriteFrameCache_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_SpriteFrameCache_class->name = "SpriteFrameCache"; + jsb_cocos2d_SpriteFrameCache_class->addProperty = JS_PropertyStub; + jsb_cocos2d_SpriteFrameCache_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_SpriteFrameCache_class->getProperty = JS_PropertyStub; + jsb_cocos2d_SpriteFrameCache_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_SpriteFrameCache_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_SpriteFrameCache_class->resolve = JS_ResolveStub; + jsb_cocos2d_SpriteFrameCache_class->convert = JS_ConvertStub; + jsb_cocos2d_SpriteFrameCache_class->finalize = js_cocos2d_SpriteFrameCache_finalize; + jsb_cocos2d_SpriteFrameCache_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("addSpriteFramesWithFileContent", js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFileContent, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addSpriteFrame", js_cocos2dx_SpriteFrameCache_addSpriteFrame, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addSpriteFrames", js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSpriteFrame", js_cocos2dx_SpriteFrameCache_getSpriteFrameByName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeSpriteFramesFromFile", js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_SpriteFrameCache_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeSpriteFrames", js_cocos2dx_SpriteFrameCache_removeSpriteFrames, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeUnusedSpriteFrames", js_cocos2dx_SpriteFrameCache_removeUnusedSpriteFrames, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeSpriteFramesFromFileContent", js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFileContent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeSpriteFrameByName", js_cocos2dx_SpriteFrameCache_removeSpriteFrameByName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isSpriteFramesWithFileLoaded", js_cocos2dx_SpriteFrameCache_isSpriteFramesWithFileLoaded, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeSpriteFramesFromTexture", js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("destroyInstance", js_cocos2dx_SpriteFrameCache_destroyInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInstance", js_cocos2dx_SpriteFrameCache_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_SpriteFrameCache_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_SpriteFrameCache_class, + empty_constructor, 0, + 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, "SpriteFrameCache", 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_SpriteFrameCache_class; + p->proto = jsb_cocos2d_SpriteFrameCache_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TextFieldTTF_class; +JSObject *jsb_cocos2d_TextFieldTTF_prototype; + +bool js_cocos2dx_TextFieldTTF_getCharCount(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextFieldTTF* cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextFieldTTF_getCharCount : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getCharCount(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_getCharCount : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TextFieldTTF_setSecureTextEntry(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextFieldTTF* cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextFieldTTF_setSecureTextEntry : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TextFieldTTF_setSecureTextEntry : Error processing arguments"); + cobj->setSecureTextEntry(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_setSecureTextEntry : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TextFieldTTF_getColorSpaceHolder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextFieldTTF* cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextFieldTTF_getColorSpaceHolder : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color4B& ret = cobj->getColorSpaceHolder(); + jsval jsret = JSVAL_NULL; + jsret = cccolor4b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_getColorSpaceHolder : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TextFieldTTF_initWithPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::TextFieldTTF* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextFieldTTF_initWithPlaceHolder : Invalid Native Object"); + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithPlaceHolder(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 5) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Size arg1; + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::TextHAlignment arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + std::string arg3; + ok &= jsval_to_std_string(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + double arg4; + ok &= JS::ToNumber( cx, args.get(4), &arg4) && !isnan(arg4); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithPlaceHolder(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_initWithPlaceHolder : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TextFieldTTF_setColorSpaceHolder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::TextFieldTTF* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextFieldTTF_setColorSpaceHolder : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->setColorSpaceHolder(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::Color3B arg0; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->setColorSpaceHolder(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_setColorSpaceHolder : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TextFieldTTF_detachWithIME(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextFieldTTF* cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextFieldTTF_detachWithIME : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->detachWithIME(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_detachWithIME : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TextFieldTTF_setPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextFieldTTF* cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextFieldTTF_setPlaceHolder : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TextFieldTTF_setPlaceHolder : Error processing arguments"); + cobj->setPlaceHolder(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_setPlaceHolder : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TextFieldTTF_isSecureTextEntry(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextFieldTTF* cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextFieldTTF_isSecureTextEntry : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isSecureTextEntry(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_isSecureTextEntry : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TextFieldTTF_getPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextFieldTTF* cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextFieldTTF_getPlaceHolder : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getPlaceHolder(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_getPlaceHolder : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TextFieldTTF_attachWithIME(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TextFieldTTF* cobj = (cocos2d::TextFieldTTF *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextFieldTTF_attachWithIME : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->attachWithIME(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_attachWithIME : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TextFieldTTF_textFieldWithPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::TextFieldTTF* ret = cocos2d::TextFieldTTF::textFieldWithPlaceHolder(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TextFieldTTF*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 5) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Size arg1; + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::TextHAlignment arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + std::string arg3; + ok &= jsval_to_std_string(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + double arg4; + ok &= JS::ToNumber( cx, args.get(4), &arg4) && !isnan(arg4); + if (!ok) { ok = true; break; } + cocos2d::TextFieldTTF* ret = cocos2d::TextFieldTTF::textFieldWithPlaceHolder(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TextFieldTTF*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_TextFieldTTF_textFieldWithPlaceHolder : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TextFieldTTF_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TextFieldTTF* cobj = new (std::nothrow) cocos2d::TextFieldTTF(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TextFieldTTF"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Label_prototype; + +void js_cocos2d_TextFieldTTF_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TextFieldTTF)", obj); +} + +static bool js_cocos2d_TextFieldTTF_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TextFieldTTF *nobj = new (std::nothrow) cocos2d::TextFieldTTF(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TextFieldTTF"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_TextFieldTTF(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TextFieldTTF_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TextFieldTTF_class->name = "TextFieldTTF"; + jsb_cocos2d_TextFieldTTF_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TextFieldTTF_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TextFieldTTF_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TextFieldTTF_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TextFieldTTF_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TextFieldTTF_class->resolve = JS_ResolveStub; + jsb_cocos2d_TextFieldTTF_class->convert = JS_ConvertStub; + jsb_cocos2d_TextFieldTTF_class->finalize = js_cocos2d_TextFieldTTF_finalize; + jsb_cocos2d_TextFieldTTF_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getCharCount", js_cocos2dx_TextFieldTTF_getCharCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSecureTextEntry", js_cocos2dx_TextFieldTTF_setSecureTextEntry, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getColorSpaceHolder", js_cocos2dx_TextFieldTTF_getColorSpaceHolder, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithPlaceHolder", js_cocos2dx_TextFieldTTF_initWithPlaceHolder, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setColorSpaceHolder", js_cocos2dx_TextFieldTTF_setColorSpaceHolder, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("detachWithIME", js_cocos2dx_TextFieldTTF_detachWithIME, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPlaceHolder", js_cocos2dx_TextFieldTTF_setPlaceHolder, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isSecureTextEntry", js_cocos2dx_TextFieldTTF_isSecureTextEntry, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPlaceHolder", js_cocos2dx_TextFieldTTF_getPlaceHolder, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("attachWithIME", js_cocos2dx_TextFieldTTF_attachWithIME, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_TextFieldTTF_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TextFieldTTF_textFieldWithPlaceHolder, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TextFieldTTF_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Label_prototype), + jsb_cocos2d_TextFieldTTF_class, + js_cocos2dx_TextFieldTTF_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, "TextFieldTTF", 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_TextFieldTTF_class; + p->proto = jsb_cocos2d_TextFieldTTF_prototype; + p->parentProto = jsb_cocos2d_Label_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ParallaxNode_class; +JSObject *jsb_cocos2d_ParallaxNode_prototype; + +bool js_cocos2dx_ParallaxNode_getParallaxArray(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ParallaxNode* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ParallaxNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParallaxNode_getParallaxArray : Invalid Native Object"); + do { + if (argc == 0) { + const cocos2d::_ccArray* ret = cobj->getParallaxArray(); + jsval jsret = JSVAL_NULL; + #pragma warning NO CONVERSION FROM NATIVE FOR _ccArray*; + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + cocos2d::_ccArray* ret = cobj->getParallaxArray(); + jsval jsret = JSVAL_NULL; + #pragma warning NO CONVERSION FROM NATIVE FOR _ccArray*; + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ParallaxNode_getParallaxArray : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ParallaxNode_addChild(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParallaxNode* cobj = (cocos2d::ParallaxNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParallaxNode_addChild : Invalid Native Object"); + if (argc == 4) { + cocos2d::Node* arg0; + int arg1; + cocos2d::Vec2 arg2; + cocos2d::Vec2 arg3; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + ok &= jsval_to_vector2(cx, args.get(2), &arg2); + ok &= jsval_to_vector2(cx, args.get(3), &arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParallaxNode_addChild : Error processing arguments"); + cobj->addChild(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParallaxNode_addChild : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_ParallaxNode_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParallaxNode* cobj = (cocos2d::ParallaxNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParallaxNode_removeAllChildrenWithCleanup : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParallaxNode_removeAllChildrenWithCleanup : Error processing arguments"); + cobj->removeAllChildrenWithCleanup(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParallaxNode_removeAllChildrenWithCleanup : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParallaxNode_setParallaxArray(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParallaxNode* cobj = (cocos2d::ParallaxNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ParallaxNode_setParallaxArray : Invalid Native Object"); + if (argc == 1) { + cocos2d::_ccArray* arg0; + #pragma warning NO CONVERSION TO NATIVE FOR _ccArray* + ok = false; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ParallaxNode_setParallaxArray : Error processing arguments"); + cobj->setParallaxArray(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ParallaxNode_setParallaxArray : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ParallaxNode_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ParallaxNode* ret = cocos2d::ParallaxNode::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ParallaxNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ParallaxNode_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ParallaxNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ParallaxNode* cobj = new (std::nothrow) cocos2d::ParallaxNode(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ParallaxNode"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_ParallaxNode_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ParallaxNode)", obj); +} + +static bool js_cocos2d_ParallaxNode_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ParallaxNode *nobj = new (std::nothrow) cocos2d::ParallaxNode(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ParallaxNode"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ParallaxNode(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ParallaxNode_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ParallaxNode_class->name = "ParallaxNode"; + jsb_cocos2d_ParallaxNode_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ParallaxNode_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ParallaxNode_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ParallaxNode_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ParallaxNode_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ParallaxNode_class->resolve = JS_ResolveStub; + jsb_cocos2d_ParallaxNode_class->convert = JS_ConvertStub; + jsb_cocos2d_ParallaxNode_class->finalize = js_cocos2d_ParallaxNode_finalize; + jsb_cocos2d_ParallaxNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getParallaxArray", js_cocos2dx_ParallaxNode_getParallaxArray, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addChild", js_cocos2dx_ParallaxNode_addChild, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllChildrenWithCleanup", js_cocos2dx_ParallaxNode_removeAllChildrenWithCleanup, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setParallaxArray", js_cocos2dx_ParallaxNode_setParallaxArray, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ParallaxNode_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ParallaxNode_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ParallaxNode_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_ParallaxNode_class, + js_cocos2dx_ParallaxNode_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, "ParallaxNode", 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_ParallaxNode_class; + p->proto = jsb_cocos2d_ParallaxNode_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TMXObjectGroup_class; +JSObject *jsb_cocos2d_TMXObjectGroup_prototype; + +bool js_cocos2dx_TMXObjectGroup_setPositionOffset(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXObjectGroup* cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXObjectGroup_setPositionOffset : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXObjectGroup_setPositionOffset : Error processing arguments"); + cobj->setPositionOffset(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_setPositionOffset : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXObjectGroup_getProperty(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXObjectGroup* cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXObjectGroup_getProperty : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXObjectGroup_getProperty : Error processing arguments"); + cocos2d::Value ret = cobj->getProperty(arg0); + jsval jsret = JSVAL_NULL; + jsret = ccvalue_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_getProperty : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXObjectGroup_getPositionOffset(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXObjectGroup* cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXObjectGroup_getPositionOffset : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getPositionOffset(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_getPositionOffset : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXObjectGroup_getObject(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXObjectGroup* cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXObjectGroup_getObject : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXObjectGroup_getObject : Error processing arguments"); + cocos2d::ValueMap ret = cobj->getObject(arg0); + jsval jsret = JSVAL_NULL; + jsret = ccvaluemap_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_getObject : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXObjectGroup_getObjects(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::TMXObjectGroup* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXObjectGroup_getObjects : Invalid Native Object"); + do { + if (argc == 0) { + cocos2d::ValueVector& ret = cobj->getObjects(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluevector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + const cocos2d::ValueVector& ret = cobj->getObjects(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluevector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_getObjects : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TMXObjectGroup_setGroupName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXObjectGroup* cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXObjectGroup_setGroupName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXObjectGroup_setGroupName : Error processing arguments"); + cobj->setGroupName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_setGroupName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXObjectGroup_getProperties(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::TMXObjectGroup* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXObjectGroup_getProperties : Invalid Native Object"); + do { + if (argc == 0) { + cocos2d::ValueMap& ret = cobj->getProperties(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluemap_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + const cocos2d::ValueMap& ret = cobj->getProperties(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluemap_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_getProperties : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TMXObjectGroup_getGroupName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXObjectGroup* cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXObjectGroup_getGroupName : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getGroupName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_getGroupName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXObjectGroup_setProperties(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXObjectGroup* cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXObjectGroup_setProperties : Invalid Native Object"); + if (argc == 1) { + cocos2d::ValueMap arg0; + ok &= jsval_to_ccvaluemap(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXObjectGroup_setProperties : Error processing arguments"); + cobj->setProperties(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_setProperties : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXObjectGroup_setObjects(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXObjectGroup* cobj = (cocos2d::TMXObjectGroup *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXObjectGroup_setObjects : Invalid Native Object"); + if (argc == 1) { + cocos2d::ValueVector arg0; + ok &= jsval_to_ccvaluevector(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXObjectGroup_setObjects : Error processing arguments"); + cobj->setObjects(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXObjectGroup_setObjects : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXObjectGroup_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TMXObjectGroup* cobj = new (std::nothrow) cocos2d::TMXObjectGroup(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TMXObjectGroup"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_TMXObjectGroup_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TMXObjectGroup)", obj); +} + +void js_register_cocos2dx_TMXObjectGroup(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TMXObjectGroup_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TMXObjectGroup_class->name = "TMXObjectGroup"; + jsb_cocos2d_TMXObjectGroup_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TMXObjectGroup_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TMXObjectGroup_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TMXObjectGroup_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TMXObjectGroup_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TMXObjectGroup_class->resolve = JS_ResolveStub; + jsb_cocos2d_TMXObjectGroup_class->convert = JS_ConvertStub; + jsb_cocos2d_TMXObjectGroup_class->finalize = js_cocos2d_TMXObjectGroup_finalize; + jsb_cocos2d_TMXObjectGroup_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setPositionOffset", js_cocos2dx_TMXObjectGroup_setPositionOffset, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getProperty", js_cocos2dx_TMXObjectGroup_getProperty, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPositionOffset", js_cocos2dx_TMXObjectGroup_getPositionOffset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getObject", js_cocos2dx_TMXObjectGroup_getObject, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getObjects", js_cocos2dx_TMXObjectGroup_getObjects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setGroupName", js_cocos2dx_TMXObjectGroup_setGroupName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getProperties", js_cocos2dx_TMXObjectGroup_getProperties, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getGroupName", js_cocos2dx_TMXObjectGroup_getGroupName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setProperties", js_cocos2dx_TMXObjectGroup_setProperties, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setObjects", js_cocos2dx_TMXObjectGroup_setObjects, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_TMXObjectGroup_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_TMXObjectGroup_class, + js_cocos2dx_TMXObjectGroup_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, "TMXObjectGroup", 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_TMXObjectGroup_class; + p->proto = jsb_cocos2d_TMXObjectGroup_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TMXLayerInfo_class; +JSObject *jsb_cocos2d_TMXLayerInfo_prototype; + +bool js_cocos2dx_TMXLayerInfo_setProperties(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayerInfo* cobj = (cocos2d::TMXLayerInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayerInfo_setProperties : Invalid Native Object"); + if (argc == 1) { + cocos2d::ValueMap arg0; + ok &= jsval_to_ccvaluemap(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXLayerInfo_setProperties : Error processing arguments"); + cobj->setProperties(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayerInfo_setProperties : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXLayerInfo_getProperties(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayerInfo* cobj = (cocos2d::TMXLayerInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayerInfo_getProperties : Invalid Native Object"); + if (argc == 0) { + cocos2d::ValueMap& ret = cobj->getProperties(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluemap_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayerInfo_getProperties : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXLayerInfo_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TMXLayerInfo* cobj = new (std::nothrow) cocos2d::TMXLayerInfo(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TMXLayerInfo"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_TMXLayerInfo_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TMXLayerInfo)", obj); +} + +void js_register_cocos2dx_TMXLayerInfo(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TMXLayerInfo_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TMXLayerInfo_class->name = "TMXLayerInfo"; + jsb_cocos2d_TMXLayerInfo_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TMXLayerInfo_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TMXLayerInfo_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TMXLayerInfo_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TMXLayerInfo_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TMXLayerInfo_class->resolve = JS_ResolveStub; + jsb_cocos2d_TMXLayerInfo_class->convert = JS_ConvertStub; + jsb_cocos2d_TMXLayerInfo_class->finalize = js_cocos2d_TMXLayerInfo_finalize; + jsb_cocos2d_TMXLayerInfo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setProperties", js_cocos2dx_TMXLayerInfo_setProperties, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getProperties", js_cocos2dx_TMXLayerInfo_getProperties, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_TMXLayerInfo_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_TMXLayerInfo_class, + js_cocos2dx_TMXLayerInfo_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, "TMXLayerInfo", 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_TMXLayerInfo_class; + p->proto = jsb_cocos2d_TMXLayerInfo_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TMXTilesetInfo_class; +JSObject *jsb_cocos2d_TMXTilesetInfo_prototype; + +bool js_cocos2dx_TMXTilesetInfo_getRectForGID(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXTilesetInfo* cobj = (cocos2d::TMXTilesetInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTilesetInfo_getRectForGID : Invalid Native Object"); + if (argc == 1) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXTilesetInfo_getRectForGID : Error processing arguments"); + cocos2d::Rect ret = cobj->getRectForGID(arg0); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXTilesetInfo_getRectForGID : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXTilesetInfo_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TMXTilesetInfo* cobj = new (std::nothrow) cocos2d::TMXTilesetInfo(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TMXTilesetInfo"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_TMXTilesetInfo_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TMXTilesetInfo)", obj); +} + +void js_register_cocos2dx_TMXTilesetInfo(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TMXTilesetInfo_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TMXTilesetInfo_class->name = "TMXTilesetInfo"; + jsb_cocos2d_TMXTilesetInfo_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TMXTilesetInfo_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TMXTilesetInfo_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TMXTilesetInfo_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TMXTilesetInfo_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TMXTilesetInfo_class->resolve = JS_ResolveStub; + jsb_cocos2d_TMXTilesetInfo_class->convert = JS_ConvertStub; + jsb_cocos2d_TMXTilesetInfo_class->finalize = js_cocos2d_TMXTilesetInfo_finalize; + jsb_cocos2d_TMXTilesetInfo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getRectForGID", js_cocos2dx_TMXTilesetInfo_getRectForGID, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_TMXTilesetInfo_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_TMXTilesetInfo_class, + js_cocos2dx_TMXTilesetInfo_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, "TMXTilesetInfo", 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_TMXTilesetInfo_class; + p->proto = jsb_cocos2d_TMXTilesetInfo_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TMXMapInfo_class; +JSObject *jsb_cocos2d_TMXMapInfo_prototype; + +bool js_cocos2dx_TMXMapInfo_setObjectGroups(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_setObjectGroups : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vector arg0; + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_setObjectGroups : Error processing arguments"); + cobj->setObjectGroups(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setObjectGroups : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXMapInfo_setTileSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_setTileSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_setTileSize : Error processing arguments"); + cobj->setTileSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setTileSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXMapInfo_initWithTMXFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_initWithTMXFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_initWithTMXFile : Error processing arguments"); + bool ret = cobj->initWithTMXFile(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_initWithTMXFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXMapInfo_getOrientation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getOrientation : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getOrientation(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getOrientation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXMapInfo_isStoringCharacters(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_isStoringCharacters : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isStoringCharacters(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_isStoringCharacters : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXMapInfo_setLayers(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_setLayers : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vector arg0; + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_setLayers : Error processing arguments"); + cobj->setLayers(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setLayers : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXMapInfo_parseXMLFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_parseXMLFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_parseXMLFile : Error processing arguments"); + bool ret = cobj->parseXMLFile(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_parseXMLFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXMapInfo_getParentElement(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getParentElement : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getParentElement(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getParentElement : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXMapInfo_setTMXFileName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_setTMXFileName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_setTMXFileName : Error processing arguments"); + cobj->setTMXFileName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setTMXFileName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXMapInfo_parseXMLString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_parseXMLString : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_parseXMLString : Error processing arguments"); + bool ret = cobj->parseXMLString(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_parseXMLString : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXMapInfo_getLayers(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::TMXMapInfo* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getLayers : Invalid Native Object"); + do { + if (argc == 0) { + cocos2d::Vector& ret = cobj->getLayers(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + const cocos2d::Vector& ret = cobj->getLayers(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getLayers : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TMXMapInfo_getTilesets(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::TMXMapInfo* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getTilesets : Invalid Native Object"); + do { + if (argc == 0) { + cocos2d::Vector& ret = cobj->getTilesets(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + const cocos2d::Vector& ret = cobj->getTilesets(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getTilesets : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TMXMapInfo_getParentGID(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getParentGID : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getParentGID(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getParentGID : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXMapInfo_setParentElement(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_setParentElement : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_setParentElement : Error processing arguments"); + cobj->setParentElement(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setParentElement : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXMapInfo_initWithXML(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_initWithXML : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_initWithXML : Error processing arguments"); + bool ret = cobj->initWithXML(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_initWithXML : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_TMXMapInfo_setParentGID(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_setParentGID : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_setParentGID : Error processing arguments"); + cobj->setParentGID(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setParentGID : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXMapInfo_getLayerAttribs(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getLayerAttribs : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getLayerAttribs(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getLayerAttribs : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXMapInfo_getTileSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getTileSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getTileSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getTileSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXMapInfo_getTileProperties(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getTileProperties : Invalid Native Object"); + if (argc == 0) { + cocos2d::ValueMapIntKey& ret = cobj->getTileProperties(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluemapintkey_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getTileProperties : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXMapInfo_getObjectGroups(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::TMXMapInfo* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getObjectGroups : Invalid Native Object"); + do { + if (argc == 0) { + cocos2d::Vector& ret = cobj->getObjectGroups(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + const cocos2d::Vector& ret = cobj->getObjectGroups(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getObjectGroups : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TMXMapInfo_getTMXFileName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getTMXFileName : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getTMXFileName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getTMXFileName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXMapInfo_setCurrentString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_setCurrentString : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_setCurrentString : Error processing arguments"); + cobj->setCurrentString(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setCurrentString : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXMapInfo_setProperties(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_setProperties : Invalid Native Object"); + if (argc == 1) { + cocos2d::ValueMap arg0; + ok &= jsval_to_ccvaluemap(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_setProperties : Error processing arguments"); + cobj->setProperties(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setProperties : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXMapInfo_setOrientation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_setOrientation : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_setOrientation : Error processing arguments"); + cobj->setOrientation(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setOrientation : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXMapInfo_setTileProperties(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_setTileProperties : Invalid Native Object"); + if (argc == 1) { + cocos2d::ValueMapIntKey arg0; + ok &= jsval_to_ccvaluemapintkey(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_setTileProperties : Error processing arguments"); + cobj->setTileProperties(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setTileProperties : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXMapInfo_setMapSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_setMapSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_setMapSize : Error processing arguments"); + cobj->setMapSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setMapSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXMapInfo_setStoringCharacters(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_setStoringCharacters : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_setStoringCharacters : Error processing arguments"); + cobj->setStoringCharacters(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setStoringCharacters : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXMapInfo_getMapSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getMapSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getMapSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getMapSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXMapInfo_setTilesets(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_setTilesets : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vector arg0; + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_setTilesets : Error processing arguments"); + cobj->setTilesets(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setTilesets : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXMapInfo_getProperties(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::TMXMapInfo* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getProperties : Invalid Native Object"); + do { + if (argc == 0) { + cocos2d::ValueMap& ret = cobj->getProperties(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluemap_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + const cocos2d::ValueMap& ret = cobj->getProperties(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluemap_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getProperties : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TMXMapInfo_getCurrentString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_getCurrentString : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getCurrentString(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_getCurrentString : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXMapInfo_setLayerAttribs(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXMapInfo* cobj = (cocos2d::TMXMapInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXMapInfo_setLayerAttribs : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_setLayerAttribs : Error processing arguments"); + cobj->setLayerAttribs(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_setLayerAttribs : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXMapInfo_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_create : Error processing arguments"); + cocos2d::TMXMapInfo* ret = cocos2d::TMXMapInfo::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TMXMapInfo*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TMXMapInfo_createWithXML(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXMapInfo_createWithXML : Error processing arguments"); + cocos2d::TMXMapInfo* ret = cocos2d::TMXMapInfo::createWithXML(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TMXMapInfo*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TMXMapInfo_createWithXML : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TMXMapInfo_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TMXMapInfo* cobj = new (std::nothrow) cocos2d::TMXMapInfo(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TMXMapInfo"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_TMXMapInfo_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TMXMapInfo)", obj); +} + +static bool js_cocos2d_TMXMapInfo_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TMXMapInfo *nobj = new (std::nothrow) cocos2d::TMXMapInfo(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TMXMapInfo"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_TMXMapInfo(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TMXMapInfo_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TMXMapInfo_class->name = "TMXMapInfo"; + jsb_cocos2d_TMXMapInfo_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TMXMapInfo_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TMXMapInfo_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TMXMapInfo_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TMXMapInfo_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TMXMapInfo_class->resolve = JS_ResolveStub; + jsb_cocos2d_TMXMapInfo_class->convert = JS_ConvertStub; + jsb_cocos2d_TMXMapInfo_class->finalize = js_cocos2d_TMXMapInfo_finalize; + jsb_cocos2d_TMXMapInfo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setObjectGroups", js_cocos2dx_TMXMapInfo_setObjectGroups, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTileSize", js_cocos2dx_TMXMapInfo_setTileSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTMXFile", js_cocos2dx_TMXMapInfo_initWithTMXFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOrientation", js_cocos2dx_TMXMapInfo_getOrientation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isStoringCharacters", js_cocos2dx_TMXMapInfo_isStoringCharacters, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLayers", js_cocos2dx_TMXMapInfo_setLayers, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("parseXMLFile", js_cocos2dx_TMXMapInfo_parseXMLFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getParentElement", js_cocos2dx_TMXMapInfo_getParentElement, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTMXFileName", js_cocos2dx_TMXMapInfo_setTMXFileName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("parseXMLString", js_cocos2dx_TMXMapInfo_parseXMLString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLayers", js_cocos2dx_TMXMapInfo_getLayers, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTilesets", js_cocos2dx_TMXMapInfo_getTilesets, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getParentGID", js_cocos2dx_TMXMapInfo_getParentGID, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setParentElement", js_cocos2dx_TMXMapInfo_setParentElement, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithXML", js_cocos2dx_TMXMapInfo_initWithXML, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setParentGID", js_cocos2dx_TMXMapInfo_setParentGID, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLayerAttribs", js_cocos2dx_TMXMapInfo_getLayerAttribs, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTileSize", js_cocos2dx_TMXMapInfo_getTileSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTileProperties", js_cocos2dx_TMXMapInfo_getTileProperties, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getObjectGroups", js_cocos2dx_TMXMapInfo_getObjectGroups, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTMXFileName", js_cocos2dx_TMXMapInfo_getTMXFileName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCurrentString", js_cocos2dx_TMXMapInfo_setCurrentString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setProperties", js_cocos2dx_TMXMapInfo_setProperties, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setOrientation", js_cocos2dx_TMXMapInfo_setOrientation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTileProperties", js_cocos2dx_TMXMapInfo_setTileProperties, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMapSize", js_cocos2dx_TMXMapInfo_setMapSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setStoringCharacters", js_cocos2dx_TMXMapInfo_setStoringCharacters, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMapSize", js_cocos2dx_TMXMapInfo_getMapSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTilesets", js_cocos2dx_TMXMapInfo_setTilesets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getProperties", js_cocos2dx_TMXMapInfo_getProperties, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCurrentString", js_cocos2dx_TMXMapInfo_getCurrentString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLayerAttribs", js_cocos2dx_TMXMapInfo_setLayerAttribs, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_TMXMapInfo_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TMXMapInfo_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithXML", js_cocos2dx_TMXMapInfo_createWithXML, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TMXMapInfo_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_TMXMapInfo_class, + js_cocos2dx_TMXMapInfo_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, "TMXMapInfo", 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_TMXMapInfo_class; + p->proto = jsb_cocos2d_TMXMapInfo_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TMXLayer_class; +JSObject *jsb_cocos2d_TMXLayer_prototype; + +bool js_cocos2dx_TMXLayer_getTileGIDAt(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_getTileGIDAt : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXLayer_getTileGIDAt : Error processing arguments"); + unsigned int ret = cobj->getTileGIDAt(arg0); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + cocos2d::Vec2 arg0; + cocos2d::TMXTileFlags_* arg1; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + #pragma warning NO CONVERSION TO NATIVE FOR TMXTileFlags_* + ok = false; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXLayer_getTileGIDAt : Error processing arguments"); + unsigned int ret = cobj->getTileGIDAt(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_getTileGIDAt : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXLayer_getPositionAt(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_getPositionAt : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXLayer_getPositionAt : Error processing arguments"); + cocos2d::Vec2 ret = cobj->getPositionAt(arg0); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_getPositionAt : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXLayer_setLayerOrientation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_setLayerOrientation : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXLayer_setLayerOrientation : Error processing arguments"); + cobj->setLayerOrientation(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_setLayerOrientation : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXLayer_releaseMap(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_releaseMap : Invalid Native Object"); + if (argc == 0) { + cobj->releaseMap(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_releaseMap : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXLayer_setTiles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_setTiles : Invalid Native Object"); + if (argc == 1) { + unsigned int* arg0; + #pragma warning NO CONVERSION TO NATIVE FOR unsigned int* + ok = false; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXLayer_setTiles : Error processing arguments"); + cobj->setTiles(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_setTiles : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXLayer_getLayerSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_getLayerSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getLayerSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_getLayerSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXLayer_setMapTileSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_setMapTileSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXLayer_setMapTileSize : Error processing arguments"); + cobj->setMapTileSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_setMapTileSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXLayer_getLayerOrientation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_getLayerOrientation : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getLayerOrientation(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_getLayerOrientation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXLayer_setProperties(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_setProperties : Invalid Native Object"); + if (argc == 1) { + cocos2d::ValueMap arg0; + ok &= jsval_to_ccvaluemap(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXLayer_setProperties : Error processing arguments"); + cobj->setProperties(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_setProperties : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXLayer_setLayerName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_setLayerName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXLayer_setLayerName : Error processing arguments"); + cobj->setLayerName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_setLayerName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXLayer_removeTileAt(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_removeTileAt : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXLayer_removeTileAt : Error processing arguments"); + cobj->removeTileAt(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_removeTileAt : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXLayer_initWithTilesetInfo(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_initWithTilesetInfo : Invalid Native Object"); + if (argc == 3) { + cocos2d::TMXTilesetInfo* arg0; + cocos2d::TMXLayerInfo* arg1; + cocos2d::TMXMapInfo* arg2; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::TMXTilesetInfo*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::TMXLayerInfo*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::TMXMapInfo*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXLayer_initWithTilesetInfo : Error processing arguments"); + bool ret = cobj->initWithTilesetInfo(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_initWithTilesetInfo : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_TMXLayer_setupTiles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_setupTiles : Invalid Native Object"); + if (argc == 0) { + cobj->setupTiles(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_setupTiles : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXLayer_setTileGID(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::TMXLayer* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_setTileGID : Invalid Native Object"); + do { + if (argc == 3) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec2 arg1; + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::TMXTileFlags_ arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + cobj->setTileGID(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 2) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec2 arg1; + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cobj->setTileGID(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_setTileGID : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TMXLayer_getMapTileSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_getMapTileSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getMapTileSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_getMapTileSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXLayer_getProperty(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_getProperty : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXLayer_getProperty : Error processing arguments"); + cocos2d::Value ret = cobj->getProperty(arg0); + jsval jsret = JSVAL_NULL; + jsret = ccvalue_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_getProperty : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXLayer_setLayerSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_setLayerSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXLayer_setLayerSize : Error processing arguments"); + cobj->setLayerSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_setLayerSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXLayer_getLayerName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_getLayerName : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getLayerName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_getLayerName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXLayer_setTileSet(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_setTileSet : Invalid Native Object"); + if (argc == 1) { + cocos2d::TMXTilesetInfo* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::TMXTilesetInfo*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXLayer_setTileSet : Error processing arguments"); + cobj->setTileSet(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_setTileSet : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXLayer_getTileSet(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_getTileSet : Invalid Native Object"); + if (argc == 0) { + cocos2d::TMXTilesetInfo* ret = cobj->getTileSet(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TMXTilesetInfo*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_getTileSet : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXLayer_getProperties(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::TMXLayer* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_getProperties : Invalid Native Object"); + do { + if (argc == 0) { + cocos2d::ValueMap& ret = cobj->getProperties(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluemap_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + const cocos2d::ValueMap& ret = cobj->getProperties(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluemap_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_getProperties : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TMXLayer_getTileAt(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXLayer_getTileAt : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXLayer_getTileAt : Error processing arguments"); + cocos2d::Sprite* ret = cobj->getTileAt(arg0); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXLayer_getTileAt : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXLayer_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 3) { + cocos2d::TMXTilesetInfo* arg0; + cocos2d::TMXLayerInfo* arg1; + cocos2d::TMXMapInfo* arg2; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::TMXTilesetInfo*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::TMXLayerInfo*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::TMXMapInfo*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXLayer_create : Error processing arguments"); + cocos2d::TMXLayer* ret = cocos2d::TMXLayer::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TMXLayer*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TMXLayer_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TMXLayer_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TMXLayer* cobj = new (std::nothrow) cocos2d::TMXLayer(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TMXLayer"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_SpriteBatchNode_prototype; + +void js_cocos2d_TMXLayer_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TMXLayer)", obj); +} + +static bool js_cocos2d_TMXLayer_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TMXLayer *nobj = new (std::nothrow) cocos2d::TMXLayer(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TMXLayer"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_TMXLayer(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TMXLayer_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TMXLayer_class->name = "TMXLayer"; + jsb_cocos2d_TMXLayer_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TMXLayer_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TMXLayer_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TMXLayer_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TMXLayer_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TMXLayer_class->resolve = JS_ResolveStub; + jsb_cocos2d_TMXLayer_class->convert = JS_ConvertStub; + jsb_cocos2d_TMXLayer_class->finalize = js_cocos2d_TMXLayer_finalize; + jsb_cocos2d_TMXLayer_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getTileGIDAt", js_cocos2dx_TMXLayer_getTileGIDAt, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPositionAt", js_cocos2dx_TMXLayer_getPositionAt, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLayerOrientation", js_cocos2dx_TMXLayer_setLayerOrientation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("releaseMap", js_cocos2dx_TMXLayer_releaseMap, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTiles", js_cocos2dx_TMXLayer_setTiles, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLayerSize", js_cocos2dx_TMXLayer_getLayerSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMapTileSize", js_cocos2dx_TMXLayer_setMapTileSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLayerOrientation", js_cocos2dx_TMXLayer_getLayerOrientation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setProperties", js_cocos2dx_TMXLayer_setProperties, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLayerName", js_cocos2dx_TMXLayer_setLayerName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeTileAt", js_cocos2dx_TMXLayer_removeTileAt, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTilesetInfo", js_cocos2dx_TMXLayer_initWithTilesetInfo, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setupTiles", js_cocos2dx_TMXLayer_setupTiles, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTileGID", js_cocos2dx_TMXLayer_setTileGID, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMapTileSize", js_cocos2dx_TMXLayer_getMapTileSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getProperty", js_cocos2dx_TMXLayer_getProperty, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLayerSize", js_cocos2dx_TMXLayer_setLayerSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLayerName", js_cocos2dx_TMXLayer_getLayerName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTileSet", js_cocos2dx_TMXLayer_setTileSet, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTileSet", js_cocos2dx_TMXLayer_getTileSet, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getProperties", js_cocos2dx_TMXLayer_getProperties, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTileAt", js_cocos2dx_TMXLayer_getTileAt, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_TMXLayer_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TMXLayer_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TMXLayer_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_SpriteBatchNode_prototype), + jsb_cocos2d_TMXLayer_class, + js_cocos2dx_TMXLayer_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, "TMXLayer", 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_TMXLayer_class; + p->proto = jsb_cocos2d_TMXLayer_prototype; + p->parentProto = jsb_cocos2d_SpriteBatchNode_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TMXTiledMap_class; +JSObject *jsb_cocos2d_TMXTiledMap_prototype; + +bool js_cocos2dx_TMXTiledMap_setObjectGroups(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_setObjectGroups : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vector arg0; + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXTiledMap_setObjectGroups : Error processing arguments"); + cobj->setObjectGroups(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_setObjectGroups : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXTiledMap_getProperty(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_getProperty : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXTiledMap_getProperty : Error processing arguments"); + cocos2d::Value ret = cobj->getProperty(arg0); + jsval jsret = JSVAL_NULL; + jsret = ccvalue_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_getProperty : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXTiledMap_setMapSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_setMapSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXTiledMap_setMapSize : Error processing arguments"); + cobj->setMapSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_setMapSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXTiledMap_getObjectGroup(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_getObjectGroup : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXTiledMap_getObjectGroup : Error processing arguments"); + cocos2d::TMXObjectGroup* ret = cobj->getObjectGroup(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TMXObjectGroup*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_getObjectGroup : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXTiledMap_getObjectGroups(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::TMXTiledMap* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_getObjectGroups : Invalid Native Object"); + do { + if (argc == 0) { + cocos2d::Vector& ret = cobj->getObjectGroups(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + const cocos2d::Vector& ret = cobj->getObjectGroups(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_getObjectGroups : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TMXTiledMap_initWithXML(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_initWithXML : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXTiledMap_initWithXML : Error processing arguments"); + bool ret = cobj->initWithXML(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_initWithXML : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_TMXTiledMap_initWithTMXFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_initWithTMXFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXTiledMap_initWithTMXFile : Error processing arguments"); + bool ret = cobj->initWithTMXFile(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_initWithTMXFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXTiledMap_getTileSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_getTileSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getTileSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_getTileSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXTiledMap_getMapSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_getMapSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getMapSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_getMapSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXTiledMap_getProperties(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_getProperties : Invalid Native Object"); + if (argc == 0) { + cocos2d::ValueMap& ret = cobj->getProperties(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluemap_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_getProperties : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXTiledMap_getPropertiesForGID(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::TMXTiledMap* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_getPropertiesForGID : Invalid Native Object"); + do { + if (argc == 2) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + cocos2d::Value** arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Value**)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + bool ret = cobj->getPropertiesForGID(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + cocos2d::Value ret = cobj->getPropertiesForGID(arg0); + jsval jsret = JSVAL_NULL; + jsret = ccvalue_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_getPropertiesForGID : wrong number of arguments"); + return false; +} +bool js_cocos2dx_TMXTiledMap_setTileSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_setTileSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXTiledMap_setTileSize : Error processing arguments"); + cobj->setTileSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_setTileSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXTiledMap_setProperties(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_setProperties : Invalid Native Object"); + if (argc == 1) { + cocos2d::ValueMap arg0; + ok &= jsval_to_ccvaluemap(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXTiledMap_setProperties : Error processing arguments"); + cobj->setProperties(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_setProperties : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXTiledMap_getLayer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_getLayer : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXTiledMap_getLayer : Error processing arguments"); + cocos2d::TMXLayer* ret = cobj->getLayer(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TMXLayer*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_getLayer : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXTiledMap_getMapOrientation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_getMapOrientation : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getMapOrientation(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_getMapOrientation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TMXTiledMap_setMapOrientation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXTiledMap* cobj = (cocos2d::TMXTiledMap *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TMXTiledMap_setMapOrientation : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXTiledMap_setMapOrientation : Error processing arguments"); + cobj->setMapOrientation(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_setMapOrientation : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TMXTiledMap_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXTiledMap_create : Error processing arguments"); + cocos2d::TMXTiledMap* ret = cocos2d::TMXTiledMap::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TMXTiledMap*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TMXTiledMap_createWithXML(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TMXTiledMap_createWithXML : Error processing arguments"); + cocos2d::TMXTiledMap* ret = cocos2d::TMXTiledMap::createWithXML(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TMXTiledMap*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TMXTiledMap_createWithXML : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TMXTiledMap_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TMXTiledMap* cobj = new (std::nothrow) cocos2d::TMXTiledMap(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TMXTiledMap"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_TMXTiledMap_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TMXTiledMap)", obj); +} + +static bool js_cocos2d_TMXTiledMap_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TMXTiledMap *nobj = new (std::nothrow) cocos2d::TMXTiledMap(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TMXTiledMap"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_TMXTiledMap(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TMXTiledMap_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TMXTiledMap_class->name = "TMXTiledMap"; + jsb_cocos2d_TMXTiledMap_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TMXTiledMap_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TMXTiledMap_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TMXTiledMap_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TMXTiledMap_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TMXTiledMap_class->resolve = JS_ResolveStub; + jsb_cocos2d_TMXTiledMap_class->convert = JS_ConvertStub; + jsb_cocos2d_TMXTiledMap_class->finalize = js_cocos2d_TMXTiledMap_finalize; + jsb_cocos2d_TMXTiledMap_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setObjectGroups", js_cocos2dx_TMXTiledMap_setObjectGroups, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getProperty", js_cocos2dx_TMXTiledMap_getProperty, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMapSize", js_cocos2dx_TMXTiledMap_setMapSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getObjectGroup", js_cocos2dx_TMXTiledMap_getObjectGroup, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getObjectGroups", js_cocos2dx_TMXTiledMap_getObjectGroups, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithXML", js_cocos2dx_TMXTiledMap_initWithXML, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTMXFile", js_cocos2dx_TMXTiledMap_initWithTMXFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTileSize", js_cocos2dx_TMXTiledMap_getTileSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMapSize", js_cocos2dx_TMXTiledMap_getMapSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getProperties", js_cocos2dx_TMXTiledMap_getProperties, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPropertiesForGID", js_cocos2dx_TMXTiledMap_getPropertiesForGID, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTileSize", js_cocos2dx_TMXTiledMap_setTileSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setProperties", js_cocos2dx_TMXTiledMap_setProperties, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLayer", js_cocos2dx_TMXTiledMap_getLayer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMapOrientation", js_cocos2dx_TMXTiledMap_getMapOrientation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMapOrientation", js_cocos2dx_TMXTiledMap_setMapOrientation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_TMXTiledMap_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TMXTiledMap_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithXML", js_cocos2dx_TMXTiledMap_createWithXML, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TMXTiledMap_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_TMXTiledMap_class, + js_cocos2dx_TMXTiledMap_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, "TMXTiledMap", 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_TMXTiledMap_class; + p->proto = jsb_cocos2d_TMXTiledMap_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_TileMapAtlas_class; +JSObject *jsb_cocos2d_TileMapAtlas_prototype; + +bool js_cocos2dx_TileMapAtlas_initWithTileFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TileMapAtlas* cobj = (cocos2d::TileMapAtlas *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TileMapAtlas_initWithTileFile : Invalid Native Object"); + if (argc == 4) { + std::string arg0; + std::string arg1; + int arg2; + int arg3; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TileMapAtlas_initWithTileFile : Error processing arguments"); + bool ret = cobj->initWithTileFile(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TileMapAtlas_initWithTileFile : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_TileMapAtlas_releaseMap(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TileMapAtlas* cobj = (cocos2d::TileMapAtlas *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TileMapAtlas_releaseMap : Invalid Native Object"); + if (argc == 0) { + cobj->releaseMap(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TileMapAtlas_releaseMap : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TileMapAtlas_getTGAInfo(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TileMapAtlas* cobj = (cocos2d::TileMapAtlas *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TileMapAtlas_getTGAInfo : Invalid Native Object"); + if (argc == 0) { + cocos2d::sImageTGA* ret = cobj->getTGAInfo(); + jsval jsret = JSVAL_NULL; + #pragma warning NO CONVERSION FROM NATIVE FOR sImageTGA*; + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TileMapAtlas_getTGAInfo : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_TileMapAtlas_getTileAt(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TileMapAtlas* cobj = (cocos2d::TileMapAtlas *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TileMapAtlas_getTileAt : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TileMapAtlas_getTileAt : Error processing arguments"); + cocos2d::Color3B ret = cobj->getTileAt(arg0); + jsval jsret = JSVAL_NULL; + jsret = cccolor3b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TileMapAtlas_getTileAt : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TileMapAtlas_setTile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TileMapAtlas* cobj = (cocos2d::TileMapAtlas *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TileMapAtlas_setTile : Invalid Native Object"); + if (argc == 2) { + cocos2d::Color3B arg0; + cocos2d::Vec2 arg1; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TileMapAtlas_setTile : Error processing arguments"); + cobj->setTile(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TileMapAtlas_setTile : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_TileMapAtlas_setTGAInfo(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TileMapAtlas* cobj = (cocos2d::TileMapAtlas *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TileMapAtlas_setTGAInfo : Invalid Native Object"); + if (argc == 1) { + cocos2d::sImageTGA* arg0; + #pragma warning NO CONVERSION TO NATIVE FOR sImageTGA* + ok = false; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TileMapAtlas_setTGAInfo : Error processing arguments"); + cobj->setTGAInfo(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_TileMapAtlas_setTGAInfo : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_TileMapAtlas_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 4) { + std::string arg0; + std::string arg1; + int arg2; + int arg3; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TileMapAtlas_create : Error processing arguments"); + cocos2d::TileMapAtlas* ret = cocos2d::TileMapAtlas::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::TileMapAtlas*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_TileMapAtlas_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_TileMapAtlas_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::TileMapAtlas* cobj = new (std::nothrow) cocos2d::TileMapAtlas(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TileMapAtlas"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_AtlasNode_prototype; + +void js_cocos2d_TileMapAtlas_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TileMapAtlas)", obj); +} + +static bool js_cocos2d_TileMapAtlas_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::TileMapAtlas *nobj = new (std::nothrow) cocos2d::TileMapAtlas(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::TileMapAtlas"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_TileMapAtlas(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_TileMapAtlas_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_TileMapAtlas_class->name = "TileMapAtlas"; + jsb_cocos2d_TileMapAtlas_class->addProperty = JS_PropertyStub; + jsb_cocos2d_TileMapAtlas_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_TileMapAtlas_class->getProperty = JS_PropertyStub; + jsb_cocos2d_TileMapAtlas_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_TileMapAtlas_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_TileMapAtlas_class->resolve = JS_ResolveStub; + jsb_cocos2d_TileMapAtlas_class->convert = JS_ConvertStub; + jsb_cocos2d_TileMapAtlas_class->finalize = js_cocos2d_TileMapAtlas_finalize; + jsb_cocos2d_TileMapAtlas_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithTileFile", js_cocos2dx_TileMapAtlas_initWithTileFile, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("releaseMap", js_cocos2dx_TileMapAtlas_releaseMap, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTGAInfo", js_cocos2dx_TileMapAtlas_getTGAInfo, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTileAt", js_cocos2dx_TileMapAtlas_getTileAt, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTile", js_cocos2dx_TileMapAtlas_setTile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTGAInfo", js_cocos2dx_TileMapAtlas_setTGAInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_TileMapAtlas_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_TileMapAtlas_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_TileMapAtlas_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_AtlasNode_prototype), + jsb_cocos2d_TileMapAtlas_class, + js_cocos2dx_TileMapAtlas_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, "TileMapAtlas", 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_TileMapAtlas_class; + p->proto = jsb_cocos2d_TileMapAtlas_prototype; + p->parentProto = jsb_cocos2d_AtlasNode_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_Component_class; +JSObject *jsb_cocos2d_Component_prototype; + +bool js_cocos2dx_Component_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_setEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Component_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Component_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Component_setName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_setName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Component_setName : Error processing arguments"); + cobj->setName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Component_setName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Component_isEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_isEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Component_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Component_update(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_update : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Component_update : Error processing arguments"); + cobj->update(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Component_update : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Component_getOwner(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_getOwner : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getOwner(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Component_getOwner : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Component_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Component_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Component_setOwner(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_setOwner : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Component_setOwner : Error processing arguments"); + cobj->setOwner(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Component_setOwner : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Component_getName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_getName : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Component_getName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Component_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Component* ret = cocos2d::Component::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Component*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Component_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Component_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Component* cobj = new (std::nothrow) cocos2d::Component(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Component"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_Component_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Component)", obj); +} + +static bool js_cocos2d_Component_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::Component *nobj = new (std::nothrow) cocos2d::Component(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Component"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_Component(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Component_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Component_class->name = "Component"; + jsb_cocos2d_Component_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Component_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Component_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Component_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Component_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Component_class->resolve = JS_ResolveStub; + jsb_cocos2d_Component_class->convert = JS_ConvertStub; + jsb_cocos2d_Component_class->finalize = js_cocos2d_Component_finalize; + jsb_cocos2d_Component_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setEnabled", js_cocos2dx_Component_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setName", js_cocos2dx_Component_setName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isEnabled", js_cocos2dx_Component_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("update", js_cocos2dx_Component_update, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOwner", js_cocos2dx_Component_getOwner, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_Component_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setOwner", js_cocos2dx_Component_setOwner, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getName", js_cocos2dx_Component_getName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_Component_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Component_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Component_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_Component_class, + js_cocos2dx_Component_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, "Component", 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_Component_class; + p->proto = jsb_cocos2d_Component_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ComponentContainer_class; +JSObject *jsb_cocos2d_ComponentContainer_prototype; + +bool js_cocos2dx_ComponentContainer_visit(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ComponentContainer* cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_visit : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ComponentContainer_visit : Error processing arguments"); + cobj->visit(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ComponentContainer_visit : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ComponentContainer_remove(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ComponentContainer* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_remove : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::Component* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Component*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + bool ret = cobj->remove(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + bool ret = cobj->remove(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ComponentContainer_remove : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ComponentContainer_removeAll(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ComponentContainer* cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_removeAll : Invalid Native Object"); + if (argc == 0) { + cobj->removeAll(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ComponentContainer_removeAll : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ComponentContainer_add(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ComponentContainer* cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_add : Invalid Native Object"); + if (argc == 1) { + cocos2d::Component* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Component*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ComponentContainer_add : Error processing arguments"); + bool ret = cobj->add(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ComponentContainer_add : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ComponentContainer_isEmpty(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ComponentContainer* cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_isEmpty : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isEmpty(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ComponentContainer_isEmpty : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ComponentContainer_get(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ComponentContainer* cobj = (cocos2d::ComponentContainer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ComponentContainer_get : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ComponentContainer_get : Error processing arguments"); + cocos2d::Component* ret = cobj->get(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Component*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ComponentContainer_get : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + + +void js_cocos2d_ComponentContainer_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ComponentContainer)", obj); +} + +void js_register_cocos2dx_ComponentContainer(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ComponentContainer_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ComponentContainer_class->name = "ComponentContainer"; + jsb_cocos2d_ComponentContainer_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ComponentContainer_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ComponentContainer_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ComponentContainer_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ComponentContainer_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ComponentContainer_class->resolve = JS_ResolveStub; + jsb_cocos2d_ComponentContainer_class->convert = JS_ConvertStub; + jsb_cocos2d_ComponentContainer_class->finalize = js_cocos2d_ComponentContainer_finalize; + jsb_cocos2d_ComponentContainer_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("visit", js_cocos2dx_ComponentContainer_visit, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("remove", js_cocos2dx_ComponentContainer_remove, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAll", js_cocos2dx_ComponentContainer_removeAll, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("add", js_cocos2dx_ComponentContainer_add, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isEmpty", js_cocos2dx_ComponentContainer_isEmpty, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getComponent", js_cocos2dx_ComponentContainer_get, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_ComponentContainer_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_ComponentContainer_class, + empty_constructor, 0, + 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, "ComponentContainer", 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_ComponentContainer_class; + p->proto = jsb_cocos2d_ComponentContainer_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_CocosDenshion_SimpleAudioEngine_class; +JSObject *jsb_CocosDenshion_SimpleAudioEngine_prototype; + +bool js_cocos2dx_SimpleAudioEngine_preloadBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_preloadBackgroundMusic : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SimpleAudioEngine_preloadBackgroundMusic : Error processing arguments"); + cobj->preloadBackgroundMusic(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_preloadBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_stopBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_stopBackgroundMusic : Invalid Native Object"); + if (argc == 0) { + cobj->stopBackgroundMusic(); + args.rval().setUndefined(); + return true; + } + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SimpleAudioEngine_stopBackgroundMusic : Error processing arguments"); + cobj->stopBackgroundMusic(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_stopBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_stopAllEffects(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_stopAllEffects : Invalid Native Object"); + if (argc == 0) { + cobj->stopAllEffects(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_stopAllEffects : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_getBackgroundMusicVolume(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_getBackgroundMusicVolume : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getBackgroundMusicVolume(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_getBackgroundMusicVolume : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_resumeBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_resumeBackgroundMusic : Invalid Native Object"); + if (argc == 0) { + cobj->resumeBackgroundMusic(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_resumeBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_setBackgroundMusicVolume(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_setBackgroundMusicVolume : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SimpleAudioEngine_setBackgroundMusicVolume : Error processing arguments"); + cobj->setBackgroundMusicVolume(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_setBackgroundMusicVolume : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_preloadEffect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_preloadEffect : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SimpleAudioEngine_preloadEffect : Error processing arguments"); + cobj->preloadEffect(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_preloadEffect : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_isBackgroundMusicPlaying(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_isBackgroundMusicPlaying : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isBackgroundMusicPlaying(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_isBackgroundMusicPlaying : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_getEffectsVolume(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_getEffectsVolume : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getEffectsVolume(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_getEffectsVolume : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_willPlayBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_willPlayBackgroundMusic : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->willPlayBackgroundMusic(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_willPlayBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_pauseEffect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_pauseEffect : Invalid Native Object"); + if (argc == 1) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SimpleAudioEngine_pauseEffect : Error processing arguments"); + cobj->pauseEffect(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_pauseEffect : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_playEffect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_playEffect : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SimpleAudioEngine_playEffect : Error processing arguments"); + unsigned int ret = cobj->playEffect(arg0); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + const char* arg0; + bool arg1; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SimpleAudioEngine_playEffect : Error processing arguments"); + unsigned int ret = cobj->playEffect(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + if (argc == 3) { + const char* arg0; + bool arg1; + double arg2; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + arg1 = JS::ToBoolean(args.get(1)); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SimpleAudioEngine_playEffect : Error processing arguments"); + unsigned int ret = cobj->playEffect(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + if (argc == 4) { + const char* arg0; + bool arg1; + double arg2; + double arg3; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + arg1 = JS::ToBoolean(args.get(1)); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SimpleAudioEngine_playEffect : Error processing arguments"); + unsigned int ret = cobj->playEffect(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + if (argc == 5) { + const char* arg0; + bool arg1; + double arg2; + double arg3; + double arg4; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + arg1 = JS::ToBoolean(args.get(1)); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + ok &= JS::ToNumber( cx, args.get(4), &arg4) && !isnan(arg4); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SimpleAudioEngine_playEffect : Error processing arguments"); + unsigned int ret = cobj->playEffect(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_playEffect : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_rewindBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_rewindBackgroundMusic : Invalid Native Object"); + if (argc == 0) { + cobj->rewindBackgroundMusic(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_rewindBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_playBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_playBackgroundMusic : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SimpleAudioEngine_playBackgroundMusic : Error processing arguments"); + cobj->playBackgroundMusic(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + const char* arg0; + bool arg1; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SimpleAudioEngine_playBackgroundMusic : Error processing arguments"); + cobj->playBackgroundMusic(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_playBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_resumeAllEffects(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_resumeAllEffects : Invalid Native Object"); + if (argc == 0) { + cobj->resumeAllEffects(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_resumeAllEffects : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_setEffectsVolume(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_setEffectsVolume : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SimpleAudioEngine_setEffectsVolume : Error processing arguments"); + cobj->setEffectsVolume(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_setEffectsVolume : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_stopEffect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_stopEffect : Invalid Native Object"); + if (argc == 1) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SimpleAudioEngine_stopEffect : Error processing arguments"); + cobj->stopEffect(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_stopEffect : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_pauseBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_pauseBackgroundMusic : Invalid Native Object"); + if (argc == 0) { + cobj->pauseBackgroundMusic(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_pauseBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_pauseAllEffects(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_pauseAllEffects : Invalid Native Object"); + if (argc == 0) { + cobj->pauseAllEffects(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_pauseAllEffects : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_unloadEffect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_unloadEffect : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SimpleAudioEngine_unloadEffect : Error processing arguments"); + cobj->unloadEffect(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_unloadEffect : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_resumeEffect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CocosDenshion::SimpleAudioEngine* cobj = (CocosDenshion::SimpleAudioEngine *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SimpleAudioEngine_resumeEffect : Invalid Native Object"); + if (argc == 1) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SimpleAudioEngine_resumeEffect : Error processing arguments"); + cobj->resumeEffect(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_resumeEffect : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_SimpleAudioEngine_end(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + CocosDenshion::SimpleAudioEngine::end(); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_end : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_SimpleAudioEngine_getInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + CocosDenshion::SimpleAudioEngine* ret = CocosDenshion::SimpleAudioEngine::getInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (CocosDenshion::SimpleAudioEngine*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_SimpleAudioEngine_getInstance : wrong number of arguments"); + return false; +} + + + +void js_CocosDenshion_SimpleAudioEngine_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (SimpleAudioEngine)", obj); +} + +void js_register_cocos2dx_SimpleAudioEngine(JSContext *cx, JS::HandleObject global) { + jsb_CocosDenshion_SimpleAudioEngine_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_CocosDenshion_SimpleAudioEngine_class->name = "AudioEngine"; + jsb_CocosDenshion_SimpleAudioEngine_class->addProperty = JS_PropertyStub; + jsb_CocosDenshion_SimpleAudioEngine_class->delProperty = JS_DeletePropertyStub; + jsb_CocosDenshion_SimpleAudioEngine_class->getProperty = JS_PropertyStub; + jsb_CocosDenshion_SimpleAudioEngine_class->setProperty = JS_StrictPropertyStub; + jsb_CocosDenshion_SimpleAudioEngine_class->enumerate = JS_EnumerateStub; + jsb_CocosDenshion_SimpleAudioEngine_class->resolve = JS_ResolveStub; + jsb_CocosDenshion_SimpleAudioEngine_class->convert = JS_ConvertStub; + jsb_CocosDenshion_SimpleAudioEngine_class->finalize = js_CocosDenshion_SimpleAudioEngine_finalize; + jsb_CocosDenshion_SimpleAudioEngine_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("preloadMusic", js_cocos2dx_SimpleAudioEngine_preloadBackgroundMusic, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("stopMusic", js_cocos2dx_SimpleAudioEngine_stopBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("stopAllEffects", js_cocos2dx_SimpleAudioEngine_stopAllEffects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMusicVolume", js_cocos2dx_SimpleAudioEngine_getBackgroundMusicVolume, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resumeMusic", js_cocos2dx_SimpleAudioEngine_resumeBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMusicVolume", js_cocos2dx_SimpleAudioEngine_setBackgroundMusicVolume, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("preloadEffect", js_cocos2dx_SimpleAudioEngine_preloadEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isMusicPlaying", js_cocos2dx_SimpleAudioEngine_isBackgroundMusicPlaying, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEffectsVolume", js_cocos2dx_SimpleAudioEngine_getEffectsVolume, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("willPlayMusic", js_cocos2dx_SimpleAudioEngine_willPlayBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pauseEffect", js_cocos2dx_SimpleAudioEngine_pauseEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("playEffect", js_cocos2dx_SimpleAudioEngine_playEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("rewindMusic", js_cocos2dx_SimpleAudioEngine_rewindBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("playMusic", js_cocos2dx_SimpleAudioEngine_playBackgroundMusic, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resumeAllEffects", js_cocos2dx_SimpleAudioEngine_resumeAllEffects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEffectsVolume", js_cocos2dx_SimpleAudioEngine_setEffectsVolume, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("stopEffect", js_cocos2dx_SimpleAudioEngine_stopEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pauseMusic", js_cocos2dx_SimpleAudioEngine_pauseBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pauseAllEffects", js_cocos2dx_SimpleAudioEngine_pauseAllEffects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("unloadEffect", js_cocos2dx_SimpleAudioEngine_unloadEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resumeEffect", js_cocos2dx_SimpleAudioEngine_resumeEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("end", js_cocos2dx_SimpleAudioEngine_end, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInstance", js_cocos2dx_SimpleAudioEngine_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_CocosDenshion_SimpleAudioEngine_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_CocosDenshion_SimpleAudioEngine_class, + empty_constructor, 0, + 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, "AudioEngine", 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_CocosDenshion_SimpleAudioEngine_class; + p->proto = jsb_CocosDenshion_SimpleAudioEngine_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj) { + // Get the ns + JS::RootedObject ns(cx); + get_or_create_js_obj(cx, obj, "cc", &ns); + + js_register_cocos2dx_Action(cx, ns); + js_register_cocos2dx_FiniteTimeAction(cx, ns); + js_register_cocos2dx_ActionInstant(cx, ns); + js_register_cocos2dx_Hide(cx, ns); + js_register_cocos2dx_Node(cx, ns); + js_register_cocos2dx_Scene(cx, ns); + js_register_cocos2dx_TransitionScene(cx, ns); + js_register_cocos2dx_TransitionEaseScene(cx, ns); + js_register_cocos2dx_TransitionMoveInL(cx, ns); + js_register_cocos2dx_TransitionMoveInB(cx, ns); + js_register_cocos2dx_Layer(cx, ns); + js_register_cocos2dx___LayerRGBA(cx, ns); + js_register_cocos2dx_AtlasNode(cx, ns); + js_register_cocos2dx_TileMapAtlas(cx, ns); + js_register_cocos2dx_TransitionMoveInT(cx, ns); + js_register_cocos2dx_TMXTilesetInfo(cx, ns); + js_register_cocos2dx_TransitionMoveInR(cx, ns); + js_register_cocos2dx_ParticleSystem(cx, ns); + js_register_cocos2dx_ParticleSystemQuad(cx, ns); + js_register_cocos2dx_ParticleSpiral(cx, ns); + js_register_cocos2dx_GridBase(cx, ns); + js_register_cocos2dx_AnimationCache(cx, ns); + js_register_cocos2dx_ActionInterval(cx, ns); + js_register_cocos2dx_ActionCamera(cx, ns); + js_register_cocos2dx_ProgressFromTo(cx, ns); + js_register_cocos2dx_MoveBy(cx, ns); + js_register_cocos2dx_MoveTo(cx, ns); + js_register_cocos2dx_JumpBy(cx, ns); + js_register_cocos2dx_EventListener(cx, ns); + js_register_cocos2dx_EventListenerKeyboard(cx, ns); + js_register_cocos2dx_EventListenerMouse(cx, ns); + js_register_cocos2dx_TransitionRotoZoom(cx, ns); + js_register_cocos2dx_Director(cx, ns); + js_register_cocos2dx_Scheduler(cx, ns); + js_register_cocos2dx_ActionEase(cx, ns); + js_register_cocos2dx_EaseElastic(cx, ns); + js_register_cocos2dx_EaseElasticOut(cx, ns); + js_register_cocos2dx_EaseQuadraticActionInOut(cx, ns); + js_register_cocos2dx_EaseBackOut(cx, ns); + js_register_cocos2dx_TransitionSceneOriented(cx, ns); + js_register_cocos2dx_TransitionFlipX(cx, ns); + js_register_cocos2dx_GridAction(cx, ns); + js_register_cocos2dx_TiledGrid3DAction(cx, ns); + js_register_cocos2dx_FadeOutTRTiles(cx, ns); + js_register_cocos2dx_FadeOutUpTiles(cx, ns); + js_register_cocos2dx_FadeOutDownTiles(cx, ns); + js_register_cocos2dx_StopGrid(cx, ns); + js_register_cocos2dx_SimpleAudioEngine(cx, ns); + js_register_cocos2dx_SkewTo(cx, ns); + js_register_cocos2dx_SkewBy(cx, ns); + js_register_cocos2dx_EaseQuadraticActionOut(cx, ns); + js_register_cocos2dx_TransitionProgress(cx, ns); + js_register_cocos2dx_TransitionProgressVertical(cx, ns); + js_register_cocos2dx_ComponentContainer(cx, ns); + js_register_cocos2dx_TMXTiledMap(cx, ns); + js_register_cocos2dx_Grid3DAction(cx, ns); + js_register_cocos2dx_BaseLight(cx, ns); + js_register_cocos2dx_SpotLight(cx, ns); + js_register_cocos2dx_FadeTo(cx, ns); + js_register_cocos2dx_FadeIn(cx, ns); + js_register_cocos2dx_DirectionLight(cx, ns); + js_register_cocos2dx_GLProgramState(cx, ns); + js_register_cocos2dx_EventListenerCustom(cx, ns); + js_register_cocos2dx_FlipX3D(cx, ns); + js_register_cocos2dx_FlipY3D(cx, ns); + js_register_cocos2dx_EaseSineInOut(cx, ns); + js_register_cocos2dx_TransitionFlipAngular(cx, ns); + js_register_cocos2dx_EaseElasticInOut(cx, ns); + js_register_cocos2dx_EaseBounce(cx, ns); + js_register_cocos2dx_Show(cx, ns); + js_register_cocos2dx_FadeOut(cx, ns); + js_register_cocos2dx_CallFunc(cx, ns); + js_register_cocos2dx_Event(cx, ns); + js_register_cocos2dx_EventMouse(cx, ns); + js_register_cocos2dx_GLView(cx, ns); + js_register_cocos2dx_EaseBezierAction(cx, ns); + js_register_cocos2dx_ParticleFireworks(cx, ns); + js_register_cocos2dx_MenuItem(cx, ns); + js_register_cocos2dx_MenuItemSprite(cx, ns); + js_register_cocos2dx_MenuItemImage(cx, ns); + js_register_cocos2dx_ParticleFire(cx, ns); + js_register_cocos2dx_ProgressTo(cx, ns); + js_register_cocos2dx_TransitionZoomFlipAngular(cx, ns); + js_register_cocos2dx_EaseRateAction(cx, ns); + js_register_cocos2dx_EaseIn(cx, ns); + js_register_cocos2dx_EaseExponentialInOut(cx, ns); + js_register_cocos2dx_EaseBackInOut(cx, ns); + js_register_cocos2dx_Waves3D(cx, ns); + js_register_cocos2dx_EaseExponentialOut(cx, ns); + js_register_cocos2dx_SpriteBatchNode(cx, ns); + js_register_cocos2dx_Label(cx, ns); + js_register_cocos2dx_Application(cx, ns); + js_register_cocos2dx_DelayTime(cx, ns); + js_register_cocos2dx_LabelAtlas(cx, ns); + js_register_cocos2dx_LabelBMFont(cx, ns); + js_register_cocos2dx_AsyncTaskPool(cx, ns); + js_register_cocos2dx_ParticleSnow(cx, ns); + js_register_cocos2dx_EaseElasticIn(cx, ns); + js_register_cocos2dx_EaseCircleActionInOut(cx, ns); + js_register_cocos2dx_EaseQuarticActionOut(cx, ns); + js_register_cocos2dx_EventAcceleration(cx, ns); + js_register_cocos2dx_EaseCubicActionIn(cx, ns); + js_register_cocos2dx_TextureCache(cx, ns); + js_register_cocos2dx_Configuration(cx, ns); + js_register_cocos2dx_ActionTween(cx, ns); + js_register_cocos2dx_TransitionFadeTR(cx, ns); + js_register_cocos2dx_TransitionFadeDown(cx, ns); + js_register_cocos2dx_ParticleSun(cx, ns); + js_register_cocos2dx_TransitionProgressHorizontal(cx, ns); + js_register_cocos2dx_TMXObjectGroup(cx, ns); + js_register_cocos2dx_TMXLayer(cx, ns); + js_register_cocos2dx_FlipX(cx, ns); + js_register_cocos2dx_FlipY(cx, ns); + js_register_cocos2dx_TransitionSplitCols(cx, ns); + js_register_cocos2dx_Repeat(cx, ns); + js_register_cocos2dx_Place(cx, ns); + js_register_cocos2dx_EventListenerAcceleration(cx, ns); + js_register_cocos2dx_TiledGrid3D(cx, ns); + js_register_cocos2dx_EaseBounceOut(cx, ns); + js_register_cocos2dx_RenderTexture(cx, ns); + js_register_cocos2dx_TintBy(cx, ns); + js_register_cocos2dx_TransitionShrinkGrow(cx, ns); + js_register_cocos2dx_LabelTTF(cx, ns); + js_register_cocos2dx_ClippingNode(cx, ns); + js_register_cocos2dx_ActionFloat(cx, ns); + js_register_cocos2dx_ParticleFlower(cx, ns); + js_register_cocos2dx_EaseCircleActionIn(cx, ns); + js_register_cocos2dx_ParticleSmoke(cx, ns); + js_register_cocos2dx_Image(cx, ns); + js_register_cocos2dx_LayerMultiplex(cx, ns); + js_register_cocos2dx_Blink(cx, ns); + js_register_cocos2dx_JumpTo(cx, ns); + js_register_cocos2dx_ParticleExplosion(cx, ns); + js_register_cocos2dx_TransitionJumpZoom(cx, ns); + js_register_cocos2dx_Touch(cx, ns); + js_register_cocos2dx_SAXParser(cx, ns); + js_register_cocos2dx_AnimationFrame(cx, ns); + js_register_cocos2dx_NodeGrid(cx, ns); + js_register_cocos2dx_TMXLayerInfo(cx, ns); + js_register_cocos2dx_EaseSineIn(cx, ns); + js_register_cocos2dx_EaseBounceIn(cx, ns); + js_register_cocos2dx_Camera(cx, ns); + js_register_cocos2dx_GLProgram(cx, ns); + js_register_cocos2dx_ParticleGalaxy(cx, ns); + js_register_cocos2dx_Twirl(cx, ns); + js_register_cocos2dx_MenuItemLabel(cx, ns); + js_register_cocos2dx_EaseQuinticActionIn(cx, ns); + js_register_cocos2dx_LayerColor(cx, ns); + js_register_cocos2dx_FadeOutBLTiles(cx, ns); + js_register_cocos2dx_LayerGradient(cx, ns); + js_register_cocos2dx_EventListenerTouchAllAtOnce(cx, ns); + js_register_cocos2dx_ToggleVisibility(cx, ns); + js_register_cocos2dx_RepeatForever(cx, ns); + js_register_cocos2dx_CardinalSplineTo(cx, ns); + js_register_cocos2dx_CardinalSplineBy(cx, ns); + js_register_cocos2dx_TransitionFlipY(cx, ns); + js_register_cocos2dx_TurnOffTiles(cx, ns); + js_register_cocos2dx_TintTo(cx, ns); + js_register_cocos2dx_CatmullRomTo(cx, ns); + js_register_cocos2dx_TransitionFadeBL(cx, ns); + js_register_cocos2dx_TargetedAction(cx, ns); + js_register_cocos2dx_DrawNode(cx, ns); + js_register_cocos2dx_TransitionTurnOffTiles(cx, ns); + js_register_cocos2dx_RotateTo(cx, ns); + js_register_cocos2dx_TransitionSplitRows(cx, ns); + js_register_cocos2dx_Device(cx, ns); + js_register_cocos2dx_TransitionProgressRadialCCW(cx, ns); + js_register_cocos2dx_EventListenerFocus(cx, ns); + js_register_cocos2dx_TransitionPageTurn(cx, ns); + js_register_cocos2dx_BezierBy(cx, ns); + js_register_cocos2dx_BezierTo(cx, ns); + js_register_cocos2dx_Menu(cx, ns); + js_register_cocos2dx_Texture2D(cx, ns); + js_register_cocos2dx_ActionManager(cx, ns); + js_register_cocos2dx_TransitionFade(cx, ns); + js_register_cocos2dx_TransitionZoomFlipX(cx, ns); + js_register_cocos2dx_EventFocus(cx, ns); + js_register_cocos2dx_EaseQuinticActionInOut(cx, ns); + js_register_cocos2dx_SpriteFrameCache(cx, ns); + js_register_cocos2dx_PointLight(cx, ns); + js_register_cocos2dx_TransitionCrossFade(cx, ns); + js_register_cocos2dx_Ripple3D(cx, ns); + js_register_cocos2dx_Lens3D(cx, ns); + js_register_cocos2dx_ScaleTo(cx, ns); + js_register_cocos2dx_Spawn(cx, ns); + js_register_cocos2dx_EaseQuarticActionInOut(cx, ns); + js_register_cocos2dx_ShakyTiles3D(cx, ns); + js_register_cocos2dx_PageTurn3D(cx, ns); + js_register_cocos2dx_TransitionSlideInL(cx, ns); + js_register_cocos2dx_TransitionSlideInT(cx, ns); + js_register_cocos2dx_Grid3D(cx, ns); + js_register_cocos2dx_EaseCircleActionOut(cx, ns); + js_register_cocos2dx_TransitionProgressInOut(cx, ns); + js_register_cocos2dx_EaseCubicActionInOut(cx, ns); + js_register_cocos2dx_EaseBackIn(cx, ns); + js_register_cocos2dx_SplitRows(cx, ns); + js_register_cocos2dx_Follow(cx, ns); + js_register_cocos2dx_Animate(cx, ns); + js_register_cocos2dx_ShuffleTiles(cx, ns); + js_register_cocos2dx_ReverseTime(cx, ns); + js_register_cocos2dx_ProgressTimer(cx, ns); + js_register_cocos2dx_ParticleMeteor(cx, ns); + js_register_cocos2dx_EaseQuarticActionIn(cx, ns); + js_register_cocos2dx_EaseInOut(cx, ns); + js_register_cocos2dx_TransitionZoomFlipY(cx, ns); + js_register_cocos2dx_ScaleBy(cx, ns); + js_register_cocos2dx_EventTouch(cx, ns); + js_register_cocos2dx_Animation(cx, ns); + js_register_cocos2dx_TMXMapInfo(cx, ns); + js_register_cocos2dx_EaseExponentialIn(cx, ns); + js_register_cocos2dx_ReuseGrid(cx, ns); + js_register_cocos2dx_SpriteFrame(cx, ns); + js_register_cocos2dx_EventDispatcher(cx, ns); + js_register_cocos2dx_MenuItemAtlasFont(cx, ns); + js_register_cocos2dx_Liquid(cx, ns); + js_register_cocos2dx_OrbitCamera(cx, ns); + js_register_cocos2dx_ParallaxNode(cx, ns); + js_register_cocos2dx_ParticleBatchNode(cx, ns); + js_register_cocos2dx_Component(cx, ns); + js_register_cocos2dx_EaseCubicActionOut(cx, ns); + js_register_cocos2dx_EventListenerTouchOneByOne(cx, ns); + js_register_cocos2dx_TextFieldTTF(cx, ns); + js_register_cocos2dx_ParticleRain(cx, ns); + js_register_cocos2dx_Waves(cx, ns); + js_register_cocos2dx_EaseQuinticActionOut(cx, ns); + js_register_cocos2dx_EaseOut(cx, ns); + js_register_cocos2dx_MenuItemFont(cx, ns); + js_register_cocos2dx_TransitionFadeUp(cx, ns); + js_register_cocos2dx_EaseSineOut(cx, ns); + js_register_cocos2dx_JumpTiles3D(cx, ns); + js_register_cocos2dx_MenuItemToggle(cx, ns); + js_register_cocos2dx_RemoveSelf(cx, ns); + js_register_cocos2dx_SplitCols(cx, ns); + js_register_cocos2dx_ProtectedNode(cx, ns); + js_register_cocos2dx_MotionStreak(cx, ns); + js_register_cocos2dx_RotateBy(cx, ns); + js_register_cocos2dx_FileUtils(cx, ns); + js_register_cocos2dx_Sprite(cx, ns); + js_register_cocos2dx_CallFuncN(cx, ns); + js_register_cocos2dx_TransitionProgressOutIn(cx, ns); + js_register_cocos2dx_CatmullRomBy(cx, ns); + js_register_cocos2dx_Sequence(cx, ns); + js_register_cocos2dx_Shaky3D(cx, ns); + js_register_cocos2dx_TransitionProgressRadialCW(cx, ns); + js_register_cocos2dx_EaseBounceInOut(cx, ns); + js_register_cocos2dx_TransitionSlideInR(cx, ns); + js_register_cocos2dx___NodeRGBA(cx, ns); + js_register_cocos2dx_AmbientLight(cx, ns); + js_register_cocos2dx_GLProgramCache(cx, ns); + js_register_cocos2dx_EaseQuadraticActionIn(cx, ns); + js_register_cocos2dx_WavesTiles3D(cx, ns); + js_register_cocos2dx_TransitionSlideInB(cx, ns); + js_register_cocos2dx_Speed(cx, ns); + js_register_cocos2dx_EventCustom(cx, ns); + js_register_cocos2dx_ShatteredTiles3D(cx, ns); +} + diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp new file mode 100644 index 0000000000..86b675bc9d --- /dev/null +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp @@ -0,0 +1,3862 @@ +#ifndef __cocos2dx_h__ +#define __cocos2dx_h__ + +#include "jsapi.h" +#include "jsfriendapi.h" + + +extern JSClass *jsb_cocos2d_Action_class; +extern JSObject *jsb_cocos2d_Action_prototype; + +bool js_cocos2dx_Action_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Action_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Action(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Action_startWithTarget(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Action_setOriginalTarget(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Action_clone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Action_getOriginalTarget(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Action_stop(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Action_update(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Action_getTarget(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Action_step(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Action_setTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Action_getTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Action_setTarget(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Action_isDone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Action_reverse(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_FiniteTimeAction_class; +extern JSObject *jsb_cocos2d_FiniteTimeAction_prototype; + +bool js_cocos2dx_FiniteTimeAction_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_FiniteTimeAction_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_FiniteTimeAction(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_FiniteTimeAction_setDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FiniteTimeAction_getDuration(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Speed_class; +extern JSObject *jsb_cocos2d_Speed_prototype; + +bool js_cocos2dx_Speed_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Speed_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Speed(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Speed_setInnerAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Speed_getSpeed(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Speed_setSpeed(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Speed_initWithAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Speed_getInnerAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Speed_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Speed_Speed(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Follow_class; +extern JSObject *jsb_cocos2d_Follow_prototype; + +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, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject 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_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); + +extern JSClass *jsb_cocos2d_Texture2D_class; +extern JSObject *jsb_cocos2d_Texture2D_prototype; + +bool js_cocos2dx_Texture2D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Texture2D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Texture2D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Texture2D_getGLProgram(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_getMaxT(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_getStringForFormat(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_initWithImage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_setGLProgram(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_getMaxS(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_releaseGLTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_hasPremultipliedAlpha(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_initWithMipmaps(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_getPixelsHigh(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_getBitsPerPixelForFormat(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_getName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_initWithString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_setMaxT(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_drawInRect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_getContentSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_setAliasTexParameters(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_setAntiAliasTexParameters(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_generateMipmap(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_getDescription(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_getPixelFormat(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_getContentSizeInPixels(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_getPixelsWide(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_drawAtPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_hasMipmaps(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_setMaxS(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_setDefaultAlphaPixelFormat(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_getDefaultAlphaPixelFormat(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Texture2D_Texture2D(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Touch_class; +extern JSObject *jsb_cocos2d_Touch_prototype; + +bool js_cocos2dx_Touch_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Touch_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Touch(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Touch_getPreviousLocationInView(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Touch_getLocation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Touch_getDelta(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Touch_getStartLocationInView(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Touch_getStartLocation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Touch_getID(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Touch_setTouchInfo(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Touch_getLocationInView(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Touch_getPreviousLocation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Touch_Touch(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Event_class; +extern JSObject *jsb_cocos2d_Event_prototype; + +bool js_cocos2dx_Event_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Event_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Event(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Event_isStopped(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Event_getType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Event_getCurrentTarget(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Event_stopPropagation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Event_Event(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EventTouch_class; +extern JSObject *jsb_cocos2d_EventTouch_prototype; + +bool js_cocos2dx_EventTouch_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EventTouch_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EventTouch(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EventTouch_getEventCode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventTouch_setEventCode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventTouch_EventTouch(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Node_class; +extern JSObject *jsb_cocos2d_Node_prototype; + +bool js_cocos2dx_Node_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Node_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Node(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Node_addChild(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_removeComponent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setPhysicsBody(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getGLProgram(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_updateTransformFromPhysics(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getDescription(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp); +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_isIgnoreAnchorPointForPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getChildByName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_updateDisplayedOpacity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getCameraMask(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setRotation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setScaleZ(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setScaleY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setScaleX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setonEnterTransitionDidFinishCallback(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_removeFromPhysicsWorld(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_removeAllComponents(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getOpacity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setCameraMask(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getonEnterTransitionDidFinishCallback(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_isOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getNodeToWorldAffineTransform(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getPosition3D(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_removeChild(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getScene(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getEventDispatcher(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setSkewX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setGLProgramState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setOnEnterCallback(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setNormalizedPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setonExitTransitionDidStartCallback(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_convertTouchToNodeSpace(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getRotationSkewX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getRotationSkewY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getNodeToWorldTransform(JSContext *cx, uint32_t argc, jsval *vp); +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_getRotation3D(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getNodeToParentAffineTransform(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_convertTouchToNodeSpaceAR(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getOnEnterCallback(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getPhysicsBody(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_stopActionByTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_reorderChild(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_ignoreAnchorPointForPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setSkewY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setRotation3D(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setPositionX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setNodeToParentTransform(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getNumberOfRunningActions(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_updateTransform(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_isVisible(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getChildrenCount(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getNodeToParentTransform(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_convertToNodeSpaceAR(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_addComponent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_runAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_visit(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setGLProgram(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getRotation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getAnchorPointInPoints(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getRotationQuat(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_removeChildByName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setPositionZ(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getGLProgramState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setScheduler(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_stopAllActions(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getSkewX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getSkewY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_isScheduled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getDisplayedColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getActionByTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setRotationSkewX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setRotationSkewY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_updatePhysicsBodyTransform(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getDisplayedOpacity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getLocalZOrder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getScheduler(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getOrderOfArrival(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setActionManager(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_isRunning(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getParent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getWorldToNodeTransform(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getPositionY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getPositionX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_removeChildByTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setPositionY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_updateDisplayedColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setVisible(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getParentToNodeAffineTransform(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getPositionZ(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setGlobalZOrder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getOnExitCallback(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getChildByTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setOrderOfArrival(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getScaleZ(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getScaleY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getScaleX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setLocalZOrder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setCascadeColorEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setOpacity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_cleanup(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getComponent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getContentSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_stopAllActionsByTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getBoundingBox(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setEventDispatcher(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getGlobalZOrder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_draw(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setUserObject(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_enumerateChildren(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getonExitTransitionDidStartCallback(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_removeFromParentAndCleanup(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setPosition3D(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_update(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_sortAllChildren(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getWorldToNodeAffineTransform(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getNormalizedPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getParentToNodeTransform(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_convertToNodeSpace(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_isCascadeColorEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_setRotationQuat(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_stopAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_getActionManager(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_Node(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d___NodeRGBA_class; +extern JSObject *jsb_cocos2d___NodeRGBA_prototype; + +bool js_cocos2dx___NodeRGBA_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx___NodeRGBA_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx___NodeRGBA(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx___NodeRGBA___NodeRGBA(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_SpriteFrame_class; +extern JSObject *jsb_cocos2d_SpriteFrame_prototype; + +bool js_cocos2dx_SpriteFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_SpriteFrame_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_SpriteFrame(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_SpriteFrame_clone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_setRotated(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_setTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_getOffset(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_setRectInPixels(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_getTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_getRect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_setOffsetInPixels(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_getRectInPixels(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_setOriginalSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_getOriginalSizeInPixels(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_setOriginalSizeInPixels(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_setOffset(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_isRotated(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_initWithTextureFilename(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_setRect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_getOffsetInPixels(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_getOriginalSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrame_SpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_AnimationFrame_class; +extern JSObject *jsb_cocos2d_AnimationFrame_prototype; + +bool js_cocos2dx_AnimationFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_AnimationFrame_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_AnimationFrame(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_AnimationFrame_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AnimationFrame_getUserInfo(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AnimationFrame_setDelayUnits(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AnimationFrame_clone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AnimationFrame_getSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AnimationFrame_getDelayUnits(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AnimationFrame_setUserInfo(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AnimationFrame_initWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AnimationFrame_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AnimationFrame_AnimationFrame(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Animation_class; +extern JSObject *jsb_cocos2d_Animation_prototype; + +bool js_cocos2dx_Animation_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Animation_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Animation(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Animation_getLoops(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animation_addSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animation_setRestoreOriginalFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animation_clone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animation_getDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animation_initWithAnimationFrames(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animation_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animation_setFrames(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animation_getFrames(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animation_setLoops(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animation_setDelayPerUnit(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animation_addSpriteFrameWithFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animation_getTotalDelayUnits(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animation_getDelayPerUnit(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animation_initWithSpriteFrames(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animation_getRestoreOriginalFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animation_addSpriteFrameWithTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animation_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animation_createWithSpriteFrames(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animation_Animation(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ActionInterval_class; +extern JSObject *jsb_cocos2d_ActionInterval_prototype; + +bool js_cocos2dx_ActionInterval_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ActionInterval_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ActionInterval(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ActionInterval_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionInterval_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionInterval_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionInterval_getElapsed(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Sequence_class; +extern JSObject *jsb_cocos2d_Sequence_prototype; + +bool js_cocos2dx_Sequence_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Sequence_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Sequence(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Sequence_initWithTwoActions(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sequence_Sequence(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Repeat_class; +extern JSObject *jsb_cocos2d_Repeat_prototype; + +bool js_cocos2dx_Repeat_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Repeat_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Repeat(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Repeat_setInnerAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Repeat_initWithAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Repeat_getInnerAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Repeat_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Repeat_Repeat(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_RepeatForever_class; +extern JSObject *jsb_cocos2d_RepeatForever_prototype; + +bool js_cocos2dx_RepeatForever_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_RepeatForever_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_RepeatForever(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_RepeatForever_setInnerAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RepeatForever_initWithAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RepeatForever_getInnerAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RepeatForever_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RepeatForever_RepeatForever(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Spawn_class; +extern JSObject *jsb_cocos2d_Spawn_prototype; + +bool js_cocos2dx_Spawn_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Spawn_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Spawn(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Spawn_initWithTwoActions(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Spawn_Spawn(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_RotateTo_class; +extern JSObject *jsb_cocos2d_RotateTo_prototype; + +bool js_cocos2dx_RotateTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_RotateTo_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_RotateTo(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_RotateTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RotateTo_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RotateTo_RotateTo(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_RotateBy_class; +extern JSObject *jsb_cocos2d_RotateBy_prototype; + +bool js_cocos2dx_RotateBy_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_RotateBy_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_RotateBy(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_RotateBy_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RotateBy_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RotateBy_RotateBy(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_MoveBy_class; +extern JSObject *jsb_cocos2d_MoveBy_prototype; + +bool js_cocos2dx_MoveBy_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_MoveBy_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_MoveBy(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_MoveBy_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MoveBy_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MoveBy_MoveBy(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_MoveTo_class; +extern JSObject *jsb_cocos2d_MoveTo_prototype; + +bool js_cocos2dx_MoveTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_MoveTo_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_MoveTo(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_MoveTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MoveTo_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MoveTo_MoveTo(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_SkewTo_class; +extern JSObject *jsb_cocos2d_SkewTo_prototype; + +bool js_cocos2dx_SkewTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_SkewTo_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_SkewTo(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_SkewTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SkewTo_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SkewTo_SkewTo(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_SkewBy_class; +extern JSObject *jsb_cocos2d_SkewBy_prototype; + +bool js_cocos2dx_SkewBy_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_SkewBy_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_SkewBy(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_SkewBy_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SkewBy_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SkewBy_SkewBy(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_JumpBy_class; +extern JSObject *jsb_cocos2d_JumpBy_prototype; + +bool js_cocos2dx_JumpBy_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_JumpBy_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_JumpBy(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_JumpBy_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_JumpBy_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_JumpBy_JumpBy(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_JumpTo_class; +extern JSObject *jsb_cocos2d_JumpTo_prototype; + +bool js_cocos2dx_JumpTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_JumpTo_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_JumpTo(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_JumpTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_JumpTo_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_JumpTo_JumpTo(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_BezierBy_class; +extern JSObject *jsb_cocos2d_BezierBy_prototype; + +bool js_cocos2dx_BezierBy_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_BezierBy_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_BezierBy(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_BezierBy_BezierBy(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_BezierTo_class; +extern JSObject *jsb_cocos2d_BezierTo_prototype; + +bool js_cocos2dx_BezierTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_BezierTo_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_BezierTo(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_BezierTo_BezierTo(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ScaleTo_class; +extern JSObject *jsb_cocos2d_ScaleTo_prototype; + +bool js_cocos2dx_ScaleTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ScaleTo_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ScaleTo(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ScaleTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ScaleTo_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ScaleTo_ScaleTo(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ScaleBy_class; +extern JSObject *jsb_cocos2d_ScaleBy_prototype; + +bool js_cocos2dx_ScaleBy_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ScaleBy_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ScaleBy(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ScaleBy_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ScaleBy_ScaleBy(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Blink_class; +extern JSObject *jsb_cocos2d_Blink_prototype; + +bool js_cocos2dx_Blink_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Blink_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Blink(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Blink_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Blink_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Blink_Blink(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_FadeTo_class; +extern JSObject *jsb_cocos2d_FadeTo_prototype; + +bool js_cocos2dx_FadeTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_FadeTo_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_FadeTo(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_FadeTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FadeTo_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FadeTo_FadeTo(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_FadeIn_class; +extern JSObject *jsb_cocos2d_FadeIn_prototype; + +bool js_cocos2dx_FadeIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_FadeIn_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_FadeIn(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_FadeIn_setReverseAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FadeIn_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FadeIn_FadeIn(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_FadeOut_class; +extern JSObject *jsb_cocos2d_FadeOut_prototype; + +bool js_cocos2dx_FadeOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_FadeOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_FadeOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_FadeOut_setReverseAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FadeOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FadeOut_FadeOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TintTo_class; +extern JSObject *jsb_cocos2d_TintTo_prototype; + +bool js_cocos2dx_TintTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TintTo_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TintTo(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TintTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TintTo_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TintTo_TintTo(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TintBy_class; +extern JSObject *jsb_cocos2d_TintBy_prototype; + +bool js_cocos2dx_TintBy_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TintBy_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TintBy(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TintBy_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TintBy_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TintBy_TintBy(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_DelayTime_class; +extern JSObject *jsb_cocos2d_DelayTime_prototype; + +bool js_cocos2dx_DelayTime_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_DelayTime_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_DelayTime(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_DelayTime_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DelayTime_DelayTime(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ReverseTime_class; +extern JSObject *jsb_cocos2d_ReverseTime_prototype; + +bool js_cocos2dx_ReverseTime_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ReverseTime_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ReverseTime(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ReverseTime_initWithAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ReverseTime_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ReverseTime_ReverseTime(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Animate_class; +extern JSObject *jsb_cocos2d_Animate_prototype; + +bool js_cocos2dx_Animate_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Animate_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Animate(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Animate_getAnimation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animate_initWithAnimation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animate_setAnimation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animate_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Animate_Animate(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TargetedAction_class; +extern JSObject *jsb_cocos2d_TargetedAction_prototype; + +bool js_cocos2dx_TargetedAction_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TargetedAction_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TargetedAction(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TargetedAction_getForcedTarget(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TargetedAction_initWithTarget(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TargetedAction_setForcedTarget(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TargetedAction_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TargetedAction_TargetedAction(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ActionFloat_class; +extern JSObject *jsb_cocos2d_ActionFloat_prototype; + +bool js_cocos2dx_ActionFloat_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ActionFloat_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ActionFloat(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ActionFloat_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionFloat_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionFloat_ActionFloat(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Configuration_class; +extern JSObject *jsb_cocos2d_Configuration_prototype; + +bool js_cocos2dx_Configuration_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Configuration_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Configuration(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Configuration_supportsPVRTC(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_getMaxModelviewStackDepth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_supportsShareableVAO(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_supportsBGRA8888(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_checkForGLExtension(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_supportsATITC(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_supportsNPOT(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_getAnimate3DQuality(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_getMaxSupportPointLightInShader(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_getMaxTextureSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_setValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_getMaxSupportSpotLightInShader(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_supportsETC(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_getMaxSupportDirLightInShader(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_loadConfigFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_supportsDiscardFramebuffer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_supportsS3TC(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_getInfo(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_getMaxTextureUnits(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_getValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_gatherGPUInfo(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Configuration_getInstance(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Scene_class; +extern JSObject *jsb_cocos2d_Scene_prototype; + +bool js_cocos2dx_Scene_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Scene_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Scene(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Scene_setCameraOrderDirty(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Scene_render(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Scene_onProjectionChanged(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Scene_initWithSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Scene_getDefaultCamera(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Scene_createWithSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Scene_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Scene_Scene(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_GLView_class; +extern JSObject *jsb_cocos2d_GLView_prototype; + +bool js_cocos2dx_GLView_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_GLView_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_GLView(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_GLView_setFrameSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_getViewPortRect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_setContentScaleFactor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_getContentScaleFactor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_setIMEKeyboardState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_setScissorInPoints(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_getViewName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_isOpenGLReady(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_setCursorVisible(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_getScaleY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_getScaleX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_getVisibleOrigin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_getFrameSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_setFrameZoomFactor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_getFrameZoomFactor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_getDesignResolutionSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_windowShouldClose(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_setDesignResolutionSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_getResolutionPolicy(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_isRetinaDisplay(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_setViewPortInPoints(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_getScissorRect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_getRetinaFactor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_setViewName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_getVisibleRect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_getVisibleSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_isScissorEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_pollEvents(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_setGLContextAttrs(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLView_getGLContextAttrs(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Director_class; +extern JSObject *jsb_cocos2d_Director_prototype; + +bool js_cocos2dx_Director_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Director_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Director(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject 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_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_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); +bool js_cocos2dx_Director_popToRootScene(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_loadMatrix(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_getNotificationNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_getWinSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_end(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_getTextureCache(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_isSendCleanupToScene(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_getVisibleOrigin(JSContext *cx, uint32_t argc, jsval *vp); +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_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); +bool js_cocos2dx_Director_setClearColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_setOpenGLView(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_convertToGL(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_purgeCachedData(JSContext *cx, uint32_t argc, jsval *vp); +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_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_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_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_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_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); + +extern JSClass *jsb_cocos2d_Scheduler_class; +extern JSObject *jsb_cocos2d_Scheduler_prototype; + +bool js_cocos2dx_Scheduler_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Scheduler_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Scheduler(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Scheduler_setTimeScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Scheduler_unscheduleAllWithMinPriority(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Scheduler_update(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Scheduler_unscheduleScriptEntry(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Scheduler_performFunctionInCocosThread(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Scheduler_unscheduleAll(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Scheduler_getTimeScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Scheduler_Scheduler(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_FileUtils_class; +extern JSObject *jsb_cocos2d_FileUtils_prototype; + +bool js_cocos2dx_FileUtils_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_FileUtils_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_FileUtils(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_FileUtils_fullPathForFilename(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_getStringFromFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_removeFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_isAbsolutePath(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_renameFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_isPopupNotify(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_getValueVectorFromFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_getSearchPaths(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_writeToFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_getValueMapFromFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_getValueMapFromData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_removeDirectory(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_setSearchPaths(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_getFileSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_setSearchResolutionsOrder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_addSearchResolutionsOrder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_addSearchPath(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_isFileExist(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_purgeCachedEntries(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_fullPathFromRelativeFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_getSuitableFOpen(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_setWritablePath(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_setPopupNotify(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_isDirectoryExist(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_setDefaultResourceRootPath(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_getSearchResolutionsOrder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_createDirectory(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_getWritablePath(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_setDelegate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FileUtils_getInstance(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_AsyncTaskPool_class; +extern JSObject *jsb_cocos2d_AsyncTaskPool_prototype; + +bool js_cocos2dx_AsyncTaskPool_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_AsyncTaskPool_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_AsyncTaskPool(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_AsyncTaskPool_stopTasks(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AsyncTaskPool_destoryInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AsyncTaskPool_getInstance(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EventListener_class; +extern JSObject *jsb_cocos2d_EventListener_prototype; + +bool js_cocos2dx_EventListener_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EventListener_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EventListener(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EventListener_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventListener_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventListener_clone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventListener_checkAvailable(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EventDispatcher_class; +extern JSObject *jsb_cocos2d_EventDispatcher_prototype; + +bool js_cocos2dx_EventDispatcher_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EventDispatcher_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EventDispatcher(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EventDispatcher_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventDispatcher_removeAllEventListeners(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventDispatcher_addEventListenerWithSceneGraphPriority(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventDispatcher_addCustomEventListener(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventDispatcher_addEventListenerWithFixedPriority(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventDispatcher_removeEventListenersForTarget(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventDispatcher_resumeEventListenersForTarget(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventDispatcher_setPriority(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventDispatcher_dispatchEvent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventDispatcher_pauseEventListenersForTarget(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventDispatcher_removeCustomEventListeners(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventDispatcher_removeEventListener(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventDispatcher_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventDispatcher_EventDispatcher(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EventListenerTouchOneByOne_class; +extern JSObject *jsb_cocos2d_EventListenerTouchOneByOne_prototype; + +bool js_cocos2dx_EventListenerTouchOneByOne_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EventListenerTouchOneByOne_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EventListenerTouchOneByOne(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EventListenerTouchOneByOne_isSwallowTouches(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventListenerTouchOneByOne_setSwallowTouches(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventListenerTouchOneByOne_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventListenerTouchOneByOne_EventListenerTouchOneByOne(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EventListenerTouchAllAtOnce_class; +extern JSObject *jsb_cocos2d_EventListenerTouchAllAtOnce_prototype; + +bool js_cocos2dx_EventListenerTouchAllAtOnce_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EventListenerTouchAllAtOnce_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EventListenerTouchAllAtOnce(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EventListenerTouchAllAtOnce_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventListenerTouchAllAtOnce_EventListenerTouchAllAtOnce(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EventListenerKeyboard_class; +extern JSObject *jsb_cocos2d_EventListenerKeyboard_prototype; + +bool js_cocos2dx_EventListenerKeyboard_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EventListenerKeyboard_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EventListenerKeyboard(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EventListenerKeyboard_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventListenerKeyboard_EventListenerKeyboard(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EventMouse_class; +extern JSObject *jsb_cocos2d_EventMouse_prototype; + +bool js_cocos2dx_EventMouse_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EventMouse_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EventMouse(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EventMouse_getMouseButton(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventMouse_getLocation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventMouse_setMouseButton(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventMouse_setScrollData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventMouse_getPreviousLocationInView(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventMouse_getDelta(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventMouse_getStartLocation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventMouse_getCursorY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventMouse_getCursorX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventMouse_getLocationInView(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventMouse_getScrollY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventMouse_setCursorPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventMouse_getScrollX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventMouse_getPreviousLocation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventMouse_getStartLocationInView(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventMouse_EventMouse(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EventListenerMouse_class; +extern JSObject *jsb_cocos2d_EventListenerMouse_prototype; + +bool js_cocos2dx_EventListenerMouse_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EventListenerMouse_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EventListenerMouse(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EventListenerMouse_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventListenerMouse_EventListenerMouse(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EventAcceleration_class; +extern JSObject *jsb_cocos2d_EventAcceleration_prototype; + +bool js_cocos2dx_EventAcceleration_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EventAcceleration_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EventAcceleration(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EventAcceleration_EventAcceleration(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EventListenerAcceleration_class; +extern JSObject *jsb_cocos2d_EventListenerAcceleration_prototype; + +bool js_cocos2dx_EventListenerAcceleration_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EventListenerAcceleration_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EventListenerAcceleration(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EventListenerAcceleration_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventListenerAcceleration_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventListenerAcceleration_EventListenerAcceleration(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EventCustom_class; +extern JSObject *jsb_cocos2d_EventCustom_prototype; + +bool js_cocos2dx_EventCustom_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EventCustom_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EventCustom(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EventCustom_getEventName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventCustom_EventCustom(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EventListenerCustom_class; +extern JSObject *jsb_cocos2d_EventListenerCustom_prototype; + +bool js_cocos2dx_EventListenerCustom_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EventListenerCustom_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EventListenerCustom(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EventListenerCustom_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventListenerCustom_EventListenerCustom(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EventFocus_class; +extern JSObject *jsb_cocos2d_EventFocus_prototype; + +bool js_cocos2dx_EventFocus_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EventFocus_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EventFocus(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EventFocus_EventFocus(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EventListenerFocus_class; +extern JSObject *jsb_cocos2d_EventListenerFocus_prototype; + +bool js_cocos2dx_EventListenerFocus_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EventListenerFocus_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EventListenerFocus(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EventListenerFocus_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EventListenerFocus_EventListenerFocus(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ActionCamera_class; +extern JSObject *jsb_cocos2d_ActionCamera_prototype; + +bool js_cocos2dx_ActionCamera_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ActionCamera_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ActionCamera(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ActionCamera_setEye(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionCamera_getEye(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionCamera_setUp(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionCamera_getCenter(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionCamera_setCenter(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionCamera_getUp(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionCamera_ActionCamera(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_OrbitCamera_class; +extern JSObject *jsb_cocos2d_OrbitCamera_prototype; + +bool js_cocos2dx_OrbitCamera_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_OrbitCamera_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_OrbitCamera(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_OrbitCamera_sphericalRadius(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_OrbitCamera_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_OrbitCamera_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_OrbitCamera_OrbitCamera(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ActionManager_class; +extern JSObject *jsb_cocos2d_ActionManager_prototype; + +bool js_cocos2dx_ActionManager_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ActionManager_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ActionManager(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ActionManager_getActionByTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionManager_removeActionByTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionManager_removeAllActions(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionManager_addAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionManager_resumeTarget(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionManager_update(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionManager_pauseTarget(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionManager_getNumberOfRunningActionsInTarget(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionManager_removeAllActionsFromTarget(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionManager_resumeTargets(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionManager_removeAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionManager_removeAllActionsByTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionManager_pauseAllRunningActions(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionManager_ActionManager(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ActionEase_class; +extern JSObject *jsb_cocos2d_ActionEase_prototype; + +bool js_cocos2dx_ActionEase_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ActionEase_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ActionEase(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ActionEase_initWithAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionEase_getInnerAction(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseRateAction_class; +extern JSObject *jsb_cocos2d_EaseRateAction_prototype; + +bool js_cocos2dx_EaseRateAction_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseRateAction_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseRateAction(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseRateAction_setRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseRateAction_initWithAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseRateAction_getRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseRateAction_create(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseIn_class; +extern JSObject *jsb_cocos2d_EaseIn_prototype; + +bool js_cocos2dx_EaseIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseIn_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseIn(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseIn_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseIn_EaseIn(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseOut_class; +extern JSObject *jsb_cocos2d_EaseOut_prototype; + +bool js_cocos2dx_EaseOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseOut_EaseOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseInOut_class; +extern JSObject *jsb_cocos2d_EaseInOut_prototype; + +bool js_cocos2dx_EaseInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseInOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseInOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseInOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseInOut_EaseInOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseExponentialIn_class; +extern JSObject *jsb_cocos2d_EaseExponentialIn_prototype; + +bool js_cocos2dx_EaseExponentialIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseExponentialIn_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseExponentialIn(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseExponentialIn_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseExponentialIn_EaseExponentialIn(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseExponentialOut_class; +extern JSObject *jsb_cocos2d_EaseExponentialOut_prototype; + +bool js_cocos2dx_EaseExponentialOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseExponentialOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseExponentialOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseExponentialOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseExponentialOut_EaseExponentialOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseExponentialInOut_class; +extern JSObject *jsb_cocos2d_EaseExponentialInOut_prototype; + +bool js_cocos2dx_EaseExponentialInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseExponentialInOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseExponentialInOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseExponentialInOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseExponentialInOut_EaseExponentialInOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseSineIn_class; +extern JSObject *jsb_cocos2d_EaseSineIn_prototype; + +bool js_cocos2dx_EaseSineIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseSineIn_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseSineIn(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseSineIn_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseSineIn_EaseSineIn(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseSineOut_class; +extern JSObject *jsb_cocos2d_EaseSineOut_prototype; + +bool js_cocos2dx_EaseSineOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseSineOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseSineOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseSineOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseSineOut_EaseSineOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseSineInOut_class; +extern JSObject *jsb_cocos2d_EaseSineInOut_prototype; + +bool js_cocos2dx_EaseSineInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseSineInOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseSineInOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseSineInOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseSineInOut_EaseSineInOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseElastic_class; +extern JSObject *jsb_cocos2d_EaseElastic_prototype; + +bool js_cocos2dx_EaseElastic_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseElastic_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseElastic(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseElastic_setPeriod(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseElastic_initWithAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseElastic_getPeriod(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseElasticIn_class; +extern JSObject *jsb_cocos2d_EaseElasticIn_prototype; + +bool js_cocos2dx_EaseElasticIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseElasticIn_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseElasticIn(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseElasticIn_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseElasticIn_EaseElasticIn(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseElasticOut_class; +extern JSObject *jsb_cocos2d_EaseElasticOut_prototype; + +bool js_cocos2dx_EaseElasticOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseElasticOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseElasticOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseElasticOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseElasticOut_EaseElasticOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseElasticInOut_class; +extern JSObject *jsb_cocos2d_EaseElasticInOut_prototype; + +bool js_cocos2dx_EaseElasticInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseElasticInOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseElasticInOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseElasticInOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseElasticInOut_EaseElasticInOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseBounce_class; +extern JSObject *jsb_cocos2d_EaseBounce_prototype; + +bool js_cocos2dx_EaseBounce_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseBounce_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseBounce(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); + +extern JSClass *jsb_cocos2d_EaseBounceIn_class; +extern JSObject *jsb_cocos2d_EaseBounceIn_prototype; + +bool js_cocos2dx_EaseBounceIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseBounceIn_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseBounceIn(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseBounceIn_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseBounceIn_EaseBounceIn(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseBounceOut_class; +extern JSObject *jsb_cocos2d_EaseBounceOut_prototype; + +bool js_cocos2dx_EaseBounceOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseBounceOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseBounceOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseBounceOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseBounceOut_EaseBounceOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseBounceInOut_class; +extern JSObject *jsb_cocos2d_EaseBounceInOut_prototype; + +bool js_cocos2dx_EaseBounceInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseBounceInOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseBounceInOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseBounceInOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseBounceInOut_EaseBounceInOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseBackIn_class; +extern JSObject *jsb_cocos2d_EaseBackIn_prototype; + +bool js_cocos2dx_EaseBackIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseBackIn_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseBackIn(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseBackIn_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseBackIn_EaseBackIn(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseBackOut_class; +extern JSObject *jsb_cocos2d_EaseBackOut_prototype; + +bool js_cocos2dx_EaseBackOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseBackOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseBackOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseBackOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseBackOut_EaseBackOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseBackInOut_class; +extern JSObject *jsb_cocos2d_EaseBackInOut_prototype; + +bool js_cocos2dx_EaseBackInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseBackInOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseBackInOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseBackInOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseBackInOut_EaseBackInOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseBezierAction_class; +extern JSObject *jsb_cocos2d_EaseBezierAction_prototype; + +bool js_cocos2dx_EaseBezierAction_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseBezierAction_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseBezierAction(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseBezierAction_setBezierParamer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseBezierAction_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseBezierAction_EaseBezierAction(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseQuadraticActionIn_class; +extern JSObject *jsb_cocos2d_EaseQuadraticActionIn_prototype; + +bool js_cocos2dx_EaseQuadraticActionIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseQuadraticActionIn_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseQuadraticActionIn(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseQuadraticActionIn_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseQuadraticActionIn_EaseQuadraticActionIn(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseQuadraticActionOut_class; +extern JSObject *jsb_cocos2d_EaseQuadraticActionOut_prototype; + +bool js_cocos2dx_EaseQuadraticActionOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseQuadraticActionOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseQuadraticActionOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseQuadraticActionOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseQuadraticActionOut_EaseQuadraticActionOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseQuadraticActionInOut_class; +extern JSObject *jsb_cocos2d_EaseQuadraticActionInOut_prototype; + +bool js_cocos2dx_EaseQuadraticActionInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseQuadraticActionInOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseQuadraticActionInOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseQuadraticActionInOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseQuadraticActionInOut_EaseQuadraticActionInOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseQuarticActionIn_class; +extern JSObject *jsb_cocos2d_EaseQuarticActionIn_prototype; + +bool js_cocos2dx_EaseQuarticActionIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseQuarticActionIn_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseQuarticActionIn(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseQuarticActionIn_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseQuarticActionIn_EaseQuarticActionIn(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseQuarticActionOut_class; +extern JSObject *jsb_cocos2d_EaseQuarticActionOut_prototype; + +bool js_cocos2dx_EaseQuarticActionOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseQuarticActionOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseQuarticActionOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseQuarticActionOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseQuarticActionOut_EaseQuarticActionOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseQuarticActionInOut_class; +extern JSObject *jsb_cocos2d_EaseQuarticActionInOut_prototype; + +bool js_cocos2dx_EaseQuarticActionInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseQuarticActionInOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseQuarticActionInOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseQuarticActionInOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseQuarticActionInOut_EaseQuarticActionInOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseQuinticActionIn_class; +extern JSObject *jsb_cocos2d_EaseQuinticActionIn_prototype; + +bool js_cocos2dx_EaseQuinticActionIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseQuinticActionIn_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseQuinticActionIn(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseQuinticActionIn_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseQuinticActionIn_EaseQuinticActionIn(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseQuinticActionOut_class; +extern JSObject *jsb_cocos2d_EaseQuinticActionOut_prototype; + +bool js_cocos2dx_EaseQuinticActionOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseQuinticActionOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseQuinticActionOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseQuinticActionOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseQuinticActionOut_EaseQuinticActionOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseQuinticActionInOut_class; +extern JSObject *jsb_cocos2d_EaseQuinticActionInOut_prototype; + +bool js_cocos2dx_EaseQuinticActionInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseQuinticActionInOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseQuinticActionInOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseQuinticActionInOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseQuinticActionInOut_EaseQuinticActionInOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseCircleActionIn_class; +extern JSObject *jsb_cocos2d_EaseCircleActionIn_prototype; + +bool js_cocos2dx_EaseCircleActionIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseCircleActionIn_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseCircleActionIn(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseCircleActionIn_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseCircleActionIn_EaseCircleActionIn(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseCircleActionOut_class; +extern JSObject *jsb_cocos2d_EaseCircleActionOut_prototype; + +bool js_cocos2dx_EaseCircleActionOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseCircleActionOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseCircleActionOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseCircleActionOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseCircleActionOut_EaseCircleActionOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseCircleActionInOut_class; +extern JSObject *jsb_cocos2d_EaseCircleActionInOut_prototype; + +bool js_cocos2dx_EaseCircleActionInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseCircleActionInOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseCircleActionInOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseCircleActionInOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseCircleActionInOut_EaseCircleActionInOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseCubicActionIn_class; +extern JSObject *jsb_cocos2d_EaseCubicActionIn_prototype; + +bool js_cocos2dx_EaseCubicActionIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseCubicActionIn_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseCubicActionIn(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseCubicActionIn_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseCubicActionIn_EaseCubicActionIn(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseCubicActionOut_class; +extern JSObject *jsb_cocos2d_EaseCubicActionOut_prototype; + +bool js_cocos2dx_EaseCubicActionOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseCubicActionOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseCubicActionOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseCubicActionOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseCubicActionOut_EaseCubicActionOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_EaseCubicActionInOut_class; +extern JSObject *jsb_cocos2d_EaseCubicActionInOut_prototype; + +bool js_cocos2dx_EaseCubicActionInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_EaseCubicActionInOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_EaseCubicActionInOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_EaseCubicActionInOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_EaseCubicActionInOut_EaseCubicActionInOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ActionInstant_class; +extern JSObject *jsb_cocos2d_ActionInstant_prototype; + +bool js_cocos2dx_ActionInstant_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ActionInstant_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ActionInstant(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); + +extern JSClass *jsb_cocos2d_Show_class; +extern JSObject *jsb_cocos2d_Show_prototype; + +bool js_cocos2dx_Show_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Show_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Show(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Show_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Show_Show(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Hide_class; +extern JSObject *jsb_cocos2d_Hide_prototype; + +bool js_cocos2dx_Hide_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Hide_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Hide(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Hide_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Hide_Hide(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ToggleVisibility_class; +extern JSObject *jsb_cocos2d_ToggleVisibility_prototype; + +bool js_cocos2dx_ToggleVisibility_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ToggleVisibility_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ToggleVisibility(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ToggleVisibility_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ToggleVisibility_ToggleVisibility(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_RemoveSelf_class; +extern JSObject *jsb_cocos2d_RemoveSelf_prototype; + +bool js_cocos2dx_RemoveSelf_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_RemoveSelf_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_RemoveSelf(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_RemoveSelf_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RemoveSelf_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RemoveSelf_RemoveSelf(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_FlipX_class; +extern JSObject *jsb_cocos2d_FlipX_prototype; + +bool js_cocos2dx_FlipX_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_FlipX_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_FlipX(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_FlipX_initWithFlipX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FlipX_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FlipX_FlipX(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_FlipY_class; +extern JSObject *jsb_cocos2d_FlipY_prototype; + +bool js_cocos2dx_FlipY_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_FlipY_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_FlipY(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_FlipY_initWithFlipY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FlipY_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FlipY_FlipY(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Place_class; +extern JSObject *jsb_cocos2d_Place_prototype; + +bool js_cocos2dx_Place_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Place_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Place(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Place_initWithPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Place_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Place_Place(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_CallFunc_class; +extern JSObject *jsb_cocos2d_CallFunc_prototype; + +bool js_cocos2dx_CallFunc_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_CallFunc_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_CallFunc(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_CallFunc_execute(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_CallFunc_CallFunc(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_CallFuncN_class; +extern JSObject *jsb_cocos2d_CallFuncN_prototype; + +bool js_cocos2dx_CallFuncN_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_CallFuncN_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_CallFuncN(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_CallFuncN_CallFuncN(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_GridAction_class; +extern JSObject *jsb_cocos2d_GridAction_prototype; + +bool js_cocos2dx_GridAction_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_GridAction_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_GridAction(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_GridAction_getGrid(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridAction_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Grid3DAction_class; +extern JSObject *jsb_cocos2d_Grid3DAction_prototype; + +bool js_cocos2dx_Grid3DAction_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Grid3DAction_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Grid3DAction(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); + +extern JSClass *jsb_cocos2d_TiledGrid3DAction_class; +extern JSObject *jsb_cocos2d_TiledGrid3DAction_prototype; + +bool js_cocos2dx_TiledGrid3DAction_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TiledGrid3DAction_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TiledGrid3DAction(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); + +extern JSClass *jsb_cocos2d_StopGrid_class; +extern JSObject *jsb_cocos2d_StopGrid_prototype; + +bool js_cocos2dx_StopGrid_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_StopGrid_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_StopGrid(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_StopGrid_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_StopGrid_StopGrid(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ReuseGrid_class; +extern JSObject *jsb_cocos2d_ReuseGrid_prototype; + +bool js_cocos2dx_ReuseGrid_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ReuseGrid_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ReuseGrid(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ReuseGrid_initWithTimes(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ReuseGrid_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ReuseGrid_ReuseGrid(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Waves3D_class; +extern JSObject *jsb_cocos2d_Waves3D_prototype; + +bool js_cocos2dx_Waves3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Waves3D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Waves3D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Waves3D_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Waves3D_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Waves3D_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Waves3D_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Waves3D_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Waves3D_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Waves3D_Waves3D(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_FlipX3D_class; +extern JSObject *jsb_cocos2d_FlipX3D_prototype; + +bool js_cocos2dx_FlipX3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_FlipX3D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_FlipX3D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_FlipX3D_initWithSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FlipX3D_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FlipX3D_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FlipX3D_FlipX3D(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_FlipY3D_class; +extern JSObject *jsb_cocos2d_FlipY3D_prototype; + +bool js_cocos2dx_FlipY3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_FlipY3D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_FlipY3D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_FlipY3D_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FlipY3D_FlipY3D(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Lens3D_class; +extern JSObject *jsb_cocos2d_Lens3D_prototype; + +bool js_cocos2dx_Lens3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Lens3D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Lens3D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Lens3D_setConcave(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Lens3D_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Lens3D_setLensEffect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Lens3D_getLensEffect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Lens3D_setPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Lens3D_getPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Lens3D_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Lens3D_Lens3D(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Ripple3D_class; +extern JSObject *jsb_cocos2d_Ripple3D_prototype; + +bool js_cocos2dx_Ripple3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Ripple3D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Ripple3D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Ripple3D_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Ripple3D_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Ripple3D_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Ripple3D_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Ripple3D_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Ripple3D_setPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Ripple3D_getPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Ripple3D_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Ripple3D_Ripple3D(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Shaky3D_class; +extern JSObject *jsb_cocos2d_Shaky3D_prototype; + +bool js_cocos2dx_Shaky3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Shaky3D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Shaky3D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Shaky3D_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Shaky3D_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Shaky3D_Shaky3D(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Liquid_class; +extern JSObject *jsb_cocos2d_Liquid_prototype; + +bool js_cocos2dx_Liquid_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Liquid_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Liquid(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Liquid_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Liquid_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Liquid_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Liquid_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Liquid_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Liquid_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Liquid_Liquid(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Waves_class; +extern JSObject *jsb_cocos2d_Waves_prototype; + +bool js_cocos2dx_Waves_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Waves_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Waves(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Waves_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Waves_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Waves_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Waves_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Waves_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Waves_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Waves_Waves(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Twirl_class; +extern JSObject *jsb_cocos2d_Twirl_prototype; + +bool js_cocos2dx_Twirl_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Twirl_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Twirl(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Twirl_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Twirl_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Twirl_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Twirl_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Twirl_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Twirl_setPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Twirl_getPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Twirl_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Twirl_Twirl(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_PageTurn3D_class; +extern JSObject *jsb_cocos2d_PageTurn3D_prototype; + +bool js_cocos2dx_PageTurn3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_PageTurn3D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_PageTurn3D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_PageTurn3D_create(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ProgressTo_class; +extern JSObject *jsb_cocos2d_ProgressTo_prototype; + +bool js_cocos2dx_ProgressTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ProgressTo_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ProgressTo(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ProgressTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProgressTo_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProgressTo_ProgressTo(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ProgressFromTo_class; +extern JSObject *jsb_cocos2d_ProgressFromTo_prototype; + +bool js_cocos2dx_ProgressFromTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ProgressFromTo_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ProgressFromTo(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ProgressFromTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProgressFromTo_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProgressFromTo_ProgressFromTo(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ShakyTiles3D_class; +extern JSObject *jsb_cocos2d_ShakyTiles3D_prototype; + +bool js_cocos2dx_ShakyTiles3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ShakyTiles3D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ShakyTiles3D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ShakyTiles3D_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ShakyTiles3D_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ShakyTiles3D_ShakyTiles3D(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ShatteredTiles3D_class; +extern JSObject *jsb_cocos2d_ShatteredTiles3D_prototype; + +bool js_cocos2dx_ShatteredTiles3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ShatteredTiles3D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ShatteredTiles3D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ShatteredTiles3D_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ShatteredTiles3D_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ShatteredTiles3D_ShatteredTiles3D(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ShuffleTiles_class; +extern JSObject *jsb_cocos2d_ShuffleTiles_prototype; + +bool js_cocos2dx_ShuffleTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ShuffleTiles_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ShuffleTiles(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ShuffleTiles_placeTile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ShuffleTiles_shuffle(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ShuffleTiles_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ShuffleTiles_getDelta(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ShuffleTiles_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ShuffleTiles_ShuffleTiles(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_FadeOutTRTiles_class; +extern JSObject *jsb_cocos2d_FadeOutTRTiles_prototype; + +bool js_cocos2dx_FadeOutTRTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_FadeOutTRTiles_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_FadeOutTRTiles(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_FadeOutTRTiles_turnOnTile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FadeOutTRTiles_turnOffTile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FadeOutTRTiles_transformTile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FadeOutTRTiles_testFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FadeOutTRTiles_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FadeOutTRTiles_FadeOutTRTiles(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_FadeOutBLTiles_class; +extern JSObject *jsb_cocos2d_FadeOutBLTiles_prototype; + +bool js_cocos2dx_FadeOutBLTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_FadeOutBLTiles_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_FadeOutBLTiles(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_FadeOutBLTiles_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FadeOutBLTiles_FadeOutBLTiles(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_FadeOutUpTiles_class; +extern JSObject *jsb_cocos2d_FadeOutUpTiles_prototype; + +bool js_cocos2dx_FadeOutUpTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_FadeOutUpTiles_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_FadeOutUpTiles(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_FadeOutUpTiles_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FadeOutUpTiles_FadeOutUpTiles(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_FadeOutDownTiles_class; +extern JSObject *jsb_cocos2d_FadeOutDownTiles_prototype; + +bool js_cocos2dx_FadeOutDownTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_FadeOutDownTiles_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_FadeOutDownTiles(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_FadeOutDownTiles_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_FadeOutDownTiles_FadeOutDownTiles(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TurnOffTiles_class; +extern JSObject *jsb_cocos2d_TurnOffTiles_prototype; + +bool js_cocos2dx_TurnOffTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TurnOffTiles_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TurnOffTiles(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TurnOffTiles_turnOnTile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TurnOffTiles_turnOffTile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TurnOffTiles_shuffle(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TurnOffTiles_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TurnOffTiles_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TurnOffTiles_TurnOffTiles(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_WavesTiles3D_class; +extern JSObject *jsb_cocos2d_WavesTiles3D_prototype; + +bool js_cocos2dx_WavesTiles3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_WavesTiles3D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_WavesTiles3D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_WavesTiles3D_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_WavesTiles3D_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_WavesTiles3D_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_WavesTiles3D_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_WavesTiles3D_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_WavesTiles3D_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_WavesTiles3D_WavesTiles3D(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_JumpTiles3D_class; +extern JSObject *jsb_cocos2d_JumpTiles3D_prototype; + +bool js_cocos2dx_JumpTiles3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_JumpTiles3D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_JumpTiles3D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_JumpTiles3D_setAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_JumpTiles3D_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_JumpTiles3D_getAmplitude(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_JumpTiles3D_getAmplitudeRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_JumpTiles3D_setAmplitude(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_JumpTiles3D_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_JumpTiles3D_JumpTiles3D(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_SplitRows_class; +extern JSObject *jsb_cocos2d_SplitRows_prototype; + +bool js_cocos2dx_SplitRows_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_SplitRows_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_SplitRows(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_SplitRows_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SplitRows_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SplitRows_SplitRows(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_SplitCols_class; +extern JSObject *jsb_cocos2d_SplitCols_prototype; + +bool js_cocos2dx_SplitCols_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_SplitCols_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_SplitCols(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_SplitCols_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SplitCols_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SplitCols_SplitCols(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ActionTween_class; +extern JSObject *jsb_cocos2d_ActionTween_prototype; + +bool js_cocos2dx_ActionTween_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ActionTween_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ActionTween(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ActionTween_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ActionTween_create(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_CardinalSplineTo_class; +extern JSObject *jsb_cocos2d_CardinalSplineTo_prototype; + +bool js_cocos2dx_CardinalSplineTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_CardinalSplineTo_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_CardinalSplineTo(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_CardinalSplineTo_getPoints(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_CardinalSplineTo_updatePosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_CardinalSplineTo_CardinalSplineTo(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_CardinalSplineBy_class; +extern JSObject *jsb_cocos2d_CardinalSplineBy_prototype; + +bool js_cocos2dx_CardinalSplineBy_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_CardinalSplineBy_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_CardinalSplineBy(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_CardinalSplineBy_CardinalSplineBy(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_CatmullRomTo_class; +extern JSObject *jsb_cocos2d_CatmullRomTo_prototype; + +bool js_cocos2dx_CatmullRomTo_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_CatmullRomTo_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_CatmullRomTo(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); + +extern JSClass *jsb_cocos2d_CatmullRomBy_class; +extern JSObject *jsb_cocos2d_CatmullRomBy_prototype; + +bool js_cocos2dx_CatmullRomBy_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_CatmullRomBy_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_CatmullRomBy(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); + +extern JSClass *jsb_cocos2d_ProtectedNode_class; +extern JSObject *jsb_cocos2d_ProtectedNode_prototype; + +bool js_cocos2dx_ProtectedNode_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ProtectedNode_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ProtectedNode(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ProtectedNode_addProtectedChild(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProtectedNode_disableCascadeColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProtectedNode_removeProtectedChildByTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProtectedNode_reorderProtectedChild(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProtectedNode_removeAllProtectedChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProtectedNode_disableCascadeOpacity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProtectedNode_sortAllProtectedChildren(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProtectedNode_getProtectedChildByTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProtectedNode_removeProtectedChild(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProtectedNode_removeAllProtectedChildren(JSContext *cx, uint32_t argc, jsval *vp); +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, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_GLProgramState_setUniformCallback(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_getVertexAttribsFlags(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_setUniformVec2(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_setUniformVec3(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_applyGLProgram(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_setUniformInt(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_setUniformVec2v(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_clone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_setGLProgram(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_setUniformFloatv(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_getGLProgram(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_setUniformTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_applyUniforms(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_setUniformFloat(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_setUniformMat4(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_setUniformVec3v(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_getVertexAttribCount(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); +bool js_cocos2dx_GLProgramState_getOrCreateWithShaders(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_AtlasNode_class; +extern JSObject *jsb_cocos2d_AtlasNode_prototype; + +bool js_cocos2dx_AtlasNode_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_AtlasNode_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_AtlasNode(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_AtlasNode_updateAtlasValues(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AtlasNode_initWithTileFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AtlasNode_getTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AtlasNode_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AtlasNode_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AtlasNode_getTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AtlasNode_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AtlasNode_getQuadsToDraw(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AtlasNode_setTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AtlasNode_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AtlasNode_setQuadsToDraw(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AtlasNode_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AtlasNode_AtlasNode(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_DrawNode_class; +extern JSObject *jsb_cocos2d_DrawNode_prototype; + +bool js_cocos2dx_DrawNode_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_DrawNode_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_DrawNode(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_DrawNode_drawLine(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_drawPoints(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_drawRect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_drawSolidCircle(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_onDrawGLPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_drawDot(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_drawCatmullRom(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_drawSegment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_onDraw(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_drawCircle(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_drawQuadBezier(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_onDrawGLLine(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_drawSolidPoly(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_drawTriangle(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_clear(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_drawCardinalSpline(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_drawSolidRect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_drawPoly(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_drawPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_drawCubicBezier(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DrawNode_DrawNode(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_LabelAtlas_class; +extern JSObject *jsb_cocos2d_LabelAtlas_prototype; + +bool js_cocos2dx_LabelAtlas_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_LabelAtlas_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_LabelAtlas(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_LabelAtlas_setString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelAtlas_initWithString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelAtlas_getString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelAtlas_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelAtlas_LabelAtlas(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_LabelTTF_class; +extern JSObject *jsb_cocos2d_LabelTTF_prototype; + +bool js_cocos2dx_LabelTTF_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_LabelTTF_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_LabelTTF(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_LabelTTF_enableShadow(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_setDimensions(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_getFontSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_getString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_setFlippedY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_setFlippedX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_setTextDefinition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_setFontName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_getHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_initWithStringAndTextDefinition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_setString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_initWithString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_setFontFillColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_enableStroke(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_getDimensions(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_setVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_setFontSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_getVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_getTextDefinition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_getFontName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_setHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_disableShadow(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_disableStroke(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_createWithFontDefinition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelTTF_LabelTTF(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_SpriteBatchNode_class; +extern JSObject *jsb_cocos2d_SpriteBatchNode_prototype; + +bool js_cocos2dx_SpriteBatchNode_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_SpriteBatchNode_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_SpriteBatchNode(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_SpriteBatchNode_appendChild(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_addSpriteWithoutQuad(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_reorderBatch(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_lowestAtlasIndexInChild(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_atlasIndexForChild(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_initWithFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_getTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_increaseAtlasCapacity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_getTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_insertQuadFromSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_setTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_rebuildIndexInOrder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_highestAtlasIndexInChild(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_removeChildAtIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_removeSpriteFromAtlas(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteBatchNode_SpriteBatchNode(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Label_class; +extern JSObject *jsb_cocos2d_Label_prototype; + +bool js_cocos2dx_Label_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Label_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Label(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Label_isClipMarginEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_enableShadow(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setDimensions(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getHeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_disableEffect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getTextColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setWidth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getMaxLineWidth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setClipMarginEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setSystemFontName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setBMFontFilePath(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setLineHeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setSystemFontSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_updateContent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getStringLength(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setLineBreakWithoutSpace(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getStringNumLines(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_enableOutline(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getAdditionalKerning(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setCharMap(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getDimensions(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setMaxLineWidth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getSystemFontName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getLineHeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getTTFConfig(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setTextColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setHeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getWidth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_enableGlow(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getLetter(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setAdditionalKerning(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getSystemFontSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getTextAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getBMFontFilePath(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_setAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_requestSystemFontRefresh(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_createWithBMFont(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_createWithCharMap(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_createWithSystemFont(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_Label(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_LabelBMFont_class; +extern JSObject *jsb_cocos2d_LabelBMFont_prototype; + +bool js_cocos2dx_LabelBMFont_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_LabelBMFont_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_LabelBMFont(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_LabelBMFont_setLineBreakWithoutSpace(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelBMFont_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelBMFont_getLetter(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelBMFont_getString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelBMFont_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelBMFont_setString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelBMFont_initWithString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelBMFont_getFntFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelBMFont_setFntFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelBMFont_setAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelBMFont_setWidth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelBMFont_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LabelBMFont_LabelBMFont(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Layer_class; +extern JSObject *jsb_cocos2d_Layer_prototype; + +bool js_cocos2dx_Layer_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Layer_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Layer(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Layer_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Layer_Layer(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d___LayerRGBA_class; +extern JSObject *jsb_cocos2d___LayerRGBA_prototype; + +bool js_cocos2dx___LayerRGBA_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx___LayerRGBA_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx___LayerRGBA(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx___LayerRGBA_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx___LayerRGBA___LayerRGBA(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_LayerColor_class; +extern JSObject *jsb_cocos2d_LayerColor_prototype; + +bool js_cocos2dx_LayerColor_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_LayerColor_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_LayerColor(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_LayerColor_changeWidthAndHeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerColor_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerColor_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerColor_changeWidth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerColor_initWithColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerColor_changeHeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerColor_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerColor_LayerColor(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_LayerGradient_class; +extern JSObject *jsb_cocos2d_LayerGradient_prototype; + +bool js_cocos2dx_LayerGradient_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_LayerGradient_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_LayerGradient(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_LayerGradient_getStartColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerGradient_isCompressedInterpolation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerGradient_getStartOpacity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerGradient_setVector(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerGradient_setStartOpacity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerGradient_setCompressedInterpolation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerGradient_setEndOpacity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerGradient_getVector(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerGradient_setEndColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerGradient_initWithColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerGradient_getEndColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerGradient_getEndOpacity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerGradient_setStartColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerGradient_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerGradient_LayerGradient(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_LayerMultiplex_class; +extern JSObject *jsb_cocos2d_LayerMultiplex_prototype; + +bool js_cocos2dx_LayerMultiplex_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_LayerMultiplex_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_LayerMultiplex(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_LayerMultiplex_initWithArray(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerMultiplex_switchToAndReleaseMe(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerMultiplex_addLayer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerMultiplex_switchTo(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_LayerMultiplex_LayerMultiplex(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionEaseScene_class; +extern JSObject *jsb_cocos2d_TransitionEaseScene_prototype; + +bool js_cocos2dx_TransitionEaseScene_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionEaseScene_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionEaseScene(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionEaseScene_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionScene_class; +extern JSObject *jsb_cocos2d_TransitionScene_prototype; + +bool js_cocos2dx_TransitionScene_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionScene_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionScene(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionScene_getInScene(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionScene_finish(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionScene_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionScene_getDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionScene_hideOutShowIn(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionScene_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionScene_TransitionScene(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionSceneOriented_class; +extern JSObject *jsb_cocos2d_TransitionSceneOriented_prototype; + +bool js_cocos2dx_TransitionSceneOriented_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionSceneOriented_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionSceneOriented(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionSceneOriented_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionSceneOriented_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionSceneOriented_TransitionSceneOriented(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionRotoZoom_class; +extern JSObject *jsb_cocos2d_TransitionRotoZoom_prototype; + +bool js_cocos2dx_TransitionRotoZoom_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionRotoZoom_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionRotoZoom(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionRotoZoom_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionRotoZoom_TransitionRotoZoom(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionJumpZoom_class; +extern JSObject *jsb_cocos2d_TransitionJumpZoom_prototype; + +bool js_cocos2dx_TransitionJumpZoom_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionJumpZoom_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionJumpZoom(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionJumpZoom_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionJumpZoom_TransitionJumpZoom(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionMoveInL_class; +extern JSObject *jsb_cocos2d_TransitionMoveInL_prototype; + +bool js_cocos2dx_TransitionMoveInL_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionMoveInL_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionMoveInL(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionMoveInL_action(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionMoveInL_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionMoveInL_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionMoveInL_TransitionMoveInL(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionMoveInR_class; +extern JSObject *jsb_cocos2d_TransitionMoveInR_prototype; + +bool js_cocos2dx_TransitionMoveInR_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionMoveInR_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionMoveInR(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionMoveInR_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionMoveInR_TransitionMoveInR(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionMoveInT_class; +extern JSObject *jsb_cocos2d_TransitionMoveInT_prototype; + +bool js_cocos2dx_TransitionMoveInT_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionMoveInT_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionMoveInT(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionMoveInT_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionMoveInT_TransitionMoveInT(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionMoveInB_class; +extern JSObject *jsb_cocos2d_TransitionMoveInB_prototype; + +bool js_cocos2dx_TransitionMoveInB_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionMoveInB_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionMoveInB(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionMoveInB_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionMoveInB_TransitionMoveInB(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionSlideInL_class; +extern JSObject *jsb_cocos2d_TransitionSlideInL_prototype; + +bool js_cocos2dx_TransitionSlideInL_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionSlideInL_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionSlideInL(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionSlideInL_action(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionSlideInL_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionSlideInL_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionSlideInL_TransitionSlideInL(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionSlideInR_class; +extern JSObject *jsb_cocos2d_TransitionSlideInR_prototype; + +bool js_cocos2dx_TransitionSlideInR_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionSlideInR_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionSlideInR(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionSlideInR_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionSlideInR_TransitionSlideInR(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionSlideInB_class; +extern JSObject *jsb_cocos2d_TransitionSlideInB_prototype; + +bool js_cocos2dx_TransitionSlideInB_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionSlideInB_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionSlideInB(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionSlideInB_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionSlideInB_TransitionSlideInB(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionSlideInT_class; +extern JSObject *jsb_cocos2d_TransitionSlideInT_prototype; + +bool js_cocos2dx_TransitionSlideInT_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionSlideInT_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionSlideInT(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionSlideInT_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionSlideInT_TransitionSlideInT(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionShrinkGrow_class; +extern JSObject *jsb_cocos2d_TransitionShrinkGrow_prototype; + +bool js_cocos2dx_TransitionShrinkGrow_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionShrinkGrow_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionShrinkGrow(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionShrinkGrow_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionShrinkGrow_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionShrinkGrow_TransitionShrinkGrow(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionFlipX_class; +extern JSObject *jsb_cocos2d_TransitionFlipX_prototype; + +bool js_cocos2dx_TransitionFlipX_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionFlipX_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionFlipX(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionFlipX_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionFlipX_TransitionFlipX(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionFlipY_class; +extern JSObject *jsb_cocos2d_TransitionFlipY_prototype; + +bool js_cocos2dx_TransitionFlipY_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionFlipY_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionFlipY(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionFlipY_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionFlipY_TransitionFlipY(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionFlipAngular_class; +extern JSObject *jsb_cocos2d_TransitionFlipAngular_prototype; + +bool js_cocos2dx_TransitionFlipAngular_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionFlipAngular_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionFlipAngular(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionFlipAngular_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionFlipAngular_TransitionFlipAngular(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionZoomFlipX_class; +extern JSObject *jsb_cocos2d_TransitionZoomFlipX_prototype; + +bool js_cocos2dx_TransitionZoomFlipX_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionZoomFlipX_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionZoomFlipX(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionZoomFlipX_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionZoomFlipX_TransitionZoomFlipX(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionZoomFlipY_class; +extern JSObject *jsb_cocos2d_TransitionZoomFlipY_prototype; + +bool js_cocos2dx_TransitionZoomFlipY_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionZoomFlipY_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionZoomFlipY(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionZoomFlipY_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionZoomFlipY_TransitionZoomFlipY(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionZoomFlipAngular_class; +extern JSObject *jsb_cocos2d_TransitionZoomFlipAngular_prototype; + +bool js_cocos2dx_TransitionZoomFlipAngular_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionZoomFlipAngular_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionZoomFlipAngular(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionZoomFlipAngular_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionZoomFlipAngular_TransitionZoomFlipAngular(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionFade_class; +extern JSObject *jsb_cocos2d_TransitionFade_prototype; + +bool js_cocos2dx_TransitionFade_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionFade_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionFade(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionFade_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionFade_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionFade_TransitionFade(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionCrossFade_class; +extern JSObject *jsb_cocos2d_TransitionCrossFade_prototype; + +bool js_cocos2dx_TransitionCrossFade_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionCrossFade_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionCrossFade(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionCrossFade_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionCrossFade_TransitionCrossFade(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionTurnOffTiles_class; +extern JSObject *jsb_cocos2d_TransitionTurnOffTiles_prototype; + +bool js_cocos2dx_TransitionTurnOffTiles_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionTurnOffTiles_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionTurnOffTiles(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionTurnOffTiles_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionTurnOffTiles_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionTurnOffTiles_TransitionTurnOffTiles(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionSplitCols_class; +extern JSObject *jsb_cocos2d_TransitionSplitCols_prototype; + +bool js_cocos2dx_TransitionSplitCols_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionSplitCols_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionSplitCols(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionSplitCols_action(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionSplitCols_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionSplitCols_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionSplitCols_TransitionSplitCols(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionSplitRows_class; +extern JSObject *jsb_cocos2d_TransitionSplitRows_prototype; + +bool js_cocos2dx_TransitionSplitRows_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionSplitRows_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionSplitRows(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionSplitRows_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionSplitRows_TransitionSplitRows(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionFadeTR_class; +extern JSObject *jsb_cocos2d_TransitionFadeTR_prototype; + +bool js_cocos2dx_TransitionFadeTR_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionFadeTR_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionFadeTR(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionFadeTR_easeActionWithAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionFadeTR_actionWithSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionFadeTR_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionFadeTR_TransitionFadeTR(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionFadeBL_class; +extern JSObject *jsb_cocos2d_TransitionFadeBL_prototype; + +bool js_cocos2dx_TransitionFadeBL_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionFadeBL_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionFadeBL(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionFadeBL_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionFadeBL_TransitionFadeBL(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionFadeUp_class; +extern JSObject *jsb_cocos2d_TransitionFadeUp_prototype; + +bool js_cocos2dx_TransitionFadeUp_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionFadeUp_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionFadeUp(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionFadeUp_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionFadeUp_TransitionFadeUp(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionFadeDown_class; +extern JSObject *jsb_cocos2d_TransitionFadeDown_prototype; + +bool js_cocos2dx_TransitionFadeDown_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionFadeDown_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionFadeDown(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionFadeDown_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionFadeDown_TransitionFadeDown(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionPageTurn_class; +extern JSObject *jsb_cocos2d_TransitionPageTurn_prototype; + +bool js_cocos2dx_TransitionPageTurn_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionPageTurn_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionPageTurn(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionPageTurn_actionWithSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionPageTurn_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionPageTurn_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionPageTurn_TransitionPageTurn(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionProgress_class; +extern JSObject *jsb_cocos2d_TransitionProgress_prototype; + +bool js_cocos2dx_TransitionProgress_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionProgress_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionProgress(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionProgress_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionProgress_TransitionProgress(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionProgressRadialCCW_class; +extern JSObject *jsb_cocos2d_TransitionProgressRadialCCW_prototype; + +bool js_cocos2dx_TransitionProgressRadialCCW_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionProgressRadialCCW_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionProgressRadialCCW(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionProgressRadialCCW_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionProgressRadialCCW_TransitionProgressRadialCCW(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionProgressRadialCW_class; +extern JSObject *jsb_cocos2d_TransitionProgressRadialCW_prototype; + +bool js_cocos2dx_TransitionProgressRadialCW_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionProgressRadialCW_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionProgressRadialCW(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionProgressRadialCW_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionProgressRadialCW_TransitionProgressRadialCW(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionProgressHorizontal_class; +extern JSObject *jsb_cocos2d_TransitionProgressHorizontal_prototype; + +bool js_cocos2dx_TransitionProgressHorizontal_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionProgressHorizontal_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionProgressHorizontal(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionProgressHorizontal_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionProgressHorizontal_TransitionProgressHorizontal(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionProgressVertical_class; +extern JSObject *jsb_cocos2d_TransitionProgressVertical_prototype; + +bool js_cocos2dx_TransitionProgressVertical_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionProgressVertical_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionProgressVertical(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionProgressVertical_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionProgressVertical_TransitionProgressVertical(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionProgressInOut_class; +extern JSObject *jsb_cocos2d_TransitionProgressInOut_prototype; + +bool js_cocos2dx_TransitionProgressInOut_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionProgressInOut_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionProgressInOut(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionProgressInOut_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionProgressInOut_TransitionProgressInOut(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TransitionProgressOutIn_class; +extern JSObject *jsb_cocos2d_TransitionProgressOutIn_prototype; + +bool js_cocos2dx_TransitionProgressOutIn_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TransitionProgressOutIn_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TransitionProgressOutIn(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TransitionProgressOutIn_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TransitionProgressOutIn_TransitionProgressOutIn(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_MenuItem_class; +extern JSObject *jsb_cocos2d_MenuItem_prototype; + +bool js_cocos2dx_MenuItem_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_MenuItem_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_MenuItem(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_MenuItem_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItem_activate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItem_initWithCallback(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItem_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItem_selected(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItem_isSelected(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItem_unselected(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItem_rect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItem_MenuItem(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_MenuItemLabel_class; +extern JSObject *jsb_cocos2d_MenuItemLabel_prototype; + +bool js_cocos2dx_MenuItemLabel_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_MenuItemLabel_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_MenuItemLabel(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_MenuItemLabel_setLabel(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemLabel_getDisabledColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemLabel_setString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemLabel_initWithLabel(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemLabel_setDisabledColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemLabel_getLabel(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemLabel_MenuItemLabel(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_MenuItemAtlasFont_class; +extern JSObject *jsb_cocos2d_MenuItemAtlasFont_prototype; + +bool js_cocos2dx_MenuItemAtlasFont_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_MenuItemAtlasFont_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_MenuItemAtlasFont(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_MenuItemAtlasFont_initWithString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemAtlasFont_MenuItemAtlasFont(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_MenuItemFont_class; +extern JSObject *jsb_cocos2d_MenuItemFont_prototype; + +bool js_cocos2dx_MenuItemFont_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_MenuItemFont_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_MenuItemFont(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_MenuItemFont_setFontNameObj(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemFont_getFontSizeObj(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemFont_setFontSizeObj(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemFont_initWithString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemFont_getFontNameObj(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemFont_setFontName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemFont_getFontSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemFont_getFontName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemFont_setFontSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemFont_MenuItemFont(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_MenuItemSprite_class; +extern JSObject *jsb_cocos2d_MenuItemSprite_prototype; + +bool js_cocos2dx_MenuItemSprite_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_MenuItemSprite_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_MenuItemSprite(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_MenuItemSprite_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemSprite_selected(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemSprite_setNormalImage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemSprite_setDisabledImage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemSprite_initWithNormalSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemSprite_setSelectedImage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemSprite_getDisabledImage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemSprite_getSelectedImage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemSprite_getNormalImage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemSprite_unselected(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemSprite_MenuItemSprite(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_MenuItemImage_class; +extern JSObject *jsb_cocos2d_MenuItemImage_prototype; + +bool js_cocos2dx_MenuItemImage_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_MenuItemImage_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_MenuItemImage(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_MenuItemImage_setDisabledSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemImage_setSelectedSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemImage_setNormalSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemImage_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemImage_initWithNormalImage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemImage_MenuItemImage(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_MenuItemToggle_class; +extern JSObject *jsb_cocos2d_MenuItemToggle_prototype; + +bool js_cocos2dx_MenuItemToggle_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_MenuItemToggle_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_MenuItemToggle(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_MenuItemToggle_setSubItems(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemToggle_initWithItem(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemToggle_getSelectedIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemToggle_addSubItem(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemToggle_getSelectedItem(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemToggle_setSelectedIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MenuItemToggle_MenuItemToggle(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Menu_class; +extern JSObject *jsb_cocos2d_Menu_prototype; + +bool js_cocos2dx_Menu_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Menu_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Menu(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Menu_initWithArray(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Menu_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Menu_alignItemsVertically(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Menu_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Menu_alignItemsHorizontallyWithPadding(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Menu_alignItemsVerticallyWithPadding(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Menu_alignItemsHorizontally(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Menu_Menu(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ClippingNode_class; +extern JSObject *jsb_cocos2d_ClippingNode_prototype; + +bool js_cocos2dx_ClippingNode_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ClippingNode_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ClippingNode(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +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_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); + +extern JSClass *jsb_cocos2d_MotionStreak_class; +extern JSObject *jsb_cocos2d_MotionStreak_prototype; + +bool js_cocos2dx_MotionStreak_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_MotionStreak_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_MotionStreak(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_MotionStreak_reset(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MotionStreak_setTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MotionStreak_getTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MotionStreak_tintWithColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MotionStreak_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MotionStreak_setStartingPositionInitialized(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MotionStreak_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MotionStreak_isStartingPositionInitialized(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MotionStreak_isFastMode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MotionStreak_getStroke(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MotionStreak_initWithFade(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MotionStreak_setFastMode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MotionStreak_setStroke(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MotionStreak_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_MotionStreak_MotionStreak(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ProgressTimer_class; +extern JSObject *jsb_cocos2d_ProgressTimer_prototype; + +bool js_cocos2dx_ProgressTimer_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ProgressTimer_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ProgressTimer(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ProgressTimer_initWithSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProgressTimer_isReverseDirection(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProgressTimer_setBarChangeRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProgressTimer_getPercentage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProgressTimer_setSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProgressTimer_getType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProgressTimer_getSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProgressTimer_setMidpoint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProgressTimer_getBarChangeRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProgressTimer_setReverseDirection(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProgressTimer_getMidpoint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProgressTimer_setPercentage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProgressTimer_setType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProgressTimer_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ProgressTimer_ProgressTimer(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Sprite_class; +extern JSObject *jsb_cocos2d_Sprite_prototype; + +bool js_cocos2dx_Sprite_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Sprite_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Sprite(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Sprite_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_setTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_getTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_setFlippedY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_setFlippedX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_setRotationSkewX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_setRotationSkewY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_getBatchNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_getOffsetPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_setTextureRect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_initWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_isFrameDisplayed(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_getAtlasIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_setBatchNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_setDisplayFrameWithAnimationName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_getSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_isDirty(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_setAtlasIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_setDirty(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_isTextureRectRotated(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_getTextureRect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_initWithFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_getTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_initWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_isFlippedX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_isFlippedY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_setVertexRect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_createWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_createWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_Sprite(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Image_class; +extern JSObject *jsb_cocos2d_Image_prototype; + +bool js_cocos2dx_Image_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Image_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Image(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Image_hasPremultipliedAlpha(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_getDataLen(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_saveToFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_hasAlpha(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_isCompressed(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_getHeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_initWithImageFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_getWidth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_getBitPerPixel(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_getFileType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_getNumberOfMipmaps(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_getRenderFormat(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_getData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_getMipmaps(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_initWithRawData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_Image(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_RenderTexture_class; +extern JSObject *jsb_cocos2d_RenderTexture_prototype; + +bool js_cocos2dx_RenderTexture_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_RenderTexture_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_RenderTexture(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_RenderTexture_setVirtualViewport(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_clearStencil(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_getClearDepth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_getClearStencil(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_end(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_setClearStencil(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_setSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_getSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_isAutoDraw(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_setKeepMatrix(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_setClearFlags(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_begin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_setAutoDraw(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_setClearColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_endToLua(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_beginWithClear(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_clearDepth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_getClearColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_clear(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_getClearFlags(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_newImage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_setClearDepth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_initWithWidthAndHeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_RenderTexture_RenderTexture(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_NodeGrid_class; +extern JSObject *jsb_cocos2d_NodeGrid_prototype; + +bool js_cocos2dx_NodeGrid_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_NodeGrid_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_NodeGrid(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_NodeGrid_setTarget(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_NodeGrid_getGrid(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_NodeGrid_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_NodeGrid_NodeGrid(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ParticleBatchNode_class; +extern JSObject *jsb_cocos2d_ParticleBatchNode_prototype; + +bool js_cocos2dx_ParticleBatchNode_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ParticleBatchNode_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ParticleBatchNode(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ParticleBatchNode_setTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleBatchNode_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleBatchNode_disableParticle(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleBatchNode_getTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleBatchNode_setTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleBatchNode_initWithFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleBatchNode_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleBatchNode_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleBatchNode_getTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleBatchNode_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleBatchNode_insertChild(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleBatchNode_removeChildAtIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleBatchNode_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleBatchNode_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleBatchNode_ParticleBatchNode(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ParticleSystem_class; +extern JSObject *jsb_cocos2d_ParticleSystem_prototype; + +bool js_cocos2dx_ParticleSystem_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ParticleSystem_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ParticleSystem(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ParticleSystem_getStartSizeVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_isFull(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getBatchNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getStartColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getPositionType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setPosVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getEndSpin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setRotatePerSecondVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getStartSpinVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getRadialAccelVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getEndSizeVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setTangentialAccel(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getRadialAccel(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setStartRadius(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setRotatePerSecond(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setEndSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getGravity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getTangentialAccel(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setEndRadius(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getSpeed(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getAngle(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setEndColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setStartSpin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getPosVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_updateWithNoTime(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_isBlendAdditive(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getSpeedVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setPositionType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_stopSystem(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getSourcePosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setLifeVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setEndColorVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_updateQuadWithParticle(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getAtlasIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getStartSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setStartSpinVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_resetSystem(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setAtlasIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setTangentialAccelVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setEndRadiusVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getEndRadius(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_isActive(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setRadialAccelVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setStartSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setSpeed(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getStartSpin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getRotatePerSecond(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_initParticle(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setEmitterMode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setSourcePosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getEndSpinVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setBlendAdditive(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setLife(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setAngleVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setRotationIsDir(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setEndSizeVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setAngle(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setBatchNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getTangentialAccelVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getEmitterMode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setEndSpinVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_initWithFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getAngleVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setStartColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getRotatePerSecondVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getEndSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getLife(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setSpeedVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setAutoRemoveOnFinish(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setGravity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_postStep(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setEmissionRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getEndColorVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getRotationIsDir(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getEmissionRate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getEndColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getLifeVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setStartSizeVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_addParticle(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getStartRadius(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getParticleCount(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getStartRadiusVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setStartColorVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setEndSpin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setRadialAccel(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_initWithDictionary(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_isAutoRemoveOnFinish(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setStartRadiusVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getEndRadiusVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_getStartColorVar(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystem_ParticleSystem(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ParticleSystemQuad_class; +extern JSObject *jsb_cocos2d_ParticleSystemQuad_prototype; + +bool js_cocos2dx_ParticleSystemQuad_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ParticleSystemQuad_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ParticleSystemQuad(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ParticleSystemQuad_setDisplayFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystemQuad_setTextureWithRect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystemQuad_listenRendererRecreated(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystemQuad_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystemQuad_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSystemQuad_ParticleSystemQuad(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ParticleFire_class; +extern JSObject *jsb_cocos2d_ParticleFire_prototype; + +bool js_cocos2dx_ParticleFire_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ParticleFire_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ParticleFire(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ParticleFire_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleFire_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleFire_ParticleFire(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ParticleFireworks_class; +extern JSObject *jsb_cocos2d_ParticleFireworks_prototype; + +bool js_cocos2dx_ParticleFireworks_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ParticleFireworks_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ParticleFireworks(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ParticleFireworks_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleFireworks_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleFireworks_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleFireworks_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleFireworks_ParticleFireworks(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ParticleSun_class; +extern JSObject *jsb_cocos2d_ParticleSun_prototype; + +bool js_cocos2dx_ParticleSun_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ParticleSun_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ParticleSun(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ParticleSun_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSun_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSun_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSun_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSun_ParticleSun(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ParticleGalaxy_class; +extern JSObject *jsb_cocos2d_ParticleGalaxy_prototype; + +bool js_cocos2dx_ParticleGalaxy_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ParticleGalaxy_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ParticleGalaxy(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ParticleGalaxy_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleGalaxy_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleGalaxy_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleGalaxy_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleGalaxy_ParticleGalaxy(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ParticleFlower_class; +extern JSObject *jsb_cocos2d_ParticleFlower_prototype; + +bool js_cocos2dx_ParticleFlower_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ParticleFlower_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ParticleFlower(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ParticleFlower_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleFlower_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleFlower_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleFlower_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleFlower_ParticleFlower(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ParticleMeteor_class; +extern JSObject *jsb_cocos2d_ParticleMeteor_prototype; + +bool js_cocos2dx_ParticleMeteor_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ParticleMeteor_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ParticleMeteor(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ParticleMeteor_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleMeteor_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleMeteor_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleMeteor_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleMeteor_ParticleMeteor(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ParticleSpiral_class; +extern JSObject *jsb_cocos2d_ParticleSpiral_prototype; + +bool js_cocos2dx_ParticleSpiral_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ParticleSpiral_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ParticleSpiral(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ParticleSpiral_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSpiral_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSpiral_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSpiral_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSpiral_ParticleSpiral(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ParticleExplosion_class; +extern JSObject *jsb_cocos2d_ParticleExplosion_prototype; + +bool js_cocos2dx_ParticleExplosion_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ParticleExplosion_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ParticleExplosion(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ParticleExplosion_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleExplosion_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleExplosion_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleExplosion_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleExplosion_ParticleExplosion(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ParticleSmoke_class; +extern JSObject *jsb_cocos2d_ParticleSmoke_prototype; + +bool js_cocos2dx_ParticleSmoke_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ParticleSmoke_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ParticleSmoke(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ParticleSmoke_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSmoke_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSmoke_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSmoke_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSmoke_ParticleSmoke(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ParticleSnow_class; +extern JSObject *jsb_cocos2d_ParticleSnow_prototype; + +bool js_cocos2dx_ParticleSnow_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ParticleSnow_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ParticleSnow(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ParticleSnow_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSnow_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSnow_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSnow_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleSnow_ParticleSnow(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ParticleRain_class; +extern JSObject *jsb_cocos2d_ParticleRain_prototype; + +bool js_cocos2dx_ParticleRain_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ParticleRain_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ParticleRain(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ParticleRain_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleRain_initWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleRain_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleRain_createWithTotalParticles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParticleRain_ParticleRain(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_GridBase_class; +extern JSObject *jsb_cocos2d_GridBase_prototype; + +bool js_cocos2dx_GridBase_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_GridBase_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_GridBase(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_GridBase_setGridSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridBase_afterBlit(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridBase_afterDraw(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridBase_beforeDraw(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridBase_calculateVertexPoints(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridBase_isTextureFlipped(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridBase_getGridSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridBase_getStep(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridBase_set2DProjection(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridBase_setStep(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridBase_setTextureFlipped(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridBase_blit(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridBase_setActive(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridBase_getReuseGrid(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridBase_initWithSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridBase_beforeBlit(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridBase_setReuseGrid(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridBase_isActive(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridBase_reuse(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GridBase_create(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Grid3D_class; +extern JSObject *jsb_cocos2d_Grid3D_prototype; + +bool js_cocos2dx_Grid3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Grid3D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Grid3D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Grid3D_getNeedDepthTestForBlit(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Grid3D_setNeedDepthTestForBlit(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Grid3D_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Grid3D_Grid3D(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TiledGrid3D_class; +extern JSObject *jsb_cocos2d_TiledGrid3D_prototype; + +bool js_cocos2dx_TiledGrid3D_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TiledGrid3D_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TiledGrid3D(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TiledGrid3D_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TiledGrid3D_TiledGrid3D(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Camera_class; +extern JSObject *jsb_cocos2d_Camera_prototype; + +bool js_cocos2dx_Camera_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Camera_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Camera(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Camera_setScene(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_initPerspective(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_getProjectionMatrix(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_getViewProjectionMatrix(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_getViewMatrix(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_getCameraFlag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_getType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_initDefault(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_project(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_getDepthInView(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_lookAt(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_setCameraFlag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_initOrthographic(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_setAdditionalProjection(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_getDepth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_setDepth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_createPerspective(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_createOrthographic(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_getDefaultCamera(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_getVisitingCamera(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Camera_Camera(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_BaseLight_class; +extern JSObject *jsb_cocos2d_BaseLight_prototype; + +bool js_cocos2dx_BaseLight_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_BaseLight_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_BaseLight(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_BaseLight_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_BaseLight_getIntensity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_BaseLight_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_BaseLight_getLightType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_BaseLight_setLightFlag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_BaseLight_setIntensity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_BaseLight_getLightFlag(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_DirectionLight_class; +extern JSObject *jsb_cocos2d_DirectionLight_prototype; + +bool js_cocos2dx_DirectionLight_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_DirectionLight_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_DirectionLight(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_DirectionLight_getDirection(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DirectionLight_getDirectionInWorld(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DirectionLight_setDirection(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DirectionLight_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_DirectionLight_DirectionLight(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_PointLight_class; +extern JSObject *jsb_cocos2d_PointLight_prototype; + +bool js_cocos2dx_PointLight_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_PointLight_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_PointLight(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_PointLight_getRange(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_PointLight_setRange(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_PointLight_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_PointLight_PointLight(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_SpotLight_class; +extern JSObject *jsb_cocos2d_SpotLight_prototype; + +bool js_cocos2dx_SpotLight_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_SpotLight_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_SpotLight(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_SpotLight_getRange(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpotLight_setDirection(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpotLight_getCosInnerAngle(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpotLight_getOuterAngle(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpotLight_getInnerAngle(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpotLight_getDirection(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpotLight_getCosOuterAngle(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpotLight_setOuterAngle(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpotLight_setInnerAngle(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpotLight_getDirectionInWorld(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpotLight_setRange(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpotLight_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpotLight_SpotLight(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_AmbientLight_class; +extern JSObject *jsb_cocos2d_AmbientLight_prototype; + +bool js_cocos2dx_AmbientLight_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_AmbientLight_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_AmbientLight(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_AmbientLight_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AmbientLight_AmbientLight(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_GLProgram_class; +extern JSObject *jsb_cocos2d_GLProgram_prototype; + +bool js_cocos2dx_GLProgram_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_GLProgram_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_GLProgram(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_GLProgram_getFragmentShaderLog(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgram_bindAttribLocation(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_setUniformLocationWith4f(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgram_updateUniforms(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_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); +bool js_cocos2dx_GLProgram_createWithByteArrays(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgram_createWithFilenames(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgram_GLProgram(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_GLProgramCache_class; +extern JSObject *jsb_cocos2d_GLProgramCache_prototype; + +bool js_cocos2dx_GLProgramCache_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_GLProgramCache_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_GLProgramCache(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_GLProgramCache_reloadDefaultGLPrograms(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramCache_addGLProgram(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramCache_getGLProgram(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramCache_loadDefaultGLPrograms(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramCache_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramCache_getInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramCache_GLProgramCache(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TextureCache_class; +extern JSObject *jsb_cocos2d_TextureCache_prototype; + +bool js_cocos2dx_TextureCache_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TextureCache_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TextureCache(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TextureCache_reloadTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextureCache_unbindAllImageAsync(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextureCache_removeTextureForKey(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextureCache_removeAllTextures(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextureCache_addImageAsync(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextureCache_getDescription(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextureCache_getCachedTextureInfo(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextureCache_addImage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextureCache_unbindImageAsync(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextureCache_getTextureForKey(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextureCache_removeUnusedTextures(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextureCache_removeTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextureCache_waitForQuit(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextureCache_TextureCache(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Device_class; +extern JSObject *jsb_cocos2d_Device_prototype; + +bool js_cocos2dx_Device_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Device_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Device(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Device_setAccelerometerEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Device_setKeepScreenOn(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Device_setAccelerometerInterval(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Device_getDPI(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_SAXParser_class; +extern JSObject *jsb_cocos2d_SAXParser_prototype; + +bool js_cocos2dx_SAXParser_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_SAXParser_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_SAXParser(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_SAXParser_init(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Application_class; +extern JSObject *jsb_cocos2d_Application_prototype; + +bool js_cocos2dx_Application_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Application_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Application(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Application_openURL(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Application_getTargetPlatform(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Application_getCurrentLanguage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Application_getInstance(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_AnimationCache_class; +extern JSObject *jsb_cocos2d_AnimationCache_prototype; + +bool js_cocos2dx_AnimationCache_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_AnimationCache_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_AnimationCache(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_AnimationCache_getAnimation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AnimationCache_addAnimation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AnimationCache_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AnimationCache_addAnimationsWithDictionary(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AnimationCache_removeAnimation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AnimationCache_addAnimationsWithFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AnimationCache_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AnimationCache_getInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_AnimationCache_AnimationCache(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_SpriteFrameCache_class; +extern JSObject *jsb_cocos2d_SpriteFrameCache_prototype; + +bool js_cocos2dx_SpriteFrameCache_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_SpriteFrameCache_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_SpriteFrameCache(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFileContent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrameCache_addSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrameCache_addSpriteFramesWithFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrameCache_getSpriteFrameByName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrameCache_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrameCache_removeSpriteFrames(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrameCache_removeUnusedSpriteFrames(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromFileContent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrameCache_removeSpriteFrameByName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrameCache_isSpriteFramesWithFileLoaded(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrameCache_removeSpriteFramesFromTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrameCache_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SpriteFrameCache_getInstance(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TextFieldTTF_class; +extern JSObject *jsb_cocos2d_TextFieldTTF_prototype; + +bool js_cocos2dx_TextFieldTTF_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TextFieldTTF_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TextFieldTTF(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TextFieldTTF_getCharCount(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextFieldTTF_setSecureTextEntry(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextFieldTTF_getColorSpaceHolder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextFieldTTF_initWithPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextFieldTTF_setColorSpaceHolder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextFieldTTF_detachWithIME(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextFieldTTF_setPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextFieldTTF_isSecureTextEntry(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextFieldTTF_getPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextFieldTTF_attachWithIME(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextFieldTTF_textFieldWithPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TextFieldTTF_TextFieldTTF(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ParallaxNode_class; +extern JSObject *jsb_cocos2d_ParallaxNode_prototype; + +bool js_cocos2dx_ParallaxNode_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ParallaxNode_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ParallaxNode(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ParallaxNode_getParallaxArray(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParallaxNode_addChild(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParallaxNode_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParallaxNode_setParallaxArray(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParallaxNode_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ParallaxNode_ParallaxNode(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TMXObjectGroup_class; +extern JSObject *jsb_cocos2d_TMXObjectGroup_prototype; + +bool js_cocos2dx_TMXObjectGroup_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TMXObjectGroup_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TMXObjectGroup(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TMXObjectGroup_setPositionOffset(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXObjectGroup_getProperty(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXObjectGroup_getPositionOffset(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXObjectGroup_getObject(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXObjectGroup_getObjects(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXObjectGroup_setGroupName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXObjectGroup_getProperties(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXObjectGroup_getGroupName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXObjectGroup_setProperties(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXObjectGroup_setObjects(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXObjectGroup_TMXObjectGroup(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TMXLayerInfo_class; +extern JSObject *jsb_cocos2d_TMXLayerInfo_prototype; + +bool js_cocos2dx_TMXLayerInfo_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TMXLayerInfo_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TMXLayerInfo(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TMXLayerInfo_setProperties(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayerInfo_getProperties(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayerInfo_TMXLayerInfo(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TMXTilesetInfo_class; +extern JSObject *jsb_cocos2d_TMXTilesetInfo_prototype; + +bool js_cocos2dx_TMXTilesetInfo_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TMXTilesetInfo_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TMXTilesetInfo(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TMXTilesetInfo_getRectForGID(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXTilesetInfo_TMXTilesetInfo(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TMXMapInfo_class; +extern JSObject *jsb_cocos2d_TMXMapInfo_prototype; + +bool js_cocos2dx_TMXMapInfo_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TMXMapInfo_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TMXMapInfo(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TMXMapInfo_setObjectGroups(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_setTileSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_initWithTMXFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_getOrientation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_isStoringCharacters(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_setLayers(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_parseXMLFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_getParentElement(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_setTMXFileName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_parseXMLString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_getLayers(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_getTilesets(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_getParentGID(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_setParentElement(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_initWithXML(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_setParentGID(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_getLayerAttribs(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_getTileSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_getTileProperties(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_getObjectGroups(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_getTMXFileName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_setCurrentString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_setProperties(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_setOrientation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_setTileProperties(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_setMapSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_setStoringCharacters(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_getMapSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_setTilesets(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_getProperties(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_getCurrentString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_setLayerAttribs(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_createWithXML(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXMapInfo_TMXMapInfo(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TMXLayer_class; +extern JSObject *jsb_cocos2d_TMXLayer_prototype; + +bool js_cocos2dx_TMXLayer_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TMXLayer_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TMXLayer(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TMXLayer_getTileGIDAt(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_getPositionAt(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_setLayerOrientation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_releaseMap(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_setTiles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_getLayerSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_setMapTileSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_getLayerOrientation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_setProperties(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_setLayerName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_removeTileAt(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_initWithTilesetInfo(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_setupTiles(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_setTileGID(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_getMapTileSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_getProperty(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_setLayerSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_getLayerName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_setTileSet(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_getTileSet(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_getProperties(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_getTileAt(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXLayer_TMXLayer(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TMXTiledMap_class; +extern JSObject *jsb_cocos2d_TMXTiledMap_prototype; + +bool js_cocos2dx_TMXTiledMap_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TMXTiledMap_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TMXTiledMap(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TMXTiledMap_setObjectGroups(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXTiledMap_getProperty(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXTiledMap_setMapSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXTiledMap_getObjectGroup(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXTiledMap_getObjectGroups(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXTiledMap_initWithXML(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXTiledMap_initWithTMXFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXTiledMap_getTileSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXTiledMap_getMapSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXTiledMap_getProperties(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXTiledMap_getPropertiesForGID(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXTiledMap_setTileSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXTiledMap_setProperties(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXTiledMap_getLayer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXTiledMap_getMapOrientation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXTiledMap_setMapOrientation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXTiledMap_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXTiledMap_createWithXML(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TMXTiledMap_TMXTiledMap(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_TileMapAtlas_class; +extern JSObject *jsb_cocos2d_TileMapAtlas_prototype; + +bool js_cocos2dx_TileMapAtlas_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_TileMapAtlas_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_TileMapAtlas(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_TileMapAtlas_initWithTileFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TileMapAtlas_releaseMap(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TileMapAtlas_getTGAInfo(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TileMapAtlas_getTileAt(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TileMapAtlas_setTile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TileMapAtlas_setTGAInfo(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TileMapAtlas_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_TileMapAtlas_TileMapAtlas(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_Component_class; +extern JSObject *jsb_cocos2d_Component_prototype; + +bool js_cocos2dx_Component_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Component_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Component(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Component_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Component_setName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Component_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Component_update(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Component_getOwner(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Component_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Component_setOwner(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Component_getName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Component_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Component_Component(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ComponentContainer_class; +extern JSObject *jsb_cocos2d_ComponentContainer_prototype; + +bool js_cocos2dx_ComponentContainer_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ComponentContainer_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ComponentContainer(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ComponentContainer_visit(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ComponentContainer_remove(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ComponentContainer_removeAll(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ComponentContainer_add(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ComponentContainer_isEmpty(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ComponentContainer_get(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_CocosDenshion_SimpleAudioEngine_class; +extern JSObject *jsb_CocosDenshion_SimpleAudioEngine_prototype; + +bool js_cocos2dx_SimpleAudioEngine_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_SimpleAudioEngine_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_SimpleAudioEngine(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_SimpleAudioEngine_preloadBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_stopBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_stopAllEffects(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_getBackgroundMusicVolume(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_resumeBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_setBackgroundMusicVolume(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_preloadEffect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_isBackgroundMusicPlaying(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_getEffectsVolume(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_willPlayBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_pauseEffect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_playEffect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_rewindBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_playBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_resumeAllEffects(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_setEffectsVolume(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_stopEffect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_pauseBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_pauseAllEffects(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_unloadEffect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_resumeEffect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_end(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_SimpleAudioEngine_getInstance(JSContext *cx, uint32_t argc, jsval *vp); +#endif + diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_builder_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_builder_auto.cpp new file mode 100644 index 0000000000..eac168bf35 --- /dev/null +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_builder_auto.cpp @@ -0,0 +1,1776 @@ +#include "jsb_cocos2dx_builder_auto.hpp" +#include "cocos2d_specifics.hpp" +#include "CocosBuilder.h" + +template +static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedValue initializing(cx); + bool isNewValid = true; + JS::RootedObject global(cx, ScriptingCore::getInstance()->getGlobalObject()); + isNewValid = JS_GetProperty(cx, global, "initializing", &initializing) && initializing.toBoolean(); + if (isNewValid) + { + 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."); + + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + + args.rval().set(OBJECT_TO_JSVAL(_tmp)); + return true; + } + + JS_ReportError(cx, "Constructor for the requested class is not available, please refer to the API reference."); + return false; +} + +static bool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) { + return false; +} + +static bool js_is_native_obj(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().setBoolean(true); + return true; +} +JSClass *jsb_cocosbuilder_CCBAnimationManager_class; +JSObject *jsb_cocosbuilder_CCBAnimationManager_prototype; + +bool js_cocos2dx_builder_CCBAnimationManager_moveAnimationsFromNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_moveAnimationsFromNode : Invalid Native Object"); + if (argc == 2) { + cocos2d::Node* arg0; + cocos2d::Node* arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_moveAnimationsFromNode : Error processing arguments"); + cobj->moveAnimationsFromNode(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_moveAnimationsFromNode : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_setAutoPlaySequenceId(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_setAutoPlaySequenceId : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_setAutoPlaySequenceId : Error processing arguments"); + cobj->setAutoPlaySequenceId(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_setAutoPlaySequenceId : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNames(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNames : Invalid Native Object"); + if (argc == 0) { + cocos2d::ValueVector& ret = cobj->getDocumentCallbackNames(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluevector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNames : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_actionForSoundChannel(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_actionForSoundChannel : Invalid Native Object"); + if (argc == 1) { + cocosbuilder::CCBSequenceProperty* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocosbuilder::CCBSequenceProperty*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_actionForSoundChannel : Error processing arguments"); + cocos2d::Sequence* ret = cobj->actionForSoundChannel(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sequence*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_actionForSoundChannel : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_setBaseValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_setBaseValue : Invalid Native Object"); + if (argc == 3) { + cocos2d::Value arg0; + cocos2d::Node* arg1; + std::string arg2; + ok &= jsval_to_ccvalue(cx, args.get(0), &arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_setBaseValue : Error processing arguments"); + cobj->setBaseValue(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_setBaseValue : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNodes(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNodes : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vector& ret = cobj->getDocumentOutletNodes(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNodes : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_getLastCompletedSequenceName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_getLastCompletedSequenceName : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getLastCompletedSequenceName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getLastCompletedSequenceName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_setRootNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_setRootNode : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_setRootNode : Error processing arguments"); + cobj->setRootNode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_setRootNode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamedTweenDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamedTweenDuration : Invalid Native Object"); + if (argc == 2) { + const char* arg0; + double arg1; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamedTweenDuration : Error processing arguments"); + cobj->runAnimationsForSequenceNamedTweenDuration(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamedTweenDuration : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletName : Error processing arguments"); + cobj->addDocumentOutletName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_getRootContainerSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_getRootContainerSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getRootContainerSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getRootContainerSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_setDocumentControllerName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_setDocumentControllerName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_setDocumentControllerName : Error processing arguments"); + cobj->setDocumentControllerName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_setDocumentControllerName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_setObject(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_setObject : Invalid Native Object"); + if (argc == 3) { + cocos2d::Ref* arg0; + cocos2d::Node* arg1; + std::string arg2; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_setObject : Error processing arguments"); + cobj->setObject(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_setObject : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_getContainerSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_getContainerSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_getContainerSize : Error processing arguments"); + const cocos2d::Size& ret = cobj->getContainerSize(arg0); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getContainerSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_actionForCallbackChannel(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_actionForCallbackChannel : Invalid Native Object"); + if (argc == 1) { + cocosbuilder::CCBSequenceProperty* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocosbuilder::CCBSequenceProperty*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_actionForCallbackChannel : Error processing arguments"); + cocos2d::Sequence* ret = cobj->actionForCallbackChannel(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sequence*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_actionForCallbackChannel : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNames(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNames : Invalid Native Object"); + if (argc == 0) { + cocos2d::ValueVector& ret = cobj->getDocumentOutletNames(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluevector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNames : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackControlEvents : Invalid Native Object"); + if (argc == 1) { + cocos2d::extension::Control::EventType arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackControlEvents : Error processing arguments"); + cobj->addDocumentCallbackControlEvents(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackControlEvents : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_getKeyframeCallbacks(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_getKeyframeCallbacks : Invalid Native Object"); + if (argc == 0) { + cocos2d::ValueVector& ret = cobj->getKeyframeCallbacks(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluevector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getKeyframeCallbacks : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackControlEvents : Invalid Native Object"); + if (argc == 0) { + cocos2d::ValueVector& ret = cobj->getDocumentCallbackControlEvents(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluevector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackControlEvents : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_setRootContainerSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_setRootContainerSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_setRootContainerSize : Error processing arguments"); + cobj->setRootContainerSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_setRootContainerSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceIdTweenDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceIdTweenDuration : Invalid Native Object"); + if (argc == 2) { + int arg0; + double arg1; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceIdTweenDuration : Error processing arguments"); + cobj->runAnimationsForSequenceIdTweenDuration(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceIdTweenDuration : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_getRunningSequenceName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_getRunningSequenceName : Invalid Native Object"); + if (argc == 0) { + const char* ret = cobj->getRunningSequenceName(); + jsval jsret = JSVAL_NULL; + jsret = c_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getRunningSequenceName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_getAutoPlaySequenceId(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_getAutoPlaySequenceId : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getAutoPlaySequenceId(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getAutoPlaySequenceId : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackName : Error processing arguments"); + cobj->addDocumentCallbackName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_getRootNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_getRootNode : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getRootNode(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getRootNode : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletNode : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletNode : Error processing arguments"); + cobj->addDocumentOutletNode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletNode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_setDelegate : Invalid Native Object"); + if (argc == 1) { + cocosbuilder::CCBAnimationManagerDelegate* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocosbuilder::CCBAnimationManagerDelegate*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_setDelegate : Error processing arguments"); + cobj->setDelegate(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_setDelegate : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_getSequenceDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_getSequenceDuration : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_getSequenceDuration : Error processing arguments"); + double ret = cobj->getSequenceDuration(arg0); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getSequenceDuration : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackNode : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackNode : Error processing arguments"); + cobj->addDocumentCallbackNode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackNode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamed(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamed : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamed : Error processing arguments"); + cobj->runAnimationsForSequenceNamed(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamed : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_getSequenceId(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_getSequenceId : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_getSequenceId : Error processing arguments"); + int ret = cobj->getSequenceId(arg0); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getSequenceId : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_setCallFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_setCallFunc : Invalid Native Object"); + if (argc == 2) { + cocos2d::CallFunc* arg0; + std::string arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::CallFunc*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_setCallFunc : Error processing arguments"); + cobj->setCallFunc(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_setCallFunc : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNodes(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNodes : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vector& ret = cobj->getDocumentCallbackNodes(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNodes : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_setSequences(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_setSequences : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vector arg0; + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBAnimationManager_setSequences : Error processing arguments"); + cobj->setSequences(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_setSequences : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_debug(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_debug : Invalid Native Object"); + if (argc == 0) { + cobj->debug(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_debug : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_getDocumentControllerName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager* cobj = (cocosbuilder::CCBAnimationManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBAnimationManager_getDocumentControllerName : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getDocumentControllerName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBAnimationManager_getDocumentControllerName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBAnimationManager_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocosbuilder::CCBAnimationManager* cobj = new (std::nothrow) cocosbuilder::CCBAnimationManager(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocosbuilder::CCBAnimationManager"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocosbuilder_CCBAnimationManager_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (CCBAnimationManager)", obj); +} + +void js_register_cocos2dx_builder_CCBAnimationManager(JSContext *cx, JS::HandleObject global) { + jsb_cocosbuilder_CCBAnimationManager_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocosbuilder_CCBAnimationManager_class->name = "BuilderAnimationManager"; + jsb_cocosbuilder_CCBAnimationManager_class->addProperty = JS_PropertyStub; + jsb_cocosbuilder_CCBAnimationManager_class->delProperty = JS_DeletePropertyStub; + jsb_cocosbuilder_CCBAnimationManager_class->getProperty = JS_PropertyStub; + jsb_cocosbuilder_CCBAnimationManager_class->setProperty = JS_StrictPropertyStub; + jsb_cocosbuilder_CCBAnimationManager_class->enumerate = JS_EnumerateStub; + jsb_cocosbuilder_CCBAnimationManager_class->resolve = JS_ResolveStub; + jsb_cocosbuilder_CCBAnimationManager_class->convert = JS_ConvertStub; + jsb_cocosbuilder_CCBAnimationManager_class->finalize = js_cocosbuilder_CCBAnimationManager_finalize; + jsb_cocosbuilder_CCBAnimationManager_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("moveAnimationsFromNode", js_cocos2dx_builder_CCBAnimationManager_moveAnimationsFromNode, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAutoPlaySequenceId", js_cocos2dx_builder_CCBAnimationManager_setAutoPlaySequenceId, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDocumentCallbackNames", js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNames, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("actionForSoundChannel", js_cocos2dx_builder_CCBAnimationManager_actionForSoundChannel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBaseValue", js_cocos2dx_builder_CCBAnimationManager_setBaseValue, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDocumentOutletNodes", js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNodes, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLastCompletedSequenceName", js_cocos2dx_builder_CCBAnimationManager_getLastCompletedSequenceName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRootNode", js_cocos2dx_builder_CCBAnimationManager_setRootNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("runAnimationsForSequenceNamedTweenDuration", js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamedTweenDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addDocumentOutletName", js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRootContainerSize", js_cocos2dx_builder_CCBAnimationManager_getRootContainerSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDocumentControllerName", js_cocos2dx_builder_CCBAnimationManager_setDocumentControllerName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setObject", js_cocos2dx_builder_CCBAnimationManager_setObject, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getContainerSize", js_cocos2dx_builder_CCBAnimationManager_getContainerSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("actionForCallbackChannel", js_cocos2dx_builder_CCBAnimationManager_actionForCallbackChannel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDocumentOutletNames", js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNames, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addDocumentCallbackControlEvents", js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackControlEvents, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_builder_CCBAnimationManager_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getKeyframeCallbacks", js_cocos2dx_builder_CCBAnimationManager_getKeyframeCallbacks, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDocumentCallbackControlEvents", js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackControlEvents, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRootContainerSize", js_cocos2dx_builder_CCBAnimationManager_setRootContainerSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("runAnimationsForSequenceIdTweenDuration", js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceIdTweenDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRunningSequenceName", js_cocos2dx_builder_CCBAnimationManager_getRunningSequenceName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAutoPlaySequenceId", js_cocos2dx_builder_CCBAnimationManager_getAutoPlaySequenceId, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addDocumentCallbackName", js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRootNode", js_cocos2dx_builder_CCBAnimationManager_getRootNode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addDocumentOutletNode", js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDelegate", js_cocos2dx_builder_CCBAnimationManager_setDelegate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSequenceDuration", js_cocos2dx_builder_CCBAnimationManager_getSequenceDuration, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addDocumentCallbackNode", js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("runAnimationsForSequenceNamed", js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamed, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSequenceId", js_cocos2dx_builder_CCBAnimationManager_getSequenceId, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCallFunc", js_cocos2dx_builder_CCBAnimationManager_setCallFunc, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDocumentCallbackNodes", js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNodes, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSequences", js_cocos2dx_builder_CCBAnimationManager_setSequences, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("debug", js_cocos2dx_builder_CCBAnimationManager_debug, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDocumentControllerName", js_cocos2dx_builder_CCBAnimationManager_getDocumentControllerName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocosbuilder_CCBAnimationManager_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocosbuilder_CCBAnimationManager_class, + js_cocos2dx_builder_CCBAnimationManager_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, "BuilderAnimationManager", 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_cocosbuilder_CCBAnimationManager_class; + p->proto = jsb_cocosbuilder_CCBAnimationManager_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocosbuilder_CCBReader_class; +JSObject *jsb_cocosbuilder_CCBReader_prototype; + +bool js_cocos2dx_builder_CCBReader_getAnimationManager(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBReader_getAnimationManager : Invalid Native Object"); + if (argc == 0) { + cocosbuilder::CCBAnimationManager* ret = cobj->getAnimationManager(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocosbuilder::CCBAnimationManager*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_getAnimationManager : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBReader_setAnimationManager(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBReader_setAnimationManager : Invalid Native Object"); + if (argc == 1) { + cocosbuilder::CCBAnimationManager* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocosbuilder::CCBAnimationManager*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBReader_setAnimationManager : Error processing arguments"); + cobj->setAnimationManager(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_setAnimationManager : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBReader_addOwnerOutletName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBReader_addOwnerOutletName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBReader_addOwnerOutletName : Error processing arguments"); + cobj->addOwnerOutletName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_addOwnerOutletName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBReader_getOwnerCallbackNames(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBReader_getOwnerCallbackNames : Invalid Native Object"); + if (argc == 0) { + cocos2d::ValueVector ret = cobj->getOwnerCallbackNames(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluevector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_getOwnerCallbackNames : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBReader_addDocumentCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBReader_addDocumentCallbackControlEvents : Invalid Native Object"); + if (argc == 1) { + cocos2d::extension::Control::EventType arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBReader_addDocumentCallbackControlEvents : Error processing arguments"); + cobj->addDocumentCallbackControlEvents(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_addDocumentCallbackControlEvents : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBReader_setCCBRootPath(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBReader_setCCBRootPath : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBReader_setCCBRootPath : Error processing arguments"); + cobj->setCCBRootPath(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_setCCBRootPath : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBReader_addOwnerOutletNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBReader_addOwnerOutletNode : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBReader_addOwnerOutletNode : Error processing arguments"); + cobj->addOwnerOutletNode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_addOwnerOutletNode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBReader_getOwnerCallbackNodes(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBReader_getOwnerCallbackNodes : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vector& ret = cobj->getOwnerCallbackNodes(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_getOwnerCallbackNodes : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBReader_readSoundKeyframesForSeq(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBReader_readSoundKeyframesForSeq : Invalid Native Object"); + if (argc == 1) { + cocosbuilder::CCBSequence* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocosbuilder::CCBSequence*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBReader_readSoundKeyframesForSeq : Error processing arguments"); + bool ret = cobj->readSoundKeyframesForSeq(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_readSoundKeyframesForSeq : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBReader_getCCBRootPath(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBReader_getCCBRootPath : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getCCBRootPath(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_getCCBRootPath : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBReader_getOwnerCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBReader_getOwnerCallbackControlEvents : Invalid Native Object"); + if (argc == 0) { + cocos2d::ValueVector& ret = cobj->getOwnerCallbackControlEvents(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluevector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_getOwnerCallbackControlEvents : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBReader_getOwnerOutletNodes(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBReader_getOwnerOutletNodes : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vector& ret = cobj->getOwnerOutletNodes(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_getOwnerOutletNodes : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBReader_readUTF8(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBReader_readUTF8 : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->readUTF8(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_readUTF8 : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBReader_addOwnerCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBReader_addOwnerCallbackControlEvents : Invalid Native Object"); + if (argc == 1) { + cocos2d::extension::Control::EventType arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBReader_addOwnerCallbackControlEvents : Error processing arguments"); + cobj->addOwnerCallbackControlEvents(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_addOwnerCallbackControlEvents : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBReader_getOwnerOutletNames(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBReader_getOwnerOutletNames : Invalid Native Object"); + if (argc == 0) { + cocos2d::ValueVector ret = cobj->getOwnerOutletNames(); + jsval jsret = JSVAL_NULL; + jsret = ccvaluevector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_getOwnerOutletNames : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBReader_readCallbackKeyframesForSeq(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBReader_readCallbackKeyframesForSeq : Invalid Native Object"); + if (argc == 1) { + cocosbuilder::CCBSequence* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocosbuilder::CCBSequence*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBReader_readCallbackKeyframesForSeq : Error processing arguments"); + bool ret = cobj->readCallbackKeyframesForSeq(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_readCallbackKeyframesForSeq : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_builder_CCBReader_getAnimationManagersForNodes(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBReader_getAnimationManagersForNodes : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vector& ret = cobj->getAnimationManagersForNodes(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_getAnimationManagersForNodes : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBReader_getNodesWithAnimationManagers(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocosbuilder::CCBReader* cobj = (cocosbuilder::CCBReader *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_builder_CCBReader_getNodesWithAnimationManagers : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vector& ret = cobj->getNodesWithAnimationManagers(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_getNodesWithAnimationManagers : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_builder_CCBReader_setResolutionScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_builder_CCBReader_setResolutionScale : Error processing arguments"); + cocosbuilder::CCBReader::setResolutionScale(arg0); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_setResolutionScale : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocosbuilder::CCBReader* cobj = NULL; + do { + if (argc == 1) { + cocosbuilder::CCBReader* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocosbuilder::CCBReader*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cobj = new (std::nothrow) cocosbuilder::CCBReader(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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocosbuilder::CCBReader"); + } + } while(0); + + do { + if (argc == 1) { + cocosbuilder::NodeLoaderLibrary* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cobj = new (std::nothrow) cocosbuilder::CCBReader(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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocosbuilder::CCBReader"); + } + } while(0); + + do { + if (argc == 2) { + cocosbuilder::NodeLoaderLibrary* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocosbuilder::CCBMemberVariableAssigner* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocosbuilder::CCBMemberVariableAssigner*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cobj = new (std::nothrow) cocosbuilder::CCBReader(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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocosbuilder::CCBReader"); + } + } while(0); + + do { + if (argc == 3) { + cocosbuilder::NodeLoaderLibrary* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocosbuilder::CCBMemberVariableAssigner* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocosbuilder::CCBMemberVariableAssigner*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocosbuilder::CCBSelectorResolver* arg2; + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocosbuilder::CCBSelectorResolver*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cobj = new (std::nothrow) cocosbuilder::CCBReader(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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocosbuilder::CCBReader"); + } + } while(0); + + do { + if (argc == 4) { + cocosbuilder::NodeLoaderLibrary* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocosbuilder::NodeLoaderLibrary*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocosbuilder::CCBMemberVariableAssigner* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocosbuilder::CCBMemberVariableAssigner*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocosbuilder::CCBSelectorResolver* arg2; + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocosbuilder::CCBSelectorResolver*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocosbuilder::NodeLoaderListener* arg3; + do { + if (!args.get(3).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(3).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg3 = (cocosbuilder::NodeLoaderListener*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cobj = new (std::nothrow) cocosbuilder::CCBReader(arg0, arg1, arg2, arg3); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocosbuilder::CCBReader"); + } + } while(0); + + do { + if (argc == 0) { + cobj = new (std::nothrow) cocosbuilder::CCBReader(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocosbuilder::CCBReader"); + } + } while(0); + + if (cobj) { + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + + args.rval().set(OBJECT_TO_JSVAL(obj)); + return true; + } + JS_ReportError(cx, "js_cocos2dx_builder_CCBReader_constructor : wrong number of arguments"); + return false; +} + + + +void js_cocosbuilder_CCBReader_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (CCBReader)", obj); +} + +void js_register_cocos2dx_builder_CCBReader(JSContext *cx, JS::HandleObject global) { + jsb_cocosbuilder_CCBReader_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocosbuilder_CCBReader_class->name = "_Reader"; + jsb_cocosbuilder_CCBReader_class->addProperty = JS_PropertyStub; + jsb_cocosbuilder_CCBReader_class->delProperty = JS_DeletePropertyStub; + jsb_cocosbuilder_CCBReader_class->getProperty = JS_PropertyStub; + jsb_cocosbuilder_CCBReader_class->setProperty = JS_StrictPropertyStub; + jsb_cocosbuilder_CCBReader_class->enumerate = JS_EnumerateStub; + jsb_cocosbuilder_CCBReader_class->resolve = JS_ResolveStub; + jsb_cocosbuilder_CCBReader_class->convert = JS_ConvertStub; + jsb_cocosbuilder_CCBReader_class->finalize = js_cocosbuilder_CCBReader_finalize; + jsb_cocosbuilder_CCBReader_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getAnimationManager", js_cocos2dx_builder_CCBReader_getAnimationManager, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAnimationManager", js_cocos2dx_builder_CCBReader_setAnimationManager, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addOwnerOutletName", js_cocos2dx_builder_CCBReader_addOwnerOutletName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOwnerCallbackNames", js_cocos2dx_builder_CCBReader_getOwnerCallbackNames, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addDocumentCallbackControlEvents", js_cocos2dx_builder_CCBReader_addDocumentCallbackControlEvents, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCCBRootPath", js_cocos2dx_builder_CCBReader_setCCBRootPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addOwnerOutletNode", js_cocos2dx_builder_CCBReader_addOwnerOutletNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOwnerCallbackNodes", js_cocos2dx_builder_CCBReader_getOwnerCallbackNodes, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("readSoundKeyframesForSeq", js_cocos2dx_builder_CCBReader_readSoundKeyframesForSeq, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCCBRootPath", js_cocos2dx_builder_CCBReader_getCCBRootPath, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOwnerCallbackControlEvents", js_cocos2dx_builder_CCBReader_getOwnerCallbackControlEvents, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOwnerOutletNodes", js_cocos2dx_builder_CCBReader_getOwnerOutletNodes, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("readUTF8", js_cocos2dx_builder_CCBReader_readUTF8, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addOwnerCallbackControlEvents", js_cocos2dx_builder_CCBReader_addOwnerCallbackControlEvents, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOwnerOutletNames", js_cocos2dx_builder_CCBReader_getOwnerOutletNames, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("readCallbackKeyframesForSeq", js_cocos2dx_builder_CCBReader_readCallbackKeyframesForSeq, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAnimationManagersForNodes", js_cocos2dx_builder_CCBReader_getAnimationManagersForNodes, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNodesWithAnimationManagers", js_cocos2dx_builder_CCBReader_getNodesWithAnimationManagers, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("setResolutionScale", js_cocos2dx_builder_CCBReader_setResolutionScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocosbuilder_CCBReader_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocosbuilder_CCBReader_class, + js_cocos2dx_builder_CCBReader_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, "_Reader", 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_cocosbuilder_CCBReader_class; + p->proto = jsb_cocosbuilder_CCBReader_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +void register_all_cocos2dx_builder(JSContext* cx, JS::HandleObject obj) { + // Get the ns + JS::RootedObject ns(cx); + get_or_create_js_obj(cx, obj, "cc", &ns); + + js_register_cocos2dx_builder_CCBAnimationManager(cx, ns); + js_register_cocos2dx_builder_CCBReader(cx, ns); +} + diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_builder_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_builder_auto.hpp new file mode 100644 index 0000000000..d64e92d1bf --- /dev/null +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_builder_auto.hpp @@ -0,0 +1,82 @@ +#ifndef __cocos2dx_builder_h__ +#define __cocos2dx_builder_h__ + +#include "jsapi.h" +#include "jsfriendapi.h" + + +extern JSClass *jsb_cocosbuilder_CCBAnimationManager_class; +extern JSObject *jsb_cocosbuilder_CCBAnimationManager_prototype; + +bool js_cocos2dx_builder_CCBAnimationManager_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_builder_CCBAnimationManager_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_builder_CCBAnimationManager(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_builder(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_builder_CCBAnimationManager_moveAnimationsFromNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_setAutoPlaySequenceId(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNames(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_actionForSoundChannel(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_setBaseValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNodes(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_getLastCompletedSequenceName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_setRootNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamedTweenDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_getRootContainerSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_setDocumentControllerName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_setObject(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_getContainerSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_actionForCallbackChannel(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_getDocumentOutletNames(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_getKeyframeCallbacks(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_setRootContainerSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceIdTweenDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_getRunningSequenceName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_getAutoPlaySequenceId(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_getRootNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_addDocumentOutletNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_setDelegate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_getSequenceDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_addDocumentCallbackNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_runAnimationsForSequenceNamed(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_getSequenceId(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_setCallFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_getDocumentCallbackNodes(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_setSequences(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_debug(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_getDocumentControllerName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBAnimationManager_CCBAnimationManager(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocosbuilder_CCBReader_class; +extern JSObject *jsb_cocosbuilder_CCBReader_prototype; + +bool js_cocos2dx_builder_CCBReader_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_builder_CCBReader_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_builder_CCBReader(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_builder(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_builder_CCBReader_getAnimationManager(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBReader_setAnimationManager(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBReader_addOwnerOutletName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBReader_getOwnerCallbackNames(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBReader_addDocumentCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBReader_setCCBRootPath(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBReader_addOwnerOutletNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBReader_getOwnerCallbackNodes(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBReader_readSoundKeyframesForSeq(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBReader_getCCBRootPath(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBReader_getOwnerCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBReader_getOwnerOutletNodes(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBReader_readUTF8(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBReader_addOwnerCallbackControlEvents(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBReader_getOwnerOutletNames(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBReader_readCallbackKeyframesForSeq(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBReader_getAnimationManagersForNodes(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBReader_getNodesWithAnimationManagers(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBReader_setResolutionScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_builder_CCBReader_CCBReader(JSContext *cx, uint32_t argc, jsval *vp); +#endif + diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp new file mode 100644 index 0000000000..1e78c64812 --- /dev/null +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp @@ -0,0 +1,7568 @@ +#include "jsb_cocos2dx_extension_auto.hpp" +#include "cocos2d_specifics.hpp" +#include "cocos-ext.h" + +template +static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedValue initializing(cx); + bool isNewValid = true; + JS::RootedObject global(cx, ScriptingCore::getInstance()->getGlobalObject()); + isNewValid = JS_GetProperty(cx, global, "initializing", &initializing) && initializing.toBoolean(); + if (isNewValid) + { + 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."); + + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + + args.rval().set(OBJECT_TO_JSVAL(_tmp)); + return true; + } + + JS_ReportError(cx, "Constructor for the requested class is not available, please refer to the API reference."); + return false; +} + +static bool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) { + return false; +} + +static bool js_is_native_obj(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().setBoolean(true); + return true; +} +JSClass *jsb_cocos2d_extension_Control_class; +JSObject *jsb_cocos2d_extension_Control_prototype; + +bool js_cocos2dx_extension_Control_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Control_setEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_Control_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_Control_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_Control_getState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Control_getState : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getState(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_Control_getState : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_Control_sendActionsForControlEvents(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Control_sendActionsForControlEvents : Invalid Native Object"); + if (argc == 1) { + cocos2d::extension::Control::EventType arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_Control_sendActionsForControlEvents : Error processing arguments"); + cobj->sendActionsForControlEvents(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_Control_sendActionsForControlEvents : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_Control_setSelected(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Control_setSelected : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_Control_setSelected : Error processing arguments"); + cobj->setSelected(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_Control_setSelected : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_Control_isEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Control_isEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_Control_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_Control_needsLayout(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Control_needsLayout : Invalid Native Object"); + if (argc == 0) { + cobj->needsLayout(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_Control_needsLayout : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_Control_hasVisibleParents(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Control_hasVisibleParents : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->hasVisibleParents(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_Control_hasVisibleParents : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_Control_isSelected(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Control_isSelected : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isSelected(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_Control_isSelected : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_Control_isTouchInside(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Control_isTouchInside : Invalid Native Object"); + if (argc == 1) { + cocos2d::Touch* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_Control_isTouchInside : Error processing arguments"); + bool ret = cobj->isTouchInside(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_Control_isTouchInside : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_Control_setHighlighted(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Control_setHighlighted : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_Control_setHighlighted : Error processing arguments"); + cobj->setHighlighted(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_Control_setHighlighted : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_Control_getTouchLocation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Control_getTouchLocation : Invalid Native Object"); + if (argc == 1) { + cocos2d::Touch* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_Control_getTouchLocation : Error processing arguments"); + cocos2d::Vec2 ret = cobj->getTouchLocation(arg0); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_Control_getTouchLocation : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_Control_isHighlighted(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Control_isHighlighted : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isHighlighted(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_Control_isHighlighted : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_Control_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::extension::Control* ret = cocos2d::extension::Control::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::Control*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_extension_Control_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_extension_Control_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::extension::Control* cobj = new (std::nothrow) cocos2d::extension::Control(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::Control"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Layer_prototype; + +void js_cocos2d_extension_Control_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Control)", obj); +} + +void js_register_cocos2dx_extension_Control(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_extension_Control_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_extension_Control_class->name = "Control"; + jsb_cocos2d_extension_Control_class->addProperty = JS_PropertyStub; + jsb_cocos2d_extension_Control_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_extension_Control_class->getProperty = JS_PropertyStub; + jsb_cocos2d_extension_Control_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_extension_Control_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_extension_Control_class->resolve = JS_ResolveStub; + jsb_cocos2d_extension_Control_class->convert = JS_ConvertStub; + jsb_cocos2d_extension_Control_class->finalize = js_cocos2d_extension_Control_finalize; + jsb_cocos2d_extension_Control_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setEnabled", js_cocos2dx_extension_Control_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getState", js_cocos2dx_extension_Control_getState, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("sendActionsForControlEvents", js_cocos2dx_extension_Control_sendActionsForControlEvents, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSelected", js_cocos2dx_extension_Control_setSelected, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isEnabled", js_cocos2dx_extension_Control_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("needsLayout", js_cocos2dx_extension_Control_needsLayout, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("hasVisibleParents", js_cocos2dx_extension_Control_hasVisibleParents, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isSelected", js_cocos2dx_extension_Control_isSelected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isTouchInside", js_cocos2dx_extension_Control_isTouchInside, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setHighlighted", js_cocos2dx_extension_Control_setHighlighted, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTouchLocation", js_cocos2dx_extension_Control_getTouchLocation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isHighlighted", js_cocos2dx_extension_Control_isHighlighted, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_extension_Control_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_extension_Control_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Layer_prototype), + jsb_cocos2d_extension_Control_class, + js_cocos2dx_extension_Control_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, "Control", 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_extension_Control_class; + p->proto = jsb_cocos2d_extension_Control_prototype; + p->parentProto = jsb_cocos2d_Layer_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_extension_ControlButton_class; +JSObject *jsb_cocos2d_extension_ControlButton_prototype; + +bool js_cocos2dx_extension_ControlButton_isPushed(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_isPushed : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isPushed(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_isPushed : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlButton_setTitleLabelForState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_setTitleLabelForState : Invalid Native Object"); + if (argc == 2) { + cocos2d::Node* arg0; + cocos2d::extension::Control::State arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_setTitleLabelForState : Error processing arguments"); + cobj->setTitleLabelForState(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setTitleLabelForState : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ControlButton_setAdjustBackgroundImage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_setAdjustBackgroundImage : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_setAdjustBackgroundImage : Error processing arguments"); + cobj->setAdjustBackgroundImage(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setAdjustBackgroundImage : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlButton_setTitleForState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_setTitleForState : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + cocos2d::extension::Control::State arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_setTitleForState : Error processing arguments"); + cobj->setTitleForState(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setTitleForState : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ControlButton_setLabelAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_setLabelAnchorPoint : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_setLabelAnchorPoint : Error processing arguments"); + cobj->setLabelAnchorPoint(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setLabelAnchorPoint : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlButton_getLabelAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_getLabelAnchorPoint : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getLabelAnchorPoint(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getLabelAnchorPoint : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlButton_initWithBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_initWithBackgroundSprite : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::Scale9Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_initWithBackgroundSprite : Error processing arguments"); + bool ret = cobj->initWithBackgroundSprite(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_initWithBackgroundSprite : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlButton_getTitleTTFSizeForState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_getTitleTTFSizeForState : Invalid Native Object"); + if (argc == 1) { + cocos2d::extension::Control::State arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_getTitleTTFSizeForState : Error processing arguments"); + double ret = cobj->getTitleTTFSizeForState(arg0); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getTitleTTFSizeForState : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlButton_setTitleTTFForState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_setTitleTTFForState : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + cocos2d::extension::Control::State arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_setTitleTTFForState : Error processing arguments"); + cobj->setTitleTTFForState(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setTitleTTFForState : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ControlButton_setTitleTTFSizeForState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_setTitleTTFSizeForState : Invalid Native Object"); + if (argc == 2) { + double arg0; + cocos2d::extension::Control::State arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_setTitleTTFSizeForState : Error processing arguments"); + cobj->setTitleTTFSizeForState(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setTitleTTFSizeForState : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ControlButton_setTitleLabel(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_setTitleLabel : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_setTitleLabel : Error processing arguments"); + cobj->setTitleLabel(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setTitleLabel : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlButton_setPreferredSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_setPreferredSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_setPreferredSize : Error processing arguments"); + cobj->setPreferredSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setPreferredSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlButton_getCurrentTitleColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_getCurrentTitleColor : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color3B& ret = cobj->getCurrentTitleColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor3b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getCurrentTitleColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlButton_setZoomOnTouchDown(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_setZoomOnTouchDown : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_setZoomOnTouchDown : Error processing arguments"); + cobj->setZoomOnTouchDown(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setZoomOnTouchDown : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlButton_setBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_setBackgroundSprite : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::Scale9Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_setBackgroundSprite : Error processing arguments"); + cobj->setBackgroundSprite(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setBackgroundSprite : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlButton_getBackgroundSpriteForState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_getBackgroundSpriteForState : Invalid Native Object"); + if (argc == 1) { + cocos2d::extension::Control::State arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_getBackgroundSpriteForState : Error processing arguments"); + cocos2d::ui::Scale9Sprite* ret = cobj->getBackgroundSpriteForState(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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getBackgroundSpriteForState : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlButton_getHorizontalOrigin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_getHorizontalOrigin : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getHorizontalOrigin(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getHorizontalOrigin : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlButton_initWithTitleAndFontNameAndFontSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_initWithTitleAndFontNameAndFontSize : Invalid Native Object"); + if (argc == 3) { + std::string arg0; + std::string arg1; + double arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_initWithTitleAndFontNameAndFontSize : Error processing arguments"); + bool ret = cobj->initWithTitleAndFontNameAndFontSize(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_initWithTitleAndFontNameAndFontSize : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_extension_ControlButton_setTitleBMFontForState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_setTitleBMFontForState : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + cocos2d::extension::Control::State arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_setTitleBMFontForState : Error processing arguments"); + cobj->setTitleBMFontForState(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setTitleBMFontForState : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ControlButton_getScaleRatio(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_getScaleRatio : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getScaleRatio(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getScaleRatio : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlButton_getTitleTTFForState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_getTitleTTFForState : Invalid Native Object"); + if (argc == 1) { + cocos2d::extension::Control::State arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_getTitleTTFForState : Error processing arguments"); + const std::string& ret = cobj->getTitleTTFForState(arg0); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getTitleTTFForState : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlButton_getBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_getBackgroundSprite : Invalid Native Object"); + if (argc == 0) { + cocos2d::ui::Scale9Sprite* ret = cobj->getBackgroundSprite(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getBackgroundSprite : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlButton_getTitleColorForState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_getTitleColorForState : Invalid Native Object"); + if (argc == 1) { + cocos2d::extension::Control::State arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_getTitleColorForState : Error processing arguments"); + cocos2d::Color3B ret = cobj->getTitleColorForState(arg0); + jsval jsret = JSVAL_NULL; + jsret = cccolor3b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getTitleColorForState : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlButton_setTitleColorForState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_setTitleColorForState : Invalid Native Object"); + if (argc == 2) { + cocos2d::Color3B arg0; + cocos2d::extension::Control::State arg1; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_setTitleColorForState : Error processing arguments"); + cobj->setTitleColorForState(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setTitleColorForState : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ControlButton_doesAdjustBackgroundImage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_doesAdjustBackgroundImage : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->doesAdjustBackgroundImage(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_doesAdjustBackgroundImage : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlButton_setBackgroundSpriteFrameForState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_setBackgroundSpriteFrameForState : Invalid Native Object"); + if (argc == 2) { + cocos2d::SpriteFrame* arg0; + cocos2d::extension::Control::State arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_setBackgroundSpriteFrameForState : Error processing arguments"); + cobj->setBackgroundSpriteFrameForState(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setBackgroundSpriteFrameForState : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ControlButton_setBackgroundSpriteForState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_setBackgroundSpriteForState : Invalid Native Object"); + if (argc == 2) { + cocos2d::ui::Scale9Sprite* arg0; + cocos2d::extension::Control::State arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_setBackgroundSpriteForState : Error processing arguments"); + cobj->setBackgroundSpriteForState(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setBackgroundSpriteForState : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ControlButton_setScaleRatio(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_setScaleRatio : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_setScaleRatio : Error processing arguments"); + cobj->setScaleRatio(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setScaleRatio : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlButton_getTitleBMFontForState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_getTitleBMFontForState : Invalid Native Object"); + if (argc == 1) { + cocos2d::extension::Control::State arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_getTitleBMFontForState : Error processing arguments"); + const std::string& ret = cobj->getTitleBMFontForState(arg0); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getTitleBMFontForState : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlButton_getTitleLabel(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_getTitleLabel : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getTitleLabel(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getTitleLabel : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlButton_getPreferredSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_getPreferredSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getPreferredSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getPreferredSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlButton_getVerticalMargin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_getVerticalMargin : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getVerticalMargin(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getVerticalMargin : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlButton_getTitleLabelForState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_getTitleLabelForState : Invalid Native Object"); + if (argc == 1) { + cocos2d::extension::Control::State arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_getTitleLabelForState : Error processing arguments"); + cocos2d::Node* ret = cobj->getTitleLabelForState(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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getTitleLabelForState : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlButton_setMargins(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_setMargins : Invalid Native Object"); + if (argc == 2) { + int arg0; + int arg1; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_setMargins : Error processing arguments"); + cobj->setMargins(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_setMargins : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ControlButton_getCurrentTitle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::extension::ControlButton* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_getCurrentTitle : Invalid Native Object"); + do { + if (argc == 0) { + std::string ret = cobj->getCurrentTitle(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + const std::string& ret = cobj->getCurrentTitle(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getCurrentTitle : wrong number of arguments"); + return false; +} +bool js_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite : Invalid Native Object"); + if (argc == 2) { + cocos2d::Node* arg0; + cocos2d::ui::Scale9Sprite* arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite : Error processing arguments"); + bool ret = cobj->initWithLabelAndBackgroundSprite(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ControlButton_getZoomOnTouchDown(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_getZoomOnTouchDown : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->getZoomOnTouchDown(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getZoomOnTouchDown : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlButton_getTitleForState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_getTitleForState : Invalid Native Object"); + if (argc == 1) { + cocos2d::extension::Control::State arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_getTitleForState : Error processing arguments"); + std::string ret = cobj->getTitleForState(arg0); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_getTitleForState : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlButton_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + cocos2d::ui::Scale9Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::extension::ControlButton* ret = cocos2d::extension::ControlButton::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlButton*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::extension::ControlButton* ret = cocos2d::extension::ControlButton::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlButton*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::ui::Scale9Sprite* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::extension::ControlButton* ret = cocos2d::extension::ControlButton::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlButton*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::extension::ControlButton* ret = cocos2d::extension::ControlButton::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlButton*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_extension_ControlButton_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::extension::ControlButton* cobj = new (std::nothrow) cocos2d::extension::ControlButton(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlButton"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_extension_Control_prototype; + +void js_cocos2d_extension_ControlButton_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ControlButton)", obj); +} + +static bool js_cocos2d_extension_ControlButton_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::extension::ControlButton *nobj = new (std::nothrow) cocos2d::extension::ControlButton(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlButton"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_extension_ControlButton(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_extension_ControlButton_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_extension_ControlButton_class->name = "ControlButton"; + jsb_cocos2d_extension_ControlButton_class->addProperty = JS_PropertyStub; + jsb_cocos2d_extension_ControlButton_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_extension_ControlButton_class->getProperty = JS_PropertyStub; + jsb_cocos2d_extension_ControlButton_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_extension_ControlButton_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_extension_ControlButton_class->resolve = JS_ResolveStub; + jsb_cocos2d_extension_ControlButton_class->convert = JS_ConvertStub; + jsb_cocos2d_extension_ControlButton_class->finalize = js_cocos2d_extension_ControlButton_finalize; + jsb_cocos2d_extension_ControlButton_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("isPushed", js_cocos2dx_extension_ControlButton_isPushed, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTitleLabelForState", js_cocos2dx_extension_ControlButton_setTitleLabelForState, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAdjustBackgroundImage", js_cocos2dx_extension_ControlButton_setAdjustBackgroundImage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTitleForState", js_cocos2dx_extension_ControlButton_setTitleForState, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLabelAnchorPoint", js_cocos2dx_extension_ControlButton_setLabelAnchorPoint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLabelAnchorPoint", js_cocos2dx_extension_ControlButton_getLabelAnchorPoint, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithBackgroundSprite", js_cocos2dx_extension_ControlButton_initWithBackgroundSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTitleTTFSizeForState", js_cocos2dx_extension_ControlButton_getTitleTTFSizeForState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTitleTTFForState", js_cocos2dx_extension_ControlButton_setTitleTTFForState, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTitleTTFSizeForState", js_cocos2dx_extension_ControlButton_setTitleTTFSizeForState, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTitleLabel", js_cocos2dx_extension_ControlButton_setTitleLabel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPreferredSize", js_cocos2dx_extension_ControlButton_setPreferredSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCurrentTitleColor", js_cocos2dx_extension_ControlButton_getCurrentTitleColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setZoomOnTouchDown", js_cocos2dx_extension_ControlButton_setZoomOnTouchDown, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBackgroundSprite", js_cocos2dx_extension_ControlButton_setBackgroundSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackgroundSpriteForState", js_cocos2dx_extension_ControlButton_getBackgroundSpriteForState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getHorizontalOrigin", js_cocos2dx_extension_ControlButton_getHorizontalOrigin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTitleAndFontNameAndFontSize", js_cocos2dx_extension_ControlButton_initWithTitleAndFontNameAndFontSize, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTitleBMFontForState", js_cocos2dx_extension_ControlButton_setTitleBMFontForState, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getScaleRatio", js_cocos2dx_extension_ControlButton_getScaleRatio, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTitleTTFForState", js_cocos2dx_extension_ControlButton_getTitleTTFForState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackgroundSprite", js_cocos2dx_extension_ControlButton_getBackgroundSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTitleColorForState", js_cocos2dx_extension_ControlButton_getTitleColorForState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTitleColorForState", js_cocos2dx_extension_ControlButton_setTitleColorForState, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("doesAdjustBackgroundImage", js_cocos2dx_extension_ControlButton_doesAdjustBackgroundImage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBackgroundSpriteFrameForState", js_cocos2dx_extension_ControlButton_setBackgroundSpriteFrameForState, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBackgroundSpriteForState", js_cocos2dx_extension_ControlButton_setBackgroundSpriteForState, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setScaleRatio", js_cocos2dx_extension_ControlButton_setScaleRatio, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTitleBMFontForState", js_cocos2dx_extension_ControlButton_getTitleBMFontForState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTitleLabel", js_cocos2dx_extension_ControlButton_getTitleLabel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPreferredSize", js_cocos2dx_extension_ControlButton_getPreferredSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVerticalMargin", js_cocos2dx_extension_ControlButton_getVerticalMargin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTitleLabelForState", js_cocos2dx_extension_ControlButton_getTitleLabelForState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMargins", js_cocos2dx_extension_ControlButton_setMargins, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCurrentTitle", js_cocos2dx_extension_ControlButton_getCurrentTitle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithLabelAndBackgroundSprite", js_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getZoomOnTouchDown", js_cocos2dx_extension_ControlButton_getZoomOnTouchDown, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTitleForState", js_cocos2dx_extension_ControlButton_getTitleForState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_extension_ControlButton_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_extension_ControlButton_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_extension_ControlButton_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + jsb_cocos2d_extension_ControlButton_class, + js_cocos2dx_extension_ControlButton_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, "ControlButton", 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_extension_ControlButton_class; + p->proto = jsb_cocos2d_extension_ControlButton_prototype; + p->parentProto = jsb_cocos2d_extension_Control_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_extension_ControlHuePicker_class; +JSObject *jsb_cocos2d_extension_ControlHuePicker_prototype; + +bool js_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos : Invalid Native Object"); + if (argc == 2) { + cocos2d::Node* arg0; + cocos2d::Vec2 arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos : Error processing arguments"); + bool ret = cobj->initWithTargetAndPos(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ControlHuePicker_setHue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlHuePicker_setHue : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlHuePicker_setHue : Error processing arguments"); + cobj->setHue(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_setHue : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlHuePicker_getStartPos(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlHuePicker_getStartPos : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getStartPos(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_getStartPos : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlHuePicker_getHue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlHuePicker_getHue : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getHue(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_getHue : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlHuePicker_getSlider(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlHuePicker_getSlider : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getSlider(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_getSlider : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlHuePicker_setBackground(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlHuePicker_setBackground : Invalid Native Object"); + if (argc == 1) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlHuePicker_setBackground : Error processing arguments"); + cobj->setBackground(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_setBackground : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlHuePicker_setHuePercentage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlHuePicker_setHuePercentage : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlHuePicker_setHuePercentage : Error processing arguments"); + cobj->setHuePercentage(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_setHuePercentage : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlHuePicker_getBackground(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlHuePicker_getBackground : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getBackground(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_getBackground : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlHuePicker_getHuePercentage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlHuePicker_getHuePercentage : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getHuePercentage(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_getHuePercentage : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlHuePicker_setSlider(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlHuePicker* cobj = (cocos2d::extension::ControlHuePicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlHuePicker_setSlider : Invalid Native Object"); + if (argc == 1) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlHuePicker_setSlider : Error processing arguments"); + cobj->setSlider(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_setSlider : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlHuePicker_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::Node* arg0; + cocos2d::Vec2 arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlHuePicker_create : Error processing arguments"); + cocos2d::extension::ControlHuePicker* ret = cocos2d::extension::ControlHuePicker::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlHuePicker*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_extension_ControlHuePicker_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_extension_ControlHuePicker_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::extension::ControlHuePicker* cobj = new (std::nothrow) cocos2d::extension::ControlHuePicker(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlHuePicker"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_extension_Control_prototype; + +void js_cocos2d_extension_ControlHuePicker_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ControlHuePicker)", obj); +} + +void js_register_cocos2dx_extension_ControlHuePicker(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_extension_ControlHuePicker_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_extension_ControlHuePicker_class->name = "ControlHuePicker"; + jsb_cocos2d_extension_ControlHuePicker_class->addProperty = JS_PropertyStub; + jsb_cocos2d_extension_ControlHuePicker_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_extension_ControlHuePicker_class->getProperty = JS_PropertyStub; + jsb_cocos2d_extension_ControlHuePicker_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_extension_ControlHuePicker_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_extension_ControlHuePicker_class->resolve = JS_ResolveStub; + jsb_cocos2d_extension_ControlHuePicker_class->convert = JS_ConvertStub; + jsb_cocos2d_extension_ControlHuePicker_class->finalize = js_cocos2d_extension_ControlHuePicker_finalize; + jsb_cocos2d_extension_ControlHuePicker_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithTargetAndPos", js_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setHue", js_cocos2dx_extension_ControlHuePicker_setHue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStartPos", js_cocos2dx_extension_ControlHuePicker_getStartPos, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getHue", js_cocos2dx_extension_ControlHuePicker_getHue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSlider", js_cocos2dx_extension_ControlHuePicker_getSlider, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBackground", js_cocos2dx_extension_ControlHuePicker_setBackground, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setHuePercentage", js_cocos2dx_extension_ControlHuePicker_setHuePercentage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackground", js_cocos2dx_extension_ControlHuePicker_getBackground, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getHuePercentage", js_cocos2dx_extension_ControlHuePicker_getHuePercentage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSlider", js_cocos2dx_extension_ControlHuePicker_setSlider, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_extension_ControlHuePicker_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_extension_ControlHuePicker_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + jsb_cocos2d_extension_ControlHuePicker_class, + js_cocos2dx_extension_ControlHuePicker_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, "ControlHuePicker", 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_extension_ControlHuePicker_class; + p->proto = jsb_cocos2d_extension_ControlHuePicker_prototype; + p->parentProto = jsb_cocos2d_extension_Control_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class; +JSObject *jsb_cocos2d_extension_ControlSaturationBrightnessPicker_prototype; + +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getShadow(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSaturationBrightnessPicker* cobj = (cocos2d::extension::ControlSaturationBrightnessPicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getShadow : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getShadow(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getShadow : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPos(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSaturationBrightnessPicker* cobj = (cocos2d::extension::ControlSaturationBrightnessPicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPos : Invalid Native Object"); + if (argc == 2) { + cocos2d::Node* arg0; + cocos2d::Vec2 arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPos : Error processing arguments"); + bool ret = cobj->initWithTargetAndPos(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPos : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getStartPos(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSaturationBrightnessPicker* cobj = (cocos2d::extension::ControlSaturationBrightnessPicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getStartPos : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getStartPos(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getStartPos : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getOverlay(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSaturationBrightnessPicker* cobj = (cocos2d::extension::ControlSaturationBrightnessPicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getOverlay : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getOverlay(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getOverlay : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSlider(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSaturationBrightnessPicker* cobj = (cocos2d::extension::ControlSaturationBrightnessPicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSlider : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getSlider(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSlider : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBackground(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSaturationBrightnessPicker* cobj = (cocos2d::extension::ControlSaturationBrightnessPicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBackground : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getBackground(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBackground : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSaturation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSaturationBrightnessPicker* cobj = (cocos2d::extension::ControlSaturationBrightnessPicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSaturation : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getSaturation(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSaturation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBrightness(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSaturationBrightnessPicker* cobj = (cocos2d::extension::ControlSaturationBrightnessPicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBrightness : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getBrightness(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBrightness : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::Node* arg0; + cocos2d::Vec2 arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_create : Error processing arguments"); + cocos2d::extension::ControlSaturationBrightnessPicker* ret = cocos2d::extension::ControlSaturationBrightnessPicker::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlSaturationBrightnessPicker*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_extension_ControlSaturationBrightnessPicker_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::extension::ControlSaturationBrightnessPicker* cobj = new (std::nothrow) cocos2d::extension::ControlSaturationBrightnessPicker(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlSaturationBrightnessPicker"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_extension_Control_prototype; + +void js_cocos2d_extension_ControlSaturationBrightnessPicker_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ControlSaturationBrightnessPicker)", obj); +} + +void js_register_cocos2dx_extension_ControlSaturationBrightnessPicker(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->name = "ControlSaturationBrightnessPicker"; + jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->addProperty = JS_PropertyStub; + jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->getProperty = JS_PropertyStub; + jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->resolve = JS_ResolveStub; + jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->convert = JS_ConvertStub; + jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->finalize = js_cocos2d_extension_ControlSaturationBrightnessPicker_finalize; + jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getShadow", js_cocos2dx_extension_ControlSaturationBrightnessPicker_getShadow, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTargetAndPos", js_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPos, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStartPos", js_cocos2dx_extension_ControlSaturationBrightnessPicker_getStartPos, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOverlay", js_cocos2dx_extension_ControlSaturationBrightnessPicker_getOverlay, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSlider", js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSlider, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackground", js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBackground, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSaturation", js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSaturation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBrightness", js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBrightness, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_extension_ControlSaturationBrightnessPicker_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_extension_ControlSaturationBrightnessPicker_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class, + js_cocos2dx_extension_ControlSaturationBrightnessPicker_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, "ControlSaturationBrightnessPicker", 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_extension_ControlSaturationBrightnessPicker_class; + p->proto = jsb_cocos2d_extension_ControlSaturationBrightnessPicker_prototype; + p->parentProto = jsb_cocos2d_extension_Control_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_extension_ControlColourPicker_class; +JSObject *jsb_cocos2d_extension_ControlColourPicker_prototype; + +bool js_cocos2dx_extension_ControlColourPicker_hueSliderValueChanged(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlColourPicker* cobj = (cocos2d::extension::ControlColourPicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlColourPicker_hueSliderValueChanged : Invalid Native Object"); + if (argc == 2) { + cocos2d::Ref* arg0; + cocos2d::extension::Control::EventType arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlColourPicker_hueSliderValueChanged : Error processing arguments"); + cobj->hueSliderValueChanged(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_hueSliderValueChanged : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ControlColourPicker_getHuePicker(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlColourPicker* cobj = (cocos2d::extension::ControlColourPicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlColourPicker_getHuePicker : Invalid Native Object"); + if (argc == 0) { + cocos2d::extension::ControlHuePicker* ret = cobj->getHuePicker(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlHuePicker*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_getHuePicker : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlColourPicker_getcolourPicker(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlColourPicker* cobj = (cocos2d::extension::ControlColourPicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlColourPicker_getcolourPicker : Invalid Native Object"); + if (argc == 0) { + cocos2d::extension::ControlSaturationBrightnessPicker* ret = cobj->getcolourPicker(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlSaturationBrightnessPicker*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_getcolourPicker : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlColourPicker_setBackground(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlColourPicker* cobj = (cocos2d::extension::ControlColourPicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlColourPicker_setBackground : Invalid Native Object"); + if (argc == 1) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlColourPicker_setBackground : Error processing arguments"); + cobj->setBackground(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_setBackground : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlColourPicker_setcolourPicker(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlColourPicker* cobj = (cocos2d::extension::ControlColourPicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlColourPicker_setcolourPicker : Invalid Native Object"); + if (argc == 1) { + cocos2d::extension::ControlSaturationBrightnessPicker* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::extension::ControlSaturationBrightnessPicker*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlColourPicker_setcolourPicker : Error processing arguments"); + cobj->setcolourPicker(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_setcolourPicker : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlColourPicker* cobj = (cocos2d::extension::ControlColourPicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged : Invalid Native Object"); + if (argc == 2) { + cocos2d::Ref* arg0; + cocos2d::extension::Control::EventType arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged : Error processing arguments"); + cobj->colourSliderValueChanged(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ControlColourPicker_setHuePicker(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlColourPicker* cobj = (cocos2d::extension::ControlColourPicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlColourPicker_setHuePicker : Invalid Native Object"); + if (argc == 1) { + cocos2d::extension::ControlHuePicker* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::extension::ControlHuePicker*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlColourPicker_setHuePicker : Error processing arguments"); + cobj->setHuePicker(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_setHuePicker : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlColourPicker_getBackground(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlColourPicker* cobj = (cocos2d::extension::ControlColourPicker *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlColourPicker_getBackground : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getBackground(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_getBackground : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlColourPicker_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::extension::ControlColourPicker* ret = cocos2d::extension::ControlColourPicker::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlColourPicker*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_extension_ControlColourPicker_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_extension_ControlColourPicker_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::extension::ControlColourPicker* cobj = new (std::nothrow) cocos2d::extension::ControlColourPicker(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlColourPicker"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_extension_Control_prototype; + +void js_cocos2d_extension_ControlColourPicker_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ControlColourPicker)", obj); +} + +static bool js_cocos2d_extension_ControlColourPicker_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::extension::ControlColourPicker *nobj = new (std::nothrow) cocos2d::extension::ControlColourPicker(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlColourPicker"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_extension_ControlColourPicker(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_extension_ControlColourPicker_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_extension_ControlColourPicker_class->name = "ControlColourPicker"; + jsb_cocos2d_extension_ControlColourPicker_class->addProperty = JS_PropertyStub; + jsb_cocos2d_extension_ControlColourPicker_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_extension_ControlColourPicker_class->getProperty = JS_PropertyStub; + jsb_cocos2d_extension_ControlColourPicker_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_extension_ControlColourPicker_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_extension_ControlColourPicker_class->resolve = JS_ResolveStub; + jsb_cocos2d_extension_ControlColourPicker_class->convert = JS_ConvertStub; + jsb_cocos2d_extension_ControlColourPicker_class->finalize = js_cocos2d_extension_ControlColourPicker_finalize; + jsb_cocos2d_extension_ControlColourPicker_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("hueSliderValueChanged", js_cocos2dx_extension_ControlColourPicker_hueSliderValueChanged, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getHuePicker", js_cocos2dx_extension_ControlColourPicker_getHuePicker, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getcolourPicker", js_cocos2dx_extension_ControlColourPicker_getcolourPicker, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBackground", js_cocos2dx_extension_ControlColourPicker_setBackground, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setcolourPicker", js_cocos2dx_extension_ControlColourPicker_setcolourPicker, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("colourSliderValueChanged", js_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setHuePicker", js_cocos2dx_extension_ControlColourPicker_setHuePicker, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackground", js_cocos2dx_extension_ControlColourPicker_getBackground, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_extension_ControlColourPicker_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_extension_ControlColourPicker_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_extension_ControlColourPicker_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + jsb_cocos2d_extension_ControlColourPicker_class, + js_cocos2dx_extension_ControlColourPicker_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, "ControlColourPicker", 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_extension_ControlColourPicker_class; + p->proto = jsb_cocos2d_extension_ControlColourPicker_prototype; + p->parentProto = jsb_cocos2d_extension_Control_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_extension_ControlPotentiometer_class; +JSObject *jsb_cocos2d_extension_ControlPotentiometer_prototype; + +bool js_cocos2dx_extension_ControlPotentiometer_setPreviousLocation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlPotentiometer_setPreviousLocation : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlPotentiometer_setPreviousLocation : Error processing arguments"); + cobj->setPreviousLocation(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_setPreviousLocation : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlPotentiometer_setValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlPotentiometer_setValue : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlPotentiometer_setValue : Error processing arguments"); + cobj->setValue(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_setValue : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlPotentiometer_getProgressTimer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlPotentiometer_getProgressTimer : Invalid Native Object"); + if (argc == 0) { + cocos2d::ProgressTimer* ret = cobj->getProgressTimer(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ProgressTimer*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_getProgressTimer : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlPotentiometer_getMaximumValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlPotentiometer_getMaximumValue : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getMaximumValue(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_getMaximumValue : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlPotentiometer_angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlPotentiometer_angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint : Invalid Native Object"); + if (argc == 4) { + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; + cocos2d::Vec2 arg2; + cocos2d::Vec2 arg3; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + ok &= jsval_to_vector2(cx, args.get(2), &arg2); + ok &= jsval_to_vector2(cx, args.get(3), &arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlPotentiometer_angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint : Error processing arguments"); + double ret = cobj->angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_extension_ControlPotentiometer_potentiometerBegan(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlPotentiometer_potentiometerBegan : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlPotentiometer_potentiometerBegan : Error processing arguments"); + cobj->potentiometerBegan(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_potentiometerBegan : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlPotentiometer_setMaximumValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlPotentiometer_setMaximumValue : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlPotentiometer_setMaximumValue : Error processing arguments"); + cobj->setMaximumValue(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_setMaximumValue : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlPotentiometer_getMinimumValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlPotentiometer_getMinimumValue : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getMinimumValue(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_getMinimumValue : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlPotentiometer_setThumbSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlPotentiometer_setThumbSprite : Invalid Native Object"); + if (argc == 1) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlPotentiometer_setThumbSprite : Error processing arguments"); + cobj->setThumbSprite(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_setThumbSprite : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlPotentiometer_getValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlPotentiometer_getValue : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getValue(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_getValue : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlPotentiometer_getPreviousLocation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlPotentiometer_getPreviousLocation : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getPreviousLocation(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_getPreviousLocation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlPotentiometer_distanceBetweenPointAndPoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlPotentiometer_distanceBetweenPointAndPoint : Invalid Native Object"); + if (argc == 2) { + cocos2d::Vec2 arg0; + cocos2d::Vec2 arg1; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + ok &= jsval_to_vector2(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlPotentiometer_distanceBetweenPointAndPoint : Error processing arguments"); + double ret = cobj->distanceBetweenPointAndPoint(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_distanceBetweenPointAndPoint : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ControlPotentiometer_potentiometerEnded(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlPotentiometer_potentiometerEnded : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlPotentiometer_potentiometerEnded : Error processing arguments"); + cobj->potentiometerEnded(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_potentiometerEnded : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlPotentiometer_setProgressTimer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlPotentiometer_setProgressTimer : Invalid Native Object"); + if (argc == 1) { + cocos2d::ProgressTimer* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ProgressTimer*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlPotentiometer_setProgressTimer : Error processing arguments"); + cobj->setProgressTimer(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_setProgressTimer : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlPotentiometer_setMinimumValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlPotentiometer_setMinimumValue : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlPotentiometer_setMinimumValue : Error processing arguments"); + cobj->setMinimumValue(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_setMinimumValue : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlPotentiometer_getThumbSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlPotentiometer_getThumbSprite : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getThumbSprite(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_getThumbSprite : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTimer_ThumbSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTimer_ThumbSprite : Invalid Native Object"); + if (argc == 3) { + cocos2d::Sprite* arg0; + cocos2d::ProgressTimer* arg1; + cocos2d::Sprite* arg2; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::ProgressTimer*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTimer_ThumbSprite : Error processing arguments"); + bool ret = cobj->initWithTrackSprite_ProgressTimer_ThumbSprite(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTimer_ThumbSprite : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_extension_ControlPotentiometer_potentiometerMoved(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlPotentiometer* cobj = (cocos2d::extension::ControlPotentiometer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlPotentiometer_potentiometerMoved : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlPotentiometer_potentiometerMoved : Error processing arguments"); + cobj->potentiometerMoved(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_potentiometerMoved : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlPotentiometer_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 3) { + const char* arg0; + const char* arg1; + const char* arg2; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + std::string arg2_tmp; ok &= jsval_to_std_string(cx, args.get(2), &arg2_tmp); arg2 = arg2_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlPotentiometer_create : Error processing arguments"); + cocos2d::extension::ControlPotentiometer* ret = cocos2d::extension::ControlPotentiometer::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlPotentiometer*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_extension_ControlPotentiometer_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_extension_ControlPotentiometer_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::extension::ControlPotentiometer* cobj = new (std::nothrow) cocos2d::extension::ControlPotentiometer(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlPotentiometer"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_extension_Control_prototype; + +void js_cocos2d_extension_ControlPotentiometer_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ControlPotentiometer)", obj); +} + +static bool js_cocos2d_extension_ControlPotentiometer_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::extension::ControlPotentiometer *nobj = new (std::nothrow) cocos2d::extension::ControlPotentiometer(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlPotentiometer"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_extension_ControlPotentiometer(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_extension_ControlPotentiometer_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_extension_ControlPotentiometer_class->name = "ControlPotentiometer"; + jsb_cocos2d_extension_ControlPotentiometer_class->addProperty = JS_PropertyStub; + jsb_cocos2d_extension_ControlPotentiometer_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_extension_ControlPotentiometer_class->getProperty = JS_PropertyStub; + jsb_cocos2d_extension_ControlPotentiometer_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_extension_ControlPotentiometer_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_extension_ControlPotentiometer_class->resolve = JS_ResolveStub; + jsb_cocos2d_extension_ControlPotentiometer_class->convert = JS_ConvertStub; + jsb_cocos2d_extension_ControlPotentiometer_class->finalize = js_cocos2d_extension_ControlPotentiometer_finalize; + jsb_cocos2d_extension_ControlPotentiometer_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setPreviousLocation", js_cocos2dx_extension_ControlPotentiometer_setPreviousLocation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setValue", js_cocos2dx_extension_ControlPotentiometer_setValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getProgressTimer", js_cocos2dx_extension_ControlPotentiometer_getProgressTimer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaximumValue", js_cocos2dx_extension_ControlPotentiometer_getMaximumValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint", js_cocos2dx_extension_ControlPotentiometer_angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("potentiometerBegan", js_cocos2dx_extension_ControlPotentiometer_potentiometerBegan, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaximumValue", js_cocos2dx_extension_ControlPotentiometer_setMaximumValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMinimumValue", js_cocos2dx_extension_ControlPotentiometer_getMinimumValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setThumbSprite", js_cocos2dx_extension_ControlPotentiometer_setThumbSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getValue", js_cocos2dx_extension_ControlPotentiometer_getValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPreviousLocation", js_cocos2dx_extension_ControlPotentiometer_getPreviousLocation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("distanceBetweenPointAndPoint", js_cocos2dx_extension_ControlPotentiometer_distanceBetweenPointAndPoint, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("potentiometerEnded", js_cocos2dx_extension_ControlPotentiometer_potentiometerEnded, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setProgressTimer", js_cocos2dx_extension_ControlPotentiometer_setProgressTimer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMinimumValue", js_cocos2dx_extension_ControlPotentiometer_setMinimumValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getThumbSprite", js_cocos2dx_extension_ControlPotentiometer_getThumbSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithTrackSprite_ProgressTimer_ThumbSprite", js_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTimer_ThumbSprite, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("potentiometerMoved", js_cocos2dx_extension_ControlPotentiometer_potentiometerMoved, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_extension_ControlPotentiometer_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_extension_ControlPotentiometer_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_extension_ControlPotentiometer_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + jsb_cocos2d_extension_ControlPotentiometer_class, + js_cocos2dx_extension_ControlPotentiometer_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, "ControlPotentiometer", 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_extension_ControlPotentiometer_class; + p->proto = jsb_cocos2d_extension_ControlPotentiometer_prototype; + p->parentProto = jsb_cocos2d_extension_Control_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_extension_ControlSlider_class; +JSObject *jsb_cocos2d_extension_ControlSlider_prototype; + +bool js_cocos2dx_extension_ControlSlider_setBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_setBackgroundSprite : Invalid Native Object"); + if (argc == 1) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlSlider_setBackgroundSprite : Error processing arguments"); + cobj->setBackgroundSprite(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_setBackgroundSprite : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlSlider_getMaximumAllowedValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_getMaximumAllowedValue : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getMaximumAllowedValue(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_getMaximumAllowedValue : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::extension::ControlSlider* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_initWithSprites : Invalid Native Object"); + do { + if (argc == 4) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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::Sprite* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Sprite* arg2; + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Sprite* arg3; + do { + if (!args.get(3).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(3).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg3 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithSprites(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 3) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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::Sprite* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Sprite* arg2; + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithSprites(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_initWithSprites : wrong number of arguments"); + return false; +} +bool js_cocos2dx_extension_ControlSlider_getMinimumAllowedValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_getMinimumAllowedValue : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getMinimumAllowedValue(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_getMinimumAllowedValue : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlSlider_getMaximumValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_getMaximumValue : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getMaximumValue(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_getMaximumValue : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlSlider_getSelectedThumbSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_getSelectedThumbSprite : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getSelectedThumbSprite(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_getSelectedThumbSprite : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlSlider_setProgressSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_setProgressSprite : Invalid Native Object"); + if (argc == 1) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlSlider_setProgressSprite : Error processing arguments"); + cobj->setProgressSprite(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_setProgressSprite : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlSlider_setMaximumValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_setMaximumValue : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlSlider_setMaximumValue : Error processing arguments"); + cobj->setMaximumValue(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_setMaximumValue : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlSlider_getMinimumValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_getMinimumValue : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getMinimumValue(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_getMinimumValue : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlSlider_setThumbSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_setThumbSprite : Invalid Native Object"); + if (argc == 1) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlSlider_setThumbSprite : Error processing arguments"); + cobj->setThumbSprite(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_setThumbSprite : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlSlider_getValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_getValue : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getValue(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_getValue : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlSlider_getBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_getBackgroundSprite : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getBackgroundSprite(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_getBackgroundSprite : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlSlider_getThumbSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_getThumbSprite : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getThumbSprite(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_getThumbSprite : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlSlider_setValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_setValue : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlSlider_setValue : Error processing arguments"); + cobj->setValue(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_setValue : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlSlider_locationFromTouch(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_locationFromTouch : Invalid Native Object"); + if (argc == 1) { + cocos2d::Touch* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlSlider_locationFromTouch : Error processing arguments"); + cocos2d::Vec2 ret = cobj->locationFromTouch(arg0); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_locationFromTouch : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlSlider_setMinimumValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_setMinimumValue : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlSlider_setMinimumValue : Error processing arguments"); + cobj->setMinimumValue(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_setMinimumValue : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlSlider_setMinimumAllowedValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_setMinimumAllowedValue : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlSlider_setMinimumAllowedValue : Error processing arguments"); + cobj->setMinimumAllowedValue(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_setMinimumAllowedValue : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlSlider_getProgressSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_getProgressSprite : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getProgressSprite(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_getProgressSprite : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlSlider_setSelectedThumbSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_setSelectedThumbSprite : Invalid Native Object"); + if (argc == 1) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlSlider_setSelectedThumbSprite : Error processing arguments"); + cobj->setSelectedThumbSprite(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_setSelectedThumbSprite : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlSlider_setMaximumAllowedValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSlider* cobj = (cocos2d::extension::ControlSlider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSlider_setMaximumAllowedValue : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlSlider_setMaximumAllowedValue : Error processing arguments"); + cobj->setMaximumAllowedValue(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_setMaximumAllowedValue : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlSlider_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 3) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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::Sprite* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Sprite* arg2; + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::extension::ControlSlider* ret = cocos2d::extension::ControlSlider::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlSlider*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 3) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(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, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + if (!ok) { ok = true; break; } + const char* arg2; + std::string arg2_tmp; ok &= jsval_to_std_string(cx, args.get(2), &arg2_tmp); arg2 = arg2_tmp.c_str(); + if (!ok) { ok = true; break; } + cocos2d::extension::ControlSlider* ret = cocos2d::extension::ControlSlider::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlSlider*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 4) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(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, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + if (!ok) { ok = true; break; } + const char* arg2; + std::string arg2_tmp; ok &= jsval_to_std_string(cx, args.get(2), &arg2_tmp); arg2 = arg2_tmp.c_str(); + if (!ok) { ok = true; break; } + const char* arg3; + std::string arg3_tmp; ok &= jsval_to_std_string(cx, args.get(3), &arg3_tmp); arg3 = arg3_tmp.c_str(); + if (!ok) { ok = true; break; } + cocos2d::extension::ControlSlider* ret = cocos2d::extension::ControlSlider::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlSlider*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 4) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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::Sprite* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Sprite* arg2; + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Sprite* arg3; + do { + if (!args.get(3).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(3).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg3 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::extension::ControlSlider* ret = cocos2d::extension::ControlSlider::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlSlider*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_extension_ControlSlider_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_extension_ControlSlider_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::extension::ControlSlider* cobj = new (std::nothrow) cocos2d::extension::ControlSlider(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlSlider"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_extension_Control_prototype; + +void js_cocos2d_extension_ControlSlider_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ControlSlider)", obj); +} + +static bool js_cocos2d_extension_ControlSlider_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::extension::ControlSlider *nobj = new (std::nothrow) cocos2d::extension::ControlSlider(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlSlider"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_extension_ControlSlider(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_extension_ControlSlider_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_extension_ControlSlider_class->name = "ControlSlider"; + jsb_cocos2d_extension_ControlSlider_class->addProperty = JS_PropertyStub; + jsb_cocos2d_extension_ControlSlider_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_extension_ControlSlider_class->getProperty = JS_PropertyStub; + jsb_cocos2d_extension_ControlSlider_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_extension_ControlSlider_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_extension_ControlSlider_class->resolve = JS_ResolveStub; + jsb_cocos2d_extension_ControlSlider_class->convert = JS_ConvertStub; + jsb_cocos2d_extension_ControlSlider_class->finalize = js_cocos2d_extension_ControlSlider_finalize; + jsb_cocos2d_extension_ControlSlider_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setBackgroundSprite", js_cocos2dx_extension_ControlSlider_setBackgroundSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaximumAllowedValue", js_cocos2dx_extension_ControlSlider_getMaximumAllowedValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithSprites", js_cocos2dx_extension_ControlSlider_initWithSprites, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMinimumAllowedValue", js_cocos2dx_extension_ControlSlider_getMinimumAllowedValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaximumValue", js_cocos2dx_extension_ControlSlider_getMaximumValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSelectedThumbSprite", js_cocos2dx_extension_ControlSlider_getSelectedThumbSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setProgressSprite", js_cocos2dx_extension_ControlSlider_setProgressSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaximumValue", js_cocos2dx_extension_ControlSlider_setMaximumValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMinimumValue", js_cocos2dx_extension_ControlSlider_getMinimumValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setThumbSprite", js_cocos2dx_extension_ControlSlider_setThumbSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getValue", js_cocos2dx_extension_ControlSlider_getValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackgroundSprite", js_cocos2dx_extension_ControlSlider_getBackgroundSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getThumbSprite", js_cocos2dx_extension_ControlSlider_getThumbSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setValue", js_cocos2dx_extension_ControlSlider_setValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("locationFromTouch", js_cocos2dx_extension_ControlSlider_locationFromTouch, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMinimumValue", js_cocos2dx_extension_ControlSlider_setMinimumValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMinimumAllowedValue", js_cocos2dx_extension_ControlSlider_setMinimumAllowedValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getProgressSprite", js_cocos2dx_extension_ControlSlider_getProgressSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSelectedThumbSprite", js_cocos2dx_extension_ControlSlider_setSelectedThumbSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaximumAllowedValue", js_cocos2dx_extension_ControlSlider_setMaximumAllowedValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_extension_ControlSlider_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_extension_ControlSlider_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_extension_ControlSlider_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + jsb_cocos2d_extension_ControlSlider_class, + js_cocos2dx_extension_ControlSlider_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, "ControlSlider", 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_extension_ControlSlider_class; + p->proto = jsb_cocos2d_extension_ControlSlider_prototype; + p->parentProto = jsb_cocos2d_extension_Control_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_extension_ControlStepper_class; +JSObject *jsb_cocos2d_extension_ControlStepper_prototype; + +bool js_cocos2dx_extension_ControlStepper_getMinusSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_getMinusSprite : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getMinusSprite(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_getMinusSprite : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlStepper_setValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_setValue : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlStepper_setValue : Error processing arguments"); + cobj->setValue(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setValue : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlStepper_setStepValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_setStepValue : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlStepper_setStepValue : Error processing arguments"); + cobj->setStepValue(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setStepValue : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite : Invalid Native Object"); + if (argc == 2) { + cocos2d::Sprite* arg0; + cocos2d::Sprite* arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite : Error processing arguments"); + bool ret = cobj->initWithMinusSpriteAndPlusSprite(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ControlStepper_setValueWithSendingEvent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_setValueWithSendingEvent : Invalid Native Object"); + if (argc == 2) { + double arg0; + bool arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlStepper_setValueWithSendingEvent : Error processing arguments"); + cobj->setValueWithSendingEvent(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setValueWithSendingEvent : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ControlStepper_setMaximumValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_setMaximumValue : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlStepper_setMaximumValue : Error processing arguments"); + cobj->setMaximumValue(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setMaximumValue : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlStepper_getMinusLabel(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_getMinusLabel : Invalid Native Object"); + if (argc == 0) { + cocos2d::Label* ret = cobj->getMinusLabel(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_getMinusLabel : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlStepper_getPlusLabel(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_getPlusLabel : Invalid Native Object"); + if (argc == 0) { + cocos2d::Label* ret = cobj->getPlusLabel(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_getPlusLabel : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlStepper_setWraps(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_setWraps : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlStepper_setWraps : Error processing arguments"); + cobj->setWraps(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setWraps : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlStepper_setMinusLabel(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_setMinusLabel : Invalid Native Object"); + if (argc == 1) { + cocos2d::Label* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Label*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlStepper_setMinusLabel : Error processing arguments"); + cobj->setMinusLabel(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setMinusLabel : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlStepper_startAutorepeat(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_startAutorepeat : Invalid Native Object"); + if (argc == 0) { + cobj->startAutorepeat(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_startAutorepeat : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlStepper_updateLayoutUsingTouchLocation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_updateLayoutUsingTouchLocation : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlStepper_updateLayoutUsingTouchLocation : Error processing arguments"); + cobj->updateLayoutUsingTouchLocation(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_updateLayoutUsingTouchLocation : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlStepper_isContinuous(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_isContinuous : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isContinuous(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_isContinuous : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlStepper_stopAutorepeat(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_stopAutorepeat : Invalid Native Object"); + if (argc == 0) { + cobj->stopAutorepeat(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_stopAutorepeat : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlStepper_setMinimumValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_setMinimumValue : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlStepper_setMinimumValue : Error processing arguments"); + cobj->setMinimumValue(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setMinimumValue : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlStepper_setPlusLabel(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_setPlusLabel : Invalid Native Object"); + if (argc == 1) { + cocos2d::Label* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Label*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlStepper_setPlusLabel : Error processing arguments"); + cobj->setPlusLabel(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setPlusLabel : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlStepper_getValue(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_getValue : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getValue(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_getValue : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlStepper_getPlusSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_getPlusSprite : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getPlusSprite(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_getPlusSprite : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlStepper_setPlusSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_setPlusSprite : Invalid Native Object"); + if (argc == 1) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlStepper_setPlusSprite : Error processing arguments"); + cobj->setPlusSprite(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setPlusSprite : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlStepper_setMinusSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlStepper* cobj = (cocos2d::extension::ControlStepper *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlStepper_setMinusSprite : Invalid Native Object"); + if (argc == 1) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlStepper_setMinusSprite : Error processing arguments"); + cobj->setMinusSprite(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_setMinusSprite : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlStepper_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::Sprite* arg0; + cocos2d::Sprite* arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlStepper_create : Error processing arguments"); + cocos2d::extension::ControlStepper* ret = cocos2d::extension::ControlStepper::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlStepper*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_extension_ControlStepper_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_extension_ControlStepper_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::extension::ControlStepper* cobj = new (std::nothrow) cocos2d::extension::ControlStepper(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlStepper"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_extension_Control_prototype; + +void js_cocos2d_extension_ControlStepper_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ControlStepper)", obj); +} + +static bool js_cocos2d_extension_ControlStepper_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::extension::ControlStepper *nobj = new (std::nothrow) cocos2d::extension::ControlStepper(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlStepper"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_extension_ControlStepper(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_extension_ControlStepper_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_extension_ControlStepper_class->name = "ControlStepper"; + jsb_cocos2d_extension_ControlStepper_class->addProperty = JS_PropertyStub; + jsb_cocos2d_extension_ControlStepper_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_extension_ControlStepper_class->getProperty = JS_PropertyStub; + jsb_cocos2d_extension_ControlStepper_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_extension_ControlStepper_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_extension_ControlStepper_class->resolve = JS_ResolveStub; + jsb_cocos2d_extension_ControlStepper_class->convert = JS_ConvertStub; + jsb_cocos2d_extension_ControlStepper_class->finalize = js_cocos2d_extension_ControlStepper_finalize; + jsb_cocos2d_extension_ControlStepper_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getMinusSprite", js_cocos2dx_extension_ControlStepper_getMinusSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setValue", js_cocos2dx_extension_ControlStepper_setValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setStepValue", js_cocos2dx_extension_ControlStepper_setStepValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithMinusSpriteAndPlusSprite", js_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setValueWithSendingEvent", js_cocos2dx_extension_ControlStepper_setValueWithSendingEvent, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaximumValue", js_cocos2dx_extension_ControlStepper_setMaximumValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMinusLabel", js_cocos2dx_extension_ControlStepper_getMinusLabel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPlusLabel", js_cocos2dx_extension_ControlStepper_getPlusLabel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setWraps", js_cocos2dx_extension_ControlStepper_setWraps, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMinusLabel", js_cocos2dx_extension_ControlStepper_setMinusLabel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("startAutorepeat", js_cocos2dx_extension_ControlStepper_startAutorepeat, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateLayoutUsingTouchLocation", js_cocos2dx_extension_ControlStepper_updateLayoutUsingTouchLocation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isContinuous", js_cocos2dx_extension_ControlStepper_isContinuous, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("stopAutorepeat", js_cocos2dx_extension_ControlStepper_stopAutorepeat, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMinimumValue", js_cocos2dx_extension_ControlStepper_setMinimumValue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPlusLabel", js_cocos2dx_extension_ControlStepper_setPlusLabel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getValue", js_cocos2dx_extension_ControlStepper_getValue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPlusSprite", js_cocos2dx_extension_ControlStepper_getPlusSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPlusSprite", js_cocos2dx_extension_ControlStepper_setPlusSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMinusSprite", js_cocos2dx_extension_ControlStepper_setMinusSprite, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_extension_ControlStepper_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_extension_ControlStepper_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_extension_ControlStepper_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + jsb_cocos2d_extension_ControlStepper_class, + js_cocos2dx_extension_ControlStepper_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, "ControlStepper", 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_extension_ControlStepper_class; + p->proto = jsb_cocos2d_extension_ControlStepper_prototype; + p->parentProto = jsb_cocos2d_extension_Control_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_extension_ControlSwitch_class; +JSObject *jsb_cocos2d_extension_ControlSwitch_prototype; + +bool js_cocos2dx_extension_ControlSwitch_setOn(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::extension::ControlSwitch* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::extension::ControlSwitch *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSwitch_setOn : Invalid Native Object"); + do { + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + cobj->setOn(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 2) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + bool arg1; + arg1 = JS::ToBoolean(args.get(1)); + cobj->setOn(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSwitch_setOn : wrong number of arguments"); + return false; +} +bool js_cocos2dx_extension_ControlSwitch_locationFromTouch(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSwitch* cobj = (cocos2d::extension::ControlSwitch *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSwitch_locationFromTouch : Invalid Native Object"); + if (argc == 1) { + cocos2d::Touch* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlSwitch_locationFromTouch : Error processing arguments"); + cocos2d::Vec2 ret = cobj->locationFromTouch(arg0); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSwitch_locationFromTouch : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ControlSwitch_isOn(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSwitch* cobj = (cocos2d::extension::ControlSwitch *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSwitch_isOn : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isOn(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSwitch_isOn : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::extension::ControlSwitch* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::extension::ControlSwitch *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSwitch_initWithMaskSprite : Invalid Native Object"); + do { + if (argc == 6) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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::Sprite* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Sprite* arg2; + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Sprite* arg3; + do { + if (!args.get(3).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(3).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg3 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Label* arg4; + do { + if (!args.get(4).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(4).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg4 = (cocos2d::Label*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg4, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Label* arg5; + do { + if (!args.get(5).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(5).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg5 = (cocos2d::Label*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg5, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithMaskSprite(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 4) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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::Sprite* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Sprite* arg2; + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Sprite* arg3; + do { + if (!args.get(3).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(3).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg3 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithMaskSprite(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSwitch_initWithMaskSprite : wrong number of arguments"); + return false; +} +bool js_cocos2dx_extension_ControlSwitch_hasMoved(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ControlSwitch* cobj = (cocos2d::extension::ControlSwitch *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlSwitch_hasMoved : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->hasMoved(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ControlSwitch_hasMoved : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 4) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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::Sprite* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Sprite* arg2; + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Sprite* arg3; + do { + if (!args.get(3).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(3).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg3 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::extension::ControlSwitch* ret = cocos2d::extension::ControlSwitch::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlSwitch*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 6) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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::Sprite* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Sprite* arg2; + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Sprite* arg3; + do { + if (!args.get(3).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(3).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg3 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Label* arg4; + do { + if (!args.get(4).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(4).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg4 = (cocos2d::Label*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg4, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Label* arg5; + do { + if (!args.get(5).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(5).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg5 = (cocos2d::Label*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg5, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::extension::ControlSwitch* ret = cocos2d::extension::ControlSwitch::create(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ControlSwitch*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_extension_ControlSwitch_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_extension_ControlSwitch_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::extension::ControlSwitch* cobj = new (std::nothrow) cocos2d::extension::ControlSwitch(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlSwitch"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_extension_Control_prototype; + +void js_cocos2d_extension_ControlSwitch_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ControlSwitch)", obj); +} + +static bool js_cocos2d_extension_ControlSwitch_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::extension::ControlSwitch *nobj = new (std::nothrow) cocos2d::extension::ControlSwitch(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ControlSwitch"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_extension_ControlSwitch(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_extension_ControlSwitch_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_extension_ControlSwitch_class->name = "ControlSwitch"; + jsb_cocos2d_extension_ControlSwitch_class->addProperty = JS_PropertyStub; + jsb_cocos2d_extension_ControlSwitch_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_extension_ControlSwitch_class->getProperty = JS_PropertyStub; + jsb_cocos2d_extension_ControlSwitch_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_extension_ControlSwitch_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_extension_ControlSwitch_class->resolve = JS_ResolveStub; + jsb_cocos2d_extension_ControlSwitch_class->convert = JS_ConvertStub; + jsb_cocos2d_extension_ControlSwitch_class->finalize = js_cocos2d_extension_ControlSwitch_finalize; + jsb_cocos2d_extension_ControlSwitch_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setOn", js_cocos2dx_extension_ControlSwitch_setOn, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("locationFromTouch", js_cocos2dx_extension_ControlSwitch_locationFromTouch, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isOn", js_cocos2dx_extension_ControlSwitch_isOn, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithMaskSprite", js_cocos2dx_extension_ControlSwitch_initWithMaskSprite, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("hasMoved", js_cocos2dx_extension_ControlSwitch_hasMoved, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_extension_ControlSwitch_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_extension_ControlSwitch_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_extension_ControlSwitch_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_extension_Control_prototype), + jsb_cocos2d_extension_ControlSwitch_class, + js_cocos2dx_extension_ControlSwitch_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, "ControlSwitch", 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_extension_ControlSwitch_class; + p->proto = jsb_cocos2d_extension_ControlSwitch_prototype; + p->parentProto = jsb_cocos2d_extension_Control_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_extension_ScrollView_class; +JSObject *jsb_cocos2d_extension_ScrollView_prototype; + +bool js_cocos2dx_extension_ScrollView_isClippingToBounds(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_isClippingToBounds : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isClippingToBounds(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_isClippingToBounds : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ScrollView_setContainer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_setContainer : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ScrollView_setContainer : Error processing arguments"); + cobj->setContainer(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setContainer : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ScrollView_setContentOffsetInDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_setContentOffsetInDuration : Invalid Native Object"); + if (argc == 2) { + cocos2d::Vec2 arg0; + double arg1; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ScrollView_setContentOffsetInDuration : Error processing arguments"); + cobj->setContentOffsetInDuration(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setContentOffsetInDuration : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ScrollView_setZoomScaleInDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_setZoomScaleInDuration : Invalid Native Object"); + if (argc == 2) { + double arg0; + double arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ScrollView_setZoomScaleInDuration : Error processing arguments"); + cobj->setZoomScaleInDuration(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setZoomScaleInDuration : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ScrollView_updateTweenAction(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_updateTweenAction : Invalid Native Object"); + if (argc == 2) { + double arg0; + std::string arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ScrollView_updateTweenAction : Error processing arguments"); + cobj->updateTweenAction(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_updateTweenAction : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_ScrollView_setMaxScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_setMaxScale : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ScrollView_setMaxScale : Error processing arguments"); + cobj->setMaxScale(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setMaxScale : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ScrollView_hasVisibleParents(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_hasVisibleParents : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->hasVisibleParents(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_hasVisibleParents : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ScrollView_getDirection(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_getDirection : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getDirection(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_getDirection : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ScrollView_getContainer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_getContainer : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getContainer(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_getContainer : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ScrollView_setMinScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_setMinScale : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ScrollView_setMinScale : Error processing arguments"); + cobj->setMinScale(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setMinScale : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ScrollView_getZoomScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_getZoomScale : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getZoomScale(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_getZoomScale : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ScrollView_updateInset(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_updateInset : Invalid Native Object"); + if (argc == 0) { + cobj->updateInset(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_updateInset : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ScrollView_initWithViewSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_initWithViewSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ScrollView_initWithViewSize : Error processing arguments"); + bool ret = cobj->initWithViewSize(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + cocos2d::Size arg0; + cocos2d::Node* arg1; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ScrollView_initWithViewSize : Error processing arguments"); + bool ret = cobj->initWithViewSize(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_initWithViewSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ScrollView_pause(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_pause : Invalid Native Object"); + if (argc == 1) { + cocos2d::Ref* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ScrollView_pause : Error processing arguments"); + cobj->pause(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_pause : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ScrollView_setDirection(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_setDirection : Invalid Native Object"); + if (argc == 1) { + cocos2d::extension::ScrollView::Direction arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ScrollView_setDirection : Error processing arguments"); + cobj->setDirection(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setDirection : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ScrollView_setBounceable(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_setBounceable : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ScrollView_setBounceable : Error processing arguments"); + cobj->setBounceable(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setBounceable : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ScrollView_setContentOffset(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_setContentOffset : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ScrollView_setContentOffset : Error processing arguments"); + cobj->setContentOffset(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + cocos2d::Vec2 arg0; + bool arg1; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ScrollView_setContentOffset : Error processing arguments"); + cobj->setContentOffset(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setContentOffset : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ScrollView_isDragging(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_isDragging : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isDragging(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_isDragging : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ScrollView_isTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_isTouchEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isTouchEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_isTouchEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ScrollView_isBounceable(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_isBounceable : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isBounceable(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_isBounceable : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ScrollView_setTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_setTouchEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ScrollView_setTouchEnabled : Error processing arguments"); + cobj->setTouchEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setTouchEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ScrollView_getContentOffset(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_getContentOffset : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getContentOffset(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_getContentOffset : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ScrollView_resume(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_resume : Invalid Native Object"); + if (argc == 1) { + cocos2d::Ref* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ScrollView_resume : Error processing arguments"); + cobj->resume(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_resume : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ScrollView_setClippingToBounds(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_setClippingToBounds : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ScrollView_setClippingToBounds : Error processing arguments"); + cobj->setClippingToBounds(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setClippingToBounds : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ScrollView_setViewSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_setViewSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ScrollView_setViewSize : Error processing arguments"); + cobj->setViewSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setViewSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ScrollView_getViewSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_getViewSize : Invalid Native Object"); + if (argc == 0) { + cocos2d::Size ret = cobj->getViewSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_getViewSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ScrollView_maxContainerOffset(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_maxContainerOffset : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->maxContainerOffset(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_maxContainerOffset : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ScrollView_isTouchMoved(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_isTouchMoved : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isTouchMoved(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_isTouchMoved : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ScrollView_isNodeVisible(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_isNodeVisible : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ScrollView_isNodeVisible : Error processing arguments"); + bool ret = cobj->isNodeVisible(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_isNodeVisible : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_ScrollView_minContainerOffset(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_minContainerOffset : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->minContainerOffset(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_minContainerOffset : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_ScrollView_setZoomScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::extension::ScrollView* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ScrollView_setZoomScale : Invalid Native Object"); + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + bool arg1; + arg1 = JS::ToBoolean(args.get(1)); + cobj->setZoomScale(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + cobj->setZoomScale(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_setZoomScale : wrong number of arguments"); + return false; +} +bool js_cocos2dx_extension_ScrollView_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 0) { + cocos2d::extension::ScrollView* ret = cocos2d::extension::ScrollView::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ScrollView*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::extension::ScrollView* ret = cocos2d::extension::ScrollView::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ScrollView*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 2) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Node* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::extension::ScrollView* ret = cocos2d::extension::ScrollView::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::ScrollView*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_extension_ScrollView_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_extension_ScrollView_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::extension::ScrollView* cobj = new (std::nothrow) cocos2d::extension::ScrollView(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ScrollView"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Layer_prototype; + +void js_cocos2d_extension_ScrollView_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ScrollView)", obj); +} + +static bool js_cocos2d_extension_ScrollView_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::extension::ScrollView *nobj = new (std::nothrow) cocos2d::extension::ScrollView(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::ScrollView"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_extension_ScrollView(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_extension_ScrollView_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_extension_ScrollView_class->name = "ScrollView"; + jsb_cocos2d_extension_ScrollView_class->addProperty = JS_PropertyStub; + jsb_cocos2d_extension_ScrollView_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_extension_ScrollView_class->getProperty = JS_PropertyStub; + jsb_cocos2d_extension_ScrollView_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_extension_ScrollView_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_extension_ScrollView_class->resolve = JS_ResolveStub; + jsb_cocos2d_extension_ScrollView_class->convert = JS_ConvertStub; + jsb_cocos2d_extension_ScrollView_class->finalize = js_cocos2d_extension_ScrollView_finalize; + jsb_cocos2d_extension_ScrollView_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("isClippingToBounds", js_cocos2dx_extension_ScrollView_isClippingToBounds, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setContainer", js_cocos2dx_extension_ScrollView_setContainer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setContentOffsetInDuration", js_cocos2dx_extension_ScrollView_setContentOffsetInDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setZoomScaleInDuration", js_cocos2dx_extension_ScrollView_setZoomScaleInDuration, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateTweenAction", js_cocos2dx_extension_ScrollView_updateTweenAction, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaxScale", js_cocos2dx_extension_ScrollView_setMaxScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("hasVisibleParents", js_cocos2dx_extension_ScrollView_hasVisibleParents, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDirection", js_cocos2dx_extension_ScrollView_getDirection, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getContainer", js_cocos2dx_extension_ScrollView_getContainer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMinScale", js_cocos2dx_extension_ScrollView_setMinScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getZoomScale", js_cocos2dx_extension_ScrollView_getZoomScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateInset", js_cocos2dx_extension_ScrollView_updateInset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithViewSize", js_cocos2dx_extension_ScrollView_initWithViewSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pause", js_cocos2dx_extension_ScrollView_pause, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDirection", js_cocos2dx_extension_ScrollView_setDirection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBounceable", js_cocos2dx_extension_ScrollView_setBounceable, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setContentOffset", js_cocos2dx_extension_ScrollView_setContentOffset, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isDragging", js_cocos2dx_extension_ScrollView_isDragging, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isTouchEnabled", js_cocos2dx_extension_ScrollView_isTouchEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isBounceable", js_cocos2dx_extension_ScrollView_isBounceable, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTouchEnabled", js_cocos2dx_extension_ScrollView_setTouchEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getContentOffset", js_cocos2dx_extension_ScrollView_getContentOffset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resume", js_cocos2dx_extension_ScrollView_resume, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setClippingToBounds", js_cocos2dx_extension_ScrollView_setClippingToBounds, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setViewSize", js_cocos2dx_extension_ScrollView_setViewSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getViewSize", js_cocos2dx_extension_ScrollView_getViewSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("maxContainerOffset", js_cocos2dx_extension_ScrollView_maxContainerOffset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isTouchMoved", js_cocos2dx_extension_ScrollView_isTouchMoved, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isNodeVisible", js_cocos2dx_extension_ScrollView_isNodeVisible, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("minContainerOffset", js_cocos2dx_extension_ScrollView_minContainerOffset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setZoomScale", js_cocos2dx_extension_ScrollView_setZoomScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_extension_ScrollView_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_extension_ScrollView_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_extension_ScrollView_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Layer_prototype), + jsb_cocos2d_extension_ScrollView_class, + js_cocos2dx_extension_ScrollView_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, "ScrollView", 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_extension_ScrollView_class; + p->proto = jsb_cocos2d_extension_ScrollView_prototype; + p->parentProto = jsb_cocos2d_Layer_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_extension_TableViewCell_class; +JSObject *jsb_cocos2d_extension_TableViewCell_prototype; + +bool js_cocos2dx_extension_TableViewCell_reset(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableViewCell* cobj = (cocos2d::extension::TableViewCell *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_TableViewCell_reset : Invalid Native Object"); + if (argc == 0) { + cobj->reset(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_TableViewCell_reset : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_TableViewCell_getIdx(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableViewCell* cobj = (cocos2d::extension::TableViewCell *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_TableViewCell_getIdx : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getIdx(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_TableViewCell_getIdx : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_TableViewCell_setIdx(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableViewCell* cobj = (cocos2d::extension::TableViewCell *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_TableViewCell_setIdx : Invalid Native Object"); + if (argc == 1) { + ssize_t arg0; + ok &= jsval_to_ssize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_TableViewCell_setIdx : Error processing arguments"); + cobj->setIdx(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_TableViewCell_setIdx : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_TableViewCell_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::extension::TableViewCell* ret = cocos2d::extension::TableViewCell::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::TableViewCell*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_extension_TableViewCell_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_extension_TableViewCell_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::extension::TableViewCell* cobj = new (std::nothrow) cocos2d::extension::TableViewCell(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::TableViewCell"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_extension_TableViewCell_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TableViewCell)", obj); +} + +static bool js_cocos2d_extension_TableViewCell_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::extension::TableViewCell *nobj = new (std::nothrow) cocos2d::extension::TableViewCell(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::TableViewCell"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_extension_TableViewCell(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_extension_TableViewCell_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_extension_TableViewCell_class->name = "TableViewCell"; + jsb_cocos2d_extension_TableViewCell_class->addProperty = JS_PropertyStub; + jsb_cocos2d_extension_TableViewCell_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_extension_TableViewCell_class->getProperty = JS_PropertyStub; + jsb_cocos2d_extension_TableViewCell_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_extension_TableViewCell_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_extension_TableViewCell_class->resolve = JS_ResolveStub; + jsb_cocos2d_extension_TableViewCell_class->convert = JS_ConvertStub; + jsb_cocos2d_extension_TableViewCell_class->finalize = js_cocos2d_extension_TableViewCell_finalize; + jsb_cocos2d_extension_TableViewCell_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("reset", js_cocos2dx_extension_TableViewCell_reset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getIdx", js_cocos2dx_extension_TableViewCell_getIdx, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setIdx", js_cocos2dx_extension_TableViewCell_setIdx, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_extension_TableViewCell_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_extension_TableViewCell_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_extension_TableViewCell_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_extension_TableViewCell_class, + js_cocos2dx_extension_TableViewCell_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, "TableViewCell", 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_extension_TableViewCell_class; + p->proto = jsb_cocos2d_extension_TableViewCell_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_extension_TableView_class; +JSObject *jsb_cocos2d_extension_TableView_prototype; + +bool js_cocos2dx_extension_TableView_updateCellAtIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_TableView_updateCellAtIndex : Invalid Native Object"); + if (argc == 1) { + ssize_t arg0; + ok &= jsval_to_ssize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_TableView_updateCellAtIndex : Error processing arguments"); + cobj->updateCellAtIndex(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_TableView_updateCellAtIndex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_TableView_setVerticalFillOrder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_TableView_setVerticalFillOrder : Invalid Native Object"); + if (argc == 1) { + cocos2d::extension::TableView::VerticalFillOrder arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_TableView_setVerticalFillOrder : Error processing arguments"); + cobj->setVerticalFillOrder(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_TableView_setVerticalFillOrder : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_TableView_scrollViewDidZoom(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_TableView_scrollViewDidZoom : Invalid Native Object"); + if (argc == 1) { + cocos2d::extension::ScrollView* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::extension::ScrollView*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_TableView_scrollViewDidZoom : Error processing arguments"); + cobj->scrollViewDidZoom(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_TableView_scrollViewDidZoom : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_TableView__updateContentSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_TableView__updateContentSize : Invalid Native Object"); + if (argc == 0) { + cobj->_updateContentSize(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_TableView__updateContentSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_TableView_getVerticalFillOrder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_TableView_getVerticalFillOrder : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getVerticalFillOrder(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_TableView_getVerticalFillOrder : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_TableView_removeCellAtIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_TableView_removeCellAtIndex : Invalid Native Object"); + if (argc == 1) { + ssize_t arg0; + ok &= jsval_to_ssize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_TableView_removeCellAtIndex : Error processing arguments"); + cobj->removeCellAtIndex(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_TableView_removeCellAtIndex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_TableView_initWithViewSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_TableView_initWithViewSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_TableView_initWithViewSize : Error processing arguments"); + bool ret = cobj->initWithViewSize(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + cocos2d::Size arg0; + cocos2d::Node* arg1; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_TableView_initWithViewSize : Error processing arguments"); + bool ret = cobj->initWithViewSize(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_TableView_initWithViewSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_TableView_scrollViewDidScroll(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_TableView_scrollViewDidScroll : Invalid Native Object"); + if (argc == 1) { + cocos2d::extension::ScrollView* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::extension::ScrollView*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_TableView_scrollViewDidScroll : Error processing arguments"); + cobj->scrollViewDidScroll(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_TableView_scrollViewDidScroll : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_TableView_reloadData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_TableView_reloadData : Invalid Native Object"); + if (argc == 0) { + cobj->reloadData(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_TableView_reloadData : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_TableView_insertCellAtIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_TableView_insertCellAtIndex : Invalid Native Object"); + if (argc == 1) { + ssize_t arg0; + ok &= jsval_to_ssize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_TableView_insertCellAtIndex : Error processing arguments"); + cobj->insertCellAtIndex(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_TableView_insertCellAtIndex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_TableView_cellAtIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_TableView_cellAtIndex : Invalid Native Object"); + if (argc == 1) { + ssize_t arg0; + ok &= jsval_to_ssize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_TableView_cellAtIndex : Error processing arguments"); + cocos2d::extension::TableViewCell* ret = cobj->cellAtIndex(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::TableViewCell*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_TableView_cellAtIndex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_extension_TableView_dequeueCell(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_TableView_dequeueCell : Invalid Native Object"); + if (argc == 0) { + cocos2d::extension::TableViewCell* ret = cobj->dequeueCell(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::TableViewCell*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_TableView_dequeueCell : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_TableView_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::extension::TableView* cobj = new (std::nothrow) cocos2d::extension::TableView(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::TableView"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_extension_ScrollView_prototype; + +void js_cocos2d_extension_TableView_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TableView)", obj); +} + +static bool js_cocos2d_extension_TableView_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::extension::TableView *nobj = new (std::nothrow) cocos2d::extension::TableView(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::TableView"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_extension_TableView(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_extension_TableView_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_extension_TableView_class->name = "TableView"; + jsb_cocos2d_extension_TableView_class->addProperty = JS_PropertyStub; + jsb_cocos2d_extension_TableView_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_extension_TableView_class->getProperty = JS_PropertyStub; + jsb_cocos2d_extension_TableView_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_extension_TableView_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_extension_TableView_class->resolve = JS_ResolveStub; + jsb_cocos2d_extension_TableView_class->convert = JS_ConvertStub; + jsb_cocos2d_extension_TableView_class->finalize = js_cocos2d_extension_TableView_finalize; + jsb_cocos2d_extension_TableView_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("updateCellAtIndex", js_cocos2dx_extension_TableView_updateCellAtIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setVerticalFillOrder", js_cocos2dx_extension_TableView_setVerticalFillOrder, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("scrollViewDidZoom", js_cocos2dx_extension_TableView_scrollViewDidZoom, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("_updateContentSize", js_cocos2dx_extension_TableView__updateContentSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVerticalFillOrder", js_cocos2dx_extension_TableView_getVerticalFillOrder, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeCellAtIndex", js_cocos2dx_extension_TableView_removeCellAtIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithViewSize", js_cocos2dx_extension_TableView_initWithViewSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("scrollViewDidScroll", js_cocos2dx_extension_TableView_scrollViewDidScroll, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("reloadData", js_cocos2dx_extension_TableView_reloadData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("insertCellAtIndex", js_cocos2dx_extension_TableView_insertCellAtIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("cellAtIndex", js_cocos2dx_extension_TableView_cellAtIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("dequeueCell", js_cocos2dx_extension_TableView_dequeueCell, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_extension_TableView_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_extension_TableView_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_extension_ScrollView_prototype), + jsb_cocos2d_extension_TableView_class, + js_cocos2dx_extension_TableView_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, "TableView", 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_extension_TableView_class; + p->proto = jsb_cocos2d_extension_TableView_prototype; + p->parentProto = jsb_cocos2d_extension_ScrollView_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_extension_EventAssetsManagerEx_class; +JSObject *jsb_cocos2d_extension_EventAssetsManagerEx_prototype; + +bool js_cocos2dx_extension_EventAssetsManagerEx_getAssetsManagerEx(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::EventAssetsManagerEx* cobj = (cocos2d::extension::EventAssetsManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_EventAssetsManagerEx_getAssetsManagerEx : Invalid Native Object"); + if (argc == 0) { + cocos2d::extension::AssetsManagerEx* ret = cobj->getAssetsManagerEx(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::AssetsManagerEx*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_EventAssetsManagerEx_getAssetsManagerEx : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_EventAssetsManagerEx_getAssetId(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::EventAssetsManagerEx* cobj = (cocos2d::extension::EventAssetsManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_EventAssetsManagerEx_getAssetId : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getAssetId(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_EventAssetsManagerEx_getAssetId : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_EventAssetsManagerEx_getCURLECode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::EventAssetsManagerEx* cobj = (cocos2d::extension::EventAssetsManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_EventAssetsManagerEx_getCURLECode : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getCURLECode(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_EventAssetsManagerEx_getCURLECode : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_EventAssetsManagerEx_getMessage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::EventAssetsManagerEx* cobj = (cocos2d::extension::EventAssetsManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_EventAssetsManagerEx_getMessage : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getMessage(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_EventAssetsManagerEx_getMessage : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_EventAssetsManagerEx_getCURLMCode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::EventAssetsManagerEx* cobj = (cocos2d::extension::EventAssetsManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_EventAssetsManagerEx_getCURLMCode : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getCURLMCode(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_EventAssetsManagerEx_getCURLMCode : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_EventAssetsManagerEx_getPercentByFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::EventAssetsManagerEx* cobj = (cocos2d::extension::EventAssetsManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_EventAssetsManagerEx_getPercentByFile : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getPercentByFile(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_EventAssetsManagerEx_getPercentByFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_EventAssetsManagerEx_getEventCode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::EventAssetsManagerEx* cobj = (cocos2d::extension::EventAssetsManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_EventAssetsManagerEx_getEventCode : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getEventCode(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_EventAssetsManagerEx_getEventCode : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_EventAssetsManagerEx_getPercent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::EventAssetsManagerEx* cobj = (cocos2d::extension::EventAssetsManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_EventAssetsManagerEx_getPercent : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getPercent(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_EventAssetsManagerEx_getPercent : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_EventAssetsManagerEx_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + std::string arg0; + cocos2d::extension::AssetsManagerEx* arg1; + cocos2d::extension::EventAssetsManagerEx::EventCode arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::extension::AssetsManagerEx*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_EventAssetsManagerEx_constructor : Error processing arguments"); + cocos2d::extension::EventAssetsManagerEx* cobj = new (std::nothrow) cocos2d::extension::EventAssetsManagerEx(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."); + // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::EventAssetsManagerEx"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_EventCustom_prototype; + +void js_cocos2d_extension_EventAssetsManagerEx_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EventAssetsManagerEx)", obj); +} + +void js_register_cocos2dx_extension_EventAssetsManagerEx(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_extension_EventAssetsManagerEx_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_extension_EventAssetsManagerEx_class->name = "EventAssetsManager"; + jsb_cocos2d_extension_EventAssetsManagerEx_class->addProperty = JS_PropertyStub; + jsb_cocos2d_extension_EventAssetsManagerEx_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_extension_EventAssetsManagerEx_class->getProperty = JS_PropertyStub; + jsb_cocos2d_extension_EventAssetsManagerEx_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_extension_EventAssetsManagerEx_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_extension_EventAssetsManagerEx_class->resolve = JS_ResolveStub; + jsb_cocos2d_extension_EventAssetsManagerEx_class->convert = JS_ConvertStub; + jsb_cocos2d_extension_EventAssetsManagerEx_class->finalize = js_cocos2d_extension_EventAssetsManagerEx_finalize; + jsb_cocos2d_extension_EventAssetsManagerEx_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getAssetsManagerEx", js_cocos2dx_extension_EventAssetsManagerEx_getAssetsManagerEx, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAssetId", js_cocos2dx_extension_EventAssetsManagerEx_getAssetId, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCURLECode", js_cocos2dx_extension_EventAssetsManagerEx_getCURLECode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMessage", js_cocos2dx_extension_EventAssetsManagerEx_getMessage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCURLMCode", js_cocos2dx_extension_EventAssetsManagerEx_getCURLMCode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPercentByFile", js_cocos2dx_extension_EventAssetsManagerEx_getPercentByFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEventCode", js_cocos2dx_extension_EventAssetsManagerEx_getEventCode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPercent", js_cocos2dx_extension_EventAssetsManagerEx_getPercent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_extension_EventAssetsManagerEx_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_EventCustom_prototype), + jsb_cocos2d_extension_EventAssetsManagerEx_class, + js_cocos2dx_extension_EventAssetsManagerEx_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, "EventAssetsManager", 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_extension_EventAssetsManagerEx_class; + p->proto = jsb_cocos2d_extension_EventAssetsManagerEx_prototype; + p->parentProto = jsb_cocos2d_EventCustom_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_extension_Manifest_class; +JSObject *jsb_cocos2d_extension_Manifest_prototype; + +bool js_cocos2dx_extension_Manifest_getManifestFileUrl(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getManifestFileUrl : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getManifestFileUrl(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_Manifest_getManifestFileUrl : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_Manifest_isVersionLoaded(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isVersionLoaded : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isVersionLoaded(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_Manifest_isVersionLoaded : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_Manifest_isLoaded(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isLoaded : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isLoaded(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_Manifest_isLoaded : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_Manifest_getPackageUrl(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getPackageUrl : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getPackageUrl(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_Manifest_getPackageUrl : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_Manifest_getVersion(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getVersion : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getVersion(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_Manifest_getVersion : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_Manifest_getVersionFileUrl(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getVersionFileUrl : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getVersionFileUrl(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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) { + CCLOGINFO("jsbindings: finalizing JS object %p (Manifest)", obj); +} + +void js_register_cocos2dx_extension_Manifest(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_extension_Manifest_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_extension_Manifest_class->name = "Manifest"; + jsb_cocos2d_extension_Manifest_class->addProperty = JS_PropertyStub; + jsb_cocos2d_extension_Manifest_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_extension_Manifest_class->getProperty = JS_PropertyStub; + jsb_cocos2d_extension_Manifest_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_extension_Manifest_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_extension_Manifest_class->resolve = JS_ResolveStub; + jsb_cocos2d_extension_Manifest_class->convert = JS_ConvertStub; + jsb_cocos2d_extension_Manifest_class->finalize = js_cocos2d_extension_Manifest_finalize; + jsb_cocos2d_extension_Manifest_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getManifestFileUrl", js_cocos2dx_extension_Manifest_getManifestFileUrl, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isVersionLoaded", js_cocos2dx_extension_Manifest_isVersionLoaded, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isLoaded", js_cocos2dx_extension_Manifest_isLoaded, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + 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 + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_extension_Manifest_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_extension_Manifest_class, + empty_constructor, 0, + 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, "Manifest", 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_extension_Manifest_class; + p->proto = jsb_cocos2d_extension_Manifest_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_extension_AssetsManagerEx_class; +JSObject *jsb_cocos2d_extension_AssetsManagerEx_prototype; + +bool js_cocos2dx_extension_AssetsManagerEx_getState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::AssetsManagerEx* cobj = (cocos2d::extension::AssetsManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_AssetsManagerEx_getState : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getState(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_AssetsManagerEx_getState : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_AssetsManagerEx_checkUpdate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::AssetsManagerEx* cobj = (cocos2d::extension::AssetsManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_AssetsManagerEx_checkUpdate : Invalid Native Object"); + if (argc == 0) { + cobj->checkUpdate(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_AssetsManagerEx_checkUpdate : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_AssetsManagerEx_getStoragePath(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::AssetsManagerEx* cobj = (cocos2d::extension::AssetsManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_AssetsManagerEx_getStoragePath : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getStoragePath(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_AssetsManagerEx_getStoragePath : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_AssetsManagerEx_update(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::AssetsManagerEx* cobj = (cocos2d::extension::AssetsManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_AssetsManagerEx_update : Invalid Native Object"); + if (argc == 0) { + cobj->update(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_AssetsManagerEx_update : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_AssetsManagerEx_getLocalManifest(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::AssetsManagerEx* cobj = (cocos2d::extension::AssetsManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_AssetsManagerEx_getLocalManifest : Invalid Native Object"); + if (argc == 0) { + const cocos2d::extension::Manifest* ret = cobj->getLocalManifest(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::Manifest*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_AssetsManagerEx_getLocalManifest : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_AssetsManagerEx_getRemoteManifest(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::AssetsManagerEx* cobj = (cocos2d::extension::AssetsManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_AssetsManagerEx_getRemoteManifest : Invalid Native Object"); + if (argc == 0) { + const cocos2d::extension::Manifest* ret = cobj->getRemoteManifest(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::Manifest*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_AssetsManagerEx_getRemoteManifest : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_AssetsManagerEx_downloadFailedAssets(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::AssetsManagerEx* cobj = (cocos2d::extension::AssetsManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_AssetsManagerEx_downloadFailedAssets : Invalid Native Object"); + if (argc == 0) { + cobj->downloadFailedAssets(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_AssetsManagerEx_downloadFailedAssets : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_extension_AssetsManagerEx_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_AssetsManagerEx_create : Error processing arguments"); + cocos2d::extension::AssetsManagerEx* ret = cocos2d::extension::AssetsManagerEx::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::AssetsManagerEx*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_extension_AssetsManagerEx_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_extension_AssetsManagerEx_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_AssetsManagerEx_constructor : Error processing arguments"); + cocos2d::extension::AssetsManagerEx* cobj = new (std::nothrow) cocos2d::extension::AssetsManagerEx(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."); + // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::AssetsManagerEx"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_extension_AssetsManagerEx_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (AssetsManagerEx)", obj); +} + +void js_register_cocos2dx_extension_AssetsManagerEx(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_extension_AssetsManagerEx_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_extension_AssetsManagerEx_class->name = "AssetsManager"; + jsb_cocos2d_extension_AssetsManagerEx_class->addProperty = JS_PropertyStub; + jsb_cocos2d_extension_AssetsManagerEx_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_extension_AssetsManagerEx_class->getProperty = JS_PropertyStub; + jsb_cocos2d_extension_AssetsManagerEx_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_extension_AssetsManagerEx_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_extension_AssetsManagerEx_class->resolve = JS_ResolveStub; + jsb_cocos2d_extension_AssetsManagerEx_class->convert = JS_ConvertStub; + jsb_cocos2d_extension_AssetsManagerEx_class->finalize = js_cocos2d_extension_AssetsManagerEx_finalize; + jsb_cocos2d_extension_AssetsManagerEx_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getState", js_cocos2dx_extension_AssetsManagerEx_getState, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("checkUpdate", js_cocos2dx_extension_AssetsManagerEx_checkUpdate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStoragePath", js_cocos2dx_extension_AssetsManagerEx_getStoragePath, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("update", js_cocos2dx_extension_AssetsManagerEx_update, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLocalManifest", js_cocos2dx_extension_AssetsManagerEx_getLocalManifest, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRemoteManifest", js_cocos2dx_extension_AssetsManagerEx_getRemoteManifest, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("downloadFailedAssets", js_cocos2dx_extension_AssetsManagerEx_downloadFailedAssets, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_extension_AssetsManagerEx_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_extension_AssetsManagerEx_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_extension_AssetsManagerEx_class, + js_cocos2dx_extension_AssetsManagerEx_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, "AssetsManager", 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_extension_AssetsManagerEx_class; + p->proto = jsb_cocos2d_extension_AssetsManagerEx_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_extension_EventListenerAssetsManagerEx_class; +JSObject *jsb_cocos2d_extension_EventListenerAssetsManagerEx_prototype; + +bool js_cocos2dx_extension_EventListenerAssetsManagerEx_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::EventListenerAssetsManagerEx* cobj = (cocos2d::extension::EventListenerAssetsManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_EventListenerAssetsManagerEx_init : Invalid Native Object"); + if (argc == 2) { + const cocos2d::extension::AssetsManagerEx* arg0; + std::function arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (const cocos2d::extension::AssetsManagerEx*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + do { + if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + auto lambda = [=](cocos2d::extension::EventAssetsManagerEx* larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + JS::RootedValue rval(cx); + 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"); + bool ret = cobj->init(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_EventListenerAssetsManagerEx_init : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_extension_EventListenerAssetsManagerEx_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::extension::AssetsManagerEx* arg0; + std::function arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::extension::AssetsManagerEx*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + do { + if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + auto lambda = [=](cocos2d::extension::EventAssetsManagerEx* larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + JS::RootedValue rval(cx); + 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"); + cocos2d::extension::EventListenerAssetsManagerEx* ret = cocos2d::extension::EventListenerAssetsManagerEx::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::EventListenerAssetsManagerEx*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_extension_EventListenerAssetsManagerEx_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_extension_EventListenerAssetsManagerEx_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::extension::EventListenerAssetsManagerEx* cobj = new (std::nothrow) cocos2d::extension::EventListenerAssetsManagerEx(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::EventListenerAssetsManagerEx"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_EventListenerCustom_prototype; + +void js_cocos2d_extension_EventListenerAssetsManagerEx_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EventListenerAssetsManagerEx)", obj); +} + +void js_register_cocos2dx_extension_EventListenerAssetsManagerEx(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_extension_EventListenerAssetsManagerEx_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_extension_EventListenerAssetsManagerEx_class->name = "EventListenerAssetsManager"; + jsb_cocos2d_extension_EventListenerAssetsManagerEx_class->addProperty = JS_PropertyStub; + jsb_cocos2d_extension_EventListenerAssetsManagerEx_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_extension_EventListenerAssetsManagerEx_class->getProperty = JS_PropertyStub; + jsb_cocos2d_extension_EventListenerAssetsManagerEx_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_extension_EventListenerAssetsManagerEx_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_extension_EventListenerAssetsManagerEx_class->resolve = JS_ResolveStub; + jsb_cocos2d_extension_EventListenerAssetsManagerEx_class->convert = JS_ConvertStub; + jsb_cocos2d_extension_EventListenerAssetsManagerEx_class->finalize = js_cocos2d_extension_EventListenerAssetsManagerEx_finalize; + jsb_cocos2d_extension_EventListenerAssetsManagerEx_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_extension_EventListenerAssetsManagerEx_init, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_extension_EventListenerAssetsManagerEx_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_extension_EventListenerAssetsManagerEx_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_EventListenerCustom_prototype), + jsb_cocos2d_extension_EventListenerAssetsManagerEx_class, + js_cocos2dx_extension_EventListenerAssetsManagerEx_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, "EventListenerAssetsManager", 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_extension_EventListenerAssetsManagerEx_class; + p->proto = jsb_cocos2d_extension_EventListenerAssetsManagerEx_prototype; + p->parentProto = jsb_cocos2d_EventListenerCustom_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +void register_all_cocos2dx_extension(JSContext* cx, JS::HandleObject obj) { + // Get the ns + JS::RootedObject ns(cx); + get_or_create_js_obj(cx, obj, "cc", &ns); + + js_register_cocos2dx_extension_AssetsManagerEx(cx, ns); + js_register_cocos2dx_extension_Control(cx, ns); + js_register_cocos2dx_extension_ControlHuePicker(cx, ns); + js_register_cocos2dx_extension_TableViewCell(cx, ns); + js_register_cocos2dx_extension_ControlStepper(cx, ns); + js_register_cocos2dx_extension_ControlColourPicker(cx, ns); + js_register_cocos2dx_extension_ControlButton(cx, ns); + js_register_cocos2dx_extension_ControlSlider(cx, ns); + js_register_cocos2dx_extension_ControlSaturationBrightnessPicker(cx, ns); + js_register_cocos2dx_extension_ScrollView(cx, ns); + js_register_cocos2dx_extension_Manifest(cx, ns); + js_register_cocos2dx_extension_ControlPotentiometer(cx, ns); + js_register_cocos2dx_extension_EventAssetsManagerEx(cx, ns); + js_register_cocos2dx_extension_TableView(cx, ns); + js_register_cocos2dx_extension_EventListenerAssetsManagerEx(cx, ns); + js_register_cocos2dx_extension_ControlSwitch(cx, ns); +} + diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.hpp new file mode 100644 index 0000000000..8700193dd0 --- /dev/null +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.hpp @@ -0,0 +1,372 @@ +#ifndef __cocos2dx_extension_h__ +#define __cocos2dx_extension_h__ + +#include "jsapi.h" +#include "jsfriendapi.h" + + +extern JSClass *jsb_cocos2d_extension_Control_class; +extern JSObject *jsb_cocos2d_extension_Control_prototype; + +bool js_cocos2dx_extension_Control_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_extension_Control_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_extension_Control(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_extension(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_extension_Control_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_Control_getState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_Control_sendActionsForControlEvents(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_Control_setSelected(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_Control_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_Control_needsLayout(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_Control_hasVisibleParents(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_Control_isSelected(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_Control_isTouchInside(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_Control_setHighlighted(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_Control_getTouchLocation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_Control_isHighlighted(JSContext *cx, uint32_t argc, jsval *vp); +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_extension_ControlButton_class; +extern JSObject *jsb_cocos2d_extension_ControlButton_prototype; + +bool js_cocos2dx_extension_ControlButton_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_extension_ControlButton_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_extension_ControlButton(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_extension(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_extension_ControlButton_isPushed(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_setTitleLabelForState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_setAdjustBackgroundImage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_setTitleForState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_setLabelAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_getLabelAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_initWithBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_getTitleTTFSizeForState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_setTitleTTFForState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_setTitleTTFSizeForState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_setTitleLabel(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_setPreferredSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_getCurrentTitleColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_setZoomOnTouchDown(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_setBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_getBackgroundSpriteForState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_getHorizontalOrigin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_initWithTitleAndFontNameAndFontSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_setTitleBMFontForState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_getScaleRatio(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_getTitleTTFForState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_getBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_getTitleColorForState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_setTitleColorForState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_doesAdjustBackgroundImage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_setBackgroundSpriteFrameForState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_setBackgroundSpriteForState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_setScaleRatio(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_getTitleBMFontForState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_getTitleLabel(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_getPreferredSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_getVerticalMargin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_getTitleLabelForState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_setMargins(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_getCurrentTitle(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_getZoomOnTouchDown(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_getTitleForState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlButton_ControlButton(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_extension_ControlHuePicker_class; +extern JSObject *jsb_cocos2d_extension_ControlHuePicker_prototype; + +bool js_cocos2dx_extension_ControlHuePicker_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_extension_ControlHuePicker_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_extension_ControlHuePicker(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_extension(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_extension_ControlHuePicker_initWithTargetAndPos(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlHuePicker_setHue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlHuePicker_getStartPos(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlHuePicker_getHue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlHuePicker_getSlider(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlHuePicker_setBackground(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlHuePicker_setHuePercentage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlHuePicker_getBackground(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlHuePicker_getHuePercentage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlHuePicker_setSlider(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlHuePicker_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlHuePicker_ControlHuePicker(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_extension_ControlSaturationBrightnessPicker_class; +extern JSObject *jsb_cocos2d_extension_ControlSaturationBrightnessPicker_prototype; + +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_extension_ControlSaturationBrightnessPicker_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_extension_ControlSaturationBrightnessPicker(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_extension(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getShadow(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_initWithTargetAndPos(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getStartPos(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getOverlay(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSlider(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBackground(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getSaturation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_getBrightness(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSaturationBrightnessPicker_ControlSaturationBrightnessPicker(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_extension_ControlColourPicker_class; +extern JSObject *jsb_cocos2d_extension_ControlColourPicker_prototype; + +bool js_cocos2dx_extension_ControlColourPicker_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_extension_ControlColourPicker_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_extension_ControlColourPicker(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_extension(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_extension_ControlColourPicker_hueSliderValueChanged(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlColourPicker_getHuePicker(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlColourPicker_getcolourPicker(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlColourPicker_setBackground(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlColourPicker_setcolourPicker(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlColourPicker_colourSliderValueChanged(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlColourPicker_setHuePicker(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlColourPicker_getBackground(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlColourPicker_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlColourPicker_ControlColourPicker(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_extension_ControlPotentiometer_class; +extern JSObject *jsb_cocos2d_extension_ControlPotentiometer_prototype; + +bool js_cocos2dx_extension_ControlPotentiometer_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_extension_ControlPotentiometer_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_extension_ControlPotentiometer(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_extension(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_extension_ControlPotentiometer_setPreviousLocation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlPotentiometer_setValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlPotentiometer_getProgressTimer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlPotentiometer_getMaximumValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlPotentiometer_angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlPotentiometer_potentiometerBegan(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlPotentiometer_setMaximumValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlPotentiometer_getMinimumValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlPotentiometer_setThumbSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlPotentiometer_getValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlPotentiometer_getPreviousLocation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlPotentiometer_distanceBetweenPointAndPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlPotentiometer_potentiometerEnded(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlPotentiometer_setProgressTimer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlPotentiometer_setMinimumValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlPotentiometer_getThumbSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlPotentiometer_initWithTrackSprite_ProgressTimer_ThumbSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlPotentiometer_potentiometerMoved(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlPotentiometer_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlPotentiometer_ControlPotentiometer(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_extension_ControlSlider_class; +extern JSObject *jsb_cocos2d_extension_ControlSlider_prototype; + +bool js_cocos2dx_extension_ControlSlider_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_extension_ControlSlider_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_extension_ControlSlider(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_extension(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_extension_ControlSlider_setBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_getMaximumAllowedValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_initWithSprites(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_getMinimumAllowedValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_getMaximumValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_getSelectedThumbSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_setProgressSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_setMaximumValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_getMinimumValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_setThumbSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_getValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_getBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_getThumbSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_setValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_locationFromTouch(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_setMinimumValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_setMinimumAllowedValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_getProgressSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_setSelectedThumbSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_setMaximumAllowedValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSlider_ControlSlider(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_extension_ControlStepper_class; +extern JSObject *jsb_cocos2d_extension_ControlStepper_prototype; + +bool js_cocos2dx_extension_ControlStepper_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_extension_ControlStepper_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_extension_ControlStepper(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_extension(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_extension_ControlStepper_getMinusSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_setValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_setStepValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_initWithMinusSpriteAndPlusSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_setValueWithSendingEvent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_setMaximumValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_getMinusLabel(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_getPlusLabel(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_setWraps(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_setMinusLabel(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_startAutorepeat(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_updateLayoutUsingTouchLocation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_isContinuous(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_stopAutorepeat(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_setMinimumValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_setPlusLabel(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_getValue(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_getPlusSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_setPlusSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_setMinusSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlStepper_ControlStepper(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_extension_ControlSwitch_class; +extern JSObject *jsb_cocos2d_extension_ControlSwitch_prototype; + +bool js_cocos2dx_extension_ControlSwitch_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_extension_ControlSwitch_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_extension_ControlSwitch(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_extension(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_extension_ControlSwitch_setOn(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSwitch_locationFromTouch(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSwitch_isOn(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSwitch_initWithMaskSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSwitch_hasMoved(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSwitch_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ControlSwitch_ControlSwitch(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_extension_ScrollView_class; +extern JSObject *jsb_cocos2d_extension_ScrollView_prototype; + +bool js_cocos2dx_extension_ScrollView_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_extension_ScrollView_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_extension_ScrollView(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_extension(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_extension_ScrollView_isClippingToBounds(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_setContainer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_setContentOffsetInDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_setZoomScaleInDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_updateTweenAction(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_setMaxScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_hasVisibleParents(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_getDirection(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_getContainer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_setMinScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_getZoomScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_updateInset(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_initWithViewSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_pause(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_setDirection(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_setBounceable(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_setContentOffset(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_isDragging(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_isTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_isBounceable(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_setTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_getContentOffset(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_resume(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_setClippingToBounds(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_setViewSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_getViewSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_maxContainerOffset(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_isTouchMoved(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_isNodeVisible(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_minContainerOffset(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_setZoomScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_ScrollView_ScrollView(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_extension_TableViewCell_class; +extern JSObject *jsb_cocos2d_extension_TableViewCell_prototype; + +bool js_cocos2dx_extension_TableViewCell_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_extension_TableViewCell_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_extension_TableViewCell(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_extension(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_extension_TableViewCell_reset(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_TableViewCell_getIdx(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_TableViewCell_setIdx(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_TableViewCell_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_TableViewCell_TableViewCell(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_extension_TableView_class; +extern JSObject *jsb_cocos2d_extension_TableView_prototype; + +bool js_cocos2dx_extension_TableView_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_extension_TableView_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_extension_TableView(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_extension(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_extension_TableView_updateCellAtIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_TableView_setVerticalFillOrder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_TableView_scrollViewDidZoom(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_TableView__updateContentSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_TableView_getVerticalFillOrder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_TableView_removeCellAtIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_TableView_initWithViewSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_TableView_scrollViewDidScroll(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_TableView_reloadData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_TableView_insertCellAtIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_TableView_cellAtIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_TableView_dequeueCell(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_TableView_TableView(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_extension_EventAssetsManagerEx_class; +extern JSObject *jsb_cocos2d_extension_EventAssetsManagerEx_prototype; + +bool js_cocos2dx_extension_EventAssetsManagerEx_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_extension_EventAssetsManagerEx_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_extension_EventAssetsManagerEx(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_extension(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_extension_EventAssetsManagerEx_getAssetsManagerEx(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_EventAssetsManagerEx_getAssetId(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_EventAssetsManagerEx_getCURLECode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_EventAssetsManagerEx_getMessage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_EventAssetsManagerEx_getCURLMCode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_EventAssetsManagerEx_getPercentByFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_EventAssetsManagerEx_getEventCode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_EventAssetsManagerEx_getPercent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_EventAssetsManagerEx_EventAssetsManagerEx(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_extension_Manifest_class; +extern JSObject *jsb_cocos2d_extension_Manifest_prototype; + +bool js_cocos2dx_extension_Manifest_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_extension_Manifest_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_extension_Manifest(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_extension(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_extension_Manifest_getManifestFileUrl(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_Manifest_isVersionLoaded(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_Manifest_isLoaded(JSContext *cx, uint32_t argc, jsval *vp); +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; + +bool js_cocos2dx_extension_AssetsManagerEx_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_extension_AssetsManagerEx_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_extension_AssetsManagerEx(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_extension(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_extension_AssetsManagerEx_getState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_AssetsManagerEx_checkUpdate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_AssetsManagerEx_getStoragePath(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_AssetsManagerEx_update(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_AssetsManagerEx_getLocalManifest(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_AssetsManagerEx_getRemoteManifest(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_AssetsManagerEx_downloadFailedAssets(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_AssetsManagerEx_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_AssetsManagerEx_AssetsManagerEx(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_extension_EventListenerAssetsManagerEx_class; +extern JSObject *jsb_cocos2d_extension_EventListenerAssetsManagerEx_prototype; + +bool js_cocos2dx_extension_EventListenerAssetsManagerEx_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_extension_EventListenerAssetsManagerEx_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_extension_EventListenerAssetsManagerEx(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_extension(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_extension_EventListenerAssetsManagerEx_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_EventListenerAssetsManagerEx_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_EventListenerAssetsManagerEx_EventListenerAssetsManagerEx(JSContext *cx, uint32_t argc, jsval *vp); +#endif + diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.cpp new file mode 100644 index 0000000000..a61a06fbd6 --- /dev/null +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.cpp @@ -0,0 +1,1896 @@ +#include "jsb_cocos2dx_spine_auto.hpp" +#include "cocos2d_specifics.hpp" +#include "spine-cocos2dx.h" +#include "jsb_cocos2dx_spine_manual.h" + +template +static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedValue initializing(cx); + bool isNewValid = true; + JS::RootedObject global(cx, ScriptingCore::getInstance()->getGlobalObject()); + isNewValid = JS_GetProperty(cx, global, "initializing", &initializing) && initializing.toBoolean(); + if (isNewValid) + { + 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."); + + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + + args.rval().set(OBJECT_TO_JSVAL(_tmp)); + return true; + } + + JS_ReportError(cx, "Constructor for the requested class is not available, please refer to the API reference."); + return false; +} + +static bool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) { + return false; +} + +static bool js_is_native_obj(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().setBoolean(true); + return true; +} +JSClass *jsb_spine_SkeletonRenderer_class; +JSObject *jsb_spine_SkeletonRenderer_prototype; + +bool js_cocos2dx_spine_SkeletonRenderer_setTimeScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setTimeScale : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setTimeScale : Error processing arguments"); + cobj->setTimeScale(arg0); + args.rval().setUndefined(); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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"); + if (argc == 0) { + bool ret = cobj->getDebugSlotsEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + 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_setAttachment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + spine::SkeletonRenderer* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setAttachment : Invalid Native Object"); + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + const char* arg1; + std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + if (!ok) { ok = true; break; } + bool ret = cobj->setAttachment(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->setAttachment(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_setAttachment : wrong number of arguments"); + return false; +} +bool js_cocos2dx_spine_SkeletonRenderer_setBonesToSetupPose(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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(); + args.rval().setUndefined(); + return true; + } + + 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_isOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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"); + if (argc == 0) { + bool ret = cobj->isOpacityModifyRGB(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + 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_initWithData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_initWithData : Invalid Native Object"); + if (argc == 1) { + spSkeletonData* arg0; + #pragma warning NO CONVERSION TO NATIVE FOR spSkeletonData* + ok = false; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonRenderer_initWithData : Error processing arguments"); + cobj->initWithData(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + spSkeletonData* arg0; + bool arg1; + #pragma warning NO CONVERSION TO NATIVE FOR spSkeletonData* + ok = false; + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonRenderer_initWithData : Error processing arguments"); + cobj->initWithData(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_initWithData : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_spine_SkeletonRenderer_setDebugSlotsEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setDebugSlotsEnabled : Error processing arguments"); + cobj->setDebugSlotsEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + 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_setSlotsToSetupPose(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setSlotsToSetupPose : Invalid Native Object"); + if (argc == 0) { + cobj->setSlotsToSetupPose(); + args.rval().setUndefined(); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB : Error processing arguments"); + cobj->setOpacityModifyRGB(arg0); + args.rval().setUndefined(); + return true; + } + + 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_setToSetupPose(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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"); + if (argc == 0) { + cobj->setToSetupPose(); + args.rval().setUndefined(); + return true; + } + + 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_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + 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_drawSkeleton(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), &arg0); + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonRenderer_drawSkeleton : Error processing arguments"); + cobj->drawSkeleton(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + 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_updateWorldTransform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_updateWorldTransform : Invalid Native Object"); + if (argc == 0) { + cobj->updateWorldTransform(); + args.rval().setUndefined(); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_initialize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_spine_SkeletonRenderer_setDebugBonesEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setDebugBonesEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setDebugBonesEnabled : Error processing arguments"); + cobj->setDebugBonesEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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"); + if (argc == 0) { + bool ret = cobj->getDebugBonesEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + 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_getTimeScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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"); + if (argc == 0) { + double ret = cobj->getTimeScale(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + 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_initWithFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + spine::SkeletonRenderer* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_initWithFile : Invalid Native Object"); + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cobj->initWithFile(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cobj->initWithFile(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(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->initWithFile(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(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, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cobj->initWithFile(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_initWithFile : wrong number of arguments"); + return false; +} +bool js_cocos2dx_spine_SkeletonRenderer_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setBlendFunc : Invalid Native Object"); + if (argc == 1) { + cocos2d::BlendFunc arg0; + ok &= jsval_to_blendfunc(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setBlendFunc : Error processing arguments"); + cobj->setBlendFunc(arg0); + args.rval().setUndefined(); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + spine::SkeletonRenderer* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setSkin : Invalid Native Object"); + do { + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + if (!ok) { ok = true; break; } + bool ret = cobj->setSkin(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + bool ret = cobj->setSkin(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_setSkin : wrong number of arguments"); + return false; +} +bool js_cocos2dx_spine_SkeletonRenderer_getSkeleton(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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"); + if (argc == 0) { + spSkeleton* ret = cobj->getSkeleton(); + jsval jsret = JSVAL_NULL; + jsret = spskeleton_to_jsval(cx, *ret); + args.rval().set(jsret); + return true; + } + + 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_createWithFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + spine::SkeletonRenderer* ret = spine::SkeletonRenderer::createWithFile(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (spine::SkeletonRenderer*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + spine::SkeletonRenderer* ret = spine::SkeletonRenderer::createWithFile(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (spine::SkeletonRenderer*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + spAtlas* arg1; + #pragma warning NO CONVERSION TO NATIVE FOR spAtlas* + ok = false; + if (!ok) { ok = true; break; } + spine::SkeletonRenderer* ret = spine::SkeletonRenderer::createWithFile(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (spine::SkeletonRenderer*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(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, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + spine::SkeletonRenderer* ret = spine::SkeletonRenderer::createWithFile(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (spine::SkeletonRenderer*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + 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(args.get(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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonRenderer"); + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonRenderer"); + } + } while(0); + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(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, args.get(2), &arg2) && !isnan(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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonRenderer"); + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonRenderer"); + } + } while(0); + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + 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", args); + + args.rval().set(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; + +void js_spine_SkeletonRenderer_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (SkeletonRenderer)", obj); +} + +void js_register_cocos2dx_spine_SkeletonRenderer(JSContext *cx, JS::HandleObject global) { + jsb_spine_SkeletonRenderer_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_spine_SkeletonRenderer_class->name = "Skeleton"; + jsb_spine_SkeletonRenderer_class->addProperty = JS_PropertyStub; + jsb_spine_SkeletonRenderer_class->delProperty = JS_DeletePropertyStub; + jsb_spine_SkeletonRenderer_class->getProperty = JS_PropertyStub; + jsb_spine_SkeletonRenderer_class->setProperty = JS_StrictPropertyStub; + jsb_spine_SkeletonRenderer_class->enumerate = JS_EnumerateStub; + jsb_spine_SkeletonRenderer_class->resolve = JS_ResolveStub; + jsb_spine_SkeletonRenderer_class->convert = JS_ConvertStub; + jsb_spine_SkeletonRenderer_class->finalize = js_spine_SkeletonRenderer_finalize; + jsb_spine_SkeletonRenderer_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + 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("initWithData", js_cocos2dx_spine_SkeletonRenderer_initWithData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDebugSlotsEnabled", js_cocos2dx_spine_SkeletonRenderer_setDebugSlotsEnabled, 1, 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("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("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("setDebugBonesEnabled", js_cocos2dx_spine_SkeletonRenderer_setDebugBonesEnabled, 1, 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("initWithFile", js_cocos2dx_spine_SkeletonRenderer_initWithFile, 2, 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_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_spine_SkeletonRenderer_createWithFile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_spine_SkeletonRenderer_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_spine_SkeletonRenderer_class, + js_cocos2dx_spine_SkeletonRenderer_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, "Skeleton", 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_spine_SkeletonRenderer_class; + p->proto = jsb_spine_SkeletonRenderer_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_spine_SkeletonAnimation_class; +JSObject *jsb_spine_SkeletonAnimation_prototype; + +bool js_cocos2dx_spine_SkeletonAnimation_setStartListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setStartListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + auto lambda = [=](int larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[1]; + largv[0] = int32_to_jsval(cx, larg0); + JS::RootedValue rval(cx); + 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"); + cobj->setStartListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_setStartListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_spine_SkeletonAnimation_setTrackEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setTrackEventListener : Invalid Native Object"); + if (argc == 2) { + spTrackEntry* arg0; + std::function arg1; + #pragma warning NO CONVERSION TO NATIVE FOR spTrackEntry* + ok = false; + do { + if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + auto lambda = [=](int larg0, spEvent* larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + largv[0] = int32_to_jsval(cx, larg0); + largv[1] = spevent_to_jsval(cx, *larg1); + JS::RootedValue rval(cx); + 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"); + cobj->setTrackEventListener(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_setTrackEventListener : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_spine_SkeletonAnimation_getState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getState : Invalid Native Object"); + if (argc == 0) { + spAnimationState* ret = cobj->getState(); + jsval jsret = JSVAL_NULL; + jsret = spanimationstate_to_jsval(cx, *ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_getState : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_spine_SkeletonAnimation_setTrackCompleteListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setTrackCompleteListener : Invalid Native Object"); + if (argc == 2) { + spTrackEntry* arg0; + std::function arg1; + #pragma warning NO CONVERSION TO NATIVE FOR spTrackEntry* + ok = false; + do { + if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + auto lambda = [=](int larg0, int larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + largv[0] = int32_to_jsval(cx, larg0); + largv[1] = int32_to_jsval(cx, larg1); + JS::RootedValue rval(cx); + 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"); + cobj->setTrackCompleteListener(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_setTrackCompleteListener : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_spine_SkeletonAnimation_onTrackEntryEvent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_onTrackEntryEvent : Invalid Native Object"); + if (argc == 4) { + int arg0; + spEventType arg1; + spEvent* arg2; + int arg3; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + #pragma warning NO CONVERSION TO NATIVE FOR spEvent* + ok = false; + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonAnimation_onTrackEntryEvent : Error processing arguments"); + cobj->onTrackEntryEvent(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_onTrackEntryEvent : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_spine_SkeletonAnimation_setTrackStartListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setTrackStartListener : Invalid Native Object"); + if (argc == 2) { + spTrackEntry* arg0; + std::function arg1; + #pragma warning NO CONVERSION TO NATIVE FOR spTrackEntry* + ok = false; + do { + if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + auto lambda = [=](int larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[1]; + largv[0] = int32_to_jsval(cx, larg0); + JS::RootedValue rval(cx); + 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"); + cobj->setTrackStartListener(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_setTrackStartListener : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_spine_SkeletonAnimation_update(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_update : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonAnimation_update : Error processing arguments"); + cobj->update(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_update : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_spine_SkeletonAnimation_setCompleteListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setCompleteListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + auto lambda = [=](int larg0, int larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + largv[0] = int32_to_jsval(cx, larg0); + largv[1] = int32_to_jsval(cx, larg1); + JS::RootedValue rval(cx); + 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"); + cobj->setCompleteListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_setCompleteListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_spine_SkeletonAnimation_setTrackEndListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setTrackEndListener : Invalid Native Object"); + if (argc == 2) { + spTrackEntry* arg0; + std::function arg1; + #pragma warning NO CONVERSION TO NATIVE FOR spTrackEntry* + ok = false; + do { + if(JS_TypeOfValue(cx, args.get(1)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(1))); + auto lambda = [=](int larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[1]; + largv[0] = int32_to_jsval(cx, larg0); + JS::RootedValue rval(cx); + 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"); + cobj->setTrackEndListener(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_setTrackEndListener : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_spine_SkeletonAnimation_setEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + auto lambda = [=](int larg0, spEvent* larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[2]; + largv[0] = int32_to_jsval(cx, larg0); + largv[1] = spevent_to_jsval(cx, *larg1); + JS::RootedValue rval(cx); + 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"); + cobj->setEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_setEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_spine_SkeletonAnimation_setMix(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setMix : Invalid Native Object"); + if (argc == 3) { + std::string arg0; + std::string arg1; + double arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonAnimation_setMix : Error processing arguments"); + cobj->setMix(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_setMix : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_spine_SkeletonAnimation_setEndListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setEndListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + auto lambda = [=](int larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[1]; + largv[0] = int32_to_jsval(cx, larg0); + JS::RootedValue rval(cx); + 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"); + cobj->setEndListener(arg0); + args.rval().setUndefined(); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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(); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_clearTracks : Invalid Native Object"); + if (argc == 0) { + cobj->clearTracks(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_clearTracks : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_spine_SkeletonAnimation_clearTrack(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_clearTrack : Invalid Native Object"); + if (argc == 0) { + cobj->clearTrack(); + args.rval().setUndefined(); + return true; + } + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonAnimation_clearTrack : Error processing arguments"); + cobj->clearTrack(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_clearTrack : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_onAnimationStateEvent : Invalid Native Object"); + if (argc == 4) { + int arg0; + spEventType arg1; + spEvent* arg2; + int arg3; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + #pragma warning NO CONVERSION TO NATIVE FOR spEvent* + ok = false; + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent : Error processing arguments"); + cobj->onAnimationStateEvent(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_spine_SkeletonAnimation_createWithFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + spine::SkeletonAnimation* ret = spine::SkeletonAnimation::createWithFile(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (spine::SkeletonAnimation*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + spine::SkeletonAnimation* ret = spine::SkeletonAnimation::createWithFile(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (spine::SkeletonAnimation*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + spAtlas* arg1; + #pragma warning NO CONVERSION TO NATIVE FOR spAtlas* + ok = false; + if (!ok) { ok = true; break; } + spine::SkeletonAnimation* ret = spine::SkeletonAnimation::createWithFile(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (spine::SkeletonAnimation*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(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, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + spine::SkeletonAnimation* ret = spine::SkeletonAnimation::createWithFile(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (spine::SkeletonAnimation*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + spine::SkeletonAnimation* 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::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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonAnimation"); + } + } while(0); + + do { + if (argc == 0) { + cobj = new (std::nothrow) spine::SkeletonAnimation(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonAnimation"); + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonAnimation"); + } + } while(0); + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(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, args.get(2), &arg2) && !isnan(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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonAnimation"); + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonAnimation"); + } + } while(0); + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + 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", args); + + args.rval().set(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; + +void js_spine_SkeletonAnimation_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (SkeletonAnimation)", obj); +} + +static bool js_spine_SkeletonAnimation_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + spine::SkeletonAnimation *nobj = new (std::nothrow) spine::SkeletonAnimation(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonAnimation"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_spine_SkeletonAnimation(JSContext *cx, JS::HandleObject global) { + jsb_spine_SkeletonAnimation_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_spine_SkeletonAnimation_class->name = "SkeletonAnimation"; + jsb_spine_SkeletonAnimation_class->addProperty = JS_PropertyStub; + jsb_spine_SkeletonAnimation_class->delProperty = JS_DeletePropertyStub; + jsb_spine_SkeletonAnimation_class->getProperty = JS_PropertyStub; + jsb_spine_SkeletonAnimation_class->setProperty = JS_StrictPropertyStub; + jsb_spine_SkeletonAnimation_class->enumerate = JS_EnumerateStub; + jsb_spine_SkeletonAnimation_class->resolve = JS_ResolveStub; + jsb_spine_SkeletonAnimation_class->convert = JS_ConvertStub; + jsb_spine_SkeletonAnimation_class->finalize = js_spine_SkeletonAnimation_finalize; + jsb_spine_SkeletonAnimation_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setStartListener", js_cocos2dx_spine_SkeletonAnimation_setStartListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTrackEventListener", js_cocos2dx_spine_SkeletonAnimation_setTrackEventListener, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getState", js_cocos2dx_spine_SkeletonAnimation_getState, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTrackCompleteListener", js_cocos2dx_spine_SkeletonAnimation_setTrackCompleteListener, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("onTrackEntryEvent", js_cocos2dx_spine_SkeletonAnimation_onTrackEntryEvent, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTrackStartListener", js_cocos2dx_spine_SkeletonAnimation_setTrackStartListener, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("update", js_cocos2dx_spine_SkeletonAnimation_update, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCompleteListener", js_cocos2dx_spine_SkeletonAnimation_setCompleteListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTrackEndListener", js_cocos2dx_spine_SkeletonAnimation_setTrackEndListener, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + 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), + JS_FN("ctor", js_spine_SkeletonAnimation_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_spine_SkeletonAnimation_createWithFile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_spine_SkeletonAnimation_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_spine_SkeletonRenderer_prototype), + jsb_spine_SkeletonAnimation_class, + js_cocos2dx_spine_SkeletonAnimation_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, "SkeletonAnimation", 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_spine_SkeletonAnimation_class; + p->proto = jsb_spine_SkeletonAnimation_prototype; + p->parentProto = jsb_spine_SkeletonRenderer_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +void register_all_cocos2dx_spine(JSContext* cx, JS::HandleObject obj) { + // Get the ns + JS::RootedObject ns(cx); + get_or_create_js_obj(cx, obj, "sp", &ns); + + js_register_cocos2dx_spine_SkeletonRenderer(cx, ns); + js_register_cocos2dx_spine_SkeletonAnimation(cx, ns); +} + diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.hpp new file mode 100644 index 0000000000..60ea77c238 --- /dev/null +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.hpp @@ -0,0 +1,65 @@ +#ifndef __cocos2dx_spine_h__ +#define __cocos2dx_spine_h__ + +#include "jsapi.h" +#include "jsfriendapi.h" + + +extern JSClass *jsb_spine_SkeletonRenderer_class; +extern JSObject *jsb_spine_SkeletonRenderer_prototype; + +bool js_cocos2dx_spine_SkeletonRenderer_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_spine_SkeletonRenderer_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_spine_SkeletonRenderer(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_spine(JSContext* cx, JS::HandleObject 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_initWithData(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_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_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_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_setDebugBonesEnabled(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_initWithFile(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_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; + +bool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_spine_SkeletonAnimation_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_spine_SkeletonAnimation(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_spine(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_spine_SkeletonAnimation_setStartListener(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_spine_SkeletonAnimation_setTrackEventListener(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_spine_SkeletonAnimation_getState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_spine_SkeletonAnimation_setTrackCompleteListener(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_spine_SkeletonAnimation_onTrackEntryEvent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_spine_SkeletonAnimation_setTrackStartListener(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_spine_SkeletonAnimation_update(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_spine_SkeletonAnimation_setCompleteListener(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_spine_SkeletonAnimation_setTrackEndListener(JSContext *cx, uint32_t argc, jsval *vp); +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/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.cpp new file mode 100644 index 0000000000..a06f019143 --- /dev/null +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.cpp @@ -0,0 +1,12918 @@ +#include "jsb_cocos2dx_studio_auto.hpp" +#include "cocos2d_specifics.hpp" +#include "CocoStudio.h" +#include "CCObjectExtensionData.h" +#include "jsb_cocos2dx_studio_conversions.h" + +template +static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedValue initializing(cx); + bool isNewValid = true; + JS::RootedObject global(cx, ScriptingCore::getInstance()->getGlobalObject()); + isNewValid = JS_GetProperty(cx, global, "initializing", &initializing) && initializing.toBoolean(); + if (isNewValid) + { + 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."); + + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + + args.rval().set(OBJECT_TO_JSVAL(_tmp)); + return true; + } + + JS_ReportError(cx, "Constructor for the requested class is not available, please refer to the API reference."); + return false; +} + +static bool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) { + return false; +} + +static bool js_is_native_obj(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().setBoolean(true); + return true; +} +JSClass *jsb_cocostudio_ActionObject_class; +JSObject *jsb_cocostudio_ActionObject_prototype; + +bool js_cocos2dx_studio_ActionObject_setCurrentTime(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_setCurrentTime : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionObject_setCurrentTime : Error processing arguments"); + cobj->setCurrentTime(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_setCurrentTime : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ActionObject_pause(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_pause : Invalid Native Object"); + if (argc == 0) { + cobj->pause(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_pause : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ActionObject_setName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_setName : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionObject_setName : Error processing arguments"); + cobj->setName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_setName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ActionObject_setUnitTime(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_setUnitTime : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionObject_setUnitTime : Error processing arguments"); + cobj->setUnitTime(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_setUnitTime : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ActionObject_getTotalTime(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_getTotalTime : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getTotalTime(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_getTotalTime : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ActionObject_getName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_getName : Invalid Native Object"); + if (argc == 0) { + const char* ret = cobj->getName(); + jsval jsret = JSVAL_NULL; + jsret = c_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_getName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ActionObject_stop(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_stop : Invalid Native Object"); + if (argc == 0) { + cobj->stop(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_stop : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ActionObject_play(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocostudio::ActionObject* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_play : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::CallFunc* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::CallFunc*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cobj->play(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 0) { + cobj->play(); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_play : wrong number of arguments"); + return false; +} +bool js_cocos2dx_studio_ActionObject_getCurrentTime(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_getCurrentTime : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getCurrentTime(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_getCurrentTime : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ActionObject_removeActionNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_removeActionNode : Invalid Native Object"); + if (argc == 1) { + cocostudio::ActionNode* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::ActionNode*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionObject_removeActionNode : Error processing arguments"); + cobj->removeActionNode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_removeActionNode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ActionObject_getLoop(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_getLoop : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->getLoop(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_getLoop : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ActionObject_initWithBinary(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_initWithBinary : Invalid Native Object"); + if (argc == 3) { + cocostudio::CocoLoader* arg0; + cocostudio::stExpCocoNode* arg1; + cocos2d::Ref* arg2; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::CocoLoader*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + #pragma warning NO CONVERSION TO NATIVE FOR stExpCocoNode* + ok = false; + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionObject_initWithBinary : Error processing arguments"); + cobj->initWithBinary(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_initWithBinary : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_studio_ActionObject_addActionNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_addActionNode : Invalid Native Object"); + if (argc == 1) { + cocostudio::ActionNode* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::ActionNode*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionObject_addActionNode : Error processing arguments"); + cobj->addActionNode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_addActionNode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ActionObject_getUnitTime(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_getUnitTime : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getUnitTime(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_getUnitTime : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ActionObject_isPlaying(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_isPlaying : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isPlaying(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_isPlaying : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ActionObject_updateToFrameByTime(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_updateToFrameByTime : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionObject_updateToFrameByTime : Error processing arguments"); + cobj->updateToFrameByTime(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_updateToFrameByTime : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ActionObject_setLoop(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_setLoop : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionObject_setLoop : Error processing arguments"); + cobj->setLoop(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_setLoop : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ActionObject_simulationActionUpdate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionObject* cobj = (cocostudio::ActionObject *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionObject_simulationActionUpdate : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionObject_simulationActionUpdate : Error processing arguments"); + cobj->simulationActionUpdate(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionObject_simulationActionUpdate : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ActionObject_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::ActionObject* cobj = new (std::nothrow) cocostudio::ActionObject(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::ActionObject"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocostudio_ActionObject_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ActionObject)", obj); +} + +void js_register_cocos2dx_studio_ActionObject(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_ActionObject_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_ActionObject_class->name = "ActionObject"; + jsb_cocostudio_ActionObject_class->addProperty = JS_PropertyStub; + jsb_cocostudio_ActionObject_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_ActionObject_class->getProperty = JS_PropertyStub; + jsb_cocostudio_ActionObject_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_ActionObject_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_ActionObject_class->resolve = JS_ResolveStub; + jsb_cocostudio_ActionObject_class->convert = JS_ConvertStub; + jsb_cocostudio_ActionObject_class->finalize = js_cocostudio_ActionObject_finalize; + jsb_cocostudio_ActionObject_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setCurrentTime", js_cocos2dx_studio_ActionObject_setCurrentTime, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pause", js_cocos2dx_studio_ActionObject_pause, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setName", js_cocos2dx_studio_ActionObject_setName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUnitTime", js_cocos2dx_studio_ActionObject_setUnitTime, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTotalTime", js_cocos2dx_studio_ActionObject_getTotalTime, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getName", js_cocos2dx_studio_ActionObject_getName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("stop", js_cocos2dx_studio_ActionObject_stop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("play", js_cocos2dx_studio_ActionObject_play, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCurrentTime", js_cocos2dx_studio_ActionObject_getCurrentTime, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeActionNode", js_cocos2dx_studio_ActionObject_removeActionNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLoop", js_cocos2dx_studio_ActionObject_getLoop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithBinary", js_cocos2dx_studio_ActionObject_initWithBinary, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addActionNode", js_cocos2dx_studio_ActionObject_addActionNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getUnitTime", js_cocos2dx_studio_ActionObject_getUnitTime, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isPlaying", js_cocos2dx_studio_ActionObject_isPlaying, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateToFrameByTime", js_cocos2dx_studio_ActionObject_updateToFrameByTime, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLoop", js_cocos2dx_studio_ActionObject_setLoop, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("simulationActionUpdate", js_cocos2dx_studio_ActionObject_simulationActionUpdate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocostudio_ActionObject_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocostudio_ActionObject_class, + js_cocos2dx_studio_ActionObject_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, "ActionObject", 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_cocostudio_ActionObject_class; + p->proto = jsb_cocostudio_ActionObject_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_ActionManagerEx_class; +JSObject *jsb_cocostudio_ActionManagerEx_prototype; + +bool js_cocos2dx_studio_ActionManagerEx_stopActionByName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + 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, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(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); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionManagerEx* cobj = (cocostudio::ActionManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionManagerEx_getActionByName : Invalid Native Object"); + if (argc == 2) { + const char* arg0; + const char* arg1; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionManagerEx_getActionByName : Error processing arguments"); + cocostudio::ActionObject* ret = cobj->getActionByName(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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionManagerEx_getActionByName : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_ActionManagerEx_initWithBinary(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionManagerEx* cobj = (cocostudio::ActionManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionManagerEx_initWithBinary : Invalid Native Object"); + if (argc == 4) { + const char* arg0; + cocos2d::Ref* arg1; + cocostudio::CocoLoader* arg2; + cocostudio::stExpCocoNode* arg3; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocostudio::CocoLoader*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + #pragma warning NO CONVERSION TO NATIVE FOR stExpCocoNode* + ok = false; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionManagerEx_initWithBinary : Error processing arguments"); + cobj->initWithBinary(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocostudio::ActionManagerEx* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + 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, args.get(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, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + if (!ok) { ok = true; break; } + cocos2d::CallFunc* arg2; + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + 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); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(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, args.get(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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionManagerEx* cobj = (cocostudio::ActionManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionManagerEx_releaseActions : Invalid Native Object"); + if (argc == 0) { + cobj->releaseActions(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionManagerEx_releaseActions : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ActionManagerEx_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::ActionManagerEx::destroyInstance(); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_ActionManagerEx_destroyInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_ActionManagerEx_getInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::ActionManagerEx* ret = cocostudio::ActionManagerEx::getInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ActionManagerEx*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_ActionManagerEx_getInstance : wrong number of arguments"); + return false; +} + + + +void js_cocostudio_ActionManagerEx_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ActionManagerEx)", obj); +} + +void js_register_cocos2dx_studio_ActionManagerEx(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_ActionManagerEx_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_ActionManagerEx_class->name = "ActionManager"; + jsb_cocostudio_ActionManagerEx_class->addProperty = JS_PropertyStub; + jsb_cocostudio_ActionManagerEx_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_ActionManagerEx_class->getProperty = JS_PropertyStub; + jsb_cocostudio_ActionManagerEx_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_ActionManagerEx_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_ActionManagerEx_class->resolve = JS_ResolveStub; + jsb_cocostudio_ActionManagerEx_class->convert = JS_ConvertStub; + jsb_cocostudio_ActionManagerEx_class->finalize = js_cocostudio_ActionManagerEx_finalize; + jsb_cocostudio_ActionManagerEx_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + 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 + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("destroyInstance", js_cocos2dx_studio_ActionManagerEx_destroyInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInstance", js_cocos2dx_studio_ActionManagerEx_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_ActionManagerEx_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocostudio_ActionManagerEx_class, + empty_constructor, 0, + 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, "ActionManager", 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_cocostudio_ActionManagerEx_class; + p->proto = jsb_cocostudio_ActionManagerEx_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_BaseData_class; +JSObject *jsb_cocostudio_BaseData_prototype; + +bool js_cocos2dx_studio_BaseData_getColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::BaseData* cobj = (cocostudio::BaseData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_BaseData_getColor : Invalid Native Object"); + if (argc == 0) { + cocos2d::Color4B ret = cobj->getColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor4b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_BaseData_getColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_BaseData_setColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::BaseData* cobj = (cocostudio::BaseData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_BaseData_setColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_BaseData_setColor : Error processing arguments"); + cobj->setColor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_BaseData_setColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_BaseData_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::BaseData* ret = cocostudio::BaseData::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::BaseData*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_BaseData_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_BaseData_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::BaseData* cobj = new (std::nothrow) cocostudio::BaseData(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::BaseData"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocostudio_BaseData_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (BaseData)", obj); +} + +void js_register_cocos2dx_studio_BaseData(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_BaseData_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_BaseData_class->name = "BaseData"; + jsb_cocostudio_BaseData_class->addProperty = JS_PropertyStub; + jsb_cocostudio_BaseData_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_BaseData_class->getProperty = JS_PropertyStub; + jsb_cocostudio_BaseData_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_BaseData_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_BaseData_class->resolve = JS_ResolveStub; + jsb_cocostudio_BaseData_class->convert = JS_ConvertStub; + jsb_cocostudio_BaseData_class->finalize = js_cocostudio_BaseData_finalize; + jsb_cocostudio_BaseData_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getColor", js_cocos2dx_studio_BaseData_getColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setColor", js_cocos2dx_studio_BaseData_setColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_BaseData_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_BaseData_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocostudio_BaseData_class, + js_cocos2dx_studio_BaseData_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, "BaseData", 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_cocostudio_BaseData_class; + p->proto = jsb_cocostudio_BaseData_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_MovementData_class; +JSObject *jsb_cocostudio_MovementData_prototype; + +bool js_cocos2dx_studio_MovementData_getMovementBoneData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::MovementData* cobj = (cocostudio::MovementData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_MovementData_getMovementBoneData : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_MovementData_getMovementBoneData : Error processing arguments"); + cocostudio::MovementBoneData* ret = cobj->getMovementBoneData(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::MovementBoneData*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_MovementData_getMovementBoneData : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_MovementData_addMovementBoneData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::MovementData* cobj = (cocostudio::MovementData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_MovementData_addMovementBoneData : Invalid Native Object"); + if (argc == 1) { + cocostudio::MovementBoneData* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::MovementBoneData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_MovementData_addMovementBoneData : Error processing arguments"); + cobj->addMovementBoneData(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_MovementData_addMovementBoneData : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_MovementData_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::MovementData* ret = cocostudio::MovementData::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::MovementData*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_MovementData_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_MovementData_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::MovementData* cobj = new (std::nothrow) cocostudio::MovementData(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::MovementData"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocostudio_MovementData_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (MovementData)", obj); +} + +void js_register_cocos2dx_studio_MovementData(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_MovementData_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_MovementData_class->name = "MovementData"; + jsb_cocostudio_MovementData_class->addProperty = JS_PropertyStub; + jsb_cocostudio_MovementData_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_MovementData_class->getProperty = JS_PropertyStub; + jsb_cocostudio_MovementData_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_MovementData_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_MovementData_class->resolve = JS_ResolveStub; + jsb_cocostudio_MovementData_class->convert = JS_ConvertStub; + jsb_cocostudio_MovementData_class->finalize = js_cocostudio_MovementData_finalize; + jsb_cocostudio_MovementData_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getMovementBoneData", js_cocos2dx_studio_MovementData_getMovementBoneData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addMovementBoneData", js_cocos2dx_studio_MovementData_addMovementBoneData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_MovementData_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_MovementData_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocostudio_MovementData_class, + js_cocos2dx_studio_MovementData_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, "MovementData", 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_cocostudio_MovementData_class; + p->proto = jsb_cocostudio_MovementData_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_AnimationData_class; +JSObject *jsb_cocostudio_AnimationData_prototype; + +bool js_cocos2dx_studio_AnimationData_getMovement(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::AnimationData* cobj = (cocostudio::AnimationData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_AnimationData_getMovement : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_AnimationData_getMovement : Error processing arguments"); + cocostudio::MovementData* ret = cobj->getMovement(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::MovementData*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_AnimationData_getMovement : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_AnimationData_getMovementCount(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::AnimationData* cobj = (cocostudio::AnimationData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_AnimationData_getMovementCount : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getMovementCount(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_AnimationData_getMovementCount : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_AnimationData_addMovement(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::AnimationData* cobj = (cocostudio::AnimationData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_AnimationData_addMovement : Invalid Native Object"); + if (argc == 1) { + cocostudio::MovementData* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::MovementData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_AnimationData_addMovement : Error processing arguments"); + cobj->addMovement(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_AnimationData_addMovement : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_AnimationData_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::AnimationData* ret = cocostudio::AnimationData::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::AnimationData*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_AnimationData_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_AnimationData_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::AnimationData* cobj = new (std::nothrow) cocostudio::AnimationData(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::AnimationData"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocostudio_AnimationData_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (AnimationData)", obj); +} + +void js_register_cocos2dx_studio_AnimationData(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_AnimationData_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_AnimationData_class->name = "AnimationData"; + jsb_cocostudio_AnimationData_class->addProperty = JS_PropertyStub; + jsb_cocostudio_AnimationData_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_AnimationData_class->getProperty = JS_PropertyStub; + jsb_cocostudio_AnimationData_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_AnimationData_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_AnimationData_class->resolve = JS_ResolveStub; + jsb_cocostudio_AnimationData_class->convert = JS_ConvertStub; + jsb_cocostudio_AnimationData_class->finalize = js_cocostudio_AnimationData_finalize; + jsb_cocostudio_AnimationData_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getMovement", js_cocos2dx_studio_AnimationData_getMovement, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMovementCount", js_cocos2dx_studio_AnimationData_getMovementCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addMovement", js_cocos2dx_studio_AnimationData_addMovement, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_AnimationData_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_AnimationData_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocostudio_AnimationData_class, + js_cocos2dx_studio_AnimationData_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, "AnimationData", 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_cocostudio_AnimationData_class; + p->proto = jsb_cocostudio_AnimationData_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_ContourData_class; +JSObject *jsb_cocostudio_ContourData_prototype; + +bool js_cocos2dx_studio_ContourData_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ContourData* cobj = (cocostudio::ContourData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ContourData_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ContourData_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ContourData_addVertex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ContourData* cobj = (cocostudio::ContourData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ContourData_addVertex : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ContourData_addVertex : Error processing arguments"); + cobj->addVertex(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ContourData_addVertex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ContourData_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::ContourData* ret = cocostudio::ContourData::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ContourData*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_ContourData_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_ContourData_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::ContourData* cobj = new (std::nothrow) cocostudio::ContourData(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::ContourData"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocostudio_ContourData_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ContourData)", obj); +} + +void js_register_cocos2dx_studio_ContourData(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_ContourData_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_ContourData_class->name = "ContourData"; + jsb_cocostudio_ContourData_class->addProperty = JS_PropertyStub; + jsb_cocostudio_ContourData_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_ContourData_class->getProperty = JS_PropertyStub; + jsb_cocostudio_ContourData_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_ContourData_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_ContourData_class->resolve = JS_ResolveStub; + jsb_cocostudio_ContourData_class->convert = JS_ConvertStub; + jsb_cocostudio_ContourData_class->finalize = js_cocostudio_ContourData_finalize; + jsb_cocostudio_ContourData_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_studio_ContourData_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addVertex", js_cocos2dx_studio_ContourData_addVertex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_ContourData_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_ContourData_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocostudio_ContourData_class, + js_cocos2dx_studio_ContourData_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, "ContourData", 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_cocostudio_ContourData_class; + p->proto = jsb_cocostudio_ContourData_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_TextureData_class; +JSObject *jsb_cocostudio_TextureData_prototype; + +bool js_cocos2dx_studio_TextureData_getContourData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::TextureData* cobj = (cocostudio::TextureData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_TextureData_getContourData : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_TextureData_getContourData : Error processing arguments"); + cocostudio::ContourData* ret = cobj->getContourData(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ContourData*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_TextureData_getContourData : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_TextureData_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::TextureData* cobj = (cocostudio::TextureData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_TextureData_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_TextureData_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_TextureData_addContourData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::TextureData* cobj = (cocostudio::TextureData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_TextureData_addContourData : Invalid Native Object"); + if (argc == 1) { + cocostudio::ContourData* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::ContourData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_TextureData_addContourData : Error processing arguments"); + cobj->addContourData(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_TextureData_addContourData : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_TextureData_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::TextureData* ret = cocostudio::TextureData::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::TextureData*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_TextureData_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_TextureData_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::TextureData* cobj = new (std::nothrow) cocostudio::TextureData(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::TextureData"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocostudio_TextureData_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TextureData)", obj); +} + +void js_register_cocos2dx_studio_TextureData(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_TextureData_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_TextureData_class->name = "TextureData"; + jsb_cocostudio_TextureData_class->addProperty = JS_PropertyStub; + jsb_cocostudio_TextureData_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_TextureData_class->getProperty = JS_PropertyStub; + jsb_cocostudio_TextureData_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_TextureData_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_TextureData_class->resolve = JS_ResolveStub; + jsb_cocostudio_TextureData_class->convert = JS_ConvertStub; + jsb_cocostudio_TextureData_class->finalize = js_cocostudio_TextureData_finalize; + jsb_cocostudio_TextureData_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getContourData", js_cocos2dx_studio_TextureData_getContourData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_studio_TextureData_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addContourData", js_cocos2dx_studio_TextureData_addContourData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_TextureData_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_TextureData_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocostudio_TextureData_class, + js_cocos2dx_studio_TextureData_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, "TextureData", 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_cocostudio_TextureData_class; + p->proto = jsb_cocostudio_TextureData_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_ProcessBase_class; +JSObject *jsb_cocostudio_ProcessBase_prototype; + +bool js_cocos2dx_studio_ProcessBase_play(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ProcessBase* cobj = (cocostudio::ProcessBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ProcessBase_play : Invalid Native Object"); + if (argc == 4) { + int arg0; + int arg1; + int arg2; + int arg3; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ProcessBase_play : Error processing arguments"); + cobj->play(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ProcessBase_play : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_studio_ProcessBase_pause(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ProcessBase* cobj = (cocostudio::ProcessBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ProcessBase_pause : Invalid Native Object"); + if (argc == 0) { + cobj->pause(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ProcessBase_pause : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ProcessBase_getRawDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ProcessBase* cobj = (cocostudio::ProcessBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ProcessBase_getRawDuration : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getRawDuration(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ProcessBase_getRawDuration : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ProcessBase_resume(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ProcessBase* cobj = (cocostudio::ProcessBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ProcessBase_resume : Invalid Native Object"); + if (argc == 0) { + cobj->resume(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ProcessBase_resume : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ProcessBase_setIsComplete(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ProcessBase* cobj = (cocostudio::ProcessBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ProcessBase_setIsComplete : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ProcessBase_setIsComplete : Error processing arguments"); + cobj->setIsComplete(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ProcessBase_setIsComplete : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ProcessBase_stop(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ProcessBase* cobj = (cocostudio::ProcessBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ProcessBase_stop : Invalid Native Object"); + if (argc == 0) { + cobj->stop(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ProcessBase_stop : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ProcessBase_update(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ProcessBase* cobj = (cocostudio::ProcessBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ProcessBase_update : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ProcessBase_update : Error processing arguments"); + cobj->update(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ProcessBase_update : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ProcessBase_getCurrentFrameIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ProcessBase* cobj = (cocostudio::ProcessBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ProcessBase_getCurrentFrameIndex : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getCurrentFrameIndex(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ProcessBase_getCurrentFrameIndex : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ProcessBase_isComplete(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ProcessBase* cobj = (cocostudio::ProcessBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ProcessBase_isComplete : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isComplete(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ProcessBase_isComplete : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ProcessBase_getCurrentPercent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ProcessBase* cobj = (cocostudio::ProcessBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ProcessBase_getCurrentPercent : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getCurrentPercent(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ProcessBase_getCurrentPercent : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ProcessBase_setIsPause(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ProcessBase* cobj = (cocostudio::ProcessBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ProcessBase_setIsPause : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ProcessBase_setIsPause : Error processing arguments"); + cobj->setIsPause(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ProcessBase_setIsPause : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ProcessBase_getProcessScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ProcessBase* cobj = (cocostudio::ProcessBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ProcessBase_getProcessScale : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getProcessScale(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ProcessBase_getProcessScale : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ProcessBase_isPause(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ProcessBase* cobj = (cocostudio::ProcessBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ProcessBase_isPause : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isPause(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ProcessBase_isPause : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ProcessBase_isPlaying(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ProcessBase* cobj = (cocostudio::ProcessBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ProcessBase_isPlaying : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isPlaying(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ProcessBase_isPlaying : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ProcessBase_setProcessScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ProcessBase* cobj = (cocostudio::ProcessBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ProcessBase_setProcessScale : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ProcessBase_setProcessScale : Error processing arguments"); + cobj->setProcessScale(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ProcessBase_setProcessScale : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ProcessBase_setIsPlaying(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ProcessBase* cobj = (cocostudio::ProcessBase *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ProcessBase_setIsPlaying : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ProcessBase_setIsPlaying : Error processing arguments"); + cobj->setIsPlaying(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ProcessBase_setIsPlaying : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ProcessBase_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::ProcessBase* cobj = new (std::nothrow) cocostudio::ProcessBase(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::ProcessBase"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocostudio_ProcessBase_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ProcessBase)", obj); +} + +void js_register_cocos2dx_studio_ProcessBase(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_ProcessBase_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_ProcessBase_class->name = "ProcessBase"; + jsb_cocostudio_ProcessBase_class->addProperty = JS_PropertyStub; + jsb_cocostudio_ProcessBase_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_ProcessBase_class->getProperty = JS_PropertyStub; + jsb_cocostudio_ProcessBase_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_ProcessBase_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_ProcessBase_class->resolve = JS_ResolveStub; + jsb_cocostudio_ProcessBase_class->convert = JS_ConvertStub; + jsb_cocostudio_ProcessBase_class->finalize = js_cocostudio_ProcessBase_finalize; + jsb_cocostudio_ProcessBase_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("play", js_cocos2dx_studio_ProcessBase_play, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pause", js_cocos2dx_studio_ProcessBase_pause, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRawDuration", js_cocos2dx_studio_ProcessBase_getRawDuration, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resume", js_cocos2dx_studio_ProcessBase_resume, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setIsComplete", js_cocos2dx_studio_ProcessBase_setIsComplete, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("stop", js_cocos2dx_studio_ProcessBase_stop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("update", js_cocos2dx_studio_ProcessBase_update, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCurrentFrameIndex", js_cocos2dx_studio_ProcessBase_getCurrentFrameIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isComplete", js_cocos2dx_studio_ProcessBase_isComplete, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCurrentPercent", js_cocos2dx_studio_ProcessBase_getCurrentPercent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setIsPause", js_cocos2dx_studio_ProcessBase_setIsPause, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getProcessScale", js_cocos2dx_studio_ProcessBase_getProcessScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isPause", js_cocos2dx_studio_ProcessBase_isPause, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isPlaying", js_cocos2dx_studio_ProcessBase_isPlaying, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setProcessScale", js_cocos2dx_studio_ProcessBase_setProcessScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setIsPlaying", js_cocos2dx_studio_ProcessBase_setIsPlaying, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocostudio_ProcessBase_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocostudio_ProcessBase_class, + js_cocos2dx_studio_ProcessBase_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, "ProcessBase", 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_cocostudio_ProcessBase_class; + p->proto = jsb_cocostudio_ProcessBase_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_Tween_class; +JSObject *jsb_cocostudio_Tween_prototype; + +bool js_cocos2dx_studio_Tween_getAnimation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Tween* cobj = (cocostudio::Tween *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Tween_getAnimation : Invalid Native Object"); + if (argc == 0) { + cocostudio::ArmatureAnimation* ret = cobj->getAnimation(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ArmatureAnimation*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Tween_getAnimation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Tween_gotoAndPause(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Tween* cobj = (cocostudio::Tween *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Tween_gotoAndPause : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Tween_gotoAndPause : Error processing arguments"); + cobj->gotoAndPause(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Tween_gotoAndPause : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Tween_play(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Tween* cobj = (cocostudio::Tween *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Tween_play : Invalid Native Object"); + if (argc == 5) { + cocostudio::MovementBoneData* arg0; + int arg1; + int arg2; + int arg3; + int arg4; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::MovementBoneData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Tween_play : Error processing arguments"); + cobj->play(arg0, arg1, arg2, arg3, arg4); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Tween_play : wrong number of arguments: %d, was expecting %d", argc, 5); + return false; +} +bool js_cocos2dx_studio_Tween_gotoAndPlay(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Tween* cobj = (cocostudio::Tween *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Tween_gotoAndPlay : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Tween_gotoAndPlay : Error processing arguments"); + cobj->gotoAndPlay(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Tween_gotoAndPlay : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Tween_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Tween* cobj = (cocostudio::Tween *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Tween_init : Invalid Native Object"); + if (argc == 1) { + cocostudio::Bone* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Tween_init : Error processing arguments"); + bool ret = cobj->init(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Tween_init : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Tween_setAnimation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Tween* cobj = (cocostudio::Tween *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Tween_setAnimation : Invalid Native Object"); + if (argc == 1) { + cocostudio::ArmatureAnimation* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::ArmatureAnimation*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Tween_setAnimation : Error processing arguments"); + cobj->setAnimation(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Tween_setAnimation : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Tween_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocostudio::Bone* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Tween_create : Error processing arguments"); + cocostudio::Tween* ret = cocostudio::Tween::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::Tween*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_Tween_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_Tween_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::Tween* cobj = new (std::nothrow) cocostudio::Tween(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::Tween"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocostudio_ProcessBase_prototype; + +void js_cocostudio_Tween_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Tween)", obj); +} + +void js_register_cocos2dx_studio_Tween(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_Tween_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_Tween_class->name = "Tween"; + jsb_cocostudio_Tween_class->addProperty = JS_PropertyStub; + jsb_cocostudio_Tween_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_Tween_class->getProperty = JS_PropertyStub; + jsb_cocostudio_Tween_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_Tween_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_Tween_class->resolve = JS_ResolveStub; + jsb_cocostudio_Tween_class->convert = JS_ConvertStub; + jsb_cocostudio_Tween_class->finalize = js_cocostudio_Tween_finalize; + jsb_cocostudio_Tween_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getAnimation", js_cocos2dx_studio_Tween_getAnimation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("gotoAndPause", js_cocos2dx_studio_Tween_gotoAndPause, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("play", js_cocos2dx_studio_Tween_play, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("gotoAndPlay", js_cocos2dx_studio_Tween_gotoAndPlay, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_studio_Tween_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAnimation", js_cocos2dx_studio_Tween_setAnimation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_Tween_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_Tween_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocostudio_ProcessBase_prototype), + jsb_cocostudio_Tween_class, + js_cocos2dx_studio_Tween_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, "Tween", 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_cocostudio_Tween_class; + p->proto = jsb_cocostudio_Tween_prototype; + p->parentProto = jsb_cocostudio_ProcessBase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_ColliderFilter_class; +JSObject *jsb_cocostudio_ColliderFilter_prototype; + + + +void js_cocostudio_ColliderFilter_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ColliderFilter)", obj); +} + +void js_register_cocos2dx_studio_ColliderFilter(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_ColliderFilter_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_ColliderFilter_class->name = "ColliderFilter"; + jsb_cocostudio_ColliderFilter_class->addProperty = JS_PropertyStub; + jsb_cocostudio_ColliderFilter_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_ColliderFilter_class->getProperty = JS_PropertyStub; + jsb_cocostudio_ColliderFilter_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_ColliderFilter_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_ColliderFilter_class->resolve = JS_ResolveStub; + jsb_cocostudio_ColliderFilter_class->convert = JS_ConvertStub; + jsb_cocostudio_ColliderFilter_class->finalize = js_cocostudio_ColliderFilter_finalize; + jsb_cocostudio_ColliderFilter_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocostudio_ColliderFilter_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocostudio_ColliderFilter_class, + empty_constructor, 0, + 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, "ColliderFilter", 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_cocostudio_ColliderFilter_class; + p->proto = jsb_cocostudio_ColliderFilter_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_ColliderBody_class; +JSObject *jsb_cocostudio_ColliderBody_prototype; + + + +void js_cocostudio_ColliderBody_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ColliderBody)", obj); +} + +void js_register_cocos2dx_studio_ColliderBody(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_ColliderBody_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_ColliderBody_class->name = "ColliderBody"; + jsb_cocostudio_ColliderBody_class->addProperty = JS_PropertyStub; + jsb_cocostudio_ColliderBody_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_ColliderBody_class->getProperty = JS_PropertyStub; + jsb_cocostudio_ColliderBody_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_ColliderBody_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_ColliderBody_class->resolve = JS_ResolveStub; + jsb_cocostudio_ColliderBody_class->convert = JS_ConvertStub; + jsb_cocostudio_ColliderBody_class->finalize = js_cocostudio_ColliderBody_finalize; + jsb_cocostudio_ColliderBody_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocostudio_ColliderBody_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocostudio_ColliderBody_class, + empty_constructor, 0, + 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, "ColliderBody", 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_cocostudio_ColliderBody_class; + p->proto = jsb_cocostudio_ColliderBody_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_ColliderDetector_class; +JSObject *jsb_cocostudio_ColliderDetector_prototype; + +bool js_cocos2dx_studio_ColliderDetector_getBone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ColliderDetector* cobj = (cocostudio::ColliderDetector *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ColliderDetector_getBone : Invalid Native Object"); + if (argc == 0) { + cocostudio::Bone* ret = cobj->getBone(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::Bone*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ColliderDetector_getBone : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ColliderDetector_getActive(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ColliderDetector* cobj = (cocostudio::ColliderDetector *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ColliderDetector_getActive : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->getActive(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ColliderDetector_getActive : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ColliderDetector_getColliderBodyList(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ColliderDetector* cobj = (cocostudio::ColliderDetector *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ColliderDetector_getColliderBodyList : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vector& ret = cobj->getColliderBodyList(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ColliderDetector_getColliderBodyList : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ColliderDetector_updateTransform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ColliderDetector* cobj = (cocostudio::ColliderDetector *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ColliderDetector_updateTransform : Invalid Native Object"); + if (argc == 1) { + cocos2d::Mat4 arg0; + ok &= jsval_to_matrix(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ColliderDetector_updateTransform : Error processing arguments"); + cobj->updateTransform(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ColliderDetector_updateTransform : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ColliderDetector_removeAll(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ColliderDetector* cobj = (cocostudio::ColliderDetector *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ColliderDetector_removeAll : Invalid Native Object"); + if (argc == 0) { + cobj->removeAll(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ColliderDetector_removeAll : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ColliderDetector_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocostudio::ColliderDetector* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocostudio::ColliderDetector *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ColliderDetector_init : Invalid Native Object"); + do { + if (argc == 1) { + cocostudio::Bone* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + bool ret = cobj->init(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_studio_ColliderDetector_init : wrong number of arguments"); + return false; +} +bool js_cocos2dx_studio_ColliderDetector_setActive(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ColliderDetector* cobj = (cocostudio::ColliderDetector *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ColliderDetector_setActive : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ColliderDetector_setActive : Error processing arguments"); + cobj->setActive(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ColliderDetector_setActive : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ColliderDetector_setBone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ColliderDetector* cobj = (cocostudio::ColliderDetector *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ColliderDetector_setBone : Invalid Native Object"); + if (argc == 1) { + cocostudio::Bone* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ColliderDetector_setBone : Error processing arguments"); + cobj->setBone(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ColliderDetector_setBone : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ColliderDetector_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + cocostudio::Bone* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocostudio::ColliderDetector* ret = cocostudio::ColliderDetector::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ColliderDetector*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocostudio::ColliderDetector* ret = cocostudio::ColliderDetector::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ColliderDetector*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_studio_ColliderDetector_create : wrong number of arguments"); + return false; +} + + +void js_cocostudio_ColliderDetector_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ColliderDetector)", obj); +} + +void js_register_cocos2dx_studio_ColliderDetector(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_ColliderDetector_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_ColliderDetector_class->name = "ColliderDetector"; + jsb_cocostudio_ColliderDetector_class->addProperty = JS_PropertyStub; + jsb_cocostudio_ColliderDetector_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_ColliderDetector_class->getProperty = JS_PropertyStub; + jsb_cocostudio_ColliderDetector_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_ColliderDetector_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_ColliderDetector_class->resolve = JS_ResolveStub; + jsb_cocostudio_ColliderDetector_class->convert = JS_ConvertStub; + jsb_cocostudio_ColliderDetector_class->finalize = js_cocostudio_ColliderDetector_finalize; + jsb_cocostudio_ColliderDetector_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getBone", js_cocos2dx_studio_ColliderDetector_getBone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getActive", js_cocos2dx_studio_ColliderDetector_getActive, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getColliderBodyList", js_cocos2dx_studio_ColliderDetector_getColliderBodyList, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateTransform", js_cocos2dx_studio_ColliderDetector_updateTransform, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAll", js_cocos2dx_studio_ColliderDetector_removeAll, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_studio_ColliderDetector_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setActive", js_cocos2dx_studio_ColliderDetector_setActive, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBone", js_cocos2dx_studio_ColliderDetector_setBone, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_ColliderDetector_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_ColliderDetector_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocostudio_ColliderDetector_class, + empty_constructor, 0, + 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, "ColliderDetector", 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_cocostudio_ColliderDetector_class; + p->proto = jsb_cocostudio_ColliderDetector_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_DecorativeDisplay_class; +JSObject *jsb_cocostudio_DecorativeDisplay_prototype; + +bool js_cocos2dx_studio_DecorativeDisplay_getColliderDetector(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DecorativeDisplay* cobj = (cocostudio::DecorativeDisplay *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DecorativeDisplay_getColliderDetector : Invalid Native Object"); + if (argc == 0) { + cocostudio::ColliderDetector* ret = cobj->getColliderDetector(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ColliderDetector*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DecorativeDisplay_getColliderDetector : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_DecorativeDisplay_getDisplay(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DecorativeDisplay* cobj = (cocostudio::DecorativeDisplay *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DecorativeDisplay_getDisplay : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getDisplay(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DecorativeDisplay_getDisplay : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_DecorativeDisplay_setDisplay(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DecorativeDisplay* cobj = (cocostudio::DecorativeDisplay *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DecorativeDisplay_setDisplay : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_DecorativeDisplay_setDisplay : Error processing arguments"); + cobj->setDisplay(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DecorativeDisplay_setDisplay : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_DecorativeDisplay_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DecorativeDisplay* cobj = (cocostudio::DecorativeDisplay *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DecorativeDisplay_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DecorativeDisplay_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_DecorativeDisplay_setDisplayData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DecorativeDisplay* cobj = (cocostudio::DecorativeDisplay *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DecorativeDisplay_setDisplayData : Invalid Native Object"); + if (argc == 1) { + cocostudio::DisplayData* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::DisplayData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_DecorativeDisplay_setDisplayData : Error processing arguments"); + cobj->setDisplayData(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DecorativeDisplay_setDisplayData : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_DecorativeDisplay_getDisplayData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DecorativeDisplay* cobj = (cocostudio::DecorativeDisplay *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DecorativeDisplay_getDisplayData : Invalid Native Object"); + if (argc == 0) { + cocostudio::DisplayData* ret = cobj->getDisplayData(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::DisplayData*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DecorativeDisplay_getDisplayData : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_DecorativeDisplay_setColliderDetector(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DecorativeDisplay* cobj = (cocostudio::DecorativeDisplay *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DecorativeDisplay_setColliderDetector : Invalid Native Object"); + if (argc == 1) { + cocostudio::ColliderDetector* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::ColliderDetector*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_DecorativeDisplay_setColliderDetector : Error processing arguments"); + cobj->setColliderDetector(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DecorativeDisplay_setColliderDetector : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_DecorativeDisplay_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::DecorativeDisplay* ret = cocostudio::DecorativeDisplay::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::DecorativeDisplay*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_DecorativeDisplay_create : wrong number of arguments"); + return false; +} + + + +void js_cocostudio_DecorativeDisplay_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (DecorativeDisplay)", obj); +} + +void js_register_cocos2dx_studio_DecorativeDisplay(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_DecorativeDisplay_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_DecorativeDisplay_class->name = "DecorativeDisplay"; + jsb_cocostudio_DecorativeDisplay_class->addProperty = JS_PropertyStub; + jsb_cocostudio_DecorativeDisplay_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_DecorativeDisplay_class->getProperty = JS_PropertyStub; + jsb_cocostudio_DecorativeDisplay_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_DecorativeDisplay_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_DecorativeDisplay_class->resolve = JS_ResolveStub; + jsb_cocostudio_DecorativeDisplay_class->convert = JS_ConvertStub; + jsb_cocostudio_DecorativeDisplay_class->finalize = js_cocostudio_DecorativeDisplay_finalize; + jsb_cocostudio_DecorativeDisplay_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getColliderDetector", js_cocos2dx_studio_DecorativeDisplay_getColliderDetector, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDisplay", js_cocos2dx_studio_DecorativeDisplay_getDisplay, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDisplay", js_cocos2dx_studio_DecorativeDisplay_setDisplay, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_studio_DecorativeDisplay_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDisplayData", js_cocos2dx_studio_DecorativeDisplay_setDisplayData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDisplayData", js_cocos2dx_studio_DecorativeDisplay_getDisplayData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setColliderDetector", js_cocos2dx_studio_DecorativeDisplay_setColliderDetector, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_DecorativeDisplay_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_DecorativeDisplay_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocostudio_DecorativeDisplay_class, + empty_constructor, 0, + 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, "DecorativeDisplay", 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_cocostudio_DecorativeDisplay_class; + p->proto = jsb_cocostudio_DecorativeDisplay_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_DisplayManager_class; +JSObject *jsb_cocostudio_DisplayManager_prototype; + +bool js_cocos2dx_studio_DisplayManager_getCurrentDecorativeDisplay(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_getCurrentDecorativeDisplay : Invalid Native Object"); + if (argc == 0) { + cocostudio::DecorativeDisplay* ret = cobj->getCurrentDecorativeDisplay(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::DecorativeDisplay*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_getCurrentDecorativeDisplay : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_DisplayManager_getDisplayRenderNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_getDisplayRenderNode : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getDisplayRenderNode(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_getDisplayRenderNode : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_DisplayManager_getAnchorPointInPoints(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_getAnchorPointInPoints : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getAnchorPointInPoints(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_getAnchorPointInPoints : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_DisplayManager_setCurrentDecorativeDisplay(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_setCurrentDecorativeDisplay : Invalid Native Object"); + if (argc == 1) { + cocostudio::DecorativeDisplay* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::DecorativeDisplay*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_DisplayManager_setCurrentDecorativeDisplay : Error processing arguments"); + cobj->setCurrentDecorativeDisplay(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_setCurrentDecorativeDisplay : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_DisplayManager_getDisplayRenderNodeType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_getDisplayRenderNodeType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getDisplayRenderNodeType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_getDisplayRenderNodeType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_DisplayManager_removeDisplay(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_removeDisplay : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_DisplayManager_removeDisplay : Error processing arguments"); + cobj->removeDisplay(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_removeDisplay : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_DisplayManager_setForceChangeDisplay(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_setForceChangeDisplay : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_DisplayManager_setForceChangeDisplay : Error processing arguments"); + cobj->setForceChangeDisplay(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_setForceChangeDisplay : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_DisplayManager_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_init : Invalid Native Object"); + if (argc == 1) { + cocostudio::Bone* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_DisplayManager_init : Error processing arguments"); + bool ret = cobj->init(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_init : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_DisplayManager_getContentSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_getContentSize : Invalid Native Object"); + if (argc == 0) { + cocos2d::Size ret = cobj->getContentSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_getContentSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_DisplayManager_getBoundingBox(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_getBoundingBox : Invalid Native Object"); + if (argc == 0) { + cocos2d::Rect ret = cobj->getBoundingBox(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_getBoundingBox : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_DisplayManager_addDisplay(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocostudio::DisplayManager* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_addDisplay : Invalid Native Object"); + do { + if (argc == 2) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cobj->addDisplay(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 2) { + cocostudio::DisplayData* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::DisplayData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cobj->addDisplay(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_addDisplay : wrong number of arguments"); + return false; +} +bool js_cocos2dx_studio_DisplayManager_containPoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocostudio::DisplayManager* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_containPoint : Invalid Native Object"); + do { + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->containPoint(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + bool ret = cobj->containPoint(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_containPoint : wrong number of arguments"); + return false; +} +bool js_cocos2dx_studio_DisplayManager_initDisplayList(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_initDisplayList : Invalid Native Object"); + if (argc == 1) { + cocostudio::BoneData* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::BoneData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_DisplayManager_initDisplayList : Error processing arguments"); + cobj->initDisplayList(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_initDisplayList : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_DisplayManager_changeDisplayWithIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_changeDisplayWithIndex : Invalid Native Object"); + if (argc == 2) { + int arg0; + bool arg1; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_DisplayManager_changeDisplayWithIndex : Error processing arguments"); + cobj->changeDisplayWithIndex(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_changeDisplayWithIndex : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_DisplayManager_changeDisplayWithName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_changeDisplayWithName : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + bool arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_DisplayManager_changeDisplayWithName : Error processing arguments"); + cobj->changeDisplayWithName(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_changeDisplayWithName : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_DisplayManager_isForceChangeDisplay(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_isForceChangeDisplay : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isForceChangeDisplay(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_isForceChangeDisplay : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_DisplayManager_getDecorativeDisplayByIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_getDecorativeDisplayByIndex : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_DisplayManager_getDecorativeDisplayByIndex : Error processing arguments"); + cocostudio::DecorativeDisplay* ret = cobj->getDecorativeDisplayByIndex(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::DecorativeDisplay*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_getDecorativeDisplayByIndex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_DisplayManager_getCurrentDisplayIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_getCurrentDisplayIndex : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getCurrentDisplayIndex(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_getCurrentDisplayIndex : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_DisplayManager_getAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_getAnchorPoint : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getAnchorPoint(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_getAnchorPoint : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_DisplayManager_getDecorativeDisplayList(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_getDecorativeDisplayList : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vector& ret = cobj->getDecorativeDisplayList(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_getDecorativeDisplayList : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_DisplayManager_isVisible(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_isVisible : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isVisible(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_isVisible : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_DisplayManager_setVisible(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::DisplayManager* cobj = (cocostudio::DisplayManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_DisplayManager_setVisible : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_DisplayManager_setVisible : Error processing arguments"); + cobj->setVisible(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_setVisible : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_DisplayManager_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocostudio::Bone* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_DisplayManager_create : Error processing arguments"); + cocostudio::DisplayManager* ret = cocostudio::DisplayManager::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::DisplayManager*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_DisplayManager_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_DisplayManager_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::DisplayManager* cobj = new (std::nothrow) cocostudio::DisplayManager(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::DisplayManager"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocostudio_DisplayManager_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (DisplayManager)", obj); +} + +void js_register_cocos2dx_studio_DisplayManager(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_DisplayManager_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_DisplayManager_class->name = "DisplayManager"; + jsb_cocostudio_DisplayManager_class->addProperty = JS_PropertyStub; + jsb_cocostudio_DisplayManager_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_DisplayManager_class->getProperty = JS_PropertyStub; + jsb_cocostudio_DisplayManager_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_DisplayManager_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_DisplayManager_class->resolve = JS_ResolveStub; + jsb_cocostudio_DisplayManager_class->convert = JS_ConvertStub; + jsb_cocostudio_DisplayManager_class->finalize = js_cocostudio_DisplayManager_finalize; + jsb_cocostudio_DisplayManager_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getCurrentDecorativeDisplay", js_cocos2dx_studio_DisplayManager_getCurrentDecorativeDisplay, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDisplayRenderNode", js_cocos2dx_studio_DisplayManager_getDisplayRenderNode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAnchorPointInPoints", js_cocos2dx_studio_DisplayManager_getAnchorPointInPoints, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCurrentDecorativeDisplay", js_cocos2dx_studio_DisplayManager_setCurrentDecorativeDisplay, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDisplayRenderNodeType", js_cocos2dx_studio_DisplayManager_getDisplayRenderNodeType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeDisplay", js_cocos2dx_studio_DisplayManager_removeDisplay, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setForceChangeDisplay", js_cocos2dx_studio_DisplayManager_setForceChangeDisplay, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_studio_DisplayManager_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getContentSize", js_cocos2dx_studio_DisplayManager_getContentSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBoundingBox", js_cocos2dx_studio_DisplayManager_getBoundingBox, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addDisplay", js_cocos2dx_studio_DisplayManager_addDisplay, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("containPoint", js_cocos2dx_studio_DisplayManager_containPoint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initDisplayList", js_cocos2dx_studio_DisplayManager_initDisplayList, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("changeDisplayWithIndex", js_cocos2dx_studio_DisplayManager_changeDisplayWithIndex, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("changeDisplayWithName", js_cocos2dx_studio_DisplayManager_changeDisplayWithName, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isForceChangeDisplay", js_cocos2dx_studio_DisplayManager_isForceChangeDisplay, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDecorativeDisplayByIndex", js_cocos2dx_studio_DisplayManager_getDecorativeDisplayByIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCurrentDisplayIndex", js_cocos2dx_studio_DisplayManager_getCurrentDisplayIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAnchorPoint", js_cocos2dx_studio_DisplayManager_getAnchorPoint, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDecorativeDisplayList", js_cocos2dx_studio_DisplayManager_getDecorativeDisplayList, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isVisible", js_cocos2dx_studio_DisplayManager_isVisible, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setVisible", js_cocos2dx_studio_DisplayManager_setVisible, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_DisplayManager_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_DisplayManager_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocostudio_DisplayManager_class, + js_cocos2dx_studio_DisplayManager_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, "DisplayManager", 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_cocostudio_DisplayManager_class; + p->proto = jsb_cocostudio_DisplayManager_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_Bone_class; +JSObject *jsb_cocostudio_Bone_prototype; + +bool js_cocos2dx_studio_Bone_isTransformDirty(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_isTransformDirty : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isTransformDirty(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_isTransformDirty : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Bone_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_setBlendFunc : Invalid Native Object"); + if (argc == 1) { + cocos2d::BlendFunc arg0; + ok &= jsval_to_blendfunc(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Bone_setBlendFunc : Error processing arguments"); + cobj->setBlendFunc(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Bone_isIgnoreMovementBoneData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_isIgnoreMovementBoneData : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isIgnoreMovementBoneData(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_isIgnoreMovementBoneData : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Bone_updateZOrder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_updateZOrder : Invalid Native Object"); + if (argc == 0) { + cobj->updateZOrder(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_updateZOrder : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Bone_getDisplayRenderNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_getDisplayRenderNode : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getDisplayRenderNode(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_getDisplayRenderNode : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Bone_isBlendDirty(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_isBlendDirty : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isBlendDirty(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_isBlendDirty : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Bone_addChildBone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_addChildBone : Invalid Native Object"); + if (argc == 1) { + cocostudio::Bone* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Bone_addChildBone : Error processing arguments"); + cobj->addChildBone(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_addChildBone : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Bone_getWorldInfo(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_getWorldInfo : Invalid Native Object"); + if (argc == 0) { + cocostudio::BaseData* ret = cobj->getWorldInfo(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::BaseData*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_getWorldInfo : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Bone_getTween(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_getTween : Invalid Native Object"); + if (argc == 0) { + cocostudio::Tween* ret = cobj->getTween(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::Tween*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_getTween : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Bone_getParentBone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_getParentBone : Invalid Native Object"); + if (argc == 0) { + cocostudio::Bone* ret = cobj->getParentBone(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::Bone*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_getParentBone : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Bone_updateColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_updateColor : Invalid Native Object"); + if (argc == 0) { + cobj->updateColor(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_updateColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Bone_setTransformDirty(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_setTransformDirty : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Bone_setTransformDirty : Error processing arguments"); + cobj->setTransformDirty(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_setTransformDirty : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Bone_getDisplayRenderNodeType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_getDisplayRenderNodeType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getDisplayRenderNodeType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_getDisplayRenderNodeType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Bone_removeDisplay(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_removeDisplay : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Bone_removeDisplay : Error processing arguments"); + cobj->removeDisplay(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_removeDisplay : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Bone_setBoneData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_setBoneData : Invalid Native Object"); + if (argc == 1) { + cocostudio::BoneData* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::BoneData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Bone_setBoneData : Error processing arguments"); + cobj->setBoneData(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_setBoneData : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Bone_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_init : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Bone_init : Error processing arguments"); + bool ret = cobj->init(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_init : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Bone_setParentBone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_setParentBone : Invalid Native Object"); + if (argc == 1) { + cocostudio::Bone* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Bone_setParentBone : Error processing arguments"); + cobj->setParentBone(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_setParentBone : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Bone_addDisplay(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocostudio::Bone* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_addDisplay : Invalid Native Object"); + do { + if (argc == 2) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cobj->addDisplay(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 2) { + cocostudio::DisplayData* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::DisplayData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cobj->addDisplay(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_addDisplay : wrong number of arguments"); + return false; +} +bool js_cocos2dx_studio_Bone_setIgnoreMovementBoneData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_setIgnoreMovementBoneData : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Bone_setIgnoreMovementBoneData : Error processing arguments"); + cobj->setIgnoreMovementBoneData(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_setIgnoreMovementBoneData : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Bone_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_getBlendFunc : Invalid Native Object"); + if (argc == 0) { + cocos2d::BlendFunc ret = cobj->getBlendFunc(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Bone_removeFromParent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_removeFromParent : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Bone_removeFromParent : Error processing arguments"); + cobj->removeFromParent(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_removeFromParent : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Bone_getColliderDetector(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_getColliderDetector : Invalid Native Object"); + if (argc == 0) { + cocostudio::ColliderDetector* ret = cobj->getColliderDetector(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ColliderDetector*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_getColliderDetector : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Bone_getChildArmature(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_getChildArmature : Invalid Native Object"); + if (argc == 0) { + cocostudio::Armature* ret = cobj->getChildArmature(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::Armature*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_getChildArmature : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Bone_changeDisplayWithIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_changeDisplayWithIndex : Invalid Native Object"); + if (argc == 2) { + int arg0; + bool arg1; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Bone_changeDisplayWithIndex : Error processing arguments"); + cobj->changeDisplayWithIndex(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_changeDisplayWithIndex : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_Bone_changeDisplayWithName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_changeDisplayWithName : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + bool arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Bone_changeDisplayWithName : Error processing arguments"); + cobj->changeDisplayWithName(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_changeDisplayWithName : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_Bone_setArmature(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_setArmature : Invalid Native Object"); + if (argc == 1) { + cocostudio::Armature* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::Armature*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Bone_setArmature : Error processing arguments"); + cobj->setArmature(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_setArmature : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Bone_setBlendDirty(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_setBlendDirty : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Bone_setBlendDirty : Error processing arguments"); + cobj->setBlendDirty(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_setBlendDirty : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Bone_removeChildBone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_removeChildBone : Invalid Native Object"); + if (argc == 2) { + cocostudio::Bone* arg0; + bool arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Bone_removeChildBone : Error processing arguments"); + cobj->removeChildBone(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_removeChildBone : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_Bone_setChildArmature(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_setChildArmature : Invalid Native Object"); + if (argc == 1) { + cocostudio::Armature* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::Armature*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Bone_setChildArmature : Error processing arguments"); + cobj->setChildArmature(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_setChildArmature : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Bone_getNodeToArmatureTransform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_getNodeToArmatureTransform : Invalid Native Object"); + if (argc == 0) { + cocos2d::Mat4 ret = cobj->getNodeToArmatureTransform(); + jsval jsret = JSVAL_NULL; + jsret = matrix_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_getNodeToArmatureTransform : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Bone_getDisplayManager(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_getDisplayManager : Invalid Native Object"); + if (argc == 0) { + cocostudio::DisplayManager* ret = cobj->getDisplayManager(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::DisplayManager*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_getDisplayManager : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Bone_getArmature(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Bone* cobj = (cocostudio::Bone *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Bone_getArmature : Invalid Native Object"); + if (argc == 0) { + cocostudio::Armature* ret = cobj->getArmature(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::Armature*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Bone_getArmature : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Bone_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocostudio::Bone* ret = cocostudio::Bone::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::Bone*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocostudio::Bone* ret = cocostudio::Bone::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::Bone*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_studio_Bone_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_studio_Bone_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::Bone* cobj = new (std::nothrow) cocostudio::Bone(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::Bone"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocostudio_Bone_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Bone)", obj); +} + +void js_register_cocos2dx_studio_Bone(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_Bone_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_Bone_class->name = "Bone"; + jsb_cocostudio_Bone_class->addProperty = JS_PropertyStub; + jsb_cocostudio_Bone_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_Bone_class->getProperty = JS_PropertyStub; + jsb_cocostudio_Bone_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_Bone_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_Bone_class->resolve = JS_ResolveStub; + jsb_cocostudio_Bone_class->convert = JS_ConvertStub; + jsb_cocostudio_Bone_class->finalize = js_cocostudio_Bone_finalize; + jsb_cocostudio_Bone_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("isTransformDirty", js_cocos2dx_studio_Bone_isTransformDirty, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBlendFunc", js_cocos2dx_studio_Bone_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isIgnoreMovementBoneData", js_cocos2dx_studio_Bone_isIgnoreMovementBoneData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateZOrder", js_cocos2dx_studio_Bone_updateZOrder, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDisplayRenderNode", js_cocos2dx_studio_Bone_getDisplayRenderNode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isBlendDirty", js_cocos2dx_studio_Bone_isBlendDirty, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addChildBone", js_cocos2dx_studio_Bone_addChildBone, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getWorldInfo", js_cocos2dx_studio_Bone_getWorldInfo, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTween", js_cocos2dx_studio_Bone_getTween, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getParentBone", js_cocos2dx_studio_Bone_getParentBone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateColor", js_cocos2dx_studio_Bone_updateColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTransformDirty", js_cocos2dx_studio_Bone_setTransformDirty, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDisplayRenderNodeType", js_cocos2dx_studio_Bone_getDisplayRenderNodeType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeDisplay", js_cocos2dx_studio_Bone_removeDisplay, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBoneData", js_cocos2dx_studio_Bone_setBoneData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_studio_Bone_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setParentBone", js_cocos2dx_studio_Bone_setParentBone, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addDisplay", js_cocos2dx_studio_Bone_addDisplay, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setIgnoreMovementBoneData", js_cocos2dx_studio_Bone_setIgnoreMovementBoneData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBlendFunc", js_cocos2dx_studio_Bone_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeFromParent", js_cocos2dx_studio_Bone_removeFromParent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getColliderDetector", js_cocos2dx_studio_Bone_getColliderDetector, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getChildArmature", js_cocos2dx_studio_Bone_getChildArmature, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("changeDisplayWithIndex", js_cocos2dx_studio_Bone_changeDisplayWithIndex, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("changeDisplayWithName", js_cocos2dx_studio_Bone_changeDisplayWithName, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setArmature", js_cocos2dx_studio_Bone_setArmature, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBlendDirty", js_cocos2dx_studio_Bone_setBlendDirty, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeChildBone", js_cocos2dx_studio_Bone_removeChildBone, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setChildArmature", js_cocos2dx_studio_Bone_setChildArmature, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNodeToArmatureTransform", js_cocos2dx_studio_Bone_getNodeToArmatureTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDisplayManager", js_cocos2dx_studio_Bone_getDisplayManager, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getArmature", js_cocos2dx_studio_Bone_getArmature, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_Bone_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_Bone_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocostudio_Bone_class, + js_cocos2dx_studio_Bone_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, "Bone", 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_cocostudio_Bone_class; + p->proto = jsb_cocostudio_Bone_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_BatchNode_class; +JSObject *jsb_cocostudio_BatchNode_prototype; + +bool js_cocos2dx_studio_BatchNode_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::BatchNode* ret = cocostudio::BatchNode::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::BatchNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_BatchNode_create : wrong number of arguments"); + return false; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocostudio_BatchNode_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (BatchNode)", obj); +} + +void js_register_cocos2dx_studio_BatchNode(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_BatchNode_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_BatchNode_class->name = "BatchNode"; + jsb_cocostudio_BatchNode_class->addProperty = JS_PropertyStub; + jsb_cocostudio_BatchNode_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_BatchNode_class->getProperty = JS_PropertyStub; + jsb_cocostudio_BatchNode_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_BatchNode_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_BatchNode_class->resolve = JS_ResolveStub; + jsb_cocostudio_BatchNode_class->convert = JS_ConvertStub; + jsb_cocostudio_BatchNode_class->finalize = js_cocostudio_BatchNode_finalize; + jsb_cocostudio_BatchNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_BatchNode_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_BatchNode_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocostudio_BatchNode_class, + empty_constructor, 0, + 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, "BatchNode", 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_cocostudio_BatchNode_class; + p->proto = jsb_cocostudio_BatchNode_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_ArmatureAnimation_class; +JSObject *jsb_cocostudio_ArmatureAnimation_prototype; + +bool js_cocos2dx_studio_ArmatureAnimation_getSpeedScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureAnimation_getSpeedScale : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getSpeedScale(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_getSpeedScale : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ArmatureAnimation_play(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureAnimation_play : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureAnimation_play : Error processing arguments"); + cobj->play(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + int arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureAnimation_play : Error processing arguments"); + cobj->play(arg0, arg1); + args.rval().setUndefined(); + return true; + } + if (argc == 3) { + std::string arg0; + int arg1; + int arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureAnimation_play : Error processing arguments"); + cobj->play(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_play : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ArmatureAnimation_gotoAndPause(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureAnimation_gotoAndPause : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureAnimation_gotoAndPause : Error processing arguments"); + cobj->gotoAndPause(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_gotoAndPause : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ArmatureAnimation_playWithIndexes(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureAnimation_playWithIndexes : Invalid Native Object"); + if (argc == 1) { + std::vector arg0; + ok &= jsval_to_std_vector_int(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureAnimation_playWithIndexes : Error processing arguments"); + cobj->playWithIndexes(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::vector arg0; + int arg1; + ok &= jsval_to_std_vector_int(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureAnimation_playWithIndexes : Error processing arguments"); + cobj->playWithIndexes(arg0, arg1); + args.rval().setUndefined(); + return true; + } + if (argc == 3) { + std::vector arg0; + int arg1; + bool arg2; + ok &= jsval_to_std_vector_int(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + arg2 = JS::ToBoolean(args.get(2)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureAnimation_playWithIndexes : Error processing arguments"); + cobj->playWithIndexes(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_playWithIndexes : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ArmatureAnimation_setAnimationData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureAnimation_setAnimationData : Invalid Native Object"); + if (argc == 1) { + cocostudio::AnimationData* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::AnimationData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureAnimation_setAnimationData : Error processing arguments"); + cobj->setAnimationData(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_setAnimationData : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ArmatureAnimation_setSpeedScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureAnimation_setSpeedScale : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureAnimation_setSpeedScale : Error processing arguments"); + cobj->setSpeedScale(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_setSpeedScale : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ArmatureAnimation_getAnimationData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureAnimation_getAnimationData : Invalid Native Object"); + if (argc == 0) { + cocostudio::AnimationData* ret = cobj->getAnimationData(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::AnimationData*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_getAnimationData : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ArmatureAnimation_gotoAndPlay(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureAnimation_gotoAndPlay : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureAnimation_gotoAndPlay : Error processing arguments"); + cobj->gotoAndPlay(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_gotoAndPlay : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ArmatureAnimation_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureAnimation_init : Invalid Native Object"); + if (argc == 1) { + cocostudio::Armature* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::Armature*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureAnimation_init : Error processing arguments"); + bool ret = cobj->init(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_init : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ArmatureAnimation_playWithNames(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureAnimation_playWithNames : Invalid Native Object"); + if (argc == 1) { + std::vector arg0; + ok &= jsval_to_std_vector_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureAnimation_playWithNames : Error processing arguments"); + cobj->playWithNames(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::vector arg0; + int arg1; + ok &= jsval_to_std_vector_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureAnimation_playWithNames : Error processing arguments"); + cobj->playWithNames(arg0, arg1); + args.rval().setUndefined(); + return true; + } + if (argc == 3) { + std::vector arg0; + int arg1; + bool arg2; + ok &= jsval_to_std_vector_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + arg2 = JS::ToBoolean(args.get(2)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureAnimation_playWithNames : Error processing arguments"); + cobj->playWithNames(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_playWithNames : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ArmatureAnimation_getMovementCount(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureAnimation_getMovementCount : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getMovementCount(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_getMovementCount : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ArmatureAnimation_playWithIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureAnimation_playWithIndex : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureAnimation_playWithIndex : Error processing arguments"); + cobj->playWithIndex(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + int arg0; + int arg1; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureAnimation_playWithIndex : Error processing arguments"); + cobj->playWithIndex(arg0, arg1); + args.rval().setUndefined(); + return true; + } + if (argc == 3) { + int arg0; + int arg1; + int arg2; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureAnimation_playWithIndex : Error processing arguments"); + cobj->playWithIndex(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_playWithIndex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ArmatureAnimation_getCurrentMovementID(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureAnimation_getCurrentMovementID : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getCurrentMovementID(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_getCurrentMovementID : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ArmatureAnimation_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocostudio::Armature* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::Armature*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureAnimation_create : Error processing arguments"); + cocostudio::ArmatureAnimation* ret = cocostudio::ArmatureAnimation::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ArmatureAnimation*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureAnimation_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_ArmatureAnimation_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::ArmatureAnimation* cobj = new (std::nothrow) cocostudio::ArmatureAnimation(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::ArmatureAnimation"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocostudio_ProcessBase_prototype; + +void js_cocostudio_ArmatureAnimation_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ArmatureAnimation)", obj); +} + +void js_register_cocos2dx_studio_ArmatureAnimation(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_ArmatureAnimation_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_ArmatureAnimation_class->name = "ArmatureAnimation"; + jsb_cocostudio_ArmatureAnimation_class->addProperty = JS_PropertyStub; + jsb_cocostudio_ArmatureAnimation_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_ArmatureAnimation_class->getProperty = JS_PropertyStub; + jsb_cocostudio_ArmatureAnimation_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_ArmatureAnimation_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_ArmatureAnimation_class->resolve = JS_ResolveStub; + jsb_cocostudio_ArmatureAnimation_class->convert = JS_ConvertStub; + jsb_cocostudio_ArmatureAnimation_class->finalize = js_cocostudio_ArmatureAnimation_finalize; + jsb_cocostudio_ArmatureAnimation_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getSpeedScale", js_cocos2dx_studio_ArmatureAnimation_getSpeedScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("play", js_cocos2dx_studio_ArmatureAnimation_play, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("gotoAndPause", js_cocos2dx_studio_ArmatureAnimation_gotoAndPause, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("playWithIndexes", js_cocos2dx_studio_ArmatureAnimation_playWithIndexes, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAnimationData", js_cocos2dx_studio_ArmatureAnimation_setAnimationData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSpeedScale", js_cocos2dx_studio_ArmatureAnimation_setSpeedScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAnimationData", js_cocos2dx_studio_ArmatureAnimation_getAnimationData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("gotoAndPlay", js_cocos2dx_studio_ArmatureAnimation_gotoAndPlay, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_studio_ArmatureAnimation_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("playWithNames", js_cocos2dx_studio_ArmatureAnimation_playWithNames, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMovementCount", js_cocos2dx_studio_ArmatureAnimation_getMovementCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("playWithIndex", js_cocos2dx_studio_ArmatureAnimation_playWithIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCurrentMovementID", js_cocos2dx_studio_ArmatureAnimation_getCurrentMovementID, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_ArmatureAnimation_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_ArmatureAnimation_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocostudio_ProcessBase_prototype), + jsb_cocostudio_ArmatureAnimation_class, + js_cocos2dx_studio_ArmatureAnimation_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, "ArmatureAnimation", 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_cocostudio_ArmatureAnimation_class; + p->proto = jsb_cocostudio_ArmatureAnimation_prototype; + p->parentProto = jsb_cocostudio_ProcessBase_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_ArmatureDataManager_class; +JSObject *jsb_cocostudio_ArmatureDataManager_prototype; + +bool js_cocos2dx_studio_ArmatureDataManager_getAnimationDatas(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureDataManager_getAnimationDatas : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Map& ret = cobj->getAnimationDatas(); + jsval jsret = JSVAL_NULL; + jsret = ccmap_string_key_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_getAnimationDatas : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ArmatureDataManager_removeAnimationData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureDataManager_removeAnimationData : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureDataManager_removeAnimationData : Error processing arguments"); + cobj->removeAnimationData(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_removeAnimationData : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ArmatureDataManager_addArmatureData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureDataManager_addArmatureData : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + cocostudio::ArmatureData* arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocostudio::ArmatureData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureDataManager_addArmatureData : Error processing arguments"); + cobj->addArmatureData(arg0, arg1); + args.rval().setUndefined(); + return true; + } + if (argc == 3) { + std::string arg0; + cocostudio::ArmatureData* arg1; + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocostudio::ArmatureData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureDataManager_addArmatureData : Error processing arguments"); + cobj->addArmatureData(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_addArmatureData : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_ArmatureDataManager_addArmatureFileInfo(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocostudio::ArmatureDataManager* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureDataManager_addArmatureFileInfo : Invalid Native Object"); + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cobj->addArmatureFileInfo(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->addArmatureFileInfo(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_addArmatureFileInfo : wrong number of arguments"); + return false; +} +bool js_cocos2dx_studio_ArmatureDataManager_removeArmatureFileInfo(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureDataManager_removeArmatureFileInfo : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureDataManager_removeArmatureFileInfo : Error processing arguments"); + cobj->removeArmatureFileInfo(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_removeArmatureFileInfo : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ArmatureDataManager_getTextureData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureDataManager_getTextureData : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureDataManager_getTextureData : Error processing arguments"); + cocostudio::TextureData* ret = cobj->getTextureData(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::TextureData*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_getTextureData : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ArmatureDataManager_getArmatureData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureDataManager_getArmatureData : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureDataManager_getArmatureData : Error processing arguments"); + cocostudio::ArmatureData* ret = cobj->getArmatureData(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ArmatureData*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_getArmatureData : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ArmatureDataManager_getAnimationData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureDataManager_getAnimationData : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureDataManager_getAnimationData : Error processing arguments"); + cocostudio::AnimationData* ret = cobj->getAnimationData(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::AnimationData*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_getAnimationData : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ArmatureDataManager_addAnimationData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureDataManager_addAnimationData : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + cocostudio::AnimationData* arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocostudio::AnimationData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureDataManager_addAnimationData : Error processing arguments"); + cobj->addAnimationData(arg0, arg1); + args.rval().setUndefined(); + return true; + } + if (argc == 3) { + std::string arg0; + cocostudio::AnimationData* arg1; + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocostudio::AnimationData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureDataManager_addAnimationData : Error processing arguments"); + cobj->addAnimationData(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_addAnimationData : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_ArmatureDataManager_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureDataManager_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ArmatureDataManager_removeArmatureData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureDataManager_removeArmatureData : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureDataManager_removeArmatureData : Error processing arguments"); + cobj->removeArmatureData(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_removeArmatureData : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ArmatureDataManager_getArmatureDatas(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureDataManager_getArmatureDatas : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Map& ret = cobj->getArmatureDatas(); + jsval jsret = JSVAL_NULL; + jsret = ccmap_string_key_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_getArmatureDatas : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ArmatureDataManager_removeTextureData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureDataManager_removeTextureData : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureDataManager_removeTextureData : Error processing arguments"); + cobj->removeTextureData(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_removeTextureData : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ArmatureDataManager_addTextureData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureDataManager_addTextureData : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + cocostudio::TextureData* arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocostudio::TextureData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureDataManager_addTextureData : Error processing arguments"); + cobj->addTextureData(arg0, arg1); + args.rval().setUndefined(); + return true; + } + if (argc == 3) { + std::string arg0; + cocostudio::TextureData* arg1; + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocostudio::TextureData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureDataManager_addTextureData : Error processing arguments"); + cobj->addTextureData(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_addTextureData : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_ArmatureDataManager_isAutoLoadSpriteFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureDataManager_isAutoLoadSpriteFile : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isAutoLoadSpriteFile(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_isAutoLoadSpriteFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ArmatureDataManager_addSpriteFrameFromFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ArmatureDataManager_addSpriteFrameFromFile : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureDataManager_addSpriteFrameFromFile : Error processing arguments"); + cobj->addSpriteFrameFromFile(arg0, arg1); + args.rval().setUndefined(); + return true; + } + if (argc == 3) { + std::string arg0; + std::string arg1; + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ArmatureDataManager_addSpriteFrameFromFile : Error processing arguments"); + cobj->addSpriteFrameFromFile(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_addSpriteFrameFromFile : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_ArmatureDataManager_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::ArmatureDataManager::destroyInstance(); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_destroyInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_ArmatureDataManager_getInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::ArmatureDataManager* ret = cocostudio::ArmatureDataManager::getInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ArmatureDataManager*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_ArmatureDataManager_getInstance : wrong number of arguments"); + return false; +} + + + +void js_cocostudio_ArmatureDataManager_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ArmatureDataManager)", obj); +} + +void js_register_cocos2dx_studio_ArmatureDataManager(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_ArmatureDataManager_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_ArmatureDataManager_class->name = "ArmatureDataManager"; + jsb_cocostudio_ArmatureDataManager_class->addProperty = JS_PropertyStub; + jsb_cocostudio_ArmatureDataManager_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_ArmatureDataManager_class->getProperty = JS_PropertyStub; + jsb_cocostudio_ArmatureDataManager_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_ArmatureDataManager_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_ArmatureDataManager_class->resolve = JS_ResolveStub; + jsb_cocostudio_ArmatureDataManager_class->convert = JS_ConvertStub; + jsb_cocostudio_ArmatureDataManager_class->finalize = js_cocostudio_ArmatureDataManager_finalize; + jsb_cocostudio_ArmatureDataManager_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getAnimationDatas", js_cocos2dx_studio_ArmatureDataManager_getAnimationDatas, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAnimationData", js_cocos2dx_studio_ArmatureDataManager_removeAnimationData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addArmatureData", js_cocos2dx_studio_ArmatureDataManager_addArmatureData, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addArmatureFileInfo", js_cocos2dx_studio_ArmatureDataManager_addArmatureFileInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeArmatureFileInfo", js_cocos2dx_studio_ArmatureDataManager_removeArmatureFileInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTextureData", js_cocos2dx_studio_ArmatureDataManager_getTextureData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getArmatureData", js_cocos2dx_studio_ArmatureDataManager_getArmatureData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAnimationData", js_cocos2dx_studio_ArmatureDataManager_getAnimationData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addAnimationData", js_cocos2dx_studio_ArmatureDataManager_addAnimationData, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_studio_ArmatureDataManager_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeArmatureData", js_cocos2dx_studio_ArmatureDataManager_removeArmatureData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getArmatureDatas", js_cocos2dx_studio_ArmatureDataManager_getArmatureDatas, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeTextureData", js_cocos2dx_studio_ArmatureDataManager_removeTextureData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addTextureData", js_cocos2dx_studio_ArmatureDataManager_addTextureData, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isAutoLoadSpriteFile", js_cocos2dx_studio_ArmatureDataManager_isAutoLoadSpriteFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addSpriteFrameFromFile", js_cocos2dx_studio_ArmatureDataManager_addSpriteFrameFromFile, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("destroyInstance", js_cocos2dx_studio_ArmatureDataManager_destroyInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInstance", js_cocos2dx_studio_ArmatureDataManager_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_ArmatureDataManager_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocostudio_ArmatureDataManager_class, + empty_constructor, 0, + 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, "ArmatureDataManager", 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_cocostudio_ArmatureDataManager_class; + p->proto = jsb_cocostudio_ArmatureDataManager_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_Armature_class; +JSObject *jsb_cocostudio_Armature_prototype; + +bool js_cocos2dx_studio_Armature_getBone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_getBone : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Armature_getBone : Error processing arguments"); + cocostudio::Bone* ret = cobj->getBone(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::Bone*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_getBone : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Armature_changeBoneParent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_changeBoneParent : Invalid Native Object"); + if (argc == 2) { + cocostudio::Bone* arg0; + std::string arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Armature_changeBoneParent : Error processing arguments"); + cobj->changeBoneParent(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_changeBoneParent : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_Armature_setAnimation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_setAnimation : Invalid Native Object"); + if (argc == 1) { + cocostudio::ArmatureAnimation* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::ArmatureAnimation*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Armature_setAnimation : Error processing arguments"); + cobj->setAnimation(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_setAnimation : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Armature_getBoneAtPoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_getBoneAtPoint : Invalid Native Object"); + if (argc == 2) { + double arg0; + double arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Armature_getBoneAtPoint : Error processing arguments"); + cocostudio::Bone* ret = cobj->getBoneAtPoint(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::Bone*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_getBoneAtPoint : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_Armature_getArmatureTransformDirty(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_getArmatureTransformDirty : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->getArmatureTransformDirty(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_getArmatureTransformDirty : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Armature_setVersion(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_setVersion : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Armature_setVersion : Error processing arguments"); + cobj->setVersion(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_setVersion : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Armature_updateOffsetPoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_updateOffsetPoint : Invalid Native Object"); + if (argc == 0) { + cobj->updateOffsetPoint(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_updateOffsetPoint : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Armature_getParentBone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_getParentBone : Invalid Native Object"); + if (argc == 0) { + cocostudio::Bone* ret = cobj->getParentBone(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::Bone*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_getParentBone : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Armature_removeBone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_removeBone : Invalid Native Object"); + if (argc == 2) { + cocostudio::Bone* arg0; + bool arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Armature_removeBone : Error processing arguments"); + cobj->removeBone(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_removeBone : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_Armature_getBatchNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_getBatchNode : Invalid Native Object"); + if (argc == 0) { + cocostudio::BatchNode* ret = cobj->getBatchNode(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::BatchNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_getBatchNode : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Armature_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocostudio::Armature* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_init : Invalid Native Object"); + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocostudio::Bone* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + bool ret = cobj->init(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + bool ret = cobj->init(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_init : wrong number of arguments"); + return false; +} +bool js_cocos2dx_studio_Armature_setParentBone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_setParentBone : Invalid Native Object"); + if (argc == 1) { + cocostudio::Bone* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Armature_setParentBone : Error processing arguments"); + cobj->setParentBone(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_setParentBone : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Armature_setBatchNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_setBatchNode : Invalid Native Object"); + if (argc == 1) { + cocostudio::BatchNode* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::BatchNode*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Armature_setBatchNode : Error processing arguments"); + cobj->setBatchNode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_setBatchNode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Armature_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_getBlendFunc : Invalid Native Object"); + if (argc == 0) { + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Armature_setArmatureData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_setArmatureData : Invalid Native Object"); + if (argc == 1) { + cocostudio::ArmatureData* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::ArmatureData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Armature_setArmatureData : Error processing arguments"); + cobj->setArmatureData(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_setArmatureData : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Armature_addBone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_addBone : Invalid Native Object"); + if (argc == 2) { + cocostudio::Bone* arg0; + std::string arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Armature_addBone : Error processing arguments"); + cobj->addBone(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_addBone : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_Armature_getArmatureData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_getArmatureData : Invalid Native Object"); + if (argc == 0) { + cocostudio::ArmatureData* ret = cobj->getArmatureData(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ArmatureData*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_getArmatureData : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Armature_getBoundingBox(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_getBoundingBox : Invalid Native Object"); + if (argc == 0) { + cocos2d::Rect ret = cobj->getBoundingBox(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_getBoundingBox : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Armature_getVersion(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_getVersion : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getVersion(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_getVersion : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Armature_getAnimation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_getAnimation : Invalid Native Object"); + if (argc == 0) { + cocostudio::ArmatureAnimation* ret = cobj->getAnimation(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ArmatureAnimation*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_getAnimation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Armature_getOffsetPoints(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_getOffsetPoints : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getOffsetPoints(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_getOffsetPoints : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Armature_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_setBlendFunc : Invalid Native Object"); + if (argc == 1) { + cocos2d::BlendFunc arg0; + ok &= jsval_to_blendfunc(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Armature_setBlendFunc : Error processing arguments"); + cobj->setBlendFunc(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Armature_getBoneDic(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Armature* cobj = (cocostudio::Armature *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Armature_getBoneDic : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Map& ret = cobj->getBoneDic(); + jsval jsret = JSVAL_NULL; + jsret = ccmap_string_key_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Armature_getBoneDic : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Armature_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocostudio::Armature* ret = cocostudio::Armature::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::Armature*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocostudio::Armature* ret = cocostudio::Armature::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::Armature*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocostudio::Bone* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocostudio::Armature* ret = cocostudio::Armature::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::Armature*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_studio_Armature_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_studio_Armature_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::Armature* cobj = new (std::nothrow) cocostudio::Armature(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::Armature"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocostudio_Armature_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Armature)", obj); +} + +static bool js_cocostudio_Armature_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocostudio::Armature *nobj = new (std::nothrow) cocostudio::Armature(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::Armature"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_studio_Armature(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_Armature_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_Armature_class->name = "Armature"; + jsb_cocostudio_Armature_class->addProperty = JS_PropertyStub; + jsb_cocostudio_Armature_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_Armature_class->getProperty = JS_PropertyStub; + jsb_cocostudio_Armature_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_Armature_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_Armature_class->resolve = JS_ResolveStub; + jsb_cocostudio_Armature_class->convert = JS_ConvertStub; + jsb_cocostudio_Armature_class->finalize = js_cocostudio_Armature_finalize; + jsb_cocostudio_Armature_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getBone", js_cocos2dx_studio_Armature_getBone, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("changeBoneParent", js_cocos2dx_studio_Armature_changeBoneParent, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAnimation", js_cocos2dx_studio_Armature_setAnimation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBoneAtPoint", js_cocos2dx_studio_Armature_getBoneAtPoint, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getArmatureTransformDirty", js_cocos2dx_studio_Armature_getArmatureTransformDirty, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setVersion", js_cocos2dx_studio_Armature_setVersion, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateOffsetPoint", js_cocos2dx_studio_Armature_updateOffsetPoint, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getParentBone", js_cocos2dx_studio_Armature_getParentBone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeBone", js_cocos2dx_studio_Armature_removeBone, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBatchNode", js_cocos2dx_studio_Armature_getBatchNode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_studio_Armature_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setParentBone", js_cocos2dx_studio_Armature_setParentBone, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBatchNode", js_cocos2dx_studio_Armature_setBatchNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBlendFunc", js_cocos2dx_studio_Armature_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setArmatureData", js_cocos2dx_studio_Armature_setArmatureData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addBone", js_cocos2dx_studio_Armature_addBone, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getArmatureData", js_cocos2dx_studio_Armature_getArmatureData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("boundingBox", js_cocos2dx_studio_Armature_getBoundingBox, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVersion", js_cocos2dx_studio_Armature_getVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAnimation", js_cocos2dx_studio_Armature_getAnimation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOffsetPoints", js_cocos2dx_studio_Armature_getOffsetPoints, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBlendFunc", js_cocos2dx_studio_Armature_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBoneDic", js_cocos2dx_studio_Armature_getBoneDic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocostudio_Armature_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_Armature_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_Armature_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocostudio_Armature_class, + js_cocos2dx_studio_Armature_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, "Armature", 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_cocostudio_Armature_class; + p->proto = jsb_cocostudio_Armature_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_Skin_class; +JSObject *jsb_cocostudio_Skin_prototype; + +bool js_cocos2dx_studio_Skin_getBone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Skin* cobj = (cocostudio::Skin *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Skin_getBone : Invalid Native Object"); + if (argc == 0) { + cocostudio::Bone* ret = cobj->getBone(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::Bone*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Skin_getBone : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Skin_getNodeToWorldTransformAR(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Skin* cobj = (cocostudio::Skin *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Skin_getNodeToWorldTransformAR : Invalid Native Object"); + if (argc == 0) { + cocos2d::Mat4 ret = cobj->getNodeToWorldTransformAR(); + jsval jsret = JSVAL_NULL; + jsret = matrix_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Skin_getNodeToWorldTransformAR : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Skin_getDisplayName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Skin* cobj = (cocostudio::Skin *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Skin_getDisplayName : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getDisplayName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Skin_getDisplayName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Skin_updateArmatureTransform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Skin* cobj = (cocostudio::Skin *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Skin_updateArmatureTransform : Invalid Native Object"); + if (argc == 0) { + cobj->updateArmatureTransform(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Skin_updateArmatureTransform : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Skin_setBone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::Skin* cobj = (cocostudio::Skin *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Skin_setBone : Invalid Native Object"); + if (argc == 1) { + cocostudio::Bone* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::Bone*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Skin_setBone : Error processing arguments"); + cobj->setBone(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Skin_setBone : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Skin_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocostudio::Skin* ret = cocostudio::Skin::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::Skin*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocostudio::Skin* ret = cocostudio::Skin::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::Skin*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_studio_Skin_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_studio_Skin_createWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Skin_createWithSpriteFrameName : Error processing arguments"); + cocostudio::Skin* ret = cocostudio::Skin::createWithSpriteFrameName(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::Skin*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_Skin_createWithSpriteFrameName : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_Skin_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::Skin* cobj = new (std::nothrow) cocostudio::Skin(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::Skin"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Sprite_prototype; + +void js_cocostudio_Skin_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Skin)", obj); +} + +void js_register_cocos2dx_studio_Skin(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_Skin_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_Skin_class->name = "Skin"; + jsb_cocostudio_Skin_class->addProperty = JS_PropertyStub; + jsb_cocostudio_Skin_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_Skin_class->getProperty = JS_PropertyStub; + jsb_cocostudio_Skin_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_Skin_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_Skin_class->resolve = JS_ResolveStub; + jsb_cocostudio_Skin_class->convert = JS_ConvertStub; + jsb_cocostudio_Skin_class->finalize = js_cocostudio_Skin_finalize; + jsb_cocostudio_Skin_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getBone", js_cocos2dx_studio_Skin_getBone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNodeToWorldTransformAR", js_cocos2dx_studio_Skin_getNodeToWorldTransformAR, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDisplayName", js_cocos2dx_studio_Skin_getDisplayName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateArmatureTransform", js_cocos2dx_studio_Skin_updateArmatureTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBone", js_cocos2dx_studio_Skin_setBone, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_Skin_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithSpriteFrameName", js_cocos2dx_studio_Skin_createWithSpriteFrameName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_Skin_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Sprite_prototype), + jsb_cocostudio_Skin_class, + js_cocos2dx_studio_Skin_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, "Skin", 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_cocostudio_Skin_class; + p->proto = jsb_cocostudio_Skin_prototype; + p->parentProto = jsb_cocos2d_Sprite_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_ComAttribute_class; +JSObject *jsb_cocostudio_ComAttribute_prototype; + +bool js_cocos2dx_studio_ComAttribute_getFloat(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAttribute* cobj = (cocostudio::ComAttribute *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAttribute_getFloat : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAttribute_getFloat : Error processing arguments"); + double ret = cobj->getFloat(arg0); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + std::string arg0; + double arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAttribute_getFloat : Error processing arguments"); + double ret = cobj->getFloat(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_getFloat : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ComAttribute_getBool(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAttribute* cobj = (cocostudio::ComAttribute *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAttribute_getBool : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAttribute_getBool : Error processing arguments"); + bool ret = cobj->getBool(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + std::string arg0; + bool arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAttribute_getBool : Error processing arguments"); + bool ret = cobj->getBool(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_getBool : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ComAttribute_getString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAttribute* cobj = (cocostudio::ComAttribute *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAttribute_getString : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAttribute_getString : Error processing arguments"); + std::string ret = cobj->getString(arg0); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAttribute_getString : Error processing arguments"); + std::string ret = cobj->getString(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_getString : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ComAttribute_setFloat(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAttribute* cobj = (cocostudio::ComAttribute *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAttribute_setFloat : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + double arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAttribute_setFloat : Error processing arguments"); + cobj->setFloat(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_setFloat : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_ComAttribute_setString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAttribute* cobj = (cocostudio::ComAttribute *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAttribute_setString : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAttribute_setString : Error processing arguments"); + cobj->setString(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_setString : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_ComAttribute_setInt(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAttribute* cobj = (cocostudio::ComAttribute *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAttribute_setInt : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + int arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAttribute_setInt : Error processing arguments"); + cobj->setInt(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_setInt : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_ComAttribute_parse(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAttribute* cobj = (cocostudio::ComAttribute *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAttribute_parse : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAttribute_parse : Error processing arguments"); + bool ret = cobj->parse(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_parse : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ComAttribute_getInt(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAttribute* cobj = (cocostudio::ComAttribute *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAttribute_getInt : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAttribute_getInt : Error processing arguments"); + int ret = cobj->getInt(arg0); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + std::string arg0; + int arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAttribute_getInt : Error processing arguments"); + int ret = cobj->getInt(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_getInt : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ComAttribute_setBool(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAttribute* cobj = (cocostudio::ComAttribute *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAttribute_setBool : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + bool arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAttribute_setBool : Error processing arguments"); + cobj->setBool(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_setBool : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_ComAttribute_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::ComAttribute* ret = cocostudio::ComAttribute::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ComAttribute*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_ComAttribute_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_ComAttribute_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::ComAttribute* cobj = new (std::nothrow) cocostudio::ComAttribute(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::ComAttribute"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Component_prototype; + +void js_cocostudio_ComAttribute_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ComAttribute)", obj); +} + +void js_register_cocos2dx_studio_ComAttribute(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_ComAttribute_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_ComAttribute_class->name = "ComAttribute"; + jsb_cocostudio_ComAttribute_class->addProperty = JS_PropertyStub; + jsb_cocostudio_ComAttribute_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_ComAttribute_class->getProperty = JS_PropertyStub; + jsb_cocostudio_ComAttribute_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_ComAttribute_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_ComAttribute_class->resolve = JS_ResolveStub; + jsb_cocostudio_ComAttribute_class->convert = JS_ConvertStub; + jsb_cocostudio_ComAttribute_class->finalize = js_cocostudio_ComAttribute_finalize; + jsb_cocostudio_ComAttribute_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getFloat", js_cocos2dx_studio_ComAttribute_getFloat, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBool", js_cocos2dx_studio_ComAttribute_getBool, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getString", js_cocos2dx_studio_ComAttribute_getString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFloat", js_cocos2dx_studio_ComAttribute_setFloat, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setString", js_cocos2dx_studio_ComAttribute_setString, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setInt", js_cocos2dx_studio_ComAttribute_setInt, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("parse", js_cocos2dx_studio_ComAttribute_parse, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInt", js_cocos2dx_studio_ComAttribute_getInt, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBool", js_cocos2dx_studio_ComAttribute_setBool, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_ComAttribute_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_ComAttribute_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + jsb_cocostudio_ComAttribute_class, + js_cocos2dx_studio_ComAttribute_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, "ComAttribute", 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_cocostudio_ComAttribute_class; + p->proto = jsb_cocostudio_ComAttribute_prototype; + p->parentProto = jsb_cocos2d_Component_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_ComAudio_class; +JSObject *jsb_cocostudio_ComAudio_prototype; + +bool js_cocos2dx_studio_ComAudio_stopAllEffects(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_stopAllEffects : Invalid Native Object"); + if (argc == 0) { + cobj->stopAllEffects(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_stopAllEffects : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ComAudio_getEffectsVolume(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_getEffectsVolume : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getEffectsVolume(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_getEffectsVolume : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ComAudio_stopEffect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_stopEffect : Invalid Native Object"); + if (argc == 1) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAudio_stopEffect : Error processing arguments"); + cobj->stopEffect(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_stopEffect : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ComAudio_getBackgroundMusicVolume(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_getBackgroundMusicVolume : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getBackgroundMusicVolume(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_getBackgroundMusicVolume : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ComAudio_willPlayBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_willPlayBackgroundMusic : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->willPlayBackgroundMusic(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_willPlayBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ComAudio_setBackgroundMusicVolume(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_setBackgroundMusicVolume : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAudio_setBackgroundMusicVolume : Error processing arguments"); + cobj->setBackgroundMusicVolume(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_setBackgroundMusicVolume : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ComAudio_end(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_end : Invalid Native Object"); + if (argc == 0) { + cobj->end(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_end : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ComAudio_stopBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocostudio::ComAudio* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_stopBackgroundMusic : Invalid Native Object"); + do { + if (argc == 0) { + cobj->stopBackgroundMusic(); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + cobj->stopBackgroundMusic(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_stopBackgroundMusic : wrong number of arguments"); + return false; +} +bool js_cocos2dx_studio_ComAudio_pauseBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_pauseBackgroundMusic : Invalid Native Object"); + if (argc == 0) { + cobj->pauseBackgroundMusic(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_pauseBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ComAudio_isBackgroundMusicPlaying(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_isBackgroundMusicPlaying : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isBackgroundMusicPlaying(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_isBackgroundMusicPlaying : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ComAudio_isLoop(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_isLoop : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isLoop(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_isLoop : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ComAudio_resumeAllEffects(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_resumeAllEffects : Invalid Native Object"); + if (argc == 0) { + cobj->resumeAllEffects(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_resumeAllEffects : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ComAudio_pauseAllEffects(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_pauseAllEffects : Invalid Native Object"); + if (argc == 0) { + cobj->pauseAllEffects(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_pauseAllEffects : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ComAudio_preloadBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_preloadBackgroundMusic : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAudio_preloadBackgroundMusic : Error processing arguments"); + cobj->preloadBackgroundMusic(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_preloadBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ComAudio_playBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocostudio::ComAudio* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_playBackgroundMusic : Invalid Native Object"); + do { + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + if (!ok) { ok = true; break; } + cobj->playBackgroundMusic(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 2) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + if (!ok) { ok = true; break; } + bool arg1; + arg1 = JS::ToBoolean(args.get(1)); + cobj->playBackgroundMusic(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 0) { + cobj->playBackgroundMusic(); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_playBackgroundMusic : wrong number of arguments"); + return false; +} +bool js_cocos2dx_studio_ComAudio_playEffect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocostudio::ComAudio* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_playEffect : Invalid Native Object"); + do { + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + if (!ok) { ok = true; break; } + unsigned int ret = cobj->playEffect(arg0); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + if (!ok) { ok = true; break; } + bool arg1; + arg1 = JS::ToBoolean(args.get(1)); + unsigned int ret = cobj->playEffect(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + unsigned int ret = cobj->playEffect(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_playEffect : wrong number of arguments"); + return false; +} +bool js_cocos2dx_studio_ComAudio_preloadEffect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_preloadEffect : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAudio_preloadEffect : Error processing arguments"); + cobj->preloadEffect(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_preloadEffect : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ComAudio_setLoop(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_setLoop : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAudio_setLoop : Error processing arguments"); + cobj->setLoop(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_setLoop : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ComAudio_unloadEffect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_unloadEffect : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAudio_unloadEffect : Error processing arguments"); + cobj->unloadEffect(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_unloadEffect : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ComAudio_rewindBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_rewindBackgroundMusic : Invalid Native Object"); + if (argc == 0) { + cobj->rewindBackgroundMusic(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_rewindBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ComAudio_pauseEffect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_pauseEffect : Invalid Native Object"); + if (argc == 1) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAudio_pauseEffect : Error processing arguments"); + cobj->pauseEffect(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_pauseEffect : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ComAudio_resumeBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_resumeBackgroundMusic : Invalid Native Object"); + if (argc == 0) { + cobj->resumeBackgroundMusic(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_resumeBackgroundMusic : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ComAudio_setFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_setFile : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAudio_setFile : Error processing arguments"); + cobj->setFile(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_setFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ComAudio_setEffectsVolume(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_setEffectsVolume : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAudio_setEffectsVolume : Error processing arguments"); + cobj->setEffectsVolume(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_setEffectsVolume : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ComAudio_getFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_getFile : Invalid Native Object"); + if (argc == 0) { + const char* ret = cobj->getFile(); + jsval jsret = JSVAL_NULL; + jsret = c_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_getFile : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ComAudio_resumeEffect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComAudio* cobj = (cocostudio::ComAudio *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComAudio_resumeEffect : Invalid Native Object"); + if (argc == 1) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComAudio_resumeEffect : Error processing arguments"); + cobj->resumeEffect(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_resumeEffect : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ComAudio_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::ComAudio* ret = cocostudio::ComAudio::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ComAudio*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_ComAudio_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_ComAudio_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::ComAudio* cobj = new (std::nothrow) cocostudio::ComAudio(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::ComAudio"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Component_prototype; + +void js_cocostudio_ComAudio_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ComAudio)", obj); +} + +void js_register_cocos2dx_studio_ComAudio(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_ComAudio_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_ComAudio_class->name = "ComAudio"; + jsb_cocostudio_ComAudio_class->addProperty = JS_PropertyStub; + jsb_cocostudio_ComAudio_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_ComAudio_class->getProperty = JS_PropertyStub; + jsb_cocostudio_ComAudio_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_ComAudio_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_ComAudio_class->resolve = JS_ResolveStub; + jsb_cocostudio_ComAudio_class->convert = JS_ConvertStub; + jsb_cocostudio_ComAudio_class->finalize = js_cocostudio_ComAudio_finalize; + jsb_cocostudio_ComAudio_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("stopAllEffects", js_cocos2dx_studio_ComAudio_stopAllEffects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEffectsVolume", js_cocos2dx_studio_ComAudio_getEffectsVolume, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("stopEffect", js_cocos2dx_studio_ComAudio_stopEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackgroundMusicVolume", js_cocos2dx_studio_ComAudio_getBackgroundMusicVolume, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("willPlayBackgroundMusic", js_cocos2dx_studio_ComAudio_willPlayBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBackgroundMusicVolume", js_cocos2dx_studio_ComAudio_setBackgroundMusicVolume, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("end", js_cocos2dx_studio_ComAudio_end, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("stopBackgroundMusic", js_cocos2dx_studio_ComAudio_stopBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pauseBackgroundMusic", js_cocos2dx_studio_ComAudio_pauseBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isBackgroundMusicPlaying", js_cocos2dx_studio_ComAudio_isBackgroundMusicPlaying, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isLoop", js_cocos2dx_studio_ComAudio_isLoop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resumeAllEffects", js_cocos2dx_studio_ComAudio_resumeAllEffects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pauseAllEffects", js_cocos2dx_studio_ComAudio_pauseAllEffects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("preloadBackgroundMusic", js_cocos2dx_studio_ComAudio_preloadBackgroundMusic, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("playBackgroundMusic", js_cocos2dx_studio_ComAudio_playBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("playEffect", js_cocos2dx_studio_ComAudio_playEffect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("preloadEffect", js_cocos2dx_studio_ComAudio_preloadEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLoop", js_cocos2dx_studio_ComAudio_setLoop, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("unloadEffect", js_cocos2dx_studio_ComAudio_unloadEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("rewindBackgroundMusic", js_cocos2dx_studio_ComAudio_rewindBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pauseEffect", js_cocos2dx_studio_ComAudio_pauseEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resumeBackgroundMusic", js_cocos2dx_studio_ComAudio_resumeBackgroundMusic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFile", js_cocos2dx_studio_ComAudio_setFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEffectsVolume", js_cocos2dx_studio_ComAudio_setEffectsVolume, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFile", js_cocos2dx_studio_ComAudio_getFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resumeEffect", js_cocos2dx_studio_ComAudio_resumeEffect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_ComAudio_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_ComAudio_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + jsb_cocostudio_ComAudio_class, + js_cocos2dx_studio_ComAudio_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, "ComAudio", 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_cocostudio_ComAudio_class; + p->proto = jsb_cocostudio_ComAudio_prototype; + p->parentProto = jsb_cocos2d_Component_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_InputDelegate_class; +JSObject *jsb_cocostudio_InputDelegate_prototype; + +bool js_cocos2dx_studio_InputDelegate_isAccelerometerEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InputDelegate_isAccelerometerEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isAccelerometerEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_isAccelerometerEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_InputDelegate_setKeypadEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InputDelegate_setKeypadEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_InputDelegate_setKeypadEnabled : Error processing arguments"); + cobj->setKeypadEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_setKeypadEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_InputDelegate_getTouchMode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InputDelegate_getTouchMode : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getTouchMode(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_getTouchMode : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_InputDelegate_setAccelerometerEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InputDelegate_setAccelerometerEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_InputDelegate_setAccelerometerEnabled : Error processing arguments"); + cobj->setAccelerometerEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_setAccelerometerEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_InputDelegate_isKeypadEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InputDelegate_isKeypadEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isKeypadEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_isKeypadEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_InputDelegate_isTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InputDelegate_isTouchEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isTouchEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_isTouchEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_InputDelegate_setTouchPriority(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InputDelegate_setTouchPriority : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_InputDelegate_setTouchPriority : Error processing arguments"); + cobj->setTouchPriority(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_setTouchPriority : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_InputDelegate_getTouchPriority(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InputDelegate_getTouchPriority : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getTouchPriority(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_getTouchPriority : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_InputDelegate_setTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InputDelegate_setTouchEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_InputDelegate_setTouchEnabled : Error processing arguments"); + cobj->setTouchEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_setTouchEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_InputDelegate_setTouchMode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::InputDelegate* cobj = (cocostudio::InputDelegate *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InputDelegate_setTouchMode : Invalid Native Object"); + if (argc == 1) { + cocos2d::Touch::DispatchMode arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_InputDelegate_setTouchMode : Error processing arguments"); + cobj->setTouchMode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InputDelegate_setTouchMode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + + +void js_cocostudio_InputDelegate_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (InputDelegate)", obj); +} + +void js_register_cocos2dx_studio_InputDelegate(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_InputDelegate_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_InputDelegate_class->name = "InputDelegate"; + jsb_cocostudio_InputDelegate_class->addProperty = JS_PropertyStub; + jsb_cocostudio_InputDelegate_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_InputDelegate_class->getProperty = JS_PropertyStub; + jsb_cocostudio_InputDelegate_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_InputDelegate_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_InputDelegate_class->resolve = JS_ResolveStub; + jsb_cocostudio_InputDelegate_class->convert = JS_ConvertStub; + jsb_cocostudio_InputDelegate_class->finalize = js_cocostudio_InputDelegate_finalize; + jsb_cocostudio_InputDelegate_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("isAccelerometerEnabled", js_cocos2dx_studio_InputDelegate_isAccelerometerEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setKeypadEnabled", js_cocos2dx_studio_InputDelegate_setKeypadEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTouchMode", js_cocos2dx_studio_InputDelegate_getTouchMode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAccelerometerEnabled", js_cocos2dx_studio_InputDelegate_setAccelerometerEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isKeypadEnabled", js_cocos2dx_studio_InputDelegate_isKeypadEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isTouchEnabled", js_cocos2dx_studio_InputDelegate_isTouchEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTouchPriority", js_cocos2dx_studio_InputDelegate_setTouchPriority, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTouchPriority", js_cocos2dx_studio_InputDelegate_getTouchPriority, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTouchEnabled", js_cocos2dx_studio_InputDelegate_setTouchEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTouchMode", js_cocos2dx_studio_InputDelegate_setTouchMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocostudio_InputDelegate_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocostudio_InputDelegate_class, + empty_constructor, 0, + 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, "InputDelegate", 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_cocostudio_InputDelegate_class; + p->proto = jsb_cocostudio_InputDelegate_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_ComController_class; +JSObject *jsb_cocostudio_ComController_prototype; + +bool js_cocos2dx_studio_ComController_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::ComController* ret = cocostudio::ComController::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ComController*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_ComController_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_ComController_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::ComController* cobj = new (std::nothrow) cocostudio::ComController(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::ComController"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Component_prototype; + +void js_cocostudio_ComController_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ComController)", obj); +} + +static bool js_cocostudio_ComController_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocostudio::ComController *nobj = new (std::nothrow) cocostudio::ComController(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::ComController"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_studio_ComController(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_ComController_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_ComController_class->name = "ComController"; + jsb_cocostudio_ComController_class->addProperty = JS_PropertyStub; + jsb_cocostudio_ComController_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_ComController_class->getProperty = JS_PropertyStub; + jsb_cocostudio_ComController_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_ComController_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_ComController_class->resolve = JS_ResolveStub; + jsb_cocostudio_ComController_class->convert = JS_ConvertStub; + jsb_cocostudio_ComController_class->finalize = js_cocostudio_ComController_finalize; + jsb_cocostudio_ComController_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocostudio_ComController_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_ComController_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_ComController_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + jsb_cocostudio_ComController_class, + js_cocos2dx_studio_ComController_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, "ComController", 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_cocostudio_ComController_class; + p->proto = jsb_cocostudio_ComController_prototype; + p->parentProto = jsb_cocos2d_Component_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_ComRender_class; +JSObject *jsb_cocostudio_ComRender_prototype; + +bool js_cocos2dx_studio_ComRender_getNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComRender* cobj = (cocostudio::ComRender *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComRender_getNode : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getNode(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComRender_getNode : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ComRender_setNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ComRender* cobj = (cocostudio::ComRender *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ComRender_setNode : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ComRender_setNode : Error processing arguments"); + cobj->setNode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ComRender_setNode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ComRender_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + const char* arg1; + std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + if (!ok) { ok = true; break; } + cocostudio::ComRender* ret = cocostudio::ComRender::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ComRender*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocostudio::ComRender* ret = cocostudio::ComRender::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ComRender*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_studio_ComRender_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_studio_ComRender_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocostudio::ComRender* cobj = NULL; + do { + if (argc == 2) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + const char* arg1; + std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + if (!ok) { ok = true; break; } + cobj = new (std::nothrow) cocostudio::ComRender(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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::ComRender"); + } + } while(0); + + do { + if (argc == 0) { + cobj = new (std::nothrow) cocostudio::ComRender(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + obj = JS_NewObject(cx, typeClass->jsclass, proto, parent); + + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::ComRender"); + } + } while(0); + + if (cobj) { + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + + args.rval().set(OBJECT_TO_JSVAL(obj)); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_ComRender_constructor : wrong number of arguments"); + return false; +} + + +extern JSObject *jsb_cocos2d_Component_prototype; + +void js_cocostudio_ComRender_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ComRender)", obj); +} + +void js_register_cocos2dx_studio_ComRender(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_ComRender_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_ComRender_class->name = "ComRender"; + jsb_cocostudio_ComRender_class->addProperty = JS_PropertyStub; + jsb_cocostudio_ComRender_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_ComRender_class->getProperty = JS_PropertyStub; + jsb_cocostudio_ComRender_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_ComRender_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_ComRender_class->resolve = JS_ResolveStub; + jsb_cocostudio_ComRender_class->convert = JS_ConvertStub; + jsb_cocostudio_ComRender_class->finalize = js_cocostudio_ComRender_finalize; + jsb_cocostudio_ComRender_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getNode", js_cocos2dx_studio_ComRender_getNode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setNode", js_cocos2dx_studio_ComRender_setNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_ComRender_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_ComRender_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + jsb_cocostudio_ComRender_class, + js_cocos2dx_studio_ComRender_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, "ComRender", 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_cocostudio_ComRender_class; + p->proto = jsb_cocostudio_ComRender_prototype; + p->parentProto = jsb_cocos2d_Component_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_timeline_Frame_class; +JSObject *jsb_cocostudio_timeline_Frame_prototype; + +bool js_cocos2dx_studio_Frame_clone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Frame* cobj = (cocostudio::timeline::Frame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Frame_clone : Invalid Native Object"); + if (argc == 0) { + cocostudio::timeline::Frame* ret = cobj->clone(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::Frame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Frame_clone : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Frame_setTweenType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Frame* cobj = (cocostudio::timeline::Frame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Frame_setTweenType : Invalid Native Object"); + if (argc == 1) { + cocos2d::tweenfunc::TweenType arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Frame_setTweenType : Error processing arguments"); + cobj->setTweenType(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Frame_setTweenType : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Frame_setNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Frame* cobj = (cocostudio::timeline::Frame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Frame_setNode : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Frame_setNode : Error processing arguments"); + cobj->setNode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Frame_setNode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Frame_setTimeline(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Frame* cobj = (cocostudio::timeline::Frame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Frame_setTimeline : Invalid Native Object"); + if (argc == 1) { + cocostudio::timeline::Timeline* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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_Frame_setTimeline : Error processing arguments"); + cobj->setTimeline(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Frame_setTimeline : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Frame_isEnterWhenPassed(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Frame* cobj = (cocostudio::timeline::Frame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Frame_isEnterWhenPassed : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isEnterWhenPassed(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Frame_isEnterWhenPassed : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Frame_getTweenType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Frame* cobj = (cocostudio::timeline::Frame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Frame_getTweenType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getTweenType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Frame_getTweenType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Frame_getFrameIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Frame* cobj = (cocostudio::timeline::Frame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Frame_getFrameIndex : Invalid Native Object"); + if (argc == 0) { + unsigned int ret = cobj->getFrameIndex(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Frame_getFrameIndex : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Frame_apply(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Frame* cobj = (cocostudio::timeline::Frame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Frame_apply : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Frame_apply : Error processing arguments"); + cobj->apply(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Frame_apply : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Frame_isTween(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Frame* cobj = (cocostudio::timeline::Frame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Frame_isTween : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isTween(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Frame_isTween : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Frame_setFrameIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Frame* cobj = (cocostudio::timeline::Frame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Frame_setFrameIndex : Invalid Native Object"); + if (argc == 1) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Frame_setFrameIndex : Error processing arguments"); + cobj->setFrameIndex(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Frame_setFrameIndex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Frame_setTween(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Frame* cobj = (cocostudio::timeline::Frame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Frame_setTween : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Frame_setTween : Error processing arguments"); + cobj->setTween(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Frame_setTween : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Frame_getTimeline(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Frame* cobj = (cocostudio::timeline::Frame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Frame_getTimeline : Invalid Native Object"); + if (argc == 0) { + cocostudio::timeline::Timeline* ret = cobj->getTimeline(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::Timeline*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Frame_getTimeline : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Frame_getNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Frame* cobj = (cocostudio::timeline::Frame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Frame_getNode : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getNode(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Frame_getNode : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + + +void js_cocostudio_timeline_Frame_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Frame)", obj); +} + +void js_register_cocos2dx_studio_Frame(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_timeline_Frame_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_timeline_Frame_class->name = "Frame"; + jsb_cocostudio_timeline_Frame_class->addProperty = JS_PropertyStub; + jsb_cocostudio_timeline_Frame_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_timeline_Frame_class->getProperty = JS_PropertyStub; + jsb_cocostudio_timeline_Frame_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_timeline_Frame_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_timeline_Frame_class->resolve = JS_ResolveStub; + jsb_cocostudio_timeline_Frame_class->convert = JS_ConvertStub; + jsb_cocostudio_timeline_Frame_class->finalize = js_cocostudio_timeline_Frame_finalize; + jsb_cocostudio_timeline_Frame_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("clone", js_cocos2dx_studio_Frame_clone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTweenType", js_cocos2dx_studio_Frame_setTweenType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setNode", js_cocos2dx_studio_Frame_setNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTimeline", js_cocos2dx_studio_Frame_setTimeline, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isEnterWhenPassed", js_cocos2dx_studio_Frame_isEnterWhenPassed, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTweenType", js_cocos2dx_studio_Frame_getTweenType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFrameIndex", js_cocos2dx_studio_Frame_getFrameIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("apply", js_cocos2dx_studio_Frame_apply, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isTween", js_cocos2dx_studio_Frame_isTween, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFrameIndex", js_cocos2dx_studio_Frame_setFrameIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTween", js_cocos2dx_studio_Frame_setTween, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTimeline", js_cocos2dx_studio_Frame_getTimeline, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNode", js_cocos2dx_studio_Frame_getNode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocostudio_timeline_Frame_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocostudio_timeline_Frame_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, "Frame", 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_cocostudio_timeline_Frame_class; + p->proto = jsb_cocostudio_timeline_Frame_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_timeline_VisibleFrame_class; +JSObject *jsb_cocostudio_timeline_VisibleFrame_prototype; + +bool js_cocos2dx_studio_VisibleFrame_isVisible(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::VisibleFrame* cobj = (cocostudio::timeline::VisibleFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_VisibleFrame_isVisible : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isVisible(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_VisibleFrame_isVisible : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_VisibleFrame_setVisible(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::VisibleFrame* cobj = (cocostudio::timeline::VisibleFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_VisibleFrame_setVisible : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_VisibleFrame_setVisible : Error processing arguments"); + cobj->setVisible(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_VisibleFrame_setVisible : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_VisibleFrame_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::timeline::VisibleFrame* ret = cocostudio::timeline::VisibleFrame::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::VisibleFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_VisibleFrame_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_VisibleFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::timeline::VisibleFrame* cobj = new (std::nothrow) cocostudio::timeline::VisibleFrame(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::timeline::VisibleFrame"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocostudio_timeline_Frame_prototype; + +void js_cocostudio_timeline_VisibleFrame_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (VisibleFrame)", obj); +} + +void js_register_cocos2dx_studio_VisibleFrame(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_timeline_VisibleFrame_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_timeline_VisibleFrame_class->name = "VisibleFrame"; + jsb_cocostudio_timeline_VisibleFrame_class->addProperty = JS_PropertyStub; + jsb_cocostudio_timeline_VisibleFrame_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_timeline_VisibleFrame_class->getProperty = JS_PropertyStub; + jsb_cocostudio_timeline_VisibleFrame_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_timeline_VisibleFrame_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_timeline_VisibleFrame_class->resolve = JS_ResolveStub; + jsb_cocostudio_timeline_VisibleFrame_class->convert = JS_ConvertStub; + jsb_cocostudio_timeline_VisibleFrame_class->finalize = js_cocostudio_timeline_VisibleFrame_finalize; + jsb_cocostudio_timeline_VisibleFrame_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("isVisible", js_cocos2dx_studio_VisibleFrame_isVisible, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setVisible", js_cocos2dx_studio_VisibleFrame_setVisible, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_VisibleFrame_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_timeline_VisibleFrame_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + jsb_cocostudio_timeline_VisibleFrame_class, + js_cocos2dx_studio_VisibleFrame_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, "VisibleFrame", 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_cocostudio_timeline_VisibleFrame_class; + p->proto = jsb_cocostudio_timeline_VisibleFrame_prototype; + p->parentProto = jsb_cocostudio_timeline_Frame_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_timeline_TextureFrame_class; +JSObject *jsb_cocostudio_timeline_TextureFrame_prototype; + +bool js_cocos2dx_studio_TextureFrame_getTextureName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::TextureFrame* cobj = (cocostudio::timeline::TextureFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_TextureFrame_getTextureName : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getTextureName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_TextureFrame_getTextureName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_TextureFrame_setTextureName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::TextureFrame* cobj = (cocostudio::timeline::TextureFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_TextureFrame_setTextureName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_TextureFrame_setTextureName : Error processing arguments"); + cobj->setTextureName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_TextureFrame_setTextureName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_TextureFrame_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::timeline::TextureFrame* ret = cocostudio::timeline::TextureFrame::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::TextureFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_TextureFrame_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_TextureFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::timeline::TextureFrame* cobj = new (std::nothrow) cocostudio::timeline::TextureFrame(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::timeline::TextureFrame"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocostudio_timeline_Frame_prototype; + +void js_cocostudio_timeline_TextureFrame_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TextureFrame)", obj); +} + +void js_register_cocos2dx_studio_TextureFrame(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_timeline_TextureFrame_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_timeline_TextureFrame_class->name = "TextureFrame"; + jsb_cocostudio_timeline_TextureFrame_class->addProperty = JS_PropertyStub; + jsb_cocostudio_timeline_TextureFrame_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_timeline_TextureFrame_class->getProperty = JS_PropertyStub; + jsb_cocostudio_timeline_TextureFrame_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_timeline_TextureFrame_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_timeline_TextureFrame_class->resolve = JS_ResolveStub; + jsb_cocostudio_timeline_TextureFrame_class->convert = JS_ConvertStub; + jsb_cocostudio_timeline_TextureFrame_class->finalize = js_cocostudio_timeline_TextureFrame_finalize; + jsb_cocostudio_timeline_TextureFrame_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getTextureName", js_cocos2dx_studio_TextureFrame_getTextureName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTextureName", js_cocos2dx_studio_TextureFrame_setTextureName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_TextureFrame_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_timeline_TextureFrame_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + jsb_cocostudio_timeline_TextureFrame_class, + js_cocos2dx_studio_TextureFrame_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, "TextureFrame", 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_cocostudio_timeline_TextureFrame_class; + p->proto = jsb_cocostudio_timeline_TextureFrame_prototype; + p->parentProto = jsb_cocostudio_timeline_Frame_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_timeline_RotationFrame_class; +JSObject *jsb_cocostudio_timeline_RotationFrame_prototype; + +bool js_cocos2dx_studio_RotationFrame_setRotation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::RotationFrame* cobj = (cocostudio::timeline::RotationFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_RotationFrame_setRotation : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_RotationFrame_setRotation : Error processing arguments"); + cobj->setRotation(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_RotationFrame_setRotation : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_RotationFrame_getRotation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::RotationFrame* cobj = (cocostudio::timeline::RotationFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_RotationFrame_getRotation : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getRotation(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_RotationFrame_getRotation : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_RotationFrame_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::timeline::RotationFrame* ret = cocostudio::timeline::RotationFrame::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::RotationFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_RotationFrame_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_RotationFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::timeline::RotationFrame* cobj = new (std::nothrow) cocostudio::timeline::RotationFrame(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::timeline::RotationFrame"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocostudio_timeline_Frame_prototype; + +void js_cocostudio_timeline_RotationFrame_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (RotationFrame)", obj); +} + +void js_register_cocos2dx_studio_RotationFrame(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_timeline_RotationFrame_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_timeline_RotationFrame_class->name = "RotationFrame"; + jsb_cocostudio_timeline_RotationFrame_class->addProperty = JS_PropertyStub; + jsb_cocostudio_timeline_RotationFrame_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_timeline_RotationFrame_class->getProperty = JS_PropertyStub; + jsb_cocostudio_timeline_RotationFrame_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_timeline_RotationFrame_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_timeline_RotationFrame_class->resolve = JS_ResolveStub; + jsb_cocostudio_timeline_RotationFrame_class->convert = JS_ConvertStub; + jsb_cocostudio_timeline_RotationFrame_class->finalize = js_cocostudio_timeline_RotationFrame_finalize; + jsb_cocostudio_timeline_RotationFrame_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setRotation", js_cocos2dx_studio_RotationFrame_setRotation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRotation", js_cocos2dx_studio_RotationFrame_getRotation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_RotationFrame_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_timeline_RotationFrame_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + jsb_cocostudio_timeline_RotationFrame_class, + js_cocos2dx_studio_RotationFrame_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, "RotationFrame", 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_cocostudio_timeline_RotationFrame_class; + p->proto = jsb_cocostudio_timeline_RotationFrame_prototype; + p->parentProto = jsb_cocostudio_timeline_Frame_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_timeline_SkewFrame_class; +JSObject *jsb_cocostudio_timeline_SkewFrame_prototype; + +bool js_cocos2dx_studio_SkewFrame_getSkewY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::SkewFrame* cobj = (cocostudio::timeline::SkewFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_SkewFrame_getSkewY : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getSkewY(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_SkewFrame_getSkewY : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_SkewFrame_setSkewX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::SkewFrame* cobj = (cocostudio::timeline::SkewFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_SkewFrame_setSkewX : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_SkewFrame_setSkewX : Error processing arguments"); + cobj->setSkewX(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_SkewFrame_setSkewX : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_SkewFrame_setSkewY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::SkewFrame* cobj = (cocostudio::timeline::SkewFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_SkewFrame_setSkewY : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_SkewFrame_setSkewY : Error processing arguments"); + cobj->setSkewY(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_SkewFrame_setSkewY : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_SkewFrame_getSkewX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::SkewFrame* cobj = (cocostudio::timeline::SkewFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_SkewFrame_getSkewX : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getSkewX(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_SkewFrame_getSkewX : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_SkewFrame_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::timeline::SkewFrame* ret = cocostudio::timeline::SkewFrame::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::SkewFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_SkewFrame_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_SkewFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::timeline::SkewFrame* cobj = new (std::nothrow) cocostudio::timeline::SkewFrame(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::timeline::SkewFrame"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocostudio_timeline_Frame_prototype; + +void js_cocostudio_timeline_SkewFrame_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (SkewFrame)", obj); +} + +void js_register_cocos2dx_studio_SkewFrame(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_timeline_SkewFrame_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_timeline_SkewFrame_class->name = "SkewFrame"; + jsb_cocostudio_timeline_SkewFrame_class->addProperty = JS_PropertyStub; + jsb_cocostudio_timeline_SkewFrame_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_timeline_SkewFrame_class->getProperty = JS_PropertyStub; + jsb_cocostudio_timeline_SkewFrame_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_timeline_SkewFrame_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_timeline_SkewFrame_class->resolve = JS_ResolveStub; + jsb_cocostudio_timeline_SkewFrame_class->convert = JS_ConvertStub; + jsb_cocostudio_timeline_SkewFrame_class->finalize = js_cocostudio_timeline_SkewFrame_finalize; + jsb_cocostudio_timeline_SkewFrame_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getSkewY", js_cocos2dx_studio_SkewFrame_getSkewY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSkewX", js_cocos2dx_studio_SkewFrame_setSkewX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSkewY", js_cocos2dx_studio_SkewFrame_setSkewY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSkewX", js_cocos2dx_studio_SkewFrame_getSkewX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_SkewFrame_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_timeline_SkewFrame_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + jsb_cocostudio_timeline_SkewFrame_class, + js_cocos2dx_studio_SkewFrame_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, "SkewFrame", 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_cocostudio_timeline_SkewFrame_class; + p->proto = jsb_cocostudio_timeline_SkewFrame_prototype; + p->parentProto = jsb_cocostudio_timeline_Frame_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_timeline_RotationSkewFrame_class; +JSObject *jsb_cocostudio_timeline_RotationSkewFrame_prototype; + +bool js_cocos2dx_studio_RotationSkewFrame_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::timeline::RotationSkewFrame* ret = cocostudio::timeline::RotationSkewFrame::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::RotationSkewFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_RotationSkewFrame_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_RotationSkewFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::timeline::RotationSkewFrame* cobj = new (std::nothrow) cocostudio::timeline::RotationSkewFrame(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::timeline::RotationSkewFrame"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocostudio_timeline_SkewFrame_prototype; + +void js_cocostudio_timeline_RotationSkewFrame_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (RotationSkewFrame)", obj); +} + +void js_register_cocos2dx_studio_RotationSkewFrame(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_timeline_RotationSkewFrame_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_timeline_RotationSkewFrame_class->name = "RotationSkewFrame"; + jsb_cocostudio_timeline_RotationSkewFrame_class->addProperty = JS_PropertyStub; + jsb_cocostudio_timeline_RotationSkewFrame_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_timeline_RotationSkewFrame_class->getProperty = JS_PropertyStub; + jsb_cocostudio_timeline_RotationSkewFrame_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_timeline_RotationSkewFrame_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_timeline_RotationSkewFrame_class->resolve = JS_ResolveStub; + jsb_cocostudio_timeline_RotationSkewFrame_class->convert = JS_ConvertStub; + jsb_cocostudio_timeline_RotationSkewFrame_class->finalize = js_cocostudio_timeline_RotationSkewFrame_finalize; + jsb_cocostudio_timeline_RotationSkewFrame_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_RotationSkewFrame_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_timeline_RotationSkewFrame_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocostudio_timeline_SkewFrame_prototype), + jsb_cocostudio_timeline_RotationSkewFrame_class, + js_cocos2dx_studio_RotationSkewFrame_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, "RotationSkewFrame", 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_cocostudio_timeline_RotationSkewFrame_class; + p->proto = jsb_cocostudio_timeline_RotationSkewFrame_prototype; + p->parentProto = jsb_cocostudio_timeline_SkewFrame_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_timeline_PositionFrame_class; +JSObject *jsb_cocostudio_timeline_PositionFrame_prototype; + +bool js_cocos2dx_studio_PositionFrame_getX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::PositionFrame* cobj = (cocostudio::timeline::PositionFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_PositionFrame_getX : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getX(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_PositionFrame_getX : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_PositionFrame_getY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::PositionFrame* cobj = (cocostudio::timeline::PositionFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_PositionFrame_getY : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getY(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_PositionFrame_getY : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_PositionFrame_setPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::PositionFrame* cobj = (cocostudio::timeline::PositionFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_PositionFrame_setPosition : Invalid Native Object"); + if (argc == 1) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_PositionFrame_setPosition : Error processing arguments"); + cobj->setPosition(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_PositionFrame_setPosition : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_PositionFrame_setX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::PositionFrame* cobj = (cocostudio::timeline::PositionFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_PositionFrame_setX : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_PositionFrame_setX : Error processing arguments"); + cobj->setX(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_PositionFrame_setX : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_PositionFrame_setY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::PositionFrame* cobj = (cocostudio::timeline::PositionFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_PositionFrame_setY : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_PositionFrame_setY : Error processing arguments"); + cobj->setY(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_PositionFrame_setY : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_PositionFrame_getPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::PositionFrame* cobj = (cocostudio::timeline::PositionFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_PositionFrame_getPosition : Invalid Native Object"); + if (argc == 0) { + cocos2d::Point ret = cobj->getPosition(); + jsval jsret = JSVAL_NULL; + jsret = ccpoint_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_PositionFrame_getPosition : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_PositionFrame_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::timeline::PositionFrame* ret = cocostudio::timeline::PositionFrame::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::PositionFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_PositionFrame_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_PositionFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::timeline::PositionFrame* cobj = new (std::nothrow) cocostudio::timeline::PositionFrame(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::timeline::PositionFrame"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocostudio_timeline_Frame_prototype; + +void js_cocostudio_timeline_PositionFrame_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (PositionFrame)", obj); +} + +void js_register_cocos2dx_studio_PositionFrame(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_timeline_PositionFrame_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_timeline_PositionFrame_class->name = "PositionFrame"; + jsb_cocostudio_timeline_PositionFrame_class->addProperty = JS_PropertyStub; + jsb_cocostudio_timeline_PositionFrame_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_timeline_PositionFrame_class->getProperty = JS_PropertyStub; + jsb_cocostudio_timeline_PositionFrame_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_timeline_PositionFrame_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_timeline_PositionFrame_class->resolve = JS_ResolveStub; + jsb_cocostudio_timeline_PositionFrame_class->convert = JS_ConvertStub; + jsb_cocostudio_timeline_PositionFrame_class->finalize = js_cocostudio_timeline_PositionFrame_finalize; + jsb_cocostudio_timeline_PositionFrame_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getX", js_cocos2dx_studio_PositionFrame_getX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getY", js_cocos2dx_studio_PositionFrame_getY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPosition", js_cocos2dx_studio_PositionFrame_setPosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setX", js_cocos2dx_studio_PositionFrame_setX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setY", js_cocos2dx_studio_PositionFrame_setY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPosition", js_cocos2dx_studio_PositionFrame_getPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_PositionFrame_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_timeline_PositionFrame_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + jsb_cocostudio_timeline_PositionFrame_class, + js_cocos2dx_studio_PositionFrame_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, "PositionFrame", 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_cocostudio_timeline_PositionFrame_class; + p->proto = jsb_cocostudio_timeline_PositionFrame_prototype; + p->parentProto = jsb_cocostudio_timeline_Frame_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_timeline_ScaleFrame_class; +JSObject *jsb_cocostudio_timeline_ScaleFrame_prototype; + +bool js_cocos2dx_studio_ScaleFrame_setScaleY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::ScaleFrame* cobj = (cocostudio::timeline::ScaleFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ScaleFrame_setScaleY : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ScaleFrame_setScaleY : Error processing arguments"); + cobj->setScaleY(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ScaleFrame_setScaleY : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ScaleFrame_setScaleX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::ScaleFrame* cobj = (cocostudio::timeline::ScaleFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ScaleFrame_setScaleX : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ScaleFrame_setScaleX : Error processing arguments"); + cobj->setScaleX(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ScaleFrame_setScaleX : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ScaleFrame_getScaleY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::ScaleFrame* cobj = (cocostudio::timeline::ScaleFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ScaleFrame_getScaleY : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getScaleY(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ScaleFrame_getScaleY : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ScaleFrame_getScaleX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::ScaleFrame* cobj = (cocostudio::timeline::ScaleFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ScaleFrame_getScaleX : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getScaleX(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ScaleFrame_getScaleX : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ScaleFrame_setScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::ScaleFrame* cobj = (cocostudio::timeline::ScaleFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ScaleFrame_setScale : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ScaleFrame_setScale : Error processing arguments"); + cobj->setScale(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ScaleFrame_setScale : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ScaleFrame_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::timeline::ScaleFrame* ret = cocostudio::timeline::ScaleFrame::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::ScaleFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_ScaleFrame_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_ScaleFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::timeline::ScaleFrame* cobj = new (std::nothrow) cocostudio::timeline::ScaleFrame(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::timeline::ScaleFrame"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocostudio_timeline_Frame_prototype; + +void js_cocostudio_timeline_ScaleFrame_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ScaleFrame)", obj); +} + +void js_register_cocos2dx_studio_ScaleFrame(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_timeline_ScaleFrame_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_timeline_ScaleFrame_class->name = "ScaleFrame"; + jsb_cocostudio_timeline_ScaleFrame_class->addProperty = JS_PropertyStub; + jsb_cocostudio_timeline_ScaleFrame_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_timeline_ScaleFrame_class->getProperty = JS_PropertyStub; + jsb_cocostudio_timeline_ScaleFrame_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_timeline_ScaleFrame_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_timeline_ScaleFrame_class->resolve = JS_ResolveStub; + jsb_cocostudio_timeline_ScaleFrame_class->convert = JS_ConvertStub; + jsb_cocostudio_timeline_ScaleFrame_class->finalize = js_cocostudio_timeline_ScaleFrame_finalize; + jsb_cocostudio_timeline_ScaleFrame_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setScaleY", js_cocos2dx_studio_ScaleFrame_setScaleY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setScaleX", js_cocos2dx_studio_ScaleFrame_setScaleX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getScaleY", js_cocos2dx_studio_ScaleFrame_getScaleY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getScaleX", js_cocos2dx_studio_ScaleFrame_getScaleX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setScale", js_cocos2dx_studio_ScaleFrame_setScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_ScaleFrame_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_timeline_ScaleFrame_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + jsb_cocostudio_timeline_ScaleFrame_class, + js_cocos2dx_studio_ScaleFrame_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, "ScaleFrame", 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_cocostudio_timeline_ScaleFrame_class; + p->proto = jsb_cocostudio_timeline_ScaleFrame_prototype; + p->parentProto = jsb_cocostudio_timeline_Frame_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_timeline_AnchorPointFrame_class; +JSObject *jsb_cocostudio_timeline_AnchorPointFrame_prototype; + +bool js_cocos2dx_studio_AnchorPointFrame_setAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::AnchorPointFrame* cobj = (cocostudio::timeline::AnchorPointFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_AnchorPointFrame_setAnchorPoint : Invalid Native Object"); + if (argc == 1) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_AnchorPointFrame_setAnchorPoint : Error processing arguments"); + cobj->setAnchorPoint(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_AnchorPointFrame_setAnchorPoint : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_AnchorPointFrame_getAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::AnchorPointFrame* cobj = (cocostudio::timeline::AnchorPointFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_AnchorPointFrame_getAnchorPoint : Invalid Native Object"); + if (argc == 0) { + cocos2d::Point ret = cobj->getAnchorPoint(); + jsval jsret = JSVAL_NULL; + jsret = ccpoint_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_AnchorPointFrame_getAnchorPoint : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_AnchorPointFrame_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::timeline::AnchorPointFrame* ret = cocostudio::timeline::AnchorPointFrame::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::AnchorPointFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_AnchorPointFrame_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_AnchorPointFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::timeline::AnchorPointFrame* cobj = new (std::nothrow) cocostudio::timeline::AnchorPointFrame(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::timeline::AnchorPointFrame"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocostudio_timeline_Frame_prototype; + +void js_cocostudio_timeline_AnchorPointFrame_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (AnchorPointFrame)", obj); +} + +void js_register_cocos2dx_studio_AnchorPointFrame(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_timeline_AnchorPointFrame_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_timeline_AnchorPointFrame_class->name = "AnchorPointFrame"; + jsb_cocostudio_timeline_AnchorPointFrame_class->addProperty = JS_PropertyStub; + jsb_cocostudio_timeline_AnchorPointFrame_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_timeline_AnchorPointFrame_class->getProperty = JS_PropertyStub; + jsb_cocostudio_timeline_AnchorPointFrame_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_timeline_AnchorPointFrame_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_timeline_AnchorPointFrame_class->resolve = JS_ResolveStub; + jsb_cocostudio_timeline_AnchorPointFrame_class->convert = JS_ConvertStub; + jsb_cocostudio_timeline_AnchorPointFrame_class->finalize = js_cocostudio_timeline_AnchorPointFrame_finalize; + jsb_cocostudio_timeline_AnchorPointFrame_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setAnchorPoint", js_cocos2dx_studio_AnchorPointFrame_setAnchorPoint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAnchorPoint", js_cocos2dx_studio_AnchorPointFrame_getAnchorPoint, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_AnchorPointFrame_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_timeline_AnchorPointFrame_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + jsb_cocostudio_timeline_AnchorPointFrame_class, + js_cocos2dx_studio_AnchorPointFrame_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, "AnchorPointFrame", 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_cocostudio_timeline_AnchorPointFrame_class; + p->proto = jsb_cocostudio_timeline_AnchorPointFrame_prototype; + p->parentProto = jsb_cocostudio_timeline_Frame_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_timeline_InnerActionFrame_class; +JSObject *jsb_cocostudio_timeline_InnerActionFrame_prototype; + +bool js_cocos2dx_studio_InnerActionFrame_getEndFrameIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::InnerActionFrame* cobj = (cocostudio::timeline::InnerActionFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InnerActionFrame_getEndFrameIndex : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getEndFrameIndex(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InnerActionFrame_getEndFrameIndex : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_InnerActionFrame_getStartFrameIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::InnerActionFrame* cobj = (cocostudio::timeline::InnerActionFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InnerActionFrame_getStartFrameIndex : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getStartFrameIndex(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InnerActionFrame_getStartFrameIndex : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_InnerActionFrame_getInnerActionType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::InnerActionFrame* cobj = (cocostudio::timeline::InnerActionFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InnerActionFrame_getInnerActionType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getInnerActionType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InnerActionFrame_getInnerActionType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_InnerActionFrame_setEndFrameIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::InnerActionFrame* cobj = (cocostudio::timeline::InnerActionFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InnerActionFrame_setEndFrameIndex : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_InnerActionFrame_setEndFrameIndex : Error processing arguments"); + cobj->setEndFrameIndex(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InnerActionFrame_setEndFrameIndex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_InnerActionFrame_setEnterWithName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::InnerActionFrame* cobj = (cocostudio::timeline::InnerActionFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InnerActionFrame_setEnterWithName : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_InnerActionFrame_setEnterWithName : Error processing arguments"); + cobj->setEnterWithName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InnerActionFrame_setEnterWithName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_InnerActionFrame_setSingleFrameIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::InnerActionFrame* cobj = (cocostudio::timeline::InnerActionFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InnerActionFrame_setSingleFrameIndex : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_InnerActionFrame_setSingleFrameIndex : Error processing arguments"); + cobj->setSingleFrameIndex(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InnerActionFrame_setSingleFrameIndex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_InnerActionFrame_setStartFrameIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::InnerActionFrame* cobj = (cocostudio::timeline::InnerActionFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InnerActionFrame_setStartFrameIndex : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_InnerActionFrame_setStartFrameIndex : Error processing arguments"); + cobj->setStartFrameIndex(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InnerActionFrame_setStartFrameIndex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_InnerActionFrame_getSingleFrameIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::InnerActionFrame* cobj = (cocostudio::timeline::InnerActionFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InnerActionFrame_getSingleFrameIndex : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getSingleFrameIndex(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InnerActionFrame_getSingleFrameIndex : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_InnerActionFrame_setInnerActionType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::InnerActionFrame* cobj = (cocostudio::timeline::InnerActionFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InnerActionFrame_setInnerActionType : Invalid Native Object"); + if (argc == 1) { + cocostudio::timeline::InnerActionType arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_InnerActionFrame_setInnerActionType : Error processing arguments"); + cobj->setInnerActionType(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InnerActionFrame_setInnerActionType : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_InnerActionFrame_setAnimationName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::InnerActionFrame* cobj = (cocostudio::timeline::InnerActionFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_InnerActionFrame_setAnimationName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_InnerActionFrame_setAnimationName : Error processing arguments"); + cobj->setAnimationName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_InnerActionFrame_setAnimationName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_InnerActionFrame_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::timeline::InnerActionFrame* ret = cocostudio::timeline::InnerActionFrame::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::InnerActionFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_InnerActionFrame_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_InnerActionFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::timeline::InnerActionFrame* cobj = new (std::nothrow) cocostudio::timeline::InnerActionFrame(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::timeline::InnerActionFrame"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocostudio_timeline_Frame_prototype; + +void js_cocostudio_timeline_InnerActionFrame_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (InnerActionFrame)", obj); +} + +void js_register_cocos2dx_studio_InnerActionFrame(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_timeline_InnerActionFrame_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_timeline_InnerActionFrame_class->name = "InnerActionFrame"; + jsb_cocostudio_timeline_InnerActionFrame_class->addProperty = JS_PropertyStub; + jsb_cocostudio_timeline_InnerActionFrame_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_timeline_InnerActionFrame_class->getProperty = JS_PropertyStub; + jsb_cocostudio_timeline_InnerActionFrame_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_timeline_InnerActionFrame_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_timeline_InnerActionFrame_class->resolve = JS_ResolveStub; + jsb_cocostudio_timeline_InnerActionFrame_class->convert = JS_ConvertStub; + jsb_cocostudio_timeline_InnerActionFrame_class->finalize = js_cocostudio_timeline_InnerActionFrame_finalize; + jsb_cocostudio_timeline_InnerActionFrame_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getEndFrameIndex", js_cocos2dx_studio_InnerActionFrame_getEndFrameIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStartFrameIndex", js_cocos2dx_studio_InnerActionFrame_getStartFrameIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInnerActionType", js_cocos2dx_studio_InnerActionFrame_getInnerActionType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEndFrameIndex", js_cocos2dx_studio_InnerActionFrame_setEndFrameIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEnterWithName", js_cocos2dx_studio_InnerActionFrame_setEnterWithName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSingleFrameIndex", js_cocos2dx_studio_InnerActionFrame_setSingleFrameIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setStartFrameIndex", js_cocos2dx_studio_InnerActionFrame_setStartFrameIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSingleFrameIndex", js_cocos2dx_studio_InnerActionFrame_getSingleFrameIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setInnerActionType", js_cocos2dx_studio_InnerActionFrame_setInnerActionType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAnimationName", js_cocos2dx_studio_InnerActionFrame_setAnimationName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_InnerActionFrame_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_timeline_InnerActionFrame_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + jsb_cocostudio_timeline_InnerActionFrame_class, + js_cocos2dx_studio_InnerActionFrame_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, "InnerActionFrame", 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_cocostudio_timeline_InnerActionFrame_class; + p->proto = jsb_cocostudio_timeline_InnerActionFrame_prototype; + p->parentProto = jsb_cocostudio_timeline_Frame_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_timeline_ColorFrame_class; +JSObject *jsb_cocostudio_timeline_ColorFrame_prototype; + +bool js_cocos2dx_studio_ColorFrame_getColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::ColorFrame* cobj = (cocostudio::timeline::ColorFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ColorFrame_getColor : Invalid Native Object"); + if (argc == 0) { + cocos2d::Color3B ret = cobj->getColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor3b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ColorFrame_getColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ColorFrame_setColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::ColorFrame* cobj = (cocostudio::timeline::ColorFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ColorFrame_setColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color3B arg0; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ColorFrame_setColor : Error processing arguments"); + cobj->setColor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ColorFrame_setColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ColorFrame_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::timeline::ColorFrame* ret = cocostudio::timeline::ColorFrame::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::ColorFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_ColorFrame_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_ColorFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::timeline::ColorFrame* cobj = new (std::nothrow) cocostudio::timeline::ColorFrame(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::timeline::ColorFrame"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocostudio_timeline_Frame_prototype; + +void js_cocostudio_timeline_ColorFrame_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ColorFrame)", obj); +} + +void js_register_cocos2dx_studio_ColorFrame(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_timeline_ColorFrame_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_timeline_ColorFrame_class->name = "ColorFrame"; + jsb_cocostudio_timeline_ColorFrame_class->addProperty = JS_PropertyStub; + jsb_cocostudio_timeline_ColorFrame_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_timeline_ColorFrame_class->getProperty = JS_PropertyStub; + jsb_cocostudio_timeline_ColorFrame_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_timeline_ColorFrame_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_timeline_ColorFrame_class->resolve = JS_ResolveStub; + jsb_cocostudio_timeline_ColorFrame_class->convert = JS_ConvertStub; + jsb_cocostudio_timeline_ColorFrame_class->finalize = js_cocostudio_timeline_ColorFrame_finalize; + jsb_cocostudio_timeline_ColorFrame_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getColor", js_cocos2dx_studio_ColorFrame_getColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setColor", js_cocos2dx_studio_ColorFrame_setColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_ColorFrame_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_timeline_ColorFrame_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + jsb_cocostudio_timeline_ColorFrame_class, + js_cocos2dx_studio_ColorFrame_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, "ColorFrame", 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_cocostudio_timeline_ColorFrame_class; + p->proto = jsb_cocostudio_timeline_ColorFrame_prototype; + p->parentProto = jsb_cocostudio_timeline_Frame_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_timeline_AlphaFrame_class; +JSObject *jsb_cocostudio_timeline_AlphaFrame_prototype; + +bool js_cocos2dx_studio_AlphaFrame_getAlpha(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::AlphaFrame* cobj = (cocostudio::timeline::AlphaFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_AlphaFrame_getAlpha : Invalid Native Object"); + if (argc == 0) { + uint16_t ret = cobj->getAlpha(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_AlphaFrame_getAlpha : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_AlphaFrame_setAlpha(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::AlphaFrame* cobj = (cocostudio::timeline::AlphaFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_AlphaFrame_setAlpha : Invalid Native Object"); + if (argc == 1) { + uint16_t arg0; + ok &= jsval_to_uint16(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_AlphaFrame_setAlpha : Error processing arguments"); + cobj->setAlpha(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_AlphaFrame_setAlpha : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_AlphaFrame_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::timeline::AlphaFrame* ret = cocostudio::timeline::AlphaFrame::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::AlphaFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_AlphaFrame_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_AlphaFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::timeline::AlphaFrame* cobj = new (std::nothrow) cocostudio::timeline::AlphaFrame(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::timeline::AlphaFrame"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocostudio_timeline_Frame_prototype; + +void js_cocostudio_timeline_AlphaFrame_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (AlphaFrame)", obj); +} + +void js_register_cocos2dx_studio_AlphaFrame(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_timeline_AlphaFrame_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_timeline_AlphaFrame_class->name = "AlphaFrame"; + jsb_cocostudio_timeline_AlphaFrame_class->addProperty = JS_PropertyStub; + jsb_cocostudio_timeline_AlphaFrame_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_timeline_AlphaFrame_class->getProperty = JS_PropertyStub; + jsb_cocostudio_timeline_AlphaFrame_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_timeline_AlphaFrame_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_timeline_AlphaFrame_class->resolve = JS_ResolveStub; + jsb_cocostudio_timeline_AlphaFrame_class->convert = JS_ConvertStub; + jsb_cocostudio_timeline_AlphaFrame_class->finalize = js_cocostudio_timeline_AlphaFrame_finalize; + jsb_cocostudio_timeline_AlphaFrame_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getAlpha", js_cocos2dx_studio_AlphaFrame_getAlpha, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAlpha", js_cocos2dx_studio_AlphaFrame_setAlpha, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_AlphaFrame_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_timeline_AlphaFrame_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + jsb_cocostudio_timeline_AlphaFrame_class, + js_cocos2dx_studio_AlphaFrame_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, "AlphaFrame", 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_cocostudio_timeline_AlphaFrame_class; + p->proto = jsb_cocostudio_timeline_AlphaFrame_prototype; + p->parentProto = jsb_cocostudio_timeline_Frame_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_timeline_EventFrame_class; +JSObject *jsb_cocostudio_timeline_EventFrame_prototype; + +bool js_cocos2dx_studio_EventFrame_setEvent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::EventFrame* cobj = (cocostudio::timeline::EventFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_EventFrame_setEvent : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_EventFrame_setEvent : Error processing arguments"); + cobj->setEvent(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_EventFrame_setEvent : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_EventFrame_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::EventFrame* cobj = (cocostudio::timeline::EventFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_EventFrame_init : Invalid Native Object"); + if (argc == 0) { + cobj->init(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_EventFrame_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_EventFrame_getEvent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::EventFrame* cobj = (cocostudio::timeline::EventFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_EventFrame_getEvent : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getEvent(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_EventFrame_getEvent : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_EventFrame_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::timeline::EventFrame* ret = cocostudio::timeline::EventFrame::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::EventFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_EventFrame_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_EventFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::timeline::EventFrame* cobj = new (std::nothrow) cocostudio::timeline::EventFrame(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::timeline::EventFrame"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocostudio_timeline_Frame_prototype; + +void js_cocostudio_timeline_EventFrame_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EventFrame)", obj); +} + +void js_register_cocos2dx_studio_EventFrame(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_timeline_EventFrame_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_timeline_EventFrame_class->name = "EventFrame"; + jsb_cocostudio_timeline_EventFrame_class->addProperty = JS_PropertyStub; + jsb_cocostudio_timeline_EventFrame_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_timeline_EventFrame_class->getProperty = JS_PropertyStub; + jsb_cocostudio_timeline_EventFrame_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_timeline_EventFrame_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_timeline_EventFrame_class->resolve = JS_ResolveStub; + jsb_cocostudio_timeline_EventFrame_class->convert = JS_ConvertStub; + jsb_cocostudio_timeline_EventFrame_class->finalize = js_cocostudio_timeline_EventFrame_finalize; + jsb_cocostudio_timeline_EventFrame_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setEvent", js_cocos2dx_studio_EventFrame_setEvent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_studio_EventFrame_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEvent", js_cocos2dx_studio_EventFrame_getEvent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_EventFrame_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_timeline_EventFrame_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + jsb_cocostudio_timeline_EventFrame_class, + js_cocos2dx_studio_EventFrame_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, "EventFrame", 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_cocostudio_timeline_EventFrame_class; + p->proto = jsb_cocostudio_timeline_EventFrame_prototype; + p->parentProto = jsb_cocostudio_timeline_Frame_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_timeline_ZOrderFrame_class; +JSObject *jsb_cocostudio_timeline_ZOrderFrame_prototype; + +bool js_cocos2dx_studio_ZOrderFrame_getZOrder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::ZOrderFrame* cobj = (cocostudio::timeline::ZOrderFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ZOrderFrame_getZOrder : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getZOrder(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ZOrderFrame_getZOrder : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ZOrderFrame_setZOrder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::ZOrderFrame* cobj = (cocostudio::timeline::ZOrderFrame *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ZOrderFrame_setZOrder : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ZOrderFrame_setZOrder : Error processing arguments"); + cobj->setZOrder(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ZOrderFrame_setZOrder : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ZOrderFrame_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::timeline::ZOrderFrame* ret = cocostudio::timeline::ZOrderFrame::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::ZOrderFrame*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_ZOrderFrame_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_ZOrderFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::timeline::ZOrderFrame* cobj = new (std::nothrow) cocostudio::timeline::ZOrderFrame(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::timeline::ZOrderFrame"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocostudio_timeline_Frame_prototype; + +void js_cocostudio_timeline_ZOrderFrame_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ZOrderFrame)", obj); +} + +void js_register_cocos2dx_studio_ZOrderFrame(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_timeline_ZOrderFrame_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_timeline_ZOrderFrame_class->name = "ZOrderFrame"; + jsb_cocostudio_timeline_ZOrderFrame_class->addProperty = JS_PropertyStub; + jsb_cocostudio_timeline_ZOrderFrame_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_timeline_ZOrderFrame_class->getProperty = JS_PropertyStub; + jsb_cocostudio_timeline_ZOrderFrame_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_timeline_ZOrderFrame_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_timeline_ZOrderFrame_class->resolve = JS_ResolveStub; + jsb_cocostudio_timeline_ZOrderFrame_class->convert = JS_ConvertStub; + jsb_cocostudio_timeline_ZOrderFrame_class->finalize = js_cocostudio_timeline_ZOrderFrame_finalize; + jsb_cocostudio_timeline_ZOrderFrame_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getZOrder", js_cocos2dx_studio_ZOrderFrame_getZOrder, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setZOrder", js_cocos2dx_studio_ZOrderFrame_setZOrder, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_ZOrderFrame_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_timeline_ZOrderFrame_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocostudio_timeline_Frame_prototype), + jsb_cocostudio_timeline_ZOrderFrame_class, + js_cocos2dx_studio_ZOrderFrame_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, "ZOrderFrame", 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_cocostudio_timeline_ZOrderFrame_class; + p->proto = jsb_cocostudio_timeline_ZOrderFrame_prototype; + p->parentProto = jsb_cocostudio_timeline_Frame_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_timeline_Timeline_class; +JSObject *jsb_cocostudio_timeline_Timeline_prototype; + +bool js_cocos2dx_studio_Timeline_clone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Timeline* cobj = (cocostudio::timeline::Timeline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Timeline_clone : Invalid Native Object"); + if (argc == 0) { + cocostudio::timeline::Timeline* ret = cobj->clone(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::Timeline*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Timeline_clone : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Timeline_gotoFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Timeline* cobj = (cocostudio::timeline::Timeline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Timeline_gotoFrame : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Timeline_gotoFrame : Error processing arguments"); + cobj->gotoFrame(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Timeline_gotoFrame : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Timeline_setNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Timeline* cobj = (cocostudio::timeline::Timeline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Timeline_setNode : Invalid Native Object"); + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Timeline_setNode : Error processing arguments"); + cobj->setNode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Timeline_setNode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Timeline_getActionTimeline(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Timeline* cobj = (cocostudio::timeline::Timeline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Timeline_getActionTimeline : Invalid Native Object"); + if (argc == 0) { + cocostudio::timeline::ActionTimeline* ret = cobj->getActionTimeline(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Timeline_getActionTimeline : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Timeline_insertFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Timeline* cobj = (cocostudio::timeline::Timeline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Timeline_insertFrame : Invalid Native Object"); + if (argc == 2) { + cocostudio::timeline::Frame* arg0; + int arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::timeline::Frame*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Timeline_insertFrame : Error processing arguments"); + cobj->insertFrame(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Timeline_insertFrame : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_Timeline_setActionTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Timeline* cobj = (cocostudio::timeline::Timeline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Timeline_setActionTag : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Timeline_setActionTag : Error processing arguments"); + cobj->setActionTag(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Timeline_setActionTag : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Timeline_addFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Timeline* cobj = (cocostudio::timeline::Timeline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Timeline_addFrame : Invalid Native Object"); + if (argc == 1) { + cocostudio::timeline::Frame* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::timeline::Frame*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Timeline_addFrame : Error processing arguments"); + cobj->addFrame(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Timeline_addFrame : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Timeline_getFrames(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Timeline* cobj = (cocostudio::timeline::Timeline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Timeline_getFrames : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vector& ret = cobj->getFrames(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Timeline_getFrames : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Timeline_getActionTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Timeline* cobj = (cocostudio::timeline::Timeline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Timeline_getActionTag : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getActionTag(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Timeline_getActionTag : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Timeline_getNode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Timeline* cobj = (cocostudio::timeline::Timeline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Timeline_getNode : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getNode(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Timeline_getNode : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_Timeline_removeFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Timeline* cobj = (cocostudio::timeline::Timeline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Timeline_removeFrame : Invalid Native Object"); + if (argc == 1) { + cocostudio::timeline::Frame* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::timeline::Frame*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Timeline_removeFrame : Error processing arguments"); + cobj->removeFrame(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Timeline_removeFrame : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Timeline_setActionTimeline(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Timeline* cobj = (cocostudio::timeline::Timeline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Timeline_setActionTimeline : Invalid Native Object"); + if (argc == 1) { + cocostudio::timeline::ActionTimeline* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::timeline::ActionTimeline*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Timeline_setActionTimeline : Error processing arguments"); + cobj->setActionTimeline(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Timeline_setActionTimeline : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Timeline_stepToFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Timeline* cobj = (cocostudio::timeline::Timeline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_Timeline_stepToFrame : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Timeline_stepToFrame : Error processing arguments"); + cobj->stepToFrame(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_Timeline_stepToFrame : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_Timeline_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::timeline::Timeline* ret = cocostudio::timeline::Timeline::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::Timeline*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_Timeline_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_Timeline_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::timeline::Timeline* cobj = new (std::nothrow) cocostudio::timeline::Timeline(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::timeline::Timeline"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocostudio_timeline_Timeline_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Timeline)", obj); +} + +void js_register_cocos2dx_studio_Timeline(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_timeline_Timeline_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_timeline_Timeline_class->name = "Timeline"; + jsb_cocostudio_timeline_Timeline_class->addProperty = JS_PropertyStub; + jsb_cocostudio_timeline_Timeline_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_timeline_Timeline_class->getProperty = JS_PropertyStub; + jsb_cocostudio_timeline_Timeline_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_timeline_Timeline_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_timeline_Timeline_class->resolve = JS_ResolveStub; + jsb_cocostudio_timeline_Timeline_class->convert = JS_ConvertStub; + jsb_cocostudio_timeline_Timeline_class->finalize = js_cocostudio_timeline_Timeline_finalize; + jsb_cocostudio_timeline_Timeline_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("clone", js_cocos2dx_studio_Timeline_clone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("gotoFrame", js_cocos2dx_studio_Timeline_gotoFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setNode", js_cocos2dx_studio_Timeline_setNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getActionTimeline", js_cocos2dx_studio_Timeline_getActionTimeline, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("insertFrame", js_cocos2dx_studio_Timeline_insertFrame, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setActionTag", js_cocos2dx_studio_Timeline_setActionTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addFrame", js_cocos2dx_studio_Timeline_addFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFrames", js_cocos2dx_studio_Timeline_getFrames, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getActionTag", js_cocos2dx_studio_Timeline_getActionTag, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNode", js_cocos2dx_studio_Timeline_getNode, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeFrame", js_cocos2dx_studio_Timeline_removeFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setActionTimeline", js_cocos2dx_studio_Timeline_setActionTimeline, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("stepToFrame", js_cocos2dx_studio_Timeline_stepToFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_Timeline_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_timeline_Timeline_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocostudio_timeline_Timeline_class, + js_cocos2dx_studio_Timeline_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, "Timeline", 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_cocostudio_timeline_Timeline_class; + p->proto = jsb_cocostudio_timeline_Timeline_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_timeline_ActionTimelineData_class; +JSObject *jsb_cocostudio_timeline_ActionTimelineData_prototype; + +bool js_cocos2dx_studio_ActionTimelineData_setActionTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::ActionTimelineData* cobj = (cocostudio::timeline::ActionTimelineData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimelineData_setActionTag : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimelineData_setActionTag : Error processing arguments"); + cobj->setActionTag(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimelineData_setActionTag : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ActionTimelineData_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::ActionTimelineData* cobj = (cocostudio::timeline::ActionTimelineData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimelineData_init : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimelineData_init : Error processing arguments"); + bool ret = cobj->init(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimelineData_init : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ActionTimelineData_getActionTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::ActionTimelineData* cobj = (cocostudio::timeline::ActionTimelineData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimelineData_getActionTag : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getActionTag(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimelineData_getActionTag : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ActionTimelineData_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimelineData_create : Error processing arguments"); + cocostudio::timeline::ActionTimelineData* ret = cocostudio::timeline::ActionTimelineData::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::ActionTimelineData*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimelineData_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_ActionTimelineData_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::timeline::ActionTimelineData* cobj = new (std::nothrow) cocostudio::timeline::ActionTimelineData(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::timeline::ActionTimelineData"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocostudio_timeline_ActionTimelineData_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ActionTimelineData)", obj); +} + +void js_register_cocos2dx_studio_ActionTimelineData(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_timeline_ActionTimelineData_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_timeline_ActionTimelineData_class->name = "ActionTimelineData"; + jsb_cocostudio_timeline_ActionTimelineData_class->addProperty = JS_PropertyStub; + jsb_cocostudio_timeline_ActionTimelineData_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_timeline_ActionTimelineData_class->getProperty = JS_PropertyStub; + jsb_cocostudio_timeline_ActionTimelineData_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_timeline_ActionTimelineData_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_timeline_ActionTimelineData_class->resolve = JS_ResolveStub; + jsb_cocostudio_timeline_ActionTimelineData_class->convert = JS_ConvertStub; + jsb_cocostudio_timeline_ActionTimelineData_class->finalize = js_cocostudio_timeline_ActionTimelineData_finalize; + jsb_cocostudio_timeline_ActionTimelineData_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setActionTag", js_cocos2dx_studio_ActionTimelineData_setActionTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_studio_ActionTimelineData_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getActionTag", js_cocos2dx_studio_ActionTimelineData_getActionTag, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_ActionTimelineData_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_timeline_ActionTimelineData_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocostudio_timeline_ActionTimelineData_class, + js_cocos2dx_studio_ActionTimelineData_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, "ActionTimelineData", 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_cocostudio_timeline_ActionTimelineData_class; + p->proto = jsb_cocostudio_timeline_ActionTimelineData_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_timeline_ActionTimeline_class; +JSObject *jsb_cocostudio_timeline_ActionTimeline_prototype; + +bool js_cocos2dx_studio_ActionTimeline_setFrameEventCallFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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 { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + auto lambda = [=](cocostudio::timeline::Frame* larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + JS::RootedValue rval(cx); + 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); + args.rval().setUndefined(); + 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_addTimeline(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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 (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getCurrentFrame : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getCurrentFrame(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_getCurrentFrame : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ActionTimeline_getStartFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getStartFrame : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getStartFrame(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_getStartFrame : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ActionTimeline_pause(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_pause : Invalid Native Object"); + if (argc == 0) { + cobj->pause(); + args.rval().setUndefined(); + return true; + } + + 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_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + 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_removeTimeline(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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"); + if (argc == 1) { + cocostudio::timeline::Timeline* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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); + args.rval().setUndefined(); + return true; + } + + 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_setLastFrameCallFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setLastFrameCallFunc : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + auto lambda = [=]() -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + JS::RootedValue rval(cx); + 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); + args.rval().setUndefined(); + return true; + } + + 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_IsAnimationInfoExists(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_IsAnimationInfoExists : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_IsAnimationInfoExists : Error processing arguments"); + bool ret = cobj->IsAnimationInfoExists(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_IsAnimationInfoExists : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ActionTimeline_getTimelines(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(jsret); + return true; + } + + 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_play(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_play : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + bool arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_play : Error processing arguments"); + cobj->play(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_play : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_studio_ActionTimeline_getAnimationInfo(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getAnimationInfo : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_getAnimationInfo : Error processing arguments"); + cocostudio::timeline::AnimationInfo ret = cobj->getAnimationInfo(arg0); + jsval jsret = JSVAL_NULL; + jsret = animationInfo_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_getAnimationInfo : 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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(); + args.rval().setUndefined(); + 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_removeAnimationInfo(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_removeAnimationInfo : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_removeAnimationInfo : Error processing arguments"); + cobj->removeAnimationInfo(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_removeAnimationInfo : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ActionTimeline_getTimeSpeed(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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"); + if (argc == 0) { + double ret = cobj->getTimeSpeed(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + 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_addAnimationInfo(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_addAnimationInfo : Invalid Native Object"); + if (argc == 1) { + cocostudio::timeline::AnimationInfo arg0; + ok &= jsval_to_animationInfo(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_addAnimationInfo : Error processing arguments"); + cobj->addAnimationInfo(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_addAnimationInfo : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ActionTimeline_getDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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"); + if (argc == 0) { + int ret = cobj->getDuration(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_gotoFrameAndPause : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_gotoFrameAndPause : Error processing arguments"); + cobj->gotoFrameAndPause(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_gotoFrameAndPause : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ActionTimeline_isPlaying(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isPlaying : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isPlaying(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_isPlaying : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ActionTimeline_gotoFrameAndPlay(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocostudio::timeline::ActionTimeline* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_gotoFrameAndPlay : Invalid Native Object"); + do { + if (argc == 2) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + bool arg1; + arg1 = JS::ToBoolean(args.get(1)); + cobj->gotoFrameAndPlay(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + cobj->gotoFrameAndPlay(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 3) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + bool arg2; + arg2 = JS::ToBoolean(args.get(2)); + cobj->gotoFrameAndPlay(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 4) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + int arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + bool arg3; + arg3 = JS::ToBoolean(args.get(3)); + cobj->gotoFrameAndPlay(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_gotoFrameAndPlay : wrong number of arguments"); + return false; +} +bool js_cocos2dx_studio_ActionTimeline_clearFrameEventCallFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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"); + if (argc == 0) { + cobj->clearFrameEventCallFunc(); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_setTimeSpeed : Error processing arguments"); + cobj->setTimeSpeed(arg0); + args.rval().setUndefined(); + return true; + } + + 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_clearLastFrameCallFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_clearLastFrameCallFunc : Invalid Native Object"); + if (argc == 0) { + cobj->clearLastFrameCallFunc(); + args.rval().setUndefined(); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_setDuration : Error processing arguments"); + cobj->setDuration(arg0); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_setCurrentFrame : Error processing arguments"); + cobj->setCurrentFrame(arg0); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::timeline::ActionTimeline* ret = cocostudio::timeline::ActionTimeline::create(); + 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); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_ActionTimeline_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::timeline::ActionTimeline* cobj = new (std::nothrow) cocostudio::timeline::ActionTimeline(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::timeline::ActionTimeline"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Action_prototype; + +void js_cocostudio_timeline_ActionTimeline_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ActionTimeline)", obj); +} + +void js_register_cocos2dx_studio_ActionTimeline(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_timeline_ActionTimeline_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_timeline_ActionTimeline_class->name = "ActionTimeline"; + jsb_cocostudio_timeline_ActionTimeline_class->addProperty = JS_PropertyStub; + jsb_cocostudio_timeline_ActionTimeline_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_timeline_ActionTimeline_class->getProperty = JS_PropertyStub; + jsb_cocostudio_timeline_ActionTimeline_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_timeline_ActionTimeline_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_timeline_ActionTimeline_class->resolve = JS_ResolveStub; + jsb_cocostudio_timeline_ActionTimeline_class->convert = JS_ConvertStub; + jsb_cocostudio_timeline_ActionTimeline_class->finalize = js_cocostudio_timeline_ActionTimeline_finalize; + jsb_cocostudio_timeline_ActionTimeline_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + 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("init", js_cocos2dx_studio_ActionTimeline_init, 0, 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("isAnimationInfoExists", js_cocos2dx_studio_ActionTimeline_IsAnimationInfoExists, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTimelines", js_cocos2dx_studio_ActionTimeline_getTimelines, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("play", js_cocos2dx_studio_ActionTimeline_play, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAnimationInfo", js_cocos2dx_studio_ActionTimeline_getAnimationInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resume", js_cocos2dx_studio_ActionTimeline_resume, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAnimationInfo", js_cocos2dx_studio_ActionTimeline_removeAnimationInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTimeSpeed", js_cocos2dx_studio_ActionTimeline_getTimeSpeed, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addAnimationInfo", js_cocos2dx_studio_ActionTimeline_addAnimationInfo, 1, 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("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 + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_ActionTimeline_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_timeline_ActionTimeline_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Action_prototype), + jsb_cocostudio_timeline_ActionTimeline_class, + js_cocos2dx_studio_ActionTimeline_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, "ActionTimeline", 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_cocostudio_timeline_ActionTimeline_class; + p->proto = jsb_cocostudio_timeline_ActionTimeline_prototype; + p->parentProto = jsb_cocos2d_Action_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocostudio_ObjectExtensionData_class; +JSObject *jsb_cocostudio_ObjectExtensionData_prototype; + +bool js_cocos2dx_studio_ObjectExtensionData_setActionTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ObjectExtensionData* cobj = (cocostudio::ObjectExtensionData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ObjectExtensionData_setActionTag : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ObjectExtensionData_setActionTag : Error processing arguments"); + cobj->setActionTag(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ObjectExtensionData_setActionTag : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ObjectExtensionData_setCustomProperty(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ObjectExtensionData* cobj = (cocostudio::ObjectExtensionData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ObjectExtensionData_setCustomProperty : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ObjectExtensionData_setCustomProperty : Error processing arguments"); + cobj->setCustomProperty(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ObjectExtensionData_setCustomProperty : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ObjectExtensionData_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ObjectExtensionData* cobj = (cocostudio::ObjectExtensionData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ObjectExtensionData_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ObjectExtensionData_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ObjectExtensionData_getCustomProperty(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ObjectExtensionData* cobj = (cocostudio::ObjectExtensionData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ObjectExtensionData_getCustomProperty : Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getCustomProperty(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ObjectExtensionData_getCustomProperty : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ObjectExtensionData_getActionTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ObjectExtensionData* cobj = (cocostudio::ObjectExtensionData *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ObjectExtensionData_getActionTag : Invalid Native Object"); + if (argc == 0) { + const int ret = cobj->getActionTag(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ObjectExtensionData_getActionTag : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ObjectExtensionData_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocostudio::ObjectExtensionData* ret = cocostudio::ObjectExtensionData::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ObjectExtensionData*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_ObjectExtensionData_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_ObjectExtensionData_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocostudio::ObjectExtensionData* cobj = new (std::nothrow) cocostudio::ObjectExtensionData(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocostudio::ObjectExtensionData"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocostudio_ObjectExtensionData_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ObjectExtensionData)", obj); +} + +void js_register_cocos2dx_studio_ObjectExtensionData(JSContext *cx, JS::HandleObject global) { + jsb_cocostudio_ObjectExtensionData_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocostudio_ObjectExtensionData_class->name = "ObjectExtensionData"; + jsb_cocostudio_ObjectExtensionData_class->addProperty = JS_PropertyStub; + jsb_cocostudio_ObjectExtensionData_class->delProperty = JS_DeletePropertyStub; + jsb_cocostudio_ObjectExtensionData_class->getProperty = JS_PropertyStub; + jsb_cocostudio_ObjectExtensionData_class->setProperty = JS_StrictPropertyStub; + jsb_cocostudio_ObjectExtensionData_class->enumerate = JS_EnumerateStub; + jsb_cocostudio_ObjectExtensionData_class->resolve = JS_ResolveStub; + jsb_cocostudio_ObjectExtensionData_class->convert = JS_ConvertStub; + jsb_cocostudio_ObjectExtensionData_class->finalize = js_cocostudio_ObjectExtensionData_finalize; + jsb_cocostudio_ObjectExtensionData_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setActionTag", js_cocos2dx_studio_ObjectExtensionData_setActionTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCustomProperty", js_cocos2dx_studio_ObjectExtensionData_setCustomProperty, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_studio_ObjectExtensionData_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCustomProperty", js_cocos2dx_studio_ObjectExtensionData_getCustomProperty, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getActionTag", js_cocos2dx_studio_ObjectExtensionData_getActionTag, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_studio_ObjectExtensionData_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocostudio_ObjectExtensionData_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocostudio_ObjectExtensionData_class, + js_cocos2dx_studio_ObjectExtensionData_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, "ObjectExtensionData", 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_cocostudio_ObjectExtensionData_class; + p->proto = jsb_cocostudio_ObjectExtensionData_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj) { + // Get the ns + JS::RootedObject ns(cx); + get_or_create_js_obj(cx, obj, "ccs", &ns); + + js_register_cocos2dx_studio_ObjectExtensionData(cx, ns); + js_register_cocos2dx_studio_Frame(cx, ns); + js_register_cocos2dx_studio_ScaleFrame(cx, ns); + js_register_cocos2dx_studio_ProcessBase(cx, ns); + js_register_cocos2dx_studio_Tween(cx, ns); + js_register_cocos2dx_studio_ContourData(cx, ns); + js_register_cocos2dx_studio_ComAudio(cx, ns); + js_register_cocos2dx_studio_ActionTimeline(cx, ns); + js_register_cocos2dx_studio_InnerActionFrame(cx, ns); + js_register_cocos2dx_studio_ActionTimelineData(cx, ns); + js_register_cocos2dx_studio_MovementData(cx, ns); + js_register_cocos2dx_studio_ArmatureDataManager(cx, ns); + js_register_cocos2dx_studio_ColorFrame(cx, ns); + js_register_cocos2dx_studio_ZOrderFrame(cx, ns); + js_register_cocos2dx_studio_Timeline(cx, ns); + js_register_cocos2dx_studio_ColliderBody(cx, ns); + js_register_cocos2dx_studio_InputDelegate(cx, ns); + js_register_cocos2dx_studio_ComController(cx, ns); + js_register_cocos2dx_studio_DecorativeDisplay(cx, ns); + js_register_cocos2dx_studio_SkewFrame(cx, ns); + js_register_cocos2dx_studio_RotationSkewFrame(cx, ns); + js_register_cocos2dx_studio_ColliderFilter(cx, ns); + js_register_cocos2dx_studio_VisibleFrame(cx, ns); + js_register_cocos2dx_studio_PositionFrame(cx, ns); + js_register_cocos2dx_studio_RotationFrame(cx, ns); + js_register_cocos2dx_studio_ColliderDetector(cx, ns); + js_register_cocos2dx_studio_BatchNode(cx, ns); + js_register_cocos2dx_studio_ActionObject(cx, ns); + js_register_cocos2dx_studio_Skin(cx, ns); + js_register_cocos2dx_studio_EventFrame(cx, ns); + js_register_cocos2dx_studio_ComRender(cx, ns); + js_register_cocos2dx_studio_DisplayManager(cx, ns); + js_register_cocos2dx_studio_ArmatureAnimation(cx, ns); + js_register_cocos2dx_studio_Armature(cx, ns); + js_register_cocos2dx_studio_ActionManagerEx(cx, ns); + js_register_cocos2dx_studio_Bone(cx, ns); + js_register_cocos2dx_studio_ComAttribute(cx, ns); + js_register_cocos2dx_studio_TextureData(cx, ns); + js_register_cocos2dx_studio_AlphaFrame(cx, ns); + js_register_cocos2dx_studio_AnimationData(cx, ns); + js_register_cocos2dx_studio_AnchorPointFrame(cx, ns); + js_register_cocos2dx_studio_TextureFrame(cx, ns); + js_register_cocos2dx_studio_BaseData(cx, ns); +} + diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.hpp new file mode 100644 index 0000000000..1b621863f3 --- /dev/null +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.hpp @@ -0,0 +1,758 @@ +#ifndef __cocos2dx_studio_h__ +#define __cocos2dx_studio_h__ + +#include "jsapi.h" +#include "jsfriendapi.h" + + +extern JSClass *jsb_cocostudio_ActionObject_class; +extern JSObject *jsb_cocostudio_ActionObject_prototype; + +bool js_cocos2dx_studio_ActionObject_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_ActionObject_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_ActionObject(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_ActionObject_setCurrentTime(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionObject_pause(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionObject_setName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionObject_setUnitTime(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionObject_getTotalTime(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionObject_getName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionObject_stop(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionObject_play(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionObject_getCurrentTime(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionObject_removeActionNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionObject_getLoop(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionObject_initWithBinary(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionObject_addActionNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionObject_getUnitTime(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionObject_isPlaying(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionObject_updateToFrameByTime(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionObject_setLoop(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionObject_simulationActionUpdate(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionObject_ActionObject(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_ActionManagerEx_class; +extern JSObject *jsb_cocostudio_ActionManagerEx_prototype; + +bool js_cocos2dx_studio_ActionManagerEx_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_ActionManagerEx_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_ActionManagerEx(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +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); + +extern JSClass *jsb_cocostudio_BaseData_class; +extern JSObject *jsb_cocostudio_BaseData_prototype; + +bool js_cocos2dx_studio_BaseData_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_BaseData_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_BaseData(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_BaseData_getColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_BaseData_setColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_BaseData_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_BaseData_BaseData(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_MovementData_class; +extern JSObject *jsb_cocostudio_MovementData_prototype; + +bool js_cocos2dx_studio_MovementData_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_MovementData_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_MovementData(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_MovementData_getMovementBoneData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_MovementData_addMovementBoneData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_MovementData_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_MovementData_MovementData(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_AnimationData_class; +extern JSObject *jsb_cocostudio_AnimationData_prototype; + +bool js_cocos2dx_studio_AnimationData_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_AnimationData_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_AnimationData(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_AnimationData_getMovement(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_AnimationData_getMovementCount(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_AnimationData_addMovement(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_AnimationData_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_AnimationData_AnimationData(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_ContourData_class; +extern JSObject *jsb_cocostudio_ContourData_prototype; + +bool js_cocos2dx_studio_ContourData_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_ContourData_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_ContourData(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_ContourData_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ContourData_addVertex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ContourData_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ContourData_ContourData(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_TextureData_class; +extern JSObject *jsb_cocostudio_TextureData_prototype; + +bool js_cocos2dx_studio_TextureData_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_TextureData_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_TextureData(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_TextureData_getContourData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_TextureData_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_TextureData_addContourData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_TextureData_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_TextureData_TextureData(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_ProcessBase_class; +extern JSObject *jsb_cocostudio_ProcessBase_prototype; + +bool js_cocos2dx_studio_ProcessBase_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_ProcessBase_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_ProcessBase(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_ProcessBase_play(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ProcessBase_pause(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ProcessBase_getRawDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ProcessBase_resume(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ProcessBase_setIsComplete(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ProcessBase_stop(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ProcessBase_update(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ProcessBase_getCurrentFrameIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ProcessBase_isComplete(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ProcessBase_getCurrentPercent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ProcessBase_setIsPause(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ProcessBase_getProcessScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ProcessBase_isPause(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ProcessBase_isPlaying(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ProcessBase_setProcessScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ProcessBase_setIsPlaying(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ProcessBase_ProcessBase(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_Tween_class; +extern JSObject *jsb_cocostudio_Tween_prototype; + +bool js_cocos2dx_studio_Tween_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_Tween_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_Tween(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_Tween_getAnimation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Tween_gotoAndPause(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Tween_play(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Tween_gotoAndPlay(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Tween_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Tween_setAnimation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Tween_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Tween_Tween(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_ColliderFilter_class; +extern JSObject *jsb_cocostudio_ColliderFilter_prototype; + +bool js_cocos2dx_studio_ColliderFilter_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_ColliderFilter_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_ColliderFilter(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); + +extern JSClass *jsb_cocostudio_ColliderBody_class; +extern JSObject *jsb_cocostudio_ColliderBody_prototype; + +bool js_cocos2dx_studio_ColliderBody_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_ColliderBody_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_ColliderBody(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); + +extern JSClass *jsb_cocostudio_ColliderDetector_class; +extern JSObject *jsb_cocostudio_ColliderDetector_prototype; + +bool js_cocos2dx_studio_ColliderDetector_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_ColliderDetector_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_ColliderDetector(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_ColliderDetector_getBone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ColliderDetector_getActive(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ColliderDetector_getColliderBodyList(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ColliderDetector_updateTransform(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ColliderDetector_removeAll(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ColliderDetector_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ColliderDetector_setActive(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ColliderDetector_setBone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ColliderDetector_create(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_DecorativeDisplay_class; +extern JSObject *jsb_cocostudio_DecorativeDisplay_prototype; + +bool js_cocos2dx_studio_DecorativeDisplay_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_DecorativeDisplay_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_DecorativeDisplay(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_DecorativeDisplay_getColliderDetector(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DecorativeDisplay_getDisplay(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DecorativeDisplay_setDisplay(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DecorativeDisplay_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DecorativeDisplay_setDisplayData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DecorativeDisplay_getDisplayData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DecorativeDisplay_setColliderDetector(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DecorativeDisplay_create(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_DisplayManager_class; +extern JSObject *jsb_cocostudio_DisplayManager_prototype; + +bool js_cocos2dx_studio_DisplayManager_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_DisplayManager_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_DisplayManager(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_DisplayManager_getCurrentDecorativeDisplay(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_getDisplayRenderNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_getAnchorPointInPoints(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_setCurrentDecorativeDisplay(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_getDisplayRenderNodeType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_removeDisplay(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_setForceChangeDisplay(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_getContentSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_getBoundingBox(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_addDisplay(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_containPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_initDisplayList(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_changeDisplayWithIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_changeDisplayWithName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_isForceChangeDisplay(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_getDecorativeDisplayByIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_getCurrentDisplayIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_getAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_getDecorativeDisplayList(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_isVisible(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_setVisible(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_DisplayManager_DisplayManager(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_Bone_class; +extern JSObject *jsb_cocostudio_Bone_prototype; + +bool js_cocos2dx_studio_Bone_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_Bone_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_Bone(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_Bone_isTransformDirty(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_isIgnoreMovementBoneData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_updateZOrder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_getDisplayRenderNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_isBlendDirty(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_addChildBone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_getWorldInfo(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_getTween(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_getParentBone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_updateColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_setTransformDirty(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_getDisplayRenderNodeType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_removeDisplay(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_setBoneData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_setParentBone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_addDisplay(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_setIgnoreMovementBoneData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_removeFromParent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_getColliderDetector(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_getChildArmature(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_changeDisplayWithIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_changeDisplayWithName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_setArmature(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_setBlendDirty(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_removeChildBone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_setChildArmature(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_getNodeToArmatureTransform(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_getDisplayManager(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_getArmature(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Bone_Bone(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_BatchNode_class; +extern JSObject *jsb_cocostudio_BatchNode_prototype; + +bool js_cocos2dx_studio_BatchNode_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_BatchNode_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_BatchNode(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_BatchNode_create(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_ArmatureAnimation_class; +extern JSObject *jsb_cocostudio_ArmatureAnimation_prototype; + +bool js_cocos2dx_studio_ArmatureAnimation_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_ArmatureAnimation_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_ArmatureAnimation(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_ArmatureAnimation_getSpeedScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureAnimation_play(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureAnimation_gotoAndPause(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureAnimation_playWithIndexes(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureAnimation_setAnimationData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureAnimation_setSpeedScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureAnimation_getAnimationData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureAnimation_gotoAndPlay(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureAnimation_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureAnimation_playWithNames(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureAnimation_getMovementCount(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureAnimation_playWithIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureAnimation_getCurrentMovementID(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureAnimation_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureAnimation_ArmatureAnimation(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_ArmatureDataManager_class; +extern JSObject *jsb_cocostudio_ArmatureDataManager_prototype; + +bool js_cocos2dx_studio_ArmatureDataManager_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_ArmatureDataManager_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_ArmatureDataManager(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_ArmatureDataManager_getAnimationDatas(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureDataManager_removeAnimationData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureDataManager_addArmatureData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureDataManager_addArmatureFileInfo(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureDataManager_removeArmatureFileInfo(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureDataManager_getTextureData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureDataManager_getArmatureData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureDataManager_getAnimationData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureDataManager_addAnimationData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureDataManager_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureDataManager_removeArmatureData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureDataManager_getArmatureDatas(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureDataManager_removeTextureData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureDataManager_addTextureData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureDataManager_isAutoLoadSpriteFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureDataManager_addSpriteFrameFromFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureDataManager_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ArmatureDataManager_getInstance(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_Armature_class; +extern JSObject *jsb_cocostudio_Armature_prototype; + +bool js_cocos2dx_studio_Armature_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_Armature_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_Armature(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_Armature_getBone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_changeBoneParent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_setAnimation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_getBoneAtPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_getArmatureTransformDirty(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_setVersion(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_updateOffsetPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_getParentBone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_removeBone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_getBatchNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_setParentBone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_setBatchNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_setArmatureData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_addBone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_getArmatureData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_getBoundingBox(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_getVersion(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_getAnimation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_getOffsetPoints(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_getBoneDic(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Armature_Armature(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_Skin_class; +extern JSObject *jsb_cocostudio_Skin_prototype; + +bool js_cocos2dx_studio_Skin_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_Skin_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_Skin(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_Skin_getBone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Skin_getNodeToWorldTransformAR(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Skin_getDisplayName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Skin_updateArmatureTransform(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Skin_setBone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Skin_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Skin_createWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Skin_Skin(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_ComAttribute_class; +extern JSObject *jsb_cocostudio_ComAttribute_prototype; + +bool js_cocos2dx_studio_ComAttribute_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_ComAttribute_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_ComAttribute(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_ComAttribute_getFloat(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAttribute_getBool(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAttribute_getString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAttribute_setFloat(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAttribute_setString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAttribute_setInt(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAttribute_parse(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAttribute_getInt(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAttribute_setBool(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAttribute_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAttribute_ComAttribute(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_ComAudio_class; +extern JSObject *jsb_cocostudio_ComAudio_prototype; + +bool js_cocos2dx_studio_ComAudio_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_ComAudio_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_ComAudio(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_ComAudio_stopAllEffects(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_getEffectsVolume(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_stopEffect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_getBackgroundMusicVolume(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_willPlayBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_setBackgroundMusicVolume(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_end(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_stopBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_pauseBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_isBackgroundMusicPlaying(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_isLoop(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_resumeAllEffects(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_pauseAllEffects(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_preloadBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_playBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_playEffect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_preloadEffect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_setLoop(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_unloadEffect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_rewindBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_pauseEffect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_resumeBackgroundMusic(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_setFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_setEffectsVolume(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_getFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_resumeEffect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComAudio_ComAudio(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_InputDelegate_class; +extern JSObject *jsb_cocostudio_InputDelegate_prototype; + +bool js_cocos2dx_studio_InputDelegate_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_InputDelegate_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_InputDelegate(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_InputDelegate_isAccelerometerEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InputDelegate_setKeypadEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InputDelegate_getTouchMode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InputDelegate_setAccelerometerEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InputDelegate_isKeypadEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InputDelegate_isTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InputDelegate_setTouchPriority(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InputDelegate_getTouchPriority(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InputDelegate_setTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InputDelegate_setTouchMode(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_ComController_class; +extern JSObject *jsb_cocostudio_ComController_prototype; + +bool js_cocos2dx_studio_ComController_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_ComController_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_ComController(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_ComController_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComController_ComController(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_ComRender_class; +extern JSObject *jsb_cocostudio_ComRender_prototype; + +bool js_cocos2dx_studio_ComRender_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_ComRender_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_ComRender(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_ComRender_getNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComRender_setNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComRender_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ComRender_ComRender(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_timeline_Frame_class; +extern JSObject *jsb_cocostudio_timeline_Frame_prototype; + +bool js_cocos2dx_studio_Frame_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_Frame_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_Frame(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_Frame_clone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Frame_setTweenType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Frame_setNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Frame_setTimeline(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Frame_isEnterWhenPassed(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Frame_getTweenType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Frame_getFrameIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Frame_apply(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Frame_isTween(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Frame_setFrameIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Frame_setTween(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Frame_getTimeline(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Frame_getNode(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_timeline_VisibleFrame_class; +extern JSObject *jsb_cocostudio_timeline_VisibleFrame_prototype; + +bool js_cocos2dx_studio_VisibleFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_VisibleFrame_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_VisibleFrame(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_VisibleFrame_isVisible(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_VisibleFrame_setVisible(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_VisibleFrame_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_VisibleFrame_VisibleFrame(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_timeline_TextureFrame_class; +extern JSObject *jsb_cocostudio_timeline_TextureFrame_prototype; + +bool js_cocos2dx_studio_TextureFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_TextureFrame_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_TextureFrame(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_TextureFrame_getTextureName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_TextureFrame_setTextureName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_TextureFrame_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_TextureFrame_TextureFrame(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_timeline_RotationFrame_class; +extern JSObject *jsb_cocostudio_timeline_RotationFrame_prototype; + +bool js_cocos2dx_studio_RotationFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_RotationFrame_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_RotationFrame(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_RotationFrame_setRotation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_RotationFrame_getRotation(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_RotationFrame_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_RotationFrame_RotationFrame(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_timeline_SkewFrame_class; +extern JSObject *jsb_cocostudio_timeline_SkewFrame_prototype; + +bool js_cocos2dx_studio_SkewFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_SkewFrame_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_SkewFrame(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_SkewFrame_getSkewY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_SkewFrame_setSkewX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_SkewFrame_setSkewY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_SkewFrame_getSkewX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_SkewFrame_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_SkewFrame_SkewFrame(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_timeline_RotationSkewFrame_class; +extern JSObject *jsb_cocostudio_timeline_RotationSkewFrame_prototype; + +bool js_cocos2dx_studio_RotationSkewFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_RotationSkewFrame_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_RotationSkewFrame(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_RotationSkewFrame_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_RotationSkewFrame_RotationSkewFrame(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_timeline_PositionFrame_class; +extern JSObject *jsb_cocostudio_timeline_PositionFrame_prototype; + +bool js_cocos2dx_studio_PositionFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_PositionFrame_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_PositionFrame(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_PositionFrame_getX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_PositionFrame_getY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_PositionFrame_setPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_PositionFrame_setX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_PositionFrame_setY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_PositionFrame_getPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_PositionFrame_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_PositionFrame_PositionFrame(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_timeline_ScaleFrame_class; +extern JSObject *jsb_cocostudio_timeline_ScaleFrame_prototype; + +bool js_cocos2dx_studio_ScaleFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_ScaleFrame_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_ScaleFrame(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_ScaleFrame_setScaleY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ScaleFrame_setScaleX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ScaleFrame_getScaleY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ScaleFrame_getScaleX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ScaleFrame_setScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ScaleFrame_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ScaleFrame_ScaleFrame(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_timeline_AnchorPointFrame_class; +extern JSObject *jsb_cocostudio_timeline_AnchorPointFrame_prototype; + +bool js_cocos2dx_studio_AnchorPointFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_AnchorPointFrame_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_AnchorPointFrame(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_AnchorPointFrame_setAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_AnchorPointFrame_getAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_AnchorPointFrame_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_AnchorPointFrame_AnchorPointFrame(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_timeline_InnerActionFrame_class; +extern JSObject *jsb_cocostudio_timeline_InnerActionFrame_prototype; + +bool js_cocos2dx_studio_InnerActionFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_InnerActionFrame_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_InnerActionFrame(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_InnerActionFrame_getEndFrameIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InnerActionFrame_getStartFrameIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InnerActionFrame_getInnerActionType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InnerActionFrame_setEndFrameIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InnerActionFrame_setEnterWithName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InnerActionFrame_setSingleFrameIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InnerActionFrame_setStartFrameIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InnerActionFrame_getSingleFrameIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InnerActionFrame_setInnerActionType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InnerActionFrame_setAnimationName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InnerActionFrame_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_InnerActionFrame_InnerActionFrame(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_timeline_ColorFrame_class; +extern JSObject *jsb_cocostudio_timeline_ColorFrame_prototype; + +bool js_cocos2dx_studio_ColorFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_ColorFrame_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_ColorFrame(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_ColorFrame_getColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ColorFrame_setColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ColorFrame_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ColorFrame_ColorFrame(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_timeline_AlphaFrame_class; +extern JSObject *jsb_cocostudio_timeline_AlphaFrame_prototype; + +bool js_cocos2dx_studio_AlphaFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_AlphaFrame_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_AlphaFrame(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_AlphaFrame_getAlpha(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_AlphaFrame_setAlpha(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_AlphaFrame_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_AlphaFrame_AlphaFrame(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_timeline_EventFrame_class; +extern JSObject *jsb_cocostudio_timeline_EventFrame_prototype; + +bool js_cocos2dx_studio_EventFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_EventFrame_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_EventFrame(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_EventFrame_setEvent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_EventFrame_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_EventFrame_getEvent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_EventFrame_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_EventFrame_EventFrame(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_timeline_ZOrderFrame_class; +extern JSObject *jsb_cocostudio_timeline_ZOrderFrame_prototype; + +bool js_cocos2dx_studio_ZOrderFrame_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_ZOrderFrame_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_ZOrderFrame(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_ZOrderFrame_getZOrder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ZOrderFrame_setZOrder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ZOrderFrame_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ZOrderFrame_ZOrderFrame(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_timeline_Timeline_class; +extern JSObject *jsb_cocostudio_timeline_Timeline_prototype; + +bool js_cocos2dx_studio_Timeline_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_Timeline_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_Timeline(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_Timeline_clone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Timeline_gotoFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Timeline_setNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Timeline_getActionTimeline(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Timeline_insertFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Timeline_setActionTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Timeline_addFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Timeline_getFrames(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Timeline_getActionTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Timeline_getNode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Timeline_removeFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Timeline_setActionTimeline(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Timeline_stepToFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Timeline_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_Timeline_Timeline(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_timeline_ActionTimelineData_class; +extern JSObject *jsb_cocostudio_timeline_ActionTimelineData_prototype; + +bool js_cocos2dx_studio_ActionTimelineData_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_ActionTimelineData_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_ActionTimelineData(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_ActionTimelineData_setActionTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionTimelineData_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionTimelineData_getActionTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionTimelineData_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionTimelineData_ActionTimelineData(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocostudio_timeline_ActionTimeline_class; +extern JSObject *jsb_cocostudio_timeline_ActionTimeline_prototype; + +bool js_cocos2dx_studio_ActionTimeline_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_ActionTimeline_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_ActionTimeline(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +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_init(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_IsAnimationInfoExists(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_play(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionTimeline_getAnimationInfo(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_removeAnimationInfo(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_addAnimationInfo(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_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); + +extern JSClass *jsb_cocostudio_ObjectExtensionData_class; +extern JSObject *jsb_cocostudio_ObjectExtensionData_prototype; + +bool js_cocos2dx_studio_ObjectExtensionData_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_studio_ObjectExtensionData_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_studio_ObjectExtensionData(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_studio(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_studio_ObjectExtensionData_setActionTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ObjectExtensionData_setCustomProperty(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ObjectExtensionData_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ObjectExtensionData_getCustomProperty(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ObjectExtensionData_getActionTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ObjectExtensionData_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ObjectExtensionData_ObjectExtensionData(JSContext *cx, uint32_t argc, jsval *vp); +#endif + diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp new file mode 100644 index 0000000000..bfab5bd891 --- /dev/null +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp @@ -0,0 +1,15776 @@ +#include "jsb_cocos2dx_ui_auto.hpp" +#include "cocos2d_specifics.hpp" +#include "CocosGUI.h" + +template +static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedValue initializing(cx); + bool isNewValid = true; + JS::RootedObject global(cx, ScriptingCore::getInstance()->getGlobalObject()); + isNewValid = JS_GetProperty(cx, global, "initializing", &initializing) && initializing.toBoolean(); + if (isNewValid) + { + 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."); + + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + + args.rval().set(OBJECT_TO_JSVAL(_tmp)); + return true; + } + + JS_ReportError(cx, "Constructor for the requested class is not available, please refer to the API reference."); + return false; +} + +static bool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) { + return false; +} + +static bool js_is_native_obj(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().setBoolean(true); + return true; +} +JSClass *jsb_cocos2d_ui_LayoutParameter_class; +JSObject *jsb_cocos2d_ui_LayoutParameter_prototype; + +bool js_cocos2dx_ui_LayoutParameter_clone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutParameter* cobj = (cocos2d::ui::LayoutParameter *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutParameter_clone : Invalid Native Object"); + if (argc == 0) { + cocos2d::ui::LayoutParameter* ret = cobj->clone(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::LayoutParameter*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutParameter_clone : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutParameter_getLayoutType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutParameter* cobj = (cocos2d::ui::LayoutParameter *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutParameter_getLayoutType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getLayoutType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutParameter_getLayoutType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutParameter_createCloneInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutParameter* cobj = (cocos2d::ui::LayoutParameter *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutParameter_createCloneInstance : Invalid Native Object"); + if (argc == 0) { + cocos2d::ui::LayoutParameter* ret = cobj->createCloneInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::LayoutParameter*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutParameter_createCloneInstance : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutParameter_copyProperties(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutParameter* cobj = (cocos2d::ui::LayoutParameter *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutParameter_copyProperties : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::LayoutParameter* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::LayoutParameter*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutParameter_copyProperties : Error processing arguments"); + cobj->copyProperties(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutParameter_copyProperties : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutParameter_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ui::LayoutParameter* ret = cocos2d::ui::LayoutParameter::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::LayoutParameter*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_LayoutParameter_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_LayoutParameter_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::LayoutParameter* cobj = new (std::nothrow) cocos2d::ui::LayoutParameter(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::LayoutParameter"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_ui_LayoutParameter_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (LayoutParameter)", obj); +} + +void js_register_cocos2dx_ui_LayoutParameter(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_LayoutParameter_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_LayoutParameter_class->name = "LayoutParameter"; + jsb_cocos2d_ui_LayoutParameter_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_LayoutParameter_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_LayoutParameter_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_LayoutParameter_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_LayoutParameter_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_LayoutParameter_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_LayoutParameter_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_LayoutParameter_class->finalize = js_cocos2d_ui_LayoutParameter_finalize; + jsb_cocos2d_ui_LayoutParameter_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("clone", js_cocos2dx_ui_LayoutParameter_clone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLayoutType", js_cocos2dx_ui_LayoutParameter_getLayoutType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createCloneInstance", js_cocos2dx_ui_LayoutParameter_createCloneInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("copyProperties", js_cocos2dx_ui_LayoutParameter_copyProperties, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_LayoutParameter_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_LayoutParameter_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_ui_LayoutParameter_class, + js_cocos2dx_ui_LayoutParameter_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, "LayoutParameter", 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_LayoutParameter_class; + p->proto = jsb_cocos2d_ui_LayoutParameter_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_LinearLayoutParameter_class; +JSObject *jsb_cocos2d_ui_LinearLayoutParameter_prototype; + +bool js_cocos2dx_ui_LinearLayoutParameter_setGravity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LinearLayoutParameter* cobj = (cocos2d::ui::LinearLayoutParameter *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LinearLayoutParameter_setGravity : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::LinearLayoutParameter::LinearGravity arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LinearLayoutParameter_setGravity : Error processing arguments"); + cobj->setGravity(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LinearLayoutParameter_setGravity : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LinearLayoutParameter_getGravity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LinearLayoutParameter* cobj = (cocos2d::ui::LinearLayoutParameter *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LinearLayoutParameter_getGravity : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getGravity(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LinearLayoutParameter_getGravity : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LinearLayoutParameter_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ui::LinearLayoutParameter* ret = cocos2d::ui::LinearLayoutParameter::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::LinearLayoutParameter*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_LinearLayoutParameter_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_LinearLayoutParameter_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::LinearLayoutParameter* cobj = new (std::nothrow) cocos2d::ui::LinearLayoutParameter(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::LinearLayoutParameter"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_LayoutParameter_prototype; + +void js_cocos2d_ui_LinearLayoutParameter_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (LinearLayoutParameter)", obj); +} + +void js_register_cocos2dx_ui_LinearLayoutParameter(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_LinearLayoutParameter_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_LinearLayoutParameter_class->name = "LinearLayoutParameter"; + jsb_cocos2d_ui_LinearLayoutParameter_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_LinearLayoutParameter_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_LinearLayoutParameter_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_LinearLayoutParameter_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_LinearLayoutParameter_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_LinearLayoutParameter_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_LinearLayoutParameter_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_LinearLayoutParameter_class->finalize = js_cocos2d_ui_LinearLayoutParameter_finalize; + jsb_cocos2d_ui_LinearLayoutParameter_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setGravity", js_cocos2dx_ui_LinearLayoutParameter_setGravity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getGravity", js_cocos2dx_ui_LinearLayoutParameter_getGravity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_LinearLayoutParameter_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_LinearLayoutParameter_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_LayoutParameter_prototype), + jsb_cocos2d_ui_LinearLayoutParameter_class, + js_cocos2dx_ui_LinearLayoutParameter_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, "LinearLayoutParameter", 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_LinearLayoutParameter_class; + p->proto = jsb_cocos2d_ui_LinearLayoutParameter_prototype; + p->parentProto = jsb_cocos2d_ui_LayoutParameter_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_RelativeLayoutParameter_class; +JSObject *jsb_cocos2d_ui_RelativeLayoutParameter_prototype; + +bool js_cocos2dx_ui_RelativeLayoutParameter_setAlign(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::RelativeLayoutParameter* cobj = (cocos2d::ui::RelativeLayoutParameter *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RelativeLayoutParameter_setAlign : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::RelativeLayoutParameter::RelativeAlign arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_RelativeLayoutParameter_setAlign : Error processing arguments"); + cobj->setAlign(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RelativeLayoutParameter_setAlign : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_RelativeLayoutParameter_setRelativeToWidgetName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::RelativeLayoutParameter* cobj = (cocos2d::ui::RelativeLayoutParameter *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RelativeLayoutParameter_setRelativeToWidgetName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_RelativeLayoutParameter_setRelativeToWidgetName : Error processing arguments"); + cobj->setRelativeToWidgetName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RelativeLayoutParameter_setRelativeToWidgetName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_RelativeLayoutParameter_getRelativeName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::RelativeLayoutParameter* cobj = (cocos2d::ui::RelativeLayoutParameter *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RelativeLayoutParameter_getRelativeName : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getRelativeName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RelativeLayoutParameter_getRelativeName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_RelativeLayoutParameter_getRelativeToWidgetName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::RelativeLayoutParameter* cobj = (cocos2d::ui::RelativeLayoutParameter *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RelativeLayoutParameter_getRelativeToWidgetName : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getRelativeToWidgetName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RelativeLayoutParameter_getRelativeToWidgetName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_RelativeLayoutParameter_setRelativeName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::RelativeLayoutParameter* cobj = (cocos2d::ui::RelativeLayoutParameter *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RelativeLayoutParameter_setRelativeName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_RelativeLayoutParameter_setRelativeName : Error processing arguments"); + cobj->setRelativeName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RelativeLayoutParameter_setRelativeName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_RelativeLayoutParameter_getAlign(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::RelativeLayoutParameter* cobj = (cocos2d::ui::RelativeLayoutParameter *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RelativeLayoutParameter_getAlign : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getAlign(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RelativeLayoutParameter_getAlign : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_RelativeLayoutParameter_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ui::RelativeLayoutParameter* ret = cocos2d::ui::RelativeLayoutParameter::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::RelativeLayoutParameter*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_RelativeLayoutParameter_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_RelativeLayoutParameter_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::RelativeLayoutParameter* cobj = new (std::nothrow) cocos2d::ui::RelativeLayoutParameter(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::RelativeLayoutParameter"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_LayoutParameter_prototype; + +void js_cocos2d_ui_RelativeLayoutParameter_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (RelativeLayoutParameter)", obj); +} + +void js_register_cocos2dx_ui_RelativeLayoutParameter(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_RelativeLayoutParameter_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_RelativeLayoutParameter_class->name = "RelativeLayoutParameter"; + jsb_cocos2d_ui_RelativeLayoutParameter_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_RelativeLayoutParameter_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_RelativeLayoutParameter_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_RelativeLayoutParameter_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_RelativeLayoutParameter_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_RelativeLayoutParameter_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_RelativeLayoutParameter_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_RelativeLayoutParameter_class->finalize = js_cocos2d_ui_RelativeLayoutParameter_finalize; + jsb_cocos2d_ui_RelativeLayoutParameter_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setAlign", js_cocos2dx_ui_RelativeLayoutParameter_setAlign, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRelativeToWidgetName", js_cocos2dx_ui_RelativeLayoutParameter_setRelativeToWidgetName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRelativeName", js_cocos2dx_ui_RelativeLayoutParameter_getRelativeName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRelativeToWidgetName", js_cocos2dx_ui_RelativeLayoutParameter_getRelativeToWidgetName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRelativeName", js_cocos2dx_ui_RelativeLayoutParameter_setRelativeName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAlign", js_cocos2dx_ui_RelativeLayoutParameter_getAlign, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_RelativeLayoutParameter_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_RelativeLayoutParameter_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_LayoutParameter_prototype), + jsb_cocos2d_ui_RelativeLayoutParameter_class, + js_cocos2dx_ui_RelativeLayoutParameter_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, "RelativeLayoutParameter", 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_RelativeLayoutParameter_class; + p->proto = jsb_cocos2d_ui_RelativeLayoutParameter_prototype; + p->parentProto = jsb_cocos2d_ui_LayoutParameter_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_Widget_class; +JSObject *jsb_cocos2d_ui_Widget_prototype; + +bool js_cocos2dx_ui_Widget_setLayoutComponentEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setLayoutComponentEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setLayoutComponentEnabled : Error processing arguments"); + cobj->setLayoutComponentEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_setLayoutComponentEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Widget_setSizePercent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setSizePercent : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setSizePercent : Error processing arguments"); + cobj->setSizePercent(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_setSizePercent : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Widget_getCustomSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getCustomSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getCustomSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getCustomSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_getLeftBoundary(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getLeftBoundary : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getLeftBoundary(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getLeftBoundary : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_setFlippedX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setFlippedX : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setFlippedX : Error processing arguments"); + cobj->setFlippedX(arg0); + args.rval().setUndefined(); + return true; + } + + 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_setCallbackName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setCallbackName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setCallbackName : Error processing arguments"); + cobj->setCallbackName(arg0); + args.rval().setUndefined(); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getVirtualRenderer : Invalid Native Object"); + if (argc == 0) { + cocos2d::Node* ret = cobj->getVirtualRenderer(); + 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); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getVirtualRenderer : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_setPropagateTouchEvents(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setPropagateTouchEvents : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setPropagateTouchEvents : Error processing arguments"); + cobj->setPropagateTouchEvents(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_setPropagateTouchEvents : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Widget_isUnifySizeEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isUnifySizeEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isUnifySizeEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_isUnifySizeEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_getSizePercent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getSizePercent : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getSizePercent(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getSizePercent : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_setPositionPercent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setPositionPercent : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setPositionPercent : Error processing arguments"); + cobj->setPositionPercent(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_setPositionPercent : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Widget_setSwallowTouches(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setSwallowTouches : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setSwallowTouches : Error processing arguments"); + cobj->setSwallowTouches(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_setSwallowTouches : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Widget_getLayoutSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getLayoutSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getLayoutSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getLayoutSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_setHighlighted(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setHighlighted : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setHighlighted : Error processing arguments"); + cobj->setHighlighted(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_setHighlighted : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Widget_setPositionType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setPositionType : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::Widget::PositionType arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setPositionType : Error processing arguments"); + cobj->setPositionType(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_setPositionType : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Widget_isIgnoreContentAdaptWithSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isIgnoreContentAdaptWithSize : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isIgnoreContentAdaptWithSize(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_isIgnoreContentAdaptWithSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_getVirtualRendererSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getVirtualRendererSize : Invalid Native Object"); + if (argc == 0) { + cocos2d::Size ret = cobj->getVirtualRendererSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getVirtualRendererSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_isHighlighted(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isHighlighted : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isHighlighted(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_isHighlighted : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_getLayoutParameter(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getLayoutParameter : Invalid Native Object"); + if (argc == 0) { + cocos2d::ui::LayoutParameter* ret = cobj->getLayoutParameter(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::LayoutParameter*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + 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_addCCSEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_addCCSEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + auto lambda = [=](cocos2d::Ref* larg0, int larg1) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + JS::RootedValue rval(cx); + 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); + args.rval().setUndefined(); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getPositionType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getPositionType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getPositionType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_getTopBoundary(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getTopBoundary : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getTopBoundary(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getTopBoundary : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_ignoreContentAdaptWithSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_ignoreContentAdaptWithSize : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_ignoreContentAdaptWithSize : Error processing arguments"); + cobj->ignoreContentAdaptWithSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_ignoreContentAdaptWithSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Widget_findNextFocusedWidget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_findNextFocusedWidget : Invalid Native Object"); + if (argc == 2) { + cocos2d::ui::Widget::FocusDirection arg0; + cocos2d::ui::Widget* arg1; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + 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_findNextFocusedWidget : Error processing arguments"); + cocos2d::ui::Widget* ret = cobj->findNextFocusedWidget(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Widget*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_findNextFocusedWidget : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ui_Widget_isEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_isFocused(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isFocused : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isFocused(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_isFocused : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_getTouchBeganPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getTouchBeganPosition : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getTouchBeganPosition(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getTouchBeganPosition : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_isTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isTouchEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isTouchEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getActionTag : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getActionTag(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getActionTag : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_getWorldPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getWorldPosition : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getWorldPosition(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getWorldPosition : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_isFocusEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isFocusEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isFocusEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_isFocusEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_setFocused(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setFocused : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setFocused : Error processing arguments"); + cobj->setFocused(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_setFocused : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Widget_setActionTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setActionTag : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setActionTag : Error processing arguments"); + cobj->setActionTag(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_setActionTag : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Widget_setTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setTouchEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setTouchEnabled : Error processing arguments"); + cobj->setTouchEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_setTouchEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Widget_setFlippedY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setFlippedY : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setFlippedY : Error processing arguments"); + cobj->setFlippedY(arg0); + args.rval().setUndefined(); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setEnabled : Error processing arguments"); + cobj->setEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_setEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Widget_getRightBoundary(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getRightBoundary : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getRightBoundary(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getRightBoundary : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_setBrightStyle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setBrightStyle : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::Widget::BrightStyle arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setBrightStyle : Error processing arguments"); + cobj->setBrightStyle(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_setBrightStyle : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Widget_setLayoutParameter(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setLayoutParameter : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::LayoutParameter* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::LayoutParameter*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setLayoutParameter : Error processing arguments"); + cobj->setLayoutParameter(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_setLayoutParameter : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Widget_clone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_clone : Invalid Native Object"); + if (argc == 0) { + cocos2d::ui::Widget* ret = cobj->clone(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Widget*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_clone : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_setFocusEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setFocusEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setFocusEnabled : Error processing arguments"); + cobj->setFocusEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_setFocusEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Widget_getBottomBoundary(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getBottomBoundary : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getBottomBoundary(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getBottomBoundary : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_isBright(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isBright : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isBright(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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 (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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 (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + 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); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setUnifySizeEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setUnifySizeEnabled : Error processing arguments"); + cobj->setUnifySizeEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_setUnifySizeEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Widget_isPropagateTouchEvents(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isPropagateTouchEvents : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isPropagateTouchEvents(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_isPropagateTouchEvents : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_getCurrentFocusedWidget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getCurrentFocusedWidget : Invalid Native Object"); + if (argc == 0) { + cocos2d::ui::Widget* ret = cobj->getCurrentFocusedWidget(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Widget*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(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); + args.rval().set(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_isLayoutComponentEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isLayoutComponentEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isLayoutComponentEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_isLayoutComponentEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_requestFocus(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_requestFocus : Invalid Native Object"); + if (argc == 0) { + cobj->requestFocus(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_requestFocus : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_updateSizeAndPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ui::Widget* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ui::Widget *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_updateSizeAndPosition : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->updateSizeAndPosition(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 0) { + cobj->updateSizeAndPosition(); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_updateSizeAndPosition : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_Widget_onFocusChange(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_onFocusChange : Invalid Native Object"); + if (argc == 2) { + cocos2d::ui::Widget* arg0; + cocos2d::ui::Widget* arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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 (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + 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_onFocusChange : Error processing arguments"); + cobj->onFocusChange(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_onFocusChange : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ui_Widget_getTouchMovePosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getTouchMovePosition : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getTouchMovePosition(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getTouchMovePosition : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_getSizeType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getSizeType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getSizeType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + 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_getCallbackType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getCallbackType : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getCallbackType(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getTouchEndPosition : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getTouchEndPosition(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getTouchEndPosition : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_getPositionPercent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getPositionPercent : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getPositionPercent(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getPositionPercent : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_propagateTouchEvent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_propagateTouchEvent : Invalid Native Object"); + if (argc == 3) { + cocos2d::ui::Widget::TouchEventType arg0; + cocos2d::ui::Widget* arg1; + cocos2d::Touch* arg2; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + 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 (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + 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_propagateTouchEvent : Error processing arguments"); + cobj->propagateTouchEvent(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_propagateTouchEvent : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_ui_Widget_addClickEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_addClickEventListener : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, args.thisv().toObjectOrNull(), args.get(0))); + auto lambda = [=](cocos2d::Ref* larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + 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); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + JS::RootedValue rval(cx); + 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"); + cobj->addClickEventListener(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_addClickEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Widget_isFlippedX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isFlippedX : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isFlippedX(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_isFlippedX : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_isFlippedY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isFlippedY : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isFlippedY(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_isFlippedY : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_isClippingParentContainsPoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isClippingParentContainsPoint : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_isClippingParentContainsPoint : Error processing arguments"); + bool ret = cobj->isClippingParentContainsPoint(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_isClippingParentContainsPoint : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Widget_setSizeType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setSizeType : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::Widget::SizeType arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setSizeType : Error processing arguments"); + cobj->setSizeType(arg0); + args.rval().setUndefined(); + return true; + } + + 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_interceptTouchEvent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), (int32_t *)&arg0); + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + 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 (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + 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); + args.rval().setUndefined(); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setBright : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setBright : Error processing arguments"); + cobj->setBright(arg0); + args.rval().setUndefined(); + return true; + } + + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setCallbackType : Error processing arguments"); + cobj->setCallbackType(arg0); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_isSwallowTouches : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isSwallowTouches(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_isSwallowTouches : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Widget_enableDpadNavigation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_enableDpadNavigation : Error processing arguments"); + cocos2d::ui::Widget::enableDpadNavigation(arg0); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_Widget_enableDpadNavigation : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_Widget_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ui::Widget* ret = cocos2d::ui::Widget::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Widget*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_Widget_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_Widget_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::Widget* cobj = new (std::nothrow) cocos2d::ui::Widget(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::Widget"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ProtectedNode_prototype; + +void js_cocos2d_ui_Widget_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Widget)", obj); +} + +static bool js_cocos2d_ui_Widget_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::Widget *nobj = new (std::nothrow) cocos2d::ui::Widget(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::Widget"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_Widget(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_Widget_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_Widget_class->name = "Widget"; + jsb_cocos2d_ui_Widget_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_Widget_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_Widget_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_Widget_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_Widget_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_Widget_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_Widget_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_Widget_class->finalize = js_cocos2d_ui_Widget_finalize; + jsb_cocos2d_ui_Widget_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setLayoutComponentEnabled", js_cocos2dx_ui_Widget_setLayoutComponentEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSizePercent", js_cocos2dx_ui_Widget_setSizePercent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + 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("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), + JS_FN("getSizePercent", js_cocos2dx_ui_Widget_getSizePercent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPositionPercent", js_cocos2dx_ui_Widget_setPositionPercent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSwallowTouches", js_cocos2dx_ui_Widget_setSwallowTouches, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLayoutSize", js_cocos2dx_ui_Widget_getLayoutSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setHighlighted", js_cocos2dx_ui_Widget_setHighlighted, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPositionType", js_cocos2dx_ui_Widget_setPositionType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isIgnoreContentAdaptWithSize", js_cocos2dx_ui_Widget_isIgnoreContentAdaptWithSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + 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("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), + JS_FN("findNextFocusedWidget", js_cocos2dx_ui_Widget_findNextFocusedWidget, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isEnabled", js_cocos2dx_ui_Widget_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + 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), + JS_FN("setFocused", js_cocos2dx_ui_Widget_setFocused, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + 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), + JS_FN("setLayoutParameter", js_cocos2dx_ui_Widget_setLayoutParameter, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("clone", js_cocos2dx_ui_Widget_clone, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + 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("isLayoutComponentEnabled", js_cocos2dx_ui_Widget_isLayoutComponentEnabled, 0, 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("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), + JS_FN("addClickEventListener", js_cocos2dx_ui_Widget_addClickEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isFlippedX", js_cocos2dx_ui_Widget_isFlippedX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + 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("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 + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("enableDpadNavigation", js_cocos2dx_ui_Widget_enableDpadNavigation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("create", js_cocos2dx_ui_Widget_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_Widget_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ProtectedNode_prototype), + jsb_cocos2d_ui_Widget_class, + js_cocos2dx_ui_Widget_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, "Widget", 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_Widget_class; + p->proto = jsb_cocos2d_ui_Widget_prototype; + p->parentProto = jsb_cocos2d_ProtectedNode_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_Layout_class; +JSObject *jsb_cocos2d_ui_Layout_prototype; + +bool js_cocos2dx_ui_Layout_setBackGroundColorVector(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_setBackGroundColorVector : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Layout_setBackGroundColorVector : Error processing arguments"); + cobj->setBackGroundColorVector(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_setBackGroundColorVector : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Layout_setClippingType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_setClippingType : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::Layout::ClippingType arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Layout_setClippingType : Error processing arguments"); + cobj->setClippingType(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_setClippingType : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Layout_setBackGroundColorType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_setBackGroundColorType : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::Layout::BackGroundColorType arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Layout_setBackGroundColorType : Error processing arguments"); + cobj->setBackGroundColorType(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_setBackGroundColorType : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Layout_setLoopFocus(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_setLoopFocus : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Layout_setLoopFocus : Error processing arguments"); + cobj->setLoopFocus(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_setLoopFocus : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Layout_setBackGroundImageColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_setBackGroundImageColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color3B arg0; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Layout_setBackGroundImageColor : Error processing arguments"); + cobj->setBackGroundImageColor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_setBackGroundImageColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Layout_getBackGroundColorVector(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_getBackGroundColorVector : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vec2& ret = cobj->getBackGroundColorVector(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_getBackGroundColorVector : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Layout_getClippingType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_getClippingType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getClippingType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_getClippingType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Layout_isLoopFocus(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_isLoopFocus : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isLoopFocus(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_isLoopFocus : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Layout_removeBackGroundImage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_removeBackGroundImage : Invalid Native Object"); + if (argc == 0) { + cobj->removeBackGroundImage(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_removeBackGroundImage : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Layout_getBackGroundColorOpacity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_getBackGroundColorOpacity : Invalid Native Object"); + if (argc == 0) { + uint16_t ret = cobj->getBackGroundColorOpacity(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_getBackGroundColorOpacity : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Layout_isClippingEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_isClippingEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isClippingEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_isClippingEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Layout_setBackGroundImageOpacity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_setBackGroundImageOpacity : Invalid Native Object"); + if (argc == 1) { + uint16_t arg0; + ok &= jsval_to_uint16(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Layout_setBackGroundImageOpacity : Error processing arguments"); + cobj->setBackGroundImageOpacity(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_setBackGroundImageOpacity : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Layout_setBackGroundImage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_setBackGroundImage : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Layout_setBackGroundImage : Error processing arguments"); + cobj->setBackGroundImage(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Layout_setBackGroundImage : Error processing arguments"); + cobj->setBackGroundImage(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_setBackGroundImage : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Layout_setBackGroundColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ui::Layout* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_setBackGroundColor : Invalid Native Object"); + do { + if (argc == 2) { + cocos2d::Color3B arg0; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Color3B arg1; + ok &= jsval_to_cccolor3b(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cobj->setBackGroundColor(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::Color3B arg0; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->setBackGroundColor(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_setBackGroundColor : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_Layout_requestDoLayout(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_requestDoLayout : Invalid Native Object"); + if (argc == 0) { + cobj->requestDoLayout(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_requestDoLayout : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Layout_getBackGroundImageCapInsets(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_getBackGroundImageCapInsets : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Rect& ret = cobj->getBackGroundImageCapInsets(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_getBackGroundImageCapInsets : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Layout_getBackGroundColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_getBackGroundColor : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color3B& ret = cobj->getBackGroundColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor3b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_getBackGroundColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Layout_setClippingEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_setClippingEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Layout_setClippingEnabled : Error processing arguments"); + cobj->setClippingEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_setClippingEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Layout_getBackGroundImageColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_getBackGroundImageColor : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color3B& ret = cobj->getBackGroundImageColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor3b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_getBackGroundImageColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Layout_isBackGroundImageScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_isBackGroundImageScale9Enabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isBackGroundImageScale9Enabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_isBackGroundImageScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Layout_getBackGroundColorType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_getBackGroundColorType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getBackGroundColorType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_getBackGroundColorType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Layout_getBackGroundEndColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_getBackGroundEndColor : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color3B& ret = cobj->getBackGroundEndColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor3b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_getBackGroundEndColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Layout_setBackGroundColorOpacity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_setBackGroundColorOpacity : Invalid Native Object"); + if (argc == 1) { + uint16_t arg0; + ok &= jsval_to_uint16(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Layout_setBackGroundColorOpacity : Error processing arguments"); + cobj->setBackGroundColorOpacity(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_setBackGroundColorOpacity : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Layout_getBackGroundImageOpacity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_getBackGroundImageOpacity : Invalid Native Object"); + if (argc == 0) { + uint16_t ret = cobj->getBackGroundImageOpacity(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_getBackGroundImageOpacity : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Layout_isPassFocusToChild(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_isPassFocusToChild : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isPassFocusToChild(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_isPassFocusToChild : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Layout_setBackGroundImageCapInsets(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_setBackGroundImageCapInsets : Invalid Native Object"); + if (argc == 1) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Layout_setBackGroundImageCapInsets : Error processing arguments"); + cobj->setBackGroundImageCapInsets(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_setBackGroundImageCapInsets : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Layout_getBackGroundImageTextureSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_getBackGroundImageTextureSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getBackGroundImageTextureSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_getBackGroundImageTextureSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Layout_forceDoLayout(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_forceDoLayout : Invalid Native Object"); + if (argc == 0) { + cobj->forceDoLayout(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_forceDoLayout : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Layout_getLayoutType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_getLayoutType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getLayoutType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_getLayoutType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Layout_setPassFocusToChild(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_setPassFocusToChild : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Layout_setPassFocusToChild : Error processing arguments"); + cobj->setPassFocusToChild(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_setPassFocusToChild : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Layout_getBackGroundStartColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_getBackGroundStartColor : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color3B& ret = cobj->getBackGroundStartColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor3b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_getBackGroundStartColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Layout_setBackGroundImageScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_setBackGroundImageScale9Enabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Layout_setBackGroundImageScale9Enabled : Error processing arguments"); + cobj->setBackGroundImageScale9Enabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_setBackGroundImageScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Layout_setLayoutType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Layout* cobj = (cocos2d::ui::Layout *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Layout_setLayoutType : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::Layout::Type arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Layout_setLayoutType : Error processing arguments"); + cobj->setLayoutType(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Layout_setLayoutType : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Layout_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ui::Layout* ret = cocos2d::ui::Layout::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Layout*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_Layout_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_Layout_createInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Ref* ret = cocos2d::ui::Layout::createInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_Layout_createInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_Layout_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::Layout* cobj = new (std::nothrow) cocos2d::ui::Layout(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::Layout"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_Widget_prototype; + +void js_cocos2d_ui_Layout_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Layout)", obj); +} + +static bool js_cocos2d_ui_Layout_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::Layout *nobj = new (std::nothrow) cocos2d::ui::Layout(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::Layout"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_Layout(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_Layout_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_Layout_class->name = "Layout"; + jsb_cocos2d_ui_Layout_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_Layout_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_Layout_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_Layout_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_Layout_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_Layout_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_Layout_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_Layout_class->finalize = js_cocos2d_ui_Layout_finalize; + jsb_cocos2d_ui_Layout_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setBackGroundColorVector", js_cocos2dx_ui_Layout_setBackGroundColorVector, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setClippingType", js_cocos2dx_ui_Layout_setClippingType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBackGroundColorType", js_cocos2dx_ui_Layout_setBackGroundColorType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLoopFocus", js_cocos2dx_ui_Layout_setLoopFocus, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBackGroundImageColor", js_cocos2dx_ui_Layout_setBackGroundImageColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackGroundColorVector", js_cocos2dx_ui_Layout_getBackGroundColorVector, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getClippingType", js_cocos2dx_ui_Layout_getClippingType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isLoopFocus", js_cocos2dx_ui_Layout_isLoopFocus, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeBackGroundImage", js_cocos2dx_ui_Layout_removeBackGroundImage, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackGroundColorOpacity", js_cocos2dx_ui_Layout_getBackGroundColorOpacity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isClippingEnabled", js_cocos2dx_ui_Layout_isClippingEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBackGroundImageOpacity", js_cocos2dx_ui_Layout_setBackGroundImageOpacity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBackGroundImage", js_cocos2dx_ui_Layout_setBackGroundImage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBackGroundColor", js_cocos2dx_ui_Layout_setBackGroundColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("requestDoLayout", js_cocos2dx_ui_Layout_requestDoLayout, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackGroundImageCapInsets", js_cocos2dx_ui_Layout_getBackGroundImageCapInsets, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackGroundColor", js_cocos2dx_ui_Layout_getBackGroundColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setClippingEnabled", js_cocos2dx_ui_Layout_setClippingEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackGroundImageColor", js_cocos2dx_ui_Layout_getBackGroundImageColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isBackGroundImageScale9Enabled", js_cocos2dx_ui_Layout_isBackGroundImageScale9Enabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackGroundColorType", js_cocos2dx_ui_Layout_getBackGroundColorType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackGroundEndColor", js_cocos2dx_ui_Layout_getBackGroundEndColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBackGroundColorOpacity", js_cocos2dx_ui_Layout_setBackGroundColorOpacity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackGroundImageOpacity", js_cocos2dx_ui_Layout_getBackGroundImageOpacity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isPassFocusToChild", js_cocos2dx_ui_Layout_isPassFocusToChild, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBackGroundImageCapInsets", js_cocos2dx_ui_Layout_setBackGroundImageCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackGroundImageTextureSize", js_cocos2dx_ui_Layout_getBackGroundImageTextureSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("forceDoLayout", js_cocos2dx_ui_Layout_forceDoLayout, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLayoutType", js_cocos2dx_ui_Layout_getLayoutType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPassFocusToChild", js_cocos2dx_ui_Layout_setPassFocusToChild, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBackGroundStartColor", js_cocos2dx_ui_Layout_getBackGroundStartColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBackGroundImageScale9Enabled", js_cocos2dx_ui_Layout_setBackGroundImageScale9Enabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLayoutType", js_cocos2dx_ui_Layout_setLayoutType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_Layout_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_Layout_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createInstance", js_cocos2dx_ui_Layout_createInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_Layout_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + jsb_cocos2d_ui_Layout_class, + js_cocos2dx_ui_Layout_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, "Layout", 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_Layout_class; + p->proto = jsb_cocos2d_ui_Layout_prototype; + p->parentProto = jsb_cocos2d_ui_Widget_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_Button_class; +JSObject *jsb_cocos2d_ui_Button_prototype; + +bool js_cocos2dx_ui_Button_getNormalTextureSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_getNormalTextureSize : Invalid Native Object"); + if (argc == 0) { + cocos2d::Size ret = cobj->getNormalTextureSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_getNormalTextureSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Button_getTitleText(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_getTitleText : Invalid Native Object"); + if (argc == 0) { + const std::string ret = cobj->getTitleText(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_getTitleText : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Button_setTitleFontSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_setTitleFontSize : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_setTitleFontSize : Error processing arguments"); + cobj->setTitleFontSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_setTitleFontSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Button_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_setScale9Enabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_setScale9Enabled : Error processing arguments"); + cobj->setScale9Enabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_setScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Button_getTitleRenderer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_getTitleRenderer : Invalid Native Object"); + if (argc == 0) { + cocos2d::Label* ret = cobj->getTitleRenderer(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_getTitleRenderer : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Button_getZoomScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_getZoomScale : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getZoomScale(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_getZoomScale : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Button_getCapInsetsDisabledRenderer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_getCapInsetsDisabledRenderer : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Rect& ret = cobj->getCapInsetsDisabledRenderer(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_getCapInsetsDisabledRenderer : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Button_setTitleColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_setTitleColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color3B arg0; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_setTitleColor : Error processing arguments"); + cobj->setTitleColor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_setTitleColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Button_setCapInsetsDisabledRenderer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_setCapInsetsDisabledRenderer : Invalid Native Object"); + if (argc == 1) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_setCapInsetsDisabledRenderer : Error processing arguments"); + cobj->setCapInsetsDisabledRenderer(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_setCapInsetsDisabledRenderer : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Button_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_setCapInsets : Invalid Native Object"); + if (argc == 1) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_setCapInsets : Error processing arguments"); + cobj->setCapInsets(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_setCapInsets : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Button_loadTextureDisabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_loadTextureDisabled : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_loadTextureDisabled : Error processing arguments"); + cobj->loadTextureDisabled(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_loadTextureDisabled : Error processing arguments"); + cobj->loadTextureDisabled(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_loadTextureDisabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Button_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_init : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_init : Error processing arguments"); + bool ret = cobj->init(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_init : Error processing arguments"); + bool ret = cobj->init(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 3) { + std::string arg0; + std::string arg1; + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_init : Error processing arguments"); + bool ret = cobj->init(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 4) { + std::string arg0; + std::string arg1; + std::string arg2; + cocos2d::ui::Widget::TextureResType arg3; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_init : Error processing arguments"); + bool ret = cobj->init(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_init : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Button_setTitleText(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_setTitleText : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_setTitleText : Error processing arguments"); + cobj->setTitleText(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_setTitleText : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Button_setCapInsetsNormalRenderer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_setCapInsetsNormalRenderer : Invalid Native Object"); + if (argc == 1) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_setCapInsetsNormalRenderer : Error processing arguments"); + cobj->setCapInsetsNormalRenderer(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_setCapInsetsNormalRenderer : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Button_loadTexturePressed(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_loadTexturePressed : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_loadTexturePressed : Error processing arguments"); + cobj->loadTexturePressed(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_loadTexturePressed : Error processing arguments"); + cobj->loadTexturePressed(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_loadTexturePressed : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Button_setTitleFontName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_setTitleFontName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_setTitleFontName : Error processing arguments"); + cobj->setTitleFontName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_setTitleFontName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Button_getCapInsetsNormalRenderer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_getCapInsetsNormalRenderer : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Rect& ret = cobj->getCapInsetsNormalRenderer(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_getCapInsetsNormalRenderer : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Button_getCapInsetsPressedRenderer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_getCapInsetsPressedRenderer : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Rect& ret = cobj->getCapInsetsPressedRenderer(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_getCapInsetsPressedRenderer : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Button_loadTextures(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_loadTextures : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_loadTextures : Error processing arguments"); + cobj->loadTextures(arg0, arg1); + args.rval().setUndefined(); + return true; + } + if (argc == 3) { + std::string arg0; + std::string arg1; + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_loadTextures : Error processing arguments"); + cobj->loadTextures(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + if (argc == 4) { + std::string arg0; + std::string arg1; + std::string arg2; + cocos2d::ui::Widget::TextureResType arg3; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_loadTextures : Error processing arguments"); + cobj->loadTextures(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_loadTextures : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ui_Button_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_isScale9Enabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isScale9Enabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_isScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Button_loadTextureNormal(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_loadTextureNormal : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_loadTextureNormal : Error processing arguments"); + cobj->loadTextureNormal(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_loadTextureNormal : Error processing arguments"); + cobj->loadTextureNormal(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_loadTextureNormal : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Button_setCapInsetsPressedRenderer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_setCapInsetsPressedRenderer : Invalid Native Object"); + if (argc == 1) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_setCapInsetsPressedRenderer : Error processing arguments"); + cobj->setCapInsetsPressedRenderer(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_setCapInsetsPressedRenderer : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Button_getTitleFontSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_getTitleFontSize : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getTitleFontSize(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_getTitleFontSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Button_getTitleFontName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_getTitleFontName : Invalid Native Object"); + if (argc == 0) { + const std::string ret = cobj->getTitleFontName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_getTitleFontName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Button_getTitleColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_getTitleColor : Invalid Native Object"); + if (argc == 0) { + cocos2d::Color3B ret = cobj->getTitleColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor3b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_getTitleColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Button_setPressedActionEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_setPressedActionEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_setPressedActionEnabled : Error processing arguments"); + cobj->setPressedActionEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_setPressedActionEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Button_setZoomScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Button* cobj = (cocos2d::ui::Button *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Button_setZoomScale : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Button_setZoomScale : Error processing arguments"); + cobj->setZoomScale(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Button_setZoomScale : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Button_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::ui::Button* ret = cocos2d::ui::Button::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Button*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::ui::Button* ret = cocos2d::ui::Button::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Button*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cocos2d::ui::Button* ret = cocos2d::ui::Button::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Button*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 4) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + cocos2d::ui::Widget::TextureResType arg3; + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + if (!ok) { ok = true; break; } + cocos2d::ui::Button* ret = cocos2d::ui::Button::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Button*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::ui::Button* ret = cocos2d::ui::Button::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Button*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ui_Button_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_Button_createInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Ref* ret = cocos2d::ui::Button::createInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_Button_createInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_Button_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::Button* cobj = new (std::nothrow) cocos2d::ui::Button(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::Button"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_Widget_prototype; + +void js_cocos2d_ui_Button_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Button)", obj); +} + +static bool js_cocos2d_ui_Button_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::Button *nobj = new (std::nothrow) cocos2d::ui::Button(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::Button"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_Button(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_Button_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_Button_class->name = "Button"; + jsb_cocos2d_ui_Button_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_Button_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_Button_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_Button_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_Button_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_Button_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_Button_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_Button_class->finalize = js_cocos2d_ui_Button_finalize; + jsb_cocos2d_ui_Button_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getNormalTextureSize", js_cocos2dx_ui_Button_getNormalTextureSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTitleText", js_cocos2dx_ui_Button_getTitleText, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTitleFontSize", js_cocos2dx_ui_Button_setTitleFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setScale9Enabled", js_cocos2dx_ui_Button_setScale9Enabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTitleRenderer", js_cocos2dx_ui_Button_getTitleRenderer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getZoomScale", js_cocos2dx_ui_Button_getZoomScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCapInsetsDisabledRenderer", js_cocos2dx_ui_Button_getCapInsetsDisabledRenderer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTitleColor", js_cocos2dx_ui_Button_setTitleColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCapInsetsDisabledRenderer", js_cocos2dx_ui_Button_setCapInsetsDisabledRenderer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCapInsets", js_cocos2dx_ui_Button_setCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadTextureDisabled", js_cocos2dx_ui_Button_loadTextureDisabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_ui_Button_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTitleText", js_cocos2dx_ui_Button_setTitleText, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCapInsetsNormalRenderer", js_cocos2dx_ui_Button_setCapInsetsNormalRenderer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadTexturePressed", js_cocos2dx_ui_Button_loadTexturePressed, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTitleFontName", js_cocos2dx_ui_Button_setTitleFontName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCapInsetsNormalRenderer", js_cocos2dx_ui_Button_getCapInsetsNormalRenderer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCapInsetsPressedRenderer", js_cocos2dx_ui_Button_getCapInsetsPressedRenderer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadTextures", js_cocos2dx_ui_Button_loadTextures, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isScale9Enabled", js_cocos2dx_ui_Button_isScale9Enabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadTextureNormal", js_cocos2dx_ui_Button_loadTextureNormal, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCapInsetsPressedRenderer", js_cocos2dx_ui_Button_setCapInsetsPressedRenderer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTitleFontSize", js_cocos2dx_ui_Button_getTitleFontSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTitleFontName", js_cocos2dx_ui_Button_getTitleFontName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTitleColor", js_cocos2dx_ui_Button_getTitleColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPressedActionEnabled", js_cocos2dx_ui_Button_setPressedActionEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setZoomScale", js_cocos2dx_ui_Button_setZoomScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_Button_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_Button_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createInstance", js_cocos2dx_ui_Button_createInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_Button_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + jsb_cocos2d_ui_Button_class, + js_cocos2dx_ui_Button_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, "Button", 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_Button_class; + p->proto = jsb_cocos2d_ui_Button_prototype; + p->parentProto = jsb_cocos2d_ui_Widget_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_CheckBox_class; +JSObject *jsb_cocos2d_ui_CheckBox_prototype; + +bool js_cocos2dx_ui_CheckBox_loadTextureBackGroundSelected(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::CheckBox* cobj = (cocos2d::ui::CheckBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_CheckBox_loadTextureBackGroundSelected : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_CheckBox_loadTextureBackGroundSelected : Error processing arguments"); + cobj->loadTextureBackGroundSelected(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_CheckBox_loadTextureBackGroundSelected : Error processing arguments"); + cobj->loadTextureBackGroundSelected(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_CheckBox_loadTextureBackGroundSelected : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_CheckBox_loadTextureBackGroundDisabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::CheckBox* cobj = (cocos2d::ui::CheckBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_CheckBox_loadTextureBackGroundDisabled : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_CheckBox_loadTextureBackGroundDisabled : Error processing arguments"); + cobj->loadTextureBackGroundDisabled(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_CheckBox_loadTextureBackGroundDisabled : Error processing arguments"); + cobj->loadTextureBackGroundDisabled(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_CheckBox_loadTextureBackGroundDisabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_CheckBox_setSelected(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::CheckBox* cobj = (cocos2d::ui::CheckBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_CheckBox_setSelected : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_CheckBox_setSelected : Error processing arguments"); + cobj->setSelected(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_CheckBox_setSelected : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_CheckBox_loadTextureFrontCross(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::CheckBox* cobj = (cocos2d::ui::CheckBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_CheckBox_loadTextureFrontCross : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_CheckBox_loadTextureFrontCross : Error processing arguments"); + cobj->loadTextureFrontCross(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_CheckBox_loadTextureFrontCross : Error processing arguments"); + cobj->loadTextureFrontCross(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_CheckBox_loadTextureFrontCross : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_CheckBox_isSelected(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::CheckBox* cobj = (cocos2d::ui::CheckBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_CheckBox_isSelected : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isSelected(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_CheckBox_isSelected : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_CheckBox_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::CheckBox* cobj = (cocos2d::ui::CheckBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_CheckBox_init : Invalid Native Object"); + if (argc == 5) { + std::string arg0; + std::string arg1; + std::string arg2; + std::string arg3; + std::string arg4; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + ok &= jsval_to_std_string(cx, args.get(3), &arg3); + ok &= jsval_to_std_string(cx, args.get(4), &arg4); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_CheckBox_init : Error processing arguments"); + bool ret = cobj->init(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 6) { + std::string arg0; + std::string arg1; + std::string arg2; + std::string arg3; + std::string arg4; + cocos2d::ui::Widget::TextureResType arg5; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + ok &= jsval_to_std_string(cx, args.get(3), &arg3); + ok &= jsval_to_std_string(cx, args.get(4), &arg4); + ok &= jsval_to_int32(cx, args.get(5), (int32_t *)&arg5); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_CheckBox_init : Error processing arguments"); + bool ret = cobj->init(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_CheckBox_init : wrong number of arguments: %d, was expecting %d", argc, 5); + return false; +} +bool js_cocos2dx_ui_CheckBox_loadTextures(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::CheckBox* cobj = (cocos2d::ui::CheckBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_CheckBox_loadTextures : Invalid Native Object"); + if (argc == 5) { + std::string arg0; + std::string arg1; + std::string arg2; + std::string arg3; + std::string arg4; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + ok &= jsval_to_std_string(cx, args.get(3), &arg3); + ok &= jsval_to_std_string(cx, args.get(4), &arg4); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_CheckBox_loadTextures : Error processing arguments"); + cobj->loadTextures(arg0, arg1, arg2, arg3, arg4); + args.rval().setUndefined(); + return true; + } + if (argc == 6) { + std::string arg0; + std::string arg1; + std::string arg2; + std::string arg3; + std::string arg4; + cocos2d::ui::Widget::TextureResType arg5; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + ok &= jsval_to_std_string(cx, args.get(3), &arg3); + ok &= jsval_to_std_string(cx, args.get(4), &arg4); + ok &= jsval_to_int32(cx, args.get(5), (int32_t *)&arg5); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_CheckBox_loadTextures : Error processing arguments"); + cobj->loadTextures(arg0, arg1, arg2, arg3, arg4, arg5); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_CheckBox_loadTextures : wrong number of arguments: %d, was expecting %d", argc, 5); + return false; +} +bool js_cocos2dx_ui_CheckBox_getZoomScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::CheckBox* cobj = (cocos2d::ui::CheckBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_CheckBox_getZoomScale : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getZoomScale(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_CheckBox_getZoomScale : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_CheckBox_loadTextureBackGround(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::CheckBox* cobj = (cocos2d::ui::CheckBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_CheckBox_loadTextureBackGround : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_CheckBox_loadTextureBackGround : Error processing arguments"); + cobj->loadTextureBackGround(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_CheckBox_loadTextureBackGround : Error processing arguments"); + cobj->loadTextureBackGround(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_CheckBox_loadTextureBackGround : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_CheckBox_setZoomScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::CheckBox* cobj = (cocos2d::ui::CheckBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_CheckBox_setZoomScale : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_CheckBox_setZoomScale : Error processing arguments"); + cobj->setZoomScale(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_CheckBox_setZoomScale : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_CheckBox_loadTextureFrontCrossDisabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::CheckBox* cobj = (cocos2d::ui::CheckBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_CheckBox_loadTextureFrontCrossDisabled : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_CheckBox_loadTextureFrontCrossDisabled : Error processing arguments"); + cobj->loadTextureFrontCrossDisabled(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_CheckBox_loadTextureFrontCrossDisabled : Error processing arguments"); + cobj->loadTextureFrontCrossDisabled(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_CheckBox_loadTextureFrontCrossDisabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_CheckBox_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 5) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + std::string arg3; + ok &= jsval_to_std_string(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + std::string arg4; + ok &= jsval_to_std_string(cx, args.get(4), &arg4); + if (!ok) { ok = true; break; } + cocos2d::ui::CheckBox* ret = cocos2d::ui::CheckBox::create(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::CheckBox*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 6) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + std::string arg3; + ok &= jsval_to_std_string(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + std::string arg4; + ok &= jsval_to_std_string(cx, args.get(4), &arg4); + if (!ok) { ok = true; break; } + cocos2d::ui::Widget::TextureResType arg5; + ok &= jsval_to_int32(cx, args.get(5), (int32_t *)&arg5); + if (!ok) { ok = true; break; } + cocos2d::ui::CheckBox* ret = cocos2d::ui::CheckBox::create(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::CheckBox*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::ui::CheckBox* ret = cocos2d::ui::CheckBox::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::CheckBox*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::ui::CheckBox* ret = cocos2d::ui::CheckBox::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::CheckBox*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::ui::Widget::TextureResType arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + cocos2d::ui::CheckBox* ret = cocos2d::ui::CheckBox::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::CheckBox*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ui_CheckBox_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_CheckBox_createInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Ref* ret = cocos2d::ui::CheckBox::createInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_CheckBox_createInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_CheckBox_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::CheckBox* cobj = new (std::nothrow) cocos2d::ui::CheckBox(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::CheckBox"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_Widget_prototype; + +void js_cocos2d_ui_CheckBox_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (CheckBox)", obj); +} + +static bool js_cocos2d_ui_CheckBox_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::CheckBox *nobj = new (std::nothrow) cocos2d::ui::CheckBox(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::CheckBox"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_CheckBox(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_CheckBox_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_CheckBox_class->name = "CheckBox"; + jsb_cocos2d_ui_CheckBox_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_CheckBox_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_CheckBox_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_CheckBox_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_CheckBox_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_CheckBox_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_CheckBox_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_CheckBox_class->finalize = js_cocos2d_ui_CheckBox_finalize; + jsb_cocos2d_ui_CheckBox_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("loadTextureBackGroundSelected", js_cocos2dx_ui_CheckBox_loadTextureBackGroundSelected, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadTextureBackGroundDisabled", js_cocos2dx_ui_CheckBox_loadTextureBackGroundDisabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSelected", js_cocos2dx_ui_CheckBox_setSelected, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadTextureFrontCross", js_cocos2dx_ui_CheckBox_loadTextureFrontCross, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isSelected", js_cocos2dx_ui_CheckBox_isSelected, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_ui_CheckBox_init, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadTextures", js_cocos2dx_ui_CheckBox_loadTextures, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getZoomScale", js_cocos2dx_ui_CheckBox_getZoomScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadTextureBackGround", js_cocos2dx_ui_CheckBox_loadTextureBackGround, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setZoomScale", js_cocos2dx_ui_CheckBox_setZoomScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadTextureFrontCrossDisabled", js_cocos2dx_ui_CheckBox_loadTextureFrontCrossDisabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_CheckBox_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_CheckBox_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createInstance", js_cocos2dx_ui_CheckBox_createInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_CheckBox_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + jsb_cocos2d_ui_CheckBox_class, + js_cocos2dx_ui_CheckBox_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, "CheckBox", 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_CheckBox_class; + p->proto = jsb_cocos2d_ui_CheckBox_prototype; + p->parentProto = jsb_cocos2d_ui_Widget_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_ImageView_class; +JSObject *jsb_cocos2d_ui_ImageView_prototype; + +bool js_cocos2dx_ui_ImageView_loadTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ImageView* cobj = (cocos2d::ui::ImageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ImageView_loadTexture : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ImageView_loadTexture : Error processing arguments"); + cobj->loadTexture(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ImageView_loadTexture : Error processing arguments"); + cobj->loadTexture(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ImageView_loadTexture : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ImageView_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ImageView* cobj = (cocos2d::ui::ImageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ImageView_init : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ImageView_init : Error processing arguments"); + bool ret = cobj->init(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ImageView_init : Error processing arguments"); + bool ret = cobj->init(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ImageView_init : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ImageView_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ImageView* cobj = (cocos2d::ui::ImageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ImageView_setScale9Enabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ImageView_setScale9Enabled : Error processing arguments"); + cobj->setScale9Enabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ImageView_setScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ImageView_setTextureRect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ImageView* cobj = (cocos2d::ui::ImageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ImageView_setTextureRect : Invalid Native Object"); + if (argc == 1) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ImageView_setTextureRect : Error processing arguments"); + cobj->setTextureRect(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ImageView_setTextureRect : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ImageView_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ImageView* cobj = (cocos2d::ui::ImageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ImageView_setCapInsets : Invalid Native Object"); + if (argc == 1) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ImageView_setCapInsets : Error processing arguments"); + cobj->setCapInsets(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ImageView_setCapInsets : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ImageView_getCapInsets(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ImageView* cobj = (cocos2d::ui::ImageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ImageView_getCapInsets : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Rect& ret = cobj->getCapInsets(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ImageView_getCapInsets : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ImageView_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ImageView* cobj = (cocos2d::ui::ImageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ImageView_isScale9Enabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isScale9Enabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ImageView_isScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ImageView_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::ui::ImageView* ret = cocos2d::ui::ImageView::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::ImageView*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cocos2d::ui::ImageView* ret = cocos2d::ui::ImageView::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::ImageView*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::ui::ImageView* ret = cocos2d::ui::ImageView::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::ImageView*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ui_ImageView_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_ImageView_createInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Ref* ret = cocos2d::ui::ImageView::createInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_ImageView_createInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_ImageView_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::ImageView* cobj = new (std::nothrow) cocos2d::ui::ImageView(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::ImageView"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_Widget_prototype; + +void js_cocos2d_ui_ImageView_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ImageView)", obj); +} + +static bool js_cocos2d_ui_ImageView_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::ImageView *nobj = new (std::nothrow) cocos2d::ui::ImageView(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::ImageView"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_ImageView(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_ImageView_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_ImageView_class->name = "ImageView"; + jsb_cocos2d_ui_ImageView_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_ImageView_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_ImageView_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_ImageView_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_ImageView_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_ImageView_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_ImageView_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_ImageView_class->finalize = js_cocos2d_ui_ImageView_finalize; + jsb_cocos2d_ui_ImageView_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("loadTexture", js_cocos2dx_ui_ImageView_loadTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("_init", js_cocos2dx_ui_ImageView_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setScale9Enabled", js_cocos2dx_ui_ImageView_setScale9Enabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTextureRect", js_cocos2dx_ui_ImageView_setTextureRect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCapInsets", js_cocos2dx_ui_ImageView_setCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCapInsets", js_cocos2dx_ui_ImageView_getCapInsets, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isScale9Enabled", js_cocos2dx_ui_ImageView_isScale9Enabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_ImageView_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_ImageView_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createInstance", js_cocos2dx_ui_ImageView_createInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_ImageView_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + jsb_cocos2d_ui_ImageView_class, + js_cocos2dx_ui_ImageView_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, "ImageView", 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_ImageView_class; + p->proto = jsb_cocos2d_ui_ImageView_prototype; + p->parentProto = jsb_cocos2d_ui_Widget_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_Text_class; +JSObject *jsb_cocos2d_ui_Text_prototype; + +bool js_cocos2dx_ui_Text_enableShadow(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_enableShadow : Invalid Native Object"); + if (argc == 0) { + cobj->enableShadow(); + args.rval().setUndefined(); + return true; + } + if (argc == 1) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Text_enableShadow : Error processing arguments"); + cobj->enableShadow(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + cocos2d::Color4B arg0; + cocos2d::Size arg1; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Text_enableShadow : Error processing arguments"); + cobj->enableShadow(arg0, arg1); + args.rval().setUndefined(); + return true; + } + if (argc == 3) { + cocos2d::Color4B arg0; + cocos2d::Size arg1; + int arg2; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Text_enableShadow : Error processing arguments"); + cobj->enableShadow(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_enableShadow : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Text_getFontSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_getFontSize : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getFontSize(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_getFontSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Text_getString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_getString : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getString(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_getString : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Text_disableEffect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ui::Text* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_disableEffect : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::LabelEffect arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + cobj->disableEffect(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 0) { + cobj->disableEffect(); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ui_Text_disableEffect : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_Text_getTextColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_getTextColor : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color4B& ret = cobj->getTextColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor4b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_getTextColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Text_setTextVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_setTextVerticalAlignment : Invalid Native Object"); + if (argc == 1) { + cocos2d::TextVAlignment arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Text_setTextVerticalAlignment : Error processing arguments"); + cobj->setTextVerticalAlignment(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_setTextVerticalAlignment : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Text_setFontName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_setFontName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Text_setFontName : Error processing arguments"); + cobj->setFontName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_setFontName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Text_setTouchScaleChangeEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_setTouchScaleChangeEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Text_setTouchScaleChangeEnabled : Error processing arguments"); + cobj->setTouchScaleChangeEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_setTouchScaleChangeEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Text_setString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_setString : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Text_setString : Error processing arguments"); + cobj->setString(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_setString : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Text_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_init : Invalid Native Object"); + if (argc == 3) { + std::string arg0; + std::string arg1; + int arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Text_init : Error processing arguments"); + bool ret = cobj->init(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_init : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_ui_Text_isTouchScaleChangeEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_isTouchScaleChangeEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isTouchScaleChangeEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_isTouchScaleChangeEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Text_getFontName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_getFontName : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getFontName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_getFontName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Text_setTextAreaSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_setTextAreaSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Text_setTextAreaSize : Error processing arguments"); + cobj->setTextAreaSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_setTextAreaSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Text_getStringLength(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_getStringLength : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getStringLength(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_getStringLength : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Text_getAutoRenderSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_getAutoRenderSize : Invalid Native Object"); + if (argc == 0) { + cocos2d::Size ret = cobj->getAutoRenderSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_getAutoRenderSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Text_enableOutline(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_enableOutline : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Text_enableOutline : Error processing arguments"); + cobj->enableOutline(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + cocos2d::Color4B arg0; + int arg1; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Text_enableOutline : Error processing arguments"); + cobj->enableOutline(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_enableOutline : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Text_getType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_getType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_getType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Text_getTextHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_getTextHorizontalAlignment : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getTextHorizontalAlignment(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_getTextHorizontalAlignment : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Text_setFontSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_setFontSize : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Text_setFontSize : Error processing arguments"); + cobj->setFontSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_setFontSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Text_setTextColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_setTextColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Text_setTextColor : Error processing arguments"); + cobj->setTextColor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_setTextColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Text_enableGlow(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_enableGlow : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Text_enableGlow : Error processing arguments"); + cobj->enableGlow(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_enableGlow : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Text_getTextVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_getTextVerticalAlignment : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getTextVerticalAlignment(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_getTextVerticalAlignment : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Text_getTextAreaSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_getTextAreaSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getTextAreaSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_getTextAreaSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Text_setTextHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_setTextHorizontalAlignment : Invalid Native Object"); + if (argc == 1) { + cocos2d::TextHAlignment arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Text_setTextHorizontalAlignment : Error processing arguments"); + cobj->setTextHorizontalAlignment(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_setTextHorizontalAlignment : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Text_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + int arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + cocos2d::ui::Text* ret = cocos2d::ui::Text::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Text*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::ui::Text* ret = cocos2d::ui::Text::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Text*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ui_Text_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_Text_createInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Ref* ret = cocos2d::ui::Text::createInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_Text_createInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_Text_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::Text* cobj = new (std::nothrow) cocos2d::ui::Text(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::Text"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_Widget_prototype; + +void js_cocos2d_ui_Text_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Text)", obj); +} + +static bool js_cocos2d_ui_Text_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::Text *nobj = new (std::nothrow) cocos2d::ui::Text(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::Text"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_Text(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_Text_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_Text_class->name = "Text"; + jsb_cocos2d_ui_Text_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_Text_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_Text_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_Text_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_Text_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_Text_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_Text_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_Text_class->finalize = js_cocos2d_ui_Text_finalize; + jsb_cocos2d_ui_Text_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("enableShadow", js_cocos2dx_ui_Text_enableShadow, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFontSize", js_cocos2dx_ui_Text_getFontSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getString", js_cocos2dx_ui_Text_getString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("disableEffect", js_cocos2dx_ui_Text_disableEffect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTextColor", js_cocos2dx_ui_Text_getTextColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTextVerticalAlignment", js_cocos2dx_ui_Text_setTextVerticalAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFontName", js_cocos2dx_ui_Text_setFontName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTouchScaleChangeEnabled", js_cocos2dx_ui_Text_setTouchScaleChangeEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setString", js_cocos2dx_ui_Text_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_ui_Text_init, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isTouchScaleChangeEnabled", js_cocos2dx_ui_Text_isTouchScaleChangeEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFontName", js_cocos2dx_ui_Text_getFontName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTextAreaSize", js_cocos2dx_ui_Text_setTextAreaSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStringLength", js_cocos2dx_ui_Text_getStringLength, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAutoRenderSize", js_cocos2dx_ui_Text_getAutoRenderSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("enableOutline", js_cocos2dx_ui_Text_enableOutline, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getType", js_cocos2dx_ui_Text_getType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTextHorizontalAlignment", js_cocos2dx_ui_Text_getTextHorizontalAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFontSize", js_cocos2dx_ui_Text_setFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTextColor", js_cocos2dx_ui_Text_setTextColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("enableGlow", js_cocos2dx_ui_Text_enableGlow, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTextVerticalAlignment", js_cocos2dx_ui_Text_getTextVerticalAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTextAreaSize", js_cocos2dx_ui_Text_getTextAreaSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTextHorizontalAlignment", js_cocos2dx_ui_Text_setTextHorizontalAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_Text_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_Text_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createInstance", js_cocos2dx_ui_Text_createInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_Text_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + jsb_cocos2d_ui_Text_class, + js_cocos2dx_ui_Text_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, "Text", 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_Text_class; + p->proto = jsb_cocos2d_ui_Text_prototype; + p->parentProto = jsb_cocos2d_ui_Widget_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_TextAtlas_class; +JSObject *jsb_cocos2d_ui_TextAtlas_prototype; + +bool js_cocos2dx_ui_TextAtlas_getStringLength(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextAtlas* cobj = (cocos2d::ui::TextAtlas *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextAtlas_getStringLength : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getStringLength(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextAtlas_getStringLength : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextAtlas_getString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextAtlas* cobj = (cocos2d::ui::TextAtlas *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextAtlas_getString : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getString(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextAtlas_getString : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextAtlas_setString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextAtlas* cobj = (cocos2d::ui::TextAtlas *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextAtlas_setString : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextAtlas_setString : Error processing arguments"); + cobj->setString(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextAtlas_setString : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextAtlas_setProperty(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextAtlas* cobj = (cocos2d::ui::TextAtlas *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextAtlas_setProperty : Invalid Native Object"); + if (argc == 5) { + std::string arg0; + std::string arg1; + int arg2; + int arg3; + std::string arg4; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + ok &= jsval_to_std_string(cx, args.get(4), &arg4); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextAtlas_setProperty : Error processing arguments"); + cobj->setProperty(arg0, arg1, arg2, arg3, arg4); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextAtlas_setProperty : wrong number of arguments: %d, was expecting %d", argc, 5); + return false; +} +bool js_cocos2dx_ui_TextAtlas_adaptRenderers(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextAtlas* cobj = (cocos2d::ui::TextAtlas *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextAtlas_adaptRenderers : Invalid Native Object"); + if (argc == 0) { + cobj->adaptRenderers(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextAtlas_adaptRenderers : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextAtlas_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 5) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + int arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + int arg3; + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + if (!ok) { ok = true; break; } + std::string arg4; + ok &= jsval_to_std_string(cx, args.get(4), &arg4); + if (!ok) { ok = true; break; } + cocos2d::ui::TextAtlas* ret = cocos2d::ui::TextAtlas::create(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::TextAtlas*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::ui::TextAtlas* ret = cocos2d::ui::TextAtlas::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::TextAtlas*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ui_TextAtlas_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_TextAtlas_createInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Ref* ret = cocos2d::ui::TextAtlas::createInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_TextAtlas_createInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_TextAtlas_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::TextAtlas* cobj = new (std::nothrow) cocos2d::ui::TextAtlas(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::TextAtlas"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_Widget_prototype; + +void js_cocos2d_ui_TextAtlas_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TextAtlas)", obj); +} + +static bool js_cocos2d_ui_TextAtlas_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::TextAtlas *nobj = new (std::nothrow) cocos2d::ui::TextAtlas(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::TextAtlas"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_TextAtlas(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_TextAtlas_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_TextAtlas_class->name = "TextAtlas"; + jsb_cocos2d_ui_TextAtlas_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_TextAtlas_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_TextAtlas_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_TextAtlas_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_TextAtlas_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_TextAtlas_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_TextAtlas_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_TextAtlas_class->finalize = js_cocos2d_ui_TextAtlas_finalize; + jsb_cocos2d_ui_TextAtlas_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getStringLength", js_cocos2dx_ui_TextAtlas_getStringLength, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getString", js_cocos2dx_ui_TextAtlas_getString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setString", js_cocos2dx_ui_TextAtlas_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setProperty", js_cocos2dx_ui_TextAtlas_setProperty, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("adaptRenderers", js_cocos2dx_ui_TextAtlas_adaptRenderers, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_TextAtlas_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_TextAtlas_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createInstance", js_cocos2dx_ui_TextAtlas_createInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_TextAtlas_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + jsb_cocos2d_ui_TextAtlas_class, + js_cocos2dx_ui_TextAtlas_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, "TextAtlas", 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_TextAtlas_class; + p->proto = jsb_cocos2d_ui_TextAtlas_prototype; + p->parentProto = jsb_cocos2d_ui_Widget_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_LoadingBar_class; +JSObject *jsb_cocos2d_ui_LoadingBar_prototype; + +bool js_cocos2dx_ui_LoadingBar_setPercent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LoadingBar* cobj = (cocos2d::ui::LoadingBar *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LoadingBar_setPercent : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LoadingBar_setPercent : Error processing arguments"); + cobj->setPercent(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LoadingBar_setPercent : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LoadingBar_loadTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LoadingBar* cobj = (cocos2d::ui::LoadingBar *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LoadingBar_loadTexture : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LoadingBar_loadTexture : Error processing arguments"); + cobj->loadTexture(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LoadingBar_loadTexture : Error processing arguments"); + cobj->loadTexture(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LoadingBar_loadTexture : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LoadingBar_setDirection(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LoadingBar* cobj = (cocos2d::ui::LoadingBar *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LoadingBar_setDirection : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::LoadingBar::Direction arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LoadingBar_setDirection : Error processing arguments"); + cobj->setDirection(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LoadingBar_setDirection : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LoadingBar_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LoadingBar* cobj = (cocos2d::ui::LoadingBar *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LoadingBar_setScale9Enabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LoadingBar_setScale9Enabled : Error processing arguments"); + cobj->setScale9Enabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LoadingBar_setScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LoadingBar_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LoadingBar* cobj = (cocos2d::ui::LoadingBar *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LoadingBar_setCapInsets : Invalid Native Object"); + if (argc == 1) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LoadingBar_setCapInsets : Error processing arguments"); + cobj->setCapInsets(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LoadingBar_setCapInsets : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LoadingBar_getDirection(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LoadingBar* cobj = (cocos2d::ui::LoadingBar *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LoadingBar_getDirection : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getDirection(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LoadingBar_getDirection : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LoadingBar_getCapInsets(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LoadingBar* cobj = (cocos2d::ui::LoadingBar *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LoadingBar_getCapInsets : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Rect& ret = cobj->getCapInsets(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LoadingBar_getCapInsets : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LoadingBar_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LoadingBar* cobj = (cocos2d::ui::LoadingBar *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LoadingBar_isScale9Enabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isScale9Enabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LoadingBar_isScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LoadingBar_getPercent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LoadingBar* cobj = (cocos2d::ui::LoadingBar *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LoadingBar_getPercent : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getPercent(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LoadingBar_getPercent : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LoadingBar_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::ui::LoadingBar* ret = cocos2d::ui::LoadingBar::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::LoadingBar*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + if (!ok) { ok = true; break; } + cocos2d::ui::LoadingBar* ret = cocos2d::ui::LoadingBar::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::LoadingBar*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::ui::LoadingBar* ret = cocos2d::ui::LoadingBar::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::LoadingBar*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cocos2d::ui::LoadingBar* ret = cocos2d::ui::LoadingBar::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::LoadingBar*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + double arg2; + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + if (!ok) { ok = true; break; } + cocos2d::ui::LoadingBar* ret = cocos2d::ui::LoadingBar::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::LoadingBar*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ui_LoadingBar_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_LoadingBar_createInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Ref* ret = cocos2d::ui::LoadingBar::createInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_LoadingBar_createInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_LoadingBar_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::LoadingBar* cobj = new (std::nothrow) cocos2d::ui::LoadingBar(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::LoadingBar"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_Widget_prototype; + +void js_cocos2d_ui_LoadingBar_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (LoadingBar)", obj); +} + +static bool js_cocos2d_ui_LoadingBar_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::LoadingBar *nobj = new (std::nothrow) cocos2d::ui::LoadingBar(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::LoadingBar"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_LoadingBar(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_LoadingBar_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_LoadingBar_class->name = "LoadingBar"; + jsb_cocos2d_ui_LoadingBar_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_LoadingBar_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_LoadingBar_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_LoadingBar_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_LoadingBar_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_LoadingBar_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_LoadingBar_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_LoadingBar_class->finalize = js_cocos2d_ui_LoadingBar_finalize; + jsb_cocos2d_ui_LoadingBar_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setPercent", js_cocos2dx_ui_LoadingBar_setPercent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadTexture", js_cocos2dx_ui_LoadingBar_loadTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDirection", js_cocos2dx_ui_LoadingBar_setDirection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setScale9Enabled", js_cocos2dx_ui_LoadingBar_setScale9Enabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCapInsets", js_cocos2dx_ui_LoadingBar_setCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDirection", js_cocos2dx_ui_LoadingBar_getDirection, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCapInsets", js_cocos2dx_ui_LoadingBar_getCapInsets, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isScale9Enabled", js_cocos2dx_ui_LoadingBar_isScale9Enabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPercent", js_cocos2dx_ui_LoadingBar_getPercent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_LoadingBar_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_LoadingBar_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createInstance", js_cocos2dx_ui_LoadingBar_createInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_LoadingBar_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + jsb_cocos2d_ui_LoadingBar_class, + js_cocos2dx_ui_LoadingBar_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, "LoadingBar", 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_LoadingBar_class; + p->proto = jsb_cocos2d_ui_LoadingBar_prototype; + p->parentProto = jsb_cocos2d_ui_Widget_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_ScrollView_class; +JSObject *jsb_cocos2d_ui_ScrollView_prototype; + +bool js_cocos2dx_ui_ScrollView_scrollToTop(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_scrollToTop : Invalid Native Object"); + if (argc == 2) { + double arg0; + bool arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_scrollToTop : Error processing arguments"); + cobj->scrollToTop(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_scrollToTop : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ui_ScrollView_scrollToPercentHorizontal(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_scrollToPercentHorizontal : Invalid Native Object"); + if (argc == 3) { + double arg0; + double arg1; + bool arg2; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + arg2 = JS::ToBoolean(args.get(2)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_scrollToPercentHorizontal : Error processing arguments"); + cobj->scrollToPercentHorizontal(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_scrollToPercentHorizontal : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_ui_ScrollView_isInertiaScrollEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_isInertiaScrollEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isInertiaScrollEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_isInertiaScrollEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ScrollView_scrollToPercentBothDirection(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_scrollToPercentBothDirection : Invalid Native Object"); + if (argc == 3) { + cocos2d::Vec2 arg0; + double arg1; + bool arg2; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + arg2 = JS::ToBoolean(args.get(2)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_scrollToPercentBothDirection : Error processing arguments"); + cobj->scrollToPercentBothDirection(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_scrollToPercentBothDirection : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_ui_ScrollView_getDirection(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_getDirection : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getDirection(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_getDirection : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ScrollView_scrollToBottomLeft(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_scrollToBottomLeft : Invalid Native Object"); + if (argc == 2) { + double arg0; + bool arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_scrollToBottomLeft : Error processing arguments"); + cobj->scrollToBottomLeft(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_scrollToBottomLeft : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ui_ScrollView_getInnerContainer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_getInnerContainer : Invalid Native Object"); + if (argc == 0) { + cocos2d::ui::Layout* ret = cobj->getInnerContainer(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Layout*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_getInnerContainer : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ScrollView_jumpToBottom(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_jumpToBottom : Invalid Native Object"); + if (argc == 0) { + cobj->jumpToBottom(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_jumpToBottom : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ScrollView_setDirection(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_setDirection : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::ScrollView::Direction arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_setDirection : Error processing arguments"); + cobj->setDirection(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_setDirection : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ScrollView_scrollToTopLeft(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_scrollToTopLeft : Invalid Native Object"); + if (argc == 2) { + double arg0; + bool arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_scrollToTopLeft : Error processing arguments"); + cobj->scrollToTopLeft(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_scrollToTopLeft : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ui_ScrollView_jumpToTopRight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_jumpToTopRight : Invalid Native Object"); + if (argc == 0) { + cobj->jumpToTopRight(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_jumpToTopRight : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ScrollView_jumpToBottomLeft(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_jumpToBottomLeft : Invalid Native Object"); + if (argc == 0) { + cobj->jumpToBottomLeft(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_jumpToBottomLeft : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ScrollView_setInnerContainerSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_setInnerContainerSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_setInnerContainerSize : Error processing arguments"); + cobj->setInnerContainerSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_setInnerContainerSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ScrollView_getInnerContainerSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_getInnerContainerSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getInnerContainerSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_getInnerContainerSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ScrollView_isBounceEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_isBounceEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isBounceEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_isBounceEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ScrollView_jumpToPercentVertical(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_jumpToPercentVertical : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_jumpToPercentVertical : Error processing arguments"); + cobj->jumpToPercentVertical(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_jumpToPercentVertical : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ScrollView_setInertiaScrollEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_setInertiaScrollEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_setInertiaScrollEnabled : Error processing arguments"); + cobj->setInertiaScrollEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_setInertiaScrollEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ScrollView_jumpToTopLeft(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_jumpToTopLeft : Invalid Native Object"); + if (argc == 0) { + cobj->jumpToTopLeft(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_jumpToTopLeft : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ScrollView_jumpToPercentHorizontal(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_jumpToPercentHorizontal : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_jumpToPercentHorizontal : Error processing arguments"); + cobj->jumpToPercentHorizontal(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_jumpToPercentHorizontal : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ScrollView_jumpToBottomRight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_jumpToBottomRight : Invalid Native Object"); + if (argc == 0) { + cobj->jumpToBottomRight(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_jumpToBottomRight : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ScrollView_setBounceEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_setBounceEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_setBounceEnabled : Error processing arguments"); + cobj->setBounceEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_setBounceEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ScrollView_jumpToTop(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_jumpToTop : Invalid Native Object"); + if (argc == 0) { + cobj->jumpToTop(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_jumpToTop : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ScrollView_scrollToLeft(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_scrollToLeft : Invalid Native Object"); + if (argc == 2) { + double arg0; + bool arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_scrollToLeft : Error processing arguments"); + cobj->scrollToLeft(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_scrollToLeft : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ui_ScrollView_jumpToPercentBothDirection(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_jumpToPercentBothDirection : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_jumpToPercentBothDirection : Error processing arguments"); + cobj->jumpToPercentBothDirection(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_jumpToPercentBothDirection : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ScrollView_scrollToPercentVertical(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_scrollToPercentVertical : Invalid Native Object"); + if (argc == 3) { + double arg0; + double arg1; + bool arg2; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + ok &= JS::ToNumber( cx, args.get(1), &arg1) && !isnan(arg1); + arg2 = JS::ToBoolean(args.get(2)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_scrollToPercentVertical : Error processing arguments"); + cobj->scrollToPercentVertical(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_scrollToPercentVertical : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_ui_ScrollView_scrollToBottom(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_scrollToBottom : Invalid Native Object"); + if (argc == 2) { + double arg0; + bool arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_scrollToBottom : Error processing arguments"); + cobj->scrollToBottom(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_scrollToBottom : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ui_ScrollView_scrollToBottomRight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_scrollToBottomRight : Invalid Native Object"); + if (argc == 2) { + double arg0; + bool arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_scrollToBottomRight : Error processing arguments"); + cobj->scrollToBottomRight(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_scrollToBottomRight : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ui_ScrollView_jumpToLeft(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_jumpToLeft : Invalid Native Object"); + if (argc == 0) { + cobj->jumpToLeft(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_jumpToLeft : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ScrollView_scrollToRight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_scrollToRight : Invalid Native Object"); + if (argc == 2) { + double arg0; + bool arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_scrollToRight : Error processing arguments"); + cobj->scrollToRight(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_scrollToRight : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ui_ScrollView_jumpToRight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_jumpToRight : Invalid Native Object"); + if (argc == 0) { + cobj->jumpToRight(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_jumpToRight : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ScrollView_scrollToTopRight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ScrollView* cobj = (cocos2d::ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ScrollView_scrollToTopRight : Invalid Native Object"); + if (argc == 2) { + double arg0; + bool arg1; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ScrollView_scrollToTopRight : Error processing arguments"); + cobj->scrollToTopRight(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_scrollToTopRight : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ui_ScrollView_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ui::ScrollView* ret = cocos2d::ui::ScrollView::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::ScrollView*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_ScrollView_createInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Ref* ret = cocos2d::ui::ScrollView::createInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_ScrollView_createInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_ScrollView_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::ScrollView* cobj = new (std::nothrow) cocos2d::ui::ScrollView(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::ScrollView"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_Layout_prototype; + +void js_cocos2d_ui_ScrollView_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ScrollView)", obj); +} + +static bool js_cocos2d_ui_ScrollView_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::ScrollView *nobj = new (std::nothrow) cocos2d::ui::ScrollView(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::ScrollView"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_ScrollView(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_ScrollView_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_ScrollView_class->name = "ScrollView"; + jsb_cocos2d_ui_ScrollView_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_ScrollView_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_ScrollView_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_ScrollView_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_ScrollView_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_ScrollView_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_ScrollView_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_ScrollView_class->finalize = js_cocos2d_ui_ScrollView_finalize; + jsb_cocos2d_ui_ScrollView_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("scrollToTop", js_cocos2dx_ui_ScrollView_scrollToTop, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("scrollToPercentHorizontal", js_cocos2dx_ui_ScrollView_scrollToPercentHorizontal, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isInertiaScrollEnabled", js_cocos2dx_ui_ScrollView_isInertiaScrollEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("scrollToPercentBothDirection", js_cocos2dx_ui_ScrollView_scrollToPercentBothDirection, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDirection", js_cocos2dx_ui_ScrollView_getDirection, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("scrollToBottomLeft", js_cocos2dx_ui_ScrollView_scrollToBottomLeft, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInnerContainer", js_cocos2dx_ui_ScrollView_getInnerContainer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("jumpToBottom", js_cocos2dx_ui_ScrollView_jumpToBottom, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDirection", js_cocos2dx_ui_ScrollView_setDirection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("scrollToTopLeft", js_cocos2dx_ui_ScrollView_scrollToTopLeft, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("jumpToTopRight", js_cocos2dx_ui_ScrollView_jumpToTopRight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("jumpToBottomLeft", js_cocos2dx_ui_ScrollView_jumpToBottomLeft, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setInnerContainerSize", js_cocos2dx_ui_ScrollView_setInnerContainerSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInnerContainerSize", js_cocos2dx_ui_ScrollView_getInnerContainerSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isBounceEnabled", js_cocos2dx_ui_ScrollView_isBounceEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("jumpToPercentVertical", js_cocos2dx_ui_ScrollView_jumpToPercentVertical, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setInertiaScrollEnabled", js_cocos2dx_ui_ScrollView_setInertiaScrollEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("jumpToTopLeft", js_cocos2dx_ui_ScrollView_jumpToTopLeft, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("jumpToPercentHorizontal", js_cocos2dx_ui_ScrollView_jumpToPercentHorizontal, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("jumpToBottomRight", js_cocos2dx_ui_ScrollView_jumpToBottomRight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBounceEnabled", js_cocos2dx_ui_ScrollView_setBounceEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("jumpToTop", js_cocos2dx_ui_ScrollView_jumpToTop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("scrollToLeft", js_cocos2dx_ui_ScrollView_scrollToLeft, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("jumpToPercentBothDirection", js_cocos2dx_ui_ScrollView_jumpToPercentBothDirection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("scrollToPercentVertical", js_cocos2dx_ui_ScrollView_scrollToPercentVertical, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("scrollToBottom", js_cocos2dx_ui_ScrollView_scrollToBottom, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("scrollToBottomRight", js_cocos2dx_ui_ScrollView_scrollToBottomRight, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("jumpToLeft", js_cocos2dx_ui_ScrollView_jumpToLeft, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("scrollToRight", js_cocos2dx_ui_ScrollView_scrollToRight, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("jumpToRight", js_cocos2dx_ui_ScrollView_jumpToRight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("scrollToTopRight", js_cocos2dx_ui_ScrollView_scrollToTopRight, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_ScrollView_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_ScrollView_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createInstance", js_cocos2dx_ui_ScrollView_createInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_ScrollView_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_Layout_prototype), + jsb_cocos2d_ui_ScrollView_class, + js_cocos2dx_ui_ScrollView_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, "ScrollView", 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_ScrollView_class; + p->proto = jsb_cocos2d_ui_ScrollView_prototype; + p->parentProto = jsb_cocos2d_ui_Layout_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_ListView_class; +JSObject *jsb_cocos2d_ui_ListView_prototype; + +bool js_cocos2dx_ui_ListView_getIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_getIndex : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::Widget* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ListView_getIndex : Error processing arguments"); + ssize_t ret = cobj->getIndex(arg0); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_getIndex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ListView_removeAllItems(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_removeAllItems : Invalid Native Object"); + if (argc == 0) { + cobj->removeAllItems(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_removeAllItems : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ListView_setGravity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_setGravity : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::ListView::Gravity arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ListView_setGravity : Error processing arguments"); + cobj->setGravity(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_setGravity : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ListView_pushBackCustomItem(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_pushBackCustomItem : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::Widget* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ListView_pushBackCustomItem : Error processing arguments"); + cobj->pushBackCustomItem(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_pushBackCustomItem : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ListView_getItems(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_getItems : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vector& ret = cobj->getItems(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_getItems : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ListView_removeItem(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_removeItem : Invalid Native Object"); + if (argc == 1) { + ssize_t arg0; + ok &= jsval_to_ssize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ListView_removeItem : Error processing arguments"); + cobj->removeItem(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_removeItem : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ListView_getCurSelectedIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_getCurSelectedIndex : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getCurSelectedIndex(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_getCurSelectedIndex : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ListView_insertDefaultItem(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_insertDefaultItem : Invalid Native Object"); + if (argc == 1) { + ssize_t arg0; + ok &= jsval_to_ssize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ListView_insertDefaultItem : Error processing arguments"); + cobj->insertDefaultItem(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_insertDefaultItem : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ListView_requestRefreshView(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_requestRefreshView : Invalid Native Object"); + if (argc == 0) { + cobj->requestRefreshView(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_requestRefreshView : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ListView_setItemsMargin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_setItemsMargin : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ListView_setItemsMargin : Error processing arguments"); + cobj->setItemsMargin(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_setItemsMargin : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ListView_refreshView(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_refreshView : Invalid Native Object"); + if (argc == 0) { + cobj->refreshView(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_refreshView : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ListView_removeLastItem(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_removeLastItem : Invalid Native Object"); + if (argc == 0) { + cobj->removeLastItem(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_removeLastItem : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ListView_getItemsMargin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_getItemsMargin : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getItemsMargin(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_getItemsMargin : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ListView_getItem(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_getItem : Invalid Native Object"); + if (argc == 1) { + ssize_t arg0; + ok &= jsval_to_ssize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ListView_getItem : Error processing arguments"); + cocos2d::ui::Widget* ret = cobj->getItem(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Widget*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_getItem : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ListView_setItemModel(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_setItemModel : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::Widget* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ListView_setItemModel : Error processing arguments"); + cobj->setItemModel(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_setItemModel : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_ListView_doLayout(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_doLayout : Invalid Native Object"); + if (argc == 0) { + cobj->doLayout(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_doLayout : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ListView_pushBackDefaultItem(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_pushBackDefaultItem : Invalid Native Object"); + if (argc == 0) { + cobj->pushBackDefaultItem(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_pushBackDefaultItem : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_ListView_insertCustomItem(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::ListView* cobj = (cocos2d::ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_ListView_insertCustomItem : Invalid Native Object"); + if (argc == 2) { + cocos2d::ui::Widget* arg0; + ssize_t arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_ssize(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_ListView_insertCustomItem : Error processing arguments"); + cobj->insertCustomItem(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_ListView_insertCustomItem : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ui_ListView_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ui::ListView* ret = cocos2d::ui::ListView::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::ListView*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_ListView_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_ListView_createInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Ref* ret = cocos2d::ui::ListView::createInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_ListView_createInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_ListView_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::ListView* cobj = new (std::nothrow) cocos2d::ui::ListView(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::ListView"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_ScrollView_prototype; + +void js_cocos2d_ui_ListView_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ListView)", obj); +} + +static bool js_cocos2d_ui_ListView_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::ListView *nobj = new (std::nothrow) cocos2d::ui::ListView(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::ListView"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_ListView(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_ListView_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_ListView_class->name = "ListView"; + jsb_cocos2d_ui_ListView_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_ListView_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_ListView_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_ListView_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_ListView_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_ListView_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_ListView_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_ListView_class->finalize = js_cocos2d_ui_ListView_finalize; + jsb_cocos2d_ui_ListView_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getIndex", js_cocos2dx_ui_ListView_getIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllItems", js_cocos2dx_ui_ListView_removeAllItems, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setGravity", js_cocos2dx_ui_ListView_setGravity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pushBackCustomItem", js_cocos2dx_ui_ListView_pushBackCustomItem, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getItems", js_cocos2dx_ui_ListView_getItems, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeItem", js_cocos2dx_ui_ListView_removeItem, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCurSelectedIndex", js_cocos2dx_ui_ListView_getCurSelectedIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("insertDefaultItem", js_cocos2dx_ui_ListView_insertDefaultItem, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("requestRefreshView", js_cocos2dx_ui_ListView_requestRefreshView, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setItemsMargin", js_cocos2dx_ui_ListView_setItemsMargin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("refreshView", js_cocos2dx_ui_ListView_refreshView, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeLastItem", js_cocos2dx_ui_ListView_removeLastItem, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getItemsMargin", js_cocos2dx_ui_ListView_getItemsMargin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getItem", js_cocos2dx_ui_ListView_getItem, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setItemModel", js_cocos2dx_ui_ListView_setItemModel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("doLayout", js_cocos2dx_ui_ListView_doLayout, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pushBackDefaultItem", js_cocos2dx_ui_ListView_pushBackDefaultItem, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("insertCustomItem", js_cocos2dx_ui_ListView_insertCustomItem, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_ListView_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_ListView_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createInstance", js_cocos2dx_ui_ListView_createInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_ListView_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_ScrollView_prototype), + jsb_cocos2d_ui_ListView_class, + js_cocos2dx_ui_ListView_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, "ListView", 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_ListView_class; + p->proto = jsb_cocos2d_ui_ListView_prototype; + p->parentProto = jsb_cocos2d_ui_ScrollView_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_Slider_class; +JSObject *jsb_cocos2d_ui_Slider_prototype; + +bool js_cocos2dx_ui_Slider_setPercent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_setPercent : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_setPercent : Error processing arguments"); + cobj->setPercent(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_setPercent : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled : Error processing arguments"); + cobj->loadSlidBallTextureDisabled(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled : Error processing arguments"); + cobj->loadSlidBallTextureDisabled(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Slider_loadSlidBallTextureNormal(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTextureNormal : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTextureNormal : Error processing arguments"); + cobj->loadSlidBallTextureNormal(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTextureNormal : Error processing arguments"); + cobj->loadSlidBallTextureNormal(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_loadSlidBallTextureNormal : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Slider_loadBarTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_loadBarTexture : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadBarTexture : Error processing arguments"); + cobj->loadBarTexture(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadBarTexture : Error processing arguments"); + cobj->loadBarTexture(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_loadBarTexture : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Slider_loadProgressBarTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_loadProgressBarTexture : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadProgressBarTexture : Error processing arguments"); + cobj->loadProgressBarTexture(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadProgressBarTexture : Error processing arguments"); + cobj->loadProgressBarTexture(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_loadProgressBarTexture : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Slider_loadSlidBallTextures(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTextures : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTextures : Error processing arguments"); + cobj->loadSlidBallTextures(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTextures : Error processing arguments"); + cobj->loadSlidBallTextures(arg0, arg1); + args.rval().setUndefined(); + return true; + } + if (argc == 3) { + std::string arg0; + std::string arg1; + std::string arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTextures : Error processing arguments"); + cobj->loadSlidBallTextures(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + if (argc == 4) { + std::string arg0; + std::string arg1; + std::string arg2; + cocos2d::ui::Widget::TextureResType arg3; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= jsval_to_std_string(cx, args.get(2), &arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTextures : Error processing arguments"); + cobj->loadSlidBallTextures(arg0, arg1, arg2, arg3); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_loadSlidBallTextures : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer : Invalid Native Object"); + if (argc == 1) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer : Error processing arguments"); + cobj->setCapInsetProgressBarRebderer(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Slider_setCapInsetsBarRenderer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_setCapInsetsBarRenderer : Invalid Native Object"); + if (argc == 1) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_setCapInsetsBarRenderer : Error processing arguments"); + cobj->setCapInsetsBarRenderer(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_setCapInsetsBarRenderer : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Rect& ret = cobj->getCapInsetsProgressBarRebderer(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Slider_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_setScale9Enabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_setScale9Enabled : Error processing arguments"); + cobj->setScale9Enabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_setScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Slider_setZoomScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_setZoomScale : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_setZoomScale : Error processing arguments"); + cobj->setZoomScale(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_setZoomScale : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Slider_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_setCapInsets : Invalid Native Object"); + if (argc == 1) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_setCapInsets : Error processing arguments"); + cobj->setCapInsets(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_setCapInsets : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Slider_getZoomScale(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_getZoomScale : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getZoomScale(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_getZoomScale : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Slider_loadSlidBallTexturePressed(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTexturePressed : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTexturePressed : Error processing arguments"); + cobj->loadSlidBallTexturePressed(arg0); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::ui::Widget::TextureResType arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_loadSlidBallTexturePressed : Error processing arguments"); + cobj->loadSlidBallTexturePressed(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_loadSlidBallTexturePressed : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Slider_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_isScale9Enabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isScale9Enabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_isScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Slider_getCapInsetsBarRenderer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_getCapInsetsBarRenderer : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Rect& ret = cobj->getCapInsetsBarRenderer(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_getCapInsetsBarRenderer : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Slider_getPercent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_getPercent : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getPercent(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_getPercent : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Slider_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::ui::Slider* ret = cocos2d::ui::Slider::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Slider*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::ui::Widget::TextureResType arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + cocos2d::ui::Slider* ret = cocos2d::ui::Slider::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Slider*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::ui::Slider* ret = cocos2d::ui::Slider::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Slider*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ui_Slider_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_Slider_createInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Ref* ret = cocos2d::ui::Slider::createInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_Slider_createInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_Slider_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::Slider* cobj = new (std::nothrow) cocos2d::ui::Slider(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::Slider"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_Widget_prototype; + +void js_cocos2d_ui_Slider_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Slider)", obj); +} + +static bool js_cocos2d_ui_Slider_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::Slider *nobj = new (std::nothrow) cocos2d::ui::Slider(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::Slider"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_Slider(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_Slider_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_Slider_class->name = "Slider"; + jsb_cocos2d_ui_Slider_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_Slider_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_Slider_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_Slider_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_Slider_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_Slider_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_Slider_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_Slider_class->finalize = js_cocos2d_ui_Slider_finalize; + jsb_cocos2d_ui_Slider_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setPercent", js_cocos2dx_ui_Slider_setPercent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadSlidBallTextureDisabled", js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadSlidBallTextureNormal", js_cocos2dx_ui_Slider_loadSlidBallTextureNormal, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadBarTexture", js_cocos2dx_ui_Slider_loadBarTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadProgressBarTexture", js_cocos2dx_ui_Slider_loadProgressBarTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadSlidBallTextures", js_cocos2dx_ui_Slider_loadSlidBallTextures, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCapInsetProgressBarRebderer", js_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCapInsetsBarRenderer", js_cocos2dx_ui_Slider_setCapInsetsBarRenderer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCapInsetsProgressBarRebderer", js_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setScale9Enabled", js_cocos2dx_ui_Slider_setScale9Enabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setZoomScale", js_cocos2dx_ui_Slider_setZoomScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCapInsets", js_cocos2dx_ui_Slider_setCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getZoomScale", js_cocos2dx_ui_Slider_getZoomScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadSlidBallTexturePressed", js_cocos2dx_ui_Slider_loadSlidBallTexturePressed, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isScale9Enabled", js_cocos2dx_ui_Slider_isScale9Enabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCapInsetsBarRenderer", js_cocos2dx_ui_Slider_getCapInsetsBarRenderer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPercent", js_cocos2dx_ui_Slider_getPercent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_Slider_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_Slider_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createInstance", js_cocos2dx_ui_Slider_createInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_Slider_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + jsb_cocos2d_ui_Slider_class, + js_cocos2dx_ui_Slider_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, "Slider", 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_Slider_class; + p->proto = jsb_cocos2d_ui_Slider_prototype; + p->parentProto = jsb_cocos2d_ui_Widget_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_UICCTextField_class; +JSObject *jsb_cocos2d_ui_UICCTextField_prototype; + +bool js_cocos2dx_ui_UICCTextField_onTextFieldAttachWithIME(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_onTextFieldAttachWithIME : Invalid Native Object"); + if (argc == 1) { + cocos2d::TextFieldTTF* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::TextFieldTTF*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_UICCTextField_onTextFieldAttachWithIME : Error processing arguments"); + bool ret = cobj->onTextFieldAttachWithIME(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_onTextFieldAttachWithIME : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_UICCTextField_setPasswordText(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_setPasswordText : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_UICCTextField_setPasswordText : Error processing arguments"); + cobj->setPasswordText(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_setPasswordText : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_UICCTextField_setAttachWithIME(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_setAttachWithIME : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_UICCTextField_setAttachWithIME : Error processing arguments"); + cobj->setAttachWithIME(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_setAttachWithIME : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_UICCTextField_getDeleteBackward(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_getDeleteBackward : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->getDeleteBackward(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_getDeleteBackward : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_UICCTextField_getAttachWithIME(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_getAttachWithIME : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->getAttachWithIME(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_getAttachWithIME : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_UICCTextField_onTextFieldDeleteBackward(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_onTextFieldDeleteBackward : Invalid Native Object"); + if (argc == 3) { + cocos2d::TextFieldTTF* arg0; + const char* arg1; + unsigned long arg2; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::TextFieldTTF*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + ok &= jsval_to_ulong(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_UICCTextField_onTextFieldDeleteBackward : Error processing arguments"); + bool ret = cobj->onTextFieldDeleteBackward(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_onTextFieldDeleteBackward : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_ui_UICCTextField_getInsertText(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_getInsertText : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->getInsertText(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_getInsertText : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_UICCTextField_deleteBackward(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_deleteBackward : Invalid Native Object"); + if (argc == 0) { + cobj->deleteBackward(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_deleteBackward : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_UICCTextField_setInsertText(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_setInsertText : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_UICCTextField_setInsertText : Error processing arguments"); + cobj->setInsertText(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_setInsertText : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_UICCTextField_getDetachWithIME(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_getDetachWithIME : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->getDetachWithIME(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_getDetachWithIME : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_UICCTextField_getCharCount(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_getCharCount : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getCharCount(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_getCharCount : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_UICCTextField_closeIME(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_closeIME : Invalid Native Object"); + if (argc == 0) { + cobj->closeIME(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_closeIME : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_UICCTextField_setPasswordEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_setPasswordEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_UICCTextField_setPasswordEnabled : Error processing arguments"); + cobj->setPasswordEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_setPasswordEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_UICCTextField_setMaxLengthEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_setMaxLengthEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_UICCTextField_setMaxLengthEnabled : Error processing arguments"); + cobj->setMaxLengthEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_setMaxLengthEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_UICCTextField_isPasswordEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_isPasswordEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isPasswordEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_isPasswordEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_UICCTextField_insertText(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_insertText : Invalid Native Object"); + if (argc == 2) { + const char* arg0; + unsigned long arg1; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + ok &= jsval_to_ulong(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_UICCTextField_insertText : Error processing arguments"); + cobj->insertText(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_insertText : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ui_UICCTextField_setPasswordStyleText(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_setPasswordStyleText : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_UICCTextField_setPasswordStyleText : Error processing arguments"); + cobj->setPasswordStyleText(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_setPasswordStyleText : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_UICCTextField_onTextFieldInsertText(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_onTextFieldInsertText : Invalid Native Object"); + if (argc == 3) { + cocos2d::TextFieldTTF* arg0; + const char* arg1; + unsigned long arg2; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::TextFieldTTF*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + ok &= jsval_to_ulong(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_UICCTextField_onTextFieldInsertText : Error processing arguments"); + bool ret = cobj->onTextFieldInsertText(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_onTextFieldInsertText : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_ui_UICCTextField_onTextFieldDetachWithIME(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_onTextFieldDetachWithIME : Invalid Native Object"); + if (argc == 1) { + cocos2d::TextFieldTTF* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::TextFieldTTF*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_UICCTextField_onTextFieldDetachWithIME : Error processing arguments"); + bool ret = cobj->onTextFieldDetachWithIME(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_onTextFieldDetachWithIME : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_UICCTextField_getMaxLength(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_getMaxLength : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getMaxLength(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_getMaxLength : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_UICCTextField_isMaxLengthEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_isMaxLengthEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isMaxLengthEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_isMaxLengthEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_UICCTextField_openIME(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_openIME : Invalid Native Object"); + if (argc == 0) { + cobj->openIME(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_openIME : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_UICCTextField_setDetachWithIME(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_setDetachWithIME : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_UICCTextField_setDetachWithIME : Error processing arguments"); + cobj->setDetachWithIME(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_setDetachWithIME : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_UICCTextField_setMaxLength(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_setMaxLength : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_UICCTextField_setMaxLength : Error processing arguments"); + cobj->setMaxLength(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_setMaxLength : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_UICCTextField_setDeleteBackward(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::UICCTextField* cobj = (cocos2d::ui::UICCTextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_UICCTextField_setDeleteBackward : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_UICCTextField_setDeleteBackward : Error processing arguments"); + cobj->setDeleteBackward(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_setDeleteBackward : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_UICCTextField_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 3) { + std::string arg0; + std::string arg1; + double arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_UICCTextField_create : Error processing arguments"); + cocos2d::ui::UICCTextField* ret = cocos2d::ui::UICCTextField::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::UICCTextField*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_UICCTextField_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_UICCTextField_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::UICCTextField* cobj = new (std::nothrow) cocos2d::ui::UICCTextField(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::UICCTextField"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_TextFieldTTF_prototype; + +void js_cocos2d_ui_UICCTextField_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (UICCTextField)", obj); +} + +void js_register_cocos2dx_ui_UICCTextField(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_UICCTextField_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_UICCTextField_class->name = "UICCTextField"; + jsb_cocos2d_ui_UICCTextField_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_UICCTextField_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_UICCTextField_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_UICCTextField_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_UICCTextField_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_UICCTextField_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_UICCTextField_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_UICCTextField_class->finalize = js_cocos2d_ui_UICCTextField_finalize; + jsb_cocos2d_ui_UICCTextField_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("onTextFieldAttachWithIME", js_cocos2dx_ui_UICCTextField_onTextFieldAttachWithIME, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPasswordText", js_cocos2dx_ui_UICCTextField_setPasswordText, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAttachWithIME", js_cocos2dx_ui_UICCTextField_setAttachWithIME, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDeleteBackward", js_cocos2dx_ui_UICCTextField_getDeleteBackward, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAttachWithIME", js_cocos2dx_ui_UICCTextField_getAttachWithIME, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("onTextFieldDeleteBackward", js_cocos2dx_ui_UICCTextField_onTextFieldDeleteBackward, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInsertText", js_cocos2dx_ui_UICCTextField_getInsertText, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("deleteBackward", js_cocos2dx_ui_UICCTextField_deleteBackward, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setInsertText", js_cocos2dx_ui_UICCTextField_setInsertText, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDetachWithIME", js_cocos2dx_ui_UICCTextField_getDetachWithIME, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCharCount", js_cocos2dx_ui_UICCTextField_getCharCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("closeIME", js_cocos2dx_ui_UICCTextField_closeIME, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPasswordEnabled", js_cocos2dx_ui_UICCTextField_setPasswordEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaxLengthEnabled", js_cocos2dx_ui_UICCTextField_setMaxLengthEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isPasswordEnabled", js_cocos2dx_ui_UICCTextField_isPasswordEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("insertText", js_cocos2dx_ui_UICCTextField_insertText, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPasswordStyleText", js_cocos2dx_ui_UICCTextField_setPasswordStyleText, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("onTextFieldInsertText", js_cocos2dx_ui_UICCTextField_onTextFieldInsertText, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("onTextFieldDetachWithIME", js_cocos2dx_ui_UICCTextField_onTextFieldDetachWithIME, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaxLength", js_cocos2dx_ui_UICCTextField_getMaxLength, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isMaxLengthEnabled", js_cocos2dx_ui_UICCTextField_isMaxLengthEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("openIME", js_cocos2dx_ui_UICCTextField_openIME, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDetachWithIME", js_cocos2dx_ui_UICCTextField_setDetachWithIME, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaxLength", js_cocos2dx_ui_UICCTextField_setMaxLength, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDeleteBackward", js_cocos2dx_ui_UICCTextField_setDeleteBackward, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_UICCTextField_create, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_UICCTextField_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_TextFieldTTF_prototype), + jsb_cocos2d_ui_UICCTextField_class, + js_cocos2dx_ui_UICCTextField_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, "UICCTextField", 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_UICCTextField_class; + p->proto = jsb_cocos2d_ui_UICCTextField_prototype; + p->parentProto = jsb_cocos2d_TextFieldTTF_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_TextField_class; +JSObject *jsb_cocos2d_ui_TextField_prototype; + +bool js_cocos2dx_ui_TextField_setAttachWithIME(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setAttachWithIME : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_setAttachWithIME : Error processing arguments"); + cobj->setAttachWithIME(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_setAttachWithIME : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextField_getFontSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_getFontSize : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getFontSize(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_getFontSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextField_getString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_getString : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getString(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_getString : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextField_setPasswordStyleText(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setPasswordStyleText : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_setPasswordStyleText : Error processing arguments"); + cobj->setPasswordStyleText(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_setPasswordStyleText : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextField_getDeleteBackward(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_getDeleteBackward : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->getDeleteBackward(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_getDeleteBackward : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextField_getPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_getPlaceHolder : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getPlaceHolder(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_getPlaceHolder : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextField_getAttachWithIME(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_getAttachWithIME : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->getAttachWithIME(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_getAttachWithIME : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextField_setFontName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setFontName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_setFontName : Error processing arguments"); + cobj->setFontName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_setFontName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextField_getInsertText(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_getInsertText : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->getInsertText(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_getInsertText : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextField_setInsertText(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setInsertText : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_setInsertText : Error processing arguments"); + cobj->setInsertText(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_setInsertText : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextField_setString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setString : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_setString : Error processing arguments"); + cobj->setString(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_setString : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextField_getDetachWithIME(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_getDetachWithIME : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->getDetachWithIME(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_getDetachWithIME : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextField_setTextVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setTextVerticalAlignment : Invalid Native Object"); + if (argc == 1) { + cocos2d::TextVAlignment arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_setTextVerticalAlignment : Error processing arguments"); + cobj->setTextVerticalAlignment(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_setTextVerticalAlignment : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextField_didNotSelectSelf(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_didNotSelectSelf : Invalid Native Object"); + if (argc == 0) { + cobj->didNotSelectSelf(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_didNotSelectSelf : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextField_getFontName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_getFontName : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getFontName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_getFontName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextField_setTextAreaSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setTextAreaSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_setTextAreaSize : Error processing arguments"); + cobj->setTextAreaSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_setTextAreaSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextField_attachWithIME(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_attachWithIME : Invalid Native Object"); + if (argc == 0) { + cobj->attachWithIME(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_attachWithIME : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextField_getStringLength(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_getStringLength : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getStringLength(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_getStringLength : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextField_getAutoRenderSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_getAutoRenderSize : Invalid Native Object"); + if (argc == 0) { + cocos2d::Size ret = cobj->getAutoRenderSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_getAutoRenderSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextField_setPasswordEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setPasswordEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_setPasswordEnabled : Error processing arguments"); + cobj->setPasswordEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_setPasswordEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextField_getPlaceHolderColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_getPlaceHolderColor : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Color4B& ret = cobj->getPlaceHolderColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor4b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_getPlaceHolderColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextField_getPasswordStyleText(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_getPasswordStyleText : Invalid Native Object"); + if (argc == 0) { + const char* ret = cobj->getPasswordStyleText(); + jsval jsret = JSVAL_NULL; + jsret = c_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_getPasswordStyleText : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextField_setMaxLengthEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setMaxLengthEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_setMaxLengthEnabled : Error processing arguments"); + cobj->setMaxLengthEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_setMaxLengthEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextField_isPasswordEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_isPasswordEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isPasswordEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_isPasswordEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextField_setDeleteBackward(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setDeleteBackward : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_setDeleteBackward : Error processing arguments"); + cobj->setDeleteBackward(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_setDeleteBackward : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextField_setFontSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setFontSize : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_setFontSize : Error processing arguments"); + cobj->setFontSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_setFontSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextField_setPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setPlaceHolder : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_setPlaceHolder : Error processing arguments"); + cobj->setPlaceHolder(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_setPlaceHolder : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextField_setPlaceHolderColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ui::TextField* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setPlaceHolderColor : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->setPlaceHolderColor(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::Color3B arg0; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->setPlaceHolderColor(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_setPlaceHolderColor : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_TextField_setTextHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setTextHorizontalAlignment : Invalid Native Object"); + if (argc == 1) { + cocos2d::TextHAlignment arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_setTextHorizontalAlignment : Error processing arguments"); + cobj->setTextHorizontalAlignment(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_setTextHorizontalAlignment : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextField_setTextColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setTextColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_setTextColor : Error processing arguments"); + cobj->setTextColor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_setTextColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextField_getMaxLength(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_getMaxLength : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getMaxLength(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_getMaxLength : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextField_isMaxLengthEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_isMaxLengthEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isMaxLengthEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_isMaxLengthEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextField_setDetachWithIME(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setDetachWithIME : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_setDetachWithIME : Error processing arguments"); + cobj->setDetachWithIME(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_setDetachWithIME : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextField_setTouchAreaEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setTouchAreaEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_setTouchAreaEnabled : Error processing arguments"); + cobj->setTouchAreaEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_setTouchAreaEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextField_setMaxLength(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setMaxLength : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_setMaxLength : Error processing arguments"); + cobj->setMaxLength(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_setMaxLength : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextField_setTouchSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_setTouchSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextField_setTouchSize : Error processing arguments"); + cobj->setTouchSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_setTouchSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextField_getTouchSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextField* cobj = (cocos2d::ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextField_getTouchSize : Invalid Native Object"); + if (argc == 0) { + cocos2d::Size ret = cobj->getTouchSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextField_getTouchSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextField_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + int arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + cocos2d::ui::TextField* ret = cocos2d::ui::TextField::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::TextField*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::ui::TextField* ret = cocos2d::ui::TextField::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::TextField*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ui_TextField_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_TextField_createInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Ref* ret = cocos2d::ui::TextField::createInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_TextField_createInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_TextField_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::TextField* cobj = new (std::nothrow) cocos2d::ui::TextField(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::TextField"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_Widget_prototype; + +void js_cocos2d_ui_TextField_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TextField)", obj); +} + +static bool js_cocos2d_ui_TextField_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::TextField *nobj = new (std::nothrow) cocos2d::ui::TextField(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::TextField"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_TextField(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_TextField_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_TextField_class->name = "TextField"; + jsb_cocos2d_ui_TextField_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_TextField_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_TextField_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_TextField_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_TextField_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_TextField_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_TextField_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_TextField_class->finalize = js_cocos2d_ui_TextField_finalize; + jsb_cocos2d_ui_TextField_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setAttachWithIME", js_cocos2dx_ui_TextField_setAttachWithIME, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFontSize", js_cocos2dx_ui_TextField_getFontSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getString", js_cocos2dx_ui_TextField_getString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPasswordStyleText", js_cocos2dx_ui_TextField_setPasswordStyleText, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDeleteBackward", js_cocos2dx_ui_TextField_getDeleteBackward, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPlaceHolder", js_cocos2dx_ui_TextField_getPlaceHolder, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAttachWithIME", js_cocos2dx_ui_TextField_getAttachWithIME, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFontName", js_cocos2dx_ui_TextField_setFontName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInsertText", js_cocos2dx_ui_TextField_getInsertText, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setInsertText", js_cocos2dx_ui_TextField_setInsertText, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setString", js_cocos2dx_ui_TextField_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDetachWithIME", js_cocos2dx_ui_TextField_getDetachWithIME, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTextVerticalAlignment", js_cocos2dx_ui_TextField_setTextVerticalAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("didNotSelectSelf", js_cocos2dx_ui_TextField_didNotSelectSelf, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFontName", js_cocos2dx_ui_TextField_getFontName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTextAreaSize", js_cocos2dx_ui_TextField_setTextAreaSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("attachWithIME", js_cocos2dx_ui_TextField_attachWithIME, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStringLength", js_cocos2dx_ui_TextField_getStringLength, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAutoRenderSize", js_cocos2dx_ui_TextField_getAutoRenderSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPasswordEnabled", js_cocos2dx_ui_TextField_setPasswordEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPlaceHolderColor", js_cocos2dx_ui_TextField_getPlaceHolderColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPasswordStyleText", js_cocos2dx_ui_TextField_getPasswordStyleText, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaxLengthEnabled", js_cocos2dx_ui_TextField_setMaxLengthEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isPasswordEnabled", js_cocos2dx_ui_TextField_isPasswordEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDeleteBackward", js_cocos2dx_ui_TextField_setDeleteBackward, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFontSize", js_cocos2dx_ui_TextField_setFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPlaceHolder", js_cocos2dx_ui_TextField_setPlaceHolder, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPlaceHolderColor", js_cocos2dx_ui_TextField_setPlaceHolderColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTextHorizontalAlignment", js_cocos2dx_ui_TextField_setTextHorizontalAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTextColor", js_cocos2dx_ui_TextField_setTextColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaxLength", js_cocos2dx_ui_TextField_getMaxLength, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isMaxLengthEnabled", js_cocos2dx_ui_TextField_isMaxLengthEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDetachWithIME", js_cocos2dx_ui_TextField_setDetachWithIME, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTouchAreaEnabled", js_cocos2dx_ui_TextField_setTouchAreaEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaxLength", js_cocos2dx_ui_TextField_setMaxLength, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTouchSize", js_cocos2dx_ui_TextField_setTouchSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTouchSize", js_cocos2dx_ui_TextField_getTouchSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_TextField_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_TextField_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createInstance", js_cocos2dx_ui_TextField_createInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_TextField_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + jsb_cocos2d_ui_TextField_class, + js_cocos2dx_ui_TextField_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, "TextField", 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_TextField_class; + p->proto = jsb_cocos2d_ui_TextField_prototype; + p->parentProto = jsb_cocos2d_ui_Widget_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_TextBMFont_class; +JSObject *jsb_cocos2d_ui_TextBMFont_prototype; + +bool js_cocos2dx_ui_TextBMFont_setFntFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextBMFont* cobj = (cocos2d::ui::TextBMFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextBMFont_setFntFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextBMFont_setFntFile : Error processing arguments"); + cobj->setFntFile(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextBMFont_setFntFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextBMFont_getStringLength(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextBMFont* cobj = (cocos2d::ui::TextBMFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextBMFont_getStringLength : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getStringLength(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextBMFont_getStringLength : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextBMFont_setString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextBMFont* cobj = (cocos2d::ui::TextBMFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextBMFont_setString : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_TextBMFont_setString : Error processing arguments"); + cobj->setString(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextBMFont_setString : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_TextBMFont_getString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::TextBMFont* cobj = (cocos2d::ui::TextBMFont *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_TextBMFont_getString : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getString(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_TextBMFont_getString : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_TextBMFont_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::ui::TextBMFont* ret = cocos2d::ui::TextBMFont::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::TextBMFont*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::ui::TextBMFont* ret = cocos2d::ui::TextBMFont::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::TextBMFont*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ui_TextBMFont_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_TextBMFont_createInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Ref* ret = cocos2d::ui::TextBMFont::createInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_TextBMFont_createInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_TextBMFont_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::TextBMFont* cobj = new (std::nothrow) cocos2d::ui::TextBMFont(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::TextBMFont"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_Widget_prototype; + +void js_cocos2d_ui_TextBMFont_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (TextBMFont)", obj); +} + +static bool js_cocos2d_ui_TextBMFont_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::TextBMFont *nobj = new (std::nothrow) cocos2d::ui::TextBMFont(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::TextBMFont"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_TextBMFont(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_TextBMFont_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_TextBMFont_class->name = "TextBMFont"; + jsb_cocos2d_ui_TextBMFont_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_TextBMFont_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_TextBMFont_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_TextBMFont_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_TextBMFont_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_TextBMFont_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_TextBMFont_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_TextBMFont_class->finalize = js_cocos2d_ui_TextBMFont_finalize; + jsb_cocos2d_ui_TextBMFont_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setFntFile", js_cocos2dx_ui_TextBMFont_setFntFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStringLength", js_cocos2dx_ui_TextBMFont_getStringLength, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setString", js_cocos2dx_ui_TextBMFont_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getString", js_cocos2dx_ui_TextBMFont_getString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_TextBMFont_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_TextBMFont_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createInstance", js_cocos2dx_ui_TextBMFont_createInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_TextBMFont_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + jsb_cocos2d_ui_TextBMFont_class, + js_cocos2dx_ui_TextBMFont_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, "TextBMFont", 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_TextBMFont_class; + p->proto = jsb_cocos2d_ui_TextBMFont_prototype; + p->parentProto = jsb_cocos2d_ui_Widget_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_PageView_class; +JSObject *jsb_cocos2d_ui_PageView_prototype; + +bool js_cocos2dx_ui_PageView_getCustomScrollThreshold(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_getCustomScrollThreshold : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getCustomScrollThreshold(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_getCustomScrollThreshold : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_PageView_getCurPageIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_getCurPageIndex : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getCurPageIndex(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_getCurPageIndex : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_PageView_addWidgetToPage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_addWidgetToPage : Invalid Native Object"); + if (argc == 3) { + cocos2d::ui::Widget* arg0; + ssize_t arg1; + bool arg2; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_ssize(cx, args.get(1), &arg1); + arg2 = JS::ToBoolean(args.get(2)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_addWidgetToPage : Error processing arguments"); + cobj->addWidgetToPage(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_addWidgetToPage : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_ui_PageView_isUsingCustomScrollThreshold(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_isUsingCustomScrollThreshold : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isUsingCustomScrollThreshold(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_isUsingCustomScrollThreshold : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_PageView_getPage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_getPage : Invalid Native Object"); + if (argc == 1) { + ssize_t arg0; + ok &= jsval_to_ssize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_getPage : Error processing arguments"); + cocos2d::ui::Layout* ret = cobj->getPage(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Layout*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_getPage : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_PageView_removePage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_removePage : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::Layout* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::Layout*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_removePage : Error processing arguments"); + cobj->removePage(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_removePage : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_PageView_setUsingCustomScrollThreshold(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_setUsingCustomScrollThreshold : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_setUsingCustomScrollThreshold : Error processing arguments"); + cobj->setUsingCustomScrollThreshold(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_setUsingCustomScrollThreshold : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_PageView_setCustomScrollThreshold(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_setCustomScrollThreshold : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_setCustomScrollThreshold : Error processing arguments"); + cobj->setCustomScrollThreshold(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_setCustomScrollThreshold : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_PageView_insertPage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_insertPage : Invalid Native Object"); + if (argc == 2) { + cocos2d::ui::Layout* arg0; + int arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::Layout*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_insertPage : Error processing arguments"); + cobj->insertPage(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_insertPage : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ui_PageView_scrollToPage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_scrollToPage : Invalid Native Object"); + if (argc == 1) { + ssize_t arg0; + ok &= jsval_to_ssize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_scrollToPage : Error processing arguments"); + cobj->scrollToPage(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_scrollToPage : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_PageView_removePageAtIndex(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_removePageAtIndex : Invalid Native Object"); + if (argc == 1) { + ssize_t arg0; + ok &= jsval_to_ssize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_removePageAtIndex : Error processing arguments"); + cobj->removePageAtIndex(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_removePageAtIndex : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_PageView_getPages(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_getPages : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vector& ret = cobj->getPages(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_getPages : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_PageView_removeAllPages(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_removeAllPages : Invalid Native Object"); + if (argc == 0) { + cobj->removeAllPages(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_removeAllPages : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_PageView_addPage(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::PageView* cobj = (cocos2d::ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_PageView_addPage : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::Layout* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::Layout*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_PageView_addPage : Error processing arguments"); + cobj->addPage(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_PageView_addPage : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_PageView_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ui::PageView* ret = cocos2d::ui::PageView::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::PageView*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_PageView_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_PageView_createInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::Ref* ret = cocos2d::ui::PageView::createInstance(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_PageView_createInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_PageView_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::PageView* cobj = new (std::nothrow) cocos2d::ui::PageView(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::PageView"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_Layout_prototype; + +void js_cocos2d_ui_PageView_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (PageView)", obj); +} + +static bool js_cocos2d_ui_PageView_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::PageView *nobj = new (std::nothrow) cocos2d::ui::PageView(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::PageView"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_PageView(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_PageView_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_PageView_class->name = "PageView"; + jsb_cocos2d_ui_PageView_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_PageView_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_PageView_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_PageView_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_PageView_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_PageView_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_PageView_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_PageView_class->finalize = js_cocos2d_ui_PageView_finalize; + jsb_cocos2d_ui_PageView_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getCustomScrollThreshold", js_cocos2dx_ui_PageView_getCustomScrollThreshold, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCurPageIndex", js_cocos2dx_ui_PageView_getCurPageIndex, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addWidgetToPage", js_cocos2dx_ui_PageView_addWidgetToPage, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isUsingCustomScrollThreshold", js_cocos2dx_ui_PageView_isUsingCustomScrollThreshold, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPage", js_cocos2dx_ui_PageView_getPage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removePage", js_cocos2dx_ui_PageView_removePage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUsingCustomScrollThreshold", js_cocos2dx_ui_PageView_setUsingCustomScrollThreshold, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCustomScrollThreshold", js_cocos2dx_ui_PageView_setCustomScrollThreshold, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("insertPage", js_cocos2dx_ui_PageView_insertPage, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("scrollToPage", js_cocos2dx_ui_PageView_scrollToPage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removePageAtIndex", js_cocos2dx_ui_PageView_removePageAtIndex, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPages", js_cocos2dx_ui_PageView_getPages, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeAllPages", js_cocos2dx_ui_PageView_removeAllPages, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addPage", js_cocos2dx_ui_PageView_addPage, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_PageView_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_PageView_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createInstance", js_cocos2dx_ui_PageView_createInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_PageView_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_Layout_prototype), + jsb_cocos2d_ui_PageView_class, + js_cocos2dx_ui_PageView_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, "PageView", 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_PageView_class; + p->proto = jsb_cocos2d_ui_PageView_prototype; + p->parentProto = jsb_cocos2d_ui_Layout_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_Helper_class; +JSObject *jsb_cocos2d_ui_Helper_prototype; + +bool js_cocos2dx_ui_Helper_getSubStringOfUTF8String(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 3) { + std::string arg0; + unsigned long arg1; + unsigned long arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_ulong(cx, args.get(1), &arg1); + ok &= jsval_to_ulong(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Helper_getSubStringOfUTF8String : Error processing arguments"); + std::string ret = cocos2d::ui::Helper::getSubStringOfUTF8String(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_Helper_getSubStringOfUTF8String : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_Helper_changeLayoutSystemActiveState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Helper_changeLayoutSystemActiveState : Error processing arguments"); + cocos2d::ui::Helper::changeLayoutSystemActiveState(arg0); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_Helper_changeLayoutSystemActiveState : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_Helper_seekActionWidgetByActionTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::ui::Widget* arg0; + int arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Helper_seekActionWidgetByActionTag : Error processing arguments"); + cocos2d::ui::Widget* ret = cocos2d::ui::Helper::seekActionWidgetByActionTag(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Widget*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_Helper_seekActionWidgetByActionTag : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_Helper_seekWidgetByName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::ui::Widget* arg0; + std::string arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Helper_seekWidgetByName : Error processing arguments"); + cocos2d::ui::Widget* ret = cocos2d::ui::Helper::seekWidgetByName(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Widget*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_Helper_seekWidgetByName : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_Helper_seekWidgetByTag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::ui::Widget* arg0; + int arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Helper_seekWidgetByTag : Error processing arguments"); + cocos2d::ui::Widget* ret = cocos2d::ui::Helper::seekWidgetByTag(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Widget*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_Helper_seekWidgetByTag : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_Helper_restrictCapInsetRect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::Rect arg0; + cocos2d::Size arg1; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Helper_restrictCapInsetRect : Error processing arguments"); + cocos2d::Rect ret = cocos2d::ui::Helper::restrictCapInsetRect(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_Helper_restrictCapInsetRect : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_Helper_doLayout(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Helper_doLayout : Error processing arguments"); + cocos2d::ui::Helper::doLayout(arg0); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_Helper_doLayout : wrong number of arguments"); + return false; +} + + + +void js_cocos2d_ui_Helper_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Helper)", obj); +} + +void js_register_cocos2dx_ui_Helper(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_Helper_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_Helper_class->name = "Helper"; + jsb_cocos2d_ui_Helper_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_Helper_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_Helper_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_Helper_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_Helper_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_Helper_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_Helper_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_Helper_class->finalize = js_cocos2d_ui_Helper_finalize; + jsb_cocos2d_ui_Helper_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("getSubStringOfUTF8String", js_cocos2dx_ui_Helper_getSubStringOfUTF8String, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("changeLayoutSystemActiveState", js_cocos2dx_ui_Helper_changeLayoutSystemActiveState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("seekActionWidgetByActionTag", js_cocos2dx_ui_Helper_seekActionWidgetByActionTag, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("seekWidgetByName", js_cocos2dx_ui_Helper_seekWidgetByName, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("seekWidgetByTag", js_cocos2dx_ui_Helper_seekWidgetByTag, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("restrictCapInsetRect", js_cocos2dx_ui_Helper_restrictCapInsetRect, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("doLayout", js_cocos2dx_ui_Helper_doLayout, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_Helper_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_ui_Helper_class, + empty_constructor, 0, + 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, "Helper", 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_Helper_class; + p->proto = jsb_cocos2d_ui_Helper_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_RichElement_class; +JSObject *jsb_cocos2d_ui_RichElement_prototype; + +bool js_cocos2dx_ui_RichElement_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::RichElement* cobj = (cocos2d::ui::RichElement *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RichElement_init : Invalid Native Object"); + if (argc == 3) { + int arg0; + cocos2d::Color3B arg1; + uint16_t arg2; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_cccolor3b(cx, args.get(1), &arg1); + ok &= jsval_to_uint16(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_RichElement_init : Error processing arguments"); + bool ret = cobj->init(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RichElement_init : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_ui_RichElement_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::RichElement* cobj = new (std::nothrow) cocos2d::ui::RichElement(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::RichElement"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_ui_RichElement_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (RichElement)", obj); +} + +static bool js_cocos2d_ui_RichElement_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::RichElement *nobj = new (std::nothrow) cocos2d::ui::RichElement(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::RichElement"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_RichElement(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_RichElement_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_RichElement_class->name = "RichElement"; + jsb_cocos2d_ui_RichElement_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_RichElement_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_RichElement_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_RichElement_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_RichElement_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_RichElement_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_RichElement_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_RichElement_class->finalize = js_cocos2d_ui_RichElement_finalize; + jsb_cocos2d_ui_RichElement_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_ui_RichElement_init, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_RichElement_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_ui_RichElement_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_ui_RichElement_class, + js_cocos2dx_ui_RichElement_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, "RichElement", 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_RichElement_class; + p->proto = jsb_cocos2d_ui_RichElement_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_RichElementText_class; +JSObject *jsb_cocos2d_ui_RichElementText_prototype; + +bool js_cocos2dx_ui_RichElementText_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::RichElementText* cobj = (cocos2d::ui::RichElementText *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RichElementText_init : Invalid Native Object"); + if (argc == 6) { + int arg0; + cocos2d::Color3B arg1; + uint16_t arg2; + std::string arg3; + std::string arg4; + double arg5; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_cccolor3b(cx, args.get(1), &arg1); + ok &= jsval_to_uint16(cx, args.get(2), &arg2); + ok &= jsval_to_std_string(cx, args.get(3), &arg3); + ok &= jsval_to_std_string(cx, args.get(4), &arg4); + ok &= JS::ToNumber( cx, args.get(5), &arg5) && !isnan(arg5); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_RichElementText_init : Error processing arguments"); + bool ret = cobj->init(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RichElementText_init : wrong number of arguments: %d, was expecting %d", argc, 6); + return false; +} +bool js_cocos2dx_ui_RichElementText_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 6) { + int arg0; + cocos2d::Color3B arg1; + uint16_t arg2; + std::string arg3; + std::string arg4; + double arg5; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_cccolor3b(cx, args.get(1), &arg1); + ok &= jsval_to_uint16(cx, args.get(2), &arg2); + ok &= jsval_to_std_string(cx, args.get(3), &arg3); + ok &= jsval_to_std_string(cx, args.get(4), &arg4); + ok &= JS::ToNumber( cx, args.get(5), &arg5) && !isnan(arg5); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_RichElementText_create : Error processing arguments"); + cocos2d::ui::RichElementText* ret = cocos2d::ui::RichElementText::create(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::RichElementText*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_RichElementText_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_RichElementText_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::RichElementText* cobj = new (std::nothrow) cocos2d::ui::RichElementText(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::RichElementText"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_RichElement_prototype; + +void js_cocos2d_ui_RichElementText_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (RichElementText)", obj); +} + +static bool js_cocos2d_ui_RichElementText_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::RichElementText *nobj = new (std::nothrow) cocos2d::ui::RichElementText(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::RichElementText"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_RichElementText(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_RichElementText_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_RichElementText_class->name = "RichElementText"; + jsb_cocos2d_ui_RichElementText_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_RichElementText_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_RichElementText_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_RichElementText_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_RichElementText_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_RichElementText_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_RichElementText_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_RichElementText_class->finalize = js_cocos2d_ui_RichElementText_finalize; + jsb_cocos2d_ui_RichElementText_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_ui_RichElementText_init, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_RichElementText_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_RichElementText_create, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_RichElementText_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_RichElement_prototype), + jsb_cocos2d_ui_RichElementText_class, + js_cocos2dx_ui_RichElementText_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, "RichElementText", 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_RichElementText_class; + p->proto = jsb_cocos2d_ui_RichElementText_prototype; + p->parentProto = jsb_cocos2d_ui_RichElement_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_RichElementImage_class; +JSObject *jsb_cocos2d_ui_RichElementImage_prototype; + +bool js_cocos2dx_ui_RichElementImage_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::RichElementImage* cobj = (cocos2d::ui::RichElementImage *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RichElementImage_init : Invalid Native Object"); + if (argc == 4) { + int arg0; + cocos2d::Color3B arg1; + uint16_t arg2; + std::string arg3; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_cccolor3b(cx, args.get(1), &arg1); + ok &= jsval_to_uint16(cx, args.get(2), &arg2); + ok &= jsval_to_std_string(cx, args.get(3), &arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_RichElementImage_init : Error processing arguments"); + bool ret = cobj->init(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RichElementImage_init : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_ui_RichElementImage_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 4) { + int arg0; + cocos2d::Color3B arg1; + uint16_t arg2; + std::string arg3; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_cccolor3b(cx, args.get(1), &arg1); + ok &= jsval_to_uint16(cx, args.get(2), &arg2); + ok &= jsval_to_std_string(cx, args.get(3), &arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_RichElementImage_create : Error processing arguments"); + cocos2d::ui::RichElementImage* ret = cocos2d::ui::RichElementImage::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::RichElementImage*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_RichElementImage_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_RichElementImage_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::RichElementImage* cobj = new (std::nothrow) cocos2d::ui::RichElementImage(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::RichElementImage"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_RichElement_prototype; + +void js_cocos2d_ui_RichElementImage_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (RichElementImage)", obj); +} + +static bool js_cocos2d_ui_RichElementImage_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::RichElementImage *nobj = new (std::nothrow) cocos2d::ui::RichElementImage(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::RichElementImage"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_RichElementImage(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_RichElementImage_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_RichElementImage_class->name = "RichElementImage"; + jsb_cocos2d_ui_RichElementImage_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_RichElementImage_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_RichElementImage_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_RichElementImage_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_RichElementImage_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_RichElementImage_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_RichElementImage_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_RichElementImage_class->finalize = js_cocos2d_ui_RichElementImage_finalize; + jsb_cocos2d_ui_RichElementImage_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_ui_RichElementImage_init, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_RichElementImage_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_RichElementImage_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_RichElementImage_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_RichElement_prototype), + jsb_cocos2d_ui_RichElementImage_class, + js_cocos2dx_ui_RichElementImage_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, "RichElementImage", 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_RichElementImage_class; + p->proto = jsb_cocos2d_ui_RichElementImage_prototype; + p->parentProto = jsb_cocos2d_ui_RichElement_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_RichElementCustomNode_class; +JSObject *jsb_cocos2d_ui_RichElementCustomNode_prototype; + +bool js_cocos2dx_ui_RichElementCustomNode_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::RichElementCustomNode* cobj = (cocos2d::ui::RichElementCustomNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RichElementCustomNode_init : Invalid Native Object"); + if (argc == 4) { + int arg0; + cocos2d::Color3B arg1; + uint16_t arg2; + cocos2d::Node* arg3; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_cccolor3b(cx, args.get(1), &arg1); + ok &= jsval_to_uint16(cx, args.get(2), &arg2); + do { + if (!args.get(3).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(3).toObjectOrNull(); + 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_ui_RichElementCustomNode_init : Error processing arguments"); + bool ret = cobj->init(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RichElementCustomNode_init : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} +bool js_cocos2dx_ui_RichElementCustomNode_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 4) { + int arg0; + cocos2d::Color3B arg1; + uint16_t arg2; + cocos2d::Node* arg3; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= jsval_to_cccolor3b(cx, args.get(1), &arg1); + ok &= jsval_to_uint16(cx, args.get(2), &arg2); + do { + if (!args.get(3).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(3).toObjectOrNull(); + 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_ui_RichElementCustomNode_create : Error processing arguments"); + cocos2d::ui::RichElementCustomNode* ret = cocos2d::ui::RichElementCustomNode::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::RichElementCustomNode*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_RichElementCustomNode_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_RichElementCustomNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::RichElementCustomNode* cobj = new (std::nothrow) cocos2d::ui::RichElementCustomNode(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::RichElementCustomNode"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_RichElement_prototype; + +void js_cocos2d_ui_RichElementCustomNode_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (RichElementCustomNode)", obj); +} + +static bool js_cocos2d_ui_RichElementCustomNode_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::RichElementCustomNode *nobj = new (std::nothrow) cocos2d::ui::RichElementCustomNode(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::RichElementCustomNode"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_RichElementCustomNode(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_RichElementCustomNode_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_RichElementCustomNode_class->name = "RichElementCustomNode"; + jsb_cocos2d_ui_RichElementCustomNode_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_RichElementCustomNode_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_RichElementCustomNode_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_RichElementCustomNode_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_RichElementCustomNode_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_RichElementCustomNode_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_RichElementCustomNode_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_RichElementCustomNode_class->finalize = js_cocos2d_ui_RichElementCustomNode_finalize; + jsb_cocos2d_ui_RichElementCustomNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("init", js_cocos2dx_ui_RichElementCustomNode_init, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_RichElementCustomNode_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_RichElementCustomNode_create, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_RichElementCustomNode_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_RichElement_prototype), + jsb_cocos2d_ui_RichElementCustomNode_class, + js_cocos2dx_ui_RichElementCustomNode_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, "RichElementCustomNode", 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_RichElementCustomNode_class; + p->proto = jsb_cocos2d_ui_RichElementCustomNode_prototype; + p->parentProto = jsb_cocos2d_ui_RichElement_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_RichText_class; +JSObject *jsb_cocos2d_ui_RichText_prototype; + +bool js_cocos2dx_ui_RichText_insertElement(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::RichText* cobj = (cocos2d::ui::RichText *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RichText_insertElement : Invalid Native Object"); + if (argc == 2) { + cocos2d::ui::RichElement* arg0; + int arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::RichElement*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_RichText_insertElement : Error processing arguments"); + cobj->insertElement(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RichText_insertElement : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ui_RichText_pushBackElement(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::RichText* cobj = (cocos2d::ui::RichText *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RichText_pushBackElement : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::RichElement* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::RichElement*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_RichText_pushBackElement : Error processing arguments"); + cobj->pushBackElement(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RichText_pushBackElement : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_RichText_setVerticalSpace(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::RichText* cobj = (cocos2d::ui::RichText *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RichText_setVerticalSpace : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_RichText_setVerticalSpace : Error processing arguments"); + cobj->setVerticalSpace(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RichText_setVerticalSpace : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_RichText_formatText(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::RichText* cobj = (cocos2d::ui::RichText *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RichText_formatText : Invalid Native Object"); + if (argc == 0) { + cobj->formatText(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RichText_formatText : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_RichText_removeElement(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ui::RichText* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ui::RichText *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RichText_removeElement : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::ui::RichElement* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::RichElement*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cobj->removeElement(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + if (!ok) { ok = true; break; } + cobj->removeElement(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ui_RichText_removeElement : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_RichText_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ui::RichText* ret = cocos2d::ui::RichText::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::RichText*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_RichText_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_RichText_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::RichText* cobj = new (std::nothrow) cocos2d::ui::RichText(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::RichText"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_Widget_prototype; + +void js_cocos2d_ui_RichText_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (RichText)", obj); +} + +static bool js_cocos2d_ui_RichText_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::RichText *nobj = new (std::nothrow) cocos2d::ui::RichText(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::RichText"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_RichText(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_RichText_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_RichText_class->name = "RichText"; + jsb_cocos2d_ui_RichText_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_RichText_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_RichText_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_RichText_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_RichText_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_RichText_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_RichText_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_RichText_class->finalize = js_cocos2d_ui_RichText_finalize; + jsb_cocos2d_ui_RichText_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("insertElement", js_cocos2dx_ui_RichText_insertElement, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pushBackElement", js_cocos2dx_ui_RichText_pushBackElement, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setVerticalSpace", js_cocos2dx_ui_RichText_setVerticalSpace, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("formatText", js_cocos2dx_ui_RichText_formatText, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeElement", js_cocos2dx_ui_RichText_removeElement, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_RichText_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_RichText_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_RichText_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + jsb_cocos2d_ui_RichText_class, + js_cocos2dx_ui_RichText_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, "RichText", 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_RichText_class; + p->proto = jsb_cocos2d_ui_RichText_prototype; + p->parentProto = jsb_cocos2d_ui_Widget_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_HBox_class; +JSObject *jsb_cocos2d_ui_HBox_prototype; + +bool js_cocos2dx_ui_HBox_initWithSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::HBox* cobj = (cocos2d::ui::HBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_HBox_initWithSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_HBox_initWithSize : Error processing arguments"); + bool ret = cobj->initWithSize(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_HBox_initWithSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_HBox_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::ui::HBox* ret = cocos2d::ui::HBox::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::HBox*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::ui::HBox* ret = cocos2d::ui::HBox::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::HBox*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ui_HBox_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_HBox_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::HBox* cobj = new (std::nothrow) cocos2d::ui::HBox(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::HBox"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_Layout_prototype; + +void js_cocos2d_ui_HBox_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (HBox)", obj); +} + +static bool js_cocos2d_ui_HBox_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::HBox *nobj = new (std::nothrow) cocos2d::ui::HBox(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::HBox"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_HBox(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_HBox_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_HBox_class->name = "HBox"; + jsb_cocos2d_ui_HBox_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_HBox_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_HBox_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_HBox_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_HBox_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_HBox_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_HBox_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_HBox_class->finalize = js_cocos2d_ui_HBox_finalize; + jsb_cocos2d_ui_HBox_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithSize", js_cocos2dx_ui_HBox_initWithSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_HBox_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_HBox_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_HBox_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_Layout_prototype), + jsb_cocos2d_ui_HBox_class, + js_cocos2dx_ui_HBox_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, "HBox", 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_HBox_class; + p->proto = jsb_cocos2d_ui_HBox_prototype; + p->parentProto = jsb_cocos2d_ui_Layout_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_VBox_class; +JSObject *jsb_cocos2d_ui_VBox_prototype; + +bool js_cocos2dx_ui_VBox_initWithSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::VBox* cobj = (cocos2d::ui::VBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_VBox_initWithSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_VBox_initWithSize : Error processing arguments"); + bool ret = cobj->initWithSize(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_VBox_initWithSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_VBox_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::ui::VBox* ret = cocos2d::ui::VBox::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::VBox*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::ui::VBox* ret = cocos2d::ui::VBox::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::VBox*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ui_VBox_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_VBox_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::VBox* cobj = new (std::nothrow) cocos2d::ui::VBox(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::VBox"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_Layout_prototype; + +void js_cocos2d_ui_VBox_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (VBox)", obj); +} + +static bool js_cocos2d_ui_VBox_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::VBox *nobj = new (std::nothrow) cocos2d::ui::VBox(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::VBox"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_VBox(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_VBox_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_VBox_class->name = "VBox"; + jsb_cocos2d_ui_VBox_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_VBox_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_VBox_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_VBox_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_VBox_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_VBox_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_VBox_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_VBox_class->finalize = js_cocos2d_ui_VBox_finalize; + jsb_cocos2d_ui_VBox_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithSize", js_cocos2dx_ui_VBox_initWithSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_VBox_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_VBox_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_VBox_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_Layout_prototype), + jsb_cocos2d_ui_VBox_class, + js_cocos2dx_ui_VBox_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, "VBox", 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_VBox_class; + p->proto = jsb_cocos2d_ui_VBox_prototype; + p->parentProto = jsb_cocos2d_ui_Layout_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_RelativeBox_class; +JSObject *jsb_cocos2d_ui_RelativeBox_prototype; + +bool js_cocos2dx_ui_RelativeBox_initWithSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::RelativeBox* cobj = (cocos2d::ui::RelativeBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_RelativeBox_initWithSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_RelativeBox_initWithSize : Error processing arguments"); + bool ret = cobj->initWithSize(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_RelativeBox_initWithSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_RelativeBox_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::ui::RelativeBox* ret = cocos2d::ui::RelativeBox::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::RelativeBox*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::ui::RelativeBox* ret = cocos2d::ui::RelativeBox::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::RelativeBox*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ui_RelativeBox_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_RelativeBox_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::RelativeBox* cobj = new (std::nothrow) cocos2d::ui::RelativeBox(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::RelativeBox"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_Layout_prototype; + +void js_cocos2d_ui_RelativeBox_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (RelativeBox)", obj); +} + +static bool js_cocos2d_ui_RelativeBox_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::RelativeBox *nobj = new (std::nothrow) cocos2d::ui::RelativeBox(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::RelativeBox"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_RelativeBox(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_RelativeBox_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_RelativeBox_class->name = "RelativeBox"; + jsb_cocos2d_ui_RelativeBox_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_RelativeBox_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_RelativeBox_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_RelativeBox_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_RelativeBox_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_RelativeBox_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_RelativeBox_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_RelativeBox_class->finalize = js_cocos2d_ui_RelativeBox_finalize; + jsb_cocos2d_ui_RelativeBox_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("initWithSize", js_cocos2dx_ui_RelativeBox_initWithSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_RelativeBox_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_RelativeBox_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_RelativeBox_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_Layout_prototype), + jsb_cocos2d_ui_RelativeBox_class, + js_cocos2dx_ui_RelativeBox_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, "RelativeBox", 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_RelativeBox_class; + p->proto = jsb_cocos2d_ui_RelativeBox_prototype; + p->parentProto = jsb_cocos2d_ui_Layout_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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(); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ui::Scale9Sprite* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + 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 (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool arg2; + arg2 = JS::ToBoolean(args.get(2)); + cocos2d::Vec2 arg3; + ok &= jsval_to_vector2(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + cocos2d::Size arg4; + ok &= jsval_to_ccsize(cx, args.get(4), &arg4); + if (!ok) { ok = true; break; } + cocos2d::Rect arg5; + ok &= jsval_to_ccrect(cx, args.get(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); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 4) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool arg2; + arg2 = JS::ToBoolean(args.get(2)); + cocos2d::Rect arg3; + ok &= jsval_to_ccrect(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + bool ret = cobj->updateWithSprite(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setScale9Enabled : Error processing arguments"); + cobj->setScale9Enabled(arg0); + args.rval().setUndefined(); + 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_setFlippedY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setFlippedY : Error processing arguments"); + cobj->setFlippedY(arg0); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setFlippedX : Error processing arguments"); + cobj->setFlippedX(arg0); + args.rval().setUndefined(); + 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_resizableSpriteWithCapInsets(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(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); + args.rval().set(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_disableCascadeOpacity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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(); + args.rval().setUndefined(); + 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_setState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setState : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::Scale9Sprite::State arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setState : Error processing arguments"); + cobj->setState(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_setState : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_setInsetBottom(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setInsetBottom : Error processing arguments"); + cobj->setInsetBottom(arg0); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ui::Scale9Sprite* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + 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, args.get(0), &arg0); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithSpriteFrameName(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithSpriteFrameName(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setInsetTop : Error processing arguments"); + cobj->setInsetTop(arg0); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ui::Scale9Sprite* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + 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 == 3) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::Rect arg2; + ok &= jsval_to_ccrect(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + bool ret = cobj->init(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 4) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool arg2; + arg2 = JS::ToBoolean(args.get(2)); + cocos2d::Rect arg3; + ok &= jsval_to_ccrect(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + bool ret = cobj->init(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 6) { + cocos2d::Sprite* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool arg2; + arg2 = JS::ToBoolean(args.get(2)); + cocos2d::Vec2 arg3; + ok &= jsval_to_vector2(cx, args.get(3), &arg3); + if (!ok) { ok = true; break; } + cocos2d::Size arg4; + ok &= jsval_to_ccsize(cx, args.get(4), &arg4); + if (!ok) { ok = true; break; } + cocos2d::Rect arg5; + ok &= jsval_to_ccrect(cx, args.get(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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setPreferredSize : Error processing arguments"); + cobj->setPreferredSize(arg0); + args.rval().setUndefined(); + 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_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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 (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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); + args.rval().setUndefined(); + return true; + } + if (argc == 2) { + cocos2d::SpriteFrame* arg0; + cocos2d::Rect arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setSpriteFrame : Error processing arguments"); + cobj->setSpriteFrame(arg0, arg1); + args.rval().setUndefined(); + 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_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_getBlendFunc : Invalid Native Object"); + if (argc == 0) { + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_getInsetBottom(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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_getCapInsets(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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_getInsetRight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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_getOriginalSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ui::Scale9Sprite* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + 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, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithFile(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::Rect arg2; + ok &= jsval_to_ccrect(cx, args.get(2), &arg2); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithFile(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithFile(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithFile(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_initWithFile : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setBlendFunc : Invalid Native Object"); + if (argc == 1) { + cocos2d::BlendFunc arg0; + ok &= jsval_to_blendfunc(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setBlendFunc : Error processing arguments"); + cobj->setBlendFunc(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_getInsetTop(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setInsetLeft : Error processing arguments"); + cobj->setInsetLeft(arg0); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ui::Scale9Sprite* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + 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 (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + cocos2d::SpriteFrame* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithSpriteFrame(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setCapInsets : Error processing arguments"); + cobj->setCapInsets(arg0); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setInsetRight : Error processing arguments"); + cobj->setInsetRight(arg0); + args.rval().setUndefined(); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::Rect arg2; + ok &= jsval_to_ccrect(cx, args.get(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); + args.rval().set(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); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(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); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, args.get(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); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, args.get(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); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + cocos2d::SpriteFrame* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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, args.get(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); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 1) { + cocos2d::SpriteFrame* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + 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); + args.rval().set(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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::Scale9Sprite"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + 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) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::Scale9Sprite *nobj = new (std::nothrow) cocos2d::ui::Scale9Sprite(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + 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", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_Scale9Sprite(JSContext *cx, JS::HandleObject 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[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + 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("setScale9Enabled", js_cocos2dx_ui_Scale9Sprite_setScale9Enabled, 1, 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("resizableSpriteWithCapInsets", js_cocos2dx_ui_Scale9Sprite_resizableSpriteWithCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("disableCascadeOpacity", js_cocos2dx_ui_Scale9Sprite_disableCascadeOpacity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setState", js_cocos2dx_ui_Scale9Sprite_setState, 1, 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, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPreferredSize", js_cocos2dx_ui_Scale9Sprite_setPreferredSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSpriteFrame", js_cocos2dx_ui_Scale9Sprite_setSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBlendFunc", js_cocos2dx_ui_Scale9Sprite_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInsetBottom", js_cocos2dx_ui_Scale9Sprite_getInsetBottom, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCapInsets", js_cocos2dx_ui_Scale9Sprite_getCapInsets, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isScale9Enabled", js_cocos2dx_ui_Scale9Sprite_isScale9Enabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInsetRight", js_cocos2dx_ui_Scale9Sprite_getInsetRight, 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("setBlendFunc", js_cocos2dx_ui_Scale9Sprite_setBlendFunc, 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, + JS::RootedObject(cx, 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; + +bool js_cocos2dx_ui_EditBox_getText(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::EditBox* cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_getText : Invalid Native Object"); + if (argc == 0) { + const char* ret = cobj->getText(); + jsval jsret = JSVAL_NULL; + jsret = c_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_EditBox_getText : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_EditBox_setFontSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::EditBox* cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_setFontSize : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_EditBox_setFontSize : Error processing arguments"); + cobj->setFontSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_EditBox_setFontSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_EditBox_setPlaceholderFontName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::EditBox* cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_setPlaceholderFontName : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_EditBox_setPlaceholderFontName : Error processing arguments"); + cobj->setPlaceholderFontName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_EditBox_setPlaceholderFontName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_EditBox_getPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::EditBox* cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_getPlaceHolder : Invalid Native Object"); + if (argc == 0) { + const char* ret = cobj->getPlaceHolder(); + jsval jsret = JSVAL_NULL; + jsret = c_string_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_EditBox_getPlaceHolder : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_EditBox_setFontName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::EditBox* cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_setFontName : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_EditBox_setFontName : Error processing arguments"); + cobj->setFontName(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_EditBox_setFontName : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_EditBox_setText(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::EditBox* cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_setText : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_EditBox_setText : Error processing arguments"); + cobj->setText(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_EditBox_setText : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_EditBox_setPlaceholderFontSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::EditBox* cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_setPlaceholderFontSize : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_EditBox_setPlaceholderFontSize : Error processing arguments"); + cobj->setPlaceholderFontSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_EditBox_setPlaceholderFontSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_EditBox_setInputMode(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::EditBox* cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_setInputMode : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::EditBox::InputMode arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_EditBox_setInputMode : Error processing arguments"); + cobj->setInputMode(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_EditBox_setInputMode : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_EditBox_setPlaceholderFontColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ui::EditBox* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_setPlaceholderFontColor : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->setPlaceholderFontColor(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::Color3B arg0; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->setPlaceholderFontColor(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ui_EditBox_setPlaceholderFontColor : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_EditBox_setFontColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ui::EditBox* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_setFontColor : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::Color4B arg0; + ok &= jsval_to_cccolor4b(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->setFontColor(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::Color3B arg0; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->setFontColor(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ui_EditBox_setFontColor : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_EditBox_setPlaceholderFont(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::EditBox* cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_setPlaceholderFont : Invalid Native Object"); + if (argc == 2) { + const char* arg0; + int arg1; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_EditBox_setPlaceholderFont : Error processing arguments"); + cobj->setPlaceholderFont(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_EditBox_setPlaceholderFont : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ui_EditBox_initWithSizeAndBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::ui::EditBox* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_initWithSizeAndBackgroundSprite : Invalid Native Object"); + do { + if (argc == 2) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::ui::Scale9Sprite* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithSizeAndBackgroundSprite(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithSizeAndBackgroundSprite(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 3) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::ui::Widget::TextureResType arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithSizeAndBackgroundSprite(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ui_EditBox_initWithSizeAndBackgroundSprite : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_EditBox_setPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::EditBox* cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_setPlaceHolder : Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_EditBox_setPlaceHolder : Error processing arguments"); + cobj->setPlaceHolder(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_EditBox_setPlaceHolder : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_EditBox_setReturnType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::EditBox* cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_setReturnType : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::EditBox::KeyboardReturnType arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_EditBox_setReturnType : Error processing arguments"); + cobj->setReturnType(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_EditBox_setReturnType : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_EditBox_setInputFlag(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::EditBox* cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_setInputFlag : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::EditBox::InputFlag arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_EditBox_setInputFlag : Error processing arguments"); + cobj->setInputFlag(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_EditBox_setInputFlag : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_EditBox_getMaxLength(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::EditBox* cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_getMaxLength : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getMaxLength(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_EditBox_getMaxLength : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_EditBox_setMaxLength(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::EditBox* cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_setMaxLength : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_EditBox_setMaxLength : Error processing arguments"); + cobj->setMaxLength(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_EditBox_setMaxLength : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_EditBox_setFont(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::EditBox* cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_EditBox_setFont : Invalid Native Object"); + if (argc == 2) { + const char* arg0; + int arg1; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_EditBox_setFont : Error processing arguments"); + cobj->setFont(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_EditBox_setFont : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_ui_EditBox_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 2) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::ui::EditBox* ret = cocos2d::ui::EditBox::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::EditBox*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 3) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::ui::Widget::TextureResType arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + if (!ok) { ok = true; break; } + cocos2d::ui::EditBox* ret = cocos2d::ui::EditBox::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::EditBox*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::ui::Scale9Sprite* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::ui::EditBox* ret = cocos2d::ui::EditBox::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::EditBox*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 3) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::ui::Scale9Sprite* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::ui::Scale9Sprite* arg2; + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::ui::EditBox* ret = cocos2d::ui::EditBox::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::EditBox*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + do { + if (argc == 4) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::ui::Scale9Sprite* arg1; + do { + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::ui::Scale9Sprite* arg2; + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::ui::Scale9Sprite* arg3; + do { + if (!args.get(3).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(3).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg3 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::ui::EditBox* ret = cocos2d::ui::EditBox::create(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::EditBox*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ui_EditBox_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_EditBox_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::EditBox* cobj = new (std::nothrow) cocos2d::ui::EditBox(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::EditBox"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_ui_Widget_prototype; + +void js_cocos2d_ui_EditBox_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EditBox)", obj); +} + +static bool js_cocos2d_ui_EditBox_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::EditBox *nobj = new (std::nothrow) cocos2d::ui::EditBox(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::EditBox"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_EditBox(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_EditBox_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_EditBox_class->name = "EditBox"; + jsb_cocos2d_ui_EditBox_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_EditBox_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_EditBox_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_EditBox_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_EditBox_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_EditBox_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_EditBox_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_EditBox_class->finalize = js_cocos2d_ui_EditBox_finalize; + jsb_cocos2d_ui_EditBox_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getString", js_cocos2dx_ui_EditBox_getText, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFontSize", js_cocos2dx_ui_EditBox_setFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPlaceholderFontName", js_cocos2dx_ui_EditBox_setPlaceholderFontName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPlaceHolder", js_cocos2dx_ui_EditBox_getPlaceHolder, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFontName", js_cocos2dx_ui_EditBox_setFontName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setString", js_cocos2dx_ui_EditBox_setText, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPlaceholderFontSize", js_cocos2dx_ui_EditBox_setPlaceholderFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setInputMode", js_cocos2dx_ui_EditBox_setInputMode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPlaceholderFontColor", js_cocos2dx_ui_EditBox_setPlaceholderFontColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFontColor", js_cocos2dx_ui_EditBox_setFontColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPlaceholderFont", js_cocos2dx_ui_EditBox_setPlaceholderFont, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithSizeAndBackgroundSprite", js_cocos2dx_ui_EditBox_initWithSizeAndBackgroundSprite, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPlaceHolder", js_cocos2dx_ui_EditBox_setPlaceHolder, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setReturnType", js_cocos2dx_ui_EditBox_setReturnType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setInputFlag", js_cocos2dx_ui_EditBox_setInputFlag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaxLength", js_cocos2dx_ui_EditBox_getMaxLength, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaxLength", js_cocos2dx_ui_EditBox_setMaxLength, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFont", js_cocos2dx_ui_EditBox_setFont, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_EditBox_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_EditBox_create, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_EditBox_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), + jsb_cocos2d_ui_EditBox_class, + js_cocos2dx_ui_EditBox_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, "EditBox", 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_EditBox_class; + p->proto = jsb_cocos2d_ui_EditBox_prototype; + p->parentProto = jsb_cocos2d_ui_Widget_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_ui_LayoutComponent_class; +JSObject *jsb_cocos2d_ui_LayoutComponent_prototype; + +bool js_cocos2dx_ui_LayoutComponent_setStretchWidthEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setStretchWidthEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setStretchWidthEnabled : Error processing arguments"); + cobj->setStretchWidthEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setStretchWidthEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setPercentWidth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setPercentWidth : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setPercentWidth : Error processing arguments"); + cobj->setPercentWidth(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setPercentWidth : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_getAnchorPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_getAnchorPosition : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Point& ret = cobj->getAnchorPosition(); + jsval jsret = JSVAL_NULL; + jsret = ccpoint_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_getAnchorPosition : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setPositionPercentXEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setPositionPercentXEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setPositionPercentXEnabled : Error processing arguments"); + cobj->setPositionPercentXEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setPositionPercentXEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setStretchHeightEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setStretchHeightEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setStretchHeightEnabled : Error processing arguments"); + cobj->setStretchHeightEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setStretchHeightEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setActiveEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setActiveEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setActiveEnabled : Error processing arguments"); + cobj->setActiveEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setActiveEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_getRightMargin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_getRightMargin : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getRightMargin(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_getRightMargin : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_getSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_getSize : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Size& ret = cobj->getSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_getSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setAnchorPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setAnchorPosition : Invalid Native Object"); + if (argc == 1) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setAnchorPosition : Error processing arguments"); + cobj->setAnchorPosition(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setAnchorPosition : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_refreshLayout(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_refreshLayout : Invalid Native Object"); + if (argc == 0) { + cobj->refreshLayout(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_refreshLayout : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_isPercentWidthEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_isPercentWidthEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isPercentWidthEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_isPercentWidthEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setVerticalEdge(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setVerticalEdge : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::LayoutComponent::VerticalEdge arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setVerticalEdge : Error processing arguments"); + cobj->setVerticalEdge(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setVerticalEdge : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_getTopMargin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_getTopMargin : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getTopMargin(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_getTopMargin : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setSizeWidth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setSizeWidth : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setSizeWidth : Error processing arguments"); + cobj->setSizeWidth(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setSizeWidth : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_getPercentContentSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_getPercentContentSize : Invalid Native Object"); + if (argc == 0) { + cocos2d::Vec2 ret = cobj->getPercentContentSize(); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_getPercentContentSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_getVerticalEdge(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_getVerticalEdge : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getVerticalEdge(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_getVerticalEdge : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setPercentWidthEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setPercentWidthEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setPercentWidthEnabled : Error processing arguments"); + cobj->setPercentWidthEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setPercentWidthEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_isStretchWidthEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_isStretchWidthEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isStretchWidthEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_isStretchWidthEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setLeftMargin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setLeftMargin : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setLeftMargin : Error processing arguments"); + cobj->setLeftMargin(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setLeftMargin : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_getSizeWidth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_getSizeWidth : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getSizeWidth(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_getSizeWidth : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setPositionPercentYEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setPositionPercentYEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setPositionPercentYEnabled : Error processing arguments"); + cobj->setPositionPercentYEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setPositionPercentYEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_getSizeHeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_getSizeHeight : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getSizeHeight(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_getSizeHeight : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_getPositionPercentY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_getPositionPercentY : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getPositionPercentY(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_getPositionPercentY : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_getPositionPercentX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_getPositionPercentX : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getPositionPercentX(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_getPositionPercentX : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setTopMargin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setTopMargin : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setTopMargin : Error processing arguments"); + cobj->setTopMargin(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setTopMargin : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_getPercentHeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_getPercentHeight : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getPercentHeight(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_getPercentHeight : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_getUsingPercentContentSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_getUsingPercentContentSize : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->getUsingPercentContentSize(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_getUsingPercentContentSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setPositionPercentY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setPositionPercentY : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setPositionPercentY : Error processing arguments"); + cobj->setPositionPercentY(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setPositionPercentY : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setPositionPercentX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setPositionPercentX : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setPositionPercentX : Error processing arguments"); + cobj->setPositionPercentX(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setPositionPercentX : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setRightMargin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setRightMargin : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setRightMargin : Error processing arguments"); + cobj->setRightMargin(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setRightMargin : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_isPositionPercentYEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_isPositionPercentYEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isPositionPercentYEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_isPositionPercentYEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setPercentHeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setPercentHeight : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setPercentHeight : Error processing arguments"); + cobj->setPercentHeight(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setPercentHeight : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setPercentOnlyEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setPercentOnlyEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setPercentOnlyEnabled : Error processing arguments"); + cobj->setPercentOnlyEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setPercentOnlyEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setHorizontalEdge(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setHorizontalEdge : Invalid Native Object"); + if (argc == 1) { + cocos2d::ui::LayoutComponent::HorizontalEdge arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setHorizontalEdge : Error processing arguments"); + cobj->setHorizontalEdge(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setHorizontalEdge : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setPosition : Invalid Native Object"); + if (argc == 1) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setPosition : Error processing arguments"); + cobj->setPosition(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setPosition : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setUsingPercentContentSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setUsingPercentContentSize : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setUsingPercentContentSize : Error processing arguments"); + cobj->setUsingPercentContentSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setUsingPercentContentSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_getLeftMargin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_getLeftMargin : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getLeftMargin(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_getLeftMargin : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_getPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_getPosition : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Point& ret = cobj->getPosition(); + jsval jsret = JSVAL_NULL; + jsret = ccpoint_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_getPosition : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setSizeHeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setSizeHeight : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setSizeHeight : Error processing arguments"); + cobj->setSizeHeight(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setSizeHeight : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_isPositionPercentXEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_isPositionPercentXEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isPositionPercentXEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_isPositionPercentXEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_getBottomMargin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_getBottomMargin : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getBottomMargin(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_getBottomMargin : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setPercentHeightEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setPercentHeightEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setPercentHeightEnabled : Error processing arguments"); + cobj->setPercentHeightEnabled(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setPercentHeightEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setPercentContentSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setPercentContentSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setPercentContentSize : Error processing arguments"); + cobj->setPercentContentSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setPercentContentSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_isPercentHeightEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_isPercentHeightEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isPercentHeightEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_isPercentHeightEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_getPercentWidth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_getPercentWidth : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getPercentWidth(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_getPercentWidth : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_getHorizontalEdge(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_getHorizontalEdge : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getHorizontalEdge(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_getHorizontalEdge : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_isStretchHeightEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_isStretchHeightEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isStretchHeightEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_isStretchHeightEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setBottomMargin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setBottomMargin : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setBottomMargin : Error processing arguments"); + cobj->setBottomMargin(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setBottomMargin : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_setSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::LayoutComponent* cobj = (cocos2d::ui::LayoutComponent *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_LayoutComponent_setSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_setSize : Error processing arguments"); + cobj->setSize(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_setSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_LayoutComponent_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + cocos2d::ui::LayoutComponent* ret = cocos2d::ui::LayoutComponent::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::LayoutComponent*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_LayoutComponent_bindLayoutComponent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_LayoutComponent_bindLayoutComponent : Error processing arguments"); + cocos2d::ui::LayoutComponent* ret = cocos2d::ui::LayoutComponent::bindLayoutComponent(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::LayoutComponent*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ui_LayoutComponent_bindLayoutComponent : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ui_LayoutComponent_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::ui::LayoutComponent* cobj = new (std::nothrow) cocos2d::ui::LayoutComponent(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::LayoutComponent"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + +extern JSObject *jsb_cocos2d_Component_prototype; + +void js_cocos2d_ui_LayoutComponent_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (LayoutComponent)", obj); +} + +static bool js_cocos2d_ui_LayoutComponent_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + cocos2d::ui::LayoutComponent *nobj = new (std::nothrow) cocos2d::ui::LayoutComponent(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::LayoutComponent"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} +void js_register_cocos2dx_ui_LayoutComponent(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_ui_LayoutComponent_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_LayoutComponent_class->name = "LayoutComponent"; + jsb_cocos2d_ui_LayoutComponent_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_LayoutComponent_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_LayoutComponent_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_LayoutComponent_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_LayoutComponent_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_LayoutComponent_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_LayoutComponent_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_LayoutComponent_class->finalize = js_cocos2d_ui_LayoutComponent_finalize; + jsb_cocos2d_ui_LayoutComponent_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setStretchWidthEnabled", js_cocos2dx_ui_LayoutComponent_setStretchWidthEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPercentWidth", js_cocos2dx_ui_LayoutComponent_setPercentWidth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAnchorPosition", js_cocos2dx_ui_LayoutComponent_getAnchorPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPositionPercentXEnabled", js_cocos2dx_ui_LayoutComponent_setPositionPercentXEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setStretchHeightEnabled", js_cocos2dx_ui_LayoutComponent_setStretchHeightEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setActiveEnabled", js_cocos2dx_ui_LayoutComponent_setActiveEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRightMargin", js_cocos2dx_ui_LayoutComponent_getRightMargin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSize", js_cocos2dx_ui_LayoutComponent_getSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAnchorPosition", js_cocos2dx_ui_LayoutComponent_setAnchorPosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("refreshLayout", js_cocos2dx_ui_LayoutComponent_refreshLayout, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isPercentWidthEnabled", js_cocos2dx_ui_LayoutComponent_isPercentWidthEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setVerticalEdge", js_cocos2dx_ui_LayoutComponent_setVerticalEdge, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTopMargin", js_cocos2dx_ui_LayoutComponent_getTopMargin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSizeWidth", js_cocos2dx_ui_LayoutComponent_setSizeWidth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPercentContentSize", js_cocos2dx_ui_LayoutComponent_getPercentContentSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVerticalEdge", js_cocos2dx_ui_LayoutComponent_getVerticalEdge, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPercentWidthEnabled", js_cocos2dx_ui_LayoutComponent_setPercentWidthEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isStretchWidthEnabled", js_cocos2dx_ui_LayoutComponent_isStretchWidthEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLeftMargin", js_cocos2dx_ui_LayoutComponent_setLeftMargin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSizeWidth", js_cocos2dx_ui_LayoutComponent_getSizeWidth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPositionPercentYEnabled", js_cocos2dx_ui_LayoutComponent_setPositionPercentYEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSizeHeight", js_cocos2dx_ui_LayoutComponent_getSizeHeight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPositionPercentY", js_cocos2dx_ui_LayoutComponent_getPositionPercentY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPositionPercentX", js_cocos2dx_ui_LayoutComponent_getPositionPercentX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTopMargin", js_cocos2dx_ui_LayoutComponent_setTopMargin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPercentHeight", js_cocos2dx_ui_LayoutComponent_getPercentHeight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getUsingPercentContentSize", js_cocos2dx_ui_LayoutComponent_getUsingPercentContentSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPositionPercentY", js_cocos2dx_ui_LayoutComponent_setPositionPercentY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPositionPercentX", js_cocos2dx_ui_LayoutComponent_setPositionPercentX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRightMargin", js_cocos2dx_ui_LayoutComponent_setRightMargin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isPositionPercentYEnabled", js_cocos2dx_ui_LayoutComponent_isPositionPercentYEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPercentHeight", js_cocos2dx_ui_LayoutComponent_setPercentHeight, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPercentOnlyEnabled", js_cocos2dx_ui_LayoutComponent_setPercentOnlyEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setHorizontalEdge", js_cocos2dx_ui_LayoutComponent_setHorizontalEdge, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPosition", js_cocos2dx_ui_LayoutComponent_setPosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUsingPercentContentSize", js_cocos2dx_ui_LayoutComponent_setUsingPercentContentSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLeftMargin", js_cocos2dx_ui_LayoutComponent_getLeftMargin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPosition", js_cocos2dx_ui_LayoutComponent_getPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSizeHeight", js_cocos2dx_ui_LayoutComponent_setSizeHeight, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isPositionPercentXEnabled", js_cocos2dx_ui_LayoutComponent_isPositionPercentXEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBottomMargin", js_cocos2dx_ui_LayoutComponent_getBottomMargin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPercentHeightEnabled", js_cocos2dx_ui_LayoutComponent_setPercentHeightEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPercentContentSize", js_cocos2dx_ui_LayoutComponent_setPercentContentSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isPercentHeightEnabled", js_cocos2dx_ui_LayoutComponent_isPercentHeightEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPercentWidth", js_cocos2dx_ui_LayoutComponent_getPercentWidth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getHorizontalEdge", js_cocos2dx_ui_LayoutComponent_getHorizontalEdge, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isStretchHeightEnabled", js_cocos2dx_ui_LayoutComponent_isStretchHeightEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBottomMargin", js_cocos2dx_ui_LayoutComponent_setBottomMargin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSize", js_cocos2dx_ui_LayoutComponent_setSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_LayoutComponent_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_LayoutComponent_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("bindLayoutComponent", js_cocos2dx_ui_LayoutComponent_bindLayoutComponent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_LayoutComponent_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Component_prototype), + jsb_cocos2d_ui_LayoutComponent_class, + js_cocos2dx_ui_LayoutComponent_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, "LayoutComponent", 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_LayoutComponent_class; + p->proto = jsb_cocos2d_ui_LayoutComponent_prototype; + p->parentProto = jsb_cocos2d_Component_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj) { + // Get the ns + JS::RootedObject ns(cx); + get_or_create_js_obj(cx, obj, "ccui", &ns); + + js_register_cocos2dx_ui_Widget(cx, ns); + js_register_cocos2dx_ui_Layout(cx, ns); + js_register_cocos2dx_ui_RelativeBox(cx, ns); + js_register_cocos2dx_ui_CheckBox(cx, ns); + js_register_cocos2dx_ui_TextAtlas(cx, ns); + js_register_cocos2dx_ui_TextBMFont(cx, ns); + js_register_cocos2dx_ui_LoadingBar(cx, ns); + js_register_cocos2dx_ui_TextField(cx, ns); + js_register_cocos2dx_ui_RichText(cx, ns); + js_register_cocos2dx_ui_Scale9Sprite(cx, ns); + js_register_cocos2dx_ui_VBox(cx, ns); + js_register_cocos2dx_ui_RichElement(cx, ns); + js_register_cocos2dx_ui_RichElementCustomNode(cx, ns); + js_register_cocos2dx_ui_Slider(cx, ns); + js_register_cocos2dx_ui_ScrollView(cx, ns); + js_register_cocos2dx_ui_ListView(cx, ns); + js_register_cocos2dx_ui_LayoutComponent(cx, ns); + js_register_cocos2dx_ui_Button(cx, ns); + js_register_cocos2dx_ui_LayoutParameter(cx, ns); + js_register_cocos2dx_ui_LinearLayoutParameter(cx, ns); + js_register_cocos2dx_ui_ImageView(cx, ns); + js_register_cocos2dx_ui_HBox(cx, ns); + js_register_cocos2dx_ui_RichElementText(cx, ns); + js_register_cocos2dx_ui_PageView(cx, ns); + js_register_cocos2dx_ui_Helper(cx, ns); + js_register_cocos2dx_ui_EditBox(cx, ns); + js_register_cocos2dx_ui_Text(cx, ns); + js_register_cocos2dx_ui_RichElementImage(cx, ns); + js_register_cocos2dx_ui_RelativeLayoutParameter(cx, ns); + js_register_cocos2dx_ui_UICCTextField(cx, ns); +} + diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp new file mode 100644 index 0000000000..0b5ea66c16 --- /dev/null +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp @@ -0,0 +1,783 @@ +#ifndef __cocos2dx_ui_h__ +#define __cocos2dx_ui_h__ + +#include "jsapi.h" +#include "jsfriendapi.h" + + +extern JSClass *jsb_cocos2d_ui_LayoutParameter_class; +extern JSObject *jsb_cocos2d_ui_LayoutParameter_prototype; + +bool js_cocos2dx_ui_LayoutParameter_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_LayoutParameter_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_LayoutParameter(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_LayoutParameter_clone(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutParameter_getLayoutType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutParameter_createCloneInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutParameter_copyProperties(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutParameter_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutParameter_LayoutParameter(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_LinearLayoutParameter_class; +extern JSObject *jsb_cocos2d_ui_LinearLayoutParameter_prototype; + +bool js_cocos2dx_ui_LinearLayoutParameter_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_LinearLayoutParameter_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_LinearLayoutParameter(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_LinearLayoutParameter_setGravity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LinearLayoutParameter_getGravity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LinearLayoutParameter_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LinearLayoutParameter_LinearLayoutParameter(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_RelativeLayoutParameter_class; +extern JSObject *jsb_cocos2d_ui_RelativeLayoutParameter_prototype; + +bool js_cocos2dx_ui_RelativeLayoutParameter_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_RelativeLayoutParameter_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_RelativeLayoutParameter(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_RelativeLayoutParameter_setAlign(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RelativeLayoutParameter_setRelativeToWidgetName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RelativeLayoutParameter_getRelativeName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RelativeLayoutParameter_getRelativeToWidgetName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RelativeLayoutParameter_setRelativeName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RelativeLayoutParameter_getAlign(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RelativeLayoutParameter_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RelativeLayoutParameter_RelativeLayoutParameter(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_Widget_class; +extern JSObject *jsb_cocos2d_ui_Widget_prototype; + +bool js_cocos2dx_ui_Widget_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_Widget_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_Widget(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_Widget_setLayoutComponentEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_setSizePercent(JSContext *cx, uint32_t argc, jsval *vp); +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_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); +bool js_cocos2dx_ui_Widget_getSizePercent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_setPositionPercent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_setSwallowTouches(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_getLayoutSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_setHighlighted(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_setPositionType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_isIgnoreContentAdaptWithSize(JSContext *cx, uint32_t argc, jsval *vp); +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_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); +bool js_cocos2dx_ui_Widget_findNextFocusedWidget(JSContext *cx, uint32_t argc, jsval *vp); +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); +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); +bool js_cocos2dx_ui_Widget_setLayoutParameter(JSContext *cx, uint32_t argc, jsval *vp); +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_isLayoutComponentEnabled(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_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); +bool js_cocos2dx_ui_Widget_addClickEventListener(JSContext *cx, uint32_t argc, jsval *vp); +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_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); +bool js_cocos2dx_ui_Widget_Widget(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_Layout_class; +extern JSObject *jsb_cocos2d_ui_Layout_prototype; + +bool js_cocos2dx_ui_Layout_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_Layout_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_Layout(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_Layout_setBackGroundColorVector(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_setClippingType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_setBackGroundColorType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_setLoopFocus(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_setBackGroundImageColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_getBackGroundColorVector(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_getClippingType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_isLoopFocus(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_removeBackGroundImage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_getBackGroundColorOpacity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_isClippingEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_setBackGroundImageOpacity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_setBackGroundImage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_setBackGroundColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_requestDoLayout(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_getBackGroundImageCapInsets(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_getBackGroundColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_setClippingEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_getBackGroundImageColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_isBackGroundImageScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_getBackGroundColorType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_getBackGroundEndColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_setBackGroundColorOpacity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_getBackGroundImageOpacity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_isPassFocusToChild(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_setBackGroundImageCapInsets(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_getBackGroundImageTextureSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_forceDoLayout(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_getLayoutType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_setPassFocusToChild(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_getBackGroundStartColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_setBackGroundImageScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_setLayoutType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_createInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Layout_Layout(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_Button_class; +extern JSObject *jsb_cocos2d_ui_Button_prototype; + +bool js_cocos2dx_ui_Button_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_Button_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_Button(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_Button_getNormalTextureSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_getTitleText(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_setTitleFontSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_getTitleRenderer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_getZoomScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_getCapInsetsDisabledRenderer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_setTitleColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_setCapInsetsDisabledRenderer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_loadTextureDisabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_setTitleText(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_setCapInsetsNormalRenderer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_loadTexturePressed(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_setTitleFontName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_getCapInsetsNormalRenderer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_getCapInsetsPressedRenderer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_loadTextures(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_loadTextureNormal(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_setCapInsetsPressedRenderer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_getTitleFontSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_getTitleFontName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_getTitleColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_setPressedActionEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_setZoomScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_createInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Button_Button(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_CheckBox_class; +extern JSObject *jsb_cocos2d_ui_CheckBox_prototype; + +bool js_cocos2dx_ui_CheckBox_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_CheckBox_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_CheckBox(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_CheckBox_loadTextureBackGroundSelected(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_CheckBox_loadTextureBackGroundDisabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_CheckBox_setSelected(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_CheckBox_loadTextureFrontCross(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_CheckBox_isSelected(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_CheckBox_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_CheckBox_loadTextures(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_CheckBox_getZoomScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_CheckBox_loadTextureBackGround(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_CheckBox_setZoomScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_CheckBox_loadTextureFrontCrossDisabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_CheckBox_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_CheckBox_createInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_CheckBox_CheckBox(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_ImageView_class; +extern JSObject *jsb_cocos2d_ui_ImageView_prototype; + +bool js_cocos2dx_ui_ImageView_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_ImageView_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_ImageView(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_ImageView_loadTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ImageView_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ImageView_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ImageView_setTextureRect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ImageView_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ImageView_getCapInsets(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ImageView_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ImageView_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ImageView_createInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ImageView_ImageView(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_Text_class; +extern JSObject *jsb_cocos2d_ui_Text_prototype; + +bool js_cocos2dx_ui_Text_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_Text_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_Text(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_Text_enableShadow(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_getFontSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_getString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_disableEffect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_getTextColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_setTextVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_setFontName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_setTouchScaleChangeEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_setString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_isTouchScaleChangeEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_getFontName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_setTextAreaSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_getStringLength(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_getAutoRenderSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_enableOutline(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_getType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_getTextHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_setFontSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_setTextColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_enableGlow(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_getTextVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_getTextAreaSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_setTextHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_createInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_Text(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_TextAtlas_class; +extern JSObject *jsb_cocos2d_ui_TextAtlas_prototype; + +bool js_cocos2dx_ui_TextAtlas_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_TextAtlas_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_TextAtlas(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_TextAtlas_getStringLength(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextAtlas_getString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextAtlas_setString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextAtlas_setProperty(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextAtlas_adaptRenderers(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextAtlas_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextAtlas_createInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextAtlas_TextAtlas(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_LoadingBar_class; +extern JSObject *jsb_cocos2d_ui_LoadingBar_prototype; + +bool js_cocos2dx_ui_LoadingBar_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_LoadingBar_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_LoadingBar(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_LoadingBar_setPercent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LoadingBar_loadTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LoadingBar_setDirection(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LoadingBar_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LoadingBar_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LoadingBar_getDirection(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LoadingBar_getCapInsets(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LoadingBar_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LoadingBar_getPercent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LoadingBar_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LoadingBar_createInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LoadingBar_LoadingBar(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_ScrollView_class; +extern JSObject *jsb_cocos2d_ui_ScrollView_prototype; + +bool js_cocos2dx_ui_ScrollView_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_ScrollView_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_ScrollView(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_ScrollView_scrollToTop(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_scrollToPercentHorizontal(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_isInertiaScrollEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_scrollToPercentBothDirection(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_getDirection(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_scrollToBottomLeft(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_getInnerContainer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_jumpToBottom(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_setDirection(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_scrollToTopLeft(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_jumpToTopRight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_jumpToBottomLeft(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_setInnerContainerSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_getInnerContainerSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_isBounceEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_jumpToPercentVertical(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_setInertiaScrollEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_jumpToTopLeft(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_jumpToPercentHorizontal(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_jumpToBottomRight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_setBounceEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_jumpToTop(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_scrollToLeft(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_jumpToPercentBothDirection(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_scrollToPercentVertical(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_scrollToBottom(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_scrollToBottomRight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_jumpToLeft(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_scrollToRight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_jumpToRight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_scrollToTopRight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_createInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ScrollView_ScrollView(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_ListView_class; +extern JSObject *jsb_cocos2d_ui_ListView_prototype; + +bool js_cocos2dx_ui_ListView_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_ListView_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_ListView(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_ListView_getIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_removeAllItems(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_setGravity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_pushBackCustomItem(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_getItems(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_removeItem(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_getCurSelectedIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_insertDefaultItem(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_requestRefreshView(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_setItemsMargin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_refreshView(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_removeLastItem(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_getItemsMargin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_getItem(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_setItemModel(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_doLayout(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_pushBackDefaultItem(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_insertCustomItem(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_createInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_ListView_ListView(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_Slider_class; +extern JSObject *jsb_cocos2d_ui_Slider_prototype; + +bool js_cocos2dx_ui_Slider_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_Slider_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_Slider(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_Slider_setPercent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_loadSlidBallTextureDisabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_loadSlidBallTextureNormal(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_loadBarTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_loadProgressBarTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_loadSlidBallTextures(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_setCapInsetsBarRenderer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_setZoomScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_getZoomScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_loadSlidBallTexturePressed(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_getCapInsetsBarRenderer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_getPercent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_createInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_Slider(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_UICCTextField_class; +extern JSObject *jsb_cocos2d_ui_UICCTextField_prototype; + +bool js_cocos2dx_ui_UICCTextField_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_UICCTextField_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_UICCTextField(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_UICCTextField_onTextFieldAttachWithIME(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_setPasswordText(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_setAttachWithIME(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_getDeleteBackward(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_getAttachWithIME(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_onTextFieldDeleteBackward(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_getInsertText(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_deleteBackward(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_setInsertText(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_getDetachWithIME(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_getCharCount(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_closeIME(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_setPasswordEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_setMaxLengthEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_isPasswordEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_insertText(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_setPasswordStyleText(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_onTextFieldInsertText(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_onTextFieldDetachWithIME(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_getMaxLength(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_isMaxLengthEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_openIME(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_setDetachWithIME(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_setMaxLength(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_setDeleteBackward(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_UICCTextField_UICCTextField(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_TextField_class; +extern JSObject *jsb_cocos2d_ui_TextField_prototype; + +bool js_cocos2dx_ui_TextField_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_TextField_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_TextField(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_TextField_setAttachWithIME(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_getFontSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_getString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_setPasswordStyleText(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_getDeleteBackward(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_getPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_getAttachWithIME(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_setFontName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_getInsertText(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_setInsertText(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_setString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_getDetachWithIME(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_setTextVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_didNotSelectSelf(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_getFontName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_setTextAreaSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_attachWithIME(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_getStringLength(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_getAutoRenderSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_setPasswordEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_getPlaceHolderColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_getPasswordStyleText(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_setMaxLengthEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_isPasswordEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_setDeleteBackward(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_setFontSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_setPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_setPlaceHolderColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_setTextHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_setTextColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_getMaxLength(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_isMaxLengthEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_setDetachWithIME(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_setTouchAreaEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_setMaxLength(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_setTouchSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_getTouchSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_createInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextField_TextField(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_TextBMFont_class; +extern JSObject *jsb_cocos2d_ui_TextBMFont_prototype; + +bool js_cocos2dx_ui_TextBMFont_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_TextBMFont_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_TextBMFont(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_TextBMFont_setFntFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextBMFont_getStringLength(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextBMFont_setString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextBMFont_getString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextBMFont_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextBMFont_createInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_TextBMFont_TextBMFont(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_PageView_class; +extern JSObject *jsb_cocos2d_ui_PageView_prototype; + +bool js_cocos2dx_ui_PageView_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_PageView_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_PageView(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_PageView_getCustomScrollThreshold(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_getCurPageIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_addWidgetToPage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_isUsingCustomScrollThreshold(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_getPage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_removePage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_setUsingCustomScrollThreshold(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_setCustomScrollThreshold(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_insertPage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_scrollToPage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_removePageAtIndex(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_getPages(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_removeAllPages(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_addPage(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_createInstance(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_PageView_PageView(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_Helper_class; +extern JSObject *jsb_cocos2d_ui_Helper_prototype; + +bool js_cocos2dx_ui_Helper_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_Helper_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_Helper(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_Helper_getSubStringOfUTF8String(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Helper_changeLayoutSystemActiveState(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Helper_seekActionWidgetByActionTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Helper_seekWidgetByName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Helper_seekWidgetByTag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Helper_restrictCapInsetRect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Helper_doLayout(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_RichElement_class; +extern JSObject *jsb_cocos2d_ui_RichElement_prototype; + +bool js_cocos2dx_ui_RichElement_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_RichElement_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_RichElement(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_RichElement_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RichElement_RichElement(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_RichElementText_class; +extern JSObject *jsb_cocos2d_ui_RichElementText_prototype; + +bool js_cocos2dx_ui_RichElementText_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_RichElementText_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_RichElementText(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_RichElementText_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RichElementText_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RichElementText_RichElementText(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_RichElementImage_class; +extern JSObject *jsb_cocos2d_ui_RichElementImage_prototype; + +bool js_cocos2dx_ui_RichElementImage_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_RichElementImage_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_RichElementImage(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_RichElementImage_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RichElementImage_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RichElementImage_RichElementImage(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_RichElementCustomNode_class; +extern JSObject *jsb_cocos2d_ui_RichElementCustomNode_prototype; + +bool js_cocos2dx_ui_RichElementCustomNode_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_RichElementCustomNode_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_RichElementCustomNode(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_RichElementCustomNode_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RichElementCustomNode_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RichElementCustomNode_RichElementCustomNode(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_RichText_class; +extern JSObject *jsb_cocos2d_ui_RichText_prototype; + +bool js_cocos2dx_ui_RichText_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_RichText_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_RichText(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_RichText_insertElement(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RichText_pushBackElement(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RichText_setVerticalSpace(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RichText_formatText(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RichText_removeElement(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RichText_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_RichText_RichText(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_HBox_class; +extern JSObject *jsb_cocos2d_ui_HBox_prototype; + +bool js_cocos2dx_ui_HBox_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_HBox_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_HBox(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_HBox_initWithSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_HBox_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_HBox_HBox(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_VBox_class; +extern JSObject *jsb_cocos2d_ui_VBox_prototype; + +bool js_cocos2dx_ui_VBox_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_VBox_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_VBox(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_VBox_initWithSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_VBox_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_VBox_VBox(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_RelativeBox_class; +extern JSObject *jsb_cocos2d_ui_RelativeBox_prototype; + +bool js_cocos2dx_ui_RelativeBox_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_RelativeBox_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_RelativeBox(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_RelativeBox_initWithSize(JSContext *cx, uint32_t argc, jsval *vp); +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, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject 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_setScale9Enabled(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_resizableSpriteWithCapInsets(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_setState(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_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_getBlendFunc(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_getCapInsets(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_getInsetRight(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_setBlendFunc(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; + +bool js_cocos2dx_ui_EditBox_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_EditBox_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_EditBox(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_EditBox_getText(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_EditBox_setFontSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_EditBox_setPlaceholderFontName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_EditBox_getPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_EditBox_setFontName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_EditBox_setText(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_EditBox_setPlaceholderFontSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_EditBox_setInputMode(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_EditBox_setPlaceholderFontColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_EditBox_setFontColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_EditBox_setPlaceholderFont(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_EditBox_initWithSizeAndBackgroundSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_EditBox_setPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_EditBox_setReturnType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_EditBox_setInputFlag(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_EditBox_getMaxLength(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_EditBox_setMaxLength(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_EditBox_setFont(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_EditBox_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_EditBox_EditBox(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_cocos2d_ui_LayoutComponent_class; +extern JSObject *jsb_cocos2d_ui_LayoutComponent_prototype; + +bool js_cocos2dx_ui_LayoutComponent_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_LayoutComponent_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_LayoutComponent(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx_ui(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_ui_LayoutComponent_setStretchWidthEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setPercentWidth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_getAnchorPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setPositionPercentXEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setStretchHeightEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setActiveEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_getRightMargin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_getSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setAnchorPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_refreshLayout(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_isPercentWidthEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setVerticalEdge(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_getTopMargin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setSizeWidth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_getPercentContentSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_getVerticalEdge(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setPercentWidthEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_isStretchWidthEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setLeftMargin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_getSizeWidth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setPositionPercentYEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_getSizeHeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_getPositionPercentY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_getPositionPercentX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setTopMargin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_getPercentHeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_getUsingPercentContentSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setPositionPercentY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setPositionPercentX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setRightMargin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_isPositionPercentYEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setPercentHeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setPercentOnlyEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setHorizontalEdge(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setUsingPercentContentSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_getLeftMargin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_getPosition(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setSizeHeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_isPositionPercentXEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_getBottomMargin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setPercentHeightEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setPercentContentSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_isPercentHeightEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_getPercentWidth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_getHorizontalEdge(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_isStretchHeightEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setBottomMargin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_setSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_bindLayoutComponent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_LayoutComponent_LayoutComponent(JSContext *cx, uint32_t argc, jsval *vp); +#endif + diff --git a/cocos/scripting/js-bindings/manual/3d/jsb_cocos2dx_3d_manual.cpp b/cocos/scripting/js-bindings/manual/3d/jsb_cocos2dx_3d_manual.cpp new file mode 100644 index 0000000000..9085c4670d --- /dev/null +++ b/cocos/scripting/js-bindings/manual/3d/jsb_cocos2dx_3d_manual.cpp @@ -0,0 +1,307 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 "jsb_cocos2dx_3d_manual.h" +#include "cocos2d_specifics.hpp" +#include "jsb_cocos2dx_3d_auto.hpp" + +using namespace cocos2d; + +class JSB_HeapValueWrapper{ +public: + JSB_HeapValueWrapper(JSContext* cx, JS::HandleValue value):_cx(cx), _data(value){ + JS::AddValueRoot(_cx, &_data); + } + + ~JSB_HeapValueWrapper(){ + JS::RemoveValueRoot(_cx, &_data); + } + + JS::Value get(){ + return _data.get(); + } +private: + JSContext* _cx; + JS::Heap _data; +}; + +static bool js_cocos2dx_Sprite3D_createAsync(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if(argc == 4 || argc == 5) + { + std::string modelPath; + jsval_to_std_string(cx, args.get(0), &modelPath); + + std::function callback; + std::shared_ptr func(new JSFunctionWrapper(cx, args.get(argc == 4 ? 2 : 3).toObjectOrNull(), args.get(argc == 4 ? 1 : 2))); + auto lambda = [=](Sprite3D* larg0, void* larg1) -> void{ + + jsval largv[2]; + js_proxy_t* proxy = js_get_or_create_proxy(cx, larg0); + largv[0] = proxy ? OBJECT_TO_JSVAL(proxy->obj) : JS::UndefinedValue(); + JSB_HeapValueWrapper* v = (JSB_HeapValueWrapper*)larg1; + largv[1] = v->get(); + + JS::RootedValue rval(cx); + bool ok = func->invoke(2, largv, &rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + + delete v; + }; + callback = lambda; + + JSB_HeapValueWrapper* data = new JSB_HeapValueWrapper(cx, args.get(argc == 4 ? 3 : 4)); + + if(argc == 4) + cocos2d::Sprite3D::createAsync(modelPath, callback, data); + else + { + std::string texturePath; + jsval_to_std_string(cx, args.get(1), &texturePath); + cocos2d::Sprite3D::createAsync(modelPath, texturePath, callback, data); + } + return true; + } + + JS_ReportError(cx, "wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Sprite3D_getAABB(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite3D* cobj = (cocos2d::Sprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Sprite3D_setCullFaceEnabled : Invalid Native Object"); + if(argc == 0) + { + cocos2d::AABB aabb = cobj->getAABB(); + + JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); + JS::RootedValue min(cx, vector3_to_jsval(cx, aabb._min)); + JS::RootedValue max(cx, vector3_to_jsval(cx, aabb._max)); + + bool ok = JS_DefineProperty(cx, tmp, "min", min, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "max", max, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Sprite3D_setCullFaceEnabled : Error processing arguments"); + + args.rval().set(OBJECT_TO_JSVAL(tmp)); + return true; + } + JS_ReportError(cx, "wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Mesh_getMeshVertexAttribute(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_getMeshVertexAttribute : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Mesh_getMeshVertexAttribute : Error processing arguments"); + const cocos2d::MeshVertexAttrib ret = cobj->getMeshVertexAttribute(arg0); + jsval jsret = JSVAL_NULL; + jsret = meshVertexAttrib_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_Mesh_getMeshVertexAttribute : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_CCTextureCube_setTexParameters(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + TextureCube* cobj = (TextureCube*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + if (argc == 4) + { + bool ok = true; + + GLuint arg0, arg1, arg2, arg3; + + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + ok &= jsval_to_uint32(cx, args.get(3), &arg3); + + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + Texture2D::TexParams param = { arg0, arg1, arg2, arg3 }; + + cobj->setTexParameters(param); + + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} + +bool jsval_to_DetailMap(JSContext* cx, JS::HandleValue v, Terrain::DetailMap* ret) +{ + JS::RootedObject jsobj(cx, v.toObjectOrNull()); + + JS::RootedValue js_file(cx); + JS::RootedValue js_size(cx); + + std::string file; + double size; + + bool ok = JS_GetProperty(cx, jsobj, "file", &js_file) && + JS_GetProperty(cx, jsobj, "size", &js_size) && + jsval_to_std_string(cx, js_file, &file) && + JS::ToNumber(cx, js_size, &size); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + ret->_detailMapSrc = file; + ret->_detailMapSize = size; + + return true; +} + +bool jsval_to_TerrainData(JSContext* cx, JS::HandleValue v, Terrain::TerrainData* ret) +{ + JS::RootedObject jsobj(cx, v.toObjectOrNull()); + + JS::RootedValue js_heightMap(cx); + JS::RootedValue js_alphaMap(cx); + JS::RootedValue js_chunkSize(cx); + JS::RootedValue js_mapHeight(cx); + JS::RootedValue js_mapScale(cx); + JS::RootedValue js_detailMap(cx); + + std::string heightMap, alphaMap; + Size chunkSize; + double mapScale, mapHeight; + + bool ok = true; + ok &= JS_GetProperty(cx, jsobj, "heightMap", &js_heightMap) && + JS_GetProperty(cx, jsobj, "alphaMap", &js_alphaMap) && + JS_GetProperty(cx, jsobj, "chunkSize", &js_chunkSize) && + JS_GetProperty(cx, jsobj, "mapHeight", &js_mapHeight) && + JS_GetProperty(cx, jsobj, "mapScale", &js_mapScale) && + JS_GetProperty(cx, jsobj, "detailMap", &js_detailMap) && + jsval_to_std_string(cx, js_heightMap, &heightMap) && + jsval_to_std_string(cx, js_alphaMap, &alphaMap) && + jsval_to_ccsize(cx, js_chunkSize, &chunkSize) && + JS::ToNumber(cx, js_mapScale, &mapScale) && + JS::ToNumber(cx, js_mapHeight, &mapHeight); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + ret->_heightMapSrc = heightMap.c_str(); + char* tmp = (char*)malloc(sizeof(char) * (alphaMap.size() + 1)); + strcpy(tmp, alphaMap.c_str()); + tmp[alphaMap.size()] = '\0'; + ret->_alphaMapSrc = tmp; + ret->_chunkSize = chunkSize; + ret->_mapHeight = mapHeight; + ret->_mapScale = mapScale; + ret->_skirtHeightRatio = 1; + + JS::RootedObject jsobj_detailMap(cx, js_detailMap.toObjectOrNull()); + uint32_t length = 0; + JS_GetArrayLength(cx, jsobj_detailMap, &length); + for(uint32_t i = 0; i < length; ++i) + { + JS::RootedValue element(cx); + JS_GetElement(cx, jsobj_detailMap, i, &element); + + Terrain::DetailMap dm; + jsval_to_DetailMap(cx, element, &dm); + ret->_detailMaps[i] = dm; + } + ret->_detailMapAmount = length; + + return true; +} + +bool js_cocos2dx_Terrain_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if(argc == 1 || argc == 2) + { + bool ok = true; + Terrain* ret = nullptr; + + Terrain::TerrainData arg0; + ok &= jsval_to_TerrainData(cx, args.get(0), &arg0); + if(argc == 1) + { + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + ret = Terrain::create(arg0); + } + else if(argc == 2) + { + Terrain::CrackFixedType arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t*)&arg1); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + ret = Terrain::create(arg0, arg1); + } + + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (Terrain*)ret); + args.rval().set(OBJECT_TO_JSVAL(jsProxy->obj)); + return true; + } + JS_ReportError(cx, "wrong number of arguments"); + return false; +} + +void register_all_cocos2dx_3d_manual(JSContext *cx, JS::HandleObject global) +{ + JS::RootedValue tmpVal(cx); + JS::RootedObject ccObj(cx); + JS::RootedObject tmpObj(cx); + get_or_create_js_obj(cx, global, "jsb", &ccObj); + + JS_GetProperty(cx, ccObj, "Sprite3D", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "createAsync", js_cocos2dx_Sprite3D_createAsync, 4, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_GetProperty(cx, ccObj, "Terrain", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_Terrain_create, 2, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Sprite3D_prototype), "getAABB", js_cocos2dx_Sprite3D_getAABB, 0, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Mesh_prototype), "getMeshVertexAttribute", js_cocos2dx_Mesh_getMeshVertexAttribute, 1, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_TextureCube_prototype), "setTexParameters", js_cocos2dx_CCTextureCube_setTexParameters, 4, JSPROP_READONLY | JSPROP_PERMANENT); +} diff --git a/cocos/scripting/js-bindings/manual/3d/jsb_cocos2dx_3d_manual.h b/cocos/scripting/js-bindings/manual/3d/jsb_cocos2dx_3d_manual.h new file mode 100644 index 0000000000..d496e1cd83 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/3d/jsb_cocos2dx_3d_manual.h @@ -0,0 +1,33 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 __jsb_cocos2dx_3d_manual_h__ +#define __jsb_cocos2dx_3d_manual_h__ + +#include "jsapi.h" + +void register_all_cocos2dx_3d_manual(JSContext *cx, JS::HandleObject global); + +#endif \ No newline at end of file diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp new file mode 100644 index 0000000000..935d212a2d --- /dev/null +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -0,0 +1,1860 @@ +/* + * Created by Rolando Abarca on 3/14/12. + * Copyright (c) 2012 Zynga Inc. All rights reserved. + * 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. + */ + +#include "ScriptingCore.h" + +// Removed in Firefox v27, use 'js/OldDebugAPI.h' instead +//#include "jsdbgapi.h" +#include "js/OldDebugAPI.h" + +#include "cocos2d.h" +#include "local-storage/LocalStorage.h" +#include "cocos2d_specifics.hpp" +#include "jsb_cocos2dx_auto.hpp" +#include "js_bindings_config.h" +// for debug socket +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#include +#include +#else +#include +#include +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef ANDROID +#include +#include +#include +#endif + +#ifdef ANDROID +#define LOG_TAG "ScriptingCore.cpp" +#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) +#else +#define LOGD(...) js_log(__VA_ARGS__) +#endif + +#include "js_bindings_config.h" + +#if COCOS2D_DEBUG +#define TRACE_DEBUGGER_SERVER(...) CCLOG(__VA_ARGS__) +#else +#define TRACE_DEBUGGER_SERVER(...) +#endif // #if DEBUG + +#define BYTE_CODE_FILE_EXT ".jsc" + +using namespace cocos2d; + +static std::string inData; +static std::string outData; +static std::vector g_queue; +static std::mutex g_qMutex; +static std::mutex g_rwMutex; +static int clientSocket = -1; +static uint32_t s_nestedLoopLevel = 0; + +// server entry point for the bg thread +static void serverEntryPoint(unsigned int port); + +js_proxy_t *_native_js_global_ht = NULL; +js_proxy_t *_js_native_global_ht = NULL; +std::unordered_map _js_global_type_map; + +static char *_js_log_buf = NULL; + +static std::vector registrationList; + +// name ~> JSScript map +static std::unordered_map filename_script; +// port ~> socket map +static std::unordered_map ports_sockets; +// name ~> globals +static std::unordered_map globals; + +static void cc_closesocket(int fd) +{ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) + closesocket(fd); +#else + close(fd); +#endif +} + +static void ReportException(JSContext *cx) +{ + if (JS_IsExceptionPending(cx)) { + if (!JS_ReportPendingException(cx)) { + JS_ClearPendingException(cx); + } + } +} + +static void executeJSFunctionFromReservedSpot(JSContext *cx, JS::HandleObject obj, + const JS::HandleValueArray& dataVal, JS::MutableHandleValue retval) { + + JS::RootedValue func(cx, JS_GetReservedSlot(obj, 0)); + + if (func.isNullOrUndefined()) { return; } + JS::RootedValue thisObj(cx, JS_GetReservedSlot(obj, 1)); + JSAutoCompartment ac(cx, obj); + + if (thisObj.isNullOrUndefined()) { + JS_CallFunctionValue(cx, obj, func, dataVal, retval); + } else { + assert(!thisObj.isPrimitive()); + JS_CallFunctionValue(cx, JS::RootedObject(cx, thisObj.toObjectOrNull()), func, dataVal, retval); + } +} + +static std::string getTouchesFuncName(EventTouch::EventCode eventCode) +{ + std::string funcName; + switch(eventCode) + { + case EventTouch::EventCode::BEGAN: + funcName = "onTouchesBegan"; + break; + case EventTouch::EventCode::ENDED: + funcName = "onTouchesEnded"; + break; + case EventTouch::EventCode::MOVED: + funcName = "onTouchesMoved"; + break; + case EventTouch::EventCode::CANCELLED: + funcName = "onTouchesCancelled"; + break; + default: + CCASSERT(false, "Invalid event code!"); + break; + } + return funcName; +} + +static std::string getTouchFuncName(EventTouch::EventCode eventCode) +{ + std::string funcName; + switch(eventCode) { + case EventTouch::EventCode::BEGAN: + funcName = "onTouchBegan"; + break; + case EventTouch::EventCode::ENDED: + funcName = "onTouchEnded"; + break; + case EventTouch::EventCode::MOVED: + funcName = "onTouchMoved"; + break; + case EventTouch::EventCode::CANCELLED: + funcName = "onTouchCancelled"; + break; + default: + CCASSERT(false, "Invalid event code!"); + } + + return funcName; +} + +static std::string getMouseFuncName(EventMouse::MouseEventType eventType) +{ + std::string funcName; + switch(eventType) { + case EventMouse::MouseEventType::MOUSE_DOWN: + funcName = "onMouseDown"; + break; + case EventMouse::MouseEventType::MOUSE_UP: + funcName = "onMouseUp"; + break; + case EventMouse::MouseEventType::MOUSE_MOVE: + funcName = "onMouseMove"; + break; + case EventMouse::MouseEventType::MOUSE_SCROLL: + funcName = "onMouseScroll"; + break; + default: + CCASSERT(false, "Invalid event code!"); + } + + return funcName; +} + +static void rootObject(JSContext *cx, JS::Heap *obj) { + AddNamedObjectRoot(cx, obj, "unnamed"); +} + + +static void unRootObject(JSContext *cx, JS::Heap *obj) { + RemoveObjectRoot(cx, obj); +} + +void removeJSObject(JSContext* cx, void* nativeObj) +{ + js_proxy_t* nproxy; + js_proxy_t* jsproxy; + + nproxy = jsb_get_native_proxy(nativeObj); + if (nproxy) { + jsproxy = jsb_get_js_proxy(nproxy->obj); + RemoveObjectRoot(cx, &jsproxy->obj); + jsb_remove_proxy(nproxy, jsproxy); + } +} + +void ScriptingCore::executeJSFunctionWithThisObj(JS::HandleValue thisObj, JS::HandleValue callback) +{ + JS::RootedValue retVal(_cx); + executeJSFunctionWithThisObj(thisObj, callback, JS::HandleValueArray::empty(), &retVal); +} + +void ScriptingCore::executeJSFunctionWithThisObj(JS::HandleValue thisObj, + JS::HandleValue callback, + const JS::HandleValueArray& vp, + JS::MutableHandleValue retVal) +{ + if (!callback.isNullOrUndefined() || !thisObj.isNullOrUndefined()) + { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + // Very important: The last parameter 'retVal' passed to 'JS_CallFunctionValue' should not be a NULL pointer. + // If it's a NULL pointer, crash will be triggered in 'JS_CallFunctionValue'. To find out the reason of this crash is very difficult. + // So we have to check the availability of 'retVal'. +// if (retVal) +// { + JS_CallFunctionValue(_cx, JS::RootedObject(_cx, thisObj.toObjectOrNull()), callback, vp, retVal); +// } +// else +// { +// jsval jsRet; +// JS_CallFunctionValue(_cx, JSVAL_TO_OBJECT(thisObj), callback, argc, vp, &jsRet); +// } + } +} + +void js_log(const char *format, ...) { + + if (_js_log_buf == NULL) + { + _js_log_buf = (char *)calloc(sizeof(char), MAX_LOG_LENGTH+1); + _js_log_buf[MAX_LOG_LENGTH] = '\0'; + } + va_list vl; + va_start(vl, format); + int len = vsnprintf(_js_log_buf, MAX_LOG_LENGTH, format, vl); + va_end(vl); + if (len > 0) + { + CCLOG("JS: %s", _js_log_buf); + } +} + +bool JSBCore_platform(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc!=0) + { + JS_ReportError(cx, "Invalid number of arguments in __getPlatform"); + return false; + } + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + Application::Platform platform; + + // config.deviceType: Device Type + // 'mobile' for any kind of mobile devices, 'desktop' for PCs, 'browser' for Web Browsers + // #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) + // platform = JS_InternString(_cx, "desktop"); + // #else + platform = Application::getInstance()->getTargetPlatform(); + // #endif + + args.rval().set(INT_TO_JSVAL((int)platform)); + + return true; +}; + +bool JSBCore_version(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc!=0) + { + JS_ReportError(cx, "Invalid number of arguments in __getVersion"); + return false; + } + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + char version[256]; + snprintf(version, sizeof(version)-1, "%s", cocos2dVersion()); + JSString * js_version = JS_InternString(cx, version); + + args.rval().set(STRING_TO_JSVAL(js_version)); + + return true; +}; + +bool JSBCore_os(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc!=0) + { + JS_ReportError(cx, "Invalid number of arguments in __getOS"); + return false; + } + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + JSString * os; + + // osx, ios, android, windows, linux, etc.. +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + os = JS_InternString(cx, "iOS"); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + os = JS_InternString(cx, "Android"); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) + os = JS_InternString(cx, "Windows"); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE) + os = JS_InternString(cx, "Marmalade"); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) + os = JS_InternString(cx, "Linux"); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_BADA) + os = JS_InternString(cx, "Bada"); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY) + os = JS_InternString(cx, "Blackberry"); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) + os = JS_InternString(cx, "OS X"); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) + os = JS_InternString(cx, "WP8"); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) + os = JS_InternString(cx, "WINRT"); +#else + os = JS_InternString(cx, "Unknown"); +#endif + + args.rval().set(STRING_TO_JSVAL(os)); + + 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; + } + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSString *jsPath = args.get(0).toString(); + JSB_PRECONDITION2(jsPath, cx, false, "Error js file in clean script"); + JSStringWrapper wrapper(jsPath); + ScriptingCore::getInstance()->cleanScript(wrapper.get()); + + args.rval().setUndefined(); + + 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"); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + ScriptingCore::getInstance()->reset(); + args.rval().setUndefined(); + return true; +}; + +void registerDefaultClasses(JSContext* cx, JS::HandleObject global) { + // first, try to get the ns + JS::RootedValue nsval(cx); + JS::RootedObject ns(cx); + JS_GetProperty(cx, global, "cc", &nsval); + // Not exist, create it + if (nsval == JSVAL_VOID) + { + ns.set(JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr())); + nsval = OBJECT_TO_JSVAL(ns); + JS_SetProperty(cx, global, "cc", nsval); + } + else + { + ns.set(nsval.toObjectOrNull()); + } + + // + // Javascript controller (__jsc__) + // + JS::RootedObject proto(cx); + JS::RootedObject parent(cx); + JS::RootedObject jsc(cx, JS_NewObject(cx, NULL, proto, parent)); + JS::RootedValue jscVal(cx); + jscVal = OBJECT_TO_JSVAL(jsc); + JS_SetProperty(cx, global, "__jsc__", jscVal); + + JS_DefineFunction(cx, jsc, "garbageCollect", ScriptingCore::forceGC, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(cx, jsc, "dumpRoot", ScriptingCore::dumpRoot, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(cx, jsc, "addGCRootObject", ScriptingCore::addRootJS, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(cx, jsc, "removeGCRootObject", ScriptingCore::removeRootJS, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(cx, jsc, "executeScript", ScriptingCore::executeScript, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + + // register some global functions + JS_DefineFunction(cx, global, "require", ScriptingCore::executeScript, 1, JSPROP_READONLY | JSPROP_PERMANENT); + 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); + JS_DefineFunction(cx, global, "__isObjectValid", ScriptingCore::isObjectValid, 1, JSPROP_READONLY | JSPROP_PERMANENT); +} + +static void sc_finalize(JSFreeOp *freeOp, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (global class)", obj); +} + +//static JSClass global_class = { +// "global", JSCLASS_GLOBAL_FLAGS, +// JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub, +// JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, sc_finalize, +// JSCLASS_NO_OPTIONAL_MEMBERS +//}; + +static const JSClass global_class = { + "global", JSCLASS_GLOBAL_FLAGS, + JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub, + JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, sc_finalize, + nullptr, nullptr, nullptr, + JS_GlobalObjectTraceHook +}; + + +ScriptingCore::ScriptingCore() +: _rt(nullptr) +, _cx(nullptr) +//, _global(nullptr) +//, _debugGlobal(nullptr) +, _callFromScript(false) +{ + // 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(); +} + +void ScriptingCore::string_report(JS::HandleValue val) { + if (val.isNull()) { + LOGD("val : (JSVAL_IS_NULL(val)"); + // return 1; + } else if (val.isBoolean() && false == val.toBoolean()) { + LOGD("val : (return value is false"); + // return 1; + } else if (val.isString()) { + JSContext* cx = this->getGlobalContext(); + JS::RootedString str(cx, val.toString()); + if (str.get()) { + LOGD("val : return string is NULL"); + } else { + JSStringWrapper wrapper(str); + LOGD("val : return string =\n%s\n", wrapper.get()); + } + } else if (val.isNumber()) { + double number = val.toNumber(); + LOGD("val : return number =\n%f", number); + } +} + +bool ScriptingCore::evalString(const char *string, jsval *outVal, const char *filename, JSContext* cx, JSObject* global) +{ + if (cx == NULL) + cx = _cx; + if (global == NULL) + global = _global.ref().get(); + + JSAutoCompartment ac(cx, global); + return JS_EvaluateScript(cx, JS::RootedObject(cx, global), string, strlen(string), "ScriptingCore::evalString", 1); +} + +void ScriptingCore::start() +{ + // for now just this + createGlobalContext(); +} + +void ScriptingCore::addRegisterCallback(sc_register_sth callback) { + registrationList.push_back(callback); +} + +void ScriptingCore::removeAllRoots(JSContext *cx) { + js_proxy_t *current, *tmp; + HASH_ITER(hh, _js_native_global_ht, current, tmp) { + RemoveObjectRoot(cx, ¤t->obj); + HASH_DEL(_js_native_global_ht, current); + free(current); + } + HASH_ITER(hh, _native_js_global_ht, current, tmp) { + HASH_DEL(_native_js_global_ht, current); + free(current); + } + HASH_CLEAR(hh, _js_native_global_ht); + HASH_CLEAR(hh, _native_js_global_ht); +} + +// Just a wrapper around JSPrincipals that allows static construction. +class CCJSPrincipals : public JSPrincipals +{ + public: + explicit CCJSPrincipals(int rc = 0) + : JSPrincipals() + { + refcount = rc; + } +}; + +static CCJSPrincipals shellTrustedPrincipals(1); + +static bool +CheckObjectAccess(JSContext *cx) +{ + return true; +} + +static JSSecurityCallbacks securityCallbacks = { + CheckObjectAccess, + NULL +}; + +void ScriptingCore::createGlobalContext() { + if (_cx && _rt) { + ScriptingCore::removeAllRoots(_cx); + JS_DestroyContext(_cx); + JS_DestroyRuntime(_rt); + _cx = NULL; + _rt = NULL; + } + + // Start the engine. Added in SpiderMonkey v25 + if (!JS_Init()) + return; + + // Removed from Spidermonkey 19. + //JS_SetCStringsAreUTF8(); + _rt = JS_NewRuntime(8L * 1024L * 1024L); + JS_SetGCParameter(_rt, JSGC_MAX_BYTES, 0xffffffff); + + JS_SetTrustedPrincipals(_rt, &shellTrustedPrincipals); + JS_SetSecurityCallbacks(_rt, &securityCallbacks); + JS_SetNativeStackQuota(_rt, JSB_MAX_STACK_QUOTA); + + _cx = JS_NewContext(_rt, 8192); + + // Removed in Firefox v27 +// JS_SetOptions(this->_cx, JSOPTION_TYPE_INFERENCE); + // Removed in Firefox v33 +// JS::ContextOptionsRef(_cx).setTypeInference(true); + + JS::RuntimeOptionsRef(_rt).setIon(true); + JS::RuntimeOptionsRef(_rt).setBaseline(true); + +// JS_SetVersion(this->_cx, JSVERSION_LATEST); + + JS_SetErrorReporter(_cx, ScriptingCore::reportError); +#if defined(JS_GC_ZEAL) && defined(DEBUG) + //JS_SetGCZeal(this->_cx, 2, JS_DEFAULT_ZEAL_FREQ); +#endif + + _global.construct(_cx); + _global.ref() = NewGlobalObject(_cx); + + JSAutoCompartment ac(_cx, _global.ref()); + + // Removed in Firefox v34 + js::SetDefaultObjectForContext(_cx, _global.ref()); + + for (std::vector::iterator it = registrationList.begin(); it != registrationList.end(); it++) { + sc_register_sth callback = *it; + callback(_cx, _global.ref()); + } +} + +static std::string RemoveFileExt(const std::string& filePath) { + size_t pos = filePath.rfind('.'); + if (0 < pos) { + return filePath.substr(0, pos); + } + else { + return filePath; + } +} + +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.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.find(fullPath) != filename_script.end()) + return filename_script[fullPath]; + + return NULL; +} + +void ScriptingCore::compileScript(const char *path, JSObject* global, JSContext* cx) +{ + if (!path) { + return; + } + + if (getScript(path)) { + return; + } + + cocos2d::FileUtils *futil = cocos2d::FileUtils::getInstance(); + + if (global == NULL) { + global = _global.ref().get(); + } + if (cx == NULL) { + cx = _cx; + } + + JSAutoCompartment ac(cx, global); + + JS::RootedScript script(cx); + JS::RootedObject obj(cx, global); + + // a) check jsc file first + std::string byteCodePath = RemoveFileExt(std::string(path)) + BYTE_CODE_FILE_EXT; + + // Check whether '.jsc' files exist to avoid outputing log which says 'couldn't find .jsc file'. + if (futil->isFileExist(byteCodePath)) + { + Data data = futil->getDataFromFile(byteCodePath); + if (!data.isNull()) + { + script = JS_DecodeScript(cx, data.getBytes(), static_cast(data.getSize()), nullptr); + } + } + + // b) no jsc file, check js file + if (!script) + { + /* Clear any pending exception from previous failed decoding. */ + ReportException(cx); + + std::string fullPath = futil->fullPathForFilename(path); + + JS::CompileOptions op(cx); + op.setUTF8(true); + op.setFileAndLine(fullPath.c_str(), 1); + + bool ok = false; +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + std::string jsFileContent = futil->getStringFromFile(fullPath); + if (!jsFileContent.empty()) + { + ok = JS::Compile(cx, obj, op, jsFileContent.c_str(), jsFileContent.size(), &script); + } +#else + ok = JS::Compile(cx, obj, op, fullPath.c_str(), &script); +#endif + if (ok) { + filename_script[fullPath] = script; + } + } + else { + filename_script[byteCodePath] = script; + } +} + +void ScriptingCore::cleanScript(const char *path) +{ + std::string byteCodePath = RemoveFileExt(std::string(path)) + BYTE_CODE_FILE_EXT; + auto it = filename_script.find(byteCodePath); + if (it != filename_script.end()) + { + filename_script.erase(it); + } + + std::string fullPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(path); + it = filename_script.find(fullPath); + if (it != filename_script.end()) + { + filename_script.erase(it); + } +} + +std::unordered_map &ScriptingCore::getFileScript() +{ + return filename_script; +} + +void ScriptingCore::cleanAllScript() +{ + filename_script.clear(); +} + +bool ScriptingCore::runScript(const char *path) +{ + return runScript(path, _global.ref(), _cx); +} + +bool ScriptingCore::runScript(const char *path, JS::HandleObject global, JSContext* cx) +{ + if (cx == NULL) { + cx = _cx; + } + + compileScript(path,global,cx); + JS::RootedScript script(cx, getScript(path)); + bool evaluatedOK = false; + if (script) { + JS::RootedValue rval(cx); + JSAutoCompartment ac(cx, global); + evaluatedOK = JS_ExecuteScript(cx, global, script, &rval); + if (false == evaluatedOK) { + cocos2d::log("(evaluatedOK == JS_FALSE)"); + JS_ReportPendingException(cx); + } + } + + return evaluatedOK; +} + +void ScriptingCore::reset() +{ + Director::getInstance()->restart(); +} + +void ScriptingCore::restartVM() +{ + cleanup(); + initRegister(); + CCApplication::getInstance()->applicationDidFinishLaunching(); +} + +ScriptingCore::~ScriptingCore() +{ + cleanup(); +} + +void ScriptingCore::cleanup() +{ + localStorageFree(); + removeAllRoots(_cx); + if (_cx) + { + JS_DestroyContext(_cx); + _cx = NULL; + } + if (_rt) + { + JS_DestroyRuntime(_rt); + _rt = NULL; + } + JS_ShutDown(); + if (_js_log_buf) { + free(_js_log_buf); + _js_log_buf = NULL; + } + + for (auto iter = _js_global_type_map.begin(); iter != _js_global_type_map.end(); ++iter) + { + free(iter->second->jsclass); + free(iter->second); + } + + _js_global_type_map.clear(); + filename_script.clear(); + registrationList.clear(); +} + +void ScriptingCore::reportError(JSContext *cx, const char *message, JSErrorReport *report) +{ + js_log("%s:%u:%s\n", + report->filename ? report->filename : "", + (unsigned int) report->lineno, + message); +}; + + +bool ScriptingCore::log(JSContext* cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc > 0) { + JSString *string = JS::ToString(cx, args.get(0)); + if (string) { + JSStringWrapper wrapper(string); + js_log("%s", wrapper.get()); + } + } + args.rval().setUndefined(); + return true; +} + + +void ScriptingCore::removeScriptObjectByObject(Ref* pObj) +{ + js_proxy_t* nproxy; + js_proxy_t* jsproxy; + void *ptr = (void*)pObj; + nproxy = jsb_get_native_proxy(ptr); + if (nproxy) { + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + jsproxy = jsb_get_js_proxy(nproxy->obj); + RemoveObjectRoot(cx, &jsproxy->obj); + jsb_remove_proxy(nproxy, jsproxy); + } +} + + +bool ScriptingCore::setReservedSpot(uint32_t i, JSObject *obj, jsval value) { + JS_SetReservedSlot(obj, i, value); + return true; +} + +bool ScriptingCore::executeScript(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc >= 1) { + JSString* str = JS::ToString(cx, JS::RootedValue(cx, args.get(0))); + JSStringWrapper path(str); + bool res = false; + if (argc == 2 && args.get(1).isString()) { + JSString* globalName = args.get(1).toString(); + JSStringWrapper name(globalName); + + JS::RootedObject debugObj(cx, ScriptingCore::getInstance()->getDebugGlobal()); + if (debugObj) { + res = ScriptingCore::getInstance()->runScript(path.get(), debugObj); + } else { + JS_ReportError(cx, "Invalid global object: %s", name.get()); + return false; + } + } else { + JS::RootedObject glob(cx, JS::CurrentGlobalOrNull(cx)); + res = ScriptingCore::getInstance()->runScript(path.get(), glob); + } + return res; + } + args.rval().setUndefined(); + return true; +} + +bool ScriptingCore::forceGC(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSRuntime *rt = JS_GetRuntime(cx); + JS_GC(rt); + return true; +} + +//static void dumpNamedRoot(const char *name, void *addr, JSGCRootType type, void *data) +//{ +// CCLOG("Root: '%s' at %p", name, addr); +//} + +bool ScriptingCore::dumpRoot(JSContext *cx, uint32_t argc, jsval *vp) +{ + // JS_DumpNamedRoots is only available on DEBUG versions of SpiderMonkey. + // Mac and Simulator versions were compiled with DEBUG. +#if COCOS2D_DEBUG +// JSContext *_cx = ScriptingCore::getInstance()->getGlobalContext(); +// JSRuntime *rt = JS_GetRuntime(_cx); +// JS_DumpNamedRoots(rt, dumpNamedRoot, NULL); +// JS_DumpHeap(rt, stdout, NULL, JSTRACE_OBJECT, NULL, 2, NULL); +#endif + return true; +} + +bool ScriptingCore::addRootJS(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc == 1) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::Heap o(args.get(0).toObjectOrNull()); + if (AddNamedObjectRoot(cx, &o, "from-js") == false) { + LOGD("something went wrong when setting an object to the root"); + } + + return true; + } + return false; +} + +bool ScriptingCore::removeRootJS(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc == 1) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::Heap o(args.get(0).toObjectOrNull()); + if (o != nullptr) { + RemoveObjectRoot(cx, &o); + } + return true; + } + return false; +} + +void ScriptingCore::pauseSchedulesAndActions(js_proxy_t* p) +{ + JS::RootedObject obj(_cx, p->obj.get()); + __Array * arr = JSScheduleWrapper::getTargetForJSObject(obj); + if (! arr) return; + + Node* node = (Node*)p->ptr; + for(ssize_t i = 0; i < arr->count(); ++i) { + if (arr->getObjectAtIndex(i)) { + node->getScheduler()->pauseTarget(arr->getObjectAtIndex(i)); + } + } +} + + +void ScriptingCore::resumeSchedulesAndActions(js_proxy_t* p) +{ + JS::RootedObject obj(_cx, p->obj.get()); + __Array * arr = JSScheduleWrapper::getTargetForJSObject(obj); + if (!arr) return; + + Node* node = (Node*)p->ptr; + for(ssize_t i = 0; i < arr->count(); ++i) { + if (!arr->getObjectAtIndex(i)) continue; + node->getScheduler()->resumeTarget(arr->getObjectAtIndex(i)); + } +} + +void ScriptingCore::cleanupSchedulesAndActions(js_proxy_t* p) +{ + JS::RootedObject obj(_cx, p->obj.get()); + __Array* arr = JSScheduleWrapper::getTargetForJSObject(obj); + if (arr) { + Node* node = (Node*)p->ptr; + Scheduler* pScheduler = node->getScheduler(); + Ref* pObj = nullptr; + CCARRAY_FOREACH(arr, pObj) + { + pScheduler->unscheduleAllForTarget(pObj); + } + + JSScheduleWrapper::removeAllTargetsForJSObject(obj); + } +} + +bool ScriptingCore::isFunctionOverridedInJS(JS::HandleObject obj, const std::string& name, JSNative native) +{ + JS::RootedValue value(_cx); + bool ok = JS_GetProperty(_cx, obj, name.c_str(), &value); + if (ok && !value.isNullOrUndefined() && !JS_IsNativeFunction(value.toObjectOrNull(), native)) + { + return true; + } + + return false; +} + +int ScriptingCore::handleNodeEvent(void* data) +{ + if (NULL == data) + return 0; + + BasicScriptData* basicScriptData = static_cast(data); + if (NULL == basicScriptData->nativeObject || NULL == basicScriptData->value) + return 0; + + Node* node = static_cast(basicScriptData->nativeObject); + int action = *((int*)(basicScriptData->value)); + + js_proxy_t * p = jsb_get_native_proxy(node); + if (!p) return 0; + + int ret = 0; + JS::RootedValue retval(_cx); + jsval dataVal = INT_TO_JSVAL(1); + + if (action == kNodeOnEnter) + { + if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onEnter", js_cocos2dx_Node_onEnter)) + { + ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onEnter", 1, &dataVal, &retval); + } + resumeSchedulesAndActions(p); + } + else if (action == kNodeOnExit) + { + if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onExit", js_cocos2dx_Node_onExit)) + { + ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onExit", 1, &dataVal, &retval); + } + pauseSchedulesAndActions(p); + } + else if (action == kNodeOnEnterTransitionDidFinish) + { + if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onEnterTransitionDidFinish", js_cocos2dx_Node_onEnterTransitionDidFinish)) + { + ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onEnterTransitionDidFinish", 1, &dataVal, &retval); + } + } + else if (action == kNodeOnExitTransitionDidStart) + { + if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onExitTransitionDidStart", js_cocos2dx_Node_onExitTransitionDidStart)) + { + ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onExitTransitionDidStart", 1, &dataVal, &retval); + } + } + else if (action == kNodeOnCleanup) { + cleanupSchedulesAndActions(p); + } + + return ret; +} + +int ScriptingCore::handleComponentEvent(void* data) +{ + if (NULL == data) + return 0; + + BasicScriptData* basicScriptData = static_cast(data); + if (NULL == basicScriptData->nativeObject || NULL == basicScriptData->value) + return 0; + + Component* node = static_cast(basicScriptData->nativeObject); + int action = *((int*)(basicScriptData->value)); + + js_proxy_t * p = jsb_get_native_proxy(node); + if (!p) return 0; + + int ret = 0; + JS::RootedValue retval(_cx); + jsval dataVal = INT_TO_JSVAL(1); + + if (action == kComponentOnEnter) + { + if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onEnter", js_cocos2dx_Component_onEnter)) + { + ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onEnter", 1, &dataVal, &retval); + } + resumeSchedulesAndActions(p); + } + else if (action == kComponentOnExit) + { + if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onExit", js_cocos2dx_Component_onExit)) + { + ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onExit", 1, &dataVal, &retval); + } + pauseSchedulesAndActions(p); + } + else if (action == kComponentOnUpdate) + { + if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "update", js_cocos2dx_Component_update)) + { + ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "update", 1, &dataVal, &retval); + } + } + + return ret; +} + +bool ScriptingCore::handleTouchesEvent(void* nativeObj, cocos2d::EventTouch::EventCode eventCode, const std::vector& touches, cocos2d::Event* event) +{ + JS::RootedValue ret(_cx); + return handleTouchesEvent(nativeObj, eventCode, touches, event, &ret); +} + +bool ScriptingCore::handleTouchesEvent(void* nativeObj, cocos2d::EventTouch::EventCode eventCode, const std::vector& touches, cocos2d::Event* event, JS::MutableHandleValue jsvalRet) +{ + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + bool ret = false; + + std::string funcName = getTouchesFuncName(eventCode); + + JS::RootedObject jsretArr(_cx, JS_NewArrayObject(this->_cx, 0)); + +// AddNamedObjectRoot(this->_cx, &jsretArr, "touchArray"); + int count = 0; + + for (const auto& touch : touches) + { + JS::RootedValue jsret(_cx, getJSObject(this->_cx, touch)); + if (!JS_SetElement(this->_cx, jsretArr, count, jsret)) + { + break; + } + ++count; + } + + do + { + js_proxy_t * p = jsb_get_native_proxy(nativeObj); + if (!p) break; + + jsval dataVal[2]; + dataVal[0] = OBJECT_TO_JSVAL(jsretArr); + dataVal[1] = getJSObject(_cx, event); + + ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 2, dataVal, jsvalRet); + + + } while(false); + +// JS_RemoveObjectRoot(this->_cx, &jsretArr); + + for (auto& touch : touches) + { + removeJSObject(this->_cx, touch); + } + + removeJSObject(_cx, event); + + return ret; +} + +bool ScriptingCore::handleTouchEvent(void* nativeObj, cocos2d::EventTouch::EventCode eventCode, cocos2d::Touch* touch, cocos2d::Event* event) +{ + JS::RootedValue ret(_cx); + return handleTouchEvent(nativeObj, eventCode, touch, event, &ret); +} + +bool ScriptingCore::handleTouchEvent(void* nativeObj, cocos2d::EventTouch::EventCode eventCode, cocos2d::Touch* touch, cocos2d::Event* event, JS::MutableHandleValue jsvalRet) +{ + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + std::string funcName = getTouchFuncName(eventCode); + bool ret = false; + + do + { + js_proxy_t * p = jsb_get_native_proxy(nativeObj); + if (!p) break; + + jsval dataVal[2]; + dataVal[0] = getJSObject(_cx, touch); + dataVal[1] = getJSObject(_cx, event); + +// if (jsvalRet != nullptr) +// { + ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 2, dataVal, jsvalRet); +// } +// else +// { +// JS::RootedValue retval(_cx); +// executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 2, dataVal, &retval); +// if(retval.isNull()) +// { +// ret = false; +// } +// else if(retval.isBoolean()) +// { +// ret = retval.toBoolean(); +// } +// else +// { +// ret = false; +// } +// } + } while(false); + + removeJSObject(_cx, touch); + removeJSObject(_cx, event); + + return ret; +} + +bool ScriptingCore::handleMouseEvent(void* nativeObj, cocos2d::EventMouse::MouseEventType eventType, cocos2d::Event* event) +{ + JS::RootedValue ret(_cx); + return handleMouseEvent(nativeObj, eventType, event, &ret); +} + +bool ScriptingCore::handleMouseEvent(void* nativeObj, cocos2d::EventMouse::MouseEventType eventType, cocos2d::Event* event, JS::MutableHandleValue jsvalRet) +{ + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + std::string funcName = getMouseFuncName(eventType); + bool ret = false; + + do + { + js_proxy_t * p = jsb_get_native_proxy(nativeObj); + if (!p) break; + + jsval dataVal[1]; + dataVal[0] = getJSObject(_cx, event); + +// if (jsvalRet != nullptr) +// { + ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 1, dataVal, jsvalRet); +// } +// else +// { +// JS::RootedValue retval(_cx); +// executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 1, dataVal, &retval); +// if(retval.isNull()) +// { +// ret = false; +// } +// else if(retval.isBoolean()) +// { +// ret = retval.toBoolean(); +// } +// else +// { +// ret = false; +// } +// } + } while(false); + + removeJSObject(_cx, event); + + return ret; +} + +bool ScriptingCore::executeFunctionWithObjectData(void* nativeObj, const char *name, JSObject *obj) { + + js_proxy_t * p = jsb_get_native_proxy(nativeObj); + if (!p) return false; + + JS::RootedValue retval(_cx); + jsval dataVal = OBJECT_TO_JSVAL(obj); + + executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), name, 1, &dataVal, &retval); + if (retval.isNull()) { + return false; + } + else if (retval.isBoolean()) { + return retval.toBoolean(); + } + return false; +} + +bool ScriptingCore::executeFunctionWithOwner(jsval owner, const char *name, uint32_t argc, jsval *vp) +{ + JS::HandleValueArray args = JS::HandleValueArray::fromMarkedLocation(argc, vp); + JS::RootedValue rval(_cx); + return executeFunctionWithOwner(owner, name, args, &rval); +} + +bool ScriptingCore::executeFunctionWithOwner(jsval owner, const char *name, uint32_t argc, jsval *vp, JS::MutableHandleValue retVal) +{ + //should not use CallArgs here, use HandleValueArray instead !! + //because the "jsval* vp" is not the standard format from JSNative, the array doesn't contain this and retval + //JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::HandleValueArray args = JS::HandleValueArray::fromMarkedLocation(argc, vp); + return executeFunctionWithOwner(owner, name, args, retVal); +} + +bool ScriptingCore::executeFunctionWithOwner(jsval owner, const char *name, const JS::HandleValueArray& args) +{ + JS::RootedValue ret(_cx); + return executeFunctionWithOwner(owner, name, args, &ret); +} + +bool ScriptingCore::executeFunctionWithOwner(jsval owner, const char *name, const JS::HandleValueArray& args, JS::MutableHandleValue retVal) +{ + bool bRet = false; + bool hasAction; + JSContext* cx = this->_cx; + JS::RootedValue temp_retval(cx); + JS::RootedObject obj(cx, JS::RootedValue(cx, owner).toObjectOrNull()); + + do + { + JSAutoCompartment ac(cx, obj); + + if (JS_HasProperty(cx, obj, name, &hasAction) && hasAction) { + if (!JS_GetProperty(cx, obj, name, &temp_retval)) { + break; + } + if (temp_retval == JSVAL_VOID) { + break; + } + + bRet = JS_CallFunctionName(cx, obj, name, args, retVal); + + } + }while(0); + return bRet; +} + +bool ScriptingCore::handleKeybardEvent(void* nativeObj, cocos2d::EventKeyboard::KeyCode keyCode, bool isPressed, cocos2d::Event* event) +{ + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + js_proxy_t * p = jsb_get_native_proxy(nativeObj); + + if (nullptr == p) + return false; + + bool ret = false; + + jsval args[2] = { + int32_to_jsval(_cx, (int32_t)keyCode), + getJSObject(_cx, event) + }; + + if (isPressed) + { + ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "_onKeyPressed", 2, args); + } + else + { + ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "_onKeyReleased", 2, args); + } + + removeJSObject(_cx, event); + + return ret; +} + +bool ScriptingCore::handleFocusEvent(void* nativeObj, cocos2d::ui::Widget* widgetLoseFocus, cocos2d::ui::Widget* widgetGetFocus) +{ + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + js_proxy_t * p = jsb_get_native_proxy(nativeObj); + + if (nullptr == p) + return false; + + jsval args[2] = { + getJSObject(_cx, widgetLoseFocus), + getJSObject(_cx, widgetGetFocus) + }; + + bool ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onFocusChanged", 2, args); + + return ret; +} + + +int ScriptingCore::executeCustomTouchesEvent(EventTouch::EventCode eventType, + const std::vector& touches, JSObject *obj) +{ + std::string funcName = getTouchesFuncName(eventType); + + JS::RootedObject jsretArr(_cx, JS_NewArrayObject(this->_cx, 0)); +// JS_AddNamedObjectRoot(this->_cx, &jsretArr, "touchArray"); + int count = 0; + for (auto& touch : touches) + { + jsval jsret = getJSObject(this->_cx, touch); + JS::RootedValue jsval(_cx, jsret); + if (!JS_SetElement(this->_cx, jsretArr, count, jsval)) { + break; + } + ++count; + } + + jsval jsretArrVal = OBJECT_TO_JSVAL(jsretArr); + executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), funcName.c_str(), 1, &jsretArrVal); +// JS_RemoveObjectRoot(this->_cx, &jsretArr); + + for (auto& touch : touches) + { + removeJSObject(this->_cx, touch); + } + + return 1; +} + + +int ScriptingCore::executeCustomTouchEvent(EventTouch::EventCode eventType, + Touch *pTouch, JSObject *obj) +{ + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JS::RootedValue retval(_cx); + std::string funcName = getTouchFuncName(eventType); + + jsval jsTouch = getJSObject(this->_cx, pTouch); + + executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), funcName.c_str(), 1, &jsTouch, &retval); + + // Remove touch object from global hash table and unroot it. + removeJSObject(this->_cx, pTouch); + + return 1; + +} + + +int ScriptingCore::executeCustomTouchEvent(EventTouch::EventCode eventType, + Touch *pTouch, JSObject *obj, + JS::MutableHandleValue retval) +{ + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + std::string funcName = getTouchFuncName(eventType); + + jsval jsTouch = getJSObject(this->_cx, pTouch); + + executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), funcName.c_str(), 1, &jsTouch, retval); + + // Remove touch object from global hash table and unroot it. + removeJSObject(this->_cx, pTouch); + + return 1; + +} + +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.ref().get()); + + switch (evt->type) + { + case kNodeEvent: + { + return handleNodeEvent(evt->data); + } + break; + case kMenuClickedEvent: + break; + case kTouchEvent: + { + TouchScriptData* data = (TouchScriptData*)evt->data; + return handleTouchEvent(data->nativeObject, data->actionType, data->touch, data->event); + } + break; + case kTouchesEvent: + { + TouchesScriptData* data = (TouchesScriptData*)evt->data; + return handleTouchesEvent(data->nativeObject, data->actionType, data->touches, data->event); + } + break; + case kComponentEvent: + { + return handleComponentEvent(evt->data); + } + break; + default: + CCASSERT(false, "Invalid script event."); + break; + } + + return 0; +} + +bool ScriptingCore::parseConfig(ConfigType type, const std::string &str) +{ + jsval args[2]; + args[0] = int32_to_jsval(_cx, static_cast(type)); + args[1] = std_string_to_jsval(_cx, str); + return (true == executeFunctionWithOwner(OBJECT_TO_JSVAL(_global.ref().get()), "__onParseConfig", 2, args)); +} + +bool ScriptingCore::isObjectValid(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 1) { + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(tmpObj); + if (proxy && proxy->ptr) { + args.rval().set(JSVAL_TRUE); + } + else { + args.rval().set(JSVAL_FALSE); + } + return true; + } + else { + JS_ReportError(cx, "Invalid number of arguments: %d. Expecting: 1", argc); + return false; + } +} + +#pragma mark - Debug + +void SimpleRunLoop::update(float dt) +{ + g_qMutex.lock(); + size_t size = g_queue.size(); + g_qMutex.unlock(); + + while (size > 0) + { + g_qMutex.lock(); + auto first = g_queue.begin(); + std::string str = *first; + g_queue.erase(first); + size = g_queue.size(); + g_qMutex.unlock(); + + ScriptingCore::getInstance()->debugProcessInput(str); + } +} + +void ScriptingCore::debugProcessInput(const std::string& str) +{ + JSAutoCompartment ac(_cx, _debugGlobal.ref()); + + JSString* jsstr = JS_NewStringCopyZ(_cx, str.c_str()); + jsval argv = STRING_TO_JSVAL(jsstr); + JS::RootedValue outval(_cx); + + JS_CallFunctionName(_cx, JS::RootedObject(_cx, _debugGlobal.ref()), "processInput", JS::HandleValueArray::fromMarkedLocation(1, &argv), &outval); +} + +static bool NS_ProcessNextEvent() +{ + g_qMutex.lock(); + size_t size = g_queue.size(); + g_qMutex.unlock(); + + while (size > 0) + { + g_qMutex.lock(); + auto first = g_queue.begin(); + std::string str = *first; + g_queue.erase(first); + size = g_queue.size(); + g_qMutex.unlock(); + + ScriptingCore::getInstance()->debugProcessInput(str); + } +// std::this_thread::yield(); + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + + return true; +} + +bool JSBDebug_enterNestedEventLoop(JSContext* cx, unsigned argc, jsval* vp) +{ + enum { + NS_OK = 0, + NS_ERROR_UNEXPECTED + }; + +#define NS_SUCCEEDED(v) ((v) == NS_OK) + + int rv = NS_OK; + + uint32_t nestLevel = ++s_nestedLoopLevel; + + while (NS_SUCCEEDED(rv) && s_nestedLoopLevel >= nestLevel) { + if (!NS_ProcessNextEvent()) + rv = NS_ERROR_UNEXPECTED; + } + + CCASSERT(s_nestedLoopLevel <= nestLevel, + "nested event didn't unwind properly"); + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().set(UINT_TO_JSVAL(s_nestedLoopLevel)); +// JS_SET_RVAL(cx, vp, UINT_TO_JSVAL(s_nestedLoopLevel)); + return true; +} + +bool JSBDebug_exitNestedEventLoop(JSContext* cx, unsigned argc, jsval* vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (s_nestedLoopLevel > 0) { + --s_nestedLoopLevel; + } else { + args.rval().set(UINT_TO_JSVAL(0)); +// JS_SET_RVAL(cx, vp, UINT_TO_JSVAL(0)); + return true; + } + args.rval().setUndefined(); +// JS_SET_RVAL(cx, vp, UINT_TO_JSVAL(s_nestedLoopLevel)); + return true; +} + +bool JSBDebug_getEventLoopNestLevel(JSContext* cx, unsigned argc, jsval* vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().set(UINT_TO_JSVAL(s_nestedLoopLevel)); +// JS_SET_RVAL(cx, vp, UINT_TO_JSVAL(s_nestedLoopLevel)); + return true; +} + +//#pragma mark - Debugger + +static void _clientSocketWriteAndClearString(std::string& s) +{ + ::send(clientSocket, s.c_str(), s.length(), 0); + s.clear(); +} + +static void processInput(const std::string& data) { + std::lock_guard lk(g_qMutex); + g_queue.push_back(data); +} + +static void clearBuffers() { + std::lock_guard lk(g_rwMutex); + // only process input if there's something and we're not locked + if (inData.length() > 0) { + processInput(inData); + inData.clear(); + } + if (outData.length() > 0) { + _clientSocketWriteAndClearString(outData); + } +} + +static void serverEntryPoint(unsigned int port) +{ + // start a server, accept the connection and keep reading data from it + struct addrinfo hints, *result = nullptr, *rp = nullptr; + int s = 0; + memset(&hints, 0, sizeof(struct addrinfo)); + hints.ai_family = AF_INET; // IPv4 + hints.ai_socktype = SOCK_STREAM; // TCP stream sockets + hints.ai_flags = AI_PASSIVE; // fill in my IP for me + + std::stringstream portstr; + portstr << port; + + int err = 0; + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) + WSADATA wsaData; + err = WSAStartup(MAKEWORD(2, 2),&wsaData); +#endif + + if ((err = getaddrinfo(NULL, portstr.str().c_str(), &hints, &result)) != 0) { + LOGD("getaddrinfo error : %s\n", gai_strerror(err)); + } + + for (rp = result; rp != NULL; rp = rp->ai_next) { + if ((s = socket(rp->ai_family, rp->ai_socktype, 0)) < 0) { + continue; + } + int optval = 1; + if ((setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&optval, sizeof(optval))) < 0) { + cc_closesocket(s); + TRACE_DEBUGGER_SERVER("debug server : error setting socket option SO_REUSEADDR"); + return; + } + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + if ((setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, &optval, sizeof(optval))) < 0) { + close(s); + TRACE_DEBUGGER_SERVER("debug server : error setting socket option SO_NOSIGPIPE"); + return; + } +#endif //(CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + + if ((::bind(s, rp->ai_addr, rp->ai_addrlen)) == 0) { + break; + } + cc_closesocket(s); + s = -1; + } + if (s < 0 || rp == NULL) { + TRACE_DEBUGGER_SERVER("debug server : error creating/binding socket"); + return; + } + + freeaddrinfo(result); + + listen(s, 1); + + while (true) { + clientSocket = accept(s, NULL, NULL); + + if (clientSocket < 0) + { + TRACE_DEBUGGER_SERVER("debug server : error on accept"); + return; + } + else + { + // read/write data + TRACE_DEBUGGER_SERVER("debug server : client connected"); + + inData = "connected"; + // process any input, send any output + clearBuffers(); + + char buf[1024] = {0}; + int readBytes = 0; + while ((readBytes = (int)::recv(clientSocket, buf, sizeof(buf), 0)) > 0) + { + buf[readBytes] = '\0'; + // TRACE_DEBUGGER_SERVER("debug server : received command >%s", buf); + + // no other thread is using this + inData.append(buf); + // process any input, send any output + clearBuffers(); + } // while(read) + + cc_closesocket(clientSocket); + } + } // while(true) +} + +bool JSBDebug_BufferWrite(JSContext* cx, unsigned argc, jsval* vp) +{ + if (argc == 1) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSStringWrapper strWrapper(args.get(0)); + // this is safe because we're already inside a lock (from clearBuffers) + outData.append(strWrapper.get()); + _clientSocketWriteAndClearString(outData); + } + return true; +} + +void ScriptingCore::enableDebugger(unsigned int port) +{ + if (_debugGlobal.empty()) + { + JSAutoCompartment ac0(_cx, _global.ref().get()); + + JS_SetDebugMode(_cx, true); + + _debugGlobal.construct(_cx); + _debugGlobal.ref() = NewGlobalObject(_cx, true); + // Adds the debugger object to root, otherwise it may be collected by GC. + //AddObjectRoot(_cx, &_debugGlobal.ref()); no need, it's persistent rooted now + //JS_WrapObject(_cx, &_debugGlobal.ref()); Not really needed, JS_WrapObject makes a cross-compartment wrapper for the given JS object + JS::RootedObject rootedDebugObj(_cx, _debugGlobal.ref().get()); + JSAutoCompartment ac(_cx, rootedDebugObj); + // these are used in the debug program + JS_DefineFunction(_cx, rootedDebugObj, "log", ScriptingCore::log, 0, JSPROP_READONLY | JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(_cx, rootedDebugObj, "_bufferWrite", JSBDebug_BufferWrite, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(_cx, rootedDebugObj, "_enterNestedEventLoop", JSBDebug_enterNestedEventLoop, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(_cx, rootedDebugObj, "_exitNestedEventLoop", JSBDebug_exitNestedEventLoop, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(_cx, rootedDebugObj, "_getEventLoopNestLevel", JSBDebug_getEventLoopNestLevel, 0, JSPROP_READONLY | JSPROP_PERMANENT); + + runScript("script/jsb_debugger.js", rootedDebugObj); + + JS::RootedObject globalObj(_cx, _global.ref().get()); + JS_WrapObject(_cx, &globalObj); + // prepare the debugger + jsval argv = OBJECT_TO_JSVAL(globalObj); + JS::RootedValue outval(_cx); + bool ok = JS_CallFunctionName(_cx, rootedDebugObj, "_prepareDebugger", JS::HandleValueArray::fromMarkedLocation(1, &argv), &outval); + if (!ok) { + JS_ReportPendingException(_cx); + } + + // start bg thread + auto t = std::thread(&serverEntryPoint,port); + t.detach(); + + Scheduler* scheduler = Director::getInstance()->getScheduler(); + scheduler->scheduleUpdate(this->_runLoop, 0, false); + } +} + +JSObject* NewGlobalObject(JSContext* cx, bool debug) +{ + JS::CompartmentOptions options; + options.setVersion(JSVERSION_LATEST); + + JS::RootedObject glob(cx, JS_NewGlobalObject(cx, &global_class, &shellTrustedPrincipals, JS::DontFireOnNewGlobalHook, options)); + if (!glob) { + return NULL; + } + JSAutoCompartment ac(cx, glob); + bool ok = true; + ok = JS_InitStandardClasses(cx, glob); + if (ok) + JS_InitReflect(cx, glob); + if (ok && debug) + ok = JS_DefineDebuggerObject(cx, glob); + if (!ok) + return NULL; + + JS_FireOnNewGlobalObject(cx, glob); + + return glob; +} + +bool jsb_set_reserved_slot(JSObject *obj, uint32_t idx, jsval value) +{ + const JSClass *klass = JS_GetClass(obj); + unsigned int slots = JSCLASS_RESERVED_SLOTS(klass); + if ( idx >= slots ) + return false; + + JS_SetReservedSlot(obj, idx, value); + + return true; +} + +bool jsb_get_reserved_slot(JSObject *obj, uint32_t idx, jsval& ret) +{ + const JSClass *klass = JS_GetClass(obj); + unsigned int slots = JSCLASS_RESERVED_SLOTS(klass); + if ( idx >= slots ) + return false; + + ret = JS_GetReservedSlot(obj, idx); + + return true; +} + +js_proxy_t* jsb_new_proxy(void* nativeObj, JSObject* jsObj) +{ + js_proxy_t* p = nullptr; + JS_NEW_PROXY(p, nativeObj, jsObj); + return p; +} + +js_proxy_t* jsb_get_native_proxy(void* nativeObj) +{ + js_proxy_t* p = nullptr; + JS_GET_PROXY(p, nativeObj); + return p; +} + +js_proxy_t* jsb_get_js_proxy(JSObject* jsObj) +{ + js_proxy_t* p = nullptr; + JS_GET_NATIVE_PROXY(p, jsObj); + return p; +} + +void jsb_remove_proxy(js_proxy_t* nativeProxy, js_proxy_t* jsProxy) +{ + JS_REMOVE_PROXY(nativeProxy, jsProxy); +} + + diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.h b/cocos/scripting/js-bindings/manual/ScriptingCore.h new file mode 100644 index 0000000000..f8c41785f0 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -0,0 +1,302 @@ +/* + * Created by Rolando Abarca on 3/14/12. + * Copyright (c) 2012 Zynga Inc. All rights reserved. + * 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. + */ + +#ifndef __SCRIPTING_CORE_H__ +#define __SCRIPTING_CORE_H__ + + +#include "jsapi.h" +#include "jsfriendapi.h" +#include "cocos2d.h" +#include "ui/CocosGUI.h" +#include "js_bindings_config.h" +#include "js_bindings_core.h" +#include "spidermonkey_specifics.h" +#include "js_manual_conversions.h" +#include "mozilla/Maybe.h" + +#include +#include + +#define ENGINE_VERSION "Cocos2d-JS v3.6" + +void js_log(const char *format, ...); + +typedef void (*sc_register_sth)(JSContext* cx, JS::HandleObject global); + +void registerDefaultClasses(JSContext* cx, JS::HandleObject global); + + +class SimpleRunLoop : public cocos2d::Ref +{ +public: + void update(float d); +}; + +class ScriptingCore : public cocos2d::ScriptEngineProtocol +{ +private: + JSRuntime *_rt; + JSContext *_cx; + mozilla::Maybe _global; + mozilla::Maybe _debugGlobal; + //JS::Heap _global; + //JS::Heap _debugGlobal; + SimpleRunLoop* _runLoop; + + bool _callFromScript; + ScriptingCore(); +public: + ~ScriptingCore(); + + static ScriptingCore *getInstance() { + static ScriptingCore* pInstance = NULL; + if (pInstance == NULL) { + pInstance = new ScriptingCore(); + } + return pInstance; + }; + + virtual cocos2d::ccScriptType getScriptType() { return cocos2d::kScriptTypeJavascript; }; + + /** + @brief Remove Object from lua state + @param object to remove + */ + virtual void removeScriptObjectByObject(cocos2d::Ref* obj); + + /** + @brief Execute script code contained in the given string. + @param codes holding the valid script code that should be executed. + @return 0 if the string is excuted correctly. + @return other if the string is excuted wrongly. + */ + virtual int executeString(const char* codes) { return 0; } + void pauseSchedulesAndActions(js_proxy_t* p); + void resumeSchedulesAndActions(js_proxy_t* p); + void cleanupSchedulesAndActions(js_proxy_t* p); + + /** + @brief Execute a script file. + @param filename String object holding the filename of the script file that is to be executed + */ + virtual int executeScriptFile(const char* filename) { return 0; } + + /** + @brief Execute a scripted global function. + @brief The function should not take any parameters and should return an integer. + @param functionName String object holding the name of the function, in the global script environment, that is to be executed. + @return The integer value returned from the script function. + */ + virtual int executeGlobalFunction(const char* functionName) { return 0; } + + virtual int sendEvent(cocos2d::ScriptEvent* message) override; + + virtual bool parseConfig(ConfigType type, const std::string& str) override; + + virtual bool handleAssert(const char *msg) { return false; } + + virtual void setCalledFromScript(bool callFromScript) { _callFromScript = callFromScript; }; + virtual bool isCalledFromScript() { return _callFromScript; }; + + bool executeFunctionWithObjectData(void* nativeObj, const char *name, JSObject *obj); + + bool executeFunctionWithOwner(jsval owner, const char *name, uint32_t argc, jsval *vp); + bool executeFunctionWithOwner(jsval owner, const char *name, uint32_t argc, jsval *vp, JS::MutableHandleValue retVal); + bool executeFunctionWithOwner(jsval owner, const char *name, const JS::HandleValueArray& args); + bool executeFunctionWithOwner(jsval owner, const char *name, const JS::HandleValueArray& args, JS::MutableHandleValue retVal); + + void executeJSFunctionWithThisObj(JS::HandleValue thisObj, JS::HandleValue callback); + void executeJSFunctionWithThisObj(JS::HandleValue thisObj, JS::HandleValue callback, const JS::HandleValueArray& vp, JS::MutableHandleValue retVal); + + /** + * will eval the specified string + * @param string The string with the javascript code to be evaluated + * @param outVal The jsval that will hold the return value of the evaluation. + * Can be NULL. + */ + bool evalString(const char *string, jsval *outVal, const char *filename = NULL, JSContext* cx = NULL, JSObject* global = NULL); + + /** + @brief get script object for the given path + @param given script path + @return script object + */ + JSScript* getScript(const char *path); + + /** + * will compile the specified string + * @param string The path of the script to be run + */ + void compileScript(const char *path, JSObject* global = NULL, JSContext* cx = NULL); + + /** + * will run the specified string + * @param string The path of the script to be run + */ + bool runScript(const char *path); + bool runScript(const char *path, JS::HandleObject global, JSContext* cx = NULL); + + /** + * will clean script object the specified string + */ + void cleanScript(const char *path); + + std::unordered_map &getFileScript(); + /** + * will clean all script object + */ + void cleanAllScript(); + + /** + * initialize everything + */ + void start(); + + /** + * cleanup everything + */ + void cleanup(); + + /** + * cleanup everything then initialize everything + */ + void reset(); + + /** + * will add the register_sth callback to the list of functions that need to be called + * after the creation of the context + */ + void addRegisterCallback(sc_register_sth callback); + + /** + * Will create a new context. If one is already there, it will destroy the old context + * and create a new one. + */ + void createGlobalContext(); + + static void removeAllRoots(JSContext *cx); + + + int executeCustomTouchEvent(cocos2d::EventTouch::EventCode eventType, + cocos2d::Touch *pTouch, JSObject *obj, JS::MutableHandleValue retval); + int executeCustomTouchEvent(cocos2d::EventTouch::EventCode eventType, + cocos2d::Touch *pTouch, JSObject *obj); + int executeCustomTouchesEvent(cocos2d::EventTouch::EventCode eventType, + const std::vector& touches, JSObject *obj); + /** + * @return the global context + */ + JSContext* getGlobalContext() { + return _cx; + }; + + /** + * @param cx + * @param message + * @param report + */ + static void reportError(JSContext *cx, const char *message, JSErrorReport *report); + + /** + * Log something using CCLog + * @param cx + * @param argc + * @param vp + */ + static bool log(JSContext *cx, uint32_t argc, jsval *vp); + + bool setReservedSpot(uint32_t i, JSObject *obj, jsval value); + + /** + * run a script from script :) + */ + static bool executeScript(JSContext *cx, uint32_t argc, jsval *vp); + + /** + * Force a cycle of GC + * @param cx + * @param argc + * @param vp + */ + static bool forceGC(JSContext *cx, uint32_t argc, jsval *vp); + static bool dumpRoot(JSContext *cx, uint32_t argc, jsval *vp); + static bool addRootJS(JSContext *cx, uint32_t argc, jsval *vp); + static bool removeRootJS(JSContext *cx, uint32_t argc, jsval *vp); + + static bool isObjectValid(JSContext *cx, uint32_t argc, jsval *vp); + + /** + * enable the debug environment + */ + void debugProcessInput(const std::string& str); + void enableDebugger(unsigned int port = 5086); + JSObject* getDebugGlobal() { return _debugGlobal.ref().get(); } + JSObject* getGlobalObject() { return _global.ref().get(); } + + bool isFunctionOverridedInJS(JS::HandleObject obj, const std::string& name, JSNative native); + +private: + void string_report(JS::HandleValue val); + void initRegister(); + +public: + int handleNodeEvent(void* data); + int handleComponentEvent(void* data); + + bool handleTouchesEvent(void* nativeObj, cocos2d::EventTouch::EventCode eventCode, const std::vector& touches, cocos2d::Event* event); + bool handleTouchesEvent(void* nativeObj, cocos2d::EventTouch::EventCode eventCode, const std::vector& touches, cocos2d::Event* event, JS::MutableHandleValue jsvalRet); + + bool handleTouchEvent(void* nativeObj, cocos2d::EventTouch::EventCode eventCode, cocos2d::Touch* touch, cocos2d::Event* event); + bool handleTouchEvent(void* nativeObj, cocos2d::EventTouch::EventCode eventCode, cocos2d::Touch* touch, cocos2d::Event* event, JS::MutableHandleValue jsvalRet); + + bool handleMouseEvent(void* nativeObj, cocos2d::EventMouse::MouseEventType eventType, cocos2d::Event* event); + bool handleMouseEvent(void* nativeObj, cocos2d::EventMouse::MouseEventType eventType, cocos2d::Event* event, JS::MutableHandleValue jsvalRet); + + bool handleKeybardEvent(void* nativeObj, cocos2d::EventKeyboard::KeyCode keyCode, bool isPressed, cocos2d::Event* event); + bool handleFocusEvent(void* nativeObj, cocos2d::ui::Widget* widgetLoseFocus, cocos2d::ui::Widget* widgetGetFocus); + + void restartVM(); +}; + +JSObject* NewGlobalObject(JSContext* cx, bool debug = false); + +bool jsb_set_reserved_slot(JSObject *obj, uint32_t idx, jsval value); +bool jsb_get_reserved_slot(JSObject *obj, uint32_t idx, jsval& ret); + +js_proxy_t* jsb_new_proxy(void* nativeObj, JSObject* jsObj); +js_proxy_t* jsb_get_native_proxy(void* nativeObj); +js_proxy_t* jsb_get_js_proxy(JSObject* jsObj); +void jsb_remove_proxy(js_proxy_t* nativeProxy, js_proxy_t* jsProxy); + +template +jsval getJSObject(JSContext* cx, T* nativeObj) +{ + js_proxy_t *proxy = js_get_or_create_proxy(cx, nativeObj); + return proxy ? OBJECT_TO_JSVAL(proxy->obj) : JSVAL_NULL; +} + +void removeJSObject(JSContext* cx, void* nativeObj); + +#endif /* __SCRIPTING_CORE_H__ */ diff --git a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp new file mode 100644 index 0000000000..df9c30a684 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp @@ -0,0 +1,5607 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-11-07 +* Script version: v0.3 +*/ +#include "js_bindings_config.h" +#ifdef JSB_INCLUDE_CHIPMUNK + +#include "js_bindings_chipmunk_manual.h" + +#include "jsfriendapi.h" +#include "js_bindings_config.h" +#include "js_manual_conversions.h" +#include "js_bindings_chipmunk_functions.h" + +/* + * cpConstraint + */ +#pragma mark - cpConstraint + +JSClass* JSB_cpConstraint_class = NULL; +JSObject* JSB_cpConstraint_object = NULL; + +// Constructor +bool JSB_cpConstraint_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==0, cx, false, "Invalid number of arguments"); + JSB_PRECONDITION2(false, cx, true, "No constructor"); + + return true; +} + +// Destructor +void JSB_cpConstraint_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpConstraint), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + cpConstraintFree( (cpConstraint*)proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + } else { + CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpConstraint)", jsthis); + } +} + +// Arguments: +// Ret value: void +bool JSB_cpConstraint_activateBodies(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpConstraint* arg0 = (cpConstraint*) proxy->handle; + + cpConstraintActivateBodies((cpConstraint*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: +// Ret value: void +bool JSB_cpConstraint_destroy(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpConstraint* arg0 = (cpConstraint*) proxy->handle; + + cpConstraintDestroy((cpConstraint*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: +// Ret value: cpBody* +bool JSB_cpConstraint_getA(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpConstraint* arg0 = (cpConstraint*) proxy->handle; + cpBody* ret_val; + + ret_val = cpConstraintGetA((cpConstraint*)arg0 ); + + jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpBody* +bool JSB_cpConstraint_getB(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpConstraint* arg0 = (cpConstraint*) proxy->handle; + cpBody* ret_val; + + ret_val = cpConstraintGetB((cpConstraint*)arg0 ); + + jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpConstraint_getErrorBias(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpConstraint* arg0 = (cpConstraint*) proxy->handle; + cpFloat ret_val; + + ret_val = cpConstraintGetErrorBias((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpConstraint_getImpulse(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpConstraint* arg0 = (cpConstraint*) proxy->handle; + cpFloat ret_val; + + ret_val = cpConstraintGetImpulse((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpConstraint_getMaxBias(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpConstraint* arg0 = (cpConstraint*) proxy->handle; + cpFloat ret_val; + + ret_val = cpConstraintGetMaxBias((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpConstraint_getMaxForce(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpConstraint* arg0 = (cpConstraint*) proxy->handle; + cpFloat ret_val; + + ret_val = cpConstraintGetMaxForce((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpSpace* +bool JSB_cpConstraint_getSpace(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpConstraint* arg0 = (cpConstraint*) proxy->handle; + cpSpace* ret_val; + + ret_val = cpConstraintGetSpace((cpConstraint*)arg0 ); + + jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpSpace" ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpConstraint_setErrorBias(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); + cpConstraint* arg0 = (cpConstraint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpConstraintSetErrorBias((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpConstraint_setMaxBias(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); + cpConstraint* arg0 = (cpConstraint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpConstraintSetMaxBias((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpConstraint_setMaxForce(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); + cpConstraint* arg0 = (cpConstraint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpConstraintSetMaxForce((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +void JSB_cpConstraint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpConstraint_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpConstraint_class->name = name; + JSB_cpConstraint_class->addProperty = JS_PropertyStub; + JSB_cpConstraint_class->delProperty = JS_DeletePropertyStub; + JSB_cpConstraint_class->getProperty = JS_PropertyStub; + JSB_cpConstraint_class->setProperty = JS_StrictPropertyStub; + JSB_cpConstraint_class->enumerate = JS_EnumerateStub; + JSB_cpConstraint_class->resolve = JS_ResolveStub; + JSB_cpConstraint_class->convert = JS_ConvertStub; + JSB_cpConstraint_class->finalize = JSB_cpConstraint_finalize; + JSB_cpConstraint_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("activateBodies", JSB_cpConstraint_activateBodies, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("destroy", JSB_cpConstraint_destroy, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getA", JSB_cpConstraint_getA, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getB", JSB_cpConstraint_getB, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getErrorBias", JSB_cpConstraint_getErrorBias, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getImpulse", JSB_cpConstraint_getImpulse, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaxBias", JSB_cpConstraint_getMaxBias, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMaxForce", JSB_cpConstraint_getMaxForce, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSpace", JSB_cpConstraint_getSpace, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setErrorBias", JSB_cpConstraint_setErrorBias, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaxBias", JSB_cpConstraint_setMaxBias, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMaxForce", JSB_cpConstraint_setMaxForce, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpConstraint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpBase_object), JSB_cpConstraint_class, JSB_cpConstraint_constructor,0,properties,funcs,NULL,st_funcs); +// bool found; +// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +/* + * cpGrooveJoint + */ +#pragma mark - cpGrooveJoint + +JSClass* JSB_cpGrooveJoint_class = NULL; +JSObject* JSB_cpGrooveJoint_object = NULL; +// Arguments: cpBody*, cpBody*, cpVect, cpVect, cpVect +// Constructor +bool JSB_cpGrooveJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==5, cx, false, "Invalid number of arguments"); + JSObject *jsobj = JS_NewObject(cx, JSB_cpGrooveJoint_class, JS::RootedObject(cx, JSB_cpGrooveJoint_object), JS::NullPtr()); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; cpVect arg4; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg0, NULL ); + ok &= jsval_to_c_class( cx, args.get(1), (void**)&arg1, NULL ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + ok &= jsval_to_cpVect( cx, args.get(3), (cpVect*) &arg3 ); + ok &= jsval_to_cpVect( cx, args.get(4), (cpVect*) &arg4 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + void* ret_val = cpGrooveJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 , (cpVect)arg4 ); + + jsb_set_jsobject_for_proxy(jsobj, ret_val); + jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + + return true; +} + +// Destructor +void JSB_cpGrooveJoint_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpGrooveJoint), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + cpConstraintFree( (cpConstraint*)proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + } else { + CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpGrooveJoint)", jsthis); + } +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpGrooveJoint_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpGrooveJoint* arg0 = (cpGrooveJoint*) proxy->handle; + cpVect ret_val; + + ret_val = cpGrooveJointGetAnchr2((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpGrooveJoint_getGrooveA(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpGrooveJoint* arg0 = (cpGrooveJoint*) proxy->handle; + cpVect ret_val; + + ret_val = cpGrooveJointGetGrooveA((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpGrooveJoint_getGrooveB(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpGrooveJoint* arg0 = (cpGrooveJoint*) proxy->handle; + cpVect ret_val; + + ret_val = cpGrooveJointGetGrooveB((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect +// Ret value: void +bool JSB_cpGrooveJoint_setAnchr2(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); + cpGrooveJoint* arg0 = (cpGrooveJoint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpGrooveJointSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpVect +// Ret value: void +bool JSB_cpGrooveJoint_setGrooveA(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); + cpGrooveJoint* arg0 = (cpGrooveJoint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpGrooveJointSetGrooveA((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpVect +// Ret value: void +bool JSB_cpGrooveJoint_setGrooveB(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); + cpGrooveJoint* arg0 = (cpGrooveJoint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpGrooveJointSetGrooveB((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +void JSB_cpGrooveJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpGrooveJoint_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpGrooveJoint_class->name = name; + JSB_cpGrooveJoint_class->addProperty = JS_PropertyStub; + JSB_cpGrooveJoint_class->delProperty = JS_DeletePropertyStub; + JSB_cpGrooveJoint_class->getProperty = JS_PropertyStub; + JSB_cpGrooveJoint_class->setProperty = JS_StrictPropertyStub; + JSB_cpGrooveJoint_class->enumerate = JS_EnumerateStub; + JSB_cpGrooveJoint_class->resolve = JS_ResolveStub; + JSB_cpGrooveJoint_class->convert = JS_ConvertStub; + JSB_cpGrooveJoint_class->finalize = JSB_cpGrooveJoint_finalize; + JSB_cpGrooveJoint_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("getAnchr2", JSB_cpGrooveJoint_getAnchr2, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getGrooveA", JSB_cpGrooveJoint_getGrooveA, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getGrooveB", JSB_cpGrooveJoint_getGrooveB, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAnchr2", JSB_cpGrooveJoint_setAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setGrooveA", JSB_cpGrooveJoint_setGrooveA, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setGrooveB", JSB_cpGrooveJoint_setGrooveB, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpGrooveJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpGrooveJoint_class, JSB_cpGrooveJoint_constructor,0,properties,funcs,NULL,st_funcs); +// bool found; +// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +/* + * cpSimpleMotor + */ +#pragma mark - cpSimpleMotor + +JSClass* JSB_cpSimpleMotor_class = NULL; +JSObject* JSB_cpSimpleMotor_object = NULL; +// Arguments: cpBody*, cpBody*, cpFloat +// Constructor +bool JSB_cpSimpleMotor_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==3, cx, false, "Invalid number of arguments"); + JSObject *jsobj = JS_NewObject(cx, JSB_cpSimpleMotor_class, JS::RootedObject(cx, JSB_cpSimpleMotor_object), JS::NullPtr()); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; double arg2; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg0, NULL ); + ok &= jsval_to_c_class( cx, args.get(1), (void**)&arg1, NULL ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + void* ret_val = cpSimpleMotorNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 ); + + jsb_set_jsobject_for_proxy(jsobj, ret_val); + jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + + return true; +} + +// Destructor +void JSB_cpSimpleMotor_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpSimpleMotor), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + cpConstraintFree( (cpConstraint*)proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + } else { + CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpSimpleMotor)", jsthis); + } +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpSimpleMotor_getRate(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSimpleMotor* arg0 = (cpSimpleMotor*) proxy->handle; + cpFloat ret_val; + + ret_val = cpSimpleMotorGetRate((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpSimpleMotor_setRate(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); + cpSimpleMotor* arg0 = (cpSimpleMotor*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSimpleMotorSetRate((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +void JSB_cpSimpleMotor_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpSimpleMotor_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpSimpleMotor_class->name = name; + JSB_cpSimpleMotor_class->addProperty = JS_PropertyStub; + JSB_cpSimpleMotor_class->delProperty = JS_DeletePropertyStub; + JSB_cpSimpleMotor_class->getProperty = JS_PropertyStub; + JSB_cpSimpleMotor_class->setProperty = JS_StrictPropertyStub; + JSB_cpSimpleMotor_class->enumerate = JS_EnumerateStub; + JSB_cpSimpleMotor_class->resolve = JS_ResolveStub; + JSB_cpSimpleMotor_class->convert = JS_ConvertStub; + JSB_cpSimpleMotor_class->finalize = JSB_cpSimpleMotor_finalize; + JSB_cpSimpleMotor_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("getRate", JSB_cpSimpleMotor_getRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRate", JSB_cpSimpleMotor_setRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpSimpleMotor_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpSimpleMotor_class, JSB_cpSimpleMotor_constructor,0,properties,funcs,NULL,st_funcs); +// bool found; +// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +/* + * cpPivotJoint + */ +#pragma mark - cpPivotJoint + +JSClass* JSB_cpPivotJoint_class = NULL; +JSObject* JSB_cpPivotJoint_object = NULL; +// Arguments: cpBody*, cpBody*, cpVect +// Constructor +bool JSB_cpPivotJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==4 || argc==3, cx, false, "Invalid number of arguments"); + JSObject *jsobj = JS_NewObject(cx, JSB_cpPivotJoint_class, JS::RootedObject(cx, JSB_cpPivotJoint_object), JS::NullPtr()); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; void *ret_val; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg0, NULL ); + ok &= jsval_to_c_class( cx, args.get(1), (void**)&arg1, NULL ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + if(argc == 4) { + ok &= jsval_to_cpVect( cx, args.get(3), (cpVect*) &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + ret_val = cpPivotJointNew2((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2, (cpVect)arg3 ); + } else { + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + ret_val = cpPivotJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2); + } + + jsb_set_jsobject_for_proxy(jsobj, ret_val); + jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + + return true; +} +// Destructor +void JSB_cpPivotJoint_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpPivotJoint), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + cpConstraintFree( (cpConstraint*)proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + } else { + CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpPivotJoint)", jsthis); + } +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpPivotJoint_getAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpPivotJoint* arg0 = (cpPivotJoint*) proxy->handle; + cpVect ret_val; + + ret_val = cpPivotJointGetAnchr1((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpPivotJoint_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpPivotJoint* arg0 = (cpPivotJoint*) proxy->handle; + cpVect ret_val; + + ret_val = cpPivotJointGetAnchr2((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect +// Ret value: void +bool JSB_cpPivotJoint_setAnchr1(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); + cpPivotJoint* arg0 = (cpPivotJoint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpPivotJointSetAnchr1((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpVect +// Ret value: void +bool JSB_cpPivotJoint_setAnchr2(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); + cpPivotJoint* arg0 = (cpPivotJoint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpPivotJointSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +void JSB_cpPivotJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpPivotJoint_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpPivotJoint_class->name = name; + JSB_cpPivotJoint_class->addProperty = JS_PropertyStub; + JSB_cpPivotJoint_class->delProperty = JS_DeletePropertyStub; + JSB_cpPivotJoint_class->getProperty = JS_PropertyStub; + JSB_cpPivotJoint_class->setProperty = JS_StrictPropertyStub; + JSB_cpPivotJoint_class->enumerate = JS_EnumerateStub; + JSB_cpPivotJoint_class->resolve = JS_ResolveStub; + JSB_cpPivotJoint_class->convert = JS_ConvertStub; + JSB_cpPivotJoint_class->finalize = JSB_cpPivotJoint_finalize; + JSB_cpPivotJoint_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("getAnchr1", JSB_cpPivotJoint_getAnchr1, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAnchr2", JSB_cpPivotJoint_getAnchr2, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAnchr1", JSB_cpPivotJoint_setAnchr1, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAnchr2", JSB_cpPivotJoint_setAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpPivotJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpPivotJoint_class, JSB_cpPivotJoint_constructor,0,properties,funcs,NULL,st_funcs); +// bool found; +// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +/* + * cpPinJoint + */ +#pragma mark - cpPinJoint + +JSClass* JSB_cpPinJoint_class = NULL; +JSObject* JSB_cpPinJoint_object = NULL; +// Arguments: cpBody*, cpBody*, cpVect, cpVect +// Constructor +bool JSB_cpPinJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments"); + JSObject *jsobj = JS_NewObject(cx, JSB_cpPinJoint_class, JS::RootedObject(cx, JSB_cpPinJoint_object), JS::NullPtr()); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg0, NULL ); + ok &= jsval_to_c_class( cx, args.get(1), (void**)&arg1, NULL ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + ok &= jsval_to_cpVect( cx, args.get(3), (cpVect*) &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + void* ret_val = cpPinJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 ); + + jsb_set_jsobject_for_proxy(jsobj, ret_val); + jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + + return true; +} + +// Destructor +void JSB_cpPinJoint_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpPinJoint), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + cpConstraintFree( (cpConstraint*)proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + } else { + CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpPinJoint)", jsthis); + } +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpPinJoint_getAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpPinJoint* arg0 = (cpPinJoint*) proxy->handle; + cpVect ret_val; + + ret_val = cpPinJointGetAnchr1((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpPinJoint_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpPinJoint* arg0 = (cpPinJoint*) proxy->handle; + cpVect ret_val; + + ret_val = cpPinJointGetAnchr2((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpPinJoint_getDist(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpPinJoint* arg0 = (cpPinJoint*) proxy->handle; + cpFloat ret_val; + + ret_val = cpPinJointGetDist((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpVect +// Ret value: void +bool JSB_cpPinJoint_setAnchr1(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); + cpPinJoint* arg0 = (cpPinJoint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpPinJointSetAnchr1((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpVect +// Ret value: void +bool JSB_cpPinJoint_setAnchr2(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); + cpPinJoint* arg0 = (cpPinJoint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpPinJointSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpPinJoint_setDist(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); + cpPinJoint* arg0 = (cpPinJoint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpPinJointSetDist((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +void JSB_cpPinJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpPinJoint_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpPinJoint_class->name = name; + JSB_cpPinJoint_class->addProperty = JS_PropertyStub; + JSB_cpPinJoint_class->delProperty = JS_DeletePropertyStub; + JSB_cpPinJoint_class->getProperty = JS_PropertyStub; + JSB_cpPinJoint_class->setProperty = JS_StrictPropertyStub; + JSB_cpPinJoint_class->enumerate = JS_EnumerateStub; + JSB_cpPinJoint_class->resolve = JS_ResolveStub; + JSB_cpPinJoint_class->convert = JS_ConvertStub; + JSB_cpPinJoint_class->finalize = JSB_cpPinJoint_finalize; + JSB_cpPinJoint_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("getAnchr1", JSB_cpPinJoint_getAnchr1, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAnchr2", JSB_cpPinJoint_getAnchr2, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDist", JSB_cpPinJoint_getDist, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAnchr1", JSB_cpPinJoint_setAnchr1, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAnchr2", JSB_cpPinJoint_setAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDist", JSB_cpPinJoint_setDist, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpPinJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpPinJoint_class, JSB_cpPinJoint_constructor,0,properties,funcs,NULL,st_funcs); +// bool found; +// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +/* + * cpSlideJoint + */ +#pragma mark - cpSlideJoint + +JSClass* JSB_cpSlideJoint_class = NULL; +JSObject* JSB_cpSlideJoint_object = NULL; +// Arguments: cpBody*, cpBody*, cpVect, cpVect, cpFloat, cpFloat +// Constructor +bool JSB_cpSlideJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==6, cx, false, "Invalid number of arguments"); + JSObject *jsobj = JS_NewObject(cx, JSB_cpSlideJoint_class, JS::RootedObject(cx, JSB_cpSlideJoint_object), JS::NullPtr()); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; double arg4; double arg5; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg0, NULL ); + ok &= jsval_to_c_class( cx, args.get(1), (void**)&arg1, NULL ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + ok &= jsval_to_cpVect( cx, args.get(3), (cpVect*) &arg3 ); + ok &= JS::ToNumber( cx, args.get(4), &arg4 ); + ok &= JS::ToNumber( cx, args.get(5), &arg5 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + void* ret_val = cpSlideJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 , (cpFloat)arg4 , (cpFloat)arg5 ); + + jsb_set_jsobject_for_proxy(jsobj, ret_val); + jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + + return true; +} + +// Destructor +void JSB_cpSlideJoint_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpSlideJoint), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + cpConstraintFree( (cpConstraint*)proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + } else { + CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpSlideJoint)", jsthis); + } +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpSlideJoint_getAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; + cpVect ret_val; + + ret_val = cpSlideJointGetAnchr1((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpSlideJoint_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; + cpVect ret_val; + + ret_val = cpSlideJointGetAnchr2((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpSlideJoint_getMax(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; + cpFloat ret_val; + + ret_val = cpSlideJointGetMax((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpSlideJoint_getMin(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; + cpFloat ret_val; + + ret_val = cpSlideJointGetMin((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpVect +// Ret value: void +bool JSB_cpSlideJoint_setAnchr1(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); + cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSlideJointSetAnchr1((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpVect +// Ret value: void +bool JSB_cpSlideJoint_setAnchr2(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); + cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSlideJointSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpSlideJoint_setMax(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); + cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSlideJointSetMax((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpSlideJoint_setMin(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); + cpSlideJoint* arg0 = (cpSlideJoint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSlideJointSetMin((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +void JSB_cpSlideJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpSlideJoint_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpSlideJoint_class->name = name; + JSB_cpSlideJoint_class->addProperty = JS_PropertyStub; + JSB_cpSlideJoint_class->delProperty = JS_DeletePropertyStub; + JSB_cpSlideJoint_class->getProperty = JS_PropertyStub; + JSB_cpSlideJoint_class->setProperty = JS_StrictPropertyStub; + JSB_cpSlideJoint_class->enumerate = JS_EnumerateStub; + JSB_cpSlideJoint_class->resolve = JS_ResolveStub; + JSB_cpSlideJoint_class->convert = JS_ConvertStub; + JSB_cpSlideJoint_class->finalize = JSB_cpSlideJoint_finalize; + JSB_cpSlideJoint_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("getAnchr1", JSB_cpSlideJoint_getAnchr1, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAnchr2", JSB_cpSlideJoint_getAnchr2, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMax", JSB_cpSlideJoint_getMax, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMin", JSB_cpSlideJoint_getMin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAnchr1", JSB_cpSlideJoint_setAnchr1, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAnchr2", JSB_cpSlideJoint_setAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMax", JSB_cpSlideJoint_setMax, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMin", JSB_cpSlideJoint_setMin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpSlideJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpSlideJoint_class, JSB_cpSlideJoint_constructor,0,properties,funcs,NULL,st_funcs); +// bool found; +// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +/* + * cpGearJoint + */ +#pragma mark - cpGearJoint + +JSClass* JSB_cpGearJoint_class = NULL; +JSObject* JSB_cpGearJoint_object = NULL; +// Arguments: cpBody*, cpBody*, cpFloat, cpFloat +// Constructor +bool JSB_cpGearJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments"); + JSObject *jsobj = JS_NewObject(cx, JSB_cpGearJoint_class, JS::RootedObject(cx, JSB_cpGearJoint_object), JS::NullPtr()); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; double arg2; double arg3; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg0, NULL ); + ok &= jsval_to_c_class( cx, args.get(1), (void**)&arg1, NULL ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + ok &= JS::ToNumber( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + void* ret_val = cpGearJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 , (cpFloat)arg3 ); + + jsb_set_jsobject_for_proxy(jsobj, ret_val); + jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + + return true; +} + +// Destructor +void JSB_cpGearJoint_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpGearJoint), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + cpConstraintFree( (cpConstraint*)proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + } else { + CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpGearJoint)", jsthis); + } +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpGearJoint_getPhase(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpGearJoint* arg0 = (cpGearJoint*) proxy->handle; + cpFloat ret_val; + + ret_val = cpGearJointGetPhase((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpGearJoint_getRatio(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpGearJoint* arg0 = (cpGearJoint*) proxy->handle; + cpFloat ret_val; + + ret_val = cpGearJointGetRatio((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpGearJoint_setPhase(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); + cpGearJoint* arg0 = (cpGearJoint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpGearJointSetPhase((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpGearJoint_setRatio(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); + cpGearJoint* arg0 = (cpGearJoint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpGearJointSetRatio((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +void JSB_cpGearJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpGearJoint_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpGearJoint_class->name = name; + JSB_cpGearJoint_class->addProperty = JS_PropertyStub; + JSB_cpGearJoint_class->delProperty = JS_DeletePropertyStub; + JSB_cpGearJoint_class->getProperty = JS_PropertyStub; + JSB_cpGearJoint_class->setProperty = JS_StrictPropertyStub; + JSB_cpGearJoint_class->enumerate = JS_EnumerateStub; + JSB_cpGearJoint_class->resolve = JS_ResolveStub; + JSB_cpGearJoint_class->convert = JS_ConvertStub; + JSB_cpGearJoint_class->finalize = JSB_cpGearJoint_finalize; + JSB_cpGearJoint_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("getPhase", JSB_cpGearJoint_getPhase, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRatio", JSB_cpGearJoint_getRatio, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPhase", JSB_cpGearJoint_setPhase, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRatio", JSB_cpGearJoint_setRatio, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpGearJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpGearJoint_class, JSB_cpGearJoint_constructor,0,properties,funcs,NULL,st_funcs); +// bool found; +// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +/* + * cpDampedRotarySpring + */ +#pragma mark - cpDampedRotarySpring + +JSClass* JSB_cpDampedRotarySpring_class = NULL; +JSObject* JSB_cpDampedRotarySpring_object = NULL; +// Arguments: cpBody*, cpBody*, cpFloat, cpFloat, cpFloat +// Constructor +bool JSB_cpDampedRotarySpring_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==5, cx, false, "Invalid number of arguments"); + JSObject *jsobj = JS_NewObject(cx, JSB_cpDampedRotarySpring_class, JS::RootedObject(cx, JSB_cpDampedRotarySpring_object), JS::NullPtr()); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; double arg2; double arg3; double arg4; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg0, NULL ); + ok &= jsval_to_c_class( cx, args.get(1), (void**)&arg1, NULL ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + ok &= JS::ToNumber( cx, args.get(3), &arg3 ); + ok &= JS::ToNumber( cx, args.get(4), &arg4 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + void* ret_val = cpDampedRotarySpringNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 , (cpFloat)arg3 , (cpFloat)arg4 ); + + jsb_set_jsobject_for_proxy(jsobj, ret_val); + jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + + return true; +} + +// Destructor +void JSB_cpDampedRotarySpring_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpDampedRotarySpring), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + cpConstraintFree( (cpConstraint*)proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + } else { + CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpDampedRotarySpring)", jsthis); + } +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpDampedRotarySpring_getDamping(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpDampedRotarySpring* arg0 = (cpDampedRotarySpring*) proxy->handle; + cpFloat ret_val; + + ret_val = cpDampedRotarySpringGetDamping((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpDampedRotarySpring_getRestAngle(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpDampedRotarySpring* arg0 = (cpDampedRotarySpring*) proxy->handle; + cpFloat ret_val; + + ret_val = cpDampedRotarySpringGetRestAngle((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpDampedRotarySpring_getStiffness(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpDampedRotarySpring* arg0 = (cpDampedRotarySpring*) proxy->handle; + cpFloat ret_val; + + ret_val = cpDampedRotarySpringGetStiffness((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpDampedRotarySpring_setDamping(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); + cpDampedRotarySpring* arg0 = (cpDampedRotarySpring*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpDampedRotarySpringSetDamping((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpDampedRotarySpring_setRestAngle(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); + cpDampedRotarySpring* arg0 = (cpDampedRotarySpring*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpDampedRotarySpringSetRestAngle((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpDampedRotarySpring_setStiffness(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); + cpDampedRotarySpring* arg0 = (cpDampedRotarySpring*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpDampedRotarySpringSetStiffness((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +void JSB_cpDampedRotarySpring_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpDampedRotarySpring_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpDampedRotarySpring_class->name = name; + JSB_cpDampedRotarySpring_class->addProperty = JS_PropertyStub; + JSB_cpDampedRotarySpring_class->delProperty = JS_DeletePropertyStub; + JSB_cpDampedRotarySpring_class->getProperty = JS_PropertyStub; + JSB_cpDampedRotarySpring_class->setProperty = JS_StrictPropertyStub; + JSB_cpDampedRotarySpring_class->enumerate = JS_EnumerateStub; + JSB_cpDampedRotarySpring_class->resolve = JS_ResolveStub; + JSB_cpDampedRotarySpring_class->convert = JS_ConvertStub; + JSB_cpDampedRotarySpring_class->finalize = JSB_cpDampedRotarySpring_finalize; + JSB_cpDampedRotarySpring_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("getDamping", JSB_cpDampedRotarySpring_getDamping, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRestAngle", JSB_cpDampedRotarySpring_getRestAngle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStiffness", JSB_cpDampedRotarySpring_getStiffness, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDamping", JSB_cpDampedRotarySpring_setDamping, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRestAngle", JSB_cpDampedRotarySpring_setRestAngle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setStiffness", JSB_cpDampedRotarySpring_setStiffness, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpDampedRotarySpring_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpDampedRotarySpring_class, JSB_cpDampedRotarySpring_constructor,0,properties,funcs,NULL,st_funcs); +// bool found; +// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +/* + * cpDampedSpring + */ +#pragma mark - cpDampedSpring + +JSClass* JSB_cpDampedSpring_class = NULL; +JSObject* JSB_cpDampedSpring_object = NULL; +// Arguments: cpBody*, cpBody*, cpVect, cpVect, cpFloat, cpFloat, cpFloat +// Constructor +bool JSB_cpDampedSpring_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==7, cx, false, "Invalid number of arguments"); + JSObject *jsobj = JS_NewObject(cx, JSB_cpDampedSpring_class, JS::RootedObject(cx, JSB_cpDampedSpring_object), JS::NullPtr()); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; double arg4; double arg5; double arg6; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg0, NULL ); + ok &= jsval_to_c_class( cx, args.get(1), (void**)&arg1, NULL ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + ok &= jsval_to_cpVect( cx, args.get(3), (cpVect*) &arg3 ); + ok &= JS::ToNumber( cx, args.get(4), &arg4 ); + ok &= JS::ToNumber( cx, args.get(5), &arg5 ); + ok &= JS::ToNumber( cx, args.get(6), &arg6 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + void* ret_val = cpDampedSpringNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 , (cpFloat)arg4 , (cpFloat)arg5 , (cpFloat)arg6 ); + + jsb_set_jsobject_for_proxy(jsobj, ret_val); + jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + + return true; +} + +// Destructor +void JSB_cpDampedSpring_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpDampedSpring), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + cpConstraintFree( (cpConstraint*)proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + } else { + CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpDampedSpring)", jsthis); + } +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpDampedSpring_getAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; + cpVect ret_val; + + ret_val = cpDampedSpringGetAnchr1((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpDampedSpring_getAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; + cpVect ret_val; + + ret_val = cpDampedSpringGetAnchr2((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpDampedSpring_getDamping(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; + cpFloat ret_val; + + ret_val = cpDampedSpringGetDamping((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpDampedSpring_getRestLength(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; + cpFloat ret_val; + + ret_val = cpDampedSpringGetRestLength((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpDampedSpring_getStiffness(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; + cpFloat ret_val; + + ret_val = cpDampedSpringGetStiffness((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpVect +// Ret value: void +bool JSB_cpDampedSpring_setAnchr1(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); + cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpDampedSpringSetAnchr1((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpVect +// Ret value: void +bool JSB_cpDampedSpring_setAnchr2(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); + cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpDampedSpringSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpDampedSpring_setDamping(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); + cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpDampedSpringSetDamping((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpDampedSpring_setRestLength(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); + cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpDampedSpringSetRestLength((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpDampedSpring_setStiffness(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); + cpDampedSpring* arg0 = (cpDampedSpring*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpDampedSpringSetStiffness((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +void JSB_cpDampedSpring_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpDampedSpring_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpDampedSpring_class->name = name; + JSB_cpDampedSpring_class->addProperty = JS_PropertyStub; + JSB_cpDampedSpring_class->delProperty = JS_DeletePropertyStub; + JSB_cpDampedSpring_class->getProperty = JS_PropertyStub; + JSB_cpDampedSpring_class->setProperty = JS_StrictPropertyStub; + JSB_cpDampedSpring_class->enumerate = JS_EnumerateStub; + JSB_cpDampedSpring_class->resolve = JS_ResolveStub; + JSB_cpDampedSpring_class->convert = JS_ConvertStub; + JSB_cpDampedSpring_class->finalize = JSB_cpDampedSpring_finalize; + JSB_cpDampedSpring_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("getAnchr1", JSB_cpDampedSpring_getAnchr1, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAnchr2", JSB_cpDampedSpring_getAnchr2, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDamping", JSB_cpDampedSpring_getDamping, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRestLength", JSB_cpDampedSpring_getRestLength, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStiffness", JSB_cpDampedSpring_getStiffness, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAnchr1", JSB_cpDampedSpring_setAnchr1, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAnchr2", JSB_cpDampedSpring_setAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDamping", JSB_cpDampedSpring_setDamping, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRestLength", JSB_cpDampedSpring_setRestLength, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setStiffness", JSB_cpDampedSpring_setStiffness, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpDampedSpring_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpDampedSpring_class, JSB_cpDampedSpring_constructor,0,properties,funcs,NULL,st_funcs); +// bool found; +// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +/* + * cpRatchetJoint + */ +#pragma mark - cpRatchetJoint + +JSClass* JSB_cpRatchetJoint_class = NULL; +JSObject* JSB_cpRatchetJoint_object = NULL; +// Arguments: cpBody*, cpBody*, cpFloat, cpFloat +// Constructor +bool JSB_cpRatchetJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments"); + JSObject *jsobj = JS_NewObject(cx, JSB_cpRatchetJoint_class, JS::RootedObject(cx, JSB_cpRatchetJoint_object), JS::NullPtr()); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; double arg2; double arg3; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg0, NULL ); + ok &= jsval_to_c_class( cx, args.get(1), (void**)&arg1, NULL ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + ok &= JS::ToNumber( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + void* ret_val = cpRatchetJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 , (cpFloat)arg3 ); + + jsb_set_jsobject_for_proxy(jsobj, ret_val); + jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + + return true; +} + +// Destructor +void JSB_cpRatchetJoint_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpRatchetJoint), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + cpConstraintFree( (cpConstraint*)proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + } else { + CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpRatchetJoint)", jsthis); + } +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpRatchetJoint_getAngle(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpRatchetJoint* arg0 = (cpRatchetJoint*) proxy->handle; + cpFloat ret_val; + + ret_val = cpRatchetJointGetAngle((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpRatchetJoint_getPhase(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpRatchetJoint* arg0 = (cpRatchetJoint*) proxy->handle; + cpFloat ret_val; + + ret_val = cpRatchetJointGetPhase((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpRatchetJoint_getRatchet(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpRatchetJoint* arg0 = (cpRatchetJoint*) proxy->handle; + cpFloat ret_val; + + ret_val = cpRatchetJointGetRatchet((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpRatchetJoint_setAngle(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); + cpRatchetJoint* arg0 = (cpRatchetJoint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpRatchetJointSetAngle((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpRatchetJoint_setPhase(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); + cpRatchetJoint* arg0 = (cpRatchetJoint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpRatchetJointSetPhase((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpRatchetJoint_setRatchet(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); + cpRatchetJoint* arg0 = (cpRatchetJoint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpRatchetJointSetRatchet((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +void JSB_cpRatchetJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpRatchetJoint_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpRatchetJoint_class->name = name; + JSB_cpRatchetJoint_class->addProperty = JS_PropertyStub; + JSB_cpRatchetJoint_class->delProperty = JS_DeletePropertyStub; + JSB_cpRatchetJoint_class->getProperty = JS_PropertyStub; + JSB_cpRatchetJoint_class->setProperty = JS_StrictPropertyStub; + JSB_cpRatchetJoint_class->enumerate = JS_EnumerateStub; + JSB_cpRatchetJoint_class->resolve = JS_ResolveStub; + JSB_cpRatchetJoint_class->convert = JS_ConvertStub; + JSB_cpRatchetJoint_class->finalize = JSB_cpRatchetJoint_finalize; + JSB_cpRatchetJoint_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("getAngle", JSB_cpRatchetJoint_getAngle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPhase", JSB_cpRatchetJoint_getPhase, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRatchet", JSB_cpRatchetJoint_getRatchet, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAngle", JSB_cpRatchetJoint_setAngle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPhase", JSB_cpRatchetJoint_setPhase, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setRatchet", JSB_cpRatchetJoint_setRatchet, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpRatchetJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpRatchetJoint_class, JSB_cpRatchetJoint_constructor,0,properties,funcs,NULL,st_funcs); +// bool found; +// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +/* + * cpRotaryLimitJoint + */ +#pragma mark - cpRotaryLimitJoint + +JSClass* JSB_cpRotaryLimitJoint_class = NULL; +JSObject* JSB_cpRotaryLimitJoint_object = NULL; +// Arguments: cpBody*, cpBody*, cpFloat, cpFloat +// Constructor +bool JSB_cpRotaryLimitJoint_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments"); + JSObject *jsobj = JS_NewObject(cx, JSB_cpRotaryLimitJoint_class, JS::RootedObject(cx, JSB_cpRotaryLimitJoint_object), JS::NullPtr()); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; double arg2; double arg3; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg0, NULL ); + ok &= jsval_to_c_class( cx, args.get(1), (void**)&arg1, NULL ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + ok &= JS::ToNumber( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + void* ret_val = cpRotaryLimitJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 , (cpFloat)arg3 ); + + jsb_set_jsobject_for_proxy(jsobj, ret_val); + jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + + return true; +} + +// Destructor +void JSB_cpRotaryLimitJoint_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpRotaryLimitJoint), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + cpConstraintFree( (cpConstraint*)proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + } else { + CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpRotaryLimitJoint)", jsthis); + } +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpRotaryLimitJoint_getMax(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpRotaryLimitJoint* arg0 = (cpRotaryLimitJoint*) proxy->handle; + cpFloat ret_val; + + ret_val = cpRotaryLimitJointGetMax((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpRotaryLimitJoint_getMin(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpRotaryLimitJoint* arg0 = (cpRotaryLimitJoint*) proxy->handle; + cpFloat ret_val; + + ret_val = cpRotaryLimitJointGetMin((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpRotaryLimitJoint_setMax(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); + cpRotaryLimitJoint* arg0 = (cpRotaryLimitJoint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpRotaryLimitJointSetMax((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpRotaryLimitJoint_setMin(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); + cpRotaryLimitJoint* arg0 = (cpRotaryLimitJoint*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpRotaryLimitJointSetMin((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +void JSB_cpRotaryLimitJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpRotaryLimitJoint_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpRotaryLimitJoint_class->name = name; + JSB_cpRotaryLimitJoint_class->addProperty = JS_PropertyStub; + JSB_cpRotaryLimitJoint_class->delProperty = JS_DeletePropertyStub; + JSB_cpRotaryLimitJoint_class->getProperty = JS_PropertyStub; + JSB_cpRotaryLimitJoint_class->setProperty = JS_StrictPropertyStub; + JSB_cpRotaryLimitJoint_class->enumerate = JS_EnumerateStub; + JSB_cpRotaryLimitJoint_class->resolve = JS_ResolveStub; + JSB_cpRotaryLimitJoint_class->convert = JS_ConvertStub; + JSB_cpRotaryLimitJoint_class->finalize = JSB_cpRotaryLimitJoint_finalize; + JSB_cpRotaryLimitJoint_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("getMax", JSB_cpRotaryLimitJoint_getMax, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMin", JSB_cpRotaryLimitJoint_getMin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMax", JSB_cpRotaryLimitJoint_setMax, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMin", JSB_cpRotaryLimitJoint_setMin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpRotaryLimitJoint_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpConstraint_object), JSB_cpRotaryLimitJoint_class, JSB_cpRotaryLimitJoint_constructor,0,properties,funcs,NULL,st_funcs); +// bool found; +// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +/* + * cpArbiter + */ +#pragma mark - cpArbiter + +JSClass* JSB_cpArbiter_class = NULL; +JSObject* JSB_cpArbiter_object = NULL; + +// Constructor +bool JSB_cpArbiter_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==0, cx, false, "Invalid number of arguments"); + JSB_PRECONDITION2(false, cx, true, "No constructor"); + + return true; +} + +// Destructor +void JSB_cpArbiter_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpArbiter), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + // No destructor found: ( (None*)proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + } else { + CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpArbiter)", jsthis); + } +} + +// Arguments: +// Ret value: int +bool JSB_cpArbiter_getCount(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpArbiter* arg0 = (cpArbiter*) proxy->handle; + int ret_val; + + ret_val = cpArbiterGetCount((cpArbiter*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: int +// Ret value: cpFloat +bool JSB_cpArbiter_getDepth(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); + cpArbiter* arg0 = (cpArbiter*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg1; + + ok &= jsval_to_int32( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpArbiterGetDepth((cpArbiter*)arg0 , (int)arg1 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpArbiter_getElasticity(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpArbiter* arg0 = (cpArbiter*) proxy->handle; + cpFloat ret_val; + + ret_val = cpArbiterGetElasticity((cpArbiter*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpArbiter_getFriction(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpArbiter* arg0 = (cpArbiter*) proxy->handle; + cpFloat ret_val; + + ret_val = cpArbiterGetFriction((cpArbiter*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: int +// Ret value: cpVect +bool JSB_cpArbiter_getNormal(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); + cpArbiter* arg0 = (cpArbiter*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg1; + + ok &= jsval_to_int32( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpArbiterGetNormal((cpArbiter*)arg0 , (int)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: int +// Ret value: cpVect +bool JSB_cpArbiter_getPoint(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); + cpArbiter* arg0 = (cpArbiter*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg1; + + ok &= jsval_to_int32( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpArbiterGetPoint((cpArbiter*)arg0 , (int)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpArbiter_getSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpArbiter* arg0 = (cpArbiter*) proxy->handle; + cpVect ret_val; + + ret_val = cpArbiterGetSurfaceVelocity((cpArbiter*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: void +bool JSB_cpArbiter_ignore(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpArbiter* arg0 = (cpArbiter*) proxy->handle; + + cpArbiterIgnore((cpArbiter*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: +// Ret value: cpBool +bool JSB_cpArbiter_isFirstContact(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpArbiter* arg0 = (cpArbiter*) proxy->handle; + cpBool ret_val; + + ret_val = cpArbiterIsFirstContact((cpArbiter*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpArbiter_setElasticity(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); + cpArbiter* arg0 = (cpArbiter*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpArbiterSetElasticity((cpArbiter*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpArbiter_setFriction(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); + cpArbiter* arg0 = (cpArbiter*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpArbiterSetFriction((cpArbiter*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpVect +// Ret value: void +bool JSB_cpArbiter_setSurfaceVelocity(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); + cpArbiter* arg0 = (cpArbiter*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpArbiterSetSurfaceVelocity((cpArbiter*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpArbiter_totalImpulse(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpArbiter* arg0 = (cpArbiter*) proxy->handle; + cpVect ret_val; + + ret_val = cpArbiterTotalImpulse((cpArbiter*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpArbiter_totalImpulseWithFriction(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpArbiter* arg0 = (cpArbiter*) proxy->handle; + cpVect ret_val; + + ret_val = cpArbiterTotalImpulseWithFriction((cpArbiter*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpArbiter_totalKE(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpArbiter* arg0 = (cpArbiter*) proxy->handle; + cpFloat ret_val; + + ret_val = cpArbiterTotalKE((cpArbiter*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +bool js_get_cpArbiter_a(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpArbiter* arbiter = (cpArbiter*) proxy->handle; + cpShape* shape = arbiter->a; + if(shape){ + JSObject* jsobj = jsb_get_jsobject_for_proxy(shape); + if(jsobj){ + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + return true; + } + } + return false; +} + +bool js_get_cpArbiter_b(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpArbiter* arbiter = (cpArbiter*) proxy->handle; + cpShape* shape = arbiter->b; + if(shape){ + JSObject* jsobj = jsb_get_jsobject_for_proxy(shape); + if(jsobj){ + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + return true; + } + } + return false; +} + +bool js_get_cpArbiter_body_a(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpArbiter* arbiter = (cpArbiter*) proxy->handle; + cpBody* body = arbiter->body_a; + if(body){ + JSObject* jsobj = jsb_get_jsobject_for_proxy(body); + if(jsobj){ + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + return true; + } + } + return false; +} + +bool js_get_cpArbiter_body_b(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpArbiter* arbiter = (cpArbiter*) proxy->handle; + cpBody* body = arbiter->body_b; + if(body){ + JSObject* jsobj = jsb_get_jsobject_for_proxy(body); + if(jsobj){ + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + return true; + } + } + return false; +} + +void JSB_cpArbiter_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpArbiter_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpArbiter_class->name = name; + JSB_cpArbiter_class->addProperty = JS_PropertyStub; + JSB_cpArbiter_class->delProperty = JS_DeletePropertyStub; + JSB_cpArbiter_class->getProperty = JS_PropertyStub; + JSB_cpArbiter_class->setProperty = JS_StrictPropertyStub; + JSB_cpArbiter_class->enumerate = JS_EnumerateStub; + JSB_cpArbiter_class->resolve = JS_ResolveStub; + JSB_cpArbiter_class->convert = JS_ConvertStub; + JSB_cpArbiter_class->finalize = JSB_cpArbiter_finalize; + JSB_cpArbiter_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PSG("a", js_get_cpArbiter_a, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PSG("b", js_get_cpArbiter_b, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PSG("body_a", js_get_cpArbiter_body_a, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PSG("body_b", js_get_cpArbiter_body_b, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("getCount", JSB_cpArbiter_getCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDepth", JSB_cpArbiter_getDepth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getElasticity", JSB_cpArbiter_getElasticity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFriction", JSB_cpArbiter_getFriction, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNormal", JSB_cpArbiter_getNormal, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPoint", JSB_cpArbiter_getPoint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSurfaceVelocity", JSB_cpArbiter_getSurfaceVelocity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ignore", JSB_cpArbiter_ignore, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isFirstContact", JSB_cpArbiter_isFirstContact, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setElasticity", JSB_cpArbiter_setElasticity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFriction", JSB_cpArbiter_setFriction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSurfaceVelocity", JSB_cpArbiter_setSurfaceVelocity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("totalImpulse", JSB_cpArbiter_totalImpulse, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("totalImpulseWithFriction", JSB_cpArbiter_totalImpulseWithFriction, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("totalKE", JSB_cpArbiter_totalKE, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getShapes", JSB_cpArbiter_getShapes, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBodies", JSB_cpArbiter_getBodies, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpArbiter_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpBase_object), JSB_cpArbiter_class, JSB_cpArbiter_constructor,0,properties,funcs,NULL,st_funcs); +// bool found; +// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +/* + * cpSpace + */ +#pragma mark - cpSpace + +JSClass* JSB_cpSpace_class = NULL; +JSObject* JSB_cpSpace_object = NULL; +// Arguments: +// Constructor +bool JSB_cpSpace_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==0, cx, false, "Invalid number of arguments"); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + //JSObject* jsobj = JS_NewObjectForConstructor(cx, JSB_cpSpace_class, args); + JSObject *jsobj = JS_NewObject(cx, JSB_cpSpace_class, JS::RootedObject(cx, JSB_cpSpace_object), JS::NullPtr()); + void* ret_val = cpSpaceNew( ); + + jsb_set_jsobject_for_proxy(jsobj, ret_val); + jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + + return true; +} + +// Arguments: cpShape* +// Ret value: void +bool JSB_cpSpace_activateShapesTouchingShape(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg1; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg1, NULL ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceActivateShapesTouchingShape((cpSpace*)arg0 , (cpShape*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody* +// Ret value: cpBool +bool JSB_cpSpace_containsBody(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg1; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg1, NULL ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpSpaceContainsBody((cpSpace*)arg0 , (cpBody*)arg1 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpBool +bool JSB_cpSpace_containsConstraint(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg1; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg1, NULL ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpSpaceContainsConstraint((cpSpace*)arg0 , (cpConstraint*)arg1 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpShape* +// Ret value: cpBool +bool JSB_cpSpace_containsShape(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg1; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg1, NULL ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpSpaceContainsShape((cpSpace*)arg0 , (cpShape*)arg1 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: +// Ret value: void +bool JSB_cpSpace_destroy(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + + cpSpaceDestroy((cpSpace*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpSpace_getCollisionBias(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + cpFloat ret_val; + + ret_val = cpSpaceGetCollisionBias((cpSpace*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpTimestamp +bool JSB_cpSpace_getCollisionPersistence(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + cpTimestamp ret_val; + + ret_val = cpSpaceGetCollisionPersistence((cpSpace*)arg0 ); + args.rval().set(UINT_TO_JSVAL((uint32_t)ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpSpace_getCollisionSlop(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + cpFloat ret_val; + + ret_val = cpSpaceGetCollisionSlop((cpSpace*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpSpace_getCurrentTimeStep(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + cpFloat ret_val; + + ret_val = cpSpaceGetCurrentTimeStep((cpSpace*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpSpace_getDamping(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + cpFloat ret_val; + + ret_val = cpSpaceGetDamping((cpSpace*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpBool +bool JSB_cpSpace_getEnableContactGraph(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + cpBool ret_val; + + ret_val = cpSpaceGetEnableContactGraph((cpSpace*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpSpace_getGravity(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + cpVect ret_val; + + ret_val = cpSpaceGetGravity((cpSpace*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpSpace_getIdleSpeedThreshold(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + cpFloat ret_val; + + ret_val = cpSpaceGetIdleSpeedThreshold((cpSpace*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: int +bool JSB_cpSpace_getIterations(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + int ret_val; + + ret_val = cpSpaceGetIterations((cpSpace*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpSpace_getSleepTimeThreshold(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + cpFloat ret_val; + + ret_val = cpSpaceGetSleepTimeThreshold((cpSpace*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpBody* +bool JSB_cpSpace_getStaticBody(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + cpBody* ret_val; + + ret_val = cpSpaceGetStaticBody((cpSpace*)arg0 ); + + jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpSpace* +bool JSB_cpSpace_init(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + cpSpace* ret_val; + + ret_val = cpSpaceInit((cpSpace*)arg0 ); + + jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpSpace" ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpBool +bool JSB_cpSpace_isLocked(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + cpBool ret_val; + + ret_val = cpSpaceIsLocked((cpSpace*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpVect, cpLayers, cpGroup +// Ret value: cpShape* +bool JSB_cpSpace_pointQueryFirst(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, 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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; uint32_t arg2; cpGroup arg3; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg2 ); + ok &= jsval_to_uint( cx, args.get(2), (unsigned int*) &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpShape* ret_val; + + ret_val = cpSpacePointQueryFirst((cpSpace*)arg0 , (cpVect)arg1 , (cpLayers)arg2 , (cpGroup)arg3 ); + + if(ret_val) { + jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpShape_object), JSB_cpShape_class, "cpShape" ); + args.rval().set(ret_jsval); + } else { + args.rval().set(JSVAL_NULL); + } + return true; +} +// Arguments: cpShape* +// Ret value: void +bool JSB_cpSpace_reindexShape(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg1; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg1, NULL ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceReindexShape((cpSpace*)arg0 , (cpShape*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody* +// Ret value: void +bool JSB_cpSpace_reindexShapesForBody(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg1; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg1, NULL ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceReindexShapesForBody((cpSpace*)arg0 , (cpBody*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: +// Ret value: void +bool JSB_cpSpace_reindexStatic(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* arg0 = (cpSpace*) proxy->handle; + + cpSpaceReindexStatic((cpSpace*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpSpace_setCollisionBias(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceSetCollisionBias((cpSpace*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpTimestamp +// Ret value: void +bool JSB_cpSpace_setCollisionPersistence(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceSetCollisionPersistence((cpSpace*)arg0 , (cpTimestamp)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpSpace_setCollisionSlop(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceSetCollisionSlop((cpSpace*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpSpace_setDamping(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceSetDamping((cpSpace*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBool +// Ret value: void +bool JSB_cpSpace_setEnableContactGraph(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg1; + + ok &= jsval_to_int32( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceSetEnableContactGraph((cpSpace*)arg0 , (cpBool)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpVect +// Ret value: void +bool JSB_cpSpace_setGravity(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceSetGravity((cpSpace*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpSpace_setIdleSpeedThreshold(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceSetIdleSpeedThreshold((cpSpace*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: int +// Ret value: void +bool JSB_cpSpace_setIterations(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg1; + + ok &= jsval_to_int32( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceSetIterations((cpSpace*)arg0 , (int)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpSpace_setSleepTimeThreshold(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceSetSleepTimeThreshold((cpSpace*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpSpace_step(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceStep((cpSpace*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat, int +// Ret value: void +bool JSB_cpSpace_useSpatialHash(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); + cpSpace* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; int32_t arg2; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + ok &= jsval_to_int32( cx, args.get(1), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceUseSpatialHash((cpSpace*)arg0 , (cpFloat)arg1 , (int)arg2 ); + args.rval().setUndefined(); + return true; +} + + +void JSB_cpSpace_createClass(JSContext *cx, JS::HandleObject 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, 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, JS::RootedObject(cx, JSB_cpBase_object), JSB_cpSpace_class, JSB_cpSpace_constructor,0,properties,funcs,NULL,st_funcs); +// bool found; +// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +/* + * cpBody + */ +#pragma mark - cpBody + +JSClass* JSB_cpBody_class = NULL; +JSObject* JSB_cpBody_object = NULL; + +// Destructor +void JSB_cpBody_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpBody), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + cpBodyFree( (cpBody*)proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + } else { + CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpBody)", jsthis); + } +} + +// Arguments: +// Ret value: void +bool JSB_cpBody_activate(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + + cpBodyActivate((cpBody*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpShape* +// Ret value: void +bool JSB_cpBody_activateStatic(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* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg1; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg1, NULL ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodyActivateStatic((cpBody*)arg0 , (cpShape*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpVect, cpVect +// Ret value: void +bool JSB_cpBody_applyForce(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); + cpBody* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; cpVect arg2; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodyApplyForce((cpBody*)arg0 , (cpVect)arg1 , (cpVect)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpVect, cpVect +// Ret value: void +bool JSB_cpBody_applyImpulse(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); + cpBody* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; cpVect arg2; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodyApplyImpulse((cpBody*)arg0 , (cpVect)arg1 , (cpVect)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: +// Ret value: void +bool JSB_cpBody_destroy(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + + cpBodyDestroy((cpBody*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpBody_getAngVel(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + cpFloat ret_val; + + ret_val = cpBodyGetAngVel((cpBody*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpBody_getAngVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + cpFloat ret_val; + + ret_val = cpBodyGetAngVelLimit((cpBody*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpBody_getAngle(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + cpFloat ret_val; + + ret_val = cpBodyGetAngle((cpBody*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpBody_getForce(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + cpVect ret_val; + + ret_val = cpBodyGetForce((cpBody*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpBody_getMass(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + cpFloat ret_val; + + ret_val = cpBodyGetMass((cpBody*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpBody_getMoment(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + cpFloat ret_val; + + ret_val = cpBodyGetMoment((cpBody*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpBody_getPos(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + cpVect ret_val; + + ret_val = cpBodyGetPos((cpBody*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpBody_getRot(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + cpVect ret_val; + + ret_val = cpBodyGetRot((cpBody*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpSpace* +bool JSB_cpBody_getSpace(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + cpSpace* ret_val; + + ret_val = cpBodyGetSpace((cpBody*)arg0 ); + + jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpSpace" ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpBody_getTorque(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + cpFloat ret_val; + + ret_val = cpBodyGetTorque((cpBody*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpBody_getVel(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + cpVect ret_val; + + ret_val = cpBodyGetVel((cpBody*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect +// Ret value: cpVect +bool JSB_cpBody_getVelAtLocalPoint(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* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpBodyGetVelAtLocalPoint((cpBody*)arg0 , (cpVect)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect +// Ret value: cpVect +bool JSB_cpBody_getVelAtWorldPoint(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* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpBodyGetVelAtWorldPoint((cpBody*)arg0 , (cpVect)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpBody_getVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + cpFloat ret_val; + + ret_val = cpBodyGetVelLimit((cpBody*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpFloat, cpFloat +// Ret value: cpBody* +bool JSB_cpBody_init(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); + cpBody* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; double arg2; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + ok &= JS::ToNumber( cx, args.get(1), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBody* ret_val; + + ret_val = cpBodyInit((cpBody*)arg0 , (cpFloat)arg1 , (cpFloat)arg2 ); + + jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpBody* +bool JSB_cpBody_initStatic(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + cpBody* ret_val; + + ret_val = cpBodyInitStatic((cpBody*)arg0 ); + + jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpBool +bool JSB_cpBody_isRogue(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + cpBool ret_val; + + ret_val = cpBodyIsRogue((cpBody*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: +// Ret value: cpBool +bool JSB_cpBody_isSleeping(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + cpBool ret_val; + + ret_val = cpBodyIsSleeping((cpBody*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: +// Ret value: cpBool +bool JSB_cpBody_isStatic(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + cpBool ret_val; + + ret_val = cpBodyIsStatic((cpBody*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpBody_kineticEnergy(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + cpFloat ret_val; + + ret_val = cpBodyKineticEnergy((cpBody*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpVect +// Ret value: cpVect +bool JSB_cpBody_local2World(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* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpBodyLocal2World((cpBody*)arg0 , (cpVect)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: void +bool JSB_cpBody_resetForces(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + + cpBodyResetForces((cpBody*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpBody_setAngVel(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* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetAngVel((cpBody*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpBody_setAngVelLimit(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* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetAngVelLimit((cpBody*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpBody_setAngle(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* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetAngle((cpBody*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpVect +// Ret value: void +bool JSB_cpBody_setForce(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* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetForce((cpBody*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpBody_setMass(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* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetMass((cpBody*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpBody_setMoment(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* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetMoment((cpBody*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpVect +// Ret value: void +bool JSB_cpBody_setPos(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* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetPos((cpBody*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpBody_setTorque(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* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetTorque((cpBody*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpVect +// Ret value: void +bool JSB_cpBody_setVel(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* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetVel((cpBody*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpBody_setVelLimit(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* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetVelLimit((cpBody*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: +// Ret value: void +bool JSB_cpBody_sleep(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* arg0 = (cpBody*) proxy->handle; + + cpBodySleep((cpBody*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody* +// Ret value: void +bool JSB_cpBody_sleepWithGroup(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* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg1; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg1, NULL ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySleepWithGroup((cpBody*)arg0 , (cpBody*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpBody_updatePosition(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* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodyUpdatePosition((cpBody*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpVect, cpFloat, cpFloat +// Ret value: void +bool JSB_cpBody_updateVelocity(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, 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* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; double arg2; double arg3; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + ok &= JS::ToNumber( cx, args.get(1), &arg2 ); + ok &= JS::ToNumber( cx, args.get(2), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodyUpdateVelocity((cpBody*)arg0 , (cpVect)arg1 , (cpFloat)arg2 , (cpFloat)arg3 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpVect +// Ret value: cpVect +bool JSB_cpBody_world2Local(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* arg0 = (cpBody*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpBodyWorld2Local((cpBody*)arg0 , (cpVect)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +bool js_get_cpBody_vx(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpBody* body = (cpBody*) proxy->handle; + args.rval().set(DOUBLE_TO_JSVAL(body->v.x)); + return true; +} + +bool js_get_cpBody_vy(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpBody* body = (cpBody*) proxy->handle; + args.rval().set(DOUBLE_TO_JSVAL(body->v.y)); + return true; +} + +bool js_get_cpBody_inverse_m(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpBody* body = (cpBody*) proxy->handle; + args.rval().set(DOUBLE_TO_JSVAL(body->m_inv)); + return true; +} + +bool js_get_cpBody_inverse_i(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpBody* body = (cpBody*) proxy->handle; + args.rval().set(DOUBLE_TO_JSVAL(body->i_inv)); + return true; +} + +void JSB_cpBody_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpBody_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpBody_class->name = name; + JSB_cpBody_class->addProperty = JS_PropertyStub; + JSB_cpBody_class->delProperty = JS_DeletePropertyStub; + JSB_cpBody_class->getProperty = JS_PropertyStub; + JSB_cpBody_class->setProperty = JS_StrictPropertyStub; + JSB_cpBody_class->enumerate = JS_EnumerateStub; + JSB_cpBody_class->resolve = JS_ResolveStub; + JSB_cpBody_class->convert = JS_ConvertStub; + JSB_cpBody_class->finalize = JSB_cpBody_finalize; + JSB_cpBody_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PSG("vx", js_get_cpBody_vx, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PSG("vy", js_get_cpBody_vy, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PSG("m_inv", js_get_cpBody_inverse_m, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PSG("i_inv", js_get_cpBody_inverse_i, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("activate", JSB_cpBody_activate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("activateStatic", JSB_cpBody_activateStatic, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("applyForce", JSB_cpBody_applyForce, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("applyImpulse", JSB_cpBody_applyImpulse, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("destroy", JSB_cpBody_destroy, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAngVel", JSB_cpBody_getAngVel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAngVelLimit", JSB_cpBody_getAngVelLimit, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAngle", JSB_cpBody_getAngle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getForce", JSB_cpBody_getForce, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMass", JSB_cpBody_getMass, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMoment", JSB_cpBody_getMoment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPos", JSB_cpBody_getPos, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRot", JSB_cpBody_getRot, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSpace", JSB_cpBody_getSpace, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTorque", JSB_cpBody_getTorque, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVel", JSB_cpBody_getVel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVelAtLocalPoint", JSB_cpBody_getVelAtLocalPoint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVelAtWorldPoint", JSB_cpBody_getVelAtWorldPoint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVelLimit", JSB_cpBody_getVelLimit, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", JSB_cpBody_init, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initStatic", JSB_cpBody_initStatic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isRogue", JSB_cpBody_isRogue, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isSleeping", JSB_cpBody_isSleeping, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isStatic", JSB_cpBody_isStatic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("kineticEnergy", JSB_cpBody_kineticEnergy, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("local2World", JSB_cpBody_local2World, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resetForces", JSB_cpBody_resetForces, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAngVel", JSB_cpBody_setAngVel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAngVelLimit", JSB_cpBody_setAngVelLimit, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAngle", JSB_cpBody_setAngle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setForce", JSB_cpBody_setForce, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMass", JSB_cpBody_setMass, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setMoment", JSB_cpBody_setMoment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPos", JSB_cpBody_setPos, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTorque", JSB_cpBody_setTorque, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setVel", JSB_cpBody_setVel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setVelLimit", JSB_cpBody_setVelLimit, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("sleep", JSB_cpBody_sleep, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("sleepWithGroup", JSB_cpBody_sleepWithGroup, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updatePosition", JSB_cpBody_updatePosition, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateVelocity", JSB_cpBody_updateVelocity, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + 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[] = { + JS_FS_END + }; + + JSB_cpBody_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpBase_object), JSB_cpBody_class, JSB_cpBody_constructor,0,properties,funcs,NULL,st_funcs); +// bool found; +// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +/* + * cpShape + */ +#pragma mark - cpShape + +JSClass* JSB_cpShape_class = NULL; +JSObject* JSB_cpShape_object = NULL; + +// Constructor +bool JSB_cpShape_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==0, cx, false, "Invalid number of arguments"); + JSB_PRECONDITION2(false, cx, true, "No constructor"); + + return true; +} + +// Destructor +void JSB_cpShape_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpShape), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + cpShapeFree( (cpShape*)proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + } else { + CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpShape)", jsthis); + } +} + +// Arguments: +// Ret value: cpBB +bool JSB_cpShape_cacheBB(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpShape* arg0 = (cpShape*) proxy->handle; + cpBB ret_val; + + ret_val = cpShapeCacheBB((cpShape*)arg0 ); + + jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: void +bool JSB_cpShape_destroy(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpShape* arg0 = (cpShape*) proxy->handle; + + cpShapeDestroy((cpShape*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: +// Ret value: cpBB +bool JSB_cpShape_getBB(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpShape* arg0 = (cpShape*) proxy->handle; + cpBB ret_val; + + ret_val = cpShapeGetBB((cpShape*)arg0 ); + + jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpBody* +bool JSB_cpShape_getBody(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpShape* arg0 = (cpShape*) proxy->handle; + cpBody* ret_val; + + ret_val = cpShapeGetBody((cpShape*)arg0 ); + + jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpCollisionType +bool JSB_cpShape_getCollisionType(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpShape* arg0 = (cpShape*) proxy->handle; + cpCollisionType ret_val; + + ret_val = cpShapeGetCollisionType((cpShape*)arg0 ); + + jsval ret_jsval = uint32_to_jsval( cx, (cpCollisionType)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpShape_getElasticity(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpShape* arg0 = (cpShape*) proxy->handle; + cpFloat ret_val; + + ret_val = cpShapeGetElasticity((cpShape*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpShape_getFriction(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpShape* arg0 = (cpShape*) proxy->handle; + cpFloat ret_val; + + ret_val = cpShapeGetFriction((cpShape*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: +// Ret value: cpGroup +bool JSB_cpShape_getGroup(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpShape* arg0 = (cpShape*) proxy->handle; + cpGroup ret_val; + + ret_val = cpShapeGetGroup((cpShape*)arg0 ); + + jsval ret_jsval = uint32_to_jsval( cx, (cpGroup)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpLayers +bool JSB_cpShape_getLayers(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpShape* arg0 = (cpShape*) proxy->handle; + cpLayers ret_val; + + ret_val = cpShapeGetLayers((cpShape*)arg0 ); + args.rval().set(UINT_TO_JSVAL((uint32_t)ret_val)); + return true; +} + +// Arguments: +// Ret value: cpBool +bool JSB_cpShape_getSensor(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpShape* arg0 = (cpShape*) proxy->handle; + cpBool ret_val; + + ret_val = cpShapeGetSensor((cpShape*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: +// Ret value: cpSpace* +bool JSB_cpShape_getSpace(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpShape* arg0 = (cpShape*) proxy->handle; + cpSpace* ret_val; + + ret_val = cpShapeGetSpace((cpShape*)arg0 ); + + jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpSpace" ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpShape_getSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpShape* arg0 = (cpShape*) proxy->handle; + cpVect ret_val; + + ret_val = cpShapeGetSurfaceVelocity((cpShape*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect +// Ret value: cpBool +bool JSB_cpShape_pointQuery(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* arg0 = (cpShape*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpShapePointQuery((cpShape*)arg0 , (cpVect)arg1 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpBody* +// Ret value: void +bool JSB_cpShape_setBody(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* arg0 = (cpShape*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg1; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg1, NULL ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpShapeSetBody((cpShape*)arg0 , (cpBody*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpCollisionType +// Ret value: void +bool JSB_cpShape_setCollisionType(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* arg0 = (cpShape*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpCollisionType arg1; + + ok &= jsval_to_uint( cx, args.get(0), (unsigned int*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpShapeSetCollisionType((cpShape*)arg0 , (cpCollisionType)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpShape_setElasticity(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* arg0 = (cpShape*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpShapeSetElasticity((cpShape*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: void +bool JSB_cpShape_setFriction(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* arg0 = (cpShape*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpShapeSetFriction((cpShape*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpGroup +// Ret value: void +bool JSB_cpShape_setGroup(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* arg0 = (cpShape*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpGroup arg1; + + ok &= jsval_to_uint( cx, args.get(0), (unsigned int*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpShapeSetGroup((cpShape*)arg0 , (cpGroup)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpLayers +// Ret value: void +bool JSB_cpShape_setLayers(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* arg0 = (cpShape*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpShapeSetLayers((cpShape*)arg0 , (cpLayers)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBool +// Ret value: void +bool JSB_cpShape_setSensor(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* arg0 = (cpShape*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg1; + + ok &= jsval_to_int32( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpShapeSetSensor((cpShape*)arg0 , (cpBool)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpVect +// Ret value: void +bool JSB_cpShape_setSurfaceVelocity(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* arg0 = (cpShape*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpShapeSetSurfaceVelocity((cpShape*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpVect, cpVect +// Ret value: cpBB +bool JSB_cpShape_update(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* arg0 = (cpShape*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; cpVect arg2; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBB ret_val; + + ret_val = cpShapeUpdate((cpShape*)arg0 , (cpVect)arg1 , (cpVect)arg2 ); + + jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: void +// Ret value: cpBool +bool JSB_cpShape_active(JSContext *cx, uint32_t argc, jsval *vp){ + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpShape* arg0 = (cpShape*) proxy->handle; + + bool active = cpShapeActive(arg0); + jsval retval = BOOLEAN_TO_JSVAL(active); + args.rval().set(retval); + 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; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + cpVect p; + bool ok = jsval_to_cpVect(cx, args.get(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, JS::RootedObject(cx, JSB_cpNearestPointQueryInfo_object), JS::NullPtr()); + jsb_set_jsobject_for_proxy(jsobj, info); + jsb_set_c_proxy_for_jsobject(jsobj, info, JSB_C_FLAG_CALL_FREE); + args.rval().set(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; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + cpVect a; + cpVect b; + bool ok = jsval_to_cpVect(cx, args.get(0), &a); + ok &= jsval_to_cpVect(cx, args.get(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, JS::RootedObject(cx, JSB_cpSegmentQueryInfo_object), JS::NullPtr()); + jsb_set_jsobject_for_proxy(jsobj, info); + jsb_set_c_proxy_for_jsobject(jsobj, info, JSB_C_FLAG_CALL_FREE); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + } + else + { + delete info; + args.rval().set(JSVAL_NULL); + } + return true; +} + +static bool js_get_cpShape_bbl(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpShape* shape = (cpShape*) proxy->handle; + args.rval().setNumber(shape->bb.l); + return true; +} + +static bool js_set_cpShape_bbl(JSContext *cx, uint32_t argc, jsval *vp){ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpShape* shape = (cpShape*) proxy->handle; + shape->bb.l = args.get(0).toDouble(); + return true; +} + +static bool js_get_cpShape_bbb(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpShape* shape = (cpShape*) proxy->handle; + args.rval().setNumber(shape->bb.b); + return true; +} + +static bool js_set_cpShape_bbb(JSContext *cx, uint32_t argc, jsval *vp){ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpShape* shape = (cpShape*) proxy->handle; + shape->bb.b = args.get(0).toDouble(); + return true; +} +static bool js_get_cpShape_bbr(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpShape* shape = (cpShape*) proxy->handle; + args.rval().setNumber(shape->bb.r); + return true; +} + +static bool js_set_cpShape_bbr(JSContext *cx, uint32_t argc, jsval *vp){ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpShape* shape = (cpShape*) proxy->handle; + shape->bb.r = args.get(0).toDouble(); + return true; +} + +static bool js_get_cpShape_bbt(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpShape* shape = (cpShape*) proxy->handle; + args.rval().setNumber(shape->bb.t); + return true; +} + +static bool js_set_cpShape_bbt(JSContext *cx, uint32_t argc, jsval *vp){ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpShape* shape = (cpShape*) proxy->handle; + shape->bb.t = args.get(0).toDouble(); + return true; +} + +void JSB_cpShape_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpShape_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpShape_class->name = name; + JSB_cpShape_class->addProperty = JS_PropertyStub; + JSB_cpShape_class->delProperty = JS_DeletePropertyStub; + JSB_cpShape_class->getProperty = JS_PropertyStub; + JSB_cpShape_class->setProperty = JS_StrictPropertyStub; + JSB_cpShape_class->enumerate = JS_EnumerateStub; + JSB_cpShape_class->resolve = JS_ResolveStub; + JSB_cpShape_class->convert = JS_ConvertStub; + JSB_cpShape_class->finalize = JSB_cpShape_finalize; + JSB_cpShape_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PSGS("bb_l", js_get_cpShape_bbl, js_set_cpShape_bbl, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PSGS("bb_b", js_get_cpShape_bbb, js_set_cpShape_bbb, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PSGS("bb_r", js_get_cpShape_bbr, js_set_cpShape_bbr, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PSGS("bb_t", js_get_cpShape_bbt, js_set_cpShape_bbt, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("cacheBB", JSB_cpShape_cacheBB, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("destroy", JSB_cpShape_destroy, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBB", JSB_cpShape_getBB, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBody", JSB_cpShape_getBody, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCollisionType", JSB_cpShape_getCollisionType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getElasticity", JSB_cpShape_getElasticity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFriction", JSB_cpShape_getFriction, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getGroup", JSB_cpShape_getGroup, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLayers", JSB_cpShape_getLayers, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSensor", JSB_cpShape_getSensor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSpace", JSB_cpShape_getSpace, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSurfaceVelocity", JSB_cpShape_getSurfaceVelocity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pointQuery", JSB_cpShape_pointQuery, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBody", JSB_cpShape_setBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCollisionType", JSB_cpShape_setCollisionType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setElasticity", JSB_cpShape_setElasticity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFriction", JSB_cpShape_setFriction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setGroup", JSB_cpShape_setGroup, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLayers", JSB_cpShape_setLayers, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSensor", JSB_cpShape_setSensor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + 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[] = { + JS_FS_END + }; + + JSB_cpShape_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpBase_object), JSB_cpShape_class, JSB_cpShape_constructor,0,properties,funcs,NULL,st_funcs); +// bool found; +// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +/* + * cpCircleShape + */ +#pragma mark - cpCircleShape + +JSClass* JSB_cpCircleShape_class = NULL; +JSObject* JSB_cpCircleShape_object = NULL; +// Arguments: cpBody*, cpFloat, cpVect +// Constructor +bool JSB_cpCircleShape_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==3, cx, false, "Invalid number of arguments"); + JSObject *jsobj = JS_NewObject(cx, JSB_cpCircleShape_class, JS::RootedObject(cx, JSB_cpCircleShape_object), JS::NullPtr()); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; double arg1; cpVect arg2; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg0, NULL ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + void* ret_val = cpCircleShapeNew((cpBody*)arg0 , (cpFloat)arg1 , (cpVect)arg2 ); + + jsb_set_jsobject_for_proxy(jsobj, ret_val); + jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + + return true; +} + +// Destructor +void JSB_cpCircleShape_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpCircleShape), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + cpShapeFree( (cpShape*)proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + } else { + CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpCircleShape)", jsthis); + } +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpCircleShape_getOffset(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpCircleShape* arg0 = (cpCircleShape*) proxy->handle; + cpVect ret_val; + + ret_val = cpCircleShapeGetOffset((cpShape*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpCircleShape_getRadius(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpCircleShape* arg0 = (cpCircleShape*) proxy->handle; + cpFloat ret_val; + + ret_val = cpCircleShapeGetRadius((cpShape*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +void JSB_cpCircleShape_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpCircleShape_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpCircleShape_class->name = name; + JSB_cpCircleShape_class->addProperty = JS_PropertyStub; + JSB_cpCircleShape_class->delProperty = JS_DeletePropertyStub; + JSB_cpCircleShape_class->getProperty = JS_PropertyStub; + JSB_cpCircleShape_class->setProperty = JS_StrictPropertyStub; + JSB_cpCircleShape_class->enumerate = JS_EnumerateStub; + JSB_cpCircleShape_class->resolve = JS_ResolveStub; + JSB_cpCircleShape_class->convert = JS_ConvertStub; + JSB_cpCircleShape_class->finalize = JSB_cpCircleShape_finalize; + JSB_cpCircleShape_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("getOffset", JSB_cpCircleShape_getOffset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRadius", JSB_cpCircleShape_getRadius, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpCircleShape_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpShape_object), JSB_cpCircleShape_class, JSB_cpCircleShape_constructor,0,properties,funcs,NULL,st_funcs); +// bool found; +// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +/* + * cpSegmentShape + */ +#pragma mark - cpSegmentShape + +JSClass* JSB_cpSegmentShape_class = NULL; +JSObject* JSB_cpSegmentShape_object = NULL; +// Arguments: cpBody*, cpVect, cpVect, cpFloat +// Constructor +bool JSB_cpSegmentShape_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments"); + JSObject *jsobj = JS_NewObject(cx, JSB_cpSegmentShape_class, JS::RootedObject(cx, JSB_cpSegmentShape_object), JS::NullPtr()); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpVect arg1; cpVect arg2; double arg3; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg0, NULL ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + ok &= JS::ToNumber( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + void* ret_val = cpSegmentShapeNew((cpBody*)arg0 , (cpVect)arg1 , (cpVect)arg2 , (cpFloat)arg3 ); + + jsb_set_jsobject_for_proxy(jsobj, ret_val); + jsb_set_c_proxy_for_jsobject(jsobj, ret_val, JSB_C_FLAG_CALL_FREE); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + + return true; +} + +// Destructor +void JSB_cpSegmentShape_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpSegmentShape), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + cpShapeFree( (cpShape*)proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + } else { + CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpSegmentShape)", jsthis); + } +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpSegmentShape_getA(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSegmentShape* arg0 = (cpSegmentShape*) proxy->handle; + cpVect ret_val; + + ret_val = cpSegmentShapeGetA((cpShape*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpSegmentShape_getB(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSegmentShape* arg0 = (cpSegmentShape*) proxy->handle; + cpVect ret_val; + + ret_val = cpSegmentShapeGetB((cpShape*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpVect +bool JSB_cpSegmentShape_getNormal(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSegmentShape* arg0 = (cpSegmentShape*) proxy->handle; + cpVect ret_val; + + ret_val = cpSegmentShapeGetNormal((cpShape*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpFloat +bool JSB_cpSegmentShape_getRadius(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSegmentShape* arg0 = (cpSegmentShape*) proxy->handle; + cpFloat ret_val; + + ret_val = cpSegmentShapeGetRadius((cpShape*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpVect, cpVect +// Ret value: void +bool JSB_cpSegmentShape_setNeighbors(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); + cpSegmentShape* arg0 = (cpSegmentShape*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg1; cpVect arg2; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg1 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSegmentShapeSetNeighbors((cpShape*)arg0 , (cpVect)arg1 , (cpVect)arg2 ); + args.rval().setUndefined(); + return true; +} + +static bool js_get_cpSegmentShape_a_tangent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpSegmentShape* shape = (cpSegmentShape*) proxy->handle; + cpVect vec = shape->a_tangent; + jsval ret = cpVect_to_jsval( cx, vec); + args.rval().set(ret); + return true; +} + +static bool js_get_cpSegmentShape_b_tangent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpSegmentShape* shape = (cpSegmentShape*) proxy->handle; + cpVect vec = shape->b_tangent; + jsval ret = cpVect_to_jsval( cx, vec); + args.rval().set(ret); + return true; +} + +void JSB_cpSegmentShape_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpSegmentShape_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpSegmentShape_class->name = name; + JSB_cpSegmentShape_class->addProperty = JS_PropertyStub; + JSB_cpSegmentShape_class->delProperty = JS_DeletePropertyStub; + JSB_cpSegmentShape_class->getProperty = JS_PropertyStub; + JSB_cpSegmentShape_class->setProperty = JS_StrictPropertyStub; + JSB_cpSegmentShape_class->enumerate = JS_EnumerateStub; + JSB_cpSegmentShape_class->resolve = JS_ResolveStub; + JSB_cpSegmentShape_class->convert = JS_ConvertStub; + JSB_cpSegmentShape_class->finalize = JSB_cpSegmentShape_finalize; + JSB_cpSegmentShape_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PSG("a_tangent", js_get_cpSegmentShape_a_tangent, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PSG("b_tangent", js_get_cpSegmentShape_a_tangent, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("getA", JSB_cpSegmentShape_getA, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getB", JSB_cpSegmentShape_getB, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNormal", JSB_cpSegmentShape_getNormal, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRadius", JSB_cpSegmentShape_getRadius, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setNeighbors", JSB_cpSegmentShape_setNeighbors, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpSegmentShape_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpShape_object), JSB_cpSegmentShape_class, JSB_cpSegmentShape_constructor,0,properties,funcs,NULL,st_funcs); +// bool found; +// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +/* + * cpPolyShape + */ +#pragma mark - cpPolyShape + +JSClass* JSB_cpPolyShape_class = NULL; +JSObject* JSB_cpPolyShape_object = NULL; + +// Destructor +void JSB_cpPolyShape_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpPolyShape), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + cpShapeFree( (cpShape*)proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + } else { + CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpPolyShape)", jsthis); + } +} + +// Arguments: +// Ret value: int +bool JSB_cpPolyShape_getNumVerts(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpPolyShape* arg0 = (cpPolyShape*) proxy->handle; + int ret_val; + + ret_val = cpPolyShapeGetNumVerts((cpShape*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: int +// Ret value: cpVect +bool JSB_cpPolyShape_getVert(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); + cpPolyShape* arg0 = (cpPolyShape*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg1; + + ok &= jsval_to_int32( cx, args.get(0), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpPolyShapeGetVert((cpShape*)arg0 , (int)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +static bool js_get_cpPolyShape_verts(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpPolyShape* shape = (cpPolyShape*) proxy->handle; + int numVerts = shape->numVerts; + cpVect* verts = shape->verts; + + JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, 0)); + 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++; + } + args.rval().set(OBJECT_TO_JSVAL(jsretArr)); + return true; +} + +static bool js_get_cpPolyShape_planes(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpPolyShape* shape = (cpPolyShape*) proxy->handle; + int numVerts = shape->numVerts; + cpSplittingPlane* planes = shape->planes; + + JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, 0)); + 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, JS::RootedObject(cx, JSB_cpSplittingPlane_object), JS::NullPtr()); + 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++; + } + args.rval().set(OBJECT_TO_JSVAL(jsretArr)); + return true; +} + +void JSB_cpPolyShape_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpPolyShape_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpPolyShape_class->name = name; + JSB_cpPolyShape_class->addProperty = JS_PropertyStub; + JSB_cpPolyShape_class->delProperty = JS_DeletePropertyStub; + JSB_cpPolyShape_class->getProperty = JS_PropertyStub; + JSB_cpPolyShape_class->setProperty = JS_StrictPropertyStub; + JSB_cpPolyShape_class->enumerate = JS_EnumerateStub; + JSB_cpPolyShape_class->resolve = JS_ResolveStub; + JSB_cpPolyShape_class->convert = JS_ConvertStub; + JSB_cpPolyShape_class->finalize = JSB_cpPolyShape_finalize; + JSB_cpPolyShape_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PSG("verts", js_get_cpPolyShape_verts, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PSG("planes", js_get_cpPolyShape_planes, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("getNumVerts", JSB_cpPolyShape_getNumVerts, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVert", JSB_cpPolyShape_getVert, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpPolyShape_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, JSB_cpShape_object), JSB_cpPolyShape_class, JSB_cpPolyShape_constructor,0,properties,funcs,NULL,st_funcs); +// bool found; +// 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, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpSplittingPlane* plane = (cpSplittingPlane*) proxy->handle; + cpVect vec = plane->n; + args.rval().set(cpVect_to_jsval(cx, vec)); + return true; +} + +bool js_get_cpSplitting_d(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpSplittingPlane* plane = (cpSplittingPlane*) proxy->handle; + args.rval().set(DOUBLE_TO_JSVAL(plane->d)); + return true; +} + +void JSB_cpSplittingPlane_createClass(JSContext *cx, JS::HandleObject 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[] = { + JS_PSG("n", js_get_cpSplitting_n, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PSG("d", js_get_cpSplitting_d, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpSplittingPlane_object = JS_InitClass(cx, globalObj, JS::NullPtr(), 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" ); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSegmentQueryInfo* info = (cpSegmentQueryInfo*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + cpVect start; + cpVect end; + + bool ok = true; + ok &= jsval_to_cpVect( cx, args.get(0), &start ); + ok &= jsval_to_cpVect( cx, args.get(1), &end ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret = cpSegmentQueryHitPoint(start, end, *info); + + jsval ret_jsval = cpVect_to_jsval( cx, ret ); + args.rval().set(ret_jsval); + return true; +} + +bool JSB_cpSegmentQueryInfo_hitDist(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); + cpSegmentQueryInfo* info = (cpSegmentQueryInfo*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + cpVect start; + cpVect end; + + bool ok = true; + ok &= jsval_to_cpVect( cx, args.get(0), &start ); + ok &= jsval_to_cpVect( cx, args.get(1), &end ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + float ret = cpSegmentQueryHitDist(start, end, *info); + + jsval ret_jsval = DOUBLE_TO_JSVAL(ret); + args.rval().set(ret_jsval); + return true; +} + +JSClass* JSB_cpSegmentQueryInfo_class = NULL; +JSObject* JSB_cpSegmentQueryInfo_object = NULL; + +// Destructor +void JSB_cpSegmentQueryInfo_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpSegmentQueryInfo), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + delete ( (cpSegmentQueryInfo*)proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + } else { + CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpSegmentQueryInfo)", jsthis); + } +} + +bool js_get_cpSegmentQueryInfo_shape(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpSegmentQueryInfo* info = (cpSegmentQueryInfo*) proxy->handle; + cpShape* shape = info->shape; + + if(shape){ + JSObject *jsobj = JS_NewObject(cx, JSB_cpShape_class, JS::RootedObject(cx, JSB_cpShape_object), JS::NullPtr()); + //jsb_set_jsobject_for_proxy(jsobj, shape); + jsb_set_c_proxy_for_jsobject(jsobj, shape, JSB_C_FLAG_DO_NOT_CALL_FREE); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + }else{ + args.rval().setUndefined(); + } + + return true; +} + +bool js_set_cpSegmentQueryInfo_shape(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpSegmentQueryInfo* info = (cpSegmentQueryInfo*) proxy->handle; + + cpShape* shape; + struct jsb_c_proxy_s *retproxy; + jsval_to_c_class( cx, args.get(0), (void**)&shape, &retproxy ); + + info->shape = shape; + return true; +} + +bool js_get_cpSegmentQueryInfo_t(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpSegmentQueryInfo* info = (cpSegmentQueryInfo*) proxy->handle; + args.rval().setNumber(info->t); + return true; +} + +bool js_set_cpSegmentQueryInfo_t(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpSegmentQueryInfo* info = (cpSegmentQueryInfo*) proxy->handle; + info->t = args.get(0).toDouble(); + return true; +} + +bool js_get_cpSegmentQueryInfo_n(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpSegmentQueryInfo* info = (cpSegmentQueryInfo*) proxy->handle; + args.rval().set(cpVect_to_jsval(cx, info->n)); + return true; +} + +bool js_set_cpSegmentQueryInfo_n(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpSegmentQueryInfo* info = (cpSegmentQueryInfo*) proxy->handle; + cpVect v; + bool ok = jsval_to_cpVect(cx, args.get(0), &v); + if(ok) + info->n = v; + return true; +} + +void JSB_cpSegmentQueryInfo_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpSegmentQueryInfo_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpSegmentQueryInfo_class->name = name; + JSB_cpSegmentQueryInfo_class->addProperty = JS_PropertyStub; + JSB_cpSegmentQueryInfo_class->delProperty = JS_DeletePropertyStub; + JSB_cpSegmentQueryInfo_class->getProperty = JS_PropertyStub; + JSB_cpSegmentQueryInfo_class->setProperty = JS_StrictPropertyStub; + JSB_cpSegmentQueryInfo_class->enumerate = JS_EnumerateStub; + JSB_cpSegmentQueryInfo_class->resolve = JS_ResolveStub; + JSB_cpSegmentQueryInfo_class->convert = JS_ConvertStub; + JSB_cpSegmentQueryInfo_class->finalize = JSB_cpSegmentQueryInfo_finalize; + JSB_cpSegmentQueryInfo_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PSGS("shape", js_get_cpSegmentQueryInfo_shape, js_set_cpSegmentQueryInfo_shape, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PSGS("t", js_get_cpSegmentQueryInfo_t, js_set_cpSegmentQueryInfo_t, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PSGS("n", js_get_cpSegmentQueryInfo_n, js_set_cpSegmentQueryInfo_n, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("hitPoint", JSB_cpSegmentQueryInfo_hitPoint, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("hitDist", JSB_cpSegmentQueryInfo_hitDist, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpSegmentQueryInfo_object = JS_InitClass(cx, globalObj, JS::NullPtr(), JSB_cpSegmentQueryInfo_class, NULL,0,properties,funcs,NULL,st_funcs); +// bool found; +// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +bool js_get_cpNearestPointQueryInfo_shape(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpNearestPointQueryInfo* info = (cpNearestPointQueryInfo*) proxy->handle; + cpShape* shape = info->shape; + + if(shape){ + JSObject *jsobj = JS_NewObject(cx, JSB_cpShape_class, JS::RootedObject(cx, JSB_cpShape_object), JS::NullPtr()); + //jsb_set_jsobject_for_proxy(jsobj, shape); + jsb_set_c_proxy_for_jsobject(jsobj, shape, JSB_C_FLAG_DO_NOT_CALL_FREE); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + }else{ + args.rval().setUndefined(); + } + + return true; +} + +bool js_set_cpNearestPointQueryInfo_shape(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpNearestPointQueryInfo* info = (cpNearestPointQueryInfo*) proxy->handle; + + cpShape* shape; + struct jsb_c_proxy_s *retproxy; + jsval_to_c_class( cx, args.get(0), (void**)&shape, &retproxy ); + + info->shape = shape; + return true; +} + +bool js_get_cpNearestPointQueryInfo_p(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpNearestPointQueryInfo* info = (cpNearestPointQueryInfo*) proxy->handle; + args.rval().set(cpVect_to_jsval(cx, info->p)); + return true; +} + +bool js_set_cpNearestPointQueryInfo_p(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpNearestPointQueryInfo* info = (cpNearestPointQueryInfo*) proxy->handle; + cpVect v; + bool ok = jsval_to_cpVect(cx, args.get(0), &v); + if(ok) + info->p = v; + return true; +} + +bool js_get_cpNearestPointQueryInfo_d(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpNearestPointQueryInfo* info = (cpNearestPointQueryInfo*) proxy->handle; + args.rval().setNumber(info->d); + return true; +} + +bool js_set_cpNearestPointQueryInfo_d(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(args.thisv().toObjectOrNull()); + cpNearestPointQueryInfo* info = (cpNearestPointQueryInfo*) proxy->handle; + info->d = args.get(0).toDouble(); + return true; +} + +JSClass* JSB_cpNearestPointQueryInfo_class = NULL; +JSObject* JSB_cpNearestPointQueryInfo_object = NULL; + +// Destructor +void JSB_cpNearestPointQueryInfo_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpSegmentQueryInfo), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + delete ( (cpNearestPointQueryInfo*)proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + } else { + CCLOGINFO("jsbindings: finalizing uninitialized JS object %p (cpSegmentQueryInfo)", jsthis); + } +} + +void JSB_cpNearestPointQueryInfo_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpNearestPointQueryInfo_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpNearestPointQueryInfo_class->name = name; + JSB_cpNearestPointQueryInfo_class->addProperty = JS_PropertyStub; + JSB_cpNearestPointQueryInfo_class->delProperty = JS_DeletePropertyStub; + JSB_cpNearestPointQueryInfo_class->getProperty = JS_PropertyStub; + JSB_cpNearestPointQueryInfo_class->setProperty = JS_StrictPropertyStub; + JSB_cpNearestPointQueryInfo_class->enumerate = JS_EnumerateStub; + JSB_cpNearestPointQueryInfo_class->resolve = JS_ResolveStub; + JSB_cpNearestPointQueryInfo_class->convert = JS_ConvertStub; + JSB_cpNearestPointQueryInfo_class->finalize = JSB_cpNearestPointQueryInfo_finalize; + JSB_cpNearestPointQueryInfo_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PSGS("shape", js_get_cpNearestPointQueryInfo_shape, js_set_cpNearestPointQueryInfo_shape, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PSGS("p", js_get_cpNearestPointQueryInfo_p, js_set_cpNearestPointQueryInfo_p, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PSGS("d", js_get_cpNearestPointQueryInfo_d, js_set_cpNearestPointQueryInfo_d, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpNearestPointQueryInfo_object = JS_InitClass(cx, globalObj, JS::NullPtr(), JSB_cpNearestPointQueryInfo_class, NULL,0,properties,funcs,NULL,st_funcs); +} +#endif // JSB_INCLUDE_CHIPMUNK diff --git a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.h b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.h new file mode 100644 index 0000000000..93f7b77cc8 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.h @@ -0,0 +1,73 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-11-07 +* Script version: v0.3 +*/ +#include "js_bindings_config.h" +#ifdef JSB_INCLUDE_CHIPMUNK + +#include "js_bindings_chipmunk_manual.h" +extern JSObject *JSB_cpConstraint_object; +extern JSClass *JSB_cpConstraint_class; +void JSB_cpConstraint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpGrooveJoint_object; +extern JSClass *JSB_cpGrooveJoint_class; +void JSB_cpGrooveJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpSimpleMotor_object; +extern JSClass *JSB_cpSimpleMotor_class; +void JSB_cpSimpleMotor_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpPivotJoint_object; +extern JSClass *JSB_cpPivotJoint_class; +void JSB_cpPivotJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpPinJoint_object; +extern JSClass *JSB_cpPinJoint_class; +void JSB_cpPinJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpSlideJoint_object; +extern JSClass *JSB_cpSlideJoint_class; +void JSB_cpSlideJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpGearJoint_object; +extern JSClass *JSB_cpGearJoint_class; +void JSB_cpGearJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpDampedRotarySpring_object; +extern JSClass *JSB_cpDampedRotarySpring_class; +void JSB_cpDampedRotarySpring_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpDampedSpring_object; +extern JSClass *JSB_cpDampedSpring_class; +void JSB_cpDampedSpring_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpRatchetJoint_object; +extern JSClass *JSB_cpRatchetJoint_class; +void JSB_cpRatchetJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpRotaryLimitJoint_object; +extern JSClass *JSB_cpRotaryLimitJoint_class; +void JSB_cpRotaryLimitJoint_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpArbiter_object; +extern JSClass *JSB_cpArbiter_class; +void JSB_cpArbiter_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpSpace_object; +extern JSClass *JSB_cpSpace_class; +void JSB_cpSpace_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpBody_object; +extern JSClass *JSB_cpBody_class; +void JSB_cpBody_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpShape_object; +extern JSClass *JSB_cpShape_class; +void JSB_cpShape_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpCircleShape_object; +extern JSClass *JSB_cpCircleShape_class; +void JSB_cpCircleShape_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpSegmentShape_object; +extern JSClass *JSB_cpSegmentShape_class; +void JSB_cpSegmentShape_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpPolyShape_object; +extern JSClass *JSB_cpPolyShape_class; +void JSB_cpPolyShape_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpSegmentQueryInfo_object; +extern JSClass *JSB_cpSegmentQueryInfo_class; +void JSB_cpSegmentQueryInfo_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpNearestPointQueryInfo_object; +extern JSClass *JSB_cpNearestPointQueryInfo_class; +void JSB_cpNearestPointQueryInfo_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +extern JSObject *JSB_cpSplittingPlane_object; +extern JSClass *JSB_cpSplittingPlane_class; +void JSB_cpSplittingPlane_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ); +#endif // JSB_INCLUDE_CHIPMUNK diff --git a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes_registration.h b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes_registration.h new file mode 100644 index 0000000000..635d3fbbbf --- /dev/null +++ b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes_registration.h @@ -0,0 +1,30 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-11-07 +* Script version: v0.3 +*/ +#include "js_bindings_config.h" +#ifdef JSB_INCLUDE_CHIPMUNK + +JSB_cpConstraint_createClass(cx, chipmunk, "Constraint"); +JSB_cpGrooveJoint_createClass(cx, chipmunk, "GrooveJoint"); +JSB_cpSimpleMotor_createClass(cx, chipmunk, "SimpleMotor"); +JSB_cpPivotJoint_createClass(cx, chipmunk, "PivotJoint"); +JSB_cpPinJoint_createClass(cx, chipmunk, "PinJoint"); +JSB_cpSlideJoint_createClass(cx, chipmunk, "SlideJoint"); +JSB_cpGearJoint_createClass(cx, chipmunk, "GearJoint"); +JSB_cpDampedRotarySpring_createClass(cx, chipmunk, "DampedRotarySpring"); +JSB_cpDampedSpring_createClass(cx, chipmunk, "DampedSpring"); +JSB_cpRatchetJoint_createClass(cx, chipmunk, "RatchetJoint"); +JSB_cpRotaryLimitJoint_createClass(cx, chipmunk, "RotaryLimitJoint"); +JSB_cpArbiter_createClass(cx, chipmunk, "Arbiter"); +JSB_cpSpace_createClass(cx, chipmunk, "Space"); +JSB_cpBody_createClass(cx, chipmunk, "Body"); +JSB_cpShape_createClass(cx, chipmunk, "Shape"); +JSB_cpCircleShape_createClass(cx, chipmunk, "CircleShape"); +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/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_functions.cpp b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_functions.cpp new file mode 100644 index 0000000000..c1f4904218 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_functions.cpp @@ -0,0 +1,5039 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-11-07 +* Script version: v0.3 +*/ +#include "js_bindings_config.h" +#ifdef JSB_INCLUDE_CHIPMUNK + +#include "js_bindings_chipmunk_manual.h" + +#include "jsfriendapi.h" +#include "js_bindings_config.h" +#include "js_manual_conversions.h" +#include "js_bindings_chipmunk_functions.h" + +// Arguments: cpArbiter* +// Ret value: int +bool JSB_cpArbiterGetCount(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpArbiter* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + int ret_val; + + ret_val = cpArbiterGetCount((cpArbiter*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpArbiter*, int +// Ret value: cpFloat +bool JSB_cpArbiterGetDepth(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpArbiter* arg0; int32_t arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpArbiterGetDepth((cpArbiter*)arg0 , (int)arg1 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpArbiter* +// Ret value: cpFloat +bool JSB_cpArbiterGetElasticity(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpArbiter* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpArbiterGetElasticity((cpArbiter*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpArbiter* +// Ret value: cpFloat +bool JSB_cpArbiterGetFriction(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpArbiter* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpArbiterGetFriction((cpArbiter*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpArbiter*, int +// Ret value: cpVect +bool JSB_cpArbiterGetNormal(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpArbiter* arg0; int32_t arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpArbiterGetNormal((cpArbiter*)arg0 , (int)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpArbiter*, int +// Ret value: cpVect +bool JSB_cpArbiterGetPoint(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpArbiter* arg0; int32_t arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpArbiterGetPoint((cpArbiter*)arg0 , (int)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpArbiter* +// Ret value: cpVect +bool JSB_cpArbiterGetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpArbiter* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpArbiterGetSurfaceVelocity((cpArbiter*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpArbiter* +// Ret value: void +bool JSB_cpArbiterIgnore(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpArbiter* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpArbiterIgnore((cpArbiter*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpArbiter* +// Ret value: cpBool +bool JSB_cpArbiterIsFirstContact(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpArbiter* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpArbiterIsFirstContact((cpArbiter*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpArbiter*, cpFloat +// Ret value: void +bool JSB_cpArbiterSetElasticity(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpArbiter* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpArbiterSetElasticity((cpArbiter*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpArbiter*, cpFloat +// Ret value: void +bool JSB_cpArbiterSetFriction(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpArbiter* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpArbiterSetFriction((cpArbiter*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpArbiter*, cpVect +// Ret value: void +bool JSB_cpArbiterSetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpArbiter* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpArbiterSetSurfaceVelocity((cpArbiter*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpArbiter* +// Ret value: cpVect +bool JSB_cpArbiterTotalImpulse(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpArbiter* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpArbiterTotalImpulse((cpArbiter*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpArbiter* +// Ret value: cpVect +bool JSB_cpArbiterTotalImpulseWithFriction(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpArbiter* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpArbiterTotalImpulseWithFriction((cpArbiter*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpArbiter* +// Ret value: cpFloat +bool JSB_cpArbiterTotalKE(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpArbiter* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpArbiterTotalKE((cpArbiter*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpFloat, cpFloat +// Ret value: cpFloat +bool JSB_cpAreaForCircle(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg0; double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpAreaForCircle((cpFloat)arg0 , (cpFloat)arg1 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpVect, cpVect, cpFloat +// Ret value: cpFloat +bool JSB_cpAreaForSegment(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; cpVect arg1; double arg2; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpAreaForSegment((cpVect)arg0 , (cpVect)arg1 , (cpFloat)arg2 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBB +// Ret value: cpFloat +bool JSB_cpBBArea(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBB arg0; + + ok &= jsval_to_cpBB( cx, args.get(0), (cpBB*) &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpBBArea((cpBB)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBB, cpVect +// Ret value: cpVect +bool JSB_cpBBClampVect(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBB arg0; cpVect arg1; + + ok &= jsval_to_cpBB( cx, args.get(0), (cpBB*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpBBClampVect((cpBB)arg0 , (cpVect)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBB, cpBB +// Ret value: cpBool +bool JSB_cpBBContainsBB(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBB arg0; cpBB arg1; + + ok &= jsval_to_cpBB( cx, args.get(0), (cpBB*) &arg0 ); + ok &= jsval_to_cpBB( cx, args.get(1), (cpBB*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpBBContainsBB((cpBB)arg0 , (cpBB)arg1 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpBB, cpVect +// Ret value: cpBool +bool JSB_cpBBContainsVect(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBB arg0; cpVect arg1; + + ok &= jsval_to_cpBB( cx, args.get(0), (cpBB*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpBBContainsVect((cpBB)arg0 , (cpVect)arg1 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpBB, cpVect +// Ret value: cpBB +bool JSB_cpBBExpand(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBB arg0; cpVect arg1; + + ok &= jsval_to_cpBB( cx, args.get(0), (cpBB*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBB ret_val; + + ret_val = cpBBExpand((cpBB)arg0 , (cpVect)arg1 ); + + jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBB, cpBB +// Ret value: cpBool +bool JSB_cpBBIntersects(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBB arg0; cpBB arg1; + + ok &= jsval_to_cpBB( cx, args.get(0), (cpBB*) &arg0 ); + ok &= jsval_to_cpBB( cx, args.get(1), (cpBB*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpBBIntersects((cpBB)arg0 , (cpBB)arg1 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpBB, cpVect, cpVect +// Ret value: cpBool +bool JSB_cpBBIntersectsSegment(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBB arg0; cpVect arg1; cpVect arg2; + + ok &= jsval_to_cpBB( cx, args.get(0), (cpBB*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpBBIntersectsSegment((cpBB)arg0 , (cpVect)arg1 , (cpVect)arg2 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpBB, cpBB +// Ret value: cpBB +bool JSB_cpBBMerge(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBB arg0; cpBB arg1; + + ok &= jsval_to_cpBB( cx, args.get(0), (cpBB*) &arg0 ); + ok &= jsval_to_cpBB( cx, args.get(1), (cpBB*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBB ret_val; + + ret_val = cpBBMerge((cpBB)arg0 , (cpBB)arg1 ); + + jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBB, cpBB +// Ret value: cpFloat +bool JSB_cpBBMergedArea(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBB arg0; cpBB arg1; + + ok &= jsval_to_cpBB( cx, args.get(0), (cpBB*) &arg0 ); + ok &= jsval_to_cpBB( cx, args.get(1), (cpBB*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpBBMergedArea((cpBB)arg0 , (cpBB)arg1 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpFloat, cpFloat, cpFloat, cpFloat +// Ret value: cpBB +bool JSB_cpBBNew(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg0; double arg1; double arg2; double arg3; + + ok &= JS::ToNumber( cx, args.get(0), &arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + ok &= JS::ToNumber( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBB ret_val; + + ret_val = cpBBNew((cpFloat)arg0 , (cpFloat)arg1 , (cpFloat)arg2 , (cpFloat)arg3 ); + + jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect, cpFloat +// Ret value: cpBB +bool JSB_cpBBNewForCircle(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; double arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBB ret_val; + + ret_val = cpBBNewForCircle((cpVect)arg0 , (cpFloat)arg1 ); + + jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBB, cpVect, cpVect +// Ret value: cpFloat +bool JSB_cpBBSegmentQuery(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBB arg0; cpVect arg1; cpVect arg2; + + ok &= jsval_to_cpBB( cx, args.get(0), (cpBB*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpBBSegmentQuery((cpBB)arg0 , (cpVect)arg1 , (cpVect)arg2 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBB, cpVect +// Ret value: cpVect +bool JSB_cpBBWrapVect(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBB arg0; cpVect arg1; + + ok &= jsval_to_cpBB( cx, args.get(0), (cpBB*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpBBWrapVect((cpBB)arg0 , (cpVect)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBody* +// Ret value: void +bool JSB_cpBodyActivate(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodyActivate((cpBody*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody*, cpShape* +// Ret value: void +bool JSB_cpBodyActivateStatic(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpShape* arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodyActivateStatic((cpBody*)arg0 , (cpShape*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody*, cpVect, cpVect +// Ret value: void +bool JSB_cpBodyApplyForce(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpVect arg1; cpVect arg2; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodyApplyForce((cpBody*)arg0 , (cpVect)arg1 , (cpVect)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody*, cpVect, cpVect +// Ret value: void +bool JSB_cpBodyApplyImpulse(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpVect arg1; cpVect arg2; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodyApplyImpulse((cpBody*)arg0 , (cpVect)arg1 , (cpVect)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody* +// Ret value: void +bool JSB_cpBodyDestroy(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodyDestroy((cpBody*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody* +// Ret value: void +bool JSB_cpBodyFree(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodyFree((cpBody*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody* +// Ret value: cpFloat +bool JSB_cpBodyGetAngVel(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpBodyGetAngVel((cpBody*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBody* +// Ret value: cpFloat +bool JSB_cpBodyGetAngVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpBodyGetAngVelLimit((cpBody*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBody* +// Ret value: cpFloat +bool JSB_cpBodyGetAngle(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpBodyGetAngle((cpBody*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBody* +// Ret value: cpVect +bool JSB_cpBodyGetForce(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpBodyGetForce((cpBody*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBody* +// Ret value: cpFloat +bool JSB_cpBodyGetMass(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpBodyGetMass((cpBody*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBody* +// Ret value: cpFloat +bool JSB_cpBodyGetMoment(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpBodyGetMoment((cpBody*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBody* +// Ret value: cpVect +bool JSB_cpBodyGetPos(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpBodyGetPos((cpBody*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBody* +// Ret value: cpVect +bool JSB_cpBodyGetRot(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpBodyGetRot((cpBody*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBody* +// Ret value: cpSpace* +bool JSB_cpBodyGetSpace(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpSpace* ret_val; + + ret_val = cpBodyGetSpace((cpBody*)arg0 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBody* +// Ret value: cpFloat +bool JSB_cpBodyGetTorque(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpBodyGetTorque((cpBody*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBody* +// Ret value: cpVect +bool JSB_cpBodyGetVel(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpBodyGetVel((cpBody*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBody*, cpVect +// Ret value: cpVect +bool JSB_cpBodyGetVelAtLocalPoint(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpBodyGetVelAtLocalPoint((cpBody*)arg0 , (cpVect)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBody*, cpVect +// Ret value: cpVect +bool JSB_cpBodyGetVelAtWorldPoint(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpBodyGetVelAtWorldPoint((cpBody*)arg0 , (cpVect)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBody* +// Ret value: cpFloat +bool JSB_cpBodyGetVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpBodyGetVelLimit((cpBody*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBody*, cpFloat, cpFloat +// Ret value: cpBody* +bool JSB_cpBodyInit(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; double arg1; double arg2; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBody* ret_val; + + ret_val = cpBodyInit((cpBody*)arg0 , (cpFloat)arg1 , (cpFloat)arg2 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBody* +// Ret value: cpBody* +bool JSB_cpBodyInitStatic(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBody* ret_val; + + ret_val = cpBodyInitStatic((cpBody*)arg0 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBody* +// Ret value: cpBool +bool JSB_cpBodyIsRogue(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpBodyIsRogue((cpBody*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpBody* +// Ret value: cpBool +bool JSB_cpBodyIsSleeping(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpBodyIsSleeping((cpBody*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpBody* +// Ret value: cpBool +bool JSB_cpBodyIsStatic(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpBodyIsStatic((cpBody*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpBody* +// Ret value: cpFloat +bool JSB_cpBodyKineticEnergy(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpBodyKineticEnergy((cpBody*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBody*, cpVect +// Ret value: cpVect +bool JSB_cpBodyLocal2World(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpBodyLocal2World((cpBody*)arg0 , (cpVect)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpFloat, cpFloat +// Ret value: cpBody* +bool JSB_cpBodyNew(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg0; double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBody* ret_val; + + ret_val = cpBodyNew((cpFloat)arg0 , (cpFloat)arg1 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: cpBody* +bool JSB_cpBodyNewStatic(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + cpBody* ret_val; + + ret_val = cpBodyNewStatic( ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBody* +// Ret value: void +bool JSB_cpBodyResetForces(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodyResetForces((cpBody*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody*, cpFloat +// Ret value: void +bool JSB_cpBodySetAngVel(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetAngVel((cpBody*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody*, cpFloat +// Ret value: void +bool JSB_cpBodySetAngVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetAngVelLimit((cpBody*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody*, cpFloat +// Ret value: void +bool JSB_cpBodySetAngle(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetAngle((cpBody*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody*, cpVect +// Ret value: void +bool JSB_cpBodySetForce(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetForce((cpBody*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody*, cpFloat +// Ret value: void +bool JSB_cpBodySetMass(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetMass((cpBody*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody*, cpFloat +// Ret value: void +bool JSB_cpBodySetMoment(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetMoment((cpBody*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody*, cpVect +// Ret value: void +bool JSB_cpBodySetPos(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetPos((cpBody*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody*, cpFloat +// Ret value: void +bool JSB_cpBodySetTorque(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetTorque((cpBody*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody*, cpVect +// Ret value: void +bool JSB_cpBodySetVel(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetVel((cpBody*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody*, cpFloat +// Ret value: void +bool JSB_cpBodySetVelLimit(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySetVelLimit((cpBody*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody* +// Ret value: void +bool JSB_cpBodySleep(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySleep((cpBody*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody*, cpBody* +// Ret value: void +bool JSB_cpBodySleepWithGroup(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodySleepWithGroup((cpBody*)arg0 , (cpBody*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody*, cpFloat +// Ret value: void +bool JSB_cpBodyUpdatePosition(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodyUpdatePosition((cpBody*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody*, cpVect, cpFloat, cpFloat +// Ret value: void +bool JSB_cpBodyUpdateVelocity(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpVect arg1; double arg2; double arg3; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + ok &= JS::ToNumber( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpBodyUpdateVelocity((cpBody*)arg0 , (cpVect)arg1 , (cpFloat)arg2 , (cpFloat)arg3 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpBody*, cpVect +// Ret value: cpVect +bool JSB_cpBodyWorld2Local(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpBodyWorld2Local((cpBody*)arg0 , (cpVect)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBody*, cpFloat, cpFloat +// Ret value: cpShape* +bool JSB_cpBoxShapeNew(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; double arg1; double arg2; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpShape* ret_val; + + ret_val = cpBoxShapeNew((cpBody*)arg0 , (cpFloat)arg1 , (cpFloat)arg2 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBody*, cpBB +// Ret value: cpShape* +bool JSB_cpBoxShapeNew2(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBB arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpBB( cx, args.get(1), (cpBB*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpShape* ret_val; + + ret_val = cpBoxShapeNew2((cpBody*)arg0 , (cpBB)arg1 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpShape* +// Ret value: cpVect +bool JSB_cpCircleShapeGetOffset(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpCircleShapeGetOffset((cpShape*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpShape* +// Ret value: cpFloat +bool JSB_cpCircleShapeGetRadius(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpCircleShapeGetRadius((cpShape*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBody*, cpFloat, cpVect +// Ret value: cpShape* +bool JSB_cpCircleShapeNew(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; double arg1; cpVect arg2; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpShape* ret_val; + + ret_val = cpCircleShapeNew((cpBody*)arg0 , (cpFloat)arg1 , (cpVect)arg2 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint* +// Ret value: void +bool JSB_cpConstraintActivateBodies(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpConstraintActivateBodies((cpConstraint*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint* +// Ret value: void +bool JSB_cpConstraintDestroy(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpConstraintDestroy((cpConstraint*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint* +// Ret value: void +bool JSB_cpConstraintFree(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpConstraintFree((cpConstraint*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpBody* +bool JSB_cpConstraintGetA(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBody* ret_val; + + ret_val = cpConstraintGetA((cpConstraint*)arg0 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpBody* +bool JSB_cpConstraintGetB(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBody* ret_val; + + ret_val = cpConstraintGetB((cpConstraint*)arg0 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpConstraintGetErrorBias(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpConstraintGetErrorBias((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpConstraintGetImpulse(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpConstraintGetImpulse((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpConstraintGetMaxBias(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpConstraintGetMaxBias((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpConstraintGetMaxForce(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpConstraintGetMaxForce((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpSpace* +bool JSB_cpConstraintGetSpace(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpSpace* ret_val; + + ret_val = cpConstraintGetSpace((cpConstraint*)arg0 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpConstraintSetErrorBias(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpConstraintSetErrorBias((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpConstraintSetMaxBias(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpConstraintSetMaxBias((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpConstraintSetMaxForce(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpConstraintSetMaxForce((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpDampedRotarySpringGetDamping(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpDampedRotarySpringGetDamping((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpDampedRotarySpringGetRestAngle(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpDampedRotarySpringGetRestAngle((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpDampedRotarySpringGetStiffness(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpDampedRotarySpringGetStiffness((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBody*, cpBody*, cpFloat, cpFloat, cpFloat +// Ret value: cpConstraint* +bool JSB_cpDampedRotarySpringNew(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 5, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; double arg2; double arg3; double arg4; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + ok &= JS::ToNumber( cx, args.get(3), &arg3 ); + ok &= JS::ToNumber( cx, args.get(4), &arg4 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpConstraint* ret_val; + + ret_val = cpDampedRotarySpringNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 , (cpFloat)arg3 , (cpFloat)arg4 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpDampedRotarySpringSetDamping(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpDampedRotarySpringSetDamping((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpDampedRotarySpringSetRestAngle(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpDampedRotarySpringSetRestAngle((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpDampedRotarySpringSetStiffness(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpDampedRotarySpringSetStiffness((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpVect +bool JSB_cpDampedSpringGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpDampedSpringGetAnchr1((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpVect +bool JSB_cpDampedSpringGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpDampedSpringGetAnchr2((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpDampedSpringGetDamping(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpDampedSpringGetDamping((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpDampedSpringGetRestLength(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpDampedSpringGetRestLength((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpDampedSpringGetStiffness(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpDampedSpringGetStiffness((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBody*, cpBody*, cpVect, cpVect, cpFloat, cpFloat, cpFloat +// Ret value: cpConstraint* +bool JSB_cpDampedSpringNew(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 7, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; double arg4; double arg5; double arg6; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + ok &= jsval_to_cpVect( cx, args.get(3), (cpVect*) &arg3 ); + ok &= JS::ToNumber( cx, args.get(4), &arg4 ); + ok &= JS::ToNumber( cx, args.get(5), &arg5 ); + ok &= JS::ToNumber( cx, args.get(6), &arg6 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpConstraint* ret_val; + + ret_val = cpDampedSpringNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 , (cpFloat)arg4 , (cpFloat)arg5 , (cpFloat)arg6 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint*, cpVect +// Ret value: void +bool JSB_cpDampedSpringSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpDampedSpringSetAnchr1((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpVect +// Ret value: void +bool JSB_cpDampedSpringSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpDampedSpringSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpDampedSpringSetDamping(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpDampedSpringSetDamping((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpDampedSpringSetRestLength(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpDampedSpringSetRestLength((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpDampedSpringSetStiffness(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpDampedSpringSetStiffness((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpGearJointGetPhase(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpGearJointGetPhase((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpGearJointGetRatio(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpGearJointGetRatio((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBody*, cpBody*, cpFloat, cpFloat +// Ret value: cpConstraint* +bool JSB_cpGearJointNew(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; double arg2; double arg3; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + ok &= JS::ToNumber( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpConstraint* ret_val; + + ret_val = cpGearJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 , (cpFloat)arg3 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpGearJointSetPhase(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpGearJointSetPhase((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpGearJointSetRatio(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpGearJointSetRatio((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpVect +bool JSB_cpGrooveJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpGrooveJointGetAnchr2((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpVect +bool JSB_cpGrooveJointGetGrooveA(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpGrooveJointGetGrooveA((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpVect +bool JSB_cpGrooveJointGetGrooveB(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpGrooveJointGetGrooveB((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBody*, cpBody*, cpVect, cpVect, cpVect +// Ret value: cpConstraint* +bool JSB_cpGrooveJointNew(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 5, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; cpVect arg4; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + ok &= jsval_to_cpVect( cx, args.get(3), (cpVect*) &arg3 ); + ok &= jsval_to_cpVect( cx, args.get(4), (cpVect*) &arg4 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpConstraint* ret_val; + + ret_val = cpGrooveJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 , (cpVect)arg4 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint*, cpVect +// Ret value: void +bool JSB_cpGrooveJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpGrooveJointSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpVect +// Ret value: void +bool JSB_cpGrooveJointSetGrooveA(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpGrooveJointSetGrooveA((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpVect +// Ret value: void +bool JSB_cpGrooveJointSetGrooveB(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpGrooveJointSetGrooveB((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: +// Ret value: void +bool JSB_cpInitChipmunk(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + cpInitChipmunk( ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat, cpFloat, cpFloat +// Ret value: cpFloat +bool JSB_cpMomentForBox(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg0; double arg1; double arg2; + + ok &= JS::ToNumber( cx, args.get(0), &arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpMomentForBox((cpFloat)arg0 , (cpFloat)arg1 , (cpFloat)arg2 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpFloat, cpBB +// Ret value: cpFloat +bool JSB_cpMomentForBox2(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg0; cpBB arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg0 ); + ok &= jsval_to_cpBB( cx, args.get(1), (cpBB*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpMomentForBox2((cpFloat)arg0 , (cpBB)arg1 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpFloat, cpFloat, cpFloat, cpVect +// Ret value: cpFloat +bool JSB_cpMomentForCircle(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg0; double arg1; double arg2; cpVect arg3; + + ok &= JS::ToNumber( cx, args.get(0), &arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + ok &= jsval_to_cpVect( cx, args.get(3), (cpVect*) &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpMomentForCircle((cpFloat)arg0 , (cpFloat)arg1 , (cpFloat)arg2 , (cpVect)arg3 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpFloat, cpVect, cpVect +// Ret value: cpFloat +bool JSB_cpMomentForSegment(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg0; cpVect arg1; cpVect arg2; + + ok &= JS::ToNumber( cx, args.get(0), &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpMomentForSegment((cpFloat)arg0 , (cpVect)arg1 , (cpVect)arg2 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpVect +bool JSB_cpPinJointGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpPinJointGetAnchr1((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpVect +bool JSB_cpPinJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpPinJointGetAnchr2((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpPinJointGetDist(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpPinJointGetDist((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBody*, cpBody*, cpVect, cpVect +// Ret value: cpConstraint* +bool JSB_cpPinJointNew(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + ok &= jsval_to_cpVect( cx, args.get(3), (cpVect*) &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpConstraint* ret_val; + + ret_val = cpPinJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint*, cpVect +// Ret value: void +bool JSB_cpPinJointSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpPinJointSetAnchr1((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpVect +// Ret value: void +bool JSB_cpPinJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpPinJointSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpPinJointSetDist(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpPinJointSetDist((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpVect +bool JSB_cpPivotJointGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpPivotJointGetAnchr1((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpVect +bool JSB_cpPivotJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpPivotJointGetAnchr2((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBody*, cpBody*, cpVect +// Ret value: cpConstraint* +bool JSB_cpPivotJointNew(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3 || argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + if(argc == 4) { + ok &= jsval_to_cpVect( cx, args.get(3), (cpVect*) &arg3 ); + } + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpConstraint* ret_val; + + if(argc == 4) { + ret_val = cpPivotJointNew2((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 ); + } else { + ret_val = cpPivotJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 ); + } + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpBody*, cpBody*, cpVect, cpVect +// Ret value: cpConstraint* +bool JSB_cpPivotJointNew2(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + ok &= jsval_to_cpVect( cx, args.get(3), (cpVect*) &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpConstraint* ret_val; + + ret_val = cpPivotJointNew2((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint*, cpVect +// Ret value: void +bool JSB_cpPivotJointSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpPivotJointSetAnchr1((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpVect +// Ret value: void +bool JSB_cpPivotJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpPivotJointSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpShape* +// Ret value: int +bool JSB_cpPolyShapeGetNumVerts(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + int ret_val; + + ret_val = cpPolyShapeGetNumVerts((cpShape*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpShape*, int +// Ret value: cpVect +bool JSB_cpPolyShapeGetVert(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; int32_t arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpPolyShapeGetVert((cpShape*)arg0 , (int)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpRatchetJointGetAngle(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpRatchetJointGetAngle((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpRatchetJointGetPhase(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpRatchetJointGetPhase((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpRatchetJointGetRatchet(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpRatchetJointGetRatchet((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBody*, cpBody*, cpFloat, cpFloat +// Ret value: cpConstraint* +bool JSB_cpRatchetJointNew(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; double arg2; double arg3; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + ok &= JS::ToNumber( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpConstraint* ret_val; + + ret_val = cpRatchetJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 , (cpFloat)arg3 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpRatchetJointSetAngle(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpRatchetJointSetAngle((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpRatchetJointSetPhase(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpRatchetJointSetPhase((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpRatchetJointSetRatchet(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpRatchetJointSetRatchet((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: +// Ret value: void +bool JSB_cpResetShapeIdCounter(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + cpResetShapeIdCounter( ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpRotaryLimitJointGetMax(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpRotaryLimitJointGetMax((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpRotaryLimitJointGetMin(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpRotaryLimitJointGetMin((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBody*, cpBody*, cpFloat, cpFloat +// Ret value: cpConstraint* +bool JSB_cpRotaryLimitJointNew(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; double arg2; double arg3; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + ok &= JS::ToNumber( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpConstraint* ret_val; + + ret_val = cpRotaryLimitJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 , (cpFloat)arg3 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpRotaryLimitJointSetMax(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpRotaryLimitJointSetMax((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpRotaryLimitJointSetMin(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpRotaryLimitJointSetMin((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpShape* +// Ret value: cpVect +bool JSB_cpSegmentShapeGetA(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpSegmentShapeGetA((cpShape*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpShape* +// Ret value: cpVect +bool JSB_cpSegmentShapeGetB(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpSegmentShapeGetB((cpShape*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpShape* +// Ret value: cpVect +bool JSB_cpSegmentShapeGetNormal(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpSegmentShapeGetNormal((cpShape*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpShape* +// Ret value: cpFloat +bool JSB_cpSegmentShapeGetRadius(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpSegmentShapeGetRadius((cpShape*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBody*, cpVect, cpVect, cpFloat +// Ret value: cpShape* +bool JSB_cpSegmentShapeNew(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpVect arg1; cpVect arg2; double arg3; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + ok &= JS::ToNumber( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpShape* ret_val; + + ret_val = cpSegmentShapeNew((cpBody*)arg0 , (cpVect)arg1 , (cpVect)arg2 , (cpFloat)arg3 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpShape*, cpVect, cpVect +// Ret value: void +bool JSB_cpSegmentShapeSetNeighbors(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; cpVect arg1; cpVect arg2; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSegmentShapeSetNeighbors((cpShape*)arg0 , (cpVect)arg1 , (cpVect)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpShape* +// Ret value: cpBB +bool JSB_cpShapeCacheBB(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBB ret_val; + + ret_val = cpShapeCacheBB((cpShape*)arg0 ); + + jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpShape* +// Ret value: void +bool JSB_cpShapeDestroy(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpShapeDestroy((cpShape*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpShape* +// Ret value: void +bool JSB_cpShapeFree(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpShapeFree((cpShape*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpShape* +// Ret value: cpBB +bool JSB_cpShapeGetBB(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBB ret_val; + + ret_val = cpShapeGetBB((cpShape*)arg0 ); + + jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpShape* +// Ret value: cpBody* +bool JSB_cpShapeGetBody(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBody* ret_val; + + ret_val = cpShapeGetBody((cpShape*)arg0 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpShape* +// Ret value: cpCollisionType +bool JSB_cpShapeGetCollisionType(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpCollisionType ret_val; + + ret_val = cpShapeGetCollisionType((cpShape*)arg0 ); + + jsval ret_jsval = uint32_to_jsval( cx, (cpCollisionType)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpShape* +// Ret value: cpFloat +bool JSB_cpShapeGetElasticity(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpShapeGetElasticity((cpShape*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpShape* +// Ret value: cpFloat +bool JSB_cpShapeGetFriction(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpShapeGetFriction((cpShape*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpShape* +// Ret value: cpGroup +bool JSB_cpShapeGetGroup(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpGroup ret_val; + + ret_val = cpShapeGetGroup((cpShape*)arg0 ); + + jsval ret_jsval = uint32_to_jsval( cx, (cpGroup)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpShape* +// Ret value: cpLayers +bool JSB_cpShapeGetLayers(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpLayers ret_val; + + ret_val = cpShapeGetLayers((cpShape*)arg0 ); + args.rval().set(UINT_TO_JSVAL((uint32_t)ret_val)); + return true; +} + +// Arguments: cpShape* +// Ret value: cpBool +bool JSB_cpShapeGetSensor(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpShapeGetSensor((cpShape*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpShape* +// Ret value: cpSpace* +bool JSB_cpShapeGetSpace(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpSpace* ret_val; + + ret_val = cpShapeGetSpace((cpShape*)arg0 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpShape* +// Ret value: cpVect +bool JSB_cpShapeGetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpShapeGetSurfaceVelocity((cpShape*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpShape*, cpVect +// Ret value: cpBool +bool JSB_cpShapePointQuery(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpShapePointQuery((cpShape*)arg0 , (cpVect)arg1 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpShape*, cpBody* +// Ret value: void +bool JSB_cpShapeSetBody(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; cpBody* arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpShapeSetBody((cpShape*)arg0 , (cpBody*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpShape*, cpCollisionType +// Ret value: void +bool JSB_cpShapeSetCollisionType(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; cpCollisionType arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_uint( cx, args.get(1), (unsigned int*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpShapeSetCollisionType((cpShape*)arg0 , (cpCollisionType)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpShape*, cpFloat +// Ret value: void +bool JSB_cpShapeSetElasticity(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpShapeSetElasticity((cpShape*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpShape*, cpFloat +// Ret value: void +bool JSB_cpShapeSetFriction(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpShapeSetFriction((cpShape*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpShape*, cpGroup +// Ret value: void +bool JSB_cpShapeSetGroup(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; cpGroup arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_uint( cx, args.get(1), (unsigned int*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpShapeSetGroup((cpShape*)arg0 , (cpGroup)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpShape*, cpLayers +// Ret value: void +bool JSB_cpShapeSetLayers(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; uint32_t arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpShapeSetLayers((cpShape*)arg0 , (cpLayers)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpShape*, cpBool +// Ret value: void +bool JSB_cpShapeSetSensor(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; int32_t arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpShapeSetSensor((cpShape*)arg0 , (cpBool)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpShape*, cpVect +// Ret value: void +bool JSB_cpShapeSetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpShapeSetSurfaceVelocity((cpShape*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpShape*, cpVect, cpVect +// Ret value: cpBB +bool JSB_cpShapeUpdate(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg0; cpVect arg1; cpVect arg2; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBB ret_val; + + ret_val = cpShapeUpdate((cpShape*)arg0 , (cpVect)arg1 , (cpVect)arg2 ); + + jsval ret_jsval = cpBB_to_jsval( cx, (cpBB)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpSimpleMotorGetRate(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpSimpleMotorGetRate((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBody*, cpBody*, cpFloat +// Ret value: cpConstraint* +bool JSB_cpSimpleMotorNew(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; double arg2; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpConstraint* ret_val; + + ret_val = cpSimpleMotorNew((cpBody*)arg0 , (cpBody*)arg1 , (cpFloat)arg2 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpSimpleMotorSetRate(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSimpleMotorSetRate((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpVect +bool JSB_cpSlideJointGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpSlideJointGetAnchr1((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpVect +bool JSB_cpSlideJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpSlideJointGetAnchr2((cpConstraint*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpSlideJointGetMax(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpSlideJointGetMax((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpFloat +bool JSB_cpSlideJointGetMin(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpSlideJointGetMin((cpConstraint*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBody*, cpBody*, cpVect, cpVect, cpFloat, cpFloat +// Ret value: cpConstraint* +bool JSB_cpSlideJointNew(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 6, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg0; cpBody* arg1; cpVect arg2; cpVect arg3; double arg4; double arg5; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &arg2 ); + ok &= jsval_to_cpVect( cx, args.get(3), (cpVect*) &arg3 ); + ok &= JS::ToNumber( cx, args.get(4), &arg4 ); + ok &= JS::ToNumber( cx, args.get(5), &arg5 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpConstraint* ret_val; + + ret_val = cpSlideJointNew((cpBody*)arg0 , (cpBody*)arg1 , (cpVect)arg2 , (cpVect)arg3 , (cpFloat)arg4 , (cpFloat)arg5 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpConstraint*, cpVect +// Ret value: void +bool JSB_cpSlideJointSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSlideJointSetAnchr1((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpVect +// Ret value: void +bool JSB_cpSlideJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSlideJointSetAnchr2((cpConstraint*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpSlideJointSetMax(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSlideJointSetMax((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint*, cpFloat +// Ret value: void +bool JSB_cpSlideJointSetMin(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSlideJointSetMin((cpConstraint*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace*, cpShape* +// Ret value: void +bool JSB_cpSpaceActivateShapesTouchingShape(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; cpShape* arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceActivateShapesTouchingShape((cpSpace*)arg0 , (cpShape*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace*, cpBody* +// Ret value: cpBody* +bool JSB_cpSpaceAddBody(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; cpBody* arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBody* ret_val; + + ret_val = cpSpaceAddBody((cpSpace*)arg0 , (cpBody*)arg1 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpSpace*, cpConstraint* +// Ret value: cpConstraint* +bool JSB_cpSpaceAddConstraint(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; cpConstraint* arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpConstraint* ret_val; + + ret_val = cpSpaceAddConstraint((cpSpace*)arg0 , (cpConstraint*)arg1 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpSpace*, cpShape* +// Ret value: cpShape* +bool JSB_cpSpaceAddShape(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; cpShape* arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpShape* ret_val; + + ret_val = cpSpaceAddShape((cpSpace*)arg0 , (cpShape*)arg1 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpSpace*, cpShape* +// Ret value: cpShape* +bool JSB_cpSpaceAddStaticShape(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; cpShape* arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpShape* ret_val; + + ret_val = cpSpaceAddStaticShape((cpSpace*)arg0 , (cpShape*)arg1 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpSpace*, cpBody* +// Ret value: cpBool +bool JSB_cpSpaceContainsBody(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; cpBody* arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpSpaceContainsBody((cpSpace*)arg0 , (cpBody*)arg1 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpSpace*, cpConstraint* +// Ret value: cpBool +bool JSB_cpSpaceContainsConstraint(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; cpConstraint* arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpSpaceContainsConstraint((cpSpace*)arg0 , (cpConstraint*)arg1 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpSpace*, cpShape* +// Ret value: cpBool +bool JSB_cpSpaceContainsShape(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; cpShape* arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpSpaceContainsShape((cpSpace*)arg0 , (cpShape*)arg1 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpSpace* +// Ret value: void +bool JSB_cpSpaceDestroy(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceDestroy((cpSpace*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace* +// Ret value: void +bool JSB_cpSpaceFree(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceFree((cpSpace*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace* +// Ret value: cpFloat +bool JSB_cpSpaceGetCollisionBias(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpSpaceGetCollisionBias((cpSpace*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpSpace* +// Ret value: cpTimestamp +bool JSB_cpSpaceGetCollisionPersistence(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpTimestamp ret_val; + + ret_val = cpSpaceGetCollisionPersistence((cpSpace*)arg0 ); + args.rval().set(UINT_TO_JSVAL((uint32_t)ret_val)); + return true; +} + +// Arguments: cpSpace* +// Ret value: cpFloat +bool JSB_cpSpaceGetCollisionSlop(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpSpaceGetCollisionSlop((cpSpace*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpSpace* +// Ret value: cpFloat +bool JSB_cpSpaceGetCurrentTimeStep(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpSpaceGetCurrentTimeStep((cpSpace*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpSpace* +// Ret value: cpFloat +bool JSB_cpSpaceGetDamping(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpSpaceGetDamping((cpSpace*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpSpace* +// Ret value: cpBool +bool JSB_cpSpaceGetEnableContactGraph(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpSpaceGetEnableContactGraph((cpSpace*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpSpace* +// Ret value: cpVect +bool JSB_cpSpaceGetGravity(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpSpaceGetGravity((cpSpace*)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpSpace* +// Ret value: cpFloat +bool JSB_cpSpaceGetIdleSpeedThreshold(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpSpaceGetIdleSpeedThreshold((cpSpace*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpSpace* +// Ret value: int +bool JSB_cpSpaceGetIterations(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + int ret_val; + + ret_val = cpSpaceGetIterations((cpSpace*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpSpace* +// Ret value: cpFloat +bool JSB_cpSpaceGetSleepTimeThreshold(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpSpaceGetSleepTimeThreshold((cpSpace*)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpSpace* +// Ret value: cpBody* +bool JSB_cpSpaceGetStaticBody(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBody* ret_val; + + ret_val = cpSpaceGetStaticBody((cpSpace*)arg0 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpSpace* +// Ret value: cpSpace* +bool JSB_cpSpaceInit(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpSpace* ret_val; + + ret_val = cpSpaceInit((cpSpace*)arg0 ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpSpace* +// Ret value: cpBool +bool JSB_cpSpaceIsLocked(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpSpaceIsLocked((cpSpace*)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: +// Ret value: cpSpace* +bool JSB_cpSpaceNew(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + cpSpace* ret_val; + + ret_val = cpSpaceNew( ); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpSpace*, cpVect, cpLayers, cpGroup +// Ret value: cpShape* +bool JSB_cpSpacePointQueryFirst(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; cpVect arg1; uint32_t arg2; cpGroup arg3; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + ok &= jsval_to_uint32( cx, args.get(2), &arg2 ); + ok &= jsval_to_uint( cx, args.get(3), (unsigned int*) &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpShape* ret_val; + + ret_val = cpSpacePointQueryFirst((cpSpace*)arg0 , (cpVect)arg1 , (cpLayers)arg2 , (cpGroup)arg3 ); + if(ret_val) { + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + } else { + args.rval().set(JSVAL_NULL); + } + + return true; +} + +// Arguments: cpSpace*, cpShape* +// Ret value: void +bool JSB_cpSpaceReindexShape(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; cpShape* arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceReindexShape((cpSpace*)arg0 , (cpShape*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace*, cpBody* +// Ret value: void +bool JSB_cpSpaceReindexShapesForBody(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; cpBody* arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceReindexShapesForBody((cpSpace*)arg0 , (cpBody*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace* +// Ret value: void +bool JSB_cpSpaceReindexStatic(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceReindexStatic((cpSpace*)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace*, cpBody* +// Ret value: void +bool JSB_cpSpaceRemoveBody(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; cpBody* arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceRemoveBody((cpSpace*)arg0 , (cpBody*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace*, cpConstraint* +// Ret value: void +bool JSB_cpSpaceRemoveConstraint(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; cpConstraint* arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceRemoveConstraint((cpSpace*)arg0 , (cpConstraint*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace*, cpShape* +// Ret value: void +bool JSB_cpSpaceRemoveShape(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; cpShape* arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceRemoveShape((cpSpace*)arg0 , (cpShape*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace*, cpShape* +// Ret value: void +bool JSB_cpSpaceRemoveStaticShape(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; cpShape* arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_opaque( cx, args.get(1), (void**)&arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceRemoveStaticShape((cpSpace*)arg0 , (cpShape*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace*, cpFloat +// Ret value: void +bool JSB_cpSpaceSetCollisionBias(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceSetCollisionBias((cpSpace*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace*, cpTimestamp +// Ret value: void +bool JSB_cpSpaceSetCollisionPersistence(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; uint32_t arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceSetCollisionPersistence((cpSpace*)arg0 , (cpTimestamp)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace*, cpFloat +// Ret value: void +bool JSB_cpSpaceSetCollisionSlop(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceSetCollisionSlop((cpSpace*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace*, cpFloat +// Ret value: void +bool JSB_cpSpaceSetDamping(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceSetDamping((cpSpace*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace*, cpBool +// Ret value: void +bool JSB_cpSpaceSetEnableContactGraph(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; int32_t arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceSetEnableContactGraph((cpSpace*)arg0 , (cpBool)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace*, cpVect +// Ret value: void +bool JSB_cpSpaceSetGravity(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; cpVect arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceSetGravity((cpSpace*)arg0 , (cpVect)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace*, cpFloat +// Ret value: void +bool JSB_cpSpaceSetIdleSpeedThreshold(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceSetIdleSpeedThreshold((cpSpace*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace*, int +// Ret value: void +bool JSB_cpSpaceSetIterations(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; int32_t arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceSetIterations((cpSpace*)arg0 , (int)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace*, cpFloat +// Ret value: void +bool JSB_cpSpaceSetSleepTimeThreshold(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceSetSleepTimeThreshold((cpSpace*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace*, cpFloat +// Ret value: void +bool JSB_cpSpaceStep(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; double arg1; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceStep((cpSpace*)arg0 , (cpFloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpSpace*, cpFloat, int +// Ret value: void +bool JSB_cpSpaceUseSpatialHash(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; double arg1; int32_t arg2; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSpaceUseSpatialHash((cpSpace*)arg0 , (cpFloat)arg1 , (int)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: cpFloat +// Ret value: cpFloat +bool JSB_cpfabs(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg0; + + ok &= JS::ToNumber( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpfabs((cpFloat)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpFloat, cpFloat, cpFloat +// Ret value: cpFloat +bool JSB_cpfclamp(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg0; double arg1; double arg2; + + ok &= JS::ToNumber( cx, args.get(0), &arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpfclamp((cpFloat)arg0 , (cpFloat)arg1 , (cpFloat)arg2 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpFloat +// Ret value: cpFloat +bool JSB_cpfclamp01(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg0; + + ok &= JS::ToNumber( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpfclamp01((cpFloat)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpFloat, cpFloat, cpFloat +// Ret value: cpFloat +bool JSB_cpflerp(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg0; double arg1; double arg2; + + ok &= JS::ToNumber( cx, args.get(0), &arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpflerp((cpFloat)arg0 , (cpFloat)arg1 , (cpFloat)arg2 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpFloat, cpFloat, cpFloat +// Ret value: cpFloat +bool JSB_cpflerpconst(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg0; double arg1; double arg2; + + ok &= JS::ToNumber( cx, args.get(0), &arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpflerpconst((cpFloat)arg0 , (cpFloat)arg1 , (cpFloat)arg2 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpFloat, cpFloat +// Ret value: cpFloat +bool JSB_cpfmax(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg0; double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpfmax((cpFloat)arg0 , (cpFloat)arg1 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpFloat, cpFloat +// Ret value: cpFloat +bool JSB_cpfmin(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg0; double arg1; + + ok &= JS::ToNumber( cx, args.get(0), &arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpfmin((cpFloat)arg0 , (cpFloat)arg1 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpVect, cpVect +// Ret value: cpVect +bool JSB_cpvadd(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpvadd((cpVect)arg0 , (cpVect)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect, cpFloat +// Ret value: cpVect +bool JSB_cpvclamp(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; double arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpvclamp((cpVect)arg0 , (cpFloat)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect, cpVect +// Ret value: cpFloat +bool JSB_cpvcross(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpvcross((cpVect)arg0 , (cpVect)arg1 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpVect, cpVect +// Ret value: cpFloat +bool JSB_cpvdist(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpvdist((cpVect)arg0 , (cpVect)arg1 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpVect, cpVect +// Ret value: cpFloat +bool JSB_cpvdistsq(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpvdistsq((cpVect)arg0 , (cpVect)arg1 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpVect, cpVect +// Ret value: cpFloat +bool JSB_cpvdot(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpvdot((cpVect)arg0 , (cpVect)arg1 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpVect, cpVect +// Ret value: cpBool +bool JSB_cpveql(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpveql((cpVect)arg0 , (cpVect)arg1 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpFloat +// Ret value: cpVect +bool JSB_cpvforangle(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double arg0; + + ok &= JS::ToNumber( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpvforangle((cpFloat)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect +// Ret value: cpFloat +bool JSB_cpvlength(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpvlength((cpVect)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpVect +// Ret value: cpFloat +bool JSB_cpvlengthsq(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpvlengthsq((cpVect)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpVect, cpVect, cpFloat +// Ret value: cpVect +bool JSB_cpvlerp(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; cpVect arg1; double arg2; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpvlerp((cpVect)arg0 , (cpVect)arg1 , (cpFloat)arg2 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect, cpVect, cpFloat +// Ret value: cpVect +bool JSB_cpvlerpconst(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; cpVect arg1; double arg2; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpvlerpconst((cpVect)arg0 , (cpVect)arg1 , (cpFloat)arg2 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect, cpFloat +// Ret value: cpVect +bool JSB_cpvmult(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; double arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + ok &= JS::ToNumber( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpvmult((cpVect)arg0 , (cpFloat)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect, cpVect, cpFloat +// Ret value: cpBool +bool JSB_cpvnear(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; cpVect arg1; double arg2; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpBool ret_val; + + ret_val = cpvnear((cpVect)arg0 , (cpVect)arg1 , (cpFloat)arg2 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: cpVect +// Ret value: cpVect +bool JSB_cpvneg(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpvneg((cpVect)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect +// Ret value: cpVect +bool JSB_cpvnormalize(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpvnormalize((cpVect)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect +// Ret value: cpVect +bool JSB_cpvnormalize_safe(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpvnormalize_safe((cpVect)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect +// Ret value: cpVect +bool JSB_cpvperp(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpvperp((cpVect)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect, cpVect +// Ret value: cpVect +bool JSB_cpvproject(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpvproject((cpVect)arg0 , (cpVect)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect, cpVect +// Ret value: cpVect +bool JSB_cpvrotate(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpvrotate((cpVect)arg0 , (cpVect)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect +// Ret value: cpVect +bool JSB_cpvrperp(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpvrperp((cpVect)arg0 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect, cpVect, cpFloat +// Ret value: cpVect +bool JSB_cpvslerp(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; cpVect arg1; double arg2; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpvslerp((cpVect)arg0 , (cpVect)arg1 , (cpFloat)arg2 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect, cpVect, cpFloat +// Ret value: cpVect +bool JSB_cpvslerpconst(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; cpVect arg1; double arg2; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + ok &= JS::ToNumber( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpvslerpconst((cpVect)arg0 , (cpVect)arg1 , (cpFloat)arg2 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect, cpVect +// Ret value: cpVect +bool JSB_cpvsub(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpvsub((cpVect)arg0 , (cpVect)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: cpVect +// Ret value: cpFloat +bool JSB_cpvtoangle(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpFloat ret_val; + + ret_val = cpvtoangle((cpVect)arg0 ); + args.rval().set(DOUBLE_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpVect, cpVect +// Ret value: cpVect +bool JSB_cpvunrotate(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect arg0; cpVect arg1; + + ok &= jsval_to_cpVect( cx, args.get(0), (cpVect*) &arg0 ); + ok &= jsval_to_cpVect( cx, args.get(1), (cpVect*) &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cpVect ret_val; + + ret_val = cpvunrotate((cpVect)arg0 , (cpVect)arg1 ); + + jsval ret_jsval = cpVect_to_jsval( cx, (cpVect)ret_val ); + args.rval().set(ret_jsval); + + return true; +} + + +#endif // JSB_INCLUDE_CHIPMUNK diff --git a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_functions.h b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_functions.h new file mode 100644 index 0000000000..e9dc4f87d9 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_functions.h @@ -0,0 +1,292 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-11-07 +* Script version: v0.3 +*/ +#include "js_bindings_config.h" +#ifdef JSB_INCLUDE_CHIPMUNK +#include "js_bindings_chipmunk_manual.h" + +#ifdef __cplusplus +extern "C" { +#endif +bool JSB_cpArbiterGetCount(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpArbiterGetDepth(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpArbiterGetElasticity(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpArbiterGetFriction(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpArbiterGetNormal(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpArbiterGetPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpArbiterGetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpArbiterIgnore(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpArbiterIsFirstContact(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpArbiterSetElasticity(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpArbiterSetFriction(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpArbiterSetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpArbiterTotalImpulse(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpArbiterTotalImpulseWithFriction(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpArbiterTotalKE(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpAreaForCircle(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpAreaForSegment(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBBArea(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBBClampVect(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBBContainsBB(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBBContainsVect(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBBExpand(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBBIntersects(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBBIntersectsSegment(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBBMerge(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBBMergedArea(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBBNew(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBBNewForCircle(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBBSegmentQuery(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBBWrapVect(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyActivate(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyActivateStatic(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyApplyForce(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyApplyImpulse(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyDestroy(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyFree(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyGetAngVel(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyGetAngVelLimit(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyGetAngle(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyGetForce(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyGetMass(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyGetMoment(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyGetPos(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyGetRot(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyGetSpace(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyGetTorque(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyGetVel(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyGetVelAtLocalPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyGetVelAtWorldPoint(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyGetVelLimit(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyInit(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyInitStatic(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyIsRogue(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyIsSleeping(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyIsStatic(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyKineticEnergy(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyLocal2World(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyNew(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyNewStatic(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyResetForces(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodySetAngVel(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodySetAngVelLimit(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodySetAngle(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodySetForce(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodySetMass(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodySetMoment(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodySetPos(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodySetTorque(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodySetVel(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodySetVelLimit(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodySleep(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodySleepWithGroup(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyUpdatePosition(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyUpdateVelocity(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodyWorld2Local(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBoxShapeNew(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBoxShapeNew2(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpCircleShapeGetOffset(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpCircleShapeGetRadius(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpCircleShapeNew(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpConstraintActivateBodies(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpConstraintDestroy(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpConstraintFree(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpConstraintGetA(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpConstraintGetB(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpConstraintGetErrorBias(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpConstraintGetImpulse(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpConstraintGetMaxBias(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpConstraintGetMaxForce(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpConstraintGetSpace(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpConstraintSetErrorBias(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpConstraintSetMaxBias(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpConstraintSetMaxForce(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpDampedRotarySpringGetDamping(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpDampedRotarySpringGetRestAngle(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpDampedRotarySpringGetStiffness(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpDampedRotarySpringNew(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpDampedRotarySpringSetDamping(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpDampedRotarySpringSetRestAngle(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpDampedRotarySpringSetStiffness(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpDampedSpringGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpDampedSpringGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpDampedSpringGetDamping(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpDampedSpringGetRestLength(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpDampedSpringGetStiffness(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpDampedSpringNew(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpDampedSpringSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpDampedSpringSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpDampedSpringSetDamping(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpDampedSpringSetRestLength(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpDampedSpringSetStiffness(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpGearJointGetPhase(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpGearJointGetRatio(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpGearJointNew(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpGearJointSetPhase(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpGearJointSetRatio(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpGrooveJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpGrooveJointGetGrooveA(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpGrooveJointGetGrooveB(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpGrooveJointNew(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpGrooveJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpGrooveJointSetGrooveA(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpGrooveJointSetGrooveB(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpInitChipmunk(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpMomentForBox(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpMomentForBox2(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpMomentForCircle(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpMomentForSegment(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpPinJointGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpPinJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpPinJointGetDist(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpPinJointNew(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpPinJointSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpPinJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpPinJointSetDist(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpPivotJointGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpPivotJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpPivotJointNew(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpPivotJointNew2(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpPivotJointSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpPivotJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpPolyShapeGetNumVerts(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpPolyShapeGetVert(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpRatchetJointGetAngle(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpRatchetJointGetPhase(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpRatchetJointGetRatchet(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpRatchetJointNew(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpRatchetJointSetAngle(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpRatchetJointSetPhase(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpRatchetJointSetRatchet(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpResetShapeIdCounter(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpRotaryLimitJointGetMax(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpRotaryLimitJointGetMin(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpRotaryLimitJointNew(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpRotaryLimitJointSetMax(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpRotaryLimitJointSetMin(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSegmentShapeGetA(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSegmentShapeGetB(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSegmentShapeGetNormal(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSegmentShapeGetRadius(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSegmentShapeNew(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSegmentShapeSetNeighbors(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeCacheBB(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeDestroy(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeFree(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeGetBB(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeGetBody(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeGetCollisionType(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeGetElasticity(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeGetFriction(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeGetGroup(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeGetLayers(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeGetSensor(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeGetSpace(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeGetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapePointQuery(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeSetBody(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeSetCollisionType(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeSetElasticity(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeSetFriction(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeSetGroup(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeSetLayers(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeSetSensor(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeSetSurfaceVelocity(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpShapeUpdate(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSimpleMotorGetRate(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSimpleMotorNew(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSimpleMotorSetRate(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSlideJointGetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSlideJointGetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSlideJointGetMax(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSlideJointGetMin(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSlideJointNew(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSlideJointSetAnchr1(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSlideJointSetAnchr2(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSlideJointSetMax(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSlideJointSetMin(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceActivateShapesTouchingShape(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceAddBody(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceAddConstraint(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceAddShape(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceAddStaticShape(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceContainsBody(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceContainsConstraint(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceContainsShape(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceDestroy(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceFree(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceGetCollisionBias(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceGetCollisionPersistence(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceGetCollisionSlop(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceGetCurrentTimeStep(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceGetDamping(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceGetEnableContactGraph(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceGetGravity(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceGetIdleSpeedThreshold(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceGetIterations(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceGetSleepTimeThreshold(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceGetStaticBody(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceInit(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceIsLocked(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceNew(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpacePointQueryFirst(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceReindexShape(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceReindexShapesForBody(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceReindexStatic(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceRemoveBody(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceRemoveConstraint(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceRemoveShape(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceRemoveStaticShape(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceSetCollisionBias(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceSetCollisionPersistence(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceSetCollisionSlop(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceSetDamping(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceSetEnableContactGraph(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceSetGravity(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceSetIdleSpeedThreshold(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceSetIterations(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceSetSleepTimeThreshold(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceStep(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceUseSpatialHash(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpfabs(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpfclamp(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpfclamp01(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpflerp(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpflerpconst(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpfmax(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpfmin(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvadd(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvclamp(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvcross(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvdist(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvdistsq(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvdot(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpveql(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvforangle(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvlength(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvlengthsq(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvlerp(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvlerpconst(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvmult(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvnear(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvneg(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvnormalize(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvnormalize_safe(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvperp(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvproject(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvrotate(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvrperp(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvslerp(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvslerpconst(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvsub(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvtoangle(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpvunrotate(JSContext *cx, uint32_t argc, jsval *vp); + +#ifdef __cplusplus +} +#endif + + +#endif // JSB_INCLUDE_CHIPMUNK diff --git a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_functions_registration.h b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_functions_registration.h new file mode 100644 index 0000000000..835575c3d0 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_functions_registration.h @@ -0,0 +1,285 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_js_bindings.py -c chipmunk_jsb.ini" on 2012-10-18 +* Script version: v0.3 +*/ +#include "js_bindings_config.h" +#ifdef JSB_INCLUDE_CHIPMUNK + +#include "js_bindings_chipmunk_manual.h" +JS_DefineFunction(cx, chipmunk, "arbiterGetCount", JSB_cpArbiterGetCount, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "arbiterGetDepth", JSB_cpArbiterGetDepth, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "arbiterGetElasticity", JSB_cpArbiterGetElasticity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "arbiterGetFriction", JSB_cpArbiterGetFriction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "arbiterGetNormal", JSB_cpArbiterGetNormal, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "arbiterGetPoint", JSB_cpArbiterGetPoint, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "arbiterGetSurfaceVelocity", JSB_cpArbiterGetSurfaceVelocity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "arbiterIgnore", JSB_cpArbiterIgnore, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "arbiterIsFirstContact", JSB_cpArbiterIsFirstContact, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "arbiterSetElasticity", JSB_cpArbiterSetElasticity, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "arbiterSetFriction", JSB_cpArbiterSetFriction, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "arbiterSetSurfaceVelocity", JSB_cpArbiterSetSurfaceVelocity, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "arbiterTotalImpulse", JSB_cpArbiterTotalImpulse, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "arbiterTotalImpulseWithFriction", JSB_cpArbiterTotalImpulseWithFriction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "arbiterTotalKE", JSB_cpArbiterTotalKE, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "areaForCircle", JSB_cpAreaForCircle, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "areaForSegment", JSB_cpAreaForSegment, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bBArea", JSB_cpBBArea, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bBClampVect", JSB_cpBBClampVect, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bBContainsBB", JSB_cpBBContainsBB, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bBContainsVect", JSB_cpBBContainsVect, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bBExpand", JSB_cpBBExpand, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bBIntersects", JSB_cpBBIntersects, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bBIntersectsSegment", JSB_cpBBIntersectsSegment, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bBMerge", JSB_cpBBMerge, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bBMergedArea", JSB_cpBBMergedArea, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bBNew", JSB_cpBBNew, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bBNewForCircle", JSB_cpBBNewForCircle, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bBSegmentQuery", JSB_cpBBSegmentQuery, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bBWrapVect", JSB_cpBBWrapVect, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyActivate", JSB_cpBodyActivate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyActivateStatic", JSB_cpBodyActivateStatic, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyApplyForce", JSB_cpBodyApplyForce, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyApplyImpulse", JSB_cpBodyApplyImpulse, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyDestroy", JSB_cpBodyDestroy, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyFree", JSB_cpBodyFree, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyGetAngVel", JSB_cpBodyGetAngVel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyGetAngVelLimit", JSB_cpBodyGetAngVelLimit, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyGetAngle", JSB_cpBodyGetAngle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyGetForce", JSB_cpBodyGetForce, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyGetMass", JSB_cpBodyGetMass, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyGetMoment", JSB_cpBodyGetMoment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyGetPos", JSB_cpBodyGetPos, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyGetRot", JSB_cpBodyGetRot, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyGetSpace", JSB_cpBodyGetSpace, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyGetTorque", JSB_cpBodyGetTorque, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyGetVel", JSB_cpBodyGetVel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyGetVelAtLocalPoint", JSB_cpBodyGetVelAtLocalPoint, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyGetVelAtWorldPoint", JSB_cpBodyGetVelAtWorldPoint, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyGetVelLimit", JSB_cpBodyGetVelLimit, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyInit", JSB_cpBodyInit, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyInitStatic", JSB_cpBodyInitStatic, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyIsRogue", JSB_cpBodyIsRogue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyIsSleeping", JSB_cpBodyIsSleeping, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyIsStatic", JSB_cpBodyIsStatic, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyKineticEnergy", JSB_cpBodyKineticEnergy, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyLocal2World", JSB_cpBodyLocal2World, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyNew", JSB_cpBodyNew, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyNewStatic", JSB_cpBodyNewStatic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyResetForces", JSB_cpBodyResetForces, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodySetAngVel", JSB_cpBodySetAngVel, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodySetAngVelLimit", JSB_cpBodySetAngVelLimit, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodySetAngle", JSB_cpBodySetAngle, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodySetForce", JSB_cpBodySetForce, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodySetMass", JSB_cpBodySetMass, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodySetMoment", JSB_cpBodySetMoment, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodySetPos", JSB_cpBodySetPos, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodySetTorque", JSB_cpBodySetTorque, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodySetVel", JSB_cpBodySetVel, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodySetVelLimit", JSB_cpBodySetVelLimit, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodySleep", JSB_cpBodySleep, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodySleepWithGroup", JSB_cpBodySleepWithGroup, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyUpdatePosition", JSB_cpBodyUpdatePosition, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyUpdateVelocity", JSB_cpBodyUpdateVelocity, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "bodyWorld2Local", JSB_cpBodyWorld2Local, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "boxShapeNew", JSB_cpBoxShapeNew, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "boxShapeNew2", JSB_cpBoxShapeNew2, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "circleShapeGetOffset", JSB_cpCircleShapeGetOffset, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "circleShapeGetRadius", JSB_cpCircleShapeGetRadius, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "circleShapeNew", JSB_cpCircleShapeNew, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "constraintActivateBodies", JSB_cpConstraintActivateBodies, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "constraintDestroy", JSB_cpConstraintDestroy, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "constraintFree", JSB_cpConstraintFree, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "constraintGetA", JSB_cpConstraintGetA, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "constraintGetB", JSB_cpConstraintGetB, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "constraintGetErrorBias", JSB_cpConstraintGetErrorBias, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "constraintGetImpulse", JSB_cpConstraintGetImpulse, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "constraintGetMaxBias", JSB_cpConstraintGetMaxBias, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "constraintGetMaxForce", JSB_cpConstraintGetMaxForce, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "constraintGetSpace", JSB_cpConstraintGetSpace, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "constraintSetErrorBias", JSB_cpConstraintSetErrorBias, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "constraintSetMaxBias", JSB_cpConstraintSetMaxBias, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "constraintSetMaxForce", JSB_cpConstraintSetMaxForce, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "dampedRotarySpringGetDamping", JSB_cpDampedRotarySpringGetDamping, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "dampedRotarySpringGetRestAngle", JSB_cpDampedRotarySpringGetRestAngle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "dampedRotarySpringGetStiffness", JSB_cpDampedRotarySpringGetStiffness, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "dampedRotarySpringNew", JSB_cpDampedRotarySpringNew, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "dampedRotarySpringSetDamping", JSB_cpDampedRotarySpringSetDamping, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "dampedRotarySpringSetRestAngle", JSB_cpDampedRotarySpringSetRestAngle, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "dampedRotarySpringSetStiffness", JSB_cpDampedRotarySpringSetStiffness, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "dampedSpringGetAnchr1", JSB_cpDampedSpringGetAnchr1, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "dampedSpringGetAnchr2", JSB_cpDampedSpringGetAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "dampedSpringGetDamping", JSB_cpDampedSpringGetDamping, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "dampedSpringGetRestLength", JSB_cpDampedSpringGetRestLength, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "dampedSpringGetStiffness", JSB_cpDampedSpringGetStiffness, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "dampedSpringNew", JSB_cpDampedSpringNew, 7, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "dampedSpringSetAnchr1", JSB_cpDampedSpringSetAnchr1, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "dampedSpringSetAnchr2", JSB_cpDampedSpringSetAnchr2, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "dampedSpringSetDamping", JSB_cpDampedSpringSetDamping, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "dampedSpringSetRestLength", JSB_cpDampedSpringSetRestLength, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "dampedSpringSetStiffness", JSB_cpDampedSpringSetStiffness, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "gearJointGetPhase", JSB_cpGearJointGetPhase, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "gearJointGetRatio", JSB_cpGearJointGetRatio, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "gearJointNew", JSB_cpGearJointNew, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "gearJointSetPhase", JSB_cpGearJointSetPhase, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "gearJointSetRatio", JSB_cpGearJointSetRatio, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "grooveJointGetAnchr2", JSB_cpGrooveJointGetAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "grooveJointGetGrooveA", JSB_cpGrooveJointGetGrooveA, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "grooveJointGetGrooveB", JSB_cpGrooveJointGetGrooveB, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "grooveJointNew", JSB_cpGrooveJointNew, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "grooveJointSetAnchr2", JSB_cpGrooveJointSetAnchr2, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "grooveJointSetGrooveA", JSB_cpGrooveJointSetGrooveA, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "grooveJointSetGrooveB", JSB_cpGrooveJointSetGrooveB, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "initChipmunk", JSB_cpInitChipmunk, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "momentForBox", JSB_cpMomentForBox, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "momentForBox2", JSB_cpMomentForBox2, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "momentForCircle", JSB_cpMomentForCircle, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "momentForSegment", JSB_cpMomentForSegment, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "pinJointGetAnchr1", JSB_cpPinJointGetAnchr1, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "pinJointGetAnchr2", JSB_cpPinJointGetAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "pinJointGetDist", JSB_cpPinJointGetDist, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "pinJointNew", JSB_cpPinJointNew, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "pinJointSetAnchr1", JSB_cpPinJointSetAnchr1, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "pinJointSetAnchr2", JSB_cpPinJointSetAnchr2, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "pinJointSetDist", JSB_cpPinJointSetDist, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "pivotJointGetAnchr1", JSB_cpPivotJointGetAnchr1, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "pivotJointGetAnchr2", JSB_cpPivotJointGetAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "pivotJointNew", JSB_cpPivotJointNew, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "pivotJointNew2", JSB_cpPivotJointNew2, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "pivotJointSetAnchr1", JSB_cpPivotJointSetAnchr1, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "pivotJointSetAnchr2", JSB_cpPivotJointSetAnchr2, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "polyShapeGetNumVerts", JSB_cpPolyShapeGetNumVerts, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "polyShapeGetVert", JSB_cpPolyShapeGetVert, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "ratchetJointGetAngle", JSB_cpRatchetJointGetAngle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "ratchetJointGetPhase", JSB_cpRatchetJointGetPhase, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "ratchetJointGetRatchet", JSB_cpRatchetJointGetRatchet, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "ratchetJointNew", JSB_cpRatchetJointNew, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "ratchetJointSetAngle", JSB_cpRatchetJointSetAngle, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "ratchetJointSetPhase", JSB_cpRatchetJointSetPhase, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "ratchetJointSetRatchet", JSB_cpRatchetJointSetRatchet, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "resetShapeIdCounter", JSB_cpResetShapeIdCounter, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "rotaryLimitJointGetMax", JSB_cpRotaryLimitJointGetMax, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "rotaryLimitJointGetMin", JSB_cpRotaryLimitJointGetMin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "rotaryLimitJointNew", JSB_cpRotaryLimitJointNew, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "rotaryLimitJointSetMax", JSB_cpRotaryLimitJointSetMax, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "rotaryLimitJointSetMin", JSB_cpRotaryLimitJointSetMin, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "segmentShapeGetA", JSB_cpSegmentShapeGetA, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "segmentShapeGetB", JSB_cpSegmentShapeGetB, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "segmentShapeGetNormal", JSB_cpSegmentShapeGetNormal, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "segmentShapeGetRadius", JSB_cpSegmentShapeGetRadius, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "segmentShapeNew", JSB_cpSegmentShapeNew, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "segmentShapeSetNeighbors", JSB_cpSegmentShapeSetNeighbors, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeCacheBB", JSB_cpShapeCacheBB, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeDestroy", JSB_cpShapeDestroy, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeFree", JSB_cpShapeFree, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeGetBB", JSB_cpShapeGetBB, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeGetBody", JSB_cpShapeGetBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeGetCollisionType", JSB_cpShapeGetCollisionType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeGetElasticity", JSB_cpShapeGetElasticity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeGetFriction", JSB_cpShapeGetFriction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeGetGroup", JSB_cpShapeGetGroup, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeGetLayers", JSB_cpShapeGetLayers, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeGetSensor", JSB_cpShapeGetSensor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeGetSpace", JSB_cpShapeGetSpace, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeGetSurfaceVelocity", JSB_cpShapeGetSurfaceVelocity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapePointQuery", JSB_cpShapePointQuery, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeSetBody", JSB_cpShapeSetBody, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeSetCollisionType", JSB_cpShapeSetCollisionType, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeSetElasticity", JSB_cpShapeSetElasticity, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeSetFriction", JSB_cpShapeSetFriction, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeSetGroup", JSB_cpShapeSetGroup, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeSetLayers", JSB_cpShapeSetLayers, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeSetSensor", JSB_cpShapeSetSensor, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeSetSurfaceVelocity", JSB_cpShapeSetSurfaceVelocity, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "shapeUpdate", JSB_cpShapeUpdate, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "simpleMotorGetRate", JSB_cpSimpleMotorGetRate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "simpleMotorNew", JSB_cpSimpleMotorNew, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "simpleMotorSetRate", JSB_cpSimpleMotorSetRate, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "slideJointGetAnchr1", JSB_cpSlideJointGetAnchr1, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "slideJointGetAnchr2", JSB_cpSlideJointGetAnchr2, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "slideJointGetMax", JSB_cpSlideJointGetMax, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "slideJointGetMin", JSB_cpSlideJointGetMin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "slideJointNew", JSB_cpSlideJointNew, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "slideJointSetAnchr1", JSB_cpSlideJointSetAnchr1, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "slideJointSetAnchr2", JSB_cpSlideJointSetAnchr2, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "slideJointSetMax", JSB_cpSlideJointSetMax, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "slideJointSetMin", JSB_cpSlideJointSetMin, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceActivateShapesTouchingShape", JSB_cpSpaceActivateShapesTouchingShape, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceAddBody", JSB_cpSpaceAddBody, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceAddConstraint", JSB_cpSpaceAddConstraint, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceAddShape", JSB_cpSpaceAddShape, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceAddStaticShape", JSB_cpSpaceAddStaticShape, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceContainsBody", JSB_cpSpaceContainsBody, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceContainsConstraint", JSB_cpSpaceContainsConstraint, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceContainsShape", JSB_cpSpaceContainsShape, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceDestroy", JSB_cpSpaceDestroy, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceFree", JSB_cpSpaceFree, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceGetCollisionBias", JSB_cpSpaceGetCollisionBias, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceGetCollisionPersistence", JSB_cpSpaceGetCollisionPersistence, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceGetCollisionSlop", JSB_cpSpaceGetCollisionSlop, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceGetCurrentTimeStep", JSB_cpSpaceGetCurrentTimeStep, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceGetDamping", JSB_cpSpaceGetDamping, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceGetEnableContactGraph", JSB_cpSpaceGetEnableContactGraph, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceGetGravity", JSB_cpSpaceGetGravity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceGetIdleSpeedThreshold", JSB_cpSpaceGetIdleSpeedThreshold, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceGetIterations", JSB_cpSpaceGetIterations, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceGetSleepTimeThreshold", JSB_cpSpaceGetSleepTimeThreshold, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceGetStaticBody", JSB_cpSpaceGetStaticBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceInit", JSB_cpSpaceInit, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceIsLocked", JSB_cpSpaceIsLocked, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceNew", JSB_cpSpaceNew, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spacePointQueryFirst", JSB_cpSpacePointQueryFirst, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceReindexShape", JSB_cpSpaceReindexShape, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceReindexShapesForBody", JSB_cpSpaceReindexShapesForBody, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceReindexStatic", JSB_cpSpaceReindexStatic, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceRemoveBody", JSB_cpSpaceRemoveBody, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceRemoveConstraint", JSB_cpSpaceRemoveConstraint, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceRemoveShape", JSB_cpSpaceRemoveShape, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceRemoveStaticShape", JSB_cpSpaceRemoveStaticShape, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceSetCollisionBias", JSB_cpSpaceSetCollisionBias, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceSetCollisionPersistence", JSB_cpSpaceSetCollisionPersistence, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceSetCollisionSlop", JSB_cpSpaceSetCollisionSlop, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceSetDamping", JSB_cpSpaceSetDamping, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceSetEnableContactGraph", JSB_cpSpaceSetEnableContactGraph, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceSetGravity", JSB_cpSpaceSetGravity, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceSetIdleSpeedThreshold", JSB_cpSpaceSetIdleSpeedThreshold, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceSetIterations", JSB_cpSpaceSetIterations, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceSetSleepTimeThreshold", JSB_cpSpaceSetSleepTimeThreshold, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceStep", JSB_cpSpaceStep, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "spaceUseSpatialHash", JSB_cpSpaceUseSpatialHash, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "fabs", JSB_cpfabs, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "fclamp", JSB_cpfclamp, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "fclamp01", JSB_cpfclamp01, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "flerp", JSB_cpflerp, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "flerpconst", JSB_cpflerpconst, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "fmax", JSB_cpfmax, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "fmin", JSB_cpfmin, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vadd", JSB_cpvadd, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vclamp", JSB_cpvclamp, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vcross", JSB_cpvcross, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vdist", JSB_cpvdist, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vdistsq", JSB_cpvdistsq, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vdot", JSB_cpvdot, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "veql", JSB_cpveql, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vforangle", JSB_cpvforangle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vlength", JSB_cpvlength, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vlengthsq", JSB_cpvlengthsq, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vlerp", JSB_cpvlerp, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vlerpconst", JSB_cpvlerpconst, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vmult", JSB_cpvmult, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vnear", JSB_cpvnear, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vneg", JSB_cpvneg, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vnormalize", JSB_cpvnormalize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vnormalize_safe", JSB_cpvnormalize_safe, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vperp", JSB_cpvperp, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vproject", JSB_cpvproject, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vrotate", JSB_cpvrotate, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vrperp", JSB_cpvrperp, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vslerp", JSB_cpvslerp, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vslerpconst", JSB_cpvslerpconst, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vsub", JSB_cpvsub, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vtoangle", JSB_cpvtoangle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(cx, chipmunk, "vunrotate", JSB_cpvunrotate, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); + + +#endif // JSB_INCLUDE_CHIPMUNK diff --git a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp new file mode 100644 index 0000000000..52d64d8179 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp @@ -0,0 +1,2359 @@ +/* + * Copyright (c) 2012 Zynga Inc. + * 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. + */ + +#include "jsapi.h" +#include "jsfriendapi.h" +#include "extensions/cocos-ext.h" +#include "js_bindings_config.h" +#include "cocos2d_specifics.hpp" +#ifdef JSB_INCLUDE_CHIPMUNK + +#include "js_bindings_chipmunk_manual.h" +#include "js_manual_conversions.h" + +USING_NS_CC_EXT; +// Function declarations +void static freeSpaceChildren(cpSpace *space); + +template +static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { + TypeTest t; + T* cobj = new T(); + cobj->autorelease(); + js_type_class_t *p; + 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!"); + p = typeMapIter->second; + CCASSERT(p, "The value is null."); + + JSObject *_tmp = JS_NewObject(cx, p->jsclass, JS::RootedObject(cx, p->proto), JS::RootedObject(cx, p->parentProto)); + js_proxy_t *pp = jsb_new_proxy(cobj, _tmp); + JS::AddObjectRoot(cx, &pp->obj); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().set(OBJECT_TO_JSVAL(_tmp)); + + return true; +} + +#pragma mark - convertions + +/* + * PhysicsSprite + */ +#pragma mark - PhysicsSprite + +JSClass* JSPROXY_CCPhysicsSprite_class = NULL; +JSObject* JSPROXY_CCPhysicsSprite_object = NULL; +// Constructor + +// Destructor +void JSPROXY_CCPhysicsSprite_finalize(JSFreeOp *fop, JSObject *obj) +{ + CCLOGINFO("jsbindings: finalizing JS object %p (PhysicsSprite)", obj); +} + +// Arguments: +// Ret value: BOOL (b) +bool JSPROXY_CCPhysicsSprite_isDirty(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, real) + + if (real->isDirty()) { + args.rval().set(JSVAL_TRUE); + } + else args.rval().set(JSVAL_FALSE); + return true; +} + +// Arguments: +// Ret value: cpBody* (N/A) +bool JSPROXY_CCPhysicsSprite_getCPBody(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, real) + cpBody* ret_val; + + ret_val = real->getCPBody(); + jsval ret_jsval = c_class_to_jsval( cx, ret_val, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpBody" ); + args.rval().set(ret_jsval); + + return true; +} + +// Arguments: +// Ret value: BOOL (b) +bool JSPROXY_CCPhysicsSprite_ignoreBodyRotation(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, real) + + bool ret_val; + + ret_val = real->isIgnoreBodyRotation(); + args.rval().set(BOOLEAN_TO_JSVAL(ret_val)); + return true; +} + +// Arguments: cpBody* +// Ret value: void (None) +bool JSPROXY_CCPhysicsSprite_setCPBody_(JSContext *cx, uint32_t argc, jsval *vp) { + + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, real) + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + cpBody* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + if( ! ok ) return false; + + real->setCPBody((cpBody*)arg0); + args.rval().setUndefined(); + return true; +} + +// Arguments: BOOL +// Ret value: void (None) +bool JSPROXY_CCPhysicsSprite_setIgnoreBodyRotation_(JSContext *cx, uint32_t argc, jsval *vp) { + + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + PhysicsSprite* real = (PhysicsSprite *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, real) + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool arg0 = JS::ToBoolean( args.get(0) ); + + real->setIgnoreBodyRotation((bool)arg0); + args.rval().setUndefined(); + return true; +} + +/* + * PhysicsDebugNode + */ +//#pragma mark - PhysicsDebugNode + +JSClass* JSB_CCPhysicsDebugNode_class = NULL; +JSObject* JSB_CCPhysicsDebugNode_object = NULL; +extern JSObject *js_cocos2dx_CCDrawNode_prototype; + +// Constructor + +// Destructor +void JSB_CCPhysicsDebugNode_finalize(JSFreeOp *fop, JSObject *obj) +{ + CCLOGINFO("jsbindings: finalizing JS object %p (PhysicsDebugNode)", obj); +} + +// Arguments: cpSpace* +// Ret value: PhysicsDebugNode* (o) +bool JSB_CCPhysicsDebugNode_debugNodeForCPSpace__static(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + PhysicsDebugNode* ret = PhysicsDebugNode::create(arg0); + jsval jsret; + do { + if (ret) { + 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, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto)); + jsret = OBJECT_TO_JSVAL(obj); + js_proxy_t *p = jsb_new_proxy(ret, obj); + JS::AddNamedObjectRoot(cx, &p->obj, "CCDebugNode"); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + + return true; +} + +// Arguments: cpSpace* +// Ret value: void (None) +bool JSB_CCPhysicsDebugNode_setSpace_(JSContext *cx, uint32_t argc, jsval *vp) { + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(jsthis); + PhysicsDebugNode* real = (PhysicsDebugNode *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, real) + + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpSpace* arg0; + + ok &= jsval_to_opaque( cx, args.get(0), (void**)&arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + real->setSpace(arg0); + args.rval().setUndefined(); + return true; +} + +// Arguments: +// Ret value: cpSpace* (N/A) +bool JSB_CCPhysicsDebugNode_space(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(jsthis); + PhysicsDebugNode* real = (PhysicsDebugNode *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, real) + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + cpSpace* ret_val; + + ret_val = real->getSpace(); + + jsval ret_jsval = opaque_to_jsval( cx, ret_val ); + args.rval().set(ret_jsval); + + return true; +} + +bool JSB_CCPhysicsDebugNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + PhysicsDebugNode* cobj = new (std::nothrow) PhysicsDebugNode(); + 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."); + //JS::RootedObject obj(cx, JS_NewObjectForConstructor(cx, typeClass->jsclass, args)); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto))); + args.rval().set(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, "PhysicsDebugNode"); + if (JS_HasProperty(cx, obj, "_ctor", &ok)) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + +void JSB_CCPhysicsDebugNode_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_CCPhysicsDebugNode_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_CCPhysicsDebugNode_class->name = name; + JSB_CCPhysicsDebugNode_class->addProperty = JS_PropertyStub; + JSB_CCPhysicsDebugNode_class->delProperty = JS_DeletePropertyStub; + JSB_CCPhysicsDebugNode_class->getProperty = JS_PropertyStub; + JSB_CCPhysicsDebugNode_class->setProperty = JS_StrictPropertyStub; + JSB_CCPhysicsDebugNode_class->enumerate = JS_EnumerateStub; + JSB_CCPhysicsDebugNode_class->resolve = JS_ResolveStub; + JSB_CCPhysicsDebugNode_class->convert = JS_ConvertStub; + JSB_CCPhysicsDebugNode_class->finalize = JSB_CCPhysicsDebugNode_finalize; + JSB_CCPhysicsDebugNode_class->flags = 0; + + static JSPropertySpec properties[] = { + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("_setSpace", JSB_CCPhysicsDebugNode_setSpace_, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSpace", JSB_CCPhysicsDebugNode_space, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FN("_create", JSB_CCPhysicsDebugNode_debugNodeForCPSpace__static, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + TypeTest t1; + js_type_class_t *typeClass = nullptr; + std::string typeName = t1.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."); + + JSB_CCPhysicsDebugNode_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, typeClass->proto), JSB_CCPhysicsDebugNode_class, JSB_CCPhysicsDebugNode_constructor, 0,properties,funcs,NULL,st_funcs); + + TypeTest t; + js_type_class_t *p; + 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_CCPhysicsDebugNode_class; + p->proto = JSB_CCPhysicsDebugNode_object; + p->parentProto = typeClass->proto; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +// Arguments: NSString*, CGRect +// Ret value: PhysicsSprite* (o) +bool JSPROXY_CCPhysicsSprite_spriteWithFile_rect__static(JSContext *cx, uint32_t argc, jsval *vp) { + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + PhysicsSprite* ret = PhysicsSprite::create(arg0, arg1); + + jsval jsret; + do { + if (ret) { + 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, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto)); + jsret = OBJECT_TO_JSVAL(obj); + js_proxy_t *p = jsb_new_proxy(ret, obj); + JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + PhysicsSprite* ret = PhysicsSprite::create(arg0); + + jsval jsret; + do { + if (ret) { + 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, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto)); + jsret = OBJECT_TO_JSVAL(obj); + js_proxy_t *p = jsb_new_proxy(ret, obj); + JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + return false; + +} + +// Arguments: SpriteFrame* +// Ret value: PhysicsSprite* (o) +bool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrame__static(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + cocos2d::SpriteFrame* arg0; + if (argc >= 1) { + do { + js_proxy_t *proxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + proxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::SpriteFrame*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, arg0) + } while (0); + } + PhysicsSprite* ret = PhysicsSprite::createWithSpriteFrame(arg0); + + jsval jsret; + do { + if (ret) { + 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, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto)); + jsret = OBJECT_TO_JSVAL(obj); + js_proxy_t *p = jsb_new_proxy(ret, obj); + JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; +} + +// Arguments: NSString* +// Ret value: PhysicsSprite* (o) +bool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrameName__static(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + const char* arg0; + std::string arg0_tmp; + if (argc == 1) { + ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + + PhysicsSprite* ret = PhysicsSprite::createWithSpriteFrameName(arg0); + + jsval jsret; + do { + if (ret) { + 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, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto)); + jsret = OBJECT_TO_JSVAL(obj); + js_proxy_t *p = jsb_new_proxy(ret, obj); + JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool JSPROXY_CCPhysicsSprite_constructor(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + PhysicsSprite* cobj = new PhysicsSprite(); + 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."); + //JS::RootedObject obj(cx, JS_NewObjectForConstructor(cx, typeClass->jsclass, args)); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto))); + args.rval().set(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::extension::PhysicsSprite"); + if (JS_HasProperty(cx, obj, "_ctor", &ok)) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + +static bool JSPROXY_CCPhysicsSprite_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + PhysicsSprite *nobj = new PhysicsSprite(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + JS::AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::SpriteFrame"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound)) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} + +void JSPROXY_CCPhysicsSprite_createClass(JSContext *cx, JS::HandleObject globalObj) +{ + JSPROXY_CCPhysicsSprite_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSPROXY_CCPhysicsSprite_class->name = "PhysicsSprite"; + JSPROXY_CCPhysicsSprite_class->addProperty = JS_PropertyStub; + JSPROXY_CCPhysicsSprite_class->delProperty = JS_DeletePropertyStub; + JSPROXY_CCPhysicsSprite_class->getProperty = JS_PropertyStub; + JSPROXY_CCPhysicsSprite_class->setProperty = JS_StrictPropertyStub; + JSPROXY_CCPhysicsSprite_class->enumerate = JS_EnumerateStub; + JSPROXY_CCPhysicsSprite_class->resolve = JS_ResolveStub; + JSPROXY_CCPhysicsSprite_class->convert = JS_ConvertStub; + JSPROXY_CCPhysicsSprite_class->finalize = JSPROXY_CCPhysicsSprite_finalize; + JSPROXY_CCPhysicsSprite_class->flags = 0; + + static JSPropertySpec properties[] = { + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("isDirty", JSPROXY_CCPhysicsSprite_isDirty, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCPBody", JSPROXY_CCPhysicsSprite_getCPBody, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getIgnoreBodyRotation", JSPROXY_CCPhysicsSprite_ignoreBodyRotation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("_setCPBody", JSPROXY_CCPhysicsSprite_setCPBody_, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setIgnoreBodyRotation", JSPROXY_CCPhysicsSprite_setIgnoreBodyRotation_, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", JSPROXY_CCPhysicsSprite_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FN("create", JSPROXY_CCPhysicsSprite_spriteWithFile_rect__static, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithSpriteFrame", JSPROXY_CCPhysicsSprite_spriteWithSpriteFrame__static, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithSpriteFrameName", JSPROXY_CCPhysicsSprite_spriteWithSpriteFrameName__static, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + TypeTest t1; + js_type_class_t *typeClass = nullptr; + std::string typeName = t1.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."); + + JSPROXY_CCPhysicsSprite_object = JS_InitClass(cx, globalObj, JS::RootedObject(cx, typeClass->proto), JSPROXY_CCPhysicsSprite_class,/* dummy_constructor*/JSPROXY_CCPhysicsSprite_constructor, 0,properties,funcs,NULL,st_funcs); + + TypeTest t; + js_type_class_t *p; + 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 = JSPROXY_CCPhysicsSprite_class; + p->proto = JSPROXY_CCPhysicsSprite_object; + p->parentProto = typeClass->proto; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + + +void register_CCPhysicsSprite(JSContext *cx, JS::HandleObject obj) { + JS::RootedObject ccObj(cx); + get_or_create_js_obj(cx, obj, "cc", &ccObj); + JSPROXY_CCPhysicsSprite_createClass(cx, ccObj); +} + +void register_CCPhysicsDebugNode(JSContext *cx, JS::HandleObject obj) { + JS::RootedObject ccObj(cx); + get_or_create_js_obj(cx, obj, "cc", &ccObj); + JSB_CCPhysicsDebugNode_createClass(cx, ccObj, "PhysicsDebugNode"); +} + +bool jsval_to_cpBB( JSContext *cx, jsval vp, cpBB *ret ) +{ + JS::RootedObject jsobj(cx); + bool ok = JS_ValueToObject( cx, JS::RootedValue(cx, vp), &jsobj ); + JSB_PRECONDITION( ok, "Error converting value to object"); + JSB_PRECONDITION( jsobj, "Not a valid JS object"); + + JS::RootedValue vall(cx); + JS::RootedValue valb(cx); + JS::RootedValue valr(cx); + JS::RootedValue valt(cx); + ok = true; + ok &= JS_GetProperty(cx, jsobj, "l", &vall); + ok &= JS_GetProperty(cx, jsobj, "b", &valb); + ok &= JS_GetProperty(cx, jsobj, "r", &valr); + ok &= JS_GetProperty(cx, jsobj, "t", &valt); + JSB_PRECONDITION( ok, "Error obtaining point properties"); + + double l, b, r, t; + ok &= JS::ToNumber(cx, vall, &l); + ok &= JS::ToNumber(cx, valb, &b); + ok &= JS::ToNumber(cx, valr, &r); + ok &= JS::ToNumber(cx, valt, &t); + JSB_PRECONDITION( ok, "Error converting value to numbers"); + + ret->l = l; + ret->b = b; + ret->r = r; + ret->t = t; + + return true; +} + +jsval cpBB_to_jsval(JSContext *cx, cpBB bb ) +{ + JS::RootedObject object(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr())); + if (!object) + return JSVAL_VOID; + + if (!JS_DefineProperty(cx, object, "l", bb.l, JSPROP_ENUMERATE | JSPROP_PERMANENT) || + !JS_DefineProperty(cx, object, "b", bb.b, JSPROP_ENUMERATE | JSPROP_PERMANENT) || + !JS_DefineProperty(cx, object, "r", bb.r, JSPROP_ENUMERATE | JSPROP_PERMANENT) || + !JS_DefineProperty(cx, object, "t", bb.t, JSPROP_ENUMERATE | JSPROP_PERMANENT) ) + return JSVAL_VOID; + + return OBJECT_TO_JSVAL(object); +} + +// In order to be compatible with Chipmunk-JS API, +// this function expect to receive an array of numbers, and not an array of vects +// OK: [1,2, 3,4, 5,6] <- expected +// BAD: [{x:1, y:2}, {x:3,y:4}, {x:5, y:6}] <- not expected +bool jsval_to_array_of_cpvect( JSContext *cx, jsval vp, cpVect**verts, int *numVerts) +{ + // Parsing sequence + JS::RootedObject jsobj(cx); + bool ok = JS_ValueToObject( cx, JS::RootedValue(cx, vp), &jsobj ); + JSB_PRECONDITION( ok, "Error converting value to object"); + + JSB_PRECONDITION( jsobj && JS_IsArrayObject( cx, jsobj), "Object must be an array"); + + uint32_t len; + JS_GetArrayLength(cx, jsobj, &len); + + JSB_PRECONDITION( len%2==0, "Array lenght should be even"); + + cpVect *array = (cpVect*)malloc( sizeof(cpVect) * len/2); + + for( uint32_t i=0; i< len;i++ ) { + JS::RootedValue valarg(cx); + JS_GetElement(cx, jsobj, i, &valarg); + + double value; + ok = JS::ToNumber(cx, valarg, &value); + JSB_PRECONDITION( ok, "Error converting value to nsobject"); + + if(i%2==0) + array[i/2].x = value; + else + array[i/2].y = value; + } + + *numVerts = len/2; + *verts = array; + + return true; +} + + +bool jsval_to_cpVect( JSContext *cx, jsval vp, cpVect *ret ) +{ +#ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + + JS::RootedObject jsobj(cx); + if( ! JS_ValueToObject( cx, JS::RootedValue(cx, vp), &jsobj ) ) + return false; + + JSB_PRECONDITION( jsobj, "Not a valid JS object"); + + JS::RootedValue valx(cx); + JS::RootedValue valy(cx); + bool ok = true; + ok &= JS_GetProperty(cx, jsobj, "x", &valx); + ok &= JS_GetProperty(cx, jsobj, "y", &valy); + + if( ! ok ) + return false; + + double x, y; + ok &= JS::ToNumber(cx, valx, &x); + ok &= JS::ToNumber(cx, valy, &y); + + if( ! ok ) + return false; + + ret->x = x; + ret->y = y; + + return true; + +#else // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + + JSObject *tmp_arg; + if( ! JS_ValueToObject( cx, vp, &tmp_arg ) ) + return false; + + JSB_PRECONDITION( tmp_arg && JS_IsTypedArrayObject( tmp_arg, cx ), "Not a TypedArray object"); + + JSB_PRECONDITION( JS_GetTypedArrayByteLength( tmp_arg, cx ) == sizeof(cpVect), "Invalid length"); + + *ret = *(cpVect*)JS_GetArrayBufferViewData( tmp_arg, cx ); + + return true; +#endif // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES +} + + +jsval cpVect_to_jsval( JSContext *cx, cpVect p) +{ + +#ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + + JS::RootedObject object(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr() )); + if (!object) + return JSVAL_VOID; + + if (!JS_DefineProperty(cx, object, "x", p.x, JSPROP_ENUMERATE | JSPROP_PERMANENT) || + !JS_DefineProperty(cx, object, "y", p.y, JSPROP_ENUMERATE | JSPROP_PERMANENT) ) + return JSVAL_VOID; + + return OBJECT_TO_JSVAL(object); + +#else // JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + +#ifdef __LP64__ + JSObject *typedArray = JS_NewFloat64Array( cx, 2 ); +#else + JSObject *typedArray = JS_NewFloat32Array( cx, 2 ); +#endif + + cpVect *buffer = (cpVect*)JS_GetArrayBufferViewData(typedArray, cx ); + *buffer = p; + return OBJECT_TO_JSVAL(typedArray); +#endif // ! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES +} + +#pragma mark - Collision Handler + +struct collision_handler { + cpCollisionType typeA; + cpCollisionType typeB; + + JS::Heap begin; + JS::Heap pre; + JS::Heap post; + JS::Heap separate; + JS::Heap jsthis; + JSContext *cx; + + // "owner" of the collision handler + // Needed when the space goes out of scope, it will remove all the allocated collision handlers for him. + cpSpace *space; + + unsigned long hash_key; + + unsigned int is_oo; // Objected oriented API ? + UT_hash_handle hh; +}; + +// hash +struct collision_handler* collision_handler_hash = NULL; + +// helper pair +static unsigned long pair_ints( unsigned long A, unsigned long B ) +{ + // order is not important + unsigned long k1 = MIN(A, B ); + unsigned long k2 = MAX(A, B ); + + return (k1 + k2) * (k1 + k2 + 1) /2 + k2; +} + +static cpBool myCollisionBegin(cpArbiter *arb, cpSpace *space, void *data) +{ + struct collision_handler *handler = (struct collision_handler*) data; + + jsval args[2]; + if( handler->is_oo ) { + args[0] = c_class_to_jsval(handler->cx, arb, JS::RootedObject(handler->cx, JSB_cpArbiter_object), JSB_cpArbiter_class, "cpArbiter"); + args[1] = c_class_to_jsval(handler->cx, space, JS::RootedObject(handler->cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpArbiter"); + } else { + args[0] = opaque_to_jsval( handler->cx, arb); + args[1] = opaque_to_jsval( handler->cx, space ); + } + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JS::RootedValue rval(handler->cx); + bool ok = JS_CallFunctionValue( handler->cx, JS::RootedObject(handler->cx, handler->jsthis), JS::RootedValue(handler->cx, OBJECT_TO_JSVAL(handler->begin)), JS::HandleValueArray::fromMarkedLocation(2, args), &rval); + JSB_PRECONDITION2(ok, handler->cx, cpFalse, "Error calling collision callback: begin"); + + if( rval.isBoolean() ) { + bool ret = rval.toBoolean(); + return (cpBool)ret; + } + return cpTrue; +} + +static cpBool myCollisionPre(cpArbiter *arb, cpSpace *space, void *data) +{ + struct collision_handler *handler = (struct collision_handler*) data; + + jsval args[2]; + if( handler->is_oo ) { + args[0] = c_class_to_jsval(handler->cx, arb, JS::RootedObject(handler->cx, JSB_cpArbiter_object), JSB_cpArbiter_class, "cpArbiter"); + args[1] = c_class_to_jsval(handler->cx, space, JS::RootedObject(handler->cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpArbiter"); + } else { + args[0] = opaque_to_jsval( handler->cx, arb); + args[1] = opaque_to_jsval( handler->cx, space ); + } + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JS::RootedValue rval(handler->cx); + bool ok = JS_CallFunctionValue( handler->cx, JS::RootedObject(handler->cx, handler->jsthis), JS::RootedValue(handler->cx, OBJECT_TO_JSVAL(handler->pre)), JS::HandleValueArray::fromMarkedLocation(2, args), &rval); + JSB_PRECONDITION2(ok, handler->cx, false, "Error calling collision callback: pre"); + + if( rval.isBoolean() ) { + bool ret = rval.toBoolean(); + return (cpBool)ret; + } + return cpTrue; +} + +static void myCollisionPost(cpArbiter *arb, cpSpace *space, void *data) +{ + struct collision_handler *handler = (struct collision_handler*) data; + + jsval args[2]; + + if( handler->is_oo ) { + args[0] = c_class_to_jsval(handler->cx, arb, JS::RootedObject(handler->cx, JSB_cpArbiter_object), JSB_cpArbiter_class, "cpArbiter"); + args[1] = c_class_to_jsval(handler->cx, space, JS::RootedObject(handler->cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpArbiter"); + } else { + args[0] = opaque_to_jsval( handler->cx, arb); + args[1] = opaque_to_jsval( handler->cx, space ); + } + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JS::RootedValue ignore(handler->cx); + bool ok = JS_CallFunctionValue( handler->cx, JS::RootedObject(handler->cx, handler->jsthis), JS::RootedValue(handler->cx, OBJECT_TO_JSVAL(handler->post)), JS::HandleValueArray::fromMarkedLocation(2, args), &ignore); + JSB_PRECONDITION2(ok, handler->cx, , "Error calling collision callback: Post"); +} + +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, JS::RootedObject(handler->cx, JSB_cpArbiter_object), JSB_cpArbiter_class, "cpArbiter"); + args[1] = c_class_to_jsval(handler->cx, space, JS::RootedObject(handler->cx, JSB_cpSpace_object), JSB_cpSpace_class, "cpArbiter"); + } else { + args[0] = opaque_to_jsval( handler->cx, arb); + args[1] = opaque_to_jsval( handler->cx, space ); + } + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JS::RootedValue ignore(handler->cx); + bool ok = JS_CallFunctionValue( handler->cx, JS::RootedObject(handler->cx, handler->jsthis), JS::RootedValue(handler->cx, OBJECT_TO_JSVAL(handler->separate)), JS::HandleValueArray::fromMarkedLocation(2, args), &ignore); + JSB_PRECONDITION2(ok, handler->cx, , "Error calling collision callback: Separate");} + +#pragma mark - cpSpace + +#pragma mark constructor / destructor + +void JSB_cpSpace_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpSpace), handle: %p", jsthis, proxy->handle); + + // space + cpSpace *space = (cpSpace*) proxy->handle; + + + // Remove collision handlers, since the user might have forgotten to manually remove them + struct collision_handler *current, *tmp; + HASH_ITER(hh, collision_handler_hash, current, tmp) { + if( current->space == space ) { + + JSContext *cx = current->cx; + + // unroot it + if( current->begin ) { + JS::RemoveObjectRoot(cx, ¤t->begin); + } + if( current->pre ) + JS::RemoveObjectRoot(cx, ¤t->pre); + if( current->post ) + JS::RemoveObjectRoot(cx, ¤t->post); + if( current->separate ) + JS::RemoveObjectRoot(cx, ¤t->separate); + + HASH_DEL(collision_handler_hash,current); /* delete; users advances to next */ + free(current); /* optional- if you want to free */ + } + } + + // Free Space Children + freeSpaceChildren(space); + + jsb_del_jsobject_for_proxy(space); + if(proxy->flags == JSB_C_FLAG_CALL_FREE) + cpSpaceFree(space); + jsb_del_c_proxy_for_jsobject(jsthis); + } +} + + +#pragma mark addCollisionHandler + +static +bool __jsb_cpSpace_addCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp, cpSpace *space, unsigned int is_oo) +{ + struct collision_handler *handler = (struct collision_handler*) malloc( sizeof(*handler) ); + + JSB_PRECONDITION(handler, "Error allocating memory"); + + bool ok = true; + + // args + ok &= jsval_to_int(cx, JS::RootedValue(cx, *argvp++), (int32_t*) &handler->typeA ); + ok &= jsval_to_int(cx, JS::RootedValue(cx, *argvp++), (int32_t*) &handler->typeB ); + + // this is no longer passed, so "this" is going to be "this". +// ok &= JS_ValueToObject(cx, *argvp++, &handler->jsthis ); + handler->jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + + handler->begin = argvp->toObjectOrNull(); + argvp++; + handler->pre = argvp->toObjectOrNull(); + argvp++; + handler->post = argvp->toObjectOrNull(); + argvp++; + handler->separate = argvp->toObjectOrNull(); + argvp++; + + JSB_PRECONDITION(ok, "Error parsing arguments"); + + // Object Oriented API ? + handler->is_oo = is_oo; + + // owner of the collision handler + handler->space = space; + + // 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"); + + handler->cx = cx; + + cpSpaceAddCollisionHandler(space, handler->typeA, handler->typeB, + !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 ) { + HASH_DEL( collision_handler_hash, hashElement ); + free( hashElement ); + } + + handler->hash_key = paired_key; + HASH_ADD_INT( collision_handler_hash, hash_key, handler ); + + return true; +} + +bool JSB_cpSpaceAddCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==7, cx, false, "Invalid number of arguments"); + + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + // args + cpSpace *space; + jsval* argvp = args.array(); + bool ok = jsval_to_opaque( cx, JS::RootedValue(cx, *argvp++), (void**)&space); + JSB_PRECONDITION(ok, "Error parsing arguments"); + + return __jsb_cpSpace_addCollisionHandler(cx, vp, argvp, space, 0); +} + +// method +bool JSB_cpSpace_addCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==6, cx, false, "Invalid number of arguments"); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JSB_PRECONDITION( jsthis, "Invalid jsthis object"); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + void *handle = proxy->handle; + + return __jsb_cpSpace_addCollisionHandler(cx, vp, args.array(), (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; + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + handler->begin = args.get(0).toObjectOrNull(); + handler->pre = args.get(1).toObjectOrNull(); + handler->post = args.get(2).toObjectOrNull(); + handler->separate = args.get(3).toObjectOrNull(); + + // 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"); + + args.rval().setUndefined(); + + return true; +} + +#pragma mark removeCollisionHandler + +static +bool __jsb_cpSpace_removeCollisionHandler(JSContext *cx, jsval *vp, jsval *argvp, cpSpace *space) +{ + bool ok = true; + + cpCollisionType typeA; + cpCollisionType typeB; + ok &= jsval_to_int(cx, JS::RootedValue(cx, *argvp++), (int32_t*) &typeA ); + ok &= jsval_to_int(cx, JS::RootedValue(cx, *argvp++), (int32_t*) &typeB ); + + JSB_PRECONDITION(ok, "Error parsing arguments"); + + cpSpaceRemoveCollisionHandler(space, typeA, typeB ); + + // Remove it + struct collision_handler *hashElement = NULL; + unsigned long key = pair_ints(typeA, typeB ); + HASH_FIND_INT(collision_handler_hash, &key, hashElement); + if( hashElement ) { + + // unroot it + 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 ); + } + + return true; +} + +// Free function +bool JSB_cpSpaceRemoveCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==3, cx, false, "Invalid number of arguments"); + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + cpSpace* space; + jsval* argvp = args.array(); + bool ok = jsval_to_opaque( cx, JS::RootedValue(cx, *argvp++), (void**)&space); + + JSB_PRECONDITION(ok, "Error parsing arguments"); + + return __jsb_cpSpace_removeCollisionHandler(cx, vp, argvp, space); +} + +// method +bool JSB_cpSpace_removeCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==2, cx, false, "Invalid number of arguments"); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JSB_PRECONDITION( jsthis, "Invalid jsthis object"); + + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + void *handle = proxy->handle; + + return __jsb_cpSpace_removeCollisionHandler(cx, vp, args.array(), (cpSpace*)handle); +} + +#pragma mark Add functios. Root JSObjects + +// Arguments: cpBody* +// Ret value: cpBody* +bool JSB_cpSpace_addBody(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg1; + + jsval retval = args.get(0); struct jsb_c_proxy_s *retproxy; + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg1, &retproxy ); + JSB_PRECONDITION(ok, "Error processing arguments"); + + cpSpaceAddBody((cpSpace*)arg0 , (cpBody*)arg1 ); + + // Root it: + JS::AddNamedObjectRoot(cx, &retproxy->jsobj, "cpBody"); + + // addBody returns the same object that was added, so return it without conversions + args.rval().set(retval); + + return true; +} + +// Arguments: cpConstraint* +// Ret value: cpConstraint* +bool JSB_cpSpace_addConstraint(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg1; + + jsval retval = args.get(0); struct jsb_c_proxy_s *retproxy; + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg1, &retproxy ); + JSB_PRECONDITION(ok, "Error processing arguments"); + + cpSpaceAddConstraint((cpSpace*)arg0 , (cpConstraint*)arg1 ); + + // Root it: + JS::AddNamedObjectRoot(cx, &retproxy->jsobj, "cpConstraint"); + + // addConstraint returns the same object that was added, so return it without conversions + args.rval().set(retval); + + return true; +} + +// Arguments: cpShape* +// Ret value: cpShape* +bool JSB_cpSpace_addShape(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg1; + + jsval retval = args.get(0); struct jsb_c_proxy_s *retproxy; + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg1, &retproxy ); + JSB_PRECONDITION(ok, "Error processing arguments"); + + cpSpaceAddShape((cpSpace*)arg0 , (cpShape*)arg1 ); + + // Root it: + JS::AddNamedObjectRoot(cx, &retproxy->jsobj, "cpShape"); + + // addShape returns the same object that was added, so return it without conversions + args.rval().set(retval); + + return true; +} + +// Arguments: cpShape* +// Ret value: cpShape* +bool JSB_cpSpace_addStaticShape(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg1; + + jsval retval = args.get(0); struct jsb_c_proxy_s *retproxy; + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg1, &retproxy ); + JSB_PRECONDITION(ok, "Error processing arguments"); + + cpSpaceAddStaticShape((cpSpace*)arg0 , (cpShape*)arg1 ); + + // Root it: + JS::AddNamedObjectRoot(cx, &retproxy->jsobj, "cpShape (static)"); + + // addStaticShape returns the same object that was added, so return it without conversions + args.rval().set(retval); + + return true; +} + +#pragma mark Remove functios. Untoot JSObjects + +// Arguments: cpBody* +// Ret value: void +bool JSB_cpSpace_removeBody(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* arg1; + + struct jsb_c_proxy_s *retproxy; + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg1, &retproxy ); + JSB_PRECONDITION(ok, "Error processing arguments"); + + cpSpaceRemoveBody((cpSpace*)arg0 , (cpBody*)arg1 ); + JS::RemoveObjectRoot(cx, &retproxy->jsobj); + + args.rval().setUndefined(); + return true; +} + +// Arguments: cpConstraint* +// Ret value: void +bool JSB_cpSpace_removeConstraint(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpConstraint* arg1; + + struct jsb_c_proxy_s *retproxy; + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg1, &retproxy ); + JSB_PRECONDITION(ok, "Error processing arguments"); + + cpSpaceRemoveConstraint((cpSpace*)arg0 , (cpConstraint*)arg1 ); + JS::RemoveObjectRoot(cx, &retproxy->jsobj); + + args.rval().setUndefined(); + return true; +} + +// Arguments: cpShape* +// Ret value: void +bool JSB_cpSpace_removeShape(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg1; + + struct jsb_c_proxy_s *retproxy; + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg1, &retproxy ); + JSB_PRECONDITION(ok, "Error processing arguments"); + + cpSpaceRemoveShape((cpSpace*)arg0 , (cpShape*)arg1 ); + JS::RemoveObjectRoot(cx, &retproxy->jsobj); + + args.rval().setUndefined(); + return true; +} + +// Arguments: cpShape* +// Ret value: void +bool JSB_cpSpace_removeStaticShape(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* arg0 = (cpSpace*) proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpShape* arg1; + + struct jsb_c_proxy_s *retproxy; + ok &= jsval_to_c_class( cx, args.get(0), (void**)&arg1, &retproxy ); + JSB_PRECONDITION(ok, "Error processing arguments"); + + cpSpaceRemoveStaticShape((cpSpace*)arg0 , (cpShape*)arg1 ); + JS::RemoveObjectRoot(cx, &retproxy->jsobj); + + args.rval().setUndefined(); + return true; +} + +#pragma mark segmentQueryFirst function + +bool JSB_cpSpace_segmentQueryFirst(JSContext *cx, uint32_t argc, jsval *vp){ + 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; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + cpVect start; + cpVect end; + cpLayers layers; + cpGroup group; + bool ok = true; + 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"); + + cpSegmentQueryInfo *out = new cpSegmentQueryInfo(); + cpShape* target = cpSpaceSegmentQueryFirst(space, start, end, layers, group, out); + + if(target) + { + JSObject *jsobj = JS_NewObject(cx, JSB_cpSegmentQueryInfo_class, JS::RootedObject(cx, JSB_cpSegmentQueryInfo_object), JS::NullPtr()); + jsb_set_jsobject_for_proxy(jsobj, out); + jsb_set_c_proxy_for_jsobject(jsobj, out, JSB_C_FLAG_CALL_FREE); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + } + else + { + delete out; + args.rval().set(JSVAL_NULL); + } + return true; +} + +#pragma mark nearestPointQueryNearest function + +bool JSB_cpSpace_nearestPointQueryNearest(JSContext *cx, uint32_t argc, jsval *vp){ + 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; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + cpVect point; + double maxDistance; + cpLayers layers; + cpGroup group; + bool ok = true; + 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"); + + cpNearestPointQueryInfo* info = new cpNearestPointQueryInfo(); + cpShape* target = cpSpaceNearestPointQueryNearest(space, point, maxDistance, layers, group, info); + + if(target) + { + JSObject *jsobj = JS_NewObject(cx, JSB_cpNearestPointQueryInfo_class, JS::RootedObject(cx, JSB_cpNearestPointQueryInfo_object), JS::NullPtr()); + jsb_set_jsobject_for_proxy(jsobj, info); + jsb_set_c_proxy_for_jsobject(jsobj, info, JSB_C_FLAG_CALL_FREE); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + } + else + { + delete info; + args.rval().set(JSVAL_NULL); + } + 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; + JS::RootedValue rval(cx); + jsval argv = OBJECT_TO_JSVAL(jsCpObject); + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + JS_CallFunctionValue(cx, JS::NullPtr(), JS::RootedValue(cx, *func), JS::HandleValueArray::fromMarkedLocation(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 = args.thisv().toObjectOrNull(); + 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; + JS::RootedValue rval(cx); + 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, JS::NullPtr(), JS::RootedValue(cx, *func), JS::HandleValueArray::fromMarkedLocation(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 = args.thisv().toObjectOrNull(); + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* space = (cpSpace*) proxy->handle; + + cpVect point; + double 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; + JS::RootedValue rval(cx); + 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, JS::NullPtr(), JS::RootedValue(cx, *func), JS::HandleValueArray::fromMarkedLocation(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 = args.thisv().toObjectOrNull(); + 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 = args.thisv().toObjectOrNull(); + 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; + JS::RootedValue rval(cx); + jsval argv = OBJECT_TO_JSVAL(jsCpObject); + + JS_CallFunctionValue(cx, JS::NullPtr(), JS::RootedValue(cx, *func), JS::HandleValueArray::fromMarkedLocation(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; + JS::CallArgs args = JS::CallArgsFromVp(argc, 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 = const_cast(args.get(0).address()); + + 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; + JS::CallArgs args = JS::CallArgsFromVp(argc, 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 = const_cast(args.get(0).address()); + + 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; + JS::CallArgs args = JS::CallArgsFromVp(argc, 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 = const_cast(args.get(0).address()); + + 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; + JS::RootedValue func(cx, data->func); + JS::RootedValue rval(cx); + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + JS_CallFunctionValue(cx, JS::NullPtr(), func, JS::HandleValueArray::empty(), &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 = args.thisv().toObjectOrNull(); + 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; + JS::RootedValue rval(cx); + jsval argv = OBJECT_TO_JSVAL(jsCpObject); + + JS_CallFunctionValue(cx, JS::NullPtr(), JS::RootedValue(cx, *func), JS::HandleValueArray::fromMarkedLocation(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; + JS::CallArgs args = JS::CallArgsFromVp(argc, 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 = const_cast(args.get(0).address()); + + 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; + JS::CallArgs args = JS::CallArgsFromVp(argc, 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 = const_cast(args.get(0).address()); + + 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; + JS::CallArgs args = JS::CallArgsFromVp(argc, 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 = const_cast(args.get(0).address()); + + cpBodyEachArbiter(body, JSB_cpBody_each_func, data); + free(data); + return true; +} + +#pragma mark - Arbiter + +#pragma mark getBodies +static +bool __jsb_cpArbiter_getBodies(JSContext *cx, const JS::CallArgs& args, cpArbiter *arbiter, unsigned int is_oo) +{ + cpBody *bodyA; + cpBody *bodyB; + cpArbiterGetBodies(arbiter, &bodyA, &bodyB); + + JS::RootedValue valA(cx); + JS::RootedValue valB(cx); + if( is_oo ) { + valA = c_class_to_jsval(cx, bodyA, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpArbiter"); + valB = c_class_to_jsval(cx, bodyB, JS::RootedObject(cx, JSB_cpBody_object), JSB_cpBody_class, "cpArbiter"); + } else { + valA = opaque_to_jsval(cx, bodyA); + valB = opaque_to_jsval(cx, bodyB); + } + + JS::RootedObject jsobj(cx, JS_NewArrayObject(cx, 2)); + JS_SetElement(cx, jsobj, 0, valA); + JS_SetElement(cx, jsobj, 1, valB); + + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + + return true; +} + +// Free function +bool JSB_cpArbiterGetBodies(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==1, cx, false, "Invalid number of arguments"); + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + cpArbiter* arbiter; + if( ! jsval_to_opaque( cx, args.get(0), (void**)&arbiter ) ) + return false; + + return __jsb_cpArbiter_getBodies(cx, args, arbiter, 0); +} + +// Method +bool JSB_cpArbiter_getBodies(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==0, cx, false, "Invalid number of arguments"); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JSB_PRECONDITION( jsthis, "Invalid jsthis object"); + + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + JSB_PRECONDITION( proxy, "Invalid private object"); + void *handle = proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + return __jsb_cpArbiter_getBodies(cx, args, (cpArbiter*)handle, 1); +} + +#pragma mark getShapes +static +bool __jsb_cpArbiter_getShapes(JSContext *cx, const JS::CallArgs& args, cpArbiter *arbiter, unsigned int is_oo) +{ + cpShape *shapeA; + cpShape *shapeB; + cpArbiterGetShapes(arbiter, &shapeA, &shapeB); + + JS::RootedValue valA(cx); + JS::RootedValue valB(cx); + if( is_oo ) { + valA = c_class_to_jsval(cx, shapeA, JS::RootedObject(cx, JSB_cpShape_object), JSB_cpShape_class, "cpShape"); + valB = c_class_to_jsval(cx, shapeB, JS::RootedObject(cx, JSB_cpShape_object), JSB_cpShape_class, "cpShape"); + } else { + valA = opaque_to_jsval(cx, shapeA); + valB = opaque_to_jsval(cx, shapeB); + } + + JS::RootedObject jsobj(cx, JS_NewArrayObject(cx, 2)); + JS_SetElement(cx, jsobj, 0, valA); + JS_SetElement(cx, jsobj, 1, valB); + + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + + return true; +} + +// function +bool JSB_cpArbiterGetShapes(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==1, cx, false, "Invalid number of arguments"); + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + cpArbiter* arbiter; + if( ! jsval_to_opaque( cx, args.get(0), (void**) &arbiter ) ) + return false; + + return __jsb_cpArbiter_getShapes(cx, args, arbiter, 0); +} + +// method +bool JSB_cpArbiter_getShapes(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==0, cx, false, "Invalid number of arguments"); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JSB_PRECONDITION( jsthis, "Invalid jsthis object"); + + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + void *handle = proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + return __jsb_cpArbiter_getShapes(cx, args, (cpArbiter*)handle, 1); +} + +#pragma mark - Body + +#pragma mark constructor + +// Manually added to identify static vs dynamic bodies +bool JSB_cpBody_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==2, cx, false, "Invalid number of arguments"); + JSObject *jsobj = JS_NewObject(cx, JSB_cpBody_class, JS::RootedObject(cx, JSB_cpBody_object), JS::NullPtr()); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + double m; double i; + + ok &= JS::ToNumber( cx, args.get(0), &m ); + ok &= JS::ToNumber( cx, args.get(1), &i ); + JSB_PRECONDITION(ok, "Error processing arguments"); + + cpBody *ret_body = NULL; + if( m == INFINITY && i == INFINITY) { + ret_body = cpBodyNewStatic(); + + // XXX: Hack. IT WILL LEAK "rogue" objects., But at least it prevents a crash. + // The thing is that "rogue" bodies needs to be freed after the its shape, and I am not sure + // how to do it in a "js" way. + jsb_set_c_proxy_for_jsobject(jsobj, ret_body, JSB_C_FLAG_DO_NOT_CALL_FREE); + } else { + ret_body = cpBodyNew((cpFloat)m , (cpFloat)i ); + jsb_set_c_proxy_for_jsobject(jsobj, ret_body, JSB_C_FLAG_CALL_FREE); + } + + jsb_set_jsobject_for_proxy(jsobj, ret_body); + + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + return true; +} + +#pragma mark getUserData + +static +bool __jsb_cpBody_getUserData(JSContext *cx, const JS::CallArgs& args, cpBody *body) +{ + JSObject *data = (JSObject*) cpBodyGetUserData(body); + args.rval().set(OBJECT_TO_JSVAL(data)); + + return true; +} + +// free function +bool JSB_cpBodyGetUserData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==1, cx, false, "Invalid number of arguments"); + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + cpBody *body; + if( ! jsval_to_opaque( cx, args.get(0), (void**) &body ) ) + return false; + + return __jsb_cpBody_getUserData(cx, args, body); +} + +// method +bool JSB_cpBody_getUserData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==0, cx, false, "Invalid number of arguments"); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JSB_PRECONDITION( jsthis, "Invalid jsthis object"); + + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + void *handle = proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + return __jsb_cpBody_getUserData(cx, args, (cpBody*)handle); +} + + +#pragma mark setUserData + +static +bool __jsb_cpBody_setUserData(JSContext *cx, jsval *vp, jsval *argvp, cpBody *body) +{ + JS::RootedObject jsobj(cx); + + bool ok = JS_ValueToObject(cx, JS::RootedValue(cx, *argvp), &jsobj); + + JSB_PRECONDITION(ok, "Error parsing arguments"); + + cpBodySetUserData(body, jsobj); + + return true; +} + +// free function +bool JSB_cpBodySetUserData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==2, cx, false, "Invalid number of arguments"); + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + cpBody *body; + jsval* argvp = args.array(); + bool ok = jsval_to_opaque( cx, JS::RootedValue(cx, *argvp++), (void**) &body ); + JSB_PRECONDITION(ok, "Error parsing arguments"); + return __jsb_cpBody_setUserData(cx, vp, argvp, body); +} + +// method +bool JSB_cpBody_setUserData(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); + JSB_PRECONDITION( jsthis, "Invalid jsthis object"); + + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + void *handle = proxy->handle; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + return __jsb_cpBody_setUserData(cx, vp, args.array(), (cpBody*)handle); +} + +#pragma mark - Poly related + +// cpFloat cpAreaForPoly(const int numVerts, const cpVect *verts); +bool JSB_cpAreaForPoly(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==1, cx, false, "Invalid number of arguments"); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect *verts; + int numVerts; + + ok &= jsval_to_array_of_cpvect( cx, args.get(0), &verts, &numVerts); + JSB_PRECONDITION2(ok, cx, false, "Error parsing array"); + + cpFloat area = cpAreaForPoly(numVerts, verts); + + free(verts); + + args.rval().set(DOUBLE_TO_JSVAL(area)); + return true; +} + +// cpFloat cpMomentForPoly(cpFloat m, int numVerts, const cpVect *verts, cpVect offset); +bool JSB_cpMomentForPoly(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==3, cx, false, "Invalid number of arguments"); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect *verts; cpVect offset; + int numVerts; + double m; + + ok &= JS::ToNumber(cx, args.get(0), &m); + ok &= jsval_to_array_of_cpvect( cx, args.get(1), &verts, &numVerts); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &offset ); + + JSB_PRECONDITION2(ok, cx, false, "Error parsing args"); + + cpFloat moment = cpMomentForPoly((cpFloat)m, numVerts, verts, offset); + + free(verts); + + args.rval().set(DOUBLE_TO_JSVAL(moment)); + return true; +} + +// cpVect cpCentroidForPoly(const int numVerts, const cpVect *verts); +bool JSB_cpCentroidForPoly(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==1, cx, false, "Invalid number of arguments"); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpVect *verts; + int numVerts; + + ok &= jsval_to_array_of_cpvect( cx, args.get(0), &verts, &numVerts); + JSB_PRECONDITION2(ok, cx, false, "Error parsing args"); + + cpVect centroid = cpCentroidForPoly(numVerts, verts); + + free(verts); + + args.rval().set(cpVect_to_jsval(cx, (cpVect)centroid)); + return true; +} + +// void cpRecenterPoly(const int numVerts, cpVect *verts); +bool JSB_cpRecenterPoly(JSContext *cx, uint32_t argc, jsval *vp) +{ + CCASSERT(false, "NOT IMPLEMENTED"); + return false; +} + +#pragma mark - Object Oriented Chipmunk + +/* + * Chipmunk Base Object + */ + +JSClass* JSB_cpBase_class = NULL; +JSObject* JSB_cpBase_object = NULL; +// Constructor +bool JSB_cpBase_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc==1, cx, false, "Invalid arguments. Expecting 1"); + + JSObject *jsobj = JS_NewObject(cx, JSB_cpBase_class, JS::RootedObject(cx, JSB_cpBase_object), JS::NullPtr()); + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + void *handle = NULL; + + ok = jsval_to_opaque(cx, args.get(0), &handle); + + JSB_PRECONDITION(ok, "Error converting arguments for JSB_cpBase_constructor"); + + jsb_set_c_proxy_for_jsobject(jsobj, handle, JSB_C_FLAG_DO_NOT_CALL_FREE); + jsb_set_jsobject_for_proxy(jsobj, handle); + + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + return true; +} + +// Destructor +void JSB_cpBase_finalize(JSFreeOp *fop, JSObject *obj) +{ + CCLOGINFO("jsbindings: finalizing JS object %p (cpBase)", obj); + + // should not delete the handle since it was manually added +} + +bool JSB_cpBase_getHandle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JSB_PRECONDITION( jsthis, "Invalid jsthis object"); + JSB_PRECONDITION2(argc==0, cx, false, "Invalid number of arguments"); + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + void *handle = proxy->handle; + + jsval ret_val = opaque_to_jsval(cx, handle); + args.rval().set(ret_val); + return true; +} + +bool JSB_cpBase_setHandle(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + JSB_PRECONDITION( jsthis, "Invalid jsthis object"); + JSB_PRECONDITION2(argc==1, cx, false, "Invalid number of arguments"); + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + void *handle; + bool ok = jsval_to_opaque(cx, args.get(0), &handle); + JSB_PRECONDITION( ok, "Invalid parsing arguments"); + + jsb_set_c_proxy_for_jsobject(jsthis, handle, JSB_C_FLAG_DO_NOT_CALL_FREE); + jsb_set_jsobject_for_proxy(jsthis, handle); + + args.rval().setUndefined(); + return true; +} + + +void JSB_cpBase_createClass(JSContext *cx, JS::HandleObject globalObj, const char* name ) +{ + JSB_cpBase_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpBase_class->name = name; + JSB_cpBase_class->addProperty = JS_PropertyStub; + JSB_cpBase_class->delProperty = JS_DeletePropertyStub; + JSB_cpBase_class->getProperty = JS_PropertyStub; + JSB_cpBase_class->setProperty = JS_StrictPropertyStub; + JSB_cpBase_class->enumerate = JS_EnumerateStub; + JSB_cpBase_class->resolve = JS_ResolveStub; + JSB_cpBase_class->convert = JS_ConvertStub; + JSB_cpBase_class->finalize = JSB_cpBase_finalize; + JSB_cpBase_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + JS_PS_END + }; + static JSFunctionSpec funcs[] = { + JS_FN("getHandle", JSB_cpBase_getHandle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setHandle", JSB_cpBase_setHandle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpBase_object = JS_InitClass(cx, globalObj, JS::NullPtr(), JSB_cpBase_class, JSB_cpBase_constructor,0,properties,funcs,NULL,st_funcs); +// bool found; +// JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + +// Manual "methods" +// Constructor +bool JSB_cpPolyShape_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==3, cx, false, "Invalid number of arguments"); + JSObject *jsobj = JS_NewObject(cx, JSB_cpPolyShape_class, JS::RootedObject(cx, JSB_cpPolyShape_object), JS::NullPtr()); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cpBody* body; cpVect *verts; cpVect offset; + int numVerts; + + ok &= jsval_to_c_class( cx, args.get(0), (void**)&body, NULL ); + ok &= jsval_to_array_of_cpvect( cx, args.get(1), &verts, &numVerts); + ok &= jsval_to_cpVect( cx, args.get(2), (cpVect*) &offset ); + JSB_PRECONDITION(ok, "Error processing arguments"); + cpShape *shape = cpPolyShapeNew(body, numVerts, verts, offset); + + jsb_set_c_proxy_for_jsobject(jsobj, shape, JSB_C_FLAG_CALL_FREE); + jsb_set_jsobject_for_proxy(jsobj, shape); + + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + + free(verts); + + return true; +} + + +#pragma mark Space Free functions +// +// When the space is removed, it should all remove its children. But not "free" them. +// "free" will be performed by the JS Garbage Collector +// +// Functions copied & pasted from ChipmunkDemo.c +// https://github.com/slembcke/Chipmunk-Physics/blob/master/Demo/ChipmunkDemo.c#L89 +// + +static void unroot_jsobject_from_handle(void *handle) +{ + JSObject *jsobj = jsb_get_jsobject_for_proxy(handle); + //2014.9.19 by joshua + //add safe guard + if(jsobj) + { + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsobj); + + // HACK context from global + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RemoveObjectRoot(cx, &proxy->jsobj); + } + +} +static void shapeFreeWrap(cpSpace *space, cpShape *shape, void *unused){ + cpSpaceRemoveShape(space, shape); + unroot_jsobject_from_handle(shape); +// cpShapeFree(shape); +} + +static void postShapeFree(cpShape *shape, cpSpace *space){ + cpSpaceAddPostStepCallback(space, (cpPostStepFunc)shapeFreeWrap, shape, NULL); +} + +static void constraintFreeWrap(cpSpace *space, cpConstraint *constraint, void *unused){ + cpSpaceRemoveConstraint(space, constraint); + unroot_jsobject_from_handle(constraint); +// cpConstraintFree(constraint); +} + +static void postConstraintFree(cpConstraint *constraint, cpSpace *space){ + cpSpaceAddPostStepCallback(space, (cpPostStepFunc)constraintFreeWrap, constraint, NULL); +} + +static void bodyFreeWrap(cpSpace *space, cpBody *body, void *unused){ + cpSpaceRemoveBody(space, body); + unroot_jsobject_from_handle(body); +// cpBodyFree(body); +} + +static void postBodyFree(cpBody *body, cpSpace *space){ + cpSpaceAddPostStepCallback(space, (cpPostStepFunc)bodyFreeWrap, body, NULL); +} + +// Safe and future proof way to remove and free all objects that have been added to the space. +void static freeSpaceChildren(cpSpace *space) +{ + // Must remove these BEFORE freeing the body or you will access dangling pointers. + cpSpaceEachShape(space, (cpSpaceShapeIteratorFunc)postShapeFree, space); + cpSpaceEachConstraint(space, (cpSpaceConstraintIteratorFunc)postConstraintFree, space); + + cpSpaceEachBody(space, (cpSpaceBodyIteratorFunc)postBodyFree, space); +} + +#endif // JSB_INCLUDE_CHIPMUNK diff --git a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.h b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.h new file mode 100644 index 0000000000..c2a9060933 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2012 Zynga Inc. + * 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. + */ + + +#ifndef __js_bindings_chipmunk_manual +#define __js_bindings_chipmunk_manual + +#include "jsapi.h" +#include "js_bindings_config.h" +#include "js_manual_conversions.h" +#include "ScriptingCore.h" +#ifdef JSB_INCLUDE_CHIPMUNK + +#include "chipmunk_private.h" +#include "js_bindings_chipmunk_auto_classes.h" + +// Free Functions +bool JSB_cpSpaceAddCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpaceRemoveCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); + +bool JSB_cpArbiterGetBodies(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpArbiterGetShapes(JSContext *cx, uint32_t argc, jsval *vp); + +bool JSB_cpBodyGetUserData(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBodySetUserData(JSContext *cx, uint32_t argc, jsval *vp); + +// poly related +bool JSB_cpAreaForPoly(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpMomentForPoly(JSContext *cx, uint32_t argc, jsval *vp); +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); + +// manually wrapped for rooting/unrooting purposes +bool JSB_cpSpace_addBody(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpace_addConstraint(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpace_addShape(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpace_addStaticShape(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpace_removeBody(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpace_removeConstraint(JSContext *cx, uint32_t argc, jsval *vp); +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); + +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 + +jsval cpBB_to_jsval(JSContext *cx, cpBB bb ); +bool jsval_to_cpBB( JSContext *cx, jsval vp, cpBB *ret ); +bool jsval_to_array_of_cpvect( JSContext *cx, jsval vp, cpVect**verts, int *numVerts); +bool jsval_to_cpVect( JSContext *cx, jsval vp, cpVect *out ); +jsval cpVect_to_jsval( JSContext *cx, cpVect p ); + +// Object Oriented Chipmunk +void JSB_cpBase_createClass(JSContext* cx, JS::HandleObject globalObj, const char * name ); +extern JSObject* JSB_cpBase_object; +extern JSClass* JSB_cpBase_class; +extern void register_CCPhysicsSprite(JSContext *cx, JS::HandleObject obj); +extern void register_CCPhysicsDebugNode(JSContext *cx, JS::HandleObject obj); + +// Manual constructor / destructors +bool JSB_cpPolyShape_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void JSB_cpSpace_finalize(JSFreeOp *fop, JSObject *obj); + +#endif // JSB_INCLUDE_CHIPMUNK + +#endif // __js_bindings_chipmunk_manual diff --git a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_registration.cpp b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_registration.cpp new file mode 100644 index 0000000000..7f8ce5aab6 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_registration.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2012 Zynga Inc. + * 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. + */ + +#ifndef JSB_INCLUDE_CHIPMUNK +#define JSB_INCLUDE_CHIPMUNK +#endif + +#include "js_bindings_config.h" +#include "ScriptingCore.h" + + +// chipmunk +#include "js_bindings_chipmunk_auto_classes.h" +#include "js_bindings_chipmunk_functions.h" +#include "js_bindings_chipmunk_manual.h" + + +void jsb_register_chipmunk(JSContext* cx, JS::HandleObject object) +{ + // + // Chipmunk + // + JS::RootedObject chipmunk(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr())); + JS::RootedValue chipmunkVal(cx); + + chipmunkVal = OBJECT_TO_JSVAL(chipmunk); + JS_SetProperty(cx, object, "cp", chipmunkVal); + + JSB_cpBase_createClass(cx, chipmunk, "Base"); // manual base class registration +#include "js_bindings_chipmunk_auto_classes_registration.h" +#include "js_bindings_chipmunk_functions_registration.h" + + // 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, 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 ); + JS_DefineFunction(cx, chipmunk, "bodySetUserData", JSB_cpBodySetUserData, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE ); + + JS_DefineFunction(cx, chipmunk, "areaForPoly", JSB_cpAreaForPoly, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); + 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::RootedObject space(cx, JSB_cpSpace_object); + JS_DefineFunction(cx, space, "segmentQueryFirst", JSB_cpSpace_segmentQueryFirst, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE); + JS_DefineFunction(cx, space, "nearestPointQueryNearest", JSB_cpSpace_nearestPointQueryNearest, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE); + JS_DefineFunction(cx, space, "eachShape", JSB_cpSpace_eachShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); + JS_DefineFunction(cx, space, "eachBody", JSB_cpSpace_eachBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); + JS_DefineFunction(cx, space, "eachConstraint", JSB_cpSpace_eachConstraint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); + + register_CCPhysicsSprite(cx, object); + register_CCPhysicsDebugNode(cx, object); +} + diff --git a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_registration.h b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_registration.h new file mode 100644 index 0000000000..3df6f2a820 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_registration.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2012 Zynga Inc. + * 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. + */ + + +#ifndef __JSB_CHIPMUNK_REGISTRATION +#define __JSB_CHIPMUNK_REGISTRATION + +void jsb_register_chipmunk( JSContext *globalC, JS::HandleObject globalO); + +#endif // __JSB_CHIPMUNK_REGISTRATION diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp new file mode 100644 index 0000000000..1c53e0e0f0 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp @@ -0,0 +1,5636 @@ +/* + * Copyright (c) 2012 Zynga Inc. + * 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. + */ + +#include "cocos2d_specifics.hpp" +#include "cocos2d.h" +#include +#include "js_bindings_config.h" +#include "jsb_cocos2dx_auto.hpp" +#include "jsb_event_dispatcher_manual.h" + +using namespace cocos2d; + +schedFunc_proxy_t *_schedFunc_target_ht = NULL; +schedTarget_proxy_t *_schedObj_target_ht = NULL; + +JSTouchDelegate::TouchDelegateMap JSTouchDelegate::sTouchDelegateMap; + +JSTouchDelegate::JSTouchDelegate() +: _obj(nullptr) +, _needUnroot(false) +, _touchListenerAllAtOnce(nullptr) +, _touchListenerOneByOne(nullptr) +{ +} + +JSTouchDelegate::~JSTouchDelegate() +{ + CCLOGINFO("In the destructor of JSTouchDelegate."); +} + +void JSTouchDelegate::setDelegateForJSObject(JSObject* pJSObj, JSTouchDelegate* pDelegate) +{ + CCASSERT(sTouchDelegateMap.find(pJSObj) == sTouchDelegateMap.end(), ""); + sTouchDelegateMap.insert(TouchDelegatePair(pJSObj, pDelegate)); +} + +JSTouchDelegate* JSTouchDelegate::getDelegateForJSObject(JSObject* pJSObj) +{ + JSTouchDelegate* pRet = NULL; + TouchDelegateMap::iterator iter = sTouchDelegateMap.find(pJSObj); + if (iter != sTouchDelegateMap.end()) + { + pRet = iter->second; + } + return pRet; +} + +void JSTouchDelegate::removeDelegateForJSObject(JSObject* pJSObj) +{ + TouchDelegateMap::iterator iter = sTouchDelegateMap.find(pJSObj); + CCASSERT(iter != sTouchDelegateMap.end(), ""); + sTouchDelegateMap.erase(pJSObj); +} + +void JSTouchDelegate::setJSObject(JSObject *obj) +{ + _obj = obj; + + js_proxy_t *p = jsb_get_js_proxy(_obj); + if (!p) + { + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::AddNamedObjectRoot(cx, &_obj, "JSB_TouchDelegateTarget, target"); + _needUnroot = true; + } +} + +void JSTouchDelegate::registerStandardDelegate(int priority) +{ + auto dispatcher = Director::getInstance()->getEventDispatcher(); + dispatcher->removeEventListener(_touchListenerAllAtOnce); + + auto listener = EventListenerTouchAllAtOnce::create(); + + listener->onTouchesBegan = CC_CALLBACK_2(JSTouchDelegate::onTouchesBegan, this); + listener->onTouchesMoved = CC_CALLBACK_2(JSTouchDelegate::onTouchesMoved, this); + listener->onTouchesEnded = CC_CALLBACK_2(JSTouchDelegate::onTouchesEnded, this); + listener->onTouchesCancelled = CC_CALLBACK_2(JSTouchDelegate::onTouchesCancelled, this); + + dispatcher->addEventListenerWithFixedPriority(listener, priority); + + _touchListenerAllAtOnce = listener; +} + +void JSTouchDelegate::registerTargetedDelegate(int priority, bool swallowsTouches) +{ + auto dispatcher = Director::getInstance()->getEventDispatcher(); + dispatcher->removeEventListener(_touchListenerOneByOne); + + auto listener = EventListenerTouchOneByOne::create(); + listener->setSwallowTouches(swallowsTouches); + + listener->onTouchBegan = CC_CALLBACK_2(JSTouchDelegate::onTouchBegan, this); + listener->onTouchMoved = CC_CALLBACK_2(JSTouchDelegate::onTouchMoved, this); + listener->onTouchEnded = CC_CALLBACK_2(JSTouchDelegate::onTouchEnded, this); + listener->onTouchCancelled = CC_CALLBACK_2(JSTouchDelegate::onTouchCancelled, this); + + dispatcher->addEventListenerWithFixedPriority(listener, priority); + _touchListenerOneByOne = listener; +} + +void JSTouchDelegate::unregisterTouchDelegate() +{ + if (_needUnroot) + { + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RemoveObjectRoot(cx, &_obj); + } + + auto dispatcher = Director::getInstance()->getEventDispatcher(); + dispatcher->removeEventListener(_touchListenerAllAtOnce); + dispatcher->removeEventListener(_touchListenerOneByOne); + + this->release(); +} + +bool JSTouchDelegate::onTouchBegan(Touch *touch, Event *event) +{ + CC_UNUSED_PARAM(event); + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedValue retval(cx); + bool bRet = false; + + ScriptingCore::getInstance()->executeCustomTouchEvent(EventTouch::EventCode::BEGAN, + touch, _obj.get(), &retval); + + if(retval.isBoolean()) + { + bRet = retval.toBoolean(); + } + + return bRet; +}; +// optional + +void JSTouchDelegate::onTouchMoved(Touch *touch, Event *event) +{ + CC_UNUSED_PARAM(event); + + ScriptingCore::getInstance()->executeCustomTouchEvent(EventTouch::EventCode::MOVED, + touch, _obj); +} + +void JSTouchDelegate::onTouchEnded(Touch *touch, Event *event) +{ + CC_UNUSED_PARAM(event); + + ScriptingCore::getInstance()->executeCustomTouchEvent(EventTouch::EventCode::ENDED, + touch, _obj); +} + +void JSTouchDelegate::onTouchCancelled(Touch *touch, Event *event) +{ + CC_UNUSED_PARAM(event); + ScriptingCore::getInstance()->executeCustomTouchEvent(EventTouch::EventCode::CANCELLED, + touch, _obj); +} + +// optional +void JSTouchDelegate::onTouchesBegan(const std::vector& touches, Event *event) +{ + CC_UNUSED_PARAM(event); + ScriptingCore::getInstance()->executeCustomTouchesEvent(EventTouch::EventCode::BEGAN, touches, _obj); +} + +void JSTouchDelegate::onTouchesMoved(const std::vector& touches, Event *event) +{ + CC_UNUSED_PARAM(event); + ScriptingCore::getInstance()->executeCustomTouchesEvent(EventTouch::EventCode::MOVED, touches, _obj); +} + +void JSTouchDelegate::onTouchesEnded(const std::vector& touches, Event *event) +{ + CC_UNUSED_PARAM(event); + ScriptingCore::getInstance()->executeCustomTouchesEvent(EventTouch::EventCode::ENDED, touches, _obj); +} + +void JSTouchDelegate::onTouchesCancelled(const std::vector& touches, Event *event) +{ + CC_UNUSED_PARAM(event); + ScriptingCore::getInstance()->executeCustomTouchesEvent(EventTouch::EventCode::CANCELLED, touches, _obj); +} + +// cc.EventTouch#getTouches +bool js_cocos2dx_EventTouch_getTouches(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::EventTouch* cobj = (cocos2d::EventTouch *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventTouch_getTouches : Invalid Native Object"); + if (argc == 0) { + const std::vector& ret = cobj->getTouches(); + JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, 0)); + + int i = 0; + for (cocos2d::Touch* touchObj : ret) + { + JS::RootedValue arrElement(cx); + + //First, check whether object is associated with js object. + js_proxy_t* jsproxy = js_get_or_create_proxy(cx, touchObj); + if (jsproxy) { + arrElement = OBJECT_TO_JSVAL(jsproxy->obj); + } + if (!JS_SetElement(cx, jsretArr, i, arrElement)) { + break; + } + ++i; + } + +// JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsretArr)); + args.rval().set(OBJECT_TO_JSVAL(jsretArr)); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventTouch_getTouches : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +// cc.EventTouch#setTouches +bool js_cocos2dx_EventTouch_setTouches(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, 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::EventTouch* cobj = (cocos2d::EventTouch *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EventTouch_setTouches : Invalid Native Object"); + if (argc == 1) { + std::vector arg0; + JS::RootedObject jsobj(cx, args.get(0).toObjectOrNull()); +// ok = argv->isObject() && JS_ValueToObject( cx, JS::RootedValue(cx, *argv), &jsobj ); + JSB_PRECONDITION3( ok, cx, false, "Error converting value to object"); + JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, false, "Object must be an array"); + + uint32_t len = 0; + JS_GetArrayLength(cx, jsobj, &len); + + for (uint32_t i=0; i < len; i++) + { + JS::RootedValue value(cx); + if (JS_GetElement(cx, jsobj, i, &value)) + { + JSObject *tmp = value.toObjectOrNull(); + proxy = jsb_get_js_proxy(tmp); + cocos2d::Touch* touchObj = (cocos2d::Touch *)(proxy ? proxy->ptr : NULL); + if (touchObj) { + arg0.push_back(touchObj); + } + } + } + cobj->setTouches(arg0); +// args.rval().setUndefined(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EventTouch_setTouches : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +static void addCallBackAndThis(JSObject *obj, jsval callback, jsval &thisObj) +{ + if(callback != JSVAL_VOID) { + ScriptingCore::getInstance()->setReservedSpot(0, obj, callback); + } + if(thisObj != JSVAL_VOID) { + ScriptingCore::getInstance()->setReservedSpot(1, obj, thisObj); + } +} + +template +JSObject* bind_menu_item(JSContext *cx, T* nativeObj, jsval callback, jsval thisObj) { + js_proxy_t *p = jsb_get_native_proxy(nativeObj); + if (p) { + addCallBackAndThis(p->obj, callback, thisObj); + return p->obj; + } else { + js_type_class_t *classType = js_get_type_from_native(nativeObj); + assert(classType); + JS::RootedObject proto(cx, classType->proto); + JS::RootedObject parent(cx, classType->parentProto); + JSObject *tmp = JS_NewObject(cx, classType->jsclass, proto, parent); + + // bind nativeObj <-> JSObject + js_proxy_t *proxy = jsb_new_proxy(nativeObj, tmp); + JS::AddNamedObjectRoot(cx, &proxy->obj, typeid(*nativeObj).name()); + addCallBackAndThis(tmp, callback, thisObj); + + return tmp; + } +} + +bool js_cocos2dx_CCMenu_create(JSContext *cx, uint32_t argc, jsval *vp) +{ +// jsval *argv = JS_ARGV(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc > 0) { + Vector items; + uint32_t i = 0; + while (i < argc) { + js_proxy_t *proxy; + JSObject *tmpObj = args.get(i).toObjectOrNull(); + proxy = jsb_get_js_proxy(tmpObj); + cocos2d::MenuItem *item = (cocos2d::MenuItem*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, item) + items.pushBack(item); + i++; + } + cocos2d::Menu* ret = cocos2d::Menu::createWithArray(items); + jsval jsret; + do { + if (ret) { + js_proxy_t *p = jsb_get_native_proxy(ret); + if (p) { + jsret = OBJECT_TO_JSVAL(p->obj); + } else { + // create a new js obj of that class + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + } else { + jsret = JSVAL_NULL; + } + } while (0); +// args.rval().set(jsret); + args.rval().set(jsret); + return true; + } + if (argc == 0) { + cocos2d::Menu* ret = cocos2d::Menu::create(); + jsval jsret; + do { + if (ret) { + js_proxy_t *p = jsb_get_native_proxy(ret); + if (p) { + jsret = OBJECT_TO_JSVAL(p->obj); + } else { + // create a new js obj of that class + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + } else { + jsret = JSVAL_NULL; + } + } while (0); +// JS_SET_RVAL(cx, vp, jsret); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "wrong number of arguments"); + return false; +} + +bool js_cocos2dx_CCSequence_create(JSContext *cx, uint32_t argc, jsval *vp) +{ +// jsval *argv = JS_ARGV(cx, vp); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc > 0) { + Vector array; + if (argc == 1 && JS_IsArrayObject(cx, JS::RootedObject(cx, args.get(0).toObjectOrNull()))) { + bool ok = true; + ok &= jsval_to_ccvector(cx, args.get(0), &array); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + } else { + uint32_t i = 0; + while (i < argc) { + js_proxy_t *proxy; + JSObject *tmpObj = args.get(i).toObjectOrNull(); + proxy = jsb_get_js_proxy(tmpObj); + cocos2d::FiniteTimeAction *item = (cocos2d::FiniteTimeAction*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, item) + array.pushBack(item); + i++; + } + } + cocos2d::FiniteTimeAction* ret = cocos2d::Sequence::create(array); + jsval jsret; + do { + if (ret) { + js_proxy_t *p = jsb_get_native_proxy(ret); + if (p) { + jsret = OBJECT_TO_JSVAL(p->obj); + } else { + // create a new js obj of that class + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + } else { + jsret = JSVAL_NULL; + } + } while (0); +// JS_SET_RVAL(cx, vp, jsret); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "wrong number of arguments"); + return false; +} + +bool js_cocos2dx_CCSpawn_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc > 0) { + Vector array; + if (argc == 1 && JS_IsArrayObject(cx, JS::RootedObject(cx, args.get(0).toObjectOrNull()))) { + bool ok = true; + ok &= jsval_to_ccvector(cx, args.get(0), &array); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + } else { + uint32_t i = 0; + while (i < argc) { + js_proxy_t *proxy; + JSObject *tmpObj = args[i].toObjectOrNull(); + proxy = jsb_get_js_proxy(tmpObj); + cocos2d::FiniteTimeAction *item = (cocos2d::FiniteTimeAction*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, item) + array.pushBack(item); + i++; + } + } + cocos2d::FiniteTimeAction* ret = cocos2d::Spawn::create(array); + jsval jsret; + do { + if (ret) { + js_proxy_t *p = jsb_get_native_proxy(ret); + if (p) { + jsret = OBJECT_TO_JSVAL(p->obj); + } else { + // create a new js obj of that class + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "wrong number of arguments"); + return false; +} + +bool js_cocos2dx_CCMenuItem_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc >= 1) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + cocos2d::MenuItem* ret = cocos2d::MenuItem::create(); + JSObject *obj = bind_menu_item(cx, ret, args.get(0), argc == 2? args.get(1) : JSVAL_VOID); + args.rval().set(OBJECT_TO_JSVAL(obj)); + return true; + } + JS_ReportError(cx, "wrong number of arguments"); + return false; +} + +// "create" in JS +// cc.MenuItemSprite.create( normalSprite, selectedSprite, [disabledSprite], [callback_fn], [this] +bool js_cocos2dx_CCMenuItemSprite_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc >= 2 && argc <= 5) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + js_proxy_t *proxy; + JSObject *tmpObj; + + tmpObj = args.get(0).toObjectOrNull(); + proxy = jsb_get_js_proxy(tmpObj); + cocos2d::Node* arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, arg0); + + tmpObj = args.get(1).toObjectOrNull(); + proxy = jsb_get_js_proxy(tmpObj); + cocos2d::Node* arg1 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, arg1); + + int last = 2; + bool thirdArgIsCallback = false; + + jsval jsCallback = JSVAL_VOID; + jsval jsThis = JSVAL_VOID; + + cocos2d::Node* arg2 = NULL; + if (argc >= 3) { + tmpObj = args.get(2).toObjectOrNull(); + thirdArgIsCallback = JS_ObjectIsFunction(cx, tmpObj); + if (!thirdArgIsCallback) { + proxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, arg2); + last = 3; + } + } + cocos2d::MenuItemSprite* ret = cocos2d::MenuItemSprite::create(arg0, arg1, arg2); + if (argc >= 3) { + if (thirdArgIsCallback) { + //cc.MenuItemSprite.create( normalSprite, selectedSprite, callback_fn, [this] ) + jsCallback = args.get(last++); + if (argc == 4) { + jsThis = args.get(last); + } + } + else { + //cc.MenuItemSprite.create( normalSprite, selectedSprite, disabledSprite, callback_fn, [this] ) + if (argc >= 4) { + jsCallback = args.get(last++); + if (argc == 5) { + jsThis = args.get(last); + } + } + } + } + + JSObject *obj = bind_menu_item(cx, ret, jsCallback, jsThis); + + args.rval().set(OBJECT_TO_JSVAL(obj)); + return true; + } + JS_ReportError(cx, "Invalid number of arguments. Expecting: 2 <= args <= 5"); + return false; +} + +// "create" in JS: +// cc.MenuItemLabel.create( label, callback_fn, [this] ); +bool js_cocos2dx_CCMenuItemLabel_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc >= 1 && argc <= 3) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + js_proxy_t *proxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + proxy = jsb_get_js_proxy(tmpObj); + cocos2d::Node* arg0 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, arg0) + cocos2d::MenuItemLabel* ret = cocos2d::MenuItemLabel::create(arg0); + JSObject *obj = bind_menu_item(cx, ret, (argc >= 2 ? args.get(1) : JSVAL_VOID), (argc == 3 ? args.get(2) : JSVAL_VOID) ); + args.rval().set(OBJECT_TO_JSVAL(obj)); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d or %d or %d", argc, 1, 2, 3); + return false; +} + +bool js_cocos2dx_CCMenuItemAtlasFont_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc >= 5) { + bool ok = true; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSStringWrapper arg0(args.get(0)); + JSStringWrapper arg1(args.get(1)); + int arg2; ok &= jsval_to_int32(cx, args.get(2), &arg2); + int arg3; ok &= jsval_to_int32(cx, args.get(3), &arg3); + int arg4; ok &= jsval_to_int32(cx, args.get(4), &arg4); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cocos2d::MenuItemAtlasFont* ret = cocos2d::MenuItemAtlasFont::create(arg0.get(), arg1.get(), arg2, arg3, arg4); + JSObject *obj = bind_menu_item(cx, ret, (argc >= 6 ? args.get(5) : JSVAL_VOID), (argc == 7 ? args.get(6) : JSVAL_VOID)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + return true; + } + JS_ReportError(cx, "wrong number of arguments"); + return false; +} + +// "create" in JS +// cc.MenuItemFont.create( string, callback_fn, [this] ); +bool js_cocos2dx_CCMenuItemFont_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc >= 1 && argc <= 3) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSStringWrapper arg0(args.get(0)); + cocos2d::MenuItemFont* ret = cocos2d::MenuItemFont::create(arg0.get()); + JSObject *obj = bind_menu_item(cx, ret, (argc >= 2 ? args.get(1) : JSVAL_VOID), (argc == 3 ? args.get(2) : JSVAL_VOID)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d or %d or %d", argc, 1, 2, 3); + return false; +} + + +bool js_cocos2dx_CCMenuItemToggle_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc >= 1) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + cocos2d::MenuItemToggle* ret = cocos2d::MenuItemToggle::create(); + + for (uint32_t i=0; i < argc; i++) { + js_proxy_t *proxy; + JSObject *tmpObj = args.get(i).toObjectOrNull(); + proxy = jsb_get_js_proxy(tmpObj); + cocos2d::MenuItem* item = (cocos2d::MenuItem*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, item) + ret->addSubItem(item); + } + + ret->setSelectedIndex(0); + + jsval jsret; + if (ret) { + js_proxy_t *proxy = jsb_get_native_proxy(ret); + if (proxy) { + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + // create a new js obj of that class + proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + } else { + jsret = JSVAL_NULL; + } + + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "wrong number of arguments"); + return false; +} + +bool js_cocos2dx_MenuItem_setCallback(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::MenuItem* cobj = (cocos2d::MenuItem *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_MenuItem_setCallback : Invalid Native Object"); + if (argc == 1 || argc == 2) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, args[0]) == JSTYPE_FUNCTION) + { + JSObject* thisObj; + if (args.get(1).isObject()) + { + thisObj = args.get(1).toObjectOrNull(); + } + else + { + thisObj = JS_THIS_OBJECT(cx, vp); + } + std::shared_ptr func(new JSFunctionWrapper(cx, thisObj, args[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); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + JS::RootedValue rval(cx); + 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_setCallback : Error processing arguments"); + cobj->setCallback(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_MenuItem_setCallback : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_CCAnimation_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + bool ok = true; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc <= 3) { + cocos2d::Animation* ret = nullptr; + double arg1 = 0.0f; + if (argc == 2) { + Vector arg0; + if (argc > 0) { + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + } + ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(1)), &arg1); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + ret = cocos2d::Animation::createWithSpriteFrames(arg0, arg1); + } else if (argc == 3) { + Vector arg0; + if (argc > 0) { + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + } + unsigned int loops; + ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(1)), &arg1); + ok &= jsval_to_uint32(cx, args.get(2), &loops); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + ret = cocos2d::Animation::create(arg0, arg1, loops); + } else if (argc == 1) { + Vector arg0; + if (argc > 0) { + ok &= jsval_to_ccvector(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + } + ret = cocos2d::Animation::createWithSpriteFrames(arg0); + } else if (argc == 0) { + ret = cocos2d::Animation::create(); + } + jsval jsret; + if (ret) { + js_proxy_t *proxy = jsb_get_native_proxy(ret); + if (proxy) { + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + // create a new js obj of that class + proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + } else { + jsret = JSVAL_NULL; + } + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "wrong number of arguments"); + return false; +} + +bool js_cocos2dx_CCScene_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scene* cobj = (cocos2d::Scene *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Scene_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Scene_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +bool js_cocos2dx_CCLayerMultiplex_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + Vector arg0; + bool ok = true; + ok &= jsvals_variadic_to_ccvector(cx, args, &arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cocos2d::LayerMultiplex* ret = cocos2d::LayerMultiplex::createWithArray(arg0); + jsval jsret; + do { + if (ret) { + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; +} + +bool js_cocos2dx_JSTouchDelegate_registerStandardDelegate(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc == 1 || argc == 2) + { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsobj = NULL; + + JSTouchDelegate *touch = new JSTouchDelegate(); + + int priority = 1; + if (argc == 2) + { + priority = args.get(1).toInt32(); + } + + touch->registerStandardDelegate(priority); + + jsobj = args.get(0).toObjectOrNull(); + touch->setJSObject(jsobj); + JSTouchDelegate::setDelegateForJSObject(jsobj, touch); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} + +bool js_cocos2dx_JSTouchDelegate_registerTargetedDelegate(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc == 3) + { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsobj = NULL; + + JSTouchDelegate *touch = new JSTouchDelegate(); + touch->registerTargetedDelegate(args.get(0).toInt32(), args.get(1).toBoolean()); + + jsobj = args.get(2).toObjectOrNull(); + touch->setJSObject(jsobj); + JSTouchDelegate::setDelegateForJSObject(jsobj, touch); + + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} + +bool js_cocos2dx_JSTouchDelegate_unregisterTouchDelegate(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc == 1) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsobj = args.get(0).toObjectOrNull(); + JSTouchDelegate* pDelegate = JSTouchDelegate::getDelegateForJSObject(jsobj); + if (pDelegate) + { + pDelegate->unregisterTouchDelegate(); + JSTouchDelegate::removeDelegateForJSObject(jsobj); + } + + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +JSObject* getObjectFromNamespace(JSContext* cx, JS::HandleObject ns, const char *name) { + JS::RootedValue out(cx); + bool ok = true; + if (JS_GetProperty(cx, ns, name, &out) == true) { + JS::RootedObject obj(cx); + ok &= JS_ValueToObject(cx, out, &obj); + JSB_PRECONDITION2(ok, cx, NULL, "Error processing arguments"); + } + return NULL; +} + +jsval anonEvaluate(JSContext *cx, JS::HandleObject thisObj, const char* string) { + JS::RootedValue out(cx); + //JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + if (JS_EvaluateScript(cx, thisObj, string, strlen(string), "(string)", 1, &out) == true) { + return out.get(); + } + return JSVAL_VOID; +} + +JSCallbackWrapper::JSCallbackWrapper() +: _jsCallback(JSVAL_VOID), _jsThisObj(JSVAL_VOID), _extraData(JSVAL_VOID) +{ + +} + +JSCallbackWrapper::~JSCallbackWrapper() +{ + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RemoveValueRoot(cx, &_jsCallback); + JS::RemoveValueRoot(cx, &_jsThisObj); +} + +void JSCallbackWrapper::setJSCallbackFunc(jsval func) { + _jsCallback = func; + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + // Root the callback function. + JS::AddNamedValueRoot(cx, &_jsCallback, "JSCallbackWrapper_callback_func"); +} + +void JSCallbackWrapper::setJSCallbackThis(jsval thisObj) { + _jsThisObj = thisObj; + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + // Root the this object. + JS::AddNamedValueRoot(cx, &_jsThisObj, "JSCallbackWrapper_callback_this"); +} + +void JSCallbackWrapper::setJSExtraData(jsval data) { + _extraData = data; +} + +const jsval& JSCallbackWrapper::getJSCallbackFunc() const +{ + return _jsCallback.get(); +} + +const jsval& JSCallbackWrapper::getJSCallbackThis() const +{ + return _jsThisObj.get(); +} + +const jsval& JSCallbackWrapper::getJSExtraData() const +{ + return _extraData.get(); +} + +// cc.CallFunc.create( func, this, [data]) +// cc.CallFunc.create( func ) +static bool js_callFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc >= 1 && argc <= 3) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + std::shared_ptr tmpCobj(new JSCallbackWrapper()); + + tmpCobj->setJSCallbackFunc(args.get(0)); + if(argc >= 2) { + tmpCobj->setJSCallbackThis(args.get(1)); + } if(argc == 3) { + tmpCobj->setJSExtraData(args.get(2)); + } + + CallFuncN *ret = CallFuncN::create([=](Node* sender){ +// const jsval& jsvalThis = tmpCobj->getJSCallbackThis(); +// const jsval& jsvalCallback = tmpCobj->getJSCallbackFunc(); +// const jsval& jsvalExtraData = tmpCobj->getJSExtraData(); + JS::RootedValue jsvalThis(cx, tmpCobj->getJSCallbackThis()); + JS::RootedValue jsvalCallback(cx, tmpCobj->getJSCallbackFunc()); + JS::RootedValue jsvalExtraData(cx, tmpCobj->getJSExtraData()); + + bool hasExtraData = !jsvalExtraData.isUndefined(); + JS::RootedObject thisObj(cx, jsvalThis.toObjectOrNull()); + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + if(sender) + { + js_proxy_t *proxy = js_get_or_create_proxy(cx, sender); + + JS::RootedValue retval(cx); + if(jsvalCallback != JSVAL_VOID) + { + if (hasExtraData) + { + jsval valArr[2]; + valArr[0] = OBJECT_TO_JSVAL(proxy->obj); + valArr[1] = jsvalExtraData; + + //TODO: really need root? +// JS_AddValueRoot(cx, valArr); + JS::HandleValueArray args = JS::HandleValueArray::fromMarkedLocation(2, valArr); + JS_CallFunctionValue(cx, thisObj, jsvalCallback, args, &retval); +// JS_RemoveValueRoot(cx, valArr); + } + else + { + jsval senderVal = OBJECT_TO_JSVAL(proxy->obj); + JS::HandleValueArray args = JS::HandleValueArray::fromMarkedLocation(1, &senderVal); +// JS_AddValueRoot(cx, &senderVal); + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JS_CallFunctionValue(cx, thisObj, jsvalCallback, args, &retval); +// JS_RemoveValueRoot(cx, &senderVal); + } + } + } + else + { + JS::RootedValue ret(cx); + JS_CallFunctionValue(cx, thisObj, jsvalCallback, JS::HandleValueArray::empty(), &ret); + } + + // I think the JSCallFuncWrapper isn't needed. + // Since an action will be run by a cc.Node, it will be released at the Node::cleanup. + // By James Chen + // JSCallFuncWrapper::setTargetForNativeNode(node, (JSCallFuncWrapper *)this); + }); + + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + args.rval().set(OBJECT_TO_JSVAL(proxy->obj)); + + JS_SetReservedSlot(proxy->obj, 0, args.get(0)); + if(argc > 1) { + JS_SetReservedSlot(proxy->obj, 1, args.get(1)); + } +// if(argc == 3) { +// JS_SetReservedSlot(proxy->obj, 2, args.get(2)); +// } + + // test->execute(); + return true; + } + JS_ReportError(cx, "Invalid number of arguments"); + return false; +} + +// callFunc.initWithFunction( func, this, [data]) +// callFunc.initWithFunction( func ) +bool js_cocos2dx_CallFunc_initWithFunction(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc >= 1 && argc <= 3) { + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + CallFuncN *action = (cocos2d::CallFuncN *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2(action, cx, false, "Invalid Native Object"); + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + std::shared_ptr tmpCobj(new JSCallbackWrapper()); + + tmpCobj->setJSCallbackFunc(args.get(0)); + if(argc >= 2) { + tmpCobj->setJSCallbackThis(args.get(1)); + } if(argc == 3) { + tmpCobj->setJSExtraData(args.get(2)); + } + + action->initWithFunction([=](Node* sender){ +// const jsval& jsvalThis = tmpCobj->getJSCallbackThis(); +// const jsval& jsvalCallback = tmpCobj->getJSCallbackFunc(); +// const jsval& jsvalExtraData = tmpCobj->getJSExtraData(); + JS::RootedValue jsvalThis(cx, tmpCobj->getJSCallbackThis()); + JS::RootedValue jsvalCallback(cx, tmpCobj->getJSCallbackFunc()); + JS::RootedValue jsvalExtraData(cx, tmpCobj->getJSExtraData()); + + bool hasExtraData = !jsvalExtraData.isUndefined(); + JS::RootedObject thisObj(cx, jsvalThis.toObjectOrNull()); + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + if(sender) + { + js_proxy_t *proxy = js_get_or_create_proxy(cx, sender); + + JS::RootedValue retval(cx); + if(jsvalCallback != JSVAL_VOID) + { + if (hasExtraData) + { + jsval valArr[2]; + valArr[0] = OBJECT_TO_JSVAL(proxy->obj); + valArr[1] = jsvalExtraData; + +// JS_AddValueRoot(cx, valArr); +// JS_CallFunctionValue(cx, thisObj, jsvalCallback, 2, valArr, &retval); +// JS_RemoveValueRoot(cx, valArr); + + JS::HandleValueArray args = JS::HandleValueArray::fromMarkedLocation(2, valArr); + JS_CallFunctionValue(cx, thisObj, jsvalCallback, args, &retval); + } + else + { + jsval senderVal = OBJECT_TO_JSVAL(proxy->obj); +// JS_AddValueRoot(cx, &senderVal); +// JS_CallFunctionValue(cx, thisObj, jsvalCallback, 1, &senderVal, &retval); +// JS_RemoveValueRoot(cx, &senderVal); + + JS::HandleValueArray args = JS::HandleValueArray::fromMarkedLocation(1, &senderVal); + JS_CallFunctionValue(cx, thisObj, jsvalCallback, args, &retval); + } + } + } + else + { + JS::RootedValue ret(cx); + JS_CallFunctionValue(cx, thisObj, jsvalCallback, JS::HandleValueArray::empty(), &ret); + } + + + // I think the JSCallFuncWrapper isn't needed. + // Since an action will be run by a cc.Node, it will be released at the Node::cleanup. + // By James Chen + // JSCallFuncWrapper::setTargetForNativeNode(node, (JSCallFuncWrapper *)this); + }); + + JS_SetReservedSlot(proxy->obj, 0, args.get(0)); + if(argc > 1) { + JS_SetReservedSlot(proxy->obj, 1, args.get(1)); + } + return true; + } + JS_ReportError(cx, "Invalid number of arguments"); + return false; +} + +JSScheduleWrapper::~JSScheduleWrapper() +{ + if (_pPureJSTarget.get()) { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RemoveObjectRoot(cx, &_pPureJSTarget); + } +} + +void JSScheduleWrapper::setTargetForSchedule(JS::HandleValue sched, JSScheduleWrapper *target) { + do { + JSObject* jsfunc = sched.toObjectOrNull(); + auto targetArray = getTargetForSchedule(sched); + if (NULL == targetArray) { + targetArray = new __Array(); + targetArray->init(); + schedFunc_proxy_t *p = (schedFunc_proxy_t *)malloc(sizeof(schedFunc_proxy_t)); + assert(p); + p->jsfuncObj = jsfunc; + p->targets = targetArray; + HASH_ADD_PTR(_schedFunc_target_ht, jsfuncObj, p); + } + + CCASSERT(!targetArray->containsObject(target), "The target was already added."); + + targetArray->addObject(target); + } while(0); +} + +__Array * JSScheduleWrapper::getTargetForSchedule(JS::HandleValue sched) { + schedFunc_proxy_t *t = NULL; + JSObject *o = sched.toObjectOrNull(); + HASH_FIND_PTR(_schedFunc_target_ht, &o, t); + return t != NULL ? t->targets : NULL; +} + + +void JSScheduleWrapper::setTargetForJSObject(JS::HandleObject jsTargetObj, JSScheduleWrapper *target) +{ + auto targetArray = getTargetForJSObject(jsTargetObj); + if (NULL == targetArray) { + targetArray = new __Array(); + targetArray->init(); + schedTarget_proxy_t *p = (schedTarget_proxy_t *)malloc(sizeof(schedTarget_proxy_t)); + assert(p); + p->jsTargetObj = jsTargetObj; + p->targets = targetArray; + HASH_ADD_PTR(_schedObj_target_ht, jsTargetObj, p); + } + + CCASSERT(!targetArray->containsObject(target), "The target was already added."); + targetArray->addObject(target); +} + +__Array * JSScheduleWrapper::getTargetForJSObject(JS::HandleObject jsTargetObj) +{ + schedTarget_proxy_t *t = NULL; + HASH_FIND_PTR(_schedObj_target_ht, &jsTargetObj.get(), t); + return t != NULL ? t->targets : NULL; +} + +void JSScheduleWrapper::removeAllTargets() +{ + CCLOGINFO("removeAllTargets begin"); + dump(); + + { + schedFunc_proxy_t *current, *tmp; + HASH_ITER(hh, _schedFunc_target_ht, current, tmp) { + current->targets->removeAllObjects(); + current->targets->release(); + HASH_DEL(_schedFunc_target_ht, current); + free(current); + } + } + + { + schedTarget_proxy_t *current, *tmp; + HASH_ITER(hh, _schedObj_target_ht, current, tmp) { + current->targets->removeAllObjects(); + current->targets->release(); + HASH_DEL(_schedObj_target_ht, current); + free(current); + } + } + + dump(); + CCLOGINFO("removeAllTargets end"); +} + +void JSScheduleWrapper::removeAllTargetsForMinPriority(int minPriority) +{ + CCLOGINFO("removeAllTargetsForPriority begin"); + dump(); + + { + schedFunc_proxy_t *current, *tmp; + HASH_ITER(hh, _schedFunc_target_ht, current, tmp) { + std::vector objectsNeedToBeReleased; + auto targets = current->targets; + Ref* pObj = NULL; + CCARRAY_FOREACH(targets, pObj) + { + JSScheduleWrapper* wrapper = static_cast(pObj); + bool isUpdateSchedule = wrapper->isUpdateSchedule(); + if (!isUpdateSchedule || (isUpdateSchedule && wrapper->getPriority() >= minPriority)) + { + objectsNeedToBeReleased.push_back(pObj); + } + } + + std::vector::iterator iter = objectsNeedToBeReleased.begin(); + for (; iter != objectsNeedToBeReleased.end(); ++iter) + { + targets->removeObject(*iter, true); + } + + if (targets->count() == 0) + { + HASH_DEL(_schedFunc_target_ht, current); + targets->release(); + free(current); + } + } + } + + { + schedTarget_proxy_t *current, *tmp; + HASH_ITER(hh, _schedObj_target_ht, current, tmp) { + std::vector objectsNeedToBeReleased; + auto targets = current->targets; + Ref* pObj = NULL; + CCARRAY_FOREACH(targets, pObj) + { + JSScheduleWrapper* wrapper = static_cast(pObj); + bool isUpdateSchedule = wrapper->isUpdateSchedule(); + if (!isUpdateSchedule || (isUpdateSchedule && wrapper->getPriority() >= minPriority)) + { + CCLOG("isUpdateSchedule2:%d", isUpdateSchedule); + objectsNeedToBeReleased.push_back(pObj); + } + } + + auto iter = objectsNeedToBeReleased.begin(); + for (; iter != objectsNeedToBeReleased.end(); ++iter) + { + targets->removeObject(*iter, true); + } + + if (targets->count() == 0) + { + HASH_DEL(_schedObj_target_ht, current); + targets->release(); + free(current); + } + } + } + + dump(); + CCLOGINFO("removeAllTargetsForPriority end"); +} + +void JSScheduleWrapper::removeAllTargetsForJSObject(JS::HandleObject jsTargetObj) +{ + CCLOGINFO("removeAllTargetsForNatiaveNode begin"); + dump(); + __Array* removeNativeTargets = NULL; + schedTarget_proxy_t *t = NULL; + HASH_FIND_PTR(_schedObj_target_ht, &jsTargetObj.get(), t); + if (t != NULL) { + removeNativeTargets = t->targets; + HASH_DEL(_schedObj_target_ht, t); + } + + if (removeNativeTargets == NULL) return; + + schedFunc_proxy_t *current, *tmp; + HASH_ITER(hh, _schedFunc_target_ht, current, tmp) { + std::vector objectsNeedToBeReleased; + auto targets = current->targets; + Ref* pObj = NULL; + CCARRAY_FOREACH(targets, pObj) + { + if (removeNativeTargets->containsObject(pObj)) + { + objectsNeedToBeReleased.push_back(pObj); + } + } + + auto iter = objectsNeedToBeReleased.begin(); + for (; iter != objectsNeedToBeReleased.end(); ++iter) + { + targets->removeObject(*iter, true); + } + + if (targets->count() == 0) + { + HASH_DEL(_schedFunc_target_ht, current); + targets->release(); + free(current); + } + } + + removeNativeTargets->removeAllObjects(); + removeNativeTargets->release(); + free(t); + dump(); + CCLOGINFO("removeAllTargetsForNatiaveNode end"); +} + +void JSScheduleWrapper::removeTargetForJSObject(JS::HandleObject jsTargetObj, JSScheduleWrapper* target) +{ + CCLOGINFO("removeTargetForJSObject begin"); + dump(); + schedTarget_proxy_t *t = NULL; + HASH_FIND_PTR(_schedObj_target_ht, &jsTargetObj.get(), t); + if (t != NULL) { + t->targets->removeObject(target); + if (t->targets->count() == 0) + { + t->targets->release(); + HASH_DEL(_schedObj_target_ht, t); + free(t); + } + } + + schedFunc_proxy_t *current, *tmp, *removed=NULL; + + HASH_ITER(hh, _schedFunc_target_ht, current, tmp) { + auto targets = current->targets; + Ref* pObj = NULL; + + CCARRAY_FOREACH(targets, pObj) + { + JSScheduleWrapper* pOneTarget = static_cast(pObj); + if (pOneTarget == target) + { + removed = current; + break; + } + } + if (removed) break; + } + + if (removed) + { + removed->targets->removeObject(target); + if (removed->targets->count() == 0) + { + removed->targets->release(); + HASH_DEL(_schedFunc_target_ht, removed); + free(removed); + } + } + dump(); + CCLOGINFO("removeTargetForJSObject end"); +} + +void JSScheduleWrapper::dump() +{ +#if COCOS2D_DEBUG > 1 + CCLOG("\n---------JSScheduleWrapper dump begin--------------\n"); + CCLOG("target hash count = %d, func hash count = %d", HASH_COUNT(_schedObj_target_ht), HASH_COUNT(_schedFunc_target_ht)); + schedTarget_proxy_t *current, *tmp; + int nativeTargetsCount = 0; + HASH_ITER(hh, _schedObj_target_ht, current, tmp) { + Ref* pObj = NULL; + CCARRAY_FOREACH(current->targets, pObj) + { + CCLOG("js target ( %p ), native target[%d]=( %p )", current->jsTargetObj, nativeTargetsCount, pObj); + nativeTargetsCount++; + } + } + + CCLOG("\n-----------------------------\n"); + + schedFunc_proxy_t *current_func, *tmp_func; + int jsfuncTargetCount = 0; + HASH_ITER(hh, _schedFunc_target_ht, current_func, tmp_func) { + Ref* pObj = NULL; + CCARRAY_FOREACH(current_func->targets, pObj) + { + CCLOG("js func ( %p ), native target[%d]=( %p )", current_func->jsfuncObj, jsfuncTargetCount, pObj); + jsfuncTargetCount++; + } + } + CCASSERT(nativeTargetsCount == jsfuncTargetCount, ""); + CCLOG("\n---------JSScheduleWrapper dump end--------------\n"); +#endif +} + +void JSScheduleWrapper::scheduleFunc(float dt) +{ + jsval data = DOUBLE_TO_JSVAL(dt); + + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + + //XXX: really need root? +// bool ok = JS_AddValueRoot(cx, &data); +// if (!ok) { +// CCLOG("scheduleFunc: Root value fails."); +// return; +// } + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + if(!_jsCallback.isNullOrUndefined()) { + JS::HandleValueArray args = JS::HandleValueArray::fromMarkedLocation(1, &data); + JS::RootedValue retval(cx); + JS_CallFunctionValue(cx, JS::RootedObject(cx, _jsThisObj.toObjectOrNull()), JS::RootedValue(cx, _jsCallback.get()), args, &retval); + } + +// JS_RemoveValueRoot(cx, &data); +} + +void JSScheduleWrapper::update(float dt) +{ + jsval data = DOUBLE_TO_JSVAL(dt); + + //XXX: really need root? +// JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + +// bool ok = JS_AddValueRoot(cx, &data); +// if (!ok) { +// CCLOG("scheduleFunc: Root value fails."); +// return; +// } + + ScriptingCore::getInstance()->executeFunctionWithOwner(_jsThisObj, "update", 1, &data); + +// JS_RemoveValueRoot(cx, &data); +} + +Ref* JSScheduleWrapper::getTarget() +{ + return _pTarget; +} + +void JSScheduleWrapper::setTarget(Ref* pTarget) +{ + _pTarget = pTarget; +} + +void JSScheduleWrapper::setPureJSTarget(JS::HandleObject pPureJSTarget) +{ + CCASSERT(_pPureJSTarget == NULL, "The pure js target has been set"); + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + _pPureJSTarget = pPureJSTarget; + JS::AddNamedObjectRoot(cx, &_pPureJSTarget, "Pure JS target"); +} + +JSObject* JSScheduleWrapper::getPureJSTarget() +{ + return _pPureJSTarget.get(); +} + +void JSScheduleWrapper::setPriority(int priority) +{ + _priority = priority; +} + +int JSScheduleWrapper::getPriority() +{ + return _priority; +} + +void JSScheduleWrapper::setUpdateSchedule(bool isUpdateSchedule) +{ + _isUpdateSchedule = isUpdateSchedule; +} + +bool JSScheduleWrapper::isUpdateSchedule() +{ + return _isUpdateSchedule; +} + +bool js_CCNode_unschedule(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc == 1) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Node *node = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2(node, cx, false, "Invalid Native Object"); + + Scheduler *sched = node->getScheduler(); + + auto targetArray = JSScheduleWrapper::getTargetForSchedule(args.get(0)); + CCLOGINFO("unschedule target number: %d", targetArray->count()); + Ref* tmp = NULL; + CCARRAY_FOREACH(targetArray, tmp) + { + JSScheduleWrapper* target = static_cast(tmp); + if (node == target->getTarget()) + { + sched->unschedule(schedule_selector(JSScheduleWrapper::scheduleFunc), target); + JSScheduleWrapper::removeTargetForJSObject(obj, target); + break; + } + } + + args.rval().setUndefined(); + } + return true; +} + +bool js_cocos2dx_CCNode_unscheduleAllSelectors(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + if (argc == 0) + { + cobj->unscheduleAllSelectors(); + + __Array *arr = JSScheduleWrapper::getTargetForJSObject(obj); + // If there aren't any targets, just return true. + // Otherwise, the for loop will break immediately. + // It will lead to logic errors. + // For details to reproduce it, please refer to SchedulerTest/SchedulerUpdate. + if(! arr) return true; + JSScheduleWrapper* wrapper = NULL; + for(ssize_t i = 0; i < arr->count(); ++i) { + wrapper = (JSScheduleWrapper*)arr->getObjectAtIndex(i); + if(wrapper) { + cobj->getScheduler()->unscheduleAllForTarget(wrapper); + } + } + + JSScheduleWrapper::removeAllTargetsForJSObject(obj); + + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +bool js_CCNode_scheduleOnce(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc >= 1) { + bool ok = true; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + +// JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Node *node = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + + Scheduler *sched = node->getScheduler(); + + JSScheduleWrapper *tmpCobj = NULL; + + // + // delay + // + double delay; + if( argc >= 2 ) { + ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(1)), &delay ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + } + + bool bFound = false; + auto pTargetArr = JSScheduleWrapper::getTargetForJSObject(obj); + Ref* pObj = NULL; + CCARRAY_FOREACH(pTargetArr, pObj) + { + JSScheduleWrapper* pTarget = static_cast(pObj); + if (args.get(0) == pTarget->getJSCallbackFunc()) + { + tmpCobj = pTarget; + bFound = true; + break; + } + } + + if (!bFound) + { + tmpCobj = new JSScheduleWrapper(); + tmpCobj->autorelease(); + tmpCobj->setJSCallbackThis(OBJECT_TO_JSVAL(obj)); + tmpCobj->setJSCallbackFunc(args.get(0)); + tmpCobj->setTarget(node); + + JSScheduleWrapper::setTargetForSchedule(args.get(0), tmpCobj); + JSScheduleWrapper::setTargetForJSObject(obj, tmpCobj); + } + + if(argc == 1) { + sched->schedule(schedule_selector(JSScheduleWrapper::scheduleFunc), tmpCobj, 0, 0, 0.0f, !node->isRunning()); + } else { + sched->schedule(schedule_selector(JSScheduleWrapper::scheduleFunc), tmpCobj, 0, 0, delay, !node->isRunning()); + } + + /* We shouldn't set the js callback function to reserved slot, + since the target object may execute more than one schedule. + Therefore, previous js callback function will be replaced + by the current one. For example: + this.scheduleOnce(function() { temporary function 1 }, 0.5); + this.scheduleOnce(function() { temporary function 2 }, 0.5); + In this case, the temporary function 1 will be removed from reserved slot 0. + And temporary function 2 will be set to reserved slot 0 of this object. + If gc is triggered before the 'JSScheduleWrapper::scheduleFunc' is invoked, + crash will happen. You could simply reproduce it by adding '__jsc__.garbageCollect();' after scheduleOnce. + + [Solution] Because one schedule corresponds to one JSScheduleWrapper, we root + the js callback function in JSScheduleWrapper::setJSCallbackFunc and unroot it + at the destructor of JSScheduleWrapper. + */ + //jsb_set_reserved_slot(proxy->obj, 0, args.get(0)); + + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments"); + return false; +} + +bool js_CCNode_schedule(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc >= 1) { + bool ok = true; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + +// JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Node *node = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + Scheduler *sched = node->getScheduler(); + + JSScheduleWrapper *tmpCobj = NULL; + + double interval = 0.0; + if( argc >= 2 ) { + ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(1)), &interval ); + } + + // + // repeat + // + double repeat = 0.0; + if( argc >= 3 ) { + ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(2)), &repeat ); + } + + // + // delay + // + double delay = 0.0; + if( argc >= 4 ) { + ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(3)), &delay ); + } + + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + bool bFound = false; + auto pTargetArr = JSScheduleWrapper::getTargetForJSObject(obj); + Ref* pObj = NULL; + CCARRAY_FOREACH(pTargetArr, pObj) + { + JSScheduleWrapper* pTarget = static_cast(pObj); + if (args.get(0) == pTarget->getJSCallbackFunc()) + { + tmpCobj = pTarget; + bFound = true; + break; + } + } + + if (!bFound) + { + tmpCobj = new JSScheduleWrapper(); + tmpCobj->autorelease(); + tmpCobj->setJSCallbackThis(OBJECT_TO_JSVAL(obj)); + tmpCobj->setJSCallbackFunc(args.get(0)); + tmpCobj->setTarget(node); + JSScheduleWrapper::setTargetForSchedule(args.get(0), tmpCobj); + JSScheduleWrapper::setTargetForJSObject(obj, tmpCobj); + } + + if(argc == 1) { + sched->schedule(schedule_selector(JSScheduleWrapper::scheduleFunc), tmpCobj, 0, !node->isRunning()); + }else if(argc == 2) { + sched->schedule(schedule_selector(JSScheduleWrapper::scheduleFunc), tmpCobj, interval, !node->isRunning()); + }else if(argc == 3) { + sched->schedule(schedule_selector(JSScheduleWrapper::scheduleFunc), tmpCobj, interval, (unsigned int)repeat, 0, !node->isRunning()); + }else if (argc == 4) { + sched->schedule(schedule_selector(JSScheduleWrapper::scheduleFunc), tmpCobj, interval, (unsigned int)repeat, delay, !node->isRunning()); + } + + // I comment next line with the same reason in the js_CCNode_scheduleOnce. + //jsb_set_reserved_slot(proxy->obj, 0, args.get(0)); + + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments"); + return false; +} + +bool js_cocos2dx_CCNode_scheduleUpdateWithPriority(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; +// JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + if (argc == 1) { + int arg0 = 0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + bool isFoundUpdate = false; + ok = JS_HasProperty(cx, obj, "update", &isFoundUpdate); + JS::RootedValue jsUpdateFunc(cx); + if (ok && isFoundUpdate) { + ok = JS_GetProperty(cx, obj, "update", &jsUpdateFunc); + } + + // if no 'update' property, return true directly. + if (!ok) { + args.rval().setUndefined(); + return true; + } + + JSScheduleWrapper* tmpCobj = NULL; + + bool bFound = false; + auto pTargetArr = JSScheduleWrapper::getTargetForJSObject(obj); + Ref* pObj = NULL; + CCARRAY_FOREACH(pTargetArr, pObj) + { + JSScheduleWrapper* pTarget = static_cast(pObj); + if (jsUpdateFunc == pTarget->getJSCallbackFunc()) + { + tmpCobj = pTarget; + bFound = true; + break; + } + } + + if (!bFound) + { + tmpCobj = new JSScheduleWrapper(); + tmpCobj->autorelease(); + tmpCobj->setJSCallbackThis(OBJECT_TO_JSVAL(obj)); + tmpCobj->setJSCallbackFunc(jsUpdateFunc); + tmpCobj->setTarget(cobj); + tmpCobj->setUpdateSchedule(true); + JSScheduleWrapper::setTargetForSchedule(jsUpdateFunc, tmpCobj); + JSScheduleWrapper::setTargetForJSObject(obj, tmpCobj); + } + + tmpCobj->setPriority(arg0); + cobj->getScheduler()->scheduleUpdate(tmpCobj, arg0, !cobj->isRunning()); + + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_CCNode_unscheduleUpdate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); +// JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + if (argc == 0) + { + cobj->unscheduleUpdate(); + do { +// JSObject *tmpObj = obj; + + __Array *arr = JSScheduleWrapper::getTargetForJSObject(obj); + // If there aren't any targets, just return true. + // Otherwise, the for loop will break immediately. + // It will lead to logic errors. + // For details to reproduce it, please refer to SchedulerTest/SchedulerUpdate. + if(! arr) return true; + + JSScheduleWrapper* wrapper = NULL; + for(ssize_t i = 0; i < arr->count(); ++i) { + wrapper = (JSScheduleWrapper*)arr->getObjectAtIndex(i); + if(wrapper && wrapper->isUpdateSchedule()) { + cobj->getScheduler()->unscheduleUpdate(wrapper); + CCASSERT(OBJECT_TO_JSVAL(obj) == wrapper->getJSCallbackThis(), "Wrong target object."); + JSScheduleWrapper::removeTargetForJSObject(obj, wrapper); + break; + } + } + } while (0); + + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +bool js_cocos2dx_CCNode_scheduleUpdate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; +// JSObject *obj = JS_THIS_OBJECT(cx, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + if (argc == 0) { + + bool isFoundUpdate = false; + ok = JS_HasProperty(cx, obj, "update", &isFoundUpdate); + JS::RootedValue jsUpdateFunc(cx); + if (ok && isFoundUpdate) { + ok = JS_GetProperty(cx, obj, "update", &jsUpdateFunc); + } + + // if no 'update' property, return true directly. + if (!ok) { + args.rval().setUndefined(); + return true; + } + + JSScheduleWrapper* tmpCobj = NULL; + + bool bFound = false; + auto pTargetArr = JSScheduleWrapper::getTargetForJSObject(obj); + Ref* pObj = NULL; + CCARRAY_FOREACH(pTargetArr, pObj) + { + JSScheduleWrapper* pTarget = static_cast(pObj); + if (jsUpdateFunc == pTarget->getJSCallbackFunc()) + { + tmpCobj = pTarget; + bFound = true; + break; + } + } + + if (!bFound) + { + tmpCobj = new JSScheduleWrapper(); + tmpCobj->autorelease(); + tmpCobj->setJSCallbackThis(OBJECT_TO_JSVAL(obj)); + tmpCobj->setJSCallbackFunc(jsUpdateFunc); + tmpCobj->setTarget(cobj); + tmpCobj->setUpdateSchedule(true); + JSScheduleWrapper::setTargetForSchedule(jsUpdateFunc, tmpCobj); + JSScheduleWrapper::setTargetForJSObject(obj, tmpCobj); + } + + cobj->getScheduler()->scheduleUpdate(tmpCobj, 0, !cobj->isRunning()); + + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_CCScheduler_unscheduleAllSelectorsForTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + if (argc == 1) { + do { + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); + + __Array *arr = JSScheduleWrapper::getTargetForJSObject(tmpObj); + // If there aren't any targets, just return true. + // Otherwise, the for loop will break immediately. + // It will lead to logic errors. + // For details to reproduce it, please refer to SchedulerTest/SchedulerUpdate. + if(! arr) return true; + + JSScheduleWrapper* wrapper = NULL; + for(ssize_t i = 0; i < arr->count(); ++i) { + wrapper = (JSScheduleWrapper*)arr->getObjectAtIndex(i); + if(wrapper) { + cobj->unscheduleAllForTarget(wrapper); + } + } + JSScheduleWrapper::removeAllTargetsForJSObject(tmpObj); + + } while (0); + + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_CCScheduler_scheduleUpdateForTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc >= 1) { + bool ok = true; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scheduler *sched = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); + + JSScheduleWrapper *tmpCObj = NULL; + + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); + proxy = jsb_get_js_proxy(tmpObj); + bool isPureJSTarget = proxy ? false : true; + + bool isFoundUpdate = false; + ok = JS_HasProperty(cx, tmpObj, "update", &isFoundUpdate); + JS::RootedValue jsUpdateFunc(cx); + if (ok && isFoundUpdate) { + ok = JS_GetProperty(cx, tmpObj, "update", &jsUpdateFunc); + } + + // if no 'update' property, return true directly. + if (!ok) { + args.rval().setUndefined(); + return true; + } + + int arg1 = 0; + if (argc >= 2) { + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + } + + bool paused = false; + + if( argc >= 3 ) { + paused = JS::ToBoolean(JS::RootedValue(cx, args.get(2))); + } + + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + bool bFound = false; + auto pTargetArr = JSScheduleWrapper::getTargetForJSObject(tmpObj); + Ref* pObj = NULL; + CCARRAY_FOREACH(pTargetArr, pObj) + { + JSScheduleWrapper* pTarget = static_cast(pObj); + if (jsUpdateFunc == pTarget->getJSCallbackFunc()) + { + tmpCObj = pTarget; + bFound = true; + break; + } + } + + if (!bFound) + { + tmpCObj = new JSScheduleWrapper(); + tmpCObj->autorelease(); + tmpCObj->setJSCallbackThis(args.get(0)); + tmpCObj->setJSCallbackFunc(jsUpdateFunc); + tmpCObj->setUpdateSchedule(true); + if (isPureJSTarget) { + tmpCObj->setPureJSTarget(tmpObj); + } + + JSScheduleWrapper::setTargetForSchedule(jsUpdateFunc, tmpCObj); + JSScheduleWrapper::setTargetForJSObject(tmpObj, tmpCObj); + } + tmpCObj->setPriority(arg1); + sched->scheduleUpdate(tmpCObj, arg1, paused); + + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments"); + return false; +} + +bool js_CCScheduler_unscheduleUpdateForTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + if (argc == 1) { + do { + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); + + __Array *arr = JSScheduleWrapper::getTargetForJSObject(tmpObj); + // If there aren't any targets, just return true. + // Otherwise, the for loop will break immediately. + // It will lead to logic errors. + // For details to reproduce it, please refer to SchedulerTest/SchedulerUpdate. + if(! arr) return true; + + JSScheduleWrapper* wrapper = NULL; + for(ssize_t i = 0; i < arr->count(); ++i) { + wrapper = (JSScheduleWrapper*)arr->getObjectAtIndex(i); + if(wrapper && wrapper->isUpdateSchedule()) { + cobj->unscheduleUpdate(wrapper); + CCASSERT(args.get(0) == wrapper->getJSCallbackThis(), "Wrong target object."); + JSScheduleWrapper::removeTargetForJSObject(tmpObj, wrapper); + break; + } + } + } while (0); + + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_CCScheduler_scheduleCallbackForTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc >= 2) { + bool ok = true; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + JS::RootedObject obj(cx); + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scheduler *sched = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); + + JSScheduleWrapper *tmpCObj = NULL; + + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); + proxy = jsb_get_js_proxy(tmpObj); + bool isPureJSTarget = proxy ? false : true; + + double interval = 0; + if( argc >= 3 ) { + ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(2)), &interval ); + } + + // + // repeat + // + double repeat = kRepeatForever; + if( argc >= 4 ) { + ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(3)), &repeat ); + } + + // + // delay + // + double delay = 0; + if( argc >= 5 ) { + ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(4)), &delay ); + } + + bool paused = false; + + if( argc >= 6 ) { + paused = JS::ToBoolean(JS::RootedValue(cx, args.get(5))); + } + + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + bool bFound = false; + auto pTargetArr = JSScheduleWrapper::getTargetForJSObject(tmpObj); + Ref* pObj = NULL; + CCARRAY_FOREACH(pTargetArr, pObj) + { + JSScheduleWrapper* pTarget = static_cast(pObj); + if (args.get(1) == pTarget->getJSCallbackFunc()) + { + tmpCObj = pTarget; + bFound = true; + break; + } + } + + if (!bFound) + { + tmpCObj = new JSScheduleWrapper(); + tmpCObj->autorelease(); + tmpCObj->setJSCallbackThis(args.get(0)); + tmpCObj->setJSCallbackFunc(args.get(1)); + if (isPureJSTarget) { + tmpCObj->setPureJSTarget(tmpObj); + } + + JSScheduleWrapper::setTargetForSchedule(args.get(1), tmpCObj); + JSScheduleWrapper::setTargetForJSObject(tmpObj, tmpCObj); + } + + sched->schedule(schedule_selector(JSScheduleWrapper::scheduleFunc), tmpCObj, interval, repeat, delay, paused); + + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments"); + return false; +} + +bool js_CCScheduler_schedule(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc >= 2) { + bool ok = true; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + JS::RootedObject obj(cx); + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scheduler *sched = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); + + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); + + std::function callback; + do { + if(JS_TypeOfValue(cx, args.get(0)) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, tmpObj, args.get(0))); + auto lambda = [=](float larg0) -> void { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + jsval largv[1]; + largv[0] = DOUBLE_TO_JSVAL(larg0); + JS::RootedValue rval(cx); + bool ok = func->invoke(1, &largv[0], &rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + callback = lambda; + } + else + { + ok = false; + callback = nullptr; + } + } while(0); + + double interval = 0; + if( argc >= 3 ) { + ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(2)), &interval ); + } + + // + // repeat + // + double repeat = kRepeatForever; + if( argc >= 4 ) { + ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(3)), &repeat ); + } + + // + // delay + // + double delay = 0; + if( argc >= 5 ) { + ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(4)), &delay ); + } + + bool paused = false; + + if( argc >= 6 ) { + paused = JS::ToBoolean(JS::RootedValue(cx, args.get(5))); + } + + std::string key; + + if( argc >= 7 ) { + ok &= jsval_to_std_string(cx, args.get(6), &key); + } + + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + sched->schedule(callback, tmpObj, interval, repeat, delay, paused, key); + + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments"); + return false; +} + +bool js_CCScheduler_unscheduleCallbackForTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + if (argc == 2) { + do { + if (args.get(0).isString()) { + std::string key; + bool ok = jsval_to_std_string(cx, args.get(0), &key); + JSB_PRECONDITION2(ok, cx, false, "Error processing argument: key"); + + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); + cobj->unschedule(key, tmpObj); + } + else { + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); + + __Array *arr = JSScheduleWrapper::getTargetForJSObject(tmpObj); + // If there aren't any targets, just return true. + // Otherwise, the for loop will break immediately. + // It will lead to logic errors. + // For details to reproduce it, please refer to SchedulerTest/SchedulerUpdate. + if(! arr) return true; + + JSScheduleWrapper* wrapper = NULL; + for(ssize_t i = 0; i < arr->count(); ++i) { + wrapper = (JSScheduleWrapper*)arr->getObjectAtIndex(i); + if(wrapper && wrapper->getJSCallbackFunc() == args.get(1)) { + cobj->unschedule(schedule_selector(JSScheduleWrapper::scheduleFunc), wrapper); + JSScheduleWrapper::removeTargetForJSObject(tmpObj, wrapper); + break; + } + } + } + } while (0); + + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_CCScheduler_unscheduleAll(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + if (argc == 0) { + cobj->unscheduleAll(); + JSScheduleWrapper::removeAllTargets(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_CCScheduler_unscheduleAllCallbacksWithMinPriority(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cobj->unscheduleAllWithMinPriority(arg0); + JSScheduleWrapper::removeAllTargetsForMinPriority(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + + +bool js_cocos2dx_CCScheduler_pauseTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scheduler *sched = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); + + if (argc == 1) { + do { + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); + __Array *arr = JSScheduleWrapper::getTargetForJSObject(tmpObj); + if(! arr) return true; + for(ssize_t i = 0; i < arr->count(); ++i) { + if(arr->getObjectAtIndex(i)) { + sched->pauseTarget(arr->getObjectAtIndex(i)); + } + } + + } while (0); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_CCScheduler_resumeTarget(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scheduler *sched = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); + + if (argc == 1) { + do { + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); + auto arr = JSScheduleWrapper::getTargetForJSObject(tmpObj); + if(! arr) return true; + for(ssize_t i = 0; i < arr->count(); ++i) { + if(arr->getObjectAtIndex(i)) { + sched->resumeTarget(arr->getObjectAtIndex(i)); + } + } + + } while (0); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_CCScheduler_isTargetPaused(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scheduler* cobj = (cocos2d::Scheduler *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + if (argc == 1) { + bool ret = false; + do { + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); + __Array *arr = JSScheduleWrapper::getTargetForJSObject(tmpObj); + if(! arr) return true; + for(ssize_t i = 0; i < arr->count(); ++i) { + if(arr->getObjectAtIndex(i)) { + ret = cobj->isTargetPaused(arr->getObjectAtIndex(i)) ? true : false; + // break directly since all targets have the same `pause` status. + break; + } + } + } while (0); +// JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); + args.rval().set(BOOLEAN_TO_JSVAL(ret)); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_forceGC(JSContext *cx, uint32_t argc, jsval *vp) { + JSRuntime *rt = JS_GetRuntime(cx); + JS_GC(rt); + return true; +} + +bool js_cocos2dx_retain(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *thisObj = JS_THIS_OBJECT(cx, vp); + if (thisObj) { + js_proxy_t *proxy = jsb_get_js_proxy(thisObj); + if (proxy) { + ((Ref *)proxy->ptr)->retain(); + return true; + } + } + JS_ReportError(cx, "Invalid Native Object."); + return false; +} + +bool js_cocos2dx_release(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *thisObj = JS_THIS_OBJECT(cx, vp); + if (thisObj) { + js_proxy_t *proxy = jsb_get_js_proxy(thisObj); + if (proxy) { + ((Ref *)proxy->ptr)->release(); + return true; + } + } + JS_ReportError(cx, "Invalid Native Object."); + return false; +} + +bool js_cocos2dx_Node_onEnter(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *thisObj = JS_THIS_OBJECT(cx, vp); + if (thisObj) { + js_proxy_t *proxy = jsb_get_js_proxy(thisObj); + if (proxy) { + ScriptingCore::getInstance()->setCalledFromScript(true); + static_cast(proxy->ptr)->onEnter(); + return true; + } + } + JS_ReportError(cx, "Invalid Native Object."); + return false; +} + +bool js_cocos2dx_Node_onExit(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *thisObj = JS_THIS_OBJECT(cx, vp); + if (thisObj) { + js_proxy_t *proxy = jsb_get_js_proxy(thisObj); + if (proxy) { + ScriptingCore::getInstance()->setCalledFromScript(true); + static_cast(proxy->ptr)->onExit(); + return true; + } + } + JS_ReportError(cx, "Invalid Native Object."); + return false; +} + +bool js_cocos2dx_Node_onEnterTransitionDidFinish(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *thisObj = JS_THIS_OBJECT(cx, vp); + if (thisObj) { + js_proxy_t *proxy = jsb_get_js_proxy(thisObj); + if (proxy) { + ScriptingCore::getInstance()->setCalledFromScript(true); + static_cast(proxy->ptr)->onEnterTransitionDidFinish(); + return true; + } + } + JS_ReportError(cx, "Invalid Native Object."); + return false; +} + +bool js_cocos2dx_Node_onExitTransitionDidStart(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *thisObj = JS_THIS_OBJECT(cx, vp); + if (thisObj) { + js_proxy_t *proxy = jsb_get_js_proxy(thisObj); + if (proxy) { + ScriptingCore::getInstance()->setCalledFromScript(true); + static_cast(proxy->ptr)->onExitTransitionDidStart(); + return true; + } + } + JS_ReportError(cx, "Invalid Native Object."); + return false; +} + +bool js_cocos2dx_CCNode_setPosition(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + bool ok = true; + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + if (argc == 1) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cobj->setPosition(arg0); + args.rval().setUndefined(); + return true; + } if (argc == 2) { + double x; + ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(0)), &x ); + double y; + ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(1)), &y ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cobj->setPosition(Point(x,y)); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_CCNode_setContentSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + bool ok = true; + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cobj->setContentSize(arg0); + args.rval().setUndefined(); + return true; + } if (argc == 2) { + double width; + ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(0)), &width ); + double height; + ok &= JS::ToNumber(cx, JS::RootedValue(cx, args.get(1)), &height ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cobj->setContentSize(Size(width,height)); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_CCNode_setAnchorPoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + bool ok = true; + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + if (argc == 1) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cobj->setAnchorPoint(arg0); + args.rval().setUndefined(); + return true; + } if (argc == 2) { + double x; + ok &= JS::ToNumber(cx, args.get(0), &x ); + double y; + ok &= JS::ToNumber(cx, args.get(1), &y ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cobj->setAnchorPoint(Point(x,y)); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_CCNode_setColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + 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_setColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Color3B arg0; + ok &= jsval_to_cccolor3b(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setColor : Error processing arguments"); + cobj->setColor(arg0); + +// int32_t alpha; +// ok &= jsval_cccolor_to_opacity(cx, args.get(0), &alpha); +// if (ok) { +// cobj->setOpacity(alpha); +// } + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_setColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_CCNode_pause(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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(obj); + 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); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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(obj); + 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_CCNode_convertToWorldSpace(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_CCNode_convertToWorldSpace : Invalid Native Object"); + cocos2d::Vec2 arg0; + if (argc == 1) { + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_CCNode_convertToWorldSpace : Error processing arguments"); + } + else if (argc != 0) { + JS_ReportError(cx, "js_cocos2dx_CCNode_convertToWorldSpace : wrong number of arguments: %d, was expecting 0 or 1", argc); + return false; + } + + cocos2d::Vec2 ret = cobj->convertToWorldSpace(arg0); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; +} + +bool js_cocos2dx_CCNode_convertToWorldSpaceAR(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_CCNode_convertToWorldSpaceAR : Invalid Native Object"); + cocos2d::Vec2 arg0; + if (argc == 1) { + ok &= jsval_to_vector2(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_CCNode_convertToWorldSpaceAR : Error processing arguments"); + } + else if (argc != 0) { + JS_ReportError(cx, "js_cocos2dx_CCNode_convertToWorldSpaceAR : wrong number of arguments: %d, was expecting 0 or 1", argc); + return false; + } + + cocos2d::Vec2 ret = cobj->convertToWorldSpaceAR(arg0); + jsval jsret = JSVAL_NULL; + jsret = vector2_to_jsval(cx, ret); + args.rval().set(jsret); + return true; +} + +bool js_cocos2dx_Component_onEnter(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *thisObj = JS_THIS_OBJECT(cx, vp); + if (thisObj) { + js_proxy_t *proxy = jsb_get_js_proxy(thisObj); + if (proxy) { + ScriptingCore::getInstance()->setCalledFromScript(true); + static_cast(proxy->ptr)->onEnter(); + return true; + } + } + JS_ReportError(cx, "Invalid Native Object."); + return false; +} + +bool js_cocos2dx_Component_onExit(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *thisObj = JS_THIS_OBJECT(cx, vp); + if (thisObj) { + js_proxy_t *proxy = jsb_get_js_proxy(thisObj); + if (proxy) { + ScriptingCore::getInstance()->setCalledFromScript(true); + static_cast(proxy->ptr)->onExit(); + return true; + } + } + JS_ReportError(cx, "Invalid Native Object."); + return false; +} + +bool js_cocos2dx_CCTMXLayer_tileFlagsAt(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj; + bool ok = true; + cocos2d::TMXLayer* cobj; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + if (argc == 1) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + cocos2d::TMXTileFlags flags = kTMXTileHorizontalFlag; + jsval jsret; + jsret = UINT_TO_JSVAL((uint32_t)flags); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "wrong number of arguments"); + return false; +} + +bool js_cocos2dx_CCTMXLayer_getTiles(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::TMXLayer* cobj = (cocos2d::TMXLayer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + if (argc == 0) { + uint32_t* ret = cobj->getTiles(); + Size size = cobj->getLayerSize(); + int count = size.width * size.height; + JSObject* array = JS_NewUint32Array(cx, count); + if (NULL == array) { + JS_ReportError(cx, "Can't allocate enough memory."); + return false; + } + uint32_t* bufdata = (uint32_t*)JS_GetArrayBufferViewData(array); + memcpy(bufdata, ret, count*sizeof(int32_t)); + + args.rval().set(OBJECT_TO_JSVAL(array)); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + + +// Actions + +bool js_cocos2dx_ActionInterval_repeat(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionInterval* cobj = (cocos2d::ActionInterval *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionInterval_repeat : Invalid Native Object"); + + if (argc == 1) + { + double times; + if( ! JS::ToNumber(cx, args.get(0), ×) ) { + return false; + } + int timesInt = (int)times; + if (timesInt <= 0) { + JS_ReportError(cx, "js_cocos2dx_ActionInterval_repeat : Repeat times must be greater than 0"); + } + + cocos2d::Repeat* action = cocos2d::Repeat::create(cobj, timesInt); + // Unbind current proxy binding + JS::RemoveObjectRoot(cx, &proxy->obj); + jsb_remove_proxy(jsb_get_native_proxy(cobj), proxy); + // Rebind js obj with new action + js_proxy_t* newProxy = jsb_new_proxy(action, obj); + JS::AddNamedObjectRoot(cx, &newProxy->obj, "cocos2d::Repeat"); + + args.rval().set(OBJECT_TO_JSVAL(obj)); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionInterval_repeat : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_ActionInterval_repeatForever(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionInterval* cobj = (cocos2d::ActionInterval *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionInterval_repeatForever : Invalid Native Object"); + + if (argc == 0) { + cocos2d::RepeatForever* action = cocos2d::RepeatForever::create(cobj); + // Unbind current proxy binding + JS::RemoveObjectRoot(cx, &proxy->obj); + jsb_remove_proxy(jsb_get_native_proxy(cobj), proxy); + // Rebind js obj with new action + js_proxy_t* newProxy = jsb_new_proxy(action, obj); + JS::AddNamedObjectRoot(cx, &newProxy->obj, "cocos2d::RepeatForever"); + + args.rval().set(OBJECT_TO_JSVAL(obj)); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionInterval_repeatForever : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +bool js_cocos2dx_ActionInterval_speed(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionInterval* cobj = (cocos2d::ActionInterval *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionInterval_speed : Invalid Native Object"); + + if (argc == 1) + { + double speed; + if( ! JS::ToNumber(cx, args.get(0), &speed) ) { + return false; + } + if (speed < 0) { + JS_ReportError(cx, "js_cocos2dx_ActionInterval_speed : Speed must not be negative"); + return false; + } + + cocos2d::Speed* action = cocos2d::Speed::create(cobj, speed); + // Unbind current proxy binding + JS::RemoveObjectRoot(cx, &proxy->obj); + jsb_remove_proxy(jsb_get_native_proxy(cobj), proxy); + // Rebind js obj with new action + js_proxy_t* newProxy = jsb_new_proxy(action, obj); + JS::AddNamedObjectRoot(cx, &newProxy->obj, "cocos2d::Speed"); + + args.rval().set(OBJECT_TO_JSVAL(obj)); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ActionInterval_speed : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +enum ACTION_TAG { + EASE_IN = 0, + EASE_OUT, + EASE_INOUT, + EASE_EXPONENTIAL_IN, + EASE_EXPONENTIAL_OUT, + EASE_EXPONENTIAL_INOUT, + EASE_SINE_IN, + EASE_SINE_OUT, + EASE_SINE_INOUT, + EASE_ELASTIC_IN, + EASE_ELASTIC_OUT, + EASE_ELASTIC_INOUT, + EASE_BOUNCE_IN, + EASE_BOUNCE_OUT, + EASE_BOUNCE_INOUT, + EASE_BACK_IN, + EASE_BACK_OUT, + EASE_BACK_INOUT, + + EASE_BEZIER_ACTION, + EASE_QUADRATIC_IN, + EASE_QUADRATIC_OUT, + EASE_QUADRATIC_INOUT, + EASE_QUARTIC_IN, + EASE_QUARTIC_OUT, + EASE_QUARTIC_INOUT, + EASE_QUINTIC_IN, + EASE_QUINTIC_OUT, + EASE_QUINTIC_INOUT, + EASE_CIRCLE_IN, + EASE_CIRCLE_OUT, + EASE_CIRCLE_INOUT, + EASE_CUBIC_IN, + EASE_CUBIC_OUT, + EASE_CUBIC_INOUT +}; + +bool js_cocos2dx_ActionInterval_easing(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ActionInterval* cobj = (cocos2d::ActionInterval *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ActionInterval_easing : Invalid Native Object"); + + cocos2d::ActionInterval* currentAction = cobj; + JS::RootedObject tmp(cx); + JS::RootedValue jsTag(cx); + JS::RootedValue jsParam(cx); + double tag; + double parameter; + + for (int i = 0; i < argc; i++) + { +// jsval vpi = argv[i]; + JS::RootedValue vpi(cx, args.get(i)); + bool ok = vpi.isObject() && + JS_ValueToObject(cx, vpi, &tmp) && + JS_GetProperty(cx, tmp, "tag", &jsTag) && + JS::ToNumber(cx, jsTag, &tag); + JS_GetProperty(cx, tmp, "param", &jsParam) && JS::ToNumber(cx, jsParam, ¶meter); + bool hasParam = (parameter == parameter); + if (!ok) continue; + + cocos2d::ActionEase* action; + ok = true; + if (tag == EASE_IN) + { + if (!hasParam) ok = false; + action = cocos2d::EaseIn::create(currentAction, parameter); + } + else if (tag == EASE_OUT) + { + if (!hasParam) ok = false; + action = cocos2d::EaseOut::create(currentAction, parameter); + } + else if (tag == EASE_INOUT) + { + if (!hasParam) ok = false; + action = cocos2d::EaseInOut::create(currentAction, parameter); + } + else if (tag == EASE_EXPONENTIAL_IN) + action = cocos2d::EaseExponentialIn::create(currentAction); + else if (tag == EASE_EXPONENTIAL_OUT) + action = cocos2d::EaseExponentialOut::create(currentAction); + else if (tag == EASE_EXPONENTIAL_INOUT) + action = cocos2d::EaseExponentialInOut::create(currentAction); + else if (tag == EASE_SINE_IN) + action = cocos2d::EaseSineIn::create(currentAction); + else if (tag == EASE_SINE_OUT) + action = cocos2d::EaseSineOut::create(currentAction); + else if (tag == EASE_SINE_INOUT) + action = cocos2d::EaseSineInOut::create(currentAction); + else if (tag == EASE_ELASTIC_IN) + { + if (!hasParam) parameter = 0.3; + action = cocos2d::EaseElasticIn::create(currentAction, parameter); + } + else if (tag == EASE_ELASTIC_OUT) + { + if (!hasParam) parameter = 0.3; + action = cocos2d::EaseElasticOut::create(currentAction, parameter); + } + else if (tag == EASE_ELASTIC_INOUT) + { + if (!hasParam) parameter = 0.3; + action = cocos2d::EaseElasticInOut::create(currentAction, parameter); + } + else if (tag == EASE_BOUNCE_IN) + action = cocos2d::EaseBounceIn::create(currentAction); + else if (tag == EASE_BOUNCE_OUT) + action = cocos2d::EaseBounceOut::create(currentAction); + else if (tag == EASE_BOUNCE_INOUT) + action = cocos2d::EaseBounceInOut::create(currentAction); + else if (tag == EASE_BACK_IN) + action = cocos2d::EaseBackIn::create(currentAction); + else if (tag == EASE_BACK_OUT) + action = cocos2d::EaseBackOut::create(currentAction); + else if (tag == EASE_BACK_INOUT) + action = cocos2d::EaseBackInOut::create(currentAction); + + else if (tag == EASE_QUADRATIC_IN) + action = cocos2d::EaseQuadraticActionIn::create(currentAction); + else if (tag == EASE_QUADRATIC_OUT) + action = cocos2d::EaseQuadraticActionOut::create(currentAction); + else if (tag == EASE_QUADRATIC_INOUT) + action = cocos2d::EaseQuadraticActionInOut::create(currentAction); + else if (tag == EASE_QUARTIC_IN) + action = cocos2d::EaseQuarticActionIn::create(currentAction); + else if (tag == EASE_QUARTIC_OUT) + action = cocos2d::EaseQuarticActionOut::create(currentAction); + else if (tag == EASE_QUARTIC_INOUT) + action = cocos2d::EaseQuarticActionInOut::create(currentAction); + else if (tag == EASE_QUINTIC_IN) + action = cocos2d::EaseQuinticActionIn::create(currentAction); + else if (tag == EASE_QUINTIC_OUT) + action = cocos2d::EaseQuinticActionOut::create(currentAction); + else if (tag == EASE_QUINTIC_INOUT) + action = cocos2d::EaseQuinticActionInOut::create(currentAction); + else if (tag == EASE_CIRCLE_IN) + action = cocos2d::EaseCircleActionIn::create(currentAction); + else if (tag == EASE_CIRCLE_OUT) + action = cocos2d::EaseCircleActionOut::create(currentAction); + else if (tag == EASE_CIRCLE_INOUT) + action = cocos2d::EaseCircleActionInOut::create(currentAction); + else if (tag == EASE_CUBIC_IN) + action = cocos2d::EaseCubicActionIn::create(currentAction); + else if (tag == EASE_CUBIC_OUT) + action = cocos2d::EaseCubicActionOut::create(currentAction); + else if (tag == EASE_CUBIC_INOUT) + action = cocos2d::EaseCubicActionInOut::create(currentAction); + else if (tag == EASE_BEZIER_ACTION) + { + JS::RootedValue jsParam2(cx); + JS::RootedValue jsParam3(cx); + JS::RootedValue jsParam4(cx); + double parameter2, parameter3, parameter4; + ok &= JS_GetProperty(cx, tmp, "param2", &jsParam2); + ok &= JS::ToNumber(cx, jsParam2, ¶meter2); + ok &= JS_GetProperty(cx, tmp, "param3", &jsParam3); + ok &= JS::ToNumber(cx, jsParam3, ¶meter3); + ok &= JS_GetProperty(cx, tmp, "param4", &jsParam4); + ok &= JS::ToNumber(cx, jsParam4, ¶meter4); + if (!ok) continue; + + action = cocos2d::EaseBezierAction::create(currentAction); + ((EaseBezierAction *)action)->setBezierParamer(parameter, parameter2, parameter3, parameter4); + } + else + continue; + + if (!ok || !action) { + JS_ReportError(cx, "js_cocos2dx_ActionInterval_easing : Invalid action: At least one action was expecting parameter"); + return false; + } + + currentAction = action; + } + + // Unbind current proxy binding + JS::RemoveObjectRoot(cx, &proxy->obj); + jsb_remove_proxy(jsb_get_native_proxy(cobj), proxy); + // Rebind js obj with new action + js_proxy_t* newProxy = jsb_new_proxy(currentAction, obj); + JS::AddNamedObjectRoot(cx, &newProxy->obj, "cocos2d::EaseAction"); + args.rval().set(OBJECT_TO_JSVAL(obj)); + return true; +} + + +template +bool js_BezierActions_create(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + if (argc == 2) { + double t; + if( ! JS::ToNumber(cx, args.get(0), &t) ) { + return false; + } + + int num; + Point *arr; + jsval_to_ccarray_of_CCPoint(cx, args.get(1), &arr, &num); + + ccBezierConfig config; + config.controlPoint_1 = arr[0]; + config.controlPoint_2 = arr[1]; + config.endPosition = arr[2]; + + T* ret = T::create(t, config); + + delete [] arr; + + jsval jsret; + do { + if (ret) { + js_proxy_t *p = jsb_get_native_proxy(ret); + if (p) { + jsret = OBJECT_TO_JSVAL(p->obj); + } else { + // create a new js obj of that class + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +template +bool js_BezierActions_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + T* cobj = (T *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Bezier_initWithDuration : Invalid Native Object"); + if (argc == 2) { + double arg0; + cocos2d::_ccBezierConfig arg1; + ok &= JS::ToNumber( cx, JS::RootedValue(cx, args.get(0)), &arg0); + + int num; + cocos2d::Vec2 *arr; + jsval_to_ccarray_of_CCPoint(cx, args.get(1), &arr, &num); + + arg1.controlPoint_1 = arr[0]; + arg1.controlPoint_2 = arr[1]; + arg1.endPosition = arr[2]; + + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Bezier_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1); + delete [] arr; + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_BezierTo_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} + +template +bool js_CardinalSplineActions_create(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + if (argc == 3) { + double dur; + ok &= JS::ToNumber(cx, args.get(0), &dur); + + int num; + Point *arr; + ok &= jsval_to_ccarray_of_CCPoint(cx, args.get(1), &arr, &num); + + double ten; + ok &= JS::ToNumber(cx, args.get(2), &ten); + + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + PointArray *points = PointArray::create(num); + + for( int i=0; i < num;i++) { + points->addControlPoint(arr[i]); + } + + T *ret = T::create(dur, points, ten); + + delete [] arr; + + jsval jsret; + do { + if (ret) { + js_proxy_t *p = jsb_get_native_proxy(ret); + if (p) { + jsret = OBJECT_TO_JSVAL(p->obj); + } else { + // create a new js obj of that class + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +template +bool js_CatmullRomActions_create(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + if (argc == 2) { + double dur; + ok &= JS::ToNumber(cx, args.get(0), &dur); + + int num; + Point *arr; + ok &= jsval_to_ccarray_of_CCPoint(cx, args.get(1), &arr, &num); + + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + PointArray *points = PointArray::create(num); + + for( int i=0; i < num;i++) { + points->addControlPoint(arr[i]); + } + + T *ret = T::create(dur, points); + + delete [] arr; + + jsval jsret; + do { + if (ret) { + js_proxy_t *p = jsb_get_native_proxy(ret); + if (p) { + jsret = OBJECT_TO_JSVAL(p->obj); + } else { + // create a new js obj of that class + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +template +bool js_CatmullRomActions_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + T* cobj = (T *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CatmullRom_initWithDuration : Invalid Native Object"); + if (argc == 2) { + double arg0; + ok &= JS::ToNumber( cx, JS::RootedValue(cx, args.get(0)), &arg0); + + int num; + Point *arr; + ok &= jsval_to_ccarray_of_CCPoint(cx, args.get(1), &arr, &num); + + cocos2d::PointArray* arg1 = cocos2d::PointArray::create(num); + for( int i=0; i < num;i++) { + arg1->addControlPoint(arr[i]); + } + + + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_CatmullRom_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1); + delete [] arr; + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_CatmullRom_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} + + +bool JSB_CCBezierBy_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { + return js_BezierActions_create(cx, argc, vp); +} + +bool JSB_CCBezierTo_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { + return js_BezierActions_create(cx, argc, vp); +} + +bool JSB_CCBezierBy_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + return js_BezierActions_initWithDuration(cx, argc, vp); +} + +bool JSB_CCBezierTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + return js_BezierActions_initWithDuration(cx, argc, vp); +} + +bool JSB_CCCardinalSplineBy_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { + return js_CardinalSplineActions_create(cx, argc, vp); +} + +bool JSB_CCCardinalSplineTo_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { + return js_CardinalSplineActions_create(cx, argc, vp); +} + +bool js_cocos2dx_CardinalSplineTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::CardinalSplineTo* cobj = (cocos2d::CardinalSplineTo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CardinalSplineTo_initWithDuration : Invalid Native Object"); + if (argc == 3) { + double arg0; + + double arg2; + ok &= JS::ToNumber( cx, JS::RootedValue(cx, args.get(0)), &arg0); + + int num; + Point *arr; + ok &= jsval_to_ccarray_of_CCPoint(cx, args.get(1), &arr, &num); + cocos2d::PointArray* arg1 = PointArray::create(num); + for( int i=0; i < num;i++) { + arg1->addControlPoint(arr[i]); + } + + ok &= JS::ToNumber( cx, JS::RootedValue(cx, args.get(2)), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_CardinalSplineTo_initWithDuration : Error processing arguments"); + bool ret = cobj->initWithDuration(arg0, arg1, arg2); + + delete [] arr; + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_CardinalSplineTo_initWithDuration : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} + +bool JSB_CCCatmullRomBy_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { + return js_CatmullRomActions_create(cx, argc, vp); +} + +bool JSB_CCCatmullRomTo_actionWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { + return js_CatmullRomActions_create(cx, argc, vp); +} + +bool JSB_CatmullRomBy_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { + return js_CatmullRomActions_initWithDuration(cx, argc, vp); +} + +bool JSB_CatmullRomTo_initWithDuration(JSContext *cx, uint32_t argc, jsval *vp) { + return js_CatmullRomActions_initWithDuration(cx, argc, vp); +} + +bool js_cocos2dx_ccGLEnableVertexAttribs(JSContext *cx, uint32_t argc, jsval *vp) +{ + bool ok = true; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + if (argc == 1) { + unsigned int arg0; + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + GL::enableVertexAttribs(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + + + +bool js_cocos2dx_ccpAdd(JSContext *cx, uint32_t argc, jsval *vp) +{ + bool ok = true; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + if (argc == 2) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + cocos2d::Point arg1; + ok &= jsval_to_ccpoint(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + Point ret = arg0 + arg1; + + jsval jsret = ccpoint_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_ccpDistanceSQ(JSContext *cx, uint32_t argc, jsval *vp) +{ + bool ok = true; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + if (argc == 2) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + cocos2d::Point arg1; + ok &= jsval_to_ccpoint(cx, args.get(1), &arg1); + + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + float ret = arg0.getDistanceSq(arg1); + + jsval jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_ccpDistance(JSContext *cx, uint32_t argc, jsval *vp) +{ + bool ok = true; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + if (argc == 2) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + cocos2d::Point arg1; + ok &= jsval_to_ccpoint(cx, args.get(1), &arg1); + + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + float ret = arg0.getDistance(arg1); + + jsval jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_ccpClamp(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 3) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + cocos2d::Point arg1; + ok &= jsval_to_ccpoint(cx, args.get(1), &arg1); + cocos2d::Point arg2; + ok &= jsval_to_ccpoint(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + Point ret = arg0.getClampPoint(arg1, arg2); + + jsval jsret = ccpoint_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_ccpLengthSQ(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + float ret = arg0.getLengthSq(); + + jsval jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_ccpLength(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + float ret = arg0.getLength(); + + jsval jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_ccpNeg(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + Point ret = -arg0; + + jsval jsret = ccpoint_to_jsval(cx, ret); + args.rval().set(jsret); + + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_ccpSub(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + cocos2d::Point arg1; + ok &= jsval_to_ccpoint(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + Point ret = arg0 - arg1; + + jsval jsret = ccpoint_to_jsval(cx, ret); + args.rval().set(jsret); + + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_ccpMult(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + + double arg1; + ok &= JS::ToNumber(cx, args.get(1), &arg1); + + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + Point ret = arg0 * arg1; + + jsval jsret = ccpoint_to_jsval(cx, ret); + args.rval().set(jsret); + + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_ccpMidpoint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + cocos2d::Point arg1; + ok &= jsval_to_ccpoint(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + Point ret = arg0.getMidpoint(arg1); + + jsval jsret = ccpoint_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} + + +bool js_cocos2dx_ccpDot(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + cocos2d::Point arg1; + ok &= jsval_to_ccpoint(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + float ret = arg0.dot(arg1); + + jsval jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} + +bool js_cocos2dx_ccpCross(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + cocos2d::Point arg1; + ok &= jsval_to_ccpoint(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + float ret = arg0.cross(arg1); + + jsval jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} + +bool js_cocos2dx_ccpPerp(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + Point ret = arg0.getPerp(); + + jsval jsret = ccpoint_to_jsval(cx, ret); + args.rval().set(jsret); + + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + + +bool js_cocos2dx_ccpRPerp(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + Point ret = arg0.getRPerp(); + + jsval jsret = ccpoint_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + + +bool js_cocos2dx_ccpProject(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + cocos2d::Point arg1; + ok &= jsval_to_ccpoint(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + Point ret = arg0.project(arg1); + + jsval jsret = ccpoint_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} + +bool js_cocos2dx_ccpRotate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + cocos2d::Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + cocos2d::Point arg1; + ok &= jsval_to_ccpoint(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + Point ret = arg0.rotate(arg1); + + jsval jsret = ccpoint_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} + +bool js_cocos2dx_ccpNormalize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + cocos2d::Vec2 ret; + ok &= jsval_to_vector2(cx, args.get(0), &ret); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + ret.normalize(); + + jsval jsret = ccpoint_to_jsval(cx, ret); + args.rval().set(jsret); + + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_ccobbGetCorners(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if(argc == 1) + { + cocos2d::OBB obb; + bool ok = jsval_to_obb(cx, args.get(0), &obb); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cocos2d::Vec3 verts[8]; + obb.getCorners(verts); + + JS::RootedObject array(cx, JS_NewArrayObject(cx, 8)); + for(int i = 0; i < 8; ++i) + { + JS::RootedValue vec(cx, vector3_to_jsval(cx, verts[i])); + ok &= JS_SetElement(cx, array, i, vec); + if(!ok) + break; + } + + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + args.rval().set(OBJECT_TO_JSVAL(array)); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_ccobbIntersects(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if(argc == 2) + { + cocos2d::OBB obb1, obb2; + bool ok = jsval_to_obb(cx, args.get(0), &obb1); + ok &= jsval_to_obb(cx, args.get(1), &obb2); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + bool ret = obb1.intersects(obb2); + + args.rval().set(BOOLEAN_TO_JSVAL(ret)); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} + +bool js_cocos2dx_ccrayIntersectsObb(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if(argc == 2) + { + cocos2d::Ray ray; + cocos2d::OBB obb; + + bool ok = jsval_to_ray(cx, args.get(0), &ray); + ok &= jsval_to_obb(cx, args.get(1), &obb); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + bool ret = ray.intersects(obb); + + args.rval().set(BOOLEAN_TO_JSVAL(ret)); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} + +bool js_cocos2dx_ccmat4CreateTranslation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if(argc == 1) + { + cocos2d::Vec3 arg0; + bool ok = jsval_to_vector3(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cocos2d::Mat4 ret; + cocos2d::Mat4::createTranslation(arg0, &ret); + jsval jsret = matrix_to_jsval(cx, ret); + + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_ccmat4CreateRotation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if(argc == 1) + { + cocos2d::Quaternion arg0; + bool ok = jsval_to_quaternion(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cocos2d::Mat4 ret; + cocos2d::Mat4::createRotation(arg0, &ret); + jsval jsret = matrix_to_jsval(cx, ret); + + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_ccmat4Multiply(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if(argc == 2) + { + cocos2d::Mat4 arg0; + cocos2d::Mat4 arg1; + bool ok = jsval_to_matrix(cx, args.get(0), &arg0); + ok &= jsval_to_matrix(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cocos2d::Mat4 ret = arg0 * arg1; + jsval jsret = matrix_to_jsval(cx, ret); + + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} + +bool js_cocos2dx_ccmat4MultiplyVec3(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if(argc == 2) + { + cocos2d::Mat4 arg0; + cocos2d::Vec3 arg1; + bool ok = jsval_to_matrix(cx, args.get(0), &arg0); + ok &= jsval_to_vector3(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cocos2d::Vec3 ret = arg0 * arg1; + jsval jsret = vector3_to_jsval(cx, ret); + + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} + +bool js_cocos2dx_ccquatMultiply(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if(argc == 2) + { + cocos2d::Quaternion arg0; + cocos2d::Quaternion arg1; + bool ok = jsval_to_quaternion(cx, args.get(0), &arg0); + ok &= jsval_to_quaternion(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cocos2d::Quaternion ret = arg0 * arg1; + jsval jsret = quaternion_to_jsval(cx, ret); + + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} + +bool js_cocos2dx_CCSprite_textureLoaded(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + Sprite* cobj = (Sprite*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj); + + bool ret = false; + if( cobj->getTexture() ) + ret = true; + + args.rval().set(BOOLEAN_TO_JSVAL(ret)); + return true; +} + +bool js_cocos2dx_CCTexture2D_setTexParameters(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + Texture2D* cobj = (Texture2D*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + if (argc == 4) + { + bool ok = true; + + GLuint arg0, arg1, arg2, arg3; + + ok &= jsval_to_uint32(cx, args.get(0), &arg0); + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + ok &= jsval_to_uint32(cx, args.get(3), &arg3); + + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + Texture2D::TexParams param = { arg0, arg1, arg2, arg3 }; + + cobj->setTexParameters(param); + + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} + +bool js_cocos2dx_CCMenu_alignItemsInRows(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); + bool ok = true; + js_proxy_t *proxy = jsb_get_js_proxy(jsthis); + Menu* cobj = (Menu*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + ValueVector items; + ok &= jsvals_variadic_to_ccvaluevector(cx, args.array(), argc, &items); + if (ok) + { + cobj->alignItemsInRowsWithArray(items); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "Error in js_cocos2dx_CCMenu_alignItemsInRows"); + return false; +} + +bool js_cocos2dx_CCMenu_alignItemsInColumns(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject jsthis(cx, args.thisv().toObjectOrNull()); + bool ok = true; + js_proxy_t *proxy = jsb_get_js_proxy(jsthis); + Menu* cobj = (Menu*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + + ValueVector items; + ok &= jsvals_variadic_to_ccvaluevector(cx, args.array(), argc, &items); + if (ok) + { + cobj->alignItemsInColumnsWithArray(items); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "Error in js_cocos2dx_CCMenu_alignItemsInColumns"); + return false; +} + +bool js_cocos2dx_CCLayer_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Layer* cobj = (cocos2d::Layer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_CCLayer_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_CCLayer_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + + +// TMXLayer +bool js_cocos2dx_CCTMXLayer_getTileFlagsAt(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JSObject *obj; + TMXLayer* cobj; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (TMXLayer*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + if (argc == 1) + { + TMXTileFlags flags; + Point arg0; + ok &= jsval_to_ccpoint(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cobj->getTileGIDAt(arg0, &flags); + + args.rval().set(UINT_TO_JSVAL((uint32_t)flags)); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} + +//#pragma mark - DrawNode + +// Arguments: Array of points, fill color (Color4F), width(float), border color (Color4F) +// Ret value: void +bool js_cocos2dx_CCDrawNode_drawPolygon(JSContext *cx, uint32_t argc, jsval *vp) +{ + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + DrawNode* cobj = (DrawNode*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + if ( argc == 4) { + bool ok = true; + JS::RootedObject argArray(cx); + Color4F argFillColor = Color4F(0.0f, 0.0f, 0.0f, 0.0f); + double argWidth = 0.0; + Color4F argBorderColor = Color4F(0.0f, 0.0f, 0.0f, 0.0f); + + // Points + ok &= JS_ValueToObject(cx, args.get(0), &argArray); + JSB_PRECONDITION2( (argArray && JS_IsArrayObject(cx, argArray)) , cx, false, "Vertex should be anArray object"); + + // Color 4F + ok &= jsval_to_cccolor4f(cx, args.get(1), &argFillColor); + + // Width + ok &= JS::ToNumber( cx, args.get(2), &argWidth ); + + // Color Border (4F) + ok &= jsval_to_cccolor4f(cx, args.get(3), &argBorderColor); + + JSB_PRECONDITION2(ok, cx, false, "Error parsing arguments"); + + { + uint32_t l; + if( ! JS_GetArrayLength(cx, argArray, &l) ) + return false; + + Point* verts = new Point[ l ]; + Point p; + + for( uint32_t i=0; idrawPolygon(verts, l, argFillColor, argWidth, argBorderColor); + CC_SAFE_DELETE_ARRAY(verts); + } + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} + +static bool jsval_to_string_vector(JSContext* cx, jsval v, std::vector& ret) { + JS::RootedObject jsobj(cx); + bool ok = JS_ValueToObject( cx, JS::RootedValue(cx, v), &jsobj ); + JSB_PRECONDITION2( ok, cx, false, "Error converting value to object"); + JSB_PRECONDITION2( jsobj && JS_IsArrayObject( cx, jsobj), cx, false, "Object must be an array"); + + uint32_t len = 0; + JS_GetArrayLength(cx, jsobj, &len); + + for (uint32_t i=0; i < len; i++) { + JS::RootedValue elt(cx); + if (JS_GetElement(cx, jsobj, i, &elt)) { + + if (elt.isString()) + { + JSStringWrapper str(elt.toString()); + ret.push_back(str.get()); + } + } + } + + return true; +} + + +static jsval string_vector_to_jsval(JSContext* cx, const std::vector& arr) { + + JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, 0)); + + int i = 0; + for(std::vector::const_iterator iter = arr.begin(); iter != arr.end(); ++iter, ++i) { + JS::RootedValue arrElement(cx, std_string_to_jsval(cx, *iter)); + if(!JS_SetElement(cx, jsretArr, i, arrElement)) { + break; + } + } + return OBJECT_TO_JSVAL(jsretArr); +} + +bool js_cocos2dx_CCFileUtils_setSearchResolutionsOrder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 1) { + std::vector arg0; + ok &= jsval_to_string_vector(cx, args.get(0), arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cobj->setSearchResolutionsOrder(arg0); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_CCFileUtils_setSearchPaths(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 1) { + std::vector arg0; + ok &= jsval_to_string_vector(cx, args.get(0), arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cobj->setSearchPaths(arg0); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_CCFileUtils_getSearchPaths(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 0) { + std::vector ret = cobj->getSearchPaths(); + jsval jsret; + jsret = string_vector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +bool js_cocos2dx_CCFileUtils_getDataFromFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + Data data = cobj->getDataFromFile(arg0); + do + { + if (!data.isNull()) + { + uint32_t size = static_cast(data.getSize()); + JSObject* array = JS_NewUint8Array(cx, size); + if (nullptr == array) + break; + + uint8_t* bufdata = (uint8_t*)JS_GetArrayBufferViewData(array); + memcpy(bufdata, data.getBytes(), size*sizeof(uint8_t)); + + args.rval().set(OBJECT_TO_JSVAL(array)); + return true; + } + } while(false); + + JS_ReportError(cx, "get file(%s) data fails", arg0.c_str()); + return false; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} + +bool js_cocos2dx_CCFileUtils_getSearchResolutionsOrder(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 0) { + std::vector ret = cobj->getSearchResolutionsOrder(); + jsval jsret; + jsret = string_vector_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +static bool js_cocos2dx_FileUtils_createDictionaryWithContentsOfFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cocos2d::ValueMap ret = FileUtils::getInstance()->getValueMapFromFile(arg0.c_str()); + jsval jsret; + jsret = ccvaluemap_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_CCGLProgram_setUniformLocationWith4f(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, 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, "Invalid Native Object"); + int arg0; + double arg1; + double arg2; + double arg3; + double arg4; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + ok &= JS::ToNumber(cx, args.get(1), &arg1); + + if(argc == 2) { + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cobj->setUniformLocationWith1f(arg0, arg1); + } + if (argc == 3) { + ok &= JS::ToNumber(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cobj->setUniformLocationWith2f(arg0, arg1, arg2); + } + if(argc == 4) { + ok &= JS::ToNumber(cx, args.get(2), &arg2); + ok &= JS::ToNumber(cx, args.get(3), &arg3); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cobj->setUniformLocationWith3f(arg0, arg1, arg2, arg3); + } + if(argc == 5) { + ok &= JS::ToNumber(cx, args.get(2), &arg2); + ok &= JS::ToNumber(cx, args.get(3), &arg3); + ok &= JS::ToNumber(cx, args.get(4), &arg4); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cobj->setUniformLocationWith4f(arg0, arg1, arg2, arg3, arg4); + } + + args.rval().setUndefined(); + return true; + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 5); + return false; +} + +bool js_cocos2dx_CCGLProgram_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if(argc != 2) { + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); + return false; + } + + const char *arg0, *arg1; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + + GLProgram* ret = new GLProgram(); + ret->autorelease(); + + ret->initWithFilenames(arg0, arg1); + + jsval jsret; + do { + if (ret) { + js_proxy_t *p = jsb_get_native_proxy(ret); + if (p) { + jsret = OBJECT_TO_JSVAL(p->obj); + } else { + // create a new js obj of that class + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + +} + + +bool js_cocos2dx_CCGLProgram_createWithString(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if(argc != 2) { + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); + return false; + } + + const char *arg0, *arg1; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + + GLProgram* ret = new GLProgram(); + ret->initWithByteArrays(arg0, arg1); + + jsval jsret; + do { + if (ret) { + js_proxy_t *p = jsb_get_native_proxy(ret); + if (p) { + jsret = OBJECT_TO_JSVAL(p->obj); + } else { + // create a new js obj of that class + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + +} + +bool js_cocos2dx_CCGLProgram_getProgram(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + 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, "Invalid Native Object"); + if (argc == 0) { + GLuint ret = cobj->getProgram(); + args.rval().set(UINT_TO_JSVAL((uint32_t)ret)); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +bool js_cocos2dx_GLProgramState_setVertexAttribPointer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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; + long arg5; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + ok &= jsval_to_uint32(cx, args.get(2), &arg2); + ok &= jsval_to_uint16(cx, args.get(3), &arg3); + ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); + ok &= jsval_to_long(cx, args.get(5), &arg5); + + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgramState_setVertexAttribPointer : Error processing arguments"); + cobj->setVertexAttribPointer(arg0, arg1, arg2, arg3, arg4, (GLvoid*)arg5); + args.rval().setUndefined(); + 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_setUniformVec4(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_setUniformVec4 : Invalid Native Object"); + bool ok = true; + if(argc == 2) + { + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec4 arg1; + ok &= jsval_to_vector4(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformVec4(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 2) { + int arg0; + ok &= jsval_to_int(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec4 arg1; + ok &= jsval_to_vector4(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformVec4(arg0, arg1); + args.rval().setUndefined(); + return true; + } + } while(0); + } + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setUniformVec4 : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} + +#define js_cocos2dx_CCCamera_getXYZ(funcName) \ + bool ok = true; \ + JSObject *obj = JS_THIS_OBJECT(cx, vp); \ + js_proxy_t *proxy = jsb_get_js_proxy(obj); \ + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); \ + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); \ + if (argc == 0) { \ + float x; \ + float y; \ + float z; \ + cobj->funcName(&x, &y, &z); \ + JSObject* tmp = JS_NewObject(cx, NULL, NULL, NULL); \ + \ + do \ + { \ + if (NULL == tmp) break; \ + \ + ok = JS_DefineProperty(cx, tmp, "x", DOUBLE_TO_JSVAL(x), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && \ + JS_DefineProperty(cx, tmp, "y", DOUBLE_TO_JSVAL(y), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && \ + JS_DefineProperty(cx, tmp, "z", DOUBLE_TO_JSVAL(z), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); \ + \ + if (ok) { \ + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); \ + return true; \ + } \ + } while (false); \ + \ + JS_SET_RVAL(cx, vp, JSVAL_NULL); \ + return true; \ + } \ + \ + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); \ + return false; + + + +bool js_cocos2dx_SpriteBatchNode_getDescendants(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::SpriteBatchNode* cobj = (cocos2d::SpriteBatchNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpriteBatchNode_getDescendants : Invalid Native Object"); + if (argc == 0) { + std::vector ret = cobj->getDescendants(); + + JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, 0)); + size_t vSize = ret.size(); + JS::RootedValue jsret(cx); + for (size_t i = 0; i < vSize; i++) + { + proxy = js_get_or_create_proxy(cx, ret[i]); + jsret = OBJECT_TO_JSVAL(proxy->obj); + JS_SetElement(cx, jsretArr, static_cast(i), jsret); + } + args.rval().set(OBJECT_TO_JSVAL(jsretArr)); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_SpriteBatchNode_getDescendants : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +bool js_cocos2dx_NodeGrid_setGrid(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::NodeGrid* cobj = (cocos2d::NodeGrid *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_NodeGrid_setGrid : Invalid Native Object"); + if (argc == 1) { + cocos2d::GridBase* arg0; + do { + if(args.get(0).isNull()) { arg0 = nullptr; break;} + if (!args.get(0).isObject()) { ok = false; break; } + JSObject *tmpObj = args.get(0).toObjectOrNull(); + proxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::GridBase*)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_NodeGrid_setGrid : Error processing arguments"); + cobj->setGrid(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_NodeGrid_setGrid : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +// cc.PlistParser.getInstance() +bool js_PlistParser_getInstance(JSContext *cx, unsigned argc, JS::Value *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + __JSPlistDelegator* delegator = __JSPlistDelegator::getInstance(); + SAXParser* parser = delegator->getParser(); + + jsval jsret; + if (parser) { + js_proxy_t *p = jsb_get_native_proxy(parser); + if (p) { + jsret = OBJECT_TO_JSVAL(p->obj); + } else { + // create a new js obj of that class + js_proxy_t *proxy = js_get_or_create_proxy(cx, parser); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + } else { + jsret = JSVAL_NULL; + } + args.rval().set(jsret); + + return true; +} +// cc.PlistParser.getInstance().parse(text) +bool js_PlistParser_parse(JSContext *cx, unsigned argc, JS::Value *vp) { + __JSPlistDelegator* delegator = __JSPlistDelegator::getInstance(); + + bool ok = true; + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + std::string parsedStr = delegator->parseText(arg0); + std::replace(parsedStr.begin(), parsedStr.end(), '\n', ' '); + + jsval strVal = std_string_to_jsval(cx, parsedStr); + // create a new js obj of the parsed string + JS::RootedValue outVal(cx); + + //JS_GetStringCharsZ was removed in SpiderMonkey 33 + //ok = JS_ParseJSON(cx, JS_GetStringCharsZ(cx, strVal), static_cast(JS_GetStringEncodingLength(JSVAL_TO_STRING(strVal))), &outVal); + ok = JS_ParseJSON(cx, JS::RootedString(cx, strVal.toString()), &outVal); + + if (ok) + args.rval().set(outVal); + else { + args.rval().setUndefined(); + JS_ReportError(cx, "js_PlistParser_parse : parse error"); + } + return true; + } + JS_ReportError(cx, "js_PlistParser_parse : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +cocos2d::SAXParser* __JSPlistDelegator::getParser() { + return &_parser; +} + +std::string __JSPlistDelegator::parse(const std::string& path) { + _result.clear(); + + SAXParser parser; + if (false != parser.init("UTF-8") ) + { + parser.setDelegator(this); + parser.parse(FileUtils::getInstance()->fullPathForFilename(path).c_str()); + } + + return _result; +} + +__JSPlistDelegator::~__JSPlistDelegator(){ + CCLOGINFO("deallocing __JSSAXDelegator: %p", this); +} + +std::string __JSPlistDelegator::parseText(const std::string& text){ + _result.clear(); + + SAXParser parser; + if (false != parser.init("UTF-8") ) + { + parser.setDelegator(this); + parser.parse(text.c_str(), text.size()); + } + + return _result; +} + +void __JSPlistDelegator::startElement(void *ctx, const char *name, const char **atts) { + _isStoringCharacters = true; + _currentValue.clear(); + + std::string elementName = (char*)name; + + int end = (int)_result.size() - 1; + if(end >= 0 && _result[end] != '{' && _result[end] != '[' && _result[end] != ':') { + _result += ","; + } + + if (elementName == "dict") { + _result += "{"; + } + else if (elementName == "array") { + _result += "["; + } +} + +void __JSPlistDelegator::endElement(void *ctx, const char *name) { + _isStoringCharacters = false; + std::string elementName = (char*)name; + + if (elementName == "dict") { + _result += "}"; + } + else if (elementName == "array") { + _result += "]"; + } + else if (elementName == "key") { + _result += "\"" + _currentValue + "\":"; + } + else if (elementName == "string") { + _result += "\"" + _currentValue + "\""; + } + else if (elementName == "false" || elementName == "true") { + _result += elementName; + } + else if (elementName == "real" || elementName == "integer") { + _result += _currentValue; + } +} + +void __JSPlistDelegator::textHandler(void *ctx, const char *ch, int len) { + CC_UNUSED_PARAM(ctx); + std::string text((char*)ch, 0, len); + + if (_isStoringCharacters) + { + _currentValue += text; + } +} + +bool jsval_to_TTFConfig(JSContext *cx, jsval v, TTFConfig* ret) { + JS::RootedObject tmp(cx); + JS::RootedValue js_fontFilePath(cx); + JS::RootedValue js_fontSize(cx); + JS::RootedValue js_outlineSize(cx); + JS::RootedValue js_glyphs(cx); + JS::RootedValue js_customGlyphs(cx); + JS::RootedValue js_distanceFieldEnable(cx); + + std::string fontFilePath,customGlyphs; + double fontSize, glyphs, outlineSize; + + bool ok = v.isObject() && + JS_ValueToObject(cx, JS::RootedValue(cx, v), &tmp) && + JS_GetProperty(cx, tmp, "fontFilePath", &js_fontFilePath) && + JS_GetProperty(cx, tmp, "fontSize", &js_fontSize) && + JS_GetProperty(cx, tmp, "outlineSize", &js_outlineSize) && + JS_GetProperty(cx, tmp, "glyphs", &js_glyphs) && + JS_GetProperty(cx, tmp, "customGlyphs", &js_customGlyphs) && + JS_GetProperty(cx, tmp, "distanceFieldEnable", &js_distanceFieldEnable) && + JS::ToNumber(cx, js_fontSize, &fontSize) && + JS::ToNumber(cx, js_outlineSize, &outlineSize) && + JS::ToNumber(cx, js_glyphs, &glyphs) && + jsval_to_std_string(cx,js_fontFilePath,&ret->fontFilePath) && + jsval_to_std_string(cx,js_customGlyphs,&customGlyphs); + bool distanceFieldEnable = JS::ToBoolean(js_distanceFieldEnable); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + ret->fontSize = (int)fontSize; + ret->outlineSize = (int)outlineSize; + ret->glyphs = GlyphCollection((int)glyphs); + ret->distanceFieldEnabled = distanceFieldEnable; + if(ret->glyphs == GlyphCollection::CUSTOM && customGlyphs.length() > 0) + ret->customGlyphs = customGlyphs.c_str(); + else + ret->customGlyphs = nullptr; + + return true; +} + +bool js_cocos2dx_Label_createWithTTF(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc < 2) + return false; + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + TTFConfig ttfConfig(""); + std::string text; + + ok &= jsval_to_TTFConfig(cx, args.get(0), &ttfConfig); + ok &= jsval_to_std_string(cx, args.get(1), &text); + + cocos2d::Label* ret = nullptr; + + if (argc == 2) { + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_createWithTTF : Error processing arguments"); + ret = cocos2d::Label::createWithTTF(ttfConfig, text); + jsval jsret = JSVAL_NULL; + if (ret) { + js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + args.rval().set(jsret); + return true; + } + if (argc == 3) { + int arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_createWithTTF : Error processing arguments"); + TextHAlignment alignment = TextHAlignment(arg2); + ret = cocos2d::Label::createWithTTF(ttfConfig, text, alignment); + jsval jsret = JSVAL_NULL; + if (ret) { + js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + args.rval().set(jsret); + return true; + } + if (argc == 4) { + int arg2,arg3; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_createWithTTF : Error processing arguments"); + TextHAlignment alignment = TextHAlignment(arg2); + ret = cocos2d::Label::createWithTTF(ttfConfig, text, alignment, arg3); + jsval jsret = JSVAL_NULL; + if (ret) { + js_proxy_t *proxy = js_get_or_create_proxy(cx, (cocos2d::Label*)ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_createWithTTF : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Label_setTTFConfig(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_setTTFConfig : Invalid Native Object"); + + if (argc == 1) { + TTFConfig ttfConfig(""); + do { + if (!args.get(0).isObject()) { ok = false; break; } + ok &= jsval_to_TTFConfig(cx, args.get(0), &ttfConfig); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Label_setTTFConfig : Error processing arguments"); + cobj->setTTFConfig(ttfConfig); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_setTTFConfig : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_RenderTexture_saveToFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JSObject *obj = NULL; + cocos2d::RenderTexture* cobj = NULL; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::RenderTexture *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_RenderTexture_saveToFile : Invalid Native Object"); + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Image::Format arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->saveToFile(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Image::Format arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + bool arg2; + arg2 = JS::ToBoolean(JS::RootedValue(cx, args.get(2))); + bool ret = cobj->saveToFile(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 4) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Image::Format arg1; + ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1); + if (!ok) { ok = true; break; } + bool arg2; + arg2 = JS::ToBoolean(JS::RootedValue(cx, args.get(2))); + std::function &)> arg3; + do { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), args.get(3))); + auto lambda = [=](cocos2d::RenderTexture* larg0, const std::string& larg1) -> void { + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::RenderTexture*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + do { + largv[1] = std_string_to_jsval(cx, larg1); + } while (0); + JS::RootedValue rval(cx); + bool ok = func->invoke(2, largv, &rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg3 = lambda; + } while(0) + ; + if (!ok) { ok = true; break; } + bool ret = cobj->saveToFile(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + bool ret = cobj->saveToFile(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + bool arg1; + arg1 = JS::ToBoolean(JS::RootedValue(cx, args.get(1))); + bool ret = cobj->saveToFile(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + bool arg1; + arg1 = JS::ToBoolean(JS::RootedValue(cx, args.get(1))); + std::function &)> arg2; + do { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), args.get(2))); + auto lambda = [=](cocos2d::RenderTexture* larg0, const std::string& larg1) -> void { + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::RenderTexture*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + do { + largv[1] = std_string_to_jsval(cx, larg1); + } while (0); + JS::RootedValue rval(cx); + bool ok = func->invoke(2, largv, &rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg2 = lambda; + } while(0) + ; + if (!ok) { ok = true; break; } + bool ret = cobj->saveToFile(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_RenderTexture_saveToFile : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Camera_unproject(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_unproject : Invalid Native Object"); + if (argc == 2) { + cocos2d::Size arg0; + cocos2d::Vec3 arg1; + cocos2d::Vec3 arg2; + ok &= jsval_to_ccsize(cx, args.get(0), &arg0); + ok &= jsval_to_vector3(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Camera_unproject : Error processing arguments"); + cobj->unproject(arg0, &arg1, &arg2); + args.rval().set(vector3_to_jsval(cx, arg2)); + return true; + } + else if (argc == 1) + { + cocos2d::Vec3 arg0; + ok &= jsval_to_vector3(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Camera_unproject : Error processing arguments"); + cocos2d::Vec3 ret = cobj->unproject(arg0); + args.rval().set(vector3_to_jsval(cx, ret)); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Camera_unproject : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} + +bool js_cocos2dx_Camera_isVisibleInFrustum(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Camera* cobj = (cocos2d::Camera *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Camera_isVisibleInFrustum : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec3 min; + JS::RootedValue jsmin(cx); + ok &= JS_GetProperty(cx, JS::RootedObject(cx, args.get(0).toObjectOrNull()), "min", &jsmin); + ok &= jsval_to_vector3(cx, jsmin, &min); + + cocos2d::Vec3 max; + JS::RootedValue jsmax(cx); + ok &= JS_GetProperty(cx, JS::RootedObject(cx, args.get(0).toObjectOrNull()), "max", &jsmax); + ok &= jsval_to_vector3(cx, jsmax, &max); + + cocos2d::AABB aabb(min, max); + + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Camera_isVisibleInFrustum : Error processing arguments"); + bool ret = cobj->isVisibleInFrustum(&aabb); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Camera_isVisibleInFrustum : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_Node_setAdditionalTransform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + JS::RootedObject obj(cx); + cocos2d::Node* cobj = NULL; + obj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_setAdditionalTransform : Invalid Native Object"); + + do { + if (argc == 1) { + cocos2d::Mat4 arg0; + ok &= jsval_to_matrix(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->setAdditionalTransform(&arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + do { + if (argc == 1) { + cocos2d::AffineTransform arg0; + ok &= jsval_to_ccaffinetransform(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cobj->setAdditionalTransform(arg0); + args.rval().setUndefined(); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_Node_setAdditionalTransform : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_ClippingNode_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + 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_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 1) { + cocos2d::Node* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ClippingNode_init : Error processing arguments"); + bool ret = cobj->init(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ClippingNode_init : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +// EventKeyboard class bindings, need manual bind for transform key codes + +JSClass *jsb_cocos2d_EventKeyboard_class; +JSObject *jsb_cocos2d_EventKeyboard_prototype; + +bool js_cocos2dx_EventKeyboard_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + cocos2d::EventKeyboard::KeyCode arg0; + ScriptingCore *core = ScriptingCore::getInstance(); + JS::RootedValue retVal(cx); + core->executeFunctionWithOwner(OBJECT_TO_JSVAL(core->getGlobalObject()), "parseKeyCode", args, &retVal); + ok &= jsval_to_int32(cx, retVal, (int32_t *)&arg0); + + bool arg1; + arg1 = JS::ToBoolean(JS::RootedValue(cx, args.get(1))); + + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventKeyboard_constructor : Error processing arguments"); + + cocos2d::EventKeyboard* cobj = new (std::nothrow) cocos2d::EventKeyboard(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."); + JSObject *obj = JS_NewObject(cx, typeClass->jsclass, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto)); + args.rval().set( 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::EventKeyboard"); + return true; +} + + +extern JSObject *jsb_cocos2d_Event_prototype; + +void js_cocos2d_EventKeyboard_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EventKeyboard)", obj); +} + +static bool js_is_native_obj(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().set(BOOLEAN_TO_JSVAL(true)); + return true; +} + +void js_register_cocos2dx_EventKeyboard(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_EventKeyboard_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_EventKeyboard_class->name = "EventKeyboard"; + jsb_cocos2d_EventKeyboard_class->addProperty = JS_PropertyStub; + jsb_cocos2d_EventKeyboard_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_EventKeyboard_class->getProperty = JS_PropertyStub; + jsb_cocos2d_EventKeyboard_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_EventKeyboard_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_EventKeyboard_class->resolve = JS_ResolveStub; + jsb_cocos2d_EventKeyboard_class->convert = JS_ConvertStub; + jsb_cocos2d_EventKeyboard_class->finalize = js_cocos2d_EventKeyboard_finalize; + jsb_cocos2d_EventKeyboard_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_EventKeyboard_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Event_prototype), + jsb_cocos2d_EventKeyboard_class, + js_cocos2dx_EventKeyboard_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, "EventKeyboard", 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_EventKeyboard_class; + p->proto = jsb_cocos2d_EventKeyboard_prototype; + p->parentProto = jsb_cocos2d_Event_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +// console.log("Message"); +bool js_console_log(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 1) { + std::string msg; + bool ok = jsval_to_std_string(cx, args.get(0), &msg); + JSB_PRECONDITION2(ok, cx, false, "js_console_log : Error processing arguments"); + + log("%s", msg.c_str()); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_console_log : wrong number of arguments"); + return false; +} + +void get_or_create_js_obj(JSContext* cx, JS::HandleObject obj, const std::string &name, JS::MutableHandleObject jsObj) +{ + JS::RootedValue nsval(cx); + JS_GetProperty(cx, obj, name.c_str(), &nsval); + if (nsval == JSVAL_VOID) { + jsObj.set(JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr())); + nsval = OBJECT_TO_JSVAL(jsObj); + JS_SetProperty(cx, obj, name.c_str(), nsval); + } else { + jsObj.set(nsval.toObjectOrNull()); + } +} + +void register_cocos2dx_js_core(JSContext* cx, JS::HandleObject global) +{ + JS::RootedObject ccObj(cx); + JS::RootedValue tmpVal(cx); + JS::RootedObject tmpObj(cx); + get_or_create_js_obj(cx, global, "cc", &ccObj); + + JS_GetProperty(cx, ccObj, "PlistParser", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "getInstance", js_PlistParser_getInstance, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS::RootedObject proto(cx, jsb_cocos2d_SAXParser_prototype); + JS_DefineFunction(cx, proto, "parse", js_PlistParser_parse, 1, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_GetProperty(cx, ccObj, "Label", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "createWithTTF", js_cocos2dx_Label_createWithTTF, 4, JSPROP_READONLY | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_Label_prototype); + JS_DefineFunction(cx, tmpObj, "setTTFConfig", js_cocos2dx_Label_setTTFConfig, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_NodeGrid_prototype); + JS_DefineFunction(cx, tmpObj, "setGrid", js_cocos2dx_NodeGrid_setGrid, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_Node_prototype); + JS_DefineFunction(cx, tmpObj, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "onEnter", js_cocos2dx_Node_onEnter, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "onExit", js_cocos2dx_Node_onExit, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "onEnterTransitionDidFinish", js_cocos2dx_Node_onEnterTransitionDidFinish, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "onExitTransitionDidStart", js_cocos2dx_Node_onExitTransitionDidStart, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "schedule", js_CCNode_schedule, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "scheduleOnce", js_CCNode_scheduleOnce, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "scheduleUpdateWithPriority", js_cocos2dx_CCNode_scheduleUpdateWithPriority, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "unscheduleUpdate", js_cocos2dx_CCNode_unscheduleUpdate, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "scheduleUpdate", js_cocos2dx_CCNode_scheduleUpdate, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "unschedule", js_CCNode_unschedule, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "unscheduleAllCallbacks", js_cocos2dx_CCNode_unscheduleAllSelectors, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "setPosition", js_cocos2dx_CCNode_setPosition, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "setContentSize", js_cocos2dx_CCNode_setContentSize, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "setAnchorPoint", js_cocos2dx_CCNode_setAnchorPoint, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "setColor", js_cocos2dx_CCNode_setColor, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "pause", js_cocos2dx_CCNode_pause, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "resume", js_cocos2dx_CCNode_resume, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "convertToWorldSpace", js_cocos2dx_CCNode_convertToWorldSpace, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "convertToWorldSpaceAR", js_cocos2dx_CCNode_convertToWorldSpaceAR, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "setAdditionalTransform", js_cocos2dx_Node_setAdditionalTransform, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_EventListener_prototype); + JS_DefineFunction(cx, tmpObj, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_Touch_prototype); + JS_DefineFunction(cx, tmpObj, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_EventTouch_prototype); + JS_DefineFunction(cx, tmpObj, "getTouches", js_cocos2dx_EventTouch_getTouches, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "setTouches", js_cocos2dx_EventTouch_setTouches, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_GLProgram_prototype); + JS_DefineFunction(cx, tmpObj, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "setUniformLocationF32", js_cocos2dx_CCGLProgram_setUniformLocationWith4f, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "getProgram", js_cocos2dx_CCGLProgram_getProgram, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_GLProgramState_prototype); + JS_DefineFunction(cx, tmpObj, "setVertexAttribPointer", js_cocos2dx_GLProgramState_setVertexAttribPointer, 6, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "setUniformVec4", js_cocos2dx_GLProgramState_setUniformVec4, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_Component_prototype); + JS_DefineFunction(cx, tmpObj, "onEnter", js_cocos2dx_Component_onEnter, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "onExit", js_cocos2dx_Component_onExit, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_Scheduler_prototype); + JS_DefineFunction(cx, tmpObj, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "resumeTarget", js_cocos2dx_CCScheduler_resumeTarget, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "pauseTarget", js_cocos2dx_CCScheduler_pauseTarget, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "scheduleUpdateForTarget", js_CCScheduler_scheduleUpdateForTarget, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "unscheduleUpdate", js_CCScheduler_unscheduleUpdateForTarget, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "schedule", js_CCScheduler_schedule, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "scheduleCallbackForTarget", js_CCScheduler_scheduleCallbackForTarget, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "unschedule", js_CCScheduler_unscheduleCallbackForTarget, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "unscheduleCallbackForTarget", js_CCScheduler_unscheduleCallbackForTarget, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "unscheduleAllForTarget", js_cocos2dx_CCScheduler_unscheduleAllSelectorsForTarget, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "unscheduleAllCallbacks", js_cocos2dx_CCScheduler_unscheduleAll, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "unscheduleAllCallbacksWithMinPriority", js_cocos2dx_CCScheduler_unscheduleAllCallbacksWithMinPriority, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "isTargetPaused", js_cocos2dx_CCScheduler_isTargetPaused, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_ActionManager_prototype); + JS_DefineFunction(cx, tmpObj, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_TMXLayer_prototype); + JS_DefineFunction(cx, tmpObj, "getTileFlagsAt", js_cocos2dx_CCTMXLayer_getTileFlagsAt, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_DrawNode_prototype); + JS_DefineFunction(cx, tmpObj, "drawPoly", js_cocos2dx_CCDrawNode_drawPolygon, 4, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_Texture2D_prototype); + JS_DefineFunction(cx, tmpObj, "setTexParameters", js_cocos2dx_CCTexture2D_setTexParameters, 4, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_Menu_prototype); + JS_DefineFunction(cx, tmpObj, "alignItemsInRows", js_cocos2dx_CCMenu_alignItemsInRows, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "alignItemsInColumns", js_cocos2dx_CCMenu_alignItemsInColumns, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_Layer_prototype); + JS_DefineFunction(cx, tmpObj, "init", js_cocos2dx_CCLayer_init, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_FileUtils_prototype); + JS_DefineFunction(cx, tmpObj, "setSearchResolutionsOrder", js_cocos2dx_CCFileUtils_setSearchResolutionsOrder, 1, JSPROP_PERMANENT ); + JS_DefineFunction(cx, tmpObj, "setSearchPaths", js_cocos2dx_CCFileUtils_setSearchPaths, 1, JSPROP_PERMANENT ); + JS_DefineFunction(cx, tmpObj, "getSearchPaths", js_cocos2dx_CCFileUtils_getSearchPaths, 0, JSPROP_PERMANENT ); + JS_DefineFunction(cx, tmpObj, "getSearchResolutionsOrder", js_cocos2dx_CCFileUtils_getSearchResolutionsOrder, 0, JSPROP_PERMANENT ); + JS_DefineFunction(cx, tmpObj, "createDictionaryWithContentsOfFile", js_cocos2dx_FileUtils_createDictionaryWithContentsOfFile, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "getDataFromFile", js_cocos2dx_CCFileUtils_getDataFromFile, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_GetProperty(cx, ccObj, "EventListenerTouchOneByOne", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_EventListenerTouchOneByOne_create, 0, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_GetProperty(cx, ccObj, "EventListenerTouchAllAtOnce", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_EventListenerTouchAllAtOnce_create, 0, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_GetProperty(cx, ccObj, "EventListenerMouse", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_EventListenerMouse_create, 0, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_GetProperty(cx, ccObj, "EventListenerKeyboard", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_EventListenerKeyboard_create, 0, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_GetProperty(cx, ccObj, "EventListenerFocus", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_EventListenerFocus_create, 0, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_GetProperty(cx, ccObj, "BezierBy", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", JSB_CCBezierBy_actionWithDuration, 2, JSPROP_READONLY | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_BezierBy_prototype); + JS_DefineFunction(cx, tmpObj, "initWithDuration", JSB_CCBezierBy_initWithDuration, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_GetProperty(cx, ccObj, "BezierTo", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", JSB_CCBezierTo_actionWithDuration, 2, JSPROP_READONLY | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_BezierTo_prototype); + JS_DefineFunction(cx, tmpObj, "initWithDuration", JSB_CCBezierTo_initWithDuration, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_GetProperty(cx, ccObj, "CardinalSplineBy", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", JSB_CCCardinalSplineBy_actionWithDuration, 2, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_GetProperty(cx, ccObj, "CardinalSplineTo", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", JSB_CCCardinalSplineTo_actionWithDuration, 2, JSPROP_READONLY | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_CardinalSplineTo_prototype); + JS_DefineFunction(cx, tmpObj, "initWithDuration", js_cocos2dx_CardinalSplineTo_initWithDuration, 3, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_GetProperty(cx, ccObj, "CatmullRomBy", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", JSB_CCCatmullRomBy_actionWithDuration, 2, JSPROP_READONLY | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_CatmullRomBy_prototype); + JS_DefineFunction(cx, tmpObj, "initWithDuration", JSB_CatmullRomBy_initWithDuration, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_GetProperty(cx, ccObj, "CatmullRomTo", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", JSB_CCCatmullRomTo_actionWithDuration, 2, JSPROP_READONLY | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_CatmullRomTo_prototype); + JS_DefineFunction(cx, tmpObj, "initWithDuration", JSB_CatmullRomBy_initWithDuration, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_Sprite_prototype); + JS_DefineFunction(cx, tmpObj, "textureLoaded", js_cocos2dx_CCSprite_textureLoaded, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_SpriteBatchNode_prototype); + JS_DefineFunction(cx, tmpObj, "getDescendants", js_cocos2dx_SpriteBatchNode_getDescendants, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_Action_prototype); + JS_DefineFunction(cx, tmpObj, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_Animation_prototype); + JS_DefineFunction(cx, tmpObj, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_SpriteFrame_prototype); + JS_DefineFunction(cx, tmpObj, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_MenuItem_prototype); + JS_DefineFunction(cx, tmpObj, "setCallback", js_cocos2dx_MenuItem_setCallback, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_TMXLayer_prototype); + JS_DefineFunction(cx, tmpObj, "getTileFlagsAt", js_cocos2dx_CCTMXLayer_tileFlagsAt, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "getTiles", js_cocos2dx_CCTMXLayer_getTiles, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_ActionInterval_prototype); + JS_DefineFunction(cx, tmpObj, "repeat", js_cocos2dx_ActionInterval_repeat, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "repeatForever", js_cocos2dx_ActionInterval_repeatForever, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "_speed", js_cocos2dx_ActionInterval_speed, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "easing", js_cocos2dx_ActionInterval_easing, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_RenderTexture_prototype); + JS_DefineFunction(cx, tmpObj, "saveToFile", js_cocos2dx_RenderTexture_saveToFile, 4, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_GetProperty(cx, ccObj, "Menu", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "_create", js_cocos2dx_CCMenu_create, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_GetProperty(cx, ccObj, "MenuItem", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCMenuItem_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_GetProperty(cx, ccObj, "MenuItemSprite", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCMenuItemSprite_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_GetProperty(cx, ccObj, "MenuItemLabel", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCMenuItemLabel_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_GetProperty(cx, ccObj, "MenuItemAtlasFont", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCMenuItemAtlasFont_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_GetProperty(cx, ccObj, "MenuItemFont", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCMenuItemFont_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_GetProperty(cx, ccObj, "MenuItemToggle", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "_create", js_cocos2dx_CCMenuItemToggle_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_GetProperty(cx, ccObj, "Sequence", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCSequence_create, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_GetProperty(cx, ccObj, "Spawn", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCSpawn_create, 0, JSPROP_READONLY | JSPROP_PERMANENT); + //JS_GetProperty(cx, ccObj, "Animation", &tmpVal); + //tmpObj = tmpVal.toObjectOrNull(); + //JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCAnimation_create, 0, JSPROP_READONLY | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_Scene_prototype); + JS_DefineFunction(cx, tmpObj, "init", js_cocos2dx_CCScene_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE); + JS_GetProperty(cx, ccObj, "LayerMultiplex", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCLayerMultiplex_create, 0, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_GetProperty(cx, ccObj, "CallFunc", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_callFunc, 1, JSPROP_READONLY | JSPROP_PERMANENT); + tmpObj.set(jsb_cocos2d_CallFuncN_prototype); + JS_DefineFunction(cx, tmpObj, "initWithFunction", js_cocos2dx_CallFunc_initWithFunction, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_GetProperty(cx, ccObj, "GLProgram", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCGLProgram_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "createWithString", js_cocos2dx_CCGLProgram_createWithString, 1, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_DefineFunction(cx, global, "garbageCollect", js_forceGC, 1, JSPROP_READONLY | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_Camera_prototype); + JS_DefineFunction(cx, tmpObj, "unproject", js_cocos2dx_Camera_unproject, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "isVisibleInFrustum", js_cocos2dx_Camera_isVisibleInFrustum, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + tmpObj.set(jsb_cocos2d_ClippingNode_prototype); + JS_DefineFunction(cx, tmpObj, "init", js_cocos2dx_ClippingNode_init, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_DefineFunction(cx, ccObj, "glEnableVertexAttribs", js_cocos2dx_ccGLEnableVertexAttribs, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ccObj, "pAdd", js_cocos2dx_ccpAdd, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ccObj, "pDistanceSQ", js_cocos2dx_ccpDistanceSQ, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ccObj, "pDistance", js_cocos2dx_ccpDistance, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ccObj, "pSub", js_cocos2dx_ccpSub, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ccObj, "pNeg", js_cocos2dx_ccpNeg, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ccObj, "pMult", js_cocos2dx_ccpMult, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ccObj, "pMidpoint", js_cocos2dx_ccpMidpoint, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ccObj, "pDot", js_cocos2dx_ccpDot, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ccObj, "pCross", js_cocos2dx_ccpCross, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ccObj, "pPerp", js_cocos2dx_ccpPerp, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ccObj, "pRPerp", js_cocos2dx_ccpRPerp, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ccObj, "pProject", js_cocos2dx_ccpProject, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ccObj, "pRotate", js_cocos2dx_ccpRotate, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ccObj, "pNormalize", js_cocos2dx_ccpNormalize, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ccObj, "pClamp", js_cocos2dx_ccpClamp, 2, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ccObj, "pLengthSQ", js_cocos2dx_ccpLengthSQ, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ccObj, "pLength", js_cocos2dx_ccpLength, 1, JSPROP_READONLY | JSPROP_PERMANENT); + + + JS_DefineFunction(cx, ccObj, "registerTargetedDelegate", js_cocos2dx_JSTouchDelegate_registerTargetedDelegate, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ccObj, "registerStandardDelegate", js_cocos2dx_JSTouchDelegate_registerStandardDelegate, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, ccObj, "unregisterTouchDelegate", js_cocos2dx_JSTouchDelegate_unregisterTouchDelegate, 1, JSPROP_READONLY | JSPROP_PERMANENT); + + get_or_create_js_obj(cx, ccObj, "math", &tmpObj); + JS_DefineFunction(cx, tmpObj, "obbGetCorners", js_cocos2dx_ccobbGetCorners, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "obbIntersectsObb", js_cocos2dx_ccobbIntersects, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "rayIntersectsObb", js_cocos2dx_ccrayIntersectsObb, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "mat4CreateTranslation", js_cocos2dx_ccmat4CreateTranslation, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "mat4CreateRotation", js_cocos2dx_ccmat4CreateRotation, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "mat4Multiply", js_cocos2dx_ccmat4Multiply, 2, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "mat4MultiplyVec3", js_cocos2dx_ccmat4MultiplyVec3, 2, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "quatMultiply", js_cocos2dx_ccquatMultiply, 2, JSPROP_READONLY | JSPROP_PERMANENT); + + js_register_cocos2dx_EventKeyboard(cx, ccObj); + + get_or_create_js_obj(cx, global, "console", &tmpObj); + JS_DefineFunction(cx, tmpObj, "log", js_console_log, 1, JSPROP_READONLY | JSPROP_PERMANENT); +} diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp new file mode 100644 index 0000000000..2fc54b6583 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp @@ -0,0 +1,270 @@ +/* + * Copyright (c) 2012 Zynga Inc. + * 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. + */ + +#ifndef __JS_COCOS2D_X_SPECIFICS_H__ +#define __JS_COCOS2D_X_SPECIFICS_H__ + +#include "ScriptingCore.h" +#include "platform/CCSAXParser.h" + +class JSScheduleWrapper; + +// JSScheduleWrapper* --> Array* since one js function may correspond to many targets. +// To debug this, you could refer to JSScheduleWrapper::dump function. +// It will prove that i'm right. :) +typedef struct jsScheduleFunc_proxy { + JS::Heap jsfuncObj; + cocos2d::__Array* targets; + UT_hash_handle hh; +} schedFunc_proxy_t; + +typedef struct jsScheduleTarget_proxy { + JS::Heap jsTargetObj; + cocos2d::__Array* targets; + UT_hash_handle hh; +} schedTarget_proxy_t; + + +typedef struct jsCallFuncTarget_proxy { + void * ptr; + cocos2d::__Array *obj; + UT_hash_handle hh; +} callfuncTarget_proxy_t; + +extern schedFunc_proxy_t *_schedFunc_target_ht; +extern schedTarget_proxy_t *_schedObj_target_ht; + +extern callfuncTarget_proxy_t *_callfuncTarget_native_ht; + +/** + * You don't need to manage the returned pointer. They live for the whole life of + * the app. + */ +template +inline js_type_class_t *js_get_type_from_native(T* native_obj) { + bool found = false; + std::string typeName = typeid(*native_obj).name(); + auto typeProxyIter = _js_global_type_map.find(typeName); + if (typeProxyIter == _js_global_type_map.end()) + { + typeName = typeid(T).name(); + typeProxyIter = _js_global_type_map.find(typeName); + if (typeProxyIter != _js_global_type_map.end()) + { + found = true; + } + } + else + { + found = true; + } + return found ? typeProxyIter->second : nullptr; +} + +/** + * The returned pointer should be deleted using jsb_remove_proxy. Most of the + * time you do that in the C++ destructor. + */ +template +inline js_proxy_t *js_get_or_create_proxy(JSContext *cx, T *native_obj) { + js_proxy_t *proxy; + HASH_FIND_PTR(_native_js_global_ht, &native_obj, proxy); + if (!proxy) { + js_type_class_t *typeProxy = js_get_type_from_native(native_obj); + // Return NULL if can't find its type rather than making an assert. +// assert(typeProxy); + if (!typeProxy) { + CCLOGINFO("Could not find the type of native object."); + return NULL; + } + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JS::RootedObject proto(cx, const_cast(typeProxy->proto.get())); + JS::RootedObject parent(cx, const_cast(typeProxy->parentProto.get())); + JS::RootedObject js_obj(cx, JS_NewObject(cx, typeProxy->jsclass, proto, parent)); + proxy = jsb_new_proxy(native_obj, js_obj); +#ifdef DEBUG + AddNamedObjectRoot(cx, &proxy->obj, typeid(*native_obj).name()); +#else + AddObjectRoot(cx, &proxy->obj); +#endif + return proxy; + } else { + return proxy; + } + return NULL; +} + +JS::Value anonEvaluate(JSContext *cx, JS::HandleObject thisObj, const char* string); +void register_cocos2dx_js_core(JSContext* cx, JS::HandleObject obj); + + +class JSCallbackWrapper: public cocos2d::Ref { +public: + JSCallbackWrapper(); + virtual ~JSCallbackWrapper(); + void setJSCallbackFunc(jsval obj); + void setJSCallbackThis(jsval thisObj); + void setJSExtraData(jsval data); + + const jsval& getJSCallbackFunc() const; + const jsval& getJSCallbackThis() const; + const jsval& getJSExtraData() const; +protected: + JS::Heap _jsCallback; + JS::Heap _jsThisObj; + JS::Heap _extraData; +}; + + +class JSScheduleWrapper: public JSCallbackWrapper { + +public: + JSScheduleWrapper() : _pTarget(NULL), _pPureJSTarget(NULL), _priority(0), _isUpdateSchedule(false) {} + virtual ~JSScheduleWrapper(); + + static void setTargetForSchedule(JS::HandleValue sched, JSScheduleWrapper *target); + static cocos2d::__Array * getTargetForSchedule(JS::HandleValue sched); + static void setTargetForJSObject(JS::HandleObject jsTargetObj, JSScheduleWrapper *target); + static cocos2d::__Array * getTargetForJSObject(JS::HandleObject jsTargetObj); + + // Remove all targets. + static void removeAllTargets(); + // Remove all targets for priority. + static void removeAllTargetsForMinPriority(int minPriority); + // Remove all targets by js object from hash table(_schedFunc_target_ht and _schedObj_target_ht). + static void removeAllTargetsForJSObject(JS::HandleObject jsTargetObj); + // Remove the target by js object and the wrapper for native schedule. + static void removeTargetForJSObject(JS::HandleObject jsTargetObj, JSScheduleWrapper* target); + static void dump(); + + void pause(); + + void scheduleFunc(float dt); + void update(float dt); + + Ref* getTarget(); + void setTarget(Ref* pTarget); + + void setPureJSTarget(JS::HandleObject jstarget); + JSObject* getPureJSTarget(); + + void setPriority(int priority); + int getPriority(); + + void setUpdateSchedule(bool isUpdateSchedule); + bool isUpdateSchedule(); + +protected: + Ref* _pTarget; + JS::Heap _pPureJSTarget; + int _priority; + bool _isUpdateSchedule; +}; + + +class JSTouchDelegate: public cocos2d::Ref +{ +public: + JSTouchDelegate(); + ~JSTouchDelegate(); + + // Set the touch delegate to map by using the key (pJSObj). + static void setDelegateForJSObject(JSObject* pJSObj, JSTouchDelegate* pDelegate); + // Get the touch delegate by the key (pJSObj). + static JSTouchDelegate* getDelegateForJSObject(JSObject* pJSObj); + // Remove the delegate by the key (pJSObj). + static void removeDelegateForJSObject(JSObject* pJSObj); + + void setJSObject(JSObject *obj); + void registerStandardDelegate(int priority); + void registerTargetedDelegate(int priority, bool swallowsTouches); + // unregister touch delegate. + // Normally, developer should invoke cc.unregisterTouchDelegate() in when the scene exits. + // So this function need to be binded. + void unregisterTouchDelegate(); + + bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *event); + void onTouchMoved(cocos2d::Touch *touch, cocos2d::Event *event); + void onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *event); + void onTouchCancelled(cocos2d::Touch *touch, cocos2d::Event *event); + + // optional + void onTouchesBegan(const std::vector& touches, cocos2d::Event *event); + void onTouchesMoved(const std::vector& touches, cocos2d::Event *event); + void onTouchesEnded(const std::vector& touches, cocos2d::Event *event); + void onTouchesCancelled(const std::vector& touches, cocos2d::Event *event); + +private: + JS::Heap _obj; + typedef std::unordered_map TouchDelegateMap; + typedef std::pair TouchDelegatePair; + static TouchDelegateMap sTouchDelegateMap; + bool _needUnroot; + cocos2d::EventListenerTouchOneByOne* _touchListenerOneByOne; + cocos2d::EventListenerTouchAllAtOnce* _touchListenerAllAtOnce; +}; + + +class __JSPlistDelegator: public cocos2d::SAXDelegator +{ +public: + static __JSPlistDelegator* getInstance() { + static __JSPlistDelegator* pInstance = NULL; + if (pInstance == NULL) { + pInstance = new __JSPlistDelegator(); + } + return pInstance; + }; + + ~__JSPlistDelegator(); + + cocos2d::SAXParser* getParser(); + + std::string parse(const std::string& path); + std::string parseText(const std::string& text); + + // implement pure virtual methods of SAXDelegator + void startElement(void *ctx, const char *name, const char **atts); + void endElement(void *ctx, const char *name); + void textHandler(void *ctx, const char *ch, int len); + +private: + cocos2d::SAXParser _parser; + JS::Heap _obj; + std::string _result; + bool _isStoringCharacters; + std::string _currentValue; +}; + +bool js_cocos2dx_Node_onEnter(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_onExit(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_onEnterTransitionDidFinish(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Node_onExitTransitionDidStart(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Component_onEnter(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Component_onExit(JSContext *cx, uint32_t argc, jsval *vp); + +void get_or_create_js_obj(JSContext* cx, JS::HandleObject obj, const std::string &name, JS::MutableHandleObject jsObj); + +#endif diff --git a/cocos/scripting/js-bindings/manual/cocosbuilder/cocosbuilder_specifics.hpp b/cocos/scripting/js-bindings/manual/cocosbuilder/cocosbuilder_specifics.hpp new file mode 100644 index 0000000000..6e41e37186 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/cocosbuilder/cocosbuilder_specifics.hpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2012 Zynga Inc. + * 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. + */ + +#ifndef __JS_COCOSBUILDER_SPECIFICS_H__ +#define __JS_COCOSBUILDER_SPECIFICS_H__ + +#include "../cocos2d_specifics.hpp" + +class JSCCBAnimationWrapper: public JSCallbackWrapper +{ +public: + JSCCBAnimationWrapper() {} + virtual ~JSCCBAnimationWrapper() {} + + void animationCompleteCallback() + { + + if(!_jsCallback.isNullOrUndefined() && !_jsThisObj.isNullOrUndefined()) + { + + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedValue retval(cx); + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JS_CallFunctionValue(cx, JS::RootedObject(cx, _jsThisObj.toObjectOrNull()), JS::RootedValue(cx, _jsCallback), JS::HandleValueArray::empty(), &retval); + } + } + +}; + +#endif diff --git a/cocos/scripting/js-bindings/manual/cocosbuilder/js_bindings_ccbreader.cpp b/cocos/scripting/js-bindings/manual/cocosbuilder/js_bindings_ccbreader.cpp new file mode 100644 index 0000000000..dd2bb40fc5 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/cocosbuilder/js_bindings_ccbreader.cpp @@ -0,0 +1,335 @@ +/* + * Created by Rohan Kuruvilla on 14/08/2012. + * Copyright (c) 2012 Zynga Inc. + * 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. + */ + +#include "js_bindings_ccbreader.h" +#include "ScriptingCore.h" +#include "js_bindings_config.h" + +USING_NS_CC; +USING_NS_CC_EXT; +using namespace cocosbuilder; + +static void removeSelector(std::string &str) { + size_t found; + found = str.find(":"); + while (found!=std::string::npos){ + str.replace(found, found+1, ""); + found = str.find(":"); + } +} + +SEL_MenuHandler CCBScriptCallbackProxy::onResolveCCBCCMenuItemSelector(cocos2d::Ref * pTarget, + const char * pSelectorName) { + this->callBackProp = pSelectorName; + removeSelector(this->callBackProp); + return menu_selector(CCBScriptCallbackProxy::menuItemCallback); +} + +Control::Handler CCBScriptCallbackProxy::onResolveCCBCCControlSelector(Ref * pTarget, + const char * pSelectorName) { + + this->callBackProp = pSelectorName; + removeSelector(this->callBackProp); + return cccontrol_selector(CCBScriptCallbackProxy::controlCallback); +} + +bool CCBScriptCallbackProxy::onAssignCCBMemberVariable(Ref * pTarget, + const char * pMemberVariableName, + Node * pNode) { + return true; +} + +void CCBScriptCallbackProxy::onNodeLoaded(Node * pNode, + NodeLoader * pNodeLoader) {} + +CCBSelectorResolver * CCBScriptCallbackProxy::createNew() { + CCBScriptCallbackProxy * ret = new CCBScriptCallbackProxy(); + ret->setJSOwner(this->owner); + return dynamic_cast(ret); +} + +void CCBScriptCallbackProxy::menuItemCallback(Ref *pSender) { + jsval arg; + ScriptingCore::getInstance()->executeFunctionWithOwner(owner, callBackProp.c_str(), 0, &arg); +} + +void CCBScriptCallbackProxy::controlCallback(Ref *pSender, Control::EventType event) { + jsval arg; + ScriptingCore::getInstance()->executeFunctionWithOwner(owner, callBackProp.c_str(), 0, &arg); +} + +void CCBScriptCallbackProxy::setCallbackProperty(const char *prop) { + callBackProp = prop; +} + +void CCBScriptCallbackProxy::setJSOwner(jsval ownr) { + owner = ownr; +} + +jsval CCBScriptCallbackProxy::getJSOwner() { + return owner; +} + +bool js_cocos2dx_CCBAnimationManager_animationCompleteCallback(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc >= 1) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *p = jsb_get_js_proxy(obj); + cocosbuilder::CCBAnimationManager *node = (cocosbuilder::CCBAnimationManager *)(p ? p->ptr : NULL); + + JSCCBAnimationWrapper *tmpCobj = new JSCCBAnimationWrapper(); + tmpCobj->autorelease(); + + tmpCobj->setJSCallbackThis(args.get(0)); + if(argc >= 2) { + tmpCobj->setJSCallbackFunc(args.get(1)); + } + + node->setAnimationCompletedCallback(tmpCobj, callfunc_selector(JSCCBAnimationWrapper::animationCompleteCallback)); + + JS_SetReservedSlot(p->obj, 0, args.get(0)); + JS_SetReservedSlot(p->obj, 1, args.get(1)); + return true; + } + return false; +} + +bool js_cocos2dx_CCBReader_readNodeGraphFromFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JSObject *obj; + cocosbuilder::CCBReader* cobj; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *p = jsb_get_js_proxy(obj); + cobj = (cocosbuilder::CCBReader *)(p ? p->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + if (argc == 2) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + cocos2d::Ref* arg1; + do { + js_proxy_t *proxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + proxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Ref*)(proxy ? proxy->ptr : NULL); + } while (0); + + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cocos2d::Node* ret = cobj->readNodeGraphFromFile(arg0, arg1); + jsval jsret; do { + if (ret) { + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cocos2d::Node* ret = cobj->readNodeGraphFromFile(arg0); + jsval jsret; do { + if (ret) { + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 3) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + cocos2d::Ref* arg1; + do { + js_proxy_t *proxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + proxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Ref*)(proxy ? proxy->ptr : NULL); + } while (0); + cocos2d::Size arg2; + ok &= jsval_to_ccsize(cx, args.get(2), &arg2); + + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cocos2d::Node* ret = cobj->readNodeGraphFromFile(arg0, arg1, arg2); + jsval jsret; do { + if (ret) { + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + return false; +} + +bool js_cocos2dx_CCBReader_createSceneWithNodeGraphFromFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JSObject *obj; + cocosbuilder::CCBReader* cobj; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *p = jsb_get_js_proxy(obj); + cobj = (cocosbuilder::CCBReader *)(p ? p->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + if (argc == 2) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + cocos2d::Ref* arg1; + do { + js_proxy_t *proxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + proxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Ref*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, arg1) + } while (0); + + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cocos2d::Scene* ret = cobj->createSceneWithNodeGraphFromFile(arg0, arg1); + jsval jsret; do { + if (ret) { + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cocos2d::Scene* ret = cobj->createSceneWithNodeGraphFromFile(arg0); + jsval jsret; do { + if (ret) { + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 3) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + cocos2d::Ref* arg1; + do { + js_proxy_t *proxy; + JSObject *tmpObj = args.get(1).toObjectOrNull(); + proxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Ref*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, arg1) + } while (0); + cocos2d::Size arg2; + ok &= jsval_to_ccsize(cx, args.get(2), &arg2); + + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cocos2d::Scene* ret = cobj->createSceneWithNodeGraphFromFile(arg0, arg1, arg2); + jsval jsret; do { + if (ret) { + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + return false; +} + + +bool js_CocosBuilder_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + NodeLoaderLibrary * ccNodeLoaderLibrary = NodeLoaderLibrary::getInstance(); + + ccNodeLoaderLibrary->registerNodeLoader("", JSLayerLoader::loader()); + + CCBReader * ret = new CCBReader(ccNodeLoaderLibrary); + ret->autorelease(); + + jsval jsret; + if (ret) { + js_proxy_t *proxy = jsb_get_native_proxy(ret); + if (proxy) { + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + // create a new js obj of that class + proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + } else { + jsret = JSVAL_NULL; + } + args.rval().set(jsret); + return true; + +} + +extern JSObject* jsb_cocosbuilder_CCBReader_prototype; +extern JSObject* jsb_cocosbuilder_CCBAnimationManager_prototype; + +void register_CCBuilderReader(JSContext *cx, JS::HandleObject global) +{ + JS::RootedObject ccObj(cx); + JS::RootedValue tmpVal(cx); + JS::RootedObject tmpObj(cx); + get_or_create_js_obj(cx, global, "cc", &ccObj); + + JS_GetProperty(cx, ccObj, "_Reader", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_CocosBuilder_create, 2, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "loadScene", js_cocos2dx_CCBReader_createSceneWithNodeGraphFromFile, 2, JSPROP_READONLY | JSPROP_PERMANENT); + + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocosbuilder_CCBReader_prototype), "load", js_cocos2dx_CCBReader_readNodeGraphFromFile, 2, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocosbuilder_CCBAnimationManager_prototype), "setCompletedAnimationCallback", js_cocos2dx_CCBAnimationManager_animationCompleteCallback, 2, JSPROP_READONLY | JSPROP_PERMANENT); +} diff --git a/cocos/scripting/js-bindings/manual/cocosbuilder/js_bindings_ccbreader.h b/cocos/scripting/js-bindings/manual/cocosbuilder/js_bindings_ccbreader.h new file mode 100644 index 0000000000..ba7f00a2ff --- /dev/null +++ b/cocos/scripting/js-bindings/manual/cocosbuilder/js_bindings_ccbreader.h @@ -0,0 +1,76 @@ +/* + * Created by Rohan Kuruvilla on 14/08/2012. + * Copyright (c) 2012 Zynga Inc. + * 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. + */ + +#ifndef __JS_BINDINGS_CCBREADER_H__ +#define __JS_BINDINGS_CCBREADER_H__ + +#include "cocosbuilder_specifics.hpp" +#include "cocosbuilder/CocosBuilder.h" + +class CCBScriptCallbackProxy: public cocos2d::Layer +, public cocosbuilder::CCBSelectorResolver +, public cocosbuilder::CCBMemberVariableAssigner { + + std::string callBackProp; + jsval owner; + +public: + + + CCBScriptCallbackProxy () {} + virtual ~CCBScriptCallbackProxy() {} + + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(CCBScriptCallbackProxy, create); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Ref * pTarget, + const char * pSelectorName); + + virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Ref * pTarget, + const char * pSelectorName); + virtual bool onAssignCCBMemberVariable(cocos2d::Ref * pTarget, const char * pMemberVariableName, + cocos2d::Node * pNode); + virtual void onNodeLoaded(cocos2d::Node * pNode, + cocosbuilder::NodeLoader * pNodeLoader); + + virtual CCBSelectorResolver * createNew(); + void menuItemCallback(Ref *pSender); + void controlCallback(Ref *pSender, cocos2d::extension::Control::EventType event); + void setCallbackProperty(const char *prop); + void setJSOwner(jsval ownr); + jsval getJSOwner(); +}; + + +class JSLayerLoader : public cocosbuilder::LayerLoader { +public: + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(JSLayerLoader, loader); + +protected: + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCBScriptCallbackProxy); +}; + +void register_CCBuilderReader(JSContext *cx, JS::HandleObject global); +bool js_CocosBuilder_Run(JSContext *cx, uint32_t argc, jsval *vp); + +#endif /* __JS_BINDINGS_CCBREADER_H__ */ + diff --git a/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_conversions.cpp b/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_conversions.cpp new file mode 100644 index 0000000000..f996404c8c --- /dev/null +++ b/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_conversions.cpp @@ -0,0 +1,66 @@ +/* + * Created by Huabin LING on 21/1/15. + * Copyright (c) 2015 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. + */ + +#include "jsb_cocos2dx_studio_conversions.h" +#include "cocos2d_specifics.hpp" +#include "cocostudio/CocoStudio.h" + +jsval animationInfo_to_jsval(JSContext* cx, const cocostudio::timeline::AnimationInfo& v) +{ + JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr())); + if (!tmp) return JSVAL_NULL; + bool ok = JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, std_string_to_jsval(cx, v.name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "startIndex", v.startIndex, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "endIndex", v.endIndex, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +bool jsval_to_animationInfo(JSContext* cx, JS::HandleValue vp, cocostudio::timeline::AnimationInfo* ret) +{ + JS::RootedObject tmp(cx); + JS::RootedValue jsName(cx); + JS::RootedValue jsStartId(cx); + JS::RootedValue jsEndId(cx); + std::string name; + double startIndex, endIndex; + + bool ok = vp.isObject() && + JS_ValueToObject(cx, vp, &tmp) && + JS_GetProperty(cx, tmp, "name", &jsName) && + JS_GetProperty(cx, tmp, "startIndex", &jsStartId) && + JS_GetProperty(cx, tmp, "endIndex", &jsEndId) && + JS::ToNumber(cx, jsStartId, &startIndex) && + JS::ToNumber(cx, jsEndId, &endIndex) && + jsval_to_std_string(cx, jsName, &name) && + !isnan(startIndex) && !isnan(endIndex); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + ret->name = name; + ret->startIndex = (int)startIndex; + ret->endIndex = (int)endIndex; + return true; +} diff --git a/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_conversions.h b/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_conversions.h new file mode 100644 index 0000000000..513d2847f9 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_conversions.h @@ -0,0 +1,40 @@ +/* + * Created by Huabin LING on 21/1/15. + * Copyright (c) 2015 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. + */ + +#ifndef __cocos2d_js_bindings__jsb_cocos2dx_studio_conversions__ +#define __cocos2d_js_bindings__jsb_cocos2dx_studio_conversions__ + +#include "jsapi.h" + +namespace cocostudio +{ + namespace timeline + { + struct AnimationInfo; + } +} + +extern jsval animationInfo_to_jsval(JSContext* cx, const cocostudio::timeline::AnimationInfo& v); +extern bool jsval_to_animationInfo(JSContext* cx, JS::HandleValue vp, cocostudio::timeline::AnimationInfo* ret); + +#endif /* defined(__cocos2d_js_bindings__jsb_cocos2dx_studio_conversions__) */ diff --git a/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp b/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp new file mode 100644 index 0000000000..bd4e2fe5b3 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp @@ -0,0 +1,1499 @@ +/* + * Created by LinWenhai on 20/10/13. + * 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. + */ + +#include "jsb_cocos2dx_studio_manual.h" +#include "ScriptingCore.h" +#include "cocos2d_specifics.hpp" +#include "cocostudio/CocoStudio.h" + +class JSArmatureWrapper: public JSCallbackWrapper { +public: + JSArmatureWrapper(); + virtual ~JSArmatureWrapper(); + + virtual void setJSCallbackThis(jsval thisObj); + + void movementCallbackFunc(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID); + void frameCallbackFunc(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex); + void addArmatureFileInfoAsyncCallbackFunc(float percent); + +private: + bool m_bNeedUnroot; +}; + +JSArmatureWrapper::JSArmatureWrapper() + : m_bNeedUnroot(false) +{ + +} + +JSArmatureWrapper::~JSArmatureWrapper() +{ + if (m_bNeedUnroot) + { + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RemoveValueRoot(cx, &_jsThisObj); + } +} + +void JSArmatureWrapper::setJSCallbackThis(jsval obj) +{ + JSCallbackWrapper::setJSCallbackThis(obj); + + JSObject *thisObj = obj.toObjectOrNull(); + js_proxy *p = jsb_get_js_proxy(thisObj); + if (!p) + { + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + m_bNeedUnroot = true; + m_bNeedUnroot &= JS::AddValueRoot(cx, &_jsThisObj); + } +} + +void JSArmatureWrapper::movementCallbackFunc(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID) +{ + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedObject thisObj(cx, _jsThisObj.toObjectOrNull()); + js_proxy_t *proxy = js_get_or_create_proxy(cx, armature); + JS::RootedValue retval(cx); + if (_jsCallback != JSVAL_VOID) + { + int movementEventType = (int)movementType; + jsval movementVal = INT_TO_JSVAL(movementEventType); + + jsval idVal = std_string_to_jsval(cx, movementID); + + jsval valArr[3]; + valArr[0] = OBJECT_TO_JSVAL(proxy->obj); + valArr[1] = movementVal; + valArr[2] = idVal; + + //JS_AddValueRoot(cx, valArr); + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JS_CallFunctionValue(cx, thisObj, JS::RootedValue(cx, _jsCallback), JS::HandleValueArray::fromMarkedLocation(3, valArr), &retval); + //JS_RemoveValueRoot(cx, valArr); + } +} + +void JSArmatureWrapper::addArmatureFileInfoAsyncCallbackFunc(float percent) +{ + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedObject thisObj(cx, _jsThisObj.toObjectOrNull()); + JS::RootedValue retval(cx); + if (_jsCallback != JSVAL_VOID) + { + jsval percentVal = DOUBLE_TO_JSVAL(percent); + + //JS_AddValueRoot(cx, &percentVal); + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JS_CallFunctionValue(cx, thisObj, JS::RootedValue(cx, _jsCallback), JS::HandleValueArray::fromMarkedLocation(1, &percentVal), &retval); + //JS_RemoveValueRoot(cx, &percentVal); + } +} + + +void JSArmatureWrapper::frameCallbackFunc(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex) +{ + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedObject thisObj(cx, _jsThisObj.toObjectOrNull()); + js_proxy_t *proxy = js_get_or_create_proxy(cx, bone); + JS::RootedValue retval(cx); + if (_jsCallback != JSVAL_VOID) + { + jsval nameVal = std_string_to_jsval(cx, evt); + jsval originIndexVal = INT_TO_JSVAL(originFrameIndex); + jsval currentIndexVal = INT_TO_JSVAL(currentFrameIndex); + + jsval valArr[4]; + valArr[0] = OBJECT_TO_JSVAL(proxy->obj); + valArr[1] = nameVal; + valArr[2] = originIndexVal; + valArr[3] = currentIndexVal; + + //JS_AddValueRoot(cx, valArr); + + JS_CallFunctionValue(cx, thisObj, JS::RootedValue(cx, _jsCallback), JS::HandleValueArray::fromMarkedLocation(4, valArr), &retval); + //JS_RemoveValueRoot(cx, valArr); + } +} + +static bool js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc > 0) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + if (args.get(0).isNull()) { + cobj->setMovementEventCallFunc(nullptr); + + return true; + } + else if (argc == 1 || argc == 2) { + JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); + tmpObj->autorelease(); + + cocos2d::__Dictionary* dict = static_cast(cobj->getUserObject()); + if (nullptr == dict) + { + dict = cocos2d::__Dictionary::create(); + cobj->setUserObject(dict); + } + dict->setObject(tmpObj, "moveEvent"); + + tmpObj->setJSCallbackFunc(args.get(0)); + if (argc == 1) + { + tmpObj->setJSCallbackThis(JSVAL_NULL); + } + else + { + tmpObj->setJSCallbackThis(args.get(1)); + } + + cobj->setMovementEventCallFunc(CC_CALLBACK_0(JSArmatureWrapper::movementCallbackFunc, tmpObj, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); + + return true; + } + } + JS_ReportError(cx, "Invalid number of arguments"); + return false; +} + +static bool js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureAnimation* cobj = (cocostudio::ArmatureAnimation *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc > 0) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + if (args.get(0).isNull()) { + cobj->setFrameEventCallFunc(nullptr); + + return true; + } + else if (argc == 1 || argc == 2) { + JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); + tmpObj->autorelease(); + + cocos2d::__Dictionary* dict = static_cast(cobj->getUserObject()); + if (nullptr == dict) + { + dict = cocos2d::__Dictionary::create(); + cobj->setUserObject(dict); + } + dict->setObject(tmpObj, "frameEvent"); + + tmpObj->setJSCallbackFunc(args.get(0)); + if (argc == 1) + { + tmpObj->setJSCallbackThis(JSVAL_NULL); + } + else + { + tmpObj->setJSCallbackThis(args.get(1)); + } + + cobj->setFrameEventCallFunc(CC_CALLBACK_0(JSArmatureWrapper::frameCallbackFunc, tmpObj, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); + + return true; + } + } + + JS_ReportError(cx, "Invalid number of arguments"); + return false; +} + +static bool jsb_Animation_addArmatureFileInfoAsyncCallFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ArmatureDataManager* cobj = (cocostudio::ArmatureDataManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 3) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); + tmpObj->autorelease(); + + tmpObj->setJSCallbackFunc(args.get(1)); + tmpObj->setJSCallbackThis(args.get(2)); + + std::string ret; + jsval_to_std_string(cx, args.get(0), &ret); + + cobj->addArmatureFileInfoAsync(ret.c_str(), tmpObj, schedule_selector(JSArmatureWrapper::addArmatureFileInfoAsyncCallbackFunc)); + + return true; + } + + if(argc == 5){ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); + tmpObj->autorelease(); + + tmpObj->setJSCallbackFunc(args.get(3)); + tmpObj->setJSCallbackThis(args.get(4)); + + std::string imagePath; + jsval_to_std_string(cx ,args.get(0) , &imagePath); + + std::string plistPath; + jsval_to_std_string(cx ,args.get(1) , &plistPath); + + std::string configFilePath; + jsval_to_std_string(cx ,args.get(2) , &configFilePath); + + cobj->addArmatureFileInfoAsync(imagePath.c_str(), plistPath.c_str(), configFilePath.c_str(), tmpObj, schedule_selector(JSArmatureWrapper::addArmatureFileInfoAsyncCallbackFunc)); + + return true; + } + JS_ReportError(cx, "Invalid number of arguments"); + return false; +} + +static bool js_cocos2dx_studio_ActionManagerEx_initWithDictionaryEx(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ActionManagerEx* cobj = (cocostudio::ActionManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionManagerEx_initWithDictionaryEx : Invalid Native Object"); + if (argc == 3) { + const char* arg0; + const char* arg1; + cocos2d::Ref* arg2; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + rapidjson::Document arg1Jsondoc; + arg1Jsondoc.Parse<0>(arg1); + if (arg1Jsondoc.HasParseError()) { + CCLOG("GetParseError %s\n",arg1Jsondoc.GetParseError()); + } + do { + if (!args.get(2).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::Ref*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionManagerEx_initWithDictionaryEx : Error processing arguments"); + cobj->initWithDictionary(arg0, arg1Jsondoc, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionManagerEx_initWithDictionaryEx : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} + +bool js_cocos2dx_studio_ColliderBody_getCalculatedVertexList(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ColliderBody* cobj = (cocostudio::ColliderBody *)(proxy ? proxy->ptr : nullptr); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + if (argc == 0) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + const std::vector& ret = cobj->getCalculatedVertexList(); + JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, 0)); + jsval jsret; + //CCObject* obj; + int i = 0; + JS::RootedObject tmp(cx); + for(const auto& point : ret) + { + tmp = JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr()); + if (!tmp) break; + bool ok = JS_DefineProperty(cx, tmp, "x", point.x, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "y", point.y, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS::RootedValue jsTmp(cx, OBJECT_TO_JSVAL(tmp)); + if(!ok || !JS_SetElement(cx, jsretArr, i, jsTmp)) + { + break; + } + ++i; + } + jsret = OBJECT_TO_JSVAL(jsretArr); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +static bool js_cocos2dx_studio_Frame_setEasingParams(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Frame* cobj = (cocostudio::timeline::Frame *)(proxy ? proxy->ptr : nullptr); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + if(argc == 1) + { + JS::RootedObject jsobj(cx); + bool ok = args.get(0).isObject() && JS_ValueToObject( cx, args.get(0), &jsobj ); + JSB_PRECONDITION3( ok, cx, false, "Error converting value to object"); + JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, false, "argument must be an array"); + + std::vector arg0; + uint32_t length = 0; + ok &= JS_GetArrayLength(cx, jsobj, & length); + arg0.reserve(length); + + for (uint32_t i = 0; i < length; ++i) + { + JS::RootedValue value(cx); + if (JS_GetElement(cx, jsobj, i, &value)) + { + arg0.push_back(value.toNumber()); + } + else + { + ok = false; + break; + } + } + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Frame_setEasingParams : Error processing arguments"); + + cobj->setEasingParams(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +static bool js_cocos2dx_studio_Frame_getEasingParams(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::Frame* cobj = (cocostudio::timeline::Frame *)(proxy ? proxy->ptr : nullptr); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + if(argc == 0) + { + const std::vector ret = cobj->getEasingParams(); + + JS::RootedObject jsobj(cx, JS_NewArrayObject(cx, ret.size())); + bool ok = true; + for(size_t i = 0; i < ret.size(); ++i) + { + ok &= JS_SetElement(cx, jsobj, i, ret[i]); + } + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_Frame_getEasingParams : Error processing arguments"); + + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +// BaseData Properties + +bool js_get_BaseData_x(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = DOUBLE_TO_JSVAL(cobj->x); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_BaseData_x : Fail to retrieve property from BaseData."); + return false; + } + JS_ReportError(cx, "js_get_BaseData_x : Invalid native object."); + return false; +} +bool js_set_BaseData_x(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + cobj->x = (float)vp.get().toDouble(); + return true; + } + JS_ReportError(cx, "js_set_BaseData_x : Invalid native object."); + return false; +} + +bool js_get_BaseData_y(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = DOUBLE_TO_JSVAL(cobj->y); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_BaseData_y : Fail to retrieve property from BaseData."); + return false; + } + JS_ReportError(cx, "js_get_BaseData_y : Invalid native object."); + return false; +} +bool js_set_BaseData_y(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + cobj->y = (float)vp.get().toDouble(); + return true; + } + JS_ReportError(cx, "js_set_BaseData_y : Invalid native object."); + return false; +} + +bool js_get_BaseData_zOrder(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = INT_TO_JSVAL(cobj->zOrder); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_BaseData_zOrder : Fail to retrieve property from BaseData."); + return false; + } + JS_ReportError(cx, "js_get_BaseData_zOrder : Invalid native object."); + return false; +} +bool js_set_BaseData_zOrder(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + cobj->y = (int)vp.get().toDouble(); + return true; + } + JS_ReportError(cx, "js_set_BaseData_zOrder : Invalid native object."); + return false; +} + +bool js_get_BaseData_skewX(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = DOUBLE_TO_JSVAL(cobj->skewX); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_BaseData_skewX : Fail to retrieve property from BaseData."); + return false; + } + JS_ReportError(cx, "js_get_BaseData_skewX : Invalid native object."); + return false; +} +bool js_set_BaseData_skewX(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + cobj->skewX = (float)vp.get().toDouble(); + return true; + } + JS_ReportError(cx, "js_set_BaseData_skewX : Invalid native object."); + return false; +} + +bool js_get_BaseData_skewY(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = DOUBLE_TO_JSVAL(cobj->skewY); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_BaseData_skewY : Fail to retrieve property from BaseData."); + return false; + } + JS_ReportError(cx, "js_get_BaseData_skewY : Invalid native object."); + return false; +} +bool js_set_BaseData_skewY(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + cobj->skewY = (float)vp.get().toDouble(); + return true; + } + JS_ReportError(cx, "js_set_BaseData_skewY : Invalid native object."); + return false; +} + +bool js_get_BaseData_scaleX(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = DOUBLE_TO_JSVAL(cobj->scaleX); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_BaseData_scaleX : Fail to retrieve property from BaseData."); + return false; + } + JS_ReportError(cx, "js_get_BaseData_scaleX : Invalid native object."); + return false; +} +bool js_set_BaseData_scaleX(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + cobj->scaleX = (float)vp.get().toDouble(); + return true; + } + JS_ReportError(cx, "js_set_BaseData_scaleX : Invalid native object."); + return false; +} + +bool js_get_BaseData_scaleY(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = DOUBLE_TO_JSVAL(cobj->scaleY); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_BaseData_scaleY : Fail to retrieve property from BaseData."); + return false; + } + JS_ReportError(cx, "js_get_BaseData_scaleY : Invalid native object."); + return false; +} +bool js_set_BaseData_scaleY(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + cobj->scaleY = (float)vp.get().toDouble(); + return true; + } + JS_ReportError(cx, "js_set_BaseData_scaleY : Invalid native object."); + return false; +} + +bool js_get_BaseData_tweenRotate(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = DOUBLE_TO_JSVAL(cobj->tweenRotate); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_BaseData_tweenRotate : Fail to retrieve property from BaseData."); + return false; + } + JS_ReportError(cx, "js_get_BaseData_tweenRotate : Invalid native object."); + return false; +} +bool js_set_BaseData_tweenRotate(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + cobj->tweenRotate = (float)vp.get().toDouble(); + return true; + } + JS_ReportError(cx, "js_set_BaseData_tweenRotate : Invalid native object."); + return false; +} + +bool js_get_BaseData_isUseColorInfo(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = BOOLEAN_TO_JSVAL(cobj->isUseColorInfo); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_BaseData_isUseColorInfo : Fail to retrieve property from BaseData."); + return false; + } + JS_ReportError(cx, "js_get_BaseData_isUseColorInfo : Invalid native object."); + return false; +} +bool js_set_BaseData_isUseColorInfo(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + cobj->isUseColorInfo = vp.get().toBoolean(); + return true; + } + JS_ReportError(cx, "js_set_BaseData_isUseColorInfo : Invalid native object."); + return false; +} + +bool js_get_BaseData_a(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = INT_TO_JSVAL(cobj->a); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_BaseData_a : Fail to retrieve property from BaseData."); + return false; + } + JS_ReportError(cx, "js_get_BaseData_a : Invalid native object."); + return false; +} +bool js_set_BaseData_a(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + cobj->a = vp.get().toInt32(); + return true; + } + JS_ReportError(cx, "js_set_BaseData_a : Invalid native object."); + return false; +} + +bool js_get_BaseData_r(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = INT_TO_JSVAL(cobj->r); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_BaseData_r : Fail to retrieve property from BaseData."); + return false; + } + JS_ReportError(cx, "js_get_BaseData_r : Invalid native object."); + return false; +} +bool js_set_BaseData_r(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + cobj->r = vp.get().toInt32(); + return true; + } + JS_ReportError(cx, "js_set_BaseData_r : Invalid native object."); + return false; +} + +bool js_get_BaseData_g(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = INT_TO_JSVAL(cobj->g); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_BaseData_g : Fail to retrieve property from BaseData."); + return false; + } + JS_ReportError(cx, "js_get_BaseData_g : Invalid native object."); + return false; +} +bool js_set_BaseData_g(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + cobj->g = vp.get().toInt32(); + return true; + } + JS_ReportError(cx, "js_set_BaseData_g : Invalid native object."); + return false; +} + +bool js_get_BaseData_b(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = INT_TO_JSVAL(cobj->b); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_BaseData_b : Fail to retrieve property from BaseData."); + return false; + } + JS_ReportError(cx, "js_get_BaseData_b : Invalid native object."); + return false; +} +bool js_set_BaseData_b(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::BaseData* cobj = (cocostudio::BaseData*)JS_GetPrivate(obj); + if (cobj) { + cobj->b = vp.get().toInt32(); + return true; + } + JS_ReportError(cx, "js_set_BaseData_b : Invalid native object."); + return false; +} + +// AnimationData Properties + +bool js_get_AnimationData_name(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::AnimationData* cobj = (cocostudio::AnimationData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = std_string_to_jsval(cx, cobj->name); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_AnimationData_name : Fail to retrieve property name of AnimationData."); + return false; + } + JS_ReportError(cx, "js_get_AnimationData_name : Invalid native object."); + return false; +} +bool js_set_AnimationData_name(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::AnimationData* cobj = (cocostudio::AnimationData*)JS_GetPrivate(obj); + if (cobj) { + std::string name; + bool ok = jsval_to_std_string(cx, JS::RootedValue(cx, vp.get()), &name); + JSB_PRECONDITION2(ok, cx, false, "js_set_AnimationData_name : Error processing arguments"); + cobj->name = name; + return true; + } + JS_ReportError(cx, "js_set_AnimationData_name : Invalid native object."); + return false; +} + +bool js_get_AnimationData_movementNames(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::AnimationData* cobj = (cocostudio::AnimationData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = std_vector_string_to_jsval(cx, cobj->movementNames); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_AnimationData_movementNames : Fail to retrieve property movementNames of AnimationData."); + return false; + } + JS_ReportError(cx, "js_get_AnimationData_movementNames : Invalid native object."); + return false; +} +bool js_set_AnimationData_movementNames(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::AnimationData* cobj = (cocostudio::AnimationData*)JS_GetPrivate(obj); + if (cobj) { + std::vector movementNames; + bool ok = jsval_to_std_vector_string(cx, JS::RootedValue(cx, vp.get()), &movementNames); + JSB_PRECONDITION2(ok, cx, false, "js_set_AnimationData_movementNames : Error processing arguments."); + cobj->movementNames.clear(); + cobj->movementNames = movementNames; + return true; + } + JS_ReportError(cx, "js_set_AnimationData_movementNames : Invalid native object."); + return false; +} + +bool js_get_AnimationData_movementDataDic(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::AnimationData* cobj = (cocostudio::AnimationData*)JS_GetPrivate(obj); + if (cobj) { + cocos2d::Map dic = cobj->movementDataDic; + JS::RootedObject jsRet(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr())); + + for (auto iter = dic.begin(); iter != dic.end(); ++iter) + { + JS::RootedValue dictElement(cx); + + std::string key = iter->first; + cocostudio::MovementData* movementData = iter->second; + do { + if (movementData) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::MovementData*)movementData); + dictElement = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + CCLOGERROR("js_get_AnimationData_movementDataDic : Fail to retrieve property movementDataDic of AnimationData."); + return false; + } + } while (0); + + if (!key.empty()) + { + JS_SetProperty(cx, jsRet, key.c_str(), dictElement); + } + } + jsval ret = OBJECT_TO_JSVAL(jsRet); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_AnimationData_movementDataDic : Fail to retrieve property movementDataDic of AnimationData."); + return false; + } + JS_ReportError(cx, "js_get_AnimationData_movementDataDic : Invalid native object."); + return false; +} +bool js_set_AnimationData_movementDataDic(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::AnimationData* cobj = (cocostudio::AnimationData*)JS_GetPrivate(obj); + if (cobj) { + if (vp.isNullOrUndefined()) + { + return true; + } + JS::RootedObject tmp(cx, vp.toObjectOrNull()); + JSB_PRECONDITION2(tmp, cx, false, "js_set_AnimationData_movementDataDic: the js value is not an object."); + + cocos2d::Map dict; + + JS::RootedObject it(cx, JS_NewPropertyIterator(cx, tmp)); + while (true) + { + JS::RootedId idp(cx); + JS::RootedValue key(cx); + if (! JS_NextProperty(cx, it, idp.address()) || ! JS_IdToValue(cx, idp, &key)) { + CCLOGERROR("js_set_AnimationData_movementDataDic : Error processing arguments."); + return false; // error + } + if (key == JSVAL_VOID) { + break; // end of iteration + } + if (!key.isString()) { + continue; // ignore integer properties + } + + JSStringWrapper keyWrapper(key.toString(), cx); + + JS::RootedValue value(cx); + JS_GetPropertyById(cx, tmp, idp, &value); + cocostudio::MovementData* movementData; + bool ok = true; + do { + if (!value.isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = value.toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + movementData = (cocostudio::MovementData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2(movementData, cx, false, "js_set_AnimationData_movementDataDic : Invalid Native Object."); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_set_AnimationData_movementDataDic : Error processing arguments."); + } + + cobj->movementDataDic.clear(); + cobj->movementDataDic = dict; + return true; + } + JS_ReportError(cx, "js_set_AnimationData_movementDataDic : Invalid native object."); + return false; +} + +// MovementData properties + +bool js_get_MovementData_name(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::MovementData* cobj = (cocostudio::MovementData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = std_string_to_jsval(cx, cobj->name); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_MovementData_name : Fail to retrieve property from MovementData."); + return false; + } + JS_ReportError(cx, "js_get_MovementData_name : Invalid native object."); + return false; +} +bool js_set_MovementData_name(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::MovementData* cobj = (cocostudio::MovementData*)JS_GetPrivate(obj); + if (cobj) { + std::string name; + bool ok = jsval_to_std_string(cx, JS::RootedValue(cx, vp.get()), &name); + JSB_PRECONDITION2(ok, cx, false, "js_set_MovementData_name : Error processing arguments"); + cobj->name = name; + return true; + } + JS_ReportError(cx, "js_set_MovementData_name : Invalid native object."); + return false; +} + +bool js_get_MovementData_duration(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::MovementData* cobj = (cocostudio::MovementData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = INT_TO_JSVAL(cobj->duration); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_MovementData_duration : Fail to retrieve property from MovementData."); + return false; + } + JS_ReportError(cx, "js_get_MovementData_duration : Invalid native object."); + return false; +} +bool js_set_MovementData_duration(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::MovementData* cobj = (cocostudio::MovementData*)JS_GetPrivate(obj); + if (cobj) { + cobj->duration = vp.get().toInt32(); + return true; + } + JS_ReportError(cx, "js_set_MovementData_duration : Invalid native object."); + return false; +} + +bool js_get_MovementData_scale(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::MovementData* cobj = (cocostudio::MovementData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = DOUBLE_TO_JSVAL(cobj->scale); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_MovementData_scale : Fail to retrieve property from MovementData."); + return false; + } + JS_ReportError(cx, "js_get_MovementData_scale : Invalid native object."); + return false; +} +bool js_set_MovementData_scale(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::MovementData* cobj = (cocostudio::MovementData*)JS_GetPrivate(obj); + if (cobj) { + cobj->scale = (float)vp.get().toDouble(); + return true; + } + JS_ReportError(cx, "js_set_MovementData_scale : Invalid native object."); + return false; +} + +bool js_get_MovementData_durationTo(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::MovementData* cobj = (cocostudio::MovementData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = INT_TO_JSVAL(cobj->durationTo); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_MovementData_durationTo : Fail to retrieve property from MovementData."); + return false; + } + JS_ReportError(cx, "js_get_MovementData_durationTo : Invalid native object."); + return false; +} +bool js_set_MovementData_durationTo(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::MovementData* cobj = (cocostudio::MovementData*)JS_GetPrivate(obj); + if (cobj) { + cobj->durationTo = vp.get().toInt32(); + return true; + } + JS_ReportError(cx, "js_set_MovementData_durationTo : Invalid native object."); + return false; +} + +bool js_get_MovementData_durationTween(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::MovementData* cobj = (cocostudio::MovementData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = INT_TO_JSVAL(cobj->durationTween); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_MovementData_durationTween : Fail to retrieve property from MovementData."); + return false; + } + JS_ReportError(cx, "js_get_MovementData_durationTween : Invalid native object."); + return false; +} +bool js_set_MovementData_durationTween(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::MovementData* cobj = (cocostudio::MovementData*)JS_GetPrivate(obj); + if (cobj) { + cobj->durationTween = vp.get().toInt32(); + return true; + } + JS_ReportError(cx, "js_set_MovementData_durationTween : Invalid native object."); + return false; +} + +bool js_get_MovementData_loop(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::MovementData* cobj = (cocostudio::MovementData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = BOOLEAN_TO_JSVAL(cobj->loop); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_MovementData_loop : Fail to retrieve property from MovementData."); + return false; + } + JS_ReportError(cx, "js_get_MovementData_loop : Invalid native object."); + return false; +} +bool js_set_MovementData_loop(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::MovementData* cobj = (cocostudio::MovementData*)JS_GetPrivate(obj); + if (cobj) { + cobj->loop = vp.get().toBoolean(); + return true; + } + JS_ReportError(cx, "js_get_MovementData_loop : Invalid native object."); + return false; +} + +bool js_get_MovementData_tweenEasing(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + cocostudio::MovementData* cobj = (cocostudio::MovementData*)JS_GetPrivate(obj); + if (cobj) { + jsval ret = INT_TO_JSVAL(cobj->tweenEasing); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_MovementData_tweenEasing : Fail to retrieve property from MovementData."); + return false; + } + JS_ReportError(cx, "js_get_MovementData_tweenEasing : Invalid native object."); + return false; +} +bool js_set_MovementData_tweenEasing(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) { + cocostudio::MovementData* cobj = (cocostudio::MovementData*)JS_GetPrivate(obj); + if (cobj) { + cobj->tweenEasing = (cocos2d::tweenfunc::TweenType)vp.get().toInt32(); + return true; + } + JS_ReportError(cx, "js_set_MovementData_tweenEasing : Invalid native object."); + return false; +} + +// ContourData properties + +bool js_get_ContourData_vertexList(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) +{ + JSObject* jsobj = obj.get(); + js_proxy_t *proxy = jsb_get_js_proxy(jsobj); + cocostudio::ContourData* cobj = (cocostudio::ContourData*)(proxy ? proxy->ptr : NULL); + if (cobj) { + const std::vector& ret = cobj->vertexList; + JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, 0)); + jsval jsret; + //CCObject* obj; + int i = 0; + for(const auto& vec2 : ret) + { + JS::RootedValue arrElement(cx); + arrElement = vector2_to_jsval(cx, vec2); + + if (!JS_SetElement(cx, jsretArr, i, arrElement)) { + break; + } + ++i; + } + jsret = OBJECT_TO_JSVAL(jsretArr); + if (jsret != JSVAL_NULL) + { + vp.set(jsret); + return true; + } + CCLOGERROR("js_get_ContourData_vertexList : Fail to retrieve property from ContourData."); + return false; + } + JS_ReportError(cx, "js_get_ContourData_vertexList : Invalid native object."); + return false; +} +bool js_set_ContourData_vertexList(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) +{ + JSObject* jsobj = obj.get(); + js_proxy_t *proxy = jsb_get_js_proxy(jsobj); + cocostudio::ContourData* cobj = (cocostudio::ContourData*)(proxy ? proxy->ptr : NULL); + if (cobj) { + JS::RootedObject jsListObj(cx); + jsListObj = vp.get().toObjectOrNull(); + JSB_PRECONDITION3(jsListObj && JS_IsArrayObject(cx, jsListObj), cx, false, "Object must be an array"); + + std::vector list; + uint32_t len = 0; + JS_GetArrayLength(cx, jsListObj, &len); + bool ok; + + for (uint32_t i=0; i < len; i++) + { + JS::RootedValue value(cx); + if (JS_GetElement(cx, jsListObj, i, &value)) + { + cocos2d::Vec2 vec2; + ok = jsval_to_vector2(cx, value, &vec2); + if (ok) + { + list.push_back(vec2); + } + } + } + + cobj->vertexList = list; + return true; + } + JS_ReportError(cx, "js_set_ContourData_vertexList : Invalid native object."); + return false; +} + +// TextureData properties + +bool js_get_TextureData_contourDataList(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) +{ + JSObject* jsobj = obj.get(); + js_proxy_t *proxy = jsb_get_js_proxy(jsobj); + cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); + if (cobj) { + const cocos2d::Vector& ret = cobj->contourDataList; + JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, 0)); + jsval jsret; + //CCObject* obj; + int i = 0; + for(const auto& contourData : ret) + { + JS::RootedValue arrElement(cx); + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ContourData*)contourData); + arrElement = OBJECT_TO_JSVAL(jsProxy->obj); + + if (!JS_SetElement(cx, jsretArr, i, arrElement)) { + break; + } + ++i; + } + jsret = OBJECT_TO_JSVAL(jsretArr); + if (jsret != JSVAL_NULL) + { + vp.set(jsret); + return true; + } + CCLOGERROR("js_get_TextureData_contourDataList : Fail to retrieve property from TextureData."); + return false; + } + JS_ReportError(cx, "js_get_TextureData_contourDataList : Invalid native object."); + return false; +} +bool js_set_TextureData_contourDataList(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) +{ + JSObject* jsobj = obj.get(); + js_proxy_t *proxy = jsb_get_js_proxy(jsobj); + cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); + if (cobj) { + JS::RootedObject jsListObj(cx); + jsListObj = vp.get().toObjectOrNull(); + JSB_PRECONDITION3(jsListObj && JS_IsArrayObject(cx, jsListObj), cx, false, "Object must be an array"); + + cocos2d::Vector list; + uint32_t len = 0; + JS_GetArrayLength(cx, jsListObj, &len); + bool ok; + + for (uint32_t i=0; i < len; i++) + { + JS::RootedValue value(cx); + if (JS_GetElement(cx, jsListObj, i, &value)) + { + cocostudio::ContourData* contourData; + do { + if (!value.isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = value.toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + contourData = (cocostudio::ContourData*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2(contourData, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_set_TextureData_contourDataList : Error processing arguments"); + + list.pushBack(contourData); + } + } + + cobj->contourDataList = list; + return true; + } + JS_ReportError(cx, "js_set_TextureData_contourDataList : Invalid native object."); + return false; +} + +bool js_get_TextureData_width(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) +{ + JSObject* jsobj = obj.get(); + js_proxy_t *proxy = jsb_get_js_proxy(jsobj); + cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); + + //struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(obj); + //cocostudio::TextureData* cobj = (cocostudio::TextureData*)proxy->handle; + + //jsval argv; + //cocostudio::TextureData* cobj = (cocostudio::TextureData*)JS_GetInstancePrivate(cx, obj.get(), jsb_cocostudio_TextureData_class, &argv); + if (cobj) { + jsval ret = DOUBLE_TO_JSVAL(cobj->width); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_TextureData_width : Fail to retrieve property from TextureData."); + return false; + } + JS_ReportError(cx, "js_get_TextureData_width : Invalid native object."); + return false; +} +bool js_set_TextureData_width(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) +{ + JSObject* jsobj = obj.get(); + js_proxy_t *proxy = jsb_get_js_proxy(jsobj); + cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); + if (cobj) { + cobj->width = (float)(vp.get().toNumber()); + return true; + } + JS_ReportError(cx, "js_set_TextureData_width : Invalid native object."); + return false; +} + +bool js_get_TextureData_height(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) +{ + JSObject* jsobj = obj.get(); + js_proxy_t *proxy = jsb_get_js_proxy(jsobj); + cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); + if (cobj) { + jsval ret = DOUBLE_TO_JSVAL(cobj->height); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_TextureData_height : Fail to retrieve property from TextureData."); + return false; + } + JS_ReportError(cx, "js_get_TextureData_height : Invalid native object."); + return false; +} +bool js_set_TextureData_height(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) +{ + JSObject* jsobj = obj.get(); + js_proxy_t *proxy = jsb_get_js_proxy(jsobj); + cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); + if (cobj) { + cobj->height = (float)vp.get().toNumber(); + return true; + } + JS_ReportError(cx, "js_set_TextureData_height : Invalid native object."); + return false; +} + +bool js_get_TextureData_pivotX(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) +{ + JSObject* jsobj = obj.get(); + js_proxy_t *proxy = jsb_get_js_proxy(jsobj); + cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); + if (cobj) { + jsval ret = DOUBLE_TO_JSVAL(cobj->pivotX); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_TextureData_pivotX : Fail to retrieve property from TextureData."); + return false; + } + JS_ReportError(cx, "js_get_TextureData_pivotX : Invalid native object."); + return false; +} +bool js_set_TextureData_pivotX(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) +{ + JSObject* jsobj = obj.get(); + js_proxy_t *proxy = jsb_get_js_proxy(jsobj); + cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); + if (cobj) { + cobj->pivotX = (float)vp.get().toNumber(); + return true; + } + JS_ReportError(cx, "js_set_TextureData_pivotX : Invalid native object."); + return false; +} + +bool js_get_TextureData_pivotY(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) +{ + JSObject* jsobj = obj.get(); + js_proxy_t *proxy = jsb_get_js_proxy(jsobj); + cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); + if (cobj) { + jsval ret = DOUBLE_TO_JSVAL(cobj->pivotY); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_TextureData_pivotY : Fail to retrieve property from TextureData."); + return false; + } + JS_ReportError(cx, "js_get_TextureData_pivotY : Invalid native object."); + return false; +} +bool js_set_TextureData_pivotY(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) +{ + JSObject* jsobj = obj.get(); + js_proxy_t *proxy = jsb_get_js_proxy(jsobj); + cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); + if (cobj) { + cobj->pivotY = (float)vp.get().toNumber(); + return true; + } + JS_ReportError(cx, "js_set_TextureData_pivotY : Invalid native object."); + return false; +} + +bool js_get_TextureData_name(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) +{ + JSObject* jsobj = obj.get(); + js_proxy_t *proxy = jsb_get_js_proxy(jsobj); + cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); + if (cobj) { + jsval ret = std_string_to_jsval(cx, cobj->name); + + if (ret != JSVAL_NULL) + { + vp.set(ret); + return true; + } + CCLOGERROR("js_get_TextureData_name : Fail to retrieve property name of TextureData."); + return false; + } + JS_ReportError(cx, "js_get_TextureData_name : Invalid native object."); + return false; +} +bool js_set_TextureData_name(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) +{ + JSObject* jsobj = obj.get(); + js_proxy_t *proxy = jsb_get_js_proxy(jsobj); + cocostudio::TextureData* cobj = (cocostudio::TextureData*)(proxy ? proxy->ptr : NULL); + if (cobj) { + std::string name; + bool ok = jsval_to_std_string(cx, JS::RootedValue(cx, vp.get()), &name); + JSB_PRECONDITION2(ok, cx, false, "js_set_TextureData_name : Error processing arguments"); + cobj->name = name; + return true; + } + JS_ReportError(cx, "js_set_TextureData_name : Invalid native object."); + return false; +} + + +extern JSObject* jsb_cocostudio_ArmatureAnimation_prototype; +extern JSObject* jsb_cocostudio_ArmatureDataManager_prototype; +extern JSObject* jsb_cocostudio_ColliderBody_prototype; +extern JSObject* jsb_cocostudio_BaseData_prototype; +extern JSObject* jsb_cocostudio_AnimationData_prototype; +extern JSObject* jsb_cocostudio_MovementData_prototype; +extern JSObject* jsb_cocostudio_ActionManagerEx_prototype; +extern JSObject* jsb_cocostudio_ContourData_prototype; +extern JSObject* jsb_cocostudio_TextureData_prototype; +extern JSObject* jsb_cocostudio_timeline_Frame_prototype; + +void register_all_cocos2dx_studio_manual(JSContext* cx, JS::HandleObject global) +{ + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocostudio_ColliderBody_prototype), "getCalculatedVertexList", js_cocos2dx_studio_ColliderBody_getCalculatedVertexList, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocostudio_ArmatureAnimation_prototype), "setMovementEventCallFunc", js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocostudio_ArmatureAnimation_prototype), "setFrameEventCallFunc", js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocostudio_ArmatureDataManager_prototype), "addArmatureFileInfoAsync", jsb_Animation_addArmatureFileInfoAsyncCallFunc, 3, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocostudio_ActionManagerEx_prototype), "initWithDictionaryEx", js_cocos2dx_studio_ActionManagerEx_initWithDictionaryEx, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE); + + JS::RootedObject frame(cx, jsb_cocostudio_timeline_Frame_prototype); + JS_DefineFunction(cx, frame, "setEasingParams", js_cocos2dx_studio_Frame_setEasingParams, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); + JS_DefineFunction(cx, frame, "getEasingParams", js_cocos2dx_studio_Frame_getEasingParams, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE); + + JS::RootedObject baseData(cx, jsb_cocostudio_BaseData_prototype); + JS_DefineProperty(cx, baseData, "x", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_BaseData_x, js_set_BaseData_x); + JS_DefineProperty(cx, baseData, "y", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_BaseData_y, js_set_BaseData_y); + JS_DefineProperty(cx, baseData, "zOrder", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_BaseData_zOrder, js_set_BaseData_zOrder); + JS_DefineProperty(cx, baseData, "skewX", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_BaseData_skewX, js_set_BaseData_skewX); + JS_DefineProperty(cx, baseData, "skewY", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_BaseData_skewY, js_set_BaseData_skewY); + JS_DefineProperty(cx, baseData, "scaleX", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_BaseData_scaleX, js_set_BaseData_scaleX); + JS_DefineProperty(cx, baseData, "scaleY", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_BaseData_scaleY, js_set_BaseData_scaleY); + JS_DefineProperty(cx, baseData, "tweenRotate", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_BaseData_tweenRotate, js_set_BaseData_tweenRotate); + JS_DefineProperty(cx, baseData, "isUseColorInfo", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_BaseData_isUseColorInfo, js_set_BaseData_isUseColorInfo); + JS_DefineProperty(cx, baseData, "a", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_BaseData_a, js_set_BaseData_a); + JS_DefineProperty(cx, baseData, "r", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_BaseData_r, js_set_BaseData_r); + JS_DefineProperty(cx, baseData, "g", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_BaseData_g, js_set_BaseData_g); + JS_DefineProperty(cx, baseData, "b", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_BaseData_b, js_set_BaseData_b); + + + JS::RootedObject animationData(cx, jsb_cocostudio_AnimationData_prototype); + JS_DefineProperty(cx, animationData, "name", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_AnimationData_name, js_set_AnimationData_name); + JS_DefineProperty(cx, animationData, "movementNames", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_AnimationData_movementNames, js_set_AnimationData_movementNames); + JS_DefineProperty(cx, animationData, "movementDataDic", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_AnimationData_movementDataDic, js_set_AnimationData_movementDataDic); + + JS::RootedObject movementData(cx, jsb_cocostudio_MovementData_prototype); + JS_DefineProperty(cx, movementData, "name", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_MovementData_name, js_set_MovementData_name); + JS_DefineProperty(cx, movementData, "duration", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_MovementData_duration, js_set_MovementData_duration); + JS_DefineProperty(cx, movementData, "scale", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_MovementData_scale, js_set_MovementData_scale); + JS_DefineProperty(cx, movementData, "durationTo", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_MovementData_durationTo, js_set_MovementData_durationTo); + JS_DefineProperty(cx, movementData, "durationTween", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_MovementData_durationTween, js_set_MovementData_durationTween); + JS_DefineProperty(cx, movementData, "loop", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_MovementData_loop, js_set_MovementData_loop); + JS_DefineProperty(cx, movementData, "tweenEasing", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_MovementData_tweenEasing, js_set_MovementData_tweenEasing); + + JS_DefineProperty(cx, JS::RootedObject(cx, jsb_cocostudio_ContourData_prototype), "vertextList", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_ContourData_vertexList, js_set_ContourData_vertexList); + + JS::RootedObject textureData(cx, jsb_cocostudio_TextureData_prototype); + JS_DefineProperty(cx, textureData, "contourDataList", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_TextureData_contourDataList, js_set_TextureData_contourDataList); + JS_DefineProperty(cx, textureData, "name", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_TextureData_name, js_set_TextureData_name); + JS_DefineProperty(cx, textureData, "width", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_TextureData_width, js_set_TextureData_width); + JS_DefineProperty(cx, textureData, "height", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_TextureData_height, js_set_TextureData_height); + JS_DefineProperty(cx, textureData, "pivotX", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_TextureData_pivotX, js_set_TextureData_pivotX); + JS_DefineProperty(cx, textureData, "pivotY", JS::UndefinedHandleValue, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, js_get_TextureData_pivotY, js_set_TextureData_pivotY); + +} diff --git a/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.h b/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.h new file mode 100644 index 0000000000..0efa151a22 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.h @@ -0,0 +1,32 @@ +/* + * Created by LinWenhai on 20/10/13. + * 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. + */ + +#ifndef __jsb_cocos2dx_studio_manual__ +#define __jsb_cocos2dx_studio_manual__ + +#include "jsapi.h" +#include "jsfriendapi.h" + +void register_all_cocos2dx_studio_manual(JSContext* cx, JS::HandleObject global); + +#endif /* defined(__jsb_cocos2dx_studio_manual__) */ diff --git a/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp b/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp new file mode 100644 index 0000000000..00edfc795d --- /dev/null +++ b/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp @@ -0,0 +1,1082 @@ +/* + * Created by James Chen on 3/11/13. + * 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. + */ + +#include "jsb_cocos2dx_extension_manual.h" +#include "extensions/cocos-ext.h" +#include "ScriptingCore.h" +#include "cocos2d_specifics.hpp" +#include "jsb_cocos2dx_auto.hpp" +#include + +USING_NS_CC; +USING_NS_CC_EXT; + + +class JSB_ScrollViewDelegate +: public Ref +, public ScrollViewDelegate +{ +public: + JSB_ScrollViewDelegate() + : _JSDelegate(NULL) + , _needUnroot(false) + {} + + virtual ~JSB_ScrollViewDelegate() + { + if (_needUnroot) + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RemoveObjectRoot(cx, &_JSDelegate); + } + } + + virtual void scrollViewDidScroll(ScrollView* view) override + { + js_proxy_t * p = jsb_get_native_proxy(view); + if (!p) return; + + jsval arg = OBJECT_TO_JSVAL(p->obj); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "scrollViewDidScroll", 1, &arg); + } + + virtual void scrollViewDidZoom(ScrollView* view) override + { + js_proxy_t * p = jsb_get_native_proxy(view); + if (!p) return; + + jsval arg = OBJECT_TO_JSVAL(p->obj); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "scrollViewDidZoom", 1, &arg); + } + + void setJSDelegate(JSObject* pJSDelegate) + { + _JSDelegate = pJSDelegate; + + // Check whether the js delegate is a pure js object. + js_proxy_t* p = jsb_get_js_proxy(_JSDelegate); + if (!p) + { + _needUnroot = true; + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::AddNamedObjectRoot(cx, &_JSDelegate, "TableViewDelegate"); + } + } +private: + JS::Heap _JSDelegate; + bool _needUnroot; +}; + +static bool js_cocos2dx_CCScrollView_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::ScrollView* cobj = (cocos2d::extension::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 1) + { + // save the delegate + JSObject *jsDelegate = args.get(0).toObjectOrNull(); + JSB_ScrollViewDelegate* nativeDelegate = new JSB_ScrollViewDelegate(); + nativeDelegate->setJSDelegate(jsDelegate); + + cobj->setUserObject(nativeDelegate); + cobj->setDelegate(nativeDelegate); + + nativeDelegate->release(); + + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + + +#define KEY_TABLEVIEW_DATA_SOURCE "TableViewDataSource" +#define KEY_TABLEVIEW_DELEGATE "TableViewDelegate" + +class JSB_TableViewDelegate +: public Ref +, public TableViewDelegate +{ +public: + JSB_TableViewDelegate() + : _JSDelegate(NULL) + , _needUnroot(false) + {} + + virtual ~JSB_TableViewDelegate() + { + if (_needUnroot) + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RemoveObjectRoot(cx, &_JSDelegate); + } + } + + virtual void scrollViewDidScroll(ScrollView* view) override + { + callJSDelegate(view, "scrollViewDidScroll"); + } + + virtual void scrollViewDidZoom(ScrollView* view) override + { + callJSDelegate(view, "scrollViewDidZoom"); + } + + virtual void tableCellTouched(TableView* table, TableViewCell* cell) override + { + callJSDelegate(table, cell, "tableCellTouched"); + } + + virtual void tableCellHighlight(TableView* table, TableViewCell* cell) override + { + callJSDelegate(table, cell, "tableCellHighlight"); + } + + virtual void tableCellUnhighlight(TableView* table, TableViewCell* cell) override + { + callJSDelegate(table, cell, "tableCellUnhighlight"); + } + + virtual void tableCellWillRecycle(TableView* table, TableViewCell* cell) override + { + callJSDelegate(table, cell, "tableCellWillRecycle"); + } + + void setJSDelegate(JSObject* pJSDelegate) + { + _JSDelegate = pJSDelegate; + + // Check whether the js delegate is a pure js object. + js_proxy_t* p = jsb_get_js_proxy(_JSDelegate); + if (!p) + { + _needUnroot = true; + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::AddNamedObjectRoot(cx, &_JSDelegate, "TableViewDelegate"); + } + } + + +private: + void callJSDelegate(ScrollView* view, std::string jsFunctionName) + { + js_proxy_t * p = jsb_get_native_proxy(view); + if (!p) return; + + jsval arg = OBJECT_TO_JSVAL(p->obj); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), jsFunctionName.c_str(), 1, &arg); + } + + void callJSDelegate(TableView* table, TableViewCell* cell, std::string jsFunctionName) + { + js_proxy_t * p = jsb_get_native_proxy(table); + if (!p) return; + + js_proxy_t * pCellProxy = jsb_get_native_proxy(cell); + if (!pCellProxy) return; + + jsval args[2]; + args[0] = OBJECT_TO_JSVAL(p->obj); + args[1] = OBJECT_TO_JSVAL(pCellProxy->obj); + + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), jsFunctionName.c_str(), 2, args); + } + + JS::Heap _JSDelegate; + bool _needUnroot; +}; + +static bool js_cocos2dx_CCTableView_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 1) + { + // save the delegate + JSObject *jsDelegate = args.get(0).toObjectOrNull(); + JSB_TableViewDelegate* nativeDelegate = new JSB_TableViewDelegate(); + nativeDelegate->setJSDelegate(jsDelegate); + + __Dictionary* userDict = static_cast<__Dictionary*>(cobj->getUserObject()); + if (NULL == userDict) + { + userDict = new __Dictionary(); + cobj->setUserObject(userDict); + userDict->release(); + } + + userDict->setObject(nativeDelegate, KEY_TABLEVIEW_DELEGATE); + + cobj->setDelegate(nativeDelegate); + + nativeDelegate->release(); + + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +class JSB_TableViewDataSource +: public Ref +, public TableViewDataSource +{ +public: + JSB_TableViewDataSource() + : _JSTableViewDataSource(NULL) + , _needUnroot(false) + {} + + virtual ~JSB_TableViewDataSource() + { + if (_needUnroot) + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RemoveObjectRoot(cx, &_JSTableViewDataSource); + } + } + + virtual Size tableCellSizeForIndex(TableView *table, ssize_t idx) override + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedValue ret(cx); + bool ok = callJSDelegate(table, idx, "tableCellSizeForIndex", &ret); + if (!ok) + { + ok = callJSDelegate(table, "cellSizeForTable", &ret); + } + if (ok) + { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + Size size; + bool isSucceed = jsval_to_ccsize(cx, ret, &size); + if (isSucceed) return size; + } + return Size::ZERO; + + } + + virtual TableViewCell* tableCellAtIndex(TableView *table, ssize_t idx) override + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedValue ret(cx); + bool ok = callJSDelegate(table, idx, "tableCellAtIndex", &ret); + if (ok) + { + cocos2d::extension::TableViewCell* arg0; + do { + js_proxy_t *proxy; + JSObject *tmpObj = ret.toObjectOrNull(); + proxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::extension::TableViewCell*)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, NULL, "Invalid Native Object"); + } while (0); + return arg0; + } + return NULL; + } + + virtual ssize_t numberOfCellsInTableView(TableView *table) override + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedValue ret(cx); + bool ok = callJSDelegate(table, "numberOfCellsInTableView", &ret); + if (ok) + { + ssize_t count = 0; + bool isSucceed = jsval_to_ssize(cx, ret, &count); + if (isSucceed) return count; + } + return 0; + } + + + void setTableViewDataSource(JSObject* pJSSource) + { + _JSTableViewDataSource = pJSSource; + + // Check whether the js delegate is a pure js object. + js_proxy_t* p = jsb_get_js_proxy(_JSTableViewDataSource); + if (!p) + { + _needUnroot = true; + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::AddNamedObjectRoot(cx, &_JSTableViewDataSource, "TableViewDataSource"); + } + } + +private: + bool callJSDelegate(TableView* table, std::string jsFunctionName, JS::MutableHandleValue retVal) + { + js_proxy_t * p = jsb_get_native_proxy(table); + if (!p) return false; + + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + + bool hasAction; + JS::RootedValue temp_retval(cx); + jsval dataVal = OBJECT_TO_JSVAL(p->obj); + + JS::RootedObject obj(cx, _JSTableViewDataSource); + JSAutoCompartment ac(cx, obj); + + if (JS_HasProperty(cx, obj, jsFunctionName.c_str(), &hasAction) && hasAction) + { + if(!JS_GetProperty(cx, obj, jsFunctionName.c_str(), &temp_retval)) + { + return false; + } + if(temp_retval == JSVAL_VOID) + { + return false; + } + + JS_CallFunctionName(cx, obj, jsFunctionName.c_str(), + JS::HandleValueArray::fromMarkedLocation(1, &dataVal), retVal); + return true; + } + return false; + } + + bool callJSDelegate(TableView* table, ssize_t idx, std::string jsFunctionName, JS::MutableHandleValue retVal) + { + js_proxy_t * p = jsb_get_native_proxy(table); + if (!p) return false; + + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + bool hasAction; + JS::RootedValue temp_retval(cx); + jsval dataVal[2]; + dataVal[0] = OBJECT_TO_JSVAL(p->obj); + dataVal[1] = ssize_to_jsval(cx,idx); + + JS::RootedObject obj(cx, _JSTableViewDataSource); + JSAutoCompartment ac(cx, obj); + + if (JS_HasProperty(cx, obj, jsFunctionName.c_str(), &hasAction) && hasAction) + { + if(!JS_GetProperty(cx, obj, jsFunctionName.c_str(), &temp_retval)) + { + return false; + } + + if(temp_retval == JSVAL_VOID) + { + return false; + } + + bool ret = JS_CallFunctionName(cx, obj, jsFunctionName.c_str(), + JS::HandleValueArray::fromMarkedLocation(2, dataVal), retVal); + return ret == true ? true : false; + } + return false; + } + +private: + JS::Heap _JSTableViewDataSource; + bool _needUnroot; +}; + +static bool js_cocos2dx_CCTableView_setDataSource(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + if (argc == 1) + { + JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); + pNativeSource->setTableViewDataSource(args.get(0).toObjectOrNull()); + + __Dictionary* userDict = static_cast<__Dictionary*>(cobj->getUserObject()); + if (NULL == userDict) + { + userDict = new __Dictionary(); + cobj->setUserObject(userDict); + userDict->release(); + } + + userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE); + + cobj->setDataSource(pNativeSource); + + pNativeSource->release(); + + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "wrong number of arguments"); + return false; +} + +static bool js_cocos2dx_CCTableView_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 3 || argc == 2) + { + + JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); + pNativeSource->setTableViewDataSource(args.get(0).toObjectOrNull()); + + cocos2d::Size arg1; + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + cocos2d::extension::TableView* ret = NULL; + ret = new TableView(); + ret->autorelease(); + + ret->setDataSource(pNativeSource); + + jsval jsret; + do { + if (ret) + { + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } + else + { + jsret = JSVAL_NULL; + } + } while (0); + + if (argc == 2) + { + ret->initWithViewSize(arg1); + } + else + { + cocos2d::Node* arg2; + do + { + js_proxy_t *proxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + proxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + ret->initWithViewSize(arg1, arg2); + } + ret->reloadData(); + + __Dictionary* userDict = new __Dictionary(); + userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE); + ret->setUserObject(userDict); + userDict->release(); + + pNativeSource->release(); + + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments"); + return false; +} + +static bool js_cocos2dx_CCTableView_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::TableView* cobj = (cocos2d::extension::TableView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_TableView_dequeueCell : Invalid Native Object"); + bool ok = true; + if (argc == 3 || argc == 2) + { + + JSB_TableViewDataSource* pNativeSource = new JSB_TableViewDataSource(); + pNativeSource->setTableViewDataSource(args.get(0).toObjectOrNull()); + cobj->setDataSource(pNativeSource); + + cocos2d::Size arg1; + ok &= jsval_to_ccsize(cx, args.get(1), &arg1); + + if (argc == 2) + { + cobj->initWithViewSize(arg1); + } + else + { + cocos2d::Node* arg2; + do + { + js_proxy_t *proxy; + JSObject *tmpObj = args.get(2).toObjectOrNull(); + proxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::Node*)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + cobj->initWithViewSize(arg1, arg2); + } + cobj->reloadData(); + + __Dictionary* userDict = new __Dictionary(); + userDict->setObject(pNativeSource, KEY_TABLEVIEW_DATA_SOURCE); + cobj->setUserObject(userDict); + userDict->release(); + + pNativeSource->release(); + + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "wrong number of arguments"); + return false; +} + + + +class JSB_ControlButtonTarget : public Ref +{ +public: + JSB_ControlButtonTarget() + : _jsFunc(nullptr), + _type(Control::EventType::TOUCH_DOWN), + _jsTarget(nullptr), + _needUnroot(false) + {} + + virtual ~JSB_ControlButtonTarget() + { + CCLOGINFO("In the destruction of JSB_ControlButtonTarget ..."); + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + if (_needUnroot) + { + JS::RemoveObjectRoot(cx, &_jsTarget); + } + + JS::RemoveObjectRoot(cx, &_jsFunc); + + for (auto iter = _jsNativeTargetMap.begin(); iter != _jsNativeTargetMap.end(); ++iter) + { + if (this == iter->second) + { + _jsNativeTargetMap.erase(iter); + break; + } + } + } + + virtual void onEvent(Ref *controlButton, Control::EventType event) + { + js_proxy_t * p; + JS_GET_PROXY(p, controlButton); + if (!p) + { + log("Failed to get proxy for control button"); + return; + } + + jsval dataVal[2]; + dataVal[0] = OBJECT_TO_JSVAL(p->obj); + int arg1 = (int)event; + dataVal[1] = INT_TO_JSVAL(arg1); + + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedValue jsRet(cx); + + ScriptingCore::getInstance()->executeJSFunctionWithThisObj(JS::RootedValue(cx, OBJECT_TO_JSVAL(_jsTarget)), JS::RootedValue(cx, OBJECT_TO_JSVAL(_jsFunc)), JS::HandleValueArray::fromMarkedLocation(2, dataVal), &jsRet); + } + + void setJSTarget(JSObject* pJSTarget) + { + _jsTarget = pJSTarget; + + js_proxy_t* p = jsb_get_js_proxy(_jsTarget); + if (!p) + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::AddNamedObjectRoot(cx, &_jsTarget, "JSB_ControlButtonTarget, target"); + _needUnroot = true; + } + } + + void setJSAction(JSObject* jsFunc) + { + _jsFunc = jsFunc; + + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::AddNamedObjectRoot(cx, &_jsFunc, "JSB_ControlButtonTarget, func"); + } + + void setEventType(Control::EventType type) + { + _type = type; + } +public: + + static std::multimap _jsNativeTargetMap; + JS::Heap _jsFunc; + Control::EventType _type; +private: + JS::Heap _jsTarget; + bool _needUnroot; +}; + +std::multimap JSB_ControlButtonTarget::_jsNativeTargetMap; + +static bool js_cocos2dx_CCControl_addTargetWithActionForControlEvents(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + bool ok = true; + if (argc == 3) + { + JSObject* jsDelegate = args.get(0).toObjectOrNull(); + JSObject* jsFunc = args.get(1).toObjectOrNull(); + Control::EventType arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + JSB_PRECONDITION2(ok, cx, false, "Error processing control event"); + + // Check whether the target already exists. + auto range = JSB_ControlButtonTarget::_jsNativeTargetMap.equal_range(jsDelegate); + for (auto it = range.first; it != range.second; ++it) + { + if (it->second->_jsFunc == jsFunc && arg2 == it->second->_type) + { + // Return true directly. + args.rval().setUndefined(); + return true; + } + } + + // save the delegate + JSB_ControlButtonTarget* nativeDelegate = new JSB_ControlButtonTarget(); + + nativeDelegate->setJSTarget(jsDelegate); + nativeDelegate->setJSAction(jsFunc); + nativeDelegate->setEventType(arg2); + + __Array* nativeDelegateArray = static_cast<__Array*>(cobj->getUserObject()); + if (nullptr == nativeDelegateArray) + { + nativeDelegateArray = new __Array(); + nativeDelegateArray->init(); + cobj->setUserObject(nativeDelegateArray); // The reference of nativeDelegateArray is added to 2 + nativeDelegateArray->release(); // Release nativeDelegateArray to make the reference to 1 + } + + nativeDelegateArray->addObject(nativeDelegate); // The reference of nativeDelegate is added to 2 + nativeDelegate->release(); // Release nativeDelegate to make the reference to 1 + + cobj->addTargetWithActionForControlEvents(nativeDelegate, cccontrol_selector(JSB_ControlButtonTarget::onEvent), arg2); + + JSB_ControlButtonTarget::_jsNativeTargetMap.insert(std::make_pair(jsDelegate, nativeDelegate)); + + args.rval().setUndefined(); + + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} + +static bool js_cocos2dx_CCControl_removeTargetWithActionForControlEvents(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::Control* cobj = (cocos2d::extension::Control *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + bool ok = true; + if (argc == 3) + { + Control::EventType arg2; + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + JSB_PRECONDITION2(ok, cx, false, "Error processing control event"); + + obj = args.get(0).toObjectOrNull(); + JSObject* jsFunc = args.get(1).toObjectOrNull(); + + JSB_ControlButtonTarget* nativeTargetToRemoved = nullptr; + + auto range = JSB_ControlButtonTarget::_jsNativeTargetMap.equal_range(obj); + for (auto it = range.first; it != range.second; ++it) + { + if (it->second->_jsFunc == jsFunc && arg2 == it->second->_type) + { + nativeTargetToRemoved = it->second; + JSB_ControlButtonTarget::_jsNativeTargetMap.erase(it); + break; + } + } + + cobj->removeTargetWithActionForControlEvents(nativeTargetToRemoved, cccontrol_selector(JSB_ControlButtonTarget::onEvent), arg2); + + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} + +/* +static bool js_cocos2dx_ext_AssetsManager_updateAssets(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::extension::AssetsManager* cobj = (cocos2d::extension::AssetsManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_AssetsManager_updateAssets : Invalid Native Object"); + if (argc == 1) { + std::unordered_map dict; + do { + if (!argv[0].isObject()) { ok = false; break; } + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + + if (!tmpObj) { + CCLOG("%s", "jsval_to_ccvaluemap: the jsval is not an object."); + return false; + } + + JSObject* it = JS_NewPropertyIterator(cx, tmpObj); + while (true) + { + jsid idp; + jsval key; + if (! JS_NextProperty(cx, it, &idp) || ! JS_IdToValue(cx, idp, &key)) { + return false; // error + } + + if (key == JSVAL_VOID) { + break; // end of iteration + } + + if (!JSVAL_IS_STRING(key)) { + continue; // ignore integer properties + } + + JSStringWrapper keyWrapper(JSVAL_TO_STRING(key), cx); + std::string keystr = keyWrapper.get(); + + JS::RootedValue value(cx); + JS_GetPropertyById(cx, tmpObj, idp, &value); + + JS::RootedObject tmp(cx); + JS::RootedValue jsSrcUrl(cx); + JS::RootedValue jsStoragePath(cx); + JS::RootedValue jsCustomId(cx); + ok = value.isObject() && + JS_ValueToObject(cx, JS::RootedValue(cx, value), &tmp) && + JS_GetProperty(cx, tmp, "srcUrl", &jsSrcUrl) && + JS_GetProperty(cx, tmp, "storagePath", &jsStoragePath) && + JS_GetProperty(cx, tmp, "customId", &jsCustomId); + JSB_PRECONDITION3(ok, cx, false, "Error parsing map entry"); + + Downloader::DownloadUnit unit; + + JSString *jsstr = JS::ToString(cx, jsSrcUrl); + JSB_PRECONDITION3(jsstr, cx, false, "Error processing srcUrl value of entry: %s", keystr); + JSStringWrapper srcUrlStr(jsstr); + unit.srcUrl = srcUrlStr.get(); + + jsstr = JS::ToString(cx, jsStoragePath); + JSB_PRECONDITION3(jsstr, cx, false, "Error processing storagePath value of entry: %s", keystr); + JSStringWrapper storagePathStr(jsstr); + unit.storagePath = storagePathStr.get(); + + jsstr = JS::ToString(cx, jsCustomId); + JSB_PRECONDITION3(jsstr, cx, false, "Error processing customId value of entry: %s", keystr); + JSStringWrapper customIdStr(jsstr); + unit.customId = customIdStr.get(); + + dict[keystr] = unit; + } + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_AssetsManager_updateAssets : Error processing arguments"); + cobj->updateAssets(dict); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_AssetsManager_updateAssets : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_ext_AssetsManager_getFailedAssets(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::AssetsManager* cobj = (cocos2d::extension::AssetsManager *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_AssetsManager_getFailedAssets : Invalid Native Object"); + if (argc == 0) { + const std::unordered_map &ret = cobj->getFailedAssets(); + jsval jsret = JSVAL_NULL; + do { + JSObject* jsRet = JS_NewObject(cx, NULL, NULL, NULL); + + for (auto it = ret.cbegin(); it != ret.cend(); ++it) { + std::string key = it->first; + const Downloader::DownloadUnit& unit = it->second; + + JSObject *elem = JS_NewObject(cx, NULL, NULL, NULL); + if (!elem) + { + JS_ReportError(cx, "js_cocos2dx_extension_AssetsManager_getFailedAssets : can not create js object"); + break; + } + bool ok = JS_DefineProperty(cx, elem, "srcUrl", std_string_to_jsval(cx, unit.srcUrl), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, elem, "storagePath", std_string_to_jsval(cx, unit.storagePath), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, elem, "customId", std_string_to_jsval(cx, unit.customId), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_AssetsManager_getFailedAssets : Error processing DownloadUnit struct"); + + if (!key.empty()) + { + JS::RootedValue dictElement(cx); + dictElement = OBJECT_TO_JSVAL(elem); + JS_SetProperty(cx, jsRet, key.c_str(), dictElement); + } + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_AssetsManager_getFailedAssets : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +*/ + +bool js_cocos2dx_ext_retain(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *thisObj = JS_THIS_OBJECT(cx, vp); + if (thisObj) { + js_proxy_t *proxy = jsb_get_js_proxy(thisObj); + if (proxy) { + ((Ref *)proxy->ptr)->retain(); + return true; + } + } + JS_ReportError(cx, "Invalid Native Object."); + return false; +} + +bool js_cocos2dx_ext_release(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *thisObj = JS_THIS_OBJECT(cx, vp); + if (thisObj) { + js_proxy_t *proxy = jsb_get_js_proxy(thisObj); + if (proxy) { + ((Ref *)proxy->ptr)->release(); + return true; + } + } + JS_ReportError(cx, "Invalid Native Object."); + return false; +} + + +__JSDownloaderDelegator::__JSDownloaderDelegator(JSContext *cx, JS::HandleObject obj, const std::string &url, JS::HandleValue callback) +: _cx(cx) +, _url(url) +, _buffer(nullptr) +{ + _obj.construct(_cx); + _obj.ref().set(obj); + _jsCallback.construct(_cx); + _jsCallback.ref().set(callback); + + if (Director::getInstance()->getTextureCache()->getTextureForKey(_url)) + { + onSuccess(nullptr, nullptr, nullptr); + } + else + { + _downloader = std::make_shared(); + _downloader->setConnectionTimeout(8); + _downloader->setErrorCallback( std::bind(&__JSDownloaderDelegator::onError, this, std::placeholders::_1) ); + _downloader->setSuccessCallback( std::bind(&__JSDownloaderDelegator::onSuccess, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3) ); + + long contentSize = _downloader->getContentSize(_url); + if (contentSize == -1) { + cocos2d::extension::Downloader::Error err; + onError(err); + } + else { + _size = contentSize / sizeof(unsigned char); + _buffer = (unsigned char*)malloc(contentSize); + _downloader->downloadToBufferSync(_url, _buffer, _size); + } + } +} + +__JSDownloaderDelegator::~__JSDownloaderDelegator() +{ + if (_buffer != nullptr) + free(_buffer); + _downloader->setErrorCallback(nullptr); + _downloader->setSuccessCallback(nullptr); +} + +void __JSDownloaderDelegator::onError(const cocos2d::extension::Downloader::Error &error) +{ + if (!_jsCallback.ref().isNull()) { + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedObject global(cx, ScriptingCore::getInstance()->getGlobalObject()); + + JSAutoCompartment ac(_cx, _obj.ref()); + + jsval succeed = BOOLEAN_TO_JSVAL(false); + JS::RootedValue retval(cx); + JS_CallFunctionValue(cx, global, _jsCallback.ref(), JS::HandleValueArray::fromMarkedLocation(1, &succeed), &retval); + } + this->release(); +} + +void __JSDownloaderDelegator::onSuccess(const std::string &srcUrl, const std::string &storagePath, const std::string &customId) +{ + Image *image = new Image(); + jsval valArr[2]; + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedObject global(cx, ScriptingCore::getInstance()->getGlobalObject()); + cocos2d::TextureCache *cache = Director::getInstance()->getTextureCache(); + + JSAutoCompartment ac(_cx, _obj.ref() ? _obj.ref() : global); + + Texture2D *tex = cache->getTextureForKey(_url); + if (tex) + { + valArr[0] = BOOLEAN_TO_JSVAL(true); + js_proxy_t* p = jsb_get_native_proxy(tex); + valArr[1] = OBJECT_TO_JSVAL(p->obj); + } + else if (image->initWithImageData(_buffer, _size)) + { + tex = Director::getInstance()->getTextureCache()->addImage(image, _url); + valArr[0] = BOOLEAN_TO_JSVAL(true); + + JS::RootedObject texProto(cx, jsb_cocos2d_Texture2D_prototype); + JSObject *obj = JS_NewObject(cx, jsb_cocos2d_Texture2D_class, texProto, global); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(tex, obj); + JS::AddNamedObjectRoot(cx, &p->obj, "cocos2d::Texture2D"); + valArr[1] = OBJECT_TO_JSVAL(p->obj); + } + else + { + valArr[0] = BOOLEAN_TO_JSVAL(false); + valArr[1] = JSVAL_NULL; + } + + image->release(); + + if (!_jsCallback.ref().isNull()) { + JS::RootedValue retval(cx); + JS_CallFunctionValue(cx, global, _jsCallback.ref(), JS::HandleValueArray::fromMarkedLocation(2, valArr), &retval); + } + this->release(); +} + +void __JSDownloaderDelegator::download(JSContext *cx, JS::HandleObject obj, const std::string &url, JS::HandleValue callback) +{ + auto t = std::thread([cx, obj, url, callback]() { + new __JSDownloaderDelegator(cx, obj, url, callback); + }); + t.detach(); +} + +// jsb.loadRemoteImg(url, function(succeed, result) {}) +bool js_load_remote_image(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, JS_THIS_OBJECT(cx, vp)); + if (argc == 2) { + std::string url; + bool ok = jsval_to_std_string(cx, args.get(0), &url); + JS::RootedValue callback(cx, args.get(1)); + + __JSDownloaderDelegator::download(cx, obj, url, callback); + + JSB_PRECONDITION2(ok, cx, false, "js_console_log : Error processing arguments"); + + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_load_remote_image : wrong number of arguments"); + return false; +} + +extern JSObject* jsb_cocos2d_extension_ScrollView_prototype; +extern JSObject* jsb_cocos2d_extension_TableView_prototype; +extern JSObject* jsb_cocos2d_extension_Control_prototype; +extern JSObject* jsb_cocos2d_extension_AssetsManagerEx_prototype; +extern JSObject* jsb_cocos2d_extension_Manifest_prototype; + +void register_all_cocos2dx_extension_manual(JSContext* cx, JS::HandleObject global) +{ + JS::RootedObject ccObj(cx); + JS::RootedValue tmpVal(cx); + JS::RootedObject tmpObj(cx); + get_or_create_js_obj(cx, global, "cc", &ccObj); + + JS::RootedObject am(cx, jsb_cocos2d_extension_AssetsManagerEx_prototype); + JS_DefineFunction(cx, am, "retain", js_cocos2dx_ext_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, am, "release", js_cocos2dx_ext_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS::RootedObject manifest(cx, jsb_cocos2d_extension_Manifest_prototype); + JS_DefineFunction(cx, manifest, "retain", js_cocos2dx_ext_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, manifest, "release", js_cocos2dx_ext_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + //JS_DefineFunction(cx, jsb_cocos2d_extension_AssetsManager_prototype, "updateAssets", js_cocos2dx_ext_AssetsManager_updateAssets, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + //JS_DefineFunction(cx, jsb_cocos2d_extension_AssetsManager_prototype, "getFailedAssets", js_cocos2dx_ext_AssetsManager_getFailedAssets, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_extension_ScrollView_prototype), "setDelegate", js_cocos2dx_CCScrollView_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS::RootedObject tableview(cx, jsb_cocos2d_extension_TableView_prototype); + JS_DefineFunction(cx, tableview, "setDelegate", js_cocos2dx_CCTableView_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tableview, "setDataSource", js_cocos2dx_CCTableView_setDataSource, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tableview, "_init", js_cocos2dx_CCTableView_init, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS::RootedObject control(cx, jsb_cocos2d_extension_Control_prototype); + JS_DefineFunction(cx, control, "addTargetWithActionForControlEvents", js_cocos2dx_CCControl_addTargetWithActionForControlEvents, 3, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, control, "removeTargetWithActionForControlEvents", js_cocos2dx_CCControl_removeTargetWithActionForControlEvents, 3, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_GetProperty(cx, ccObj, "TableView", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCTableView_create, 3, JSPROP_READONLY | JSPROP_PERMANENT); + + JS::RootedObject jsbObj(cx); + get_or_create_js_obj(cx, global, "jsb", &jsbObj); + + JS_DefineFunction(cx, jsbObj, "loadRemoteImg", js_load_remote_image, 2, JSPROP_READONLY | JSPROP_PERMANENT); +} \ No newline at end of file diff --git a/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.h b/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.h new file mode 100644 index 0000000000..29cd76e94b --- /dev/null +++ b/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.h @@ -0,0 +1,55 @@ +/* + * Created by James Chen on 3/11/13. + * 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. + */ + +#ifndef __jsb_cocos2dx_extension_manual__ +#define __jsb_cocos2dx_extension_manual__ + +#include "jsapi.h" +#include "jsfriendapi.h" +#include "mozilla/Maybe.h" +#include "extensions/assets-manager/Downloader.h" + +class __JSDownloaderDelegator : cocos2d::Ref +{ +public: + static void download(JSContext *cx, JS::HandleObject obj, const std::string &url, JS::HandleValue callback); + +protected: + __JSDownloaderDelegator(JSContext *cx, JS::HandleObject obj, const std::string &url, JS::HandleValue callback); + ~__JSDownloaderDelegator(); + +private: + void onSuccess(const std::string &srcUrl, const std::string &storagePath, const std::string &customId); + void onError(const cocos2d::extension::Downloader::Error &error); + unsigned char *_buffer; + long _size; + std::shared_ptr _downloader; + std::string _url; + JSContext *_cx; + mozilla::Maybe _jsCallback; + mozilla::Maybe _obj; +}; + +void register_all_cocos2dx_extension_manual(JSContext* cx, JS::HandleObject global); + +#endif /* defined(__jsb_cocos2dx_extension_manual__) */ diff --git a/cocos/scripting/js-bindings/manual/js_bindings_config.h b/cocos/scripting/js-bindings/manual/js_bindings_config.h new file mode 100644 index 0000000000..4b85ec4197 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/js_bindings_config.h @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2012 Zynga Inc. + * 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. + */ + + +#ifndef __JS_BINDINGS_CONFIG_H +#define __JS_BINDINGS_CONFIG_H + + +/** @def JSB_ASSERT_ON_FAIL + Whether or not to assert when the arguments or conversions are incorrect. + It is recommened to turn it off in Release mode. + */ +#ifndef JSB_ASSERT_ON_FAIL +#define JSB_ASSERT_ON_FAIL 0 +#endif + + +#if JSB_ASSERT_ON_FAIL +#define JSB_PRECONDITION( condition, error_msg) do { NSCAssert( condition, [NSString stringWithUTF8String:error_msg] ); } while(0) +#define JSB_PRECONDITION2( condition, context, ret_value, error_msg) do { NSCAssert( condition, [NSString stringWithUTF8String:error_msg] ); } while(0) +#define ASSERT( condition, error_msg) do { NSCAssert( condition, [NSString stringWithUTF8String:error_msg] ); } while(0) + +#else +#define JSB_PRECONDITION( condition, ...) do { \ + if( ! (condition) ) { \ + cocos2d::log("jsb: ERROR: File %s: Line: %d, Function: %s", __FILE__, __LINE__, __FUNCTION__ ); \ + cocos2d::log(__VA_ARGS__); \ + JSContext* globalContext = ScriptingCore::getInstance()->getGlobalContext(); \ + if( ! JS_IsExceptionPending( globalContext ) ) { \ + JS_ReportError( globalContext, __VA_ARGS__ ); \ + } \ + return false; \ + } \ +} while(0) +#define JSB_PRECONDITION2( condition, context, ret_value, ...) do { \ + if( ! (condition) ) { \ + cocos2d::log("jsb: ERROR: File %s: Line: %d, Function: %s", __FILE__, __LINE__, __FUNCTION__ ); \ + cocos2d::log(__VA_ARGS__); \ + if( ! JS_IsExceptionPending( context ) ) { \ + JS_ReportError( context, __VA_ARGS__ ); \ + } \ + return ret_value; \ + } \ +} while(0) +#define ASSERT( condition, error_msg) do { \ + if( ! (condition) ) { \ + CCLOG("jsb: ERROR in %s: %s\n", __FUNCTION__, error_msg); \ + return false; \ + } \ + } while(0) +#endif + +#define JSB_PRECONDITION3( condition, context, ret_value, ...) do { \ + if( ! (condition) ) return (ret_value); \ + } while(0) + + +/** @def JSB_REPRESENT_LONGLONG_AS_STR + When JSB_REPRESENT_LONGLONG_AS_STR is defined, the long long will be represented as JS strings. + Otherwise they will be represented as an array of two intengers. + It is needed to to use an special representation since there are no 64-bit integers in JS. + Representing the long long as string could be a bit slower, but it is easier to debug from JS. + Enabled by default. + */ +#ifndef JSB_REPRESENT_LONGLONG_AS_STR +#define JSB_REPRESENT_LONGLONG_AS_STR 1 +#endif // JSB_REPRESENT_LONGLONG_AS_STR + + +/** @def JSB_INCLUDE_CHIPMUNK + Whether or not it should include JS bindings for Chipmunk + */ +#ifndef JSB_INCLUDE_CHIPMUNK +#define JSB_INCLUDE_CHIPMUNK 1 +#endif // JSB_INCLUDE_CHIPMUNK + + +/** @def JSB_INCLUDE_COCOSBUILDERREADER + Whether or not it should include JS bindings for CocosBuilder Reader + */ +#ifndef JSB_INCLUDE_COCOSBUILDERREADER +#define JSB_INCLUDE_COCOSBUILDERREADER 1 +#endif // JSB_INCLUDE_COCOSBUILDERREADER + +/** @def JSB_INCLUDE_COCOSDENSHION + Whether or not it should include bindings for CocosDenshion (sound engine) + */ +#ifndef JSB_INCLUDE_COCOSDENSHION +#define JSB_INCLUDE_COCOSDENSHION 1 +#endif // JSB_INCLUDE_COCOSDENSHION + +#if JSB_ENABLE_DEBUGGER +#define JSB_ENSURE_AUTOCOMPARTMENT(cx, obj) \ +JSAutoCompartment ac(cx, obj) +#else +#define JSB_ENSURE_AUTOCOMPARTMENT(cx, obj) +#endif + +#define JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET \ +JSAutoCompartment __jsb_ac(ScriptingCore::getInstance()->getGlobalContext(), ScriptingCore::getInstance()->getGlobalObject()); + + +/** @def JSB_INCLUDE_SYSTEM + Whether or not it should include bindings for system components like LocalStorage + */ +#ifndef JSB_INCLUDE_SYSTEM +#define JSB_INCLUDE_SYSTEM 1 +#endif // JSB_INCLUDE_SYSTEM + +/** @def JSB_INCLUDE_OPENGL + Whether or not it should include bindings for WebGL / OpenGL ES 2.0 + */ +#ifndef JSB_INCLUDE_OPENGL +#define JSB_INCLUDE_OPENGL 1 +#endif // JSB_INCLUDE_OPENGL + +/** @def JSB_INCLUDE_XMLHTTP + Whether or not it should include bindings for XmlHttpRequest + */ +#ifndef JSB_INCLUDE_XMLHTTP +#define JSB_INCLUDE_XMLHTTP 1 +#endif // JSB_INCLUDE_XMLHTTP + +#ifndef JSB_MAX_STACK_QUOTA +#define JSB_MAX_STACK_QUOTA 500000 +#endif // JSB_MAX_STACK_QUOTA + +#endif // __JS_BINDINGS_CONFIG_H diff --git a/cocos/scripting/js-bindings/manual/js_bindings_core.cpp b/cocos/scripting/js-bindings/manual/js_bindings_core.cpp new file mode 100644 index 0000000000..be2fbc2264 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/js_bindings_core.cpp @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2012 Zynga Inc. + * 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. + */ +#include "js_bindings_config.h" +#include "js_bindings_core.h" + +// cocos2d + chipmunk registration files +#include "chipmunk/js_bindings_chipmunk_registration.h" +#include "cocos2d.h" + +//#pragma mark - Hash + +typedef struct _hashJSObject +{ + JSObject *jsObject; + void *proxy; + UT_hash_handle hh; +} tHashJSObject; + +static tHashJSObject *hash = NULL; +static tHashJSObject *reverse_hash = NULL; + +//#pragma mark JSBCore - Helper free functions +static void reportError(JSContext *cx, const char *message, JSErrorReport *report) +{ + fprintf(stderr, "%s:%u:%s\n", + report->filename ? report->filename : "", + (unsigned int) report->lineno, + message); +}; + + +// Hash of JSObject -> proxy +void* jsb_get_proxy_for_jsobject(JSObject *obj) +{ + tHashJSObject *element = NULL; + HASH_FIND_PTR(hash, &obj, element); + + if( element ) + return element->proxy; + return NULL; +} + +void jsb_set_proxy_for_jsobject(void *proxy, JSObject *obj) +{ + CCASSERT( !jsb_get_proxy_for_jsobject(obj), "Already added. abort"); + +// printf("Setting proxy for: %p - %p (%s)\n", obj, proxy, [[proxy description] UTF8String] ); + + tHashJSObject *element = (tHashJSObject*) malloc( sizeof( *element ) ); + + // XXX: Do not retain it here. +// [proxy retain]; + element->proxy = proxy; + element->jsObject = obj; + + HASH_ADD_PTR( hash, jsObject, element ); +} + +void jsb_del_proxy_for_jsobject(JSObject *obj) +{ + tHashJSObject *element = NULL; + HASH_FIND_PTR(hash, &obj, element); + if( element ) { + HASH_DEL(hash, element); + free(element); + } +} + +//#pragma mark Proxy -> JSObject + +// Reverse hash: Proxy -> JSObject +JSObject* jsb_get_jsobject_for_proxy(void *proxy) +{ + tHashJSObject *element = NULL; + HASH_FIND_PTR(reverse_hash, &proxy, element); + + if( element ) + return element->jsObject; + return NULL; +} + +void jsb_set_jsobject_for_proxy(JSObject *jsobj, void* proxy) +{ + CCASSERT( !jsb_get_jsobject_for_proxy(proxy), "Already added. abort"); + + tHashJSObject *element = (tHashJSObject*) malloc( sizeof( *element ) ); + + element->proxy = proxy; + element->jsObject = jsobj; + + HASH_ADD_PTR( reverse_hash, proxy, element ); +} + +void jsb_del_jsobject_for_proxy(void* proxy) +{ + tHashJSObject *element = NULL; + HASH_FIND_PTR(reverse_hash, &proxy, element); + if( element ) { + HASH_DEL(reverse_hash, element); + free(element); + } +} + +//#pragma mark + + +//#pragma mark "C" proxy functions + +struct jsb_c_proxy_s* jsb_get_c_proxy_for_jsobject( JSObject *jsobj ) +{ + struct jsb_c_proxy_s *proxy = (struct jsb_c_proxy_s *) JS_GetPrivate(jsobj); + + return proxy; +} + +void jsb_del_c_proxy_for_jsobject( JSObject *jsobj ) +{ + struct jsb_c_proxy_s *proxy = (struct jsb_c_proxy_s *) JS_GetPrivate(jsobj); + CCASSERT(proxy, "Invalid proxy for JSObject"); + JS_SetPrivate(jsobj, NULL); + + free(proxy); +} + +void jsb_set_c_proxy_for_jsobject( JSObject *jsobj, void *handle, unsigned long flags) +{ + struct jsb_c_proxy_s *proxy = (struct jsb_c_proxy_s*) malloc(sizeof(*proxy)); + CCASSERT(proxy, "No memory for proxy"); + + proxy->handle = handle; + proxy->flags = flags; + proxy->jsobj = jsobj; + + JS_SetPrivate(jsobj, proxy); +} + + +//#pragma mark Do Nothing - Callbacks + +bool JSB_do_nothing(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().setUndefined(); + return true; +} diff --git a/cocos/scripting/js-bindings/manual/js_bindings_core.h b/cocos/scripting/js-bindings/manual/js_bindings_core.h new file mode 100644 index 0000000000..4669b2ab5a --- /dev/null +++ b/cocos/scripting/js-bindings/manual/js_bindings_core.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2012 Zynga Inc. + * 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. + */ + +#ifndef __JS_BINDINGS_CORE_H__ +#define __JS_BINDINGS_CORE_H__ + +#include "jsapi.h" +#include "jsfriendapi.h" + +#ifdef __cplusplus +extern "C" { +#endif + + enum { + JSB_C_FLAG_CALL_FREE = 0, + JSB_C_FLAG_DO_NOT_CALL_FREE =1, + }; + + // structure used by "Object Oriented Functions". + // handle is a pointer to the native object + // flags: flags for the object + struct jsb_c_proxy_s { + unsigned long flags; // Should it be removed at "destructor" time, or not ? + void *handle; // native object, like cpSpace, cpBody, etc. + JS::Heap jsobj; // JS Object. Needed for rooting / unrooting + }; + + // Functions for setting / removing / getting the proxy used by the "C" Object Oriented API. Think of Chipmunk classes + struct jsb_c_proxy_s* jsb_get_c_proxy_for_jsobject( JSObject *jsobj ); + void jsb_del_c_proxy_for_jsobject( JSObject *jsobj ); + void jsb_set_c_proxy_for_jsobject( JSObject *jsobj, void *handle, unsigned long flags); + + // JSObject -> proxy + /** gets a proxy for a given JSObject */ + void* jsb_get_proxy_for_jsobject(JSObject *jsobj); + /** sets a proxy for a given JSObject */ + void jsb_set_proxy_for_jsobject(void* proxy, JSObject *jsobj); + /** dels a proxy for a given JSObject */ + void jsb_del_proxy_for_jsobject(JSObject *jsobj); + + // reverse: proxy -> JSObject + /** gets a JSObject for a given proxy */ + JSObject* jsb_get_jsobject_for_proxy(void *proxy); + /** sets a JSObject for a given proxy */ + void jsb_set_jsobject_for_proxy(JSObject *jsobj, void* proxy); + /** delts a JSObject for a given proxy */ + void jsb_del_jsobject_for_proxy(void* proxy); + + + // needed for callbacks. It does nothing. + bool JSB_do_nothing(JSContext *cx, uint32_t argc, jsval *vp); + +#ifdef __cplusplus +} +#endif + +#endif /* __JS_BINDINGS_CORE_H__ */ diff --git a/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp b/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp new file mode 100644 index 0000000000..0a795eb802 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp @@ -0,0 +1,188 @@ +/* + * 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. + */ + +#include "js_bindings_opengl.h" + +NS_CC_BEGIN + +void GLNode::draw(Renderer *renderer, const Mat4& transform, uint32_t flags) { + _customCommand.init(_globalZOrder); + _customCommand.func = CC_CALLBACK_0(GLNode::onDraw, this, transform, flags); + renderer->addCommand(&_customCommand); +} + +void GLNode::onDraw(Mat4 &transform, uint32_t flags) +{ + js_proxy_t* proxy = NULL; + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + proxy = js_get_or_create_proxy(cx, this); + + if( proxy ) { +// JSObject *jsObj = proxy->obj; + JS::RootedObject jsObj(cx, proxy->obj.get()); + if (jsObj) { + bool found = false; + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JS_HasProperty(cx, jsObj, "draw", &found); + if (found == true) { + auto director = Director::getInstance(); + director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); + director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, transform); + + JS::RootedValue rval(cx); + JS::RootedValue fval(cx); + JS_GetProperty(cx, jsObj, "draw", &fval); + + JS_CallFunctionValue(cx, jsObj, fval, JS::HandleValueArray::empty(), &rval); + + director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); + } + } + } +} + +NS_CC_END + +JSClass *js_cocos2dx_GLNode_class; +JSObject *js_cocos2dx_GLNode_prototype; + +bool js_cocos2dx_GLNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + + if (argc == 0) { + cocos2d::GLNode* cobj = new cocos2d::GLNode(); + 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, JS::RootedObject(cx, typeClass->proto), JS::RootedObject(cx, typeClass->parentProto)); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().set(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::GLNode"); + + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +void js_cocos2dx_GLNode_finalize(JSFreeOp *fop, JSObject *obj) { +} + +static bool js_cocos2dx_GLNode_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + cocos2d::GLNode *nobj = new cocos2d::GLNode(); + js_proxy_t* p = jsb_new_proxy(nobj, obj); + nobj->autorelease(); + JS::AddNamedObjectRoot(cx, &p->obj, "GLNode"); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().setUndefined(); + return true; +} + +bool js_cocos2dx_GLNode_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + cocos2d::GLNode* ret = new cocos2d::GLNode(); + jsval jsret; + do { + if (ret) { + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; +} + +extern JSObject* jsb_cocos2d_Node_prototype; + +void js_register_cocos2dx_GLNode(JSContext *cx, JS::HandleObject global) { + js_cocos2dx_GLNode_class = (JSClass *)calloc(1, sizeof(JSClass)); + js_cocos2dx_GLNode_class->name = "GLNode"; + js_cocos2dx_GLNode_class->addProperty = JS_PropertyStub; + js_cocos2dx_GLNode_class->delProperty = JS_DeletePropertyStub; + js_cocos2dx_GLNode_class->getProperty = JS_PropertyStub; + js_cocos2dx_GLNode_class->setProperty = JS_StrictPropertyStub; + js_cocos2dx_GLNode_class->enumerate = JS_EnumerateStub; + js_cocos2dx_GLNode_class->resolve = JS_ResolveStub; + js_cocos2dx_GLNode_class->convert = JS_ConvertStub; + js_cocos2dx_GLNode_class->finalize = js_cocos2dx_GLNode_finalize; + js_cocos2dx_GLNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + {0, 0, 0, 0, 0} + }; + + static JSFunctionSpec funcs[] = { + JS_FN("ctor", js_cocos2dx_GLNode_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_GLNode_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + js_cocos2dx_GLNode_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + js_cocos2dx_GLNode_class, + js_cocos2dx_GLNode_constructor, 0, // constructor + properties, + funcs, + NULL, // no static properties + st_funcs); + // make the class enumerable in the registered namespace +// bool found; +// JS_SetPropertyAttributes(cx, global, "GLNode", 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 = js_cocos2dx_GLNode_class; + p->proto = js_cocos2dx_GLNode_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} diff --git a/cocos/scripting/js-bindings/manual/js_bindings_opengl.h b/cocos/scripting/js-bindings/manual/js_bindings_opengl.h new file mode 100644 index 0000000000..061cecf5d3 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/js_bindings_opengl.h @@ -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. + */ + +#include "ScriptingCore.h" +#include "cocos2d_specifics.hpp" + +NS_CC_BEGIN + +class GLNode : public cocos2d::Node +{ +public: + void draw(Renderer *renderer, const Mat4& transform, uint32_t flags) override; +protected: + void onDraw(Mat4 &transform, uint32_t flags); + cocos2d::CustomCommand _customCommand; +}; + +NS_CC_END + +void js_register_cocos2dx_GLNode(JSContext *cx, JS::HandleObject global); diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp b/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp new file mode 100644 index 0000000000..ff324bb62c --- /dev/null +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp @@ -0,0 +1,2551 @@ +/* + * Created by Rohan Kuruvilla + * Copyright (c) 2012 Zynga Inc. + * 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. + */ + +#include "ScriptingCore.h" +#include "js_bindings_config.h" +#include "js_manual_conversions.h" +#include "cocos2d_specifics.hpp" +#include "math/TransformUtils.h" + +USING_NS_CC; + +// JSStringWrapper +JSStringWrapper::JSStringWrapper() +: _buffer(nullptr) +{ +} + +JSStringWrapper::JSStringWrapper(JSString* str, JSContext* cx/* = NULL*/) +: _buffer(nullptr) +{ + set(str, cx); +} + +JSStringWrapper::JSStringWrapper(jsval val, JSContext* cx/* = NULL*/) +: _buffer(nullptr) +{ + set(val, cx); +} + +JSStringWrapper::~JSStringWrapper() +{ + JS_free(ScriptingCore::getInstance()->getGlobalContext(), (void*)_buffer); +} + +void JSStringWrapper::set(jsval val, JSContext* cx) +{ + if (val.isString()) + { + this->set(val.toString(), cx); + } + else + { + CC_SAFE_DELETE_ARRAY(_buffer); + } +} + +void JSStringWrapper::set(JSString* str, JSContext* cx) +{ + CC_SAFE_DELETE_ARRAY(_buffer); + + if (!cx) + { + cx = ScriptingCore::getInstance()->getGlobalContext(); + } + // JS_EncodeString isn't supported in SpiderMonkey ff19.0. + //buffer = JS_EncodeString(cx, string); + + //JS_GetStringCharsZ is removed in SpiderMonkey 33 +// unsigned short* pStrUTF16 = (unsigned short*)JS_GetStringCharsZ(cx, str); + +// _buffer = cc_utf16_to_utf8(pStrUTF16, -1, NULL, NULL); + + _buffer = JS_EncodeStringToUTF8(cx, JS::RootedString(cx, str)); +} + +const char* JSStringWrapper::get() +{ + return _buffer ? _buffer : ""; +} + +// JSFunctionWrapper +JSFunctionWrapper::JSFunctionWrapper(JSContext* cx, JSObject *jsthis, jsval fval) +: _cx(cx) +, _jsthis(jsthis) +, _fval(fval) +{ + JS::AddNamedValueRoot(cx, &this->_fval, "JSFunctionWrapper"); + JS::AddNamedObjectRoot(cx, &this->_jsthis, "JSFunctionWrapper"); +} + +JSFunctionWrapper::~JSFunctionWrapper() +{ + JS::RemoveValueRoot(this->_cx, &this->_fval); + JS::RemoveObjectRoot(this->_cx, &this->_jsthis); +} + +bool JSFunctionWrapper::invoke(unsigned int argc, jsval *argv, JS::MutableHandleValue rval) +{ + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + return JS_CallFunctionValue(this->_cx, JS::RootedObject(_cx, this->_jsthis.get()), JS::RootedValue(_cx, this->_fval.get()), JS::HandleValueArray::fromMarkedLocation(argc, argv), rval); +} + +static Color3B getColorFromJSObject(JSContext *cx, JS::HandleObject colorObject) +{ + JS::RootedValue jsr(cx); + Color3B out; + JS_GetProperty(cx, colorObject, "r", &jsr); + double fontR = 0.0; + JS::ToNumber(cx, jsr, &fontR); + + JS_GetProperty(cx, colorObject, "g", &jsr); + double fontG = 0.0; + JS::ToNumber(cx, jsr, &fontG); + + JS_GetProperty(cx, colorObject, "b", &jsr); + double fontB = 0.0; + JS::ToNumber(cx, jsr, &fontB); + + // the out + out.r = (unsigned char)fontR; + out.g = (unsigned char)fontG; + out.b = (unsigned char)fontB; + + return out; +} + +static Size getSizeFromJSObject(JSContext *cx, JS::HandleObject sizeObject) +{ + JS::RootedValue jsr(cx); + Size out; + JS_GetProperty(cx, sizeObject, "width", &jsr); + double width = 0.0; + JS::ToNumber(cx, jsr, &width); + + JS_GetProperty(cx, sizeObject, "height", &jsr); + double height = 0.0; + JS::ToNumber(cx, jsr, &height); + + + // the out + out.width = width; + out.height = height; + + return out; +} + +bool jsval_to_opaque( JSContext *cx, JS::HandleValue vp, void **r) +{ +#ifdef __LP64__ + + // begin + JS::RootedObject tmp_arg(cx); + bool ok = JS_ValueToObject( cx, vp, &tmp_arg ); + JSB_PRECONDITION2( ok, cx, false, "Error converting value to object"); + JSB_PRECONDITION2( tmp_arg && JS_IsTypedArrayObject( tmp_arg ), cx, false, "Not a TypedArray object"); + JSB_PRECONDITION2( JS_GetTypedArrayByteLength( tmp_arg ) == sizeof(void*), cx, false, "Invalid Typed Array length"); + + uint32_t* arg_array = (uint32_t*)JS_GetArrayBufferViewData( tmp_arg ); + uint64_t ret = arg_array[0]; + ret = ret << 32; + ret |= arg_array[1]; + +#else + assert( sizeof(int)==4); + int32_t ret; + if( ! jsval_to_int32(cx, vp, &ret ) ) + return false; +#endif + *r = (void*)ret; + return true; +} + +bool jsval_to_int( JSContext *cx, JS::HandleValue vp, int *ret ) +{ + // Since this is called to cast uint64 to uint32, + // it is needed to initialize the value to 0 first +#ifdef __LP64__ + long *tmp = (long*)ret; + *tmp = 0; +#endif + return jsval_to_int32(cx, vp, (int32_t*)ret); +} + +jsval opaque_to_jsval( JSContext *cx, void *opaque ) +{ +#ifdef __LP64__ + uint64_t number = (uint64_t)opaque; + JSObject *typedArray = JS_NewUint32Array( cx, 2 ); + uint32_t *buffer = (uint32_t*)JS_GetArrayBufferViewData(typedArray); + buffer[0] = number >> 32; + buffer[1] = number & 0xffffffff; + return OBJECT_TO_JSVAL(typedArray); +#else + assert(sizeof(int)==4); + int32_t number = (int32_t) opaque; + return INT_TO_JSVAL(number); +#endif +} + +jsval c_class_to_jsval( JSContext *cx, void* handle, JS::HandleObject object, JSClass *klass, const char* class_name) +{ + JS::RootedObject jsobj(cx); + + jsobj = jsb_get_jsobject_for_proxy(handle); + if( !jsobj ) { + JS::RootedObject parent(cx); + jsobj = JS_NewObject(cx, klass, object, parent); + CCASSERT(jsobj, "Invalid object"); + jsb_set_c_proxy_for_jsobject(jsobj, handle, JSB_C_FLAG_DO_NOT_CALL_FREE); + jsb_set_jsobject_for_proxy(jsobj, handle); + } + + return OBJECT_TO_JSVAL(jsobj); +} + +bool jsval_to_c_class( JSContext *cx, JS::HandleValue vp, void **out_native, struct jsb_c_proxy_s **out_proxy) +{ + JS::RootedObject jsobj(cx); + bool ok = JS_ValueToObject( cx, vp, &jsobj ); + JSB_PRECONDITION2(ok, cx, false, "Error converting jsval to object"); + + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsobj); + *out_native = proxy->handle; + if( out_proxy ) + *out_proxy = proxy; + return true; +} + +bool jsval_to_uint( JSContext *cx, JS::HandleValue vp, unsigned int *ret ) +{ + // Since this is called to cast uint64 to uint32, + // it is needed to initialize the value to 0 first +#ifdef __LP64__ + long *tmp = (long*)ret; + *tmp = 0; +#endif + return jsval_to_int32(cx, vp, (int32_t*)ret); +} + +jsval long_to_jsval( JSContext *cx, long number ) +{ +#ifdef __LP64__ + assert( sizeof(long)==8); + + char chr[128]; + snprintf(chr, sizeof(chr)-1, "%ld", number); + JSString *ret_obj = JS_NewStringCopyZ(cx, chr); + return STRING_TO_JSVAL(ret_obj); +#else + CCASSERT( sizeof(int)==4, "Error!"); + return INT_TO_JSVAL(number); +#endif +} + +jsval ulong_to_jsval( JSContext *cx, unsigned long number ) +{ +#ifdef __LP64__ + assert( sizeof(unsigned long)==8); + + char chr[128]; + snprintf(chr, sizeof(chr)-1, "%lu", number); + JSString *ret_obj = JS_NewStringCopyZ(cx, chr); + return STRING_TO_JSVAL(ret_obj); +#else + CCASSERT( sizeof(int)==4, "Error!"); + return UINT_TO_JSVAL(number); +#endif +} + +jsval long_long_to_jsval( JSContext *cx, long long number ) +{ +#if JSB_REPRESENT_LONGLONG_AS_STR + char chr[128]; + snprintf(chr, sizeof(chr)-1, "%lld", number); + JSString *ret_obj = JS_NewStringCopyZ(cx, chr); + return STRING_TO_JSVAL(ret_obj); + +#else + CCASSERT( sizeof(long long)==8, "Error!"); + JSObject *typedArray = JS_NewUint32Array( cx, 2 ); + uint32_t *buffer = (uint32_t*)JS_GetArrayBufferViewData(typedArray, cx); + buffer[0] = number >> 32; + buffer[1] = number & 0xffffffff; + return OBJECT_TO_JSVAL(typedArray); +#endif +} + +bool jsval_to_charptr( JSContext *cx, JS::HandleValue vp, const char **ret ) +{ + JSString *jsstr = JS::ToString( cx, vp ); + JSB_PRECONDITION2( jsstr, cx, false, "invalid string" ); + + //XXX: what's this? + // root it +// vp = STRING_TO_JSVAL(jsstr); + + JSStringWrapper strWrapper(jsstr); + + // XXX: It is converted to String and then back to char* to autorelease the created object. + __String *tmp = String::create(strWrapper.get()); + + JSB_PRECONDITION2( tmp, cx, false, "Error creating string from UTF8"); + + *ret = tmp->getCString(); + + return true; +} + +jsval charptr_to_jsval( JSContext *cx, const char *str) +{ + return c_string_to_jsval(cx, str); +} + +bool JSB_jsval_typedarray_to_dataptr( JSContext *cx, JS::HandleValue vp, GLsizei *count, void **data, js::Scalar::Type t) +{ + JS::RootedObject jsobj(cx); + bool ok = JS_ValueToObject( cx, vp, &jsobj ); + JSB_PRECONDITION2( ok && jsobj, cx, false, "Error converting value to object"); + + // WebGL supports TypedArray and sequences for some of its APIs. So when converting a TypedArray, we should + // also check for a possible non-Typed Array JS object, like a JS Array. + + if( JS_IsTypedArrayObject( jsobj ) ) { + + *count = JS_GetTypedArrayLength(jsobj); + js::Scalar::Type type = JS_GetArrayBufferViewType(jsobj); + JSB_PRECONDITION2(t==type, cx, false, "TypedArray type different than expected type"); + + switch (t) { + case js::Scalar::Int8: + case js::Scalar::Uint8: + *data = JS_GetUint8ArrayData(jsobj); + break; + + case js::Scalar::Int16: + case js::Scalar::Uint16: + *data = JS_GetUint16ArrayData(jsobj); + break; + + case js::Scalar::Int32: + case js::Scalar::Uint32: + *data = JS_GetUint32ArrayData(jsobj); + break; + + case js::Scalar::Float32: + *data = JS_GetFloat32ArrayData(jsobj); + break; + + default: + JSB_PRECONDITION2(false, cx, false, "Unsupported typedarray type"); + break; + } + } else if( JS_IsArrayObject(cx, jsobj)) { + // Slow... avoid it. Use TypedArray instead, but the spec says that it can receive + // Sequence<> as well. + uint32_t length; + JS_GetArrayLength(cx, jsobj, &length); + + for( uint32_t i=0; ix = (float)x; + ret->y = (float)y; + return true; +} + +bool jsval_to_ccacceleration(JSContext* cx, JS::HandleValue v, Acceleration* ret) { + JS::RootedObject tmp(cx); + JS::RootedValue jsx(cx); + JS::RootedValue jsy(cx); + JS::RootedValue jsz(cx); + JS::RootedValue jstimestamp(cx); + + double x, y, timestamp, z; + bool ok = v.isObject() && + JS_ValueToObject(cx, v, &tmp) && + JS_GetProperty(cx, tmp, "x", &jsx) && + JS_GetProperty(cx, tmp, "y", &jsy) && + JS_GetProperty(cx, tmp, "z", &jsz) && + JS_GetProperty(cx, tmp, "timestamp", &jstimestamp) && + JS::ToNumber(cx, jsx, &x) && + JS::ToNumber(cx, jsy, &y) && + JS::ToNumber(cx, jsz, &z) && + JS::ToNumber(cx, jstimestamp, ×tamp); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + ret->x = x; + ret->y = y; + ret->z = z; + ret->timestamp = timestamp; + return true; +} + +bool jsval_to_quaternion( JSContext *cx, JS::HandleValue v, cocos2d::Quaternion* ret) +{ + JS::RootedObject tmp(cx); + JS::RootedValue x(cx); + JS::RootedValue y(cx); + JS::RootedValue z(cx); + JS::RootedValue w(cx); + + double xx, yy, zz, ww; + bool ok = v.isObject() && + JS_ValueToObject(cx, v, &tmp) && + JS_GetProperty(cx, tmp, "x", &x) && + JS_GetProperty(cx, tmp, "y", &y) && + JS_GetProperty(cx, tmp, "z", &z) && + JS_GetProperty(cx, tmp, "w", &w) && + JS::ToNumber(cx, x, &xx) && + JS::ToNumber(cx, y, &yy) && + JS::ToNumber(cx, z, &zz) && + JS::ToNumber(cx, w, &ww) && + !isnan(xx) && !isnan(yy) && !isnan(zz) && !isnan(ww); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + ret->set(xx, yy, zz, ww); + + return true; +} + +bool jsval_to_obb(JSContext *cx, JS::HandleValue v, cocos2d::OBB* ret) +{ + JS::RootedObject tmp(cx); + JS::RootedValue jscenter(cx); + JS::RootedValue jsxAxis(cx); + JS::RootedValue jsyAxis(cx); + JS::RootedValue jszAxis(cx); + JS::RootedValue jsextents(cx); + JS::RootedValue jsextentx(cx); + JS::RootedValue jsextenty(cx); + JS::RootedValue jsextentz(cx); + + cocos2d::Vec3 center, xAxis, yAxis, zAxis, extents, extentx, extenty, extentz; + bool ok = v.isObject() && + JS_ValueToObject(cx, v, &tmp) && + JS_GetProperty(cx, tmp, "center", &jscenter) && + JS_GetProperty(cx, tmp, "xAxis", &jsxAxis) && + JS_GetProperty(cx, tmp, "yAxis", &jsyAxis) && + JS_GetProperty(cx, tmp, "zAxis", &jszAxis) && + JS_GetProperty(cx, tmp, "extents", &jsextents) && + JS_GetProperty(cx, tmp, "extentX", &jsextentx) && + JS_GetProperty(cx, tmp, "extentY", &jsextenty) && + JS_GetProperty(cx, tmp, "extentZ", &jsextentz) && + jsval_to_vector3(cx, jscenter, ¢er) && + jsval_to_vector3(cx, jsxAxis, &xAxis) && + jsval_to_vector3(cx, jsyAxis, &yAxis) && + jsval_to_vector3(cx, jszAxis, &zAxis) && + jsval_to_vector3(cx, jsextents, &extents) && + jsval_to_vector3(cx, jsextentx, &extentx) && + jsval_to_vector3(cx, jsextenty, &extenty) && + jsval_to_vector3(cx, jsextentz, &extentz); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + ret->_center.set(center); + ret->_xAxis.set(xAxis); + ret->_yAxis.set(yAxis); + ret->_zAxis.set(zAxis); + ret->_extents.set(extents); + ret->_extentX.set(extentx); + ret->_extentY.set(extenty); + ret->_extentZ.set(extentz); + return true; +} + +bool jsval_to_ray(JSContext *cx, JS::HandleValue v, cocos2d::Ray* ret) +{ + JS::RootedObject tmp(cx); + JS::RootedValue jsorigin(cx); + JS::RootedValue jsdirection(cx); + + cocos2d::Vec3 origin, direction; + bool ok = v.isObject() && + JS_ValueToObject(cx, v, &tmp) && + JS_GetProperty(cx, tmp, "origin", &jsorigin) && + JS_GetProperty(cx, tmp, "direction", &jsdirection) && + jsval_to_vector3(cx, jsorigin, &origin) && + jsval_to_vector3(cx, jsdirection, &direction); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + ret->set(origin, direction); + return true; +} + +bool jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc, __Array** ret) +{ + bool ok = true; + __Array* pArray = Array::create(); + for( int i=0; i < argc; i++ ) + { + double num = 0.0; + // optimization: JS::ToNumber is expensive. And can convert an string like "12" to a number + if (vp->isNumber()) { + ok &= JS::ToNumber(cx, JS::RootedValue(cx, *vp), &num ); + if (!ok) { + break; + } + pArray->addObject(Integer::create((int)num)); + } + else if (vp->isString()) + { + JSStringWrapper str(vp->toString(), cx); + pArray->addObject(String::create(str.get())); + } + else + { + js_proxy_t* p; + JSObject* obj = vp->toObjectOrNull(); + p = jsb_get_js_proxy(obj); + if (p) { + pArray->addObject((Ref*)p->ptr); + } + } + // next + vp++; + } + *ret = pArray; + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + return ok; +} + +bool jsvals_variadic_to_ccvaluevector( JSContext *cx, jsval *vp, int argc, cocos2d::ValueVector* ret) +{ + JS::RootedValue value(cx); + for (int i = 0; i < argc; i++) + { + value = *vp; + if (value.isObject()) + { + JS::RootedObject jsobj(cx, value.toObjectOrNull()); + CCASSERT(jsb_get_js_proxy(jsobj) == nullptr, "Native object should be added!"); + + if (!JS_IsArrayObject(cx, jsobj)) + { + // It's a normal js object. + ValueMap dictVal; + bool ok = jsval_to_ccvaluemap(cx, value, &dictVal); + if (ok) + { + ret->push_back(Value(dictVal)); + } + } + else { + // It's a js array object. + ValueVector arrVal; + bool ok = jsval_to_ccvaluevector(cx, value, &arrVal); + if (ok) + { + ret->push_back(Value(arrVal)); + } + } + } + else if (value.isString()) + { + JSStringWrapper valueWapper(value.toString(), cx); + ret->push_back(Value(valueWapper.get())); + } + else if (value.isNumber()) + { + double number = 0.0; + bool ok = JS::ToNumber(cx, value, &number); + if (ok) + { + ret->push_back(Value(number)); + } + } + else if (value.isBoolean()) + { + bool boolVal = JS::ToBoolean(value); + ret->push_back(Value(boolVal)); + } + else + { + CCASSERT(false, "not supported type"); + } + // next + vp++; + } + + return true; +} + +bool jsval_to_ccrect(JSContext *cx, JS::HandleValue v, Rect* ret) { + JS::RootedObject tmp(cx); + JS::RootedValue jsx(cx); + JS::RootedValue jsy(cx); + JS::RootedValue jswidth(cx); + JS::RootedValue jsheight(cx); + + double x, y, width, height; + bool ok = v.isObject() && + JS_ValueToObject(cx, v, &tmp) && + JS_GetProperty(cx, tmp, "x", &jsx) && + JS_GetProperty(cx, tmp, "y", &jsy) && + JS_GetProperty(cx, tmp, "width", &jswidth) && + JS_GetProperty(cx, tmp, "height", &jsheight) && + JS::ToNumber(cx, jsx, &x) && + JS::ToNumber(cx, jsy, &y) && + JS::ToNumber(cx, jswidth, &width) && + JS::ToNumber(cx, jsheight, &height); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + ret->origin.x = x; + ret->origin.y = y; + ret->size.width = width; + ret->size.height = height; + return true; +} + +bool jsval_to_ccsize(JSContext *cx, JS::HandleValue v, Size* ret) { + JS::RootedObject tmp(cx); + JS::RootedValue jsw(cx); + JS::RootedValue jsh(cx); + double w, h; + bool ok = v.isObject() && + JS_ValueToObject(cx, v, &tmp) && + JS_GetProperty(cx, tmp, "width", &jsw) && + JS_GetProperty(cx, tmp, "height", &jsh) && + JS::ToNumber(cx, jsw, &w) && + JS::ToNumber(cx, jsh, &h); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + ret->width = w; + ret->height = h; + return true; +} + +bool jsval_to_cccolor4b(JSContext *cx, JS::HandleValue v, Color4B* ret) { + JS::RootedObject tmp(cx); + JS::RootedValue jsr(cx); + JS::RootedValue jsg(cx); + JS::RootedValue jsb(cx); + JS::RootedValue jsa(cx); + + double r, g, b, a; + bool ok = v.isObject() && + JS_ValueToObject(cx, v, &tmp) && + JS_GetProperty(cx, tmp, "r", &jsr) && + JS_GetProperty(cx, tmp, "g", &jsg) && + JS_GetProperty(cx, tmp, "b", &jsb) && + JS_GetProperty(cx, tmp, "a", &jsa) && + JS::ToNumber(cx, jsr, &r) && + JS::ToNumber(cx, jsg, &g) && + JS::ToNumber(cx, jsb, &b) && + JS::ToNumber(cx, jsa, &a); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + ret->r = (GLubyte)r; + ret->g = (GLubyte)g; + ret->b = (GLubyte)b; + ret->a = (GLubyte)a; + return true; +} + +bool jsval_to_cccolor4f(JSContext *cx, JS::HandleValue v, Color4F* ret) { + JS::RootedObject tmp(cx); + JS::RootedValue jsr(cx); + JS::RootedValue jsg(cx); + JS::RootedValue jsb(cx); + JS::RootedValue jsa(cx); + double r, g, b, a; + bool ok = v.isObject() && + JS_ValueToObject(cx, v, &tmp) && + JS_GetProperty(cx, tmp, "r", &jsr) && + JS_GetProperty(cx, tmp, "g", &jsg) && + JS_GetProperty(cx, tmp, "b", &jsb) && + JS_GetProperty(cx, tmp, "a", &jsa) && + JS::ToNumber(cx, jsr, &r) && + JS::ToNumber(cx, jsg, &g) && + JS::ToNumber(cx, jsb, &b) && + JS::ToNumber(cx, jsa, &a); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + ret->r = (float)r / 255; + ret->g = (float)g / 255; + ret->b = (float)b / 255; + ret->a = (float)a / 255; + return true; +} + +bool jsval_to_cccolor3b(JSContext *cx, JS::HandleValue v, Color3B* ret) { + JS::RootedObject tmp(cx); + JS::RootedValue jsr(cx); + JS::RootedValue jsg(cx); + JS::RootedValue jsb(cx); + double r, g, b; + bool ok = v.isObject() && + JS_ValueToObject(cx, v, &tmp) && + JS_GetProperty(cx, tmp, "r", &jsr) && + JS_GetProperty(cx, tmp, "g", &jsg) && + JS_GetProperty(cx, tmp, "b", &jsb) && + JS::ToNumber(cx, jsr, &r) && + JS::ToNumber(cx, jsg, &g) && + JS::ToNumber(cx, jsb, &b); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + ret->r = (GLubyte)r; + ret->g = (GLubyte)g; + ret->b = (GLubyte)b; + return true; +} + +bool jsval_cccolor_to_opacity(JSContext *cx, JS::HandleValue v, int32_t* ret) { + JS::RootedObject tmp(cx); + JS::RootedValue jsa(cx); + + double a; + bool ok = v.isObject() && + JS_ValueToObject(cx, v, &tmp) && + JS_LookupProperty(cx, tmp, "a", &jsa) && + !jsa.isUndefined() && + JS::ToNumber(cx, jsa, &a); + + if (ok) { + *ret = (int32_t)a; + return true; + } + else return false; +} + +bool jsval_to_ccarray_of_CCPoint(JSContext* cx, JS::HandleValue v, Point **points, int *numPoints) { + // Parsing sequence + JS::RootedObject jsobj(cx); + bool ok = v.isObject() && JS_ValueToObject( cx, v, &jsobj ); + JSB_PRECONDITION3( ok, cx, false, "Error converting value to object"); + JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, false, "Object must be an array"); + + uint32_t len; + JS_GetArrayLength(cx, jsobj, &len); + + Point *array = new Point[len]; + + for( uint32_t i=0; i< len;i++ ) { + JS::RootedValue valarg(cx); + JS_GetElement(cx, jsobj, i, &valarg); + + ok = jsval_to_ccpoint(cx, valarg, &array[i]); + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + } + + *numPoints = len; + *points = array; + + return true; +} + + +bool jsval_to_ccarray(JSContext* cx, JS::HandleValue v, __Array** ret) +{ + JS::RootedObject jsobj(cx); + bool ok = v.isObject() && JS_ValueToObject( cx, v, &jsobj ); + JSB_PRECONDITION3( ok, cx, false, "Error converting value to object"); + JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, false, "Object must be an array"); + + uint32_t len = 0; + JS_GetArrayLength(cx, jsobj, &len); + __Array* arr = __Array::createWithCapacity(len); + for (uint32_t i=0; i < len; i++) { + JS::RootedValue value(cx); + if (JS_GetElement(cx, jsobj, i, &value)) { + if (value.isObject()) + { + js_proxy_t *proxy; + JS::RootedObject tmp(cx, value.toObjectOrNull()); + proxy = jsb_get_js_proxy(tmp); + cocos2d::Ref* cobj = (cocos2d::Ref *)(proxy ? proxy->ptr : NULL); + // Don't test it. + //TEST_NATIVE_OBJECT(cx, cobj) + if (cobj) { + // It's a native js object. + arr->addObject(cobj); + } + else if (!JS_IsArrayObject(cx, tmp)){ + // It's a normal js object. + __Dictionary* dictVal = NULL; + ok = jsval_to_ccdictionary(cx, value, &dictVal); + if (ok) { + arr->addObject(dictVal); + } + } + else { + // It's a js array object. + __Array* arrVal = NULL; + ok = jsval_to_ccarray(cx, value, &arrVal); + if (ok) { + arr->addObject(arrVal); + } + } + } + else if (value.isString()) { + JSStringWrapper valueWapper(value.toString(), cx); + arr->addObject(String::create(valueWapper.get())); + // CCLOG("iterate array: value = %s", valueWapper.get().c_str()); + } + else if (value.isNumber()) { + double number = 0.0; + ok = JS::ToNumber(cx, value, &number); + if (ok) { + arr->addObject(Double::create(number)); + // CCLOG("iterate array: value = %lf", number); + } + } + else if (value.isBoolean()) { + bool boolVal = JS::ToBoolean(value); + arr->addObject(Bool::create(boolVal)); + // CCLOG("iterate object: value = %d", boolVal); + } + else { + CCASSERT(false, "not supported type"); + } + } + } + *ret = arr; + return true; +} + +bool jsval_to_ccvalue(JSContext* cx, JS::HandleValue v, cocos2d::Value* ret) +{ + if (v.isObject()) + { + JS::RootedObject jsobj(cx, v.toObjectOrNull()); + CCASSERT(jsb_get_js_proxy(jsobj) == nullptr, "Native object should be added!"); + if (!JS_IsArrayObject(cx, jsobj)) + { + // It's a normal js object. + ValueMap dictVal; + bool ok = jsval_to_ccvaluemap(cx, v, &dictVal); + if (ok) + { + *ret = Value(dictVal); + } + } + else { + // It's a js array object. + ValueVector arrVal; + bool ok = jsval_to_ccvaluevector(cx, v, &arrVal); + if (ok) + { + *ret = Value(arrVal); + } + } + } + else if (v.isString()) + { + JSStringWrapper valueWapper(v.toString(), cx); + *ret = Value(valueWapper.get()); + } + else if (v.isNumber()) + { + double number = 0.0; + bool ok = JS::ToNumber(cx, v, &number); + if (ok) { + *ret = Value(number); + } + } + else if (v.isBoolean()) + { + bool boolVal = JS::ToBoolean(v); + *ret = Value(boolVal); + } + else { + CCASSERT(false, "not supported type"); + } + + return true; +} + +bool jsval_to_ccvaluemap(JSContext* cx, JS::HandleValue v, cocos2d::ValueMap* ret) +{ + if (v.isNullOrUndefined()) + { + return true; + } + + JS::RootedObject tmp(cx, v.toObjectOrNull()); + if (!tmp) { + CCLOG("%s", "jsval_to_ccvaluemap: the jsval is not an object."); + return false; + } + + JS::RootedObject it(cx, JS_NewPropertyIterator(cx, tmp)); + + ValueMap& dict = *ret; + + while (true) + { + JS::RootedId idp(cx); + JS::RootedValue key(cx); + if (! JS_NextProperty(cx, it, idp.address()) || ! JS_IdToValue(cx, idp, &key)) { + return false; // error + } + + if (key.isNullOrUndefined()) { + break; // end of iteration + } + + if (!key.isString()) { + continue; // ignore integer properties + } + + JSStringWrapper keyWrapper(key.toString(), cx); + + JS::RootedValue value(cx); + JS_GetPropertyById(cx, tmp, idp, &value); + if (value.isObject()) + { + JS::RootedObject jsobj(cx, value.toObjectOrNull()); + CCASSERT(jsb_get_js_proxy(jsobj) == nullptr, "Native object should be added!"); + if (!JS_IsArrayObject(cx, jsobj)) + { + // It's a normal js object. + ValueMap dictVal; + bool ok = jsval_to_ccvaluemap(cx, value, &dictVal); + if (ok) + { + dict.insert(ValueMap::value_type(keyWrapper.get(), Value(dictVal))); + } + } + else { + // It's a js array object. + ValueVector arrVal; + bool ok = jsval_to_ccvaluevector(cx, value, &arrVal); + if (ok) + { + dict.insert(ValueMap::value_type(keyWrapper.get(), Value(arrVal))); + } + } + } + else if (value.isString()) + { + JSStringWrapper valueWapper(value.toString(), cx); + dict.insert(ValueMap::value_type(keyWrapper.get(), Value(valueWapper.get()))); + // CCLOG("iterate object: key = %s, value = %s", keyWrapper.get().c_str(), valueWapper.get().c_str()); + } + else if (value.isNumber()) + { + double number = 0.0; + bool ok = JS::ToNumber(cx, value, &number); + if (ok) { + dict.insert(ValueMap::value_type(keyWrapper.get(), Value(number))); + // CCLOG("iterate object: key = %s, value = %lf", keyWrapper.get().c_str(), number); + } + } + else if (value.isBoolean()) + { + bool boolVal = JS::ToBoolean(value); + dict.insert(ValueMap::value_type(keyWrapper.get(), Value(boolVal))); + // CCLOG("iterate object: key = %s, value = %d", keyWrapper.get().c_str(), boolVal); + } + else { + CCASSERT(false, "not supported type"); + } + } + + return true; +} + +bool jsval_to_ccvaluemapintkey(JSContext* cx, JS::HandleValue v, cocos2d::ValueMapIntKey* ret) +{ + if (v.isNullOrUndefined()) + { + return true; + } + + JS::RootedObject tmp(cx, v.toObjectOrNull()); + if (!tmp) { + CCLOG("%s", "jsval_to_ccvaluemap: the jsval is not an object."); + return false; + } + + JS::RootedObject it(cx, JS_NewPropertyIterator(cx, tmp)); + + ValueMapIntKey& dict = *ret; + + while (true) + { + JS::RootedId idp(cx); + JS::RootedValue key(cx); + if (! JS_NextProperty(cx, it, idp.address()) || ! JS_IdToValue(cx, idp, &key)) { + return false; // error + } + + if (key.isNullOrUndefined()) { + break; // end of iteration + } + + if (!key.isString()) { + continue; // ignore integer properties + } + + int keyVal = key.toInt32(); + + JS::RootedValue value(cx); + JS_GetPropertyById(cx, tmp, idp, &value); + if (value.isObject()) + { + JS::RootedObject jsobj(cx, value.toObjectOrNull()); + CCASSERT(jsb_get_js_proxy(jsobj) == nullptr, "Native object should be added!"); + if (!JS_IsArrayObject(cx, jsobj)) + { + // It's a normal js object. + ValueMap dictVal; + bool ok = jsval_to_ccvaluemap(cx, value, &dictVal); + if (ok) + { + dict.insert(ValueMapIntKey::value_type(keyVal, Value(dictVal))); + } + } + else { + // It's a js array object. + ValueVector arrVal; + bool ok = jsval_to_ccvaluevector(cx, value, &arrVal); + if (ok) + { + dict.insert(ValueMapIntKey::value_type(keyVal, Value(arrVal))); + } + } + } + else if (value.isString()) + { + JSStringWrapper valueWapper(value.toString(), cx); + dict.insert(ValueMapIntKey::value_type(keyVal, Value(valueWapper.get()))); + } + else if (value.isNumber()) + { + double number = 0.0; + bool ok = JS::ToNumber(cx, value, &number); + if (ok) { + dict.insert(ValueMapIntKey::value_type(keyVal, Value(number))); + } + } + else if (value.isBoolean()) + { + bool boolVal = JS::ToBoolean(value); + dict.insert(ValueMapIntKey::value_type(keyVal, Value(boolVal))); + } + else { + CCASSERT(false, "not supported type"); + } + } + + return true; +} + +bool jsval_to_ccvaluevector(JSContext* cx, JS::HandleValue v, cocos2d::ValueVector* ret) +{ + JS::RootedObject jsArr(cx); + bool ok = v.isObject() && JS_ValueToObject( cx, v, &jsArr ); + JSB_PRECONDITION3( ok, cx, false, "Error converting value to object"); + JSB_PRECONDITION3( jsArr && JS_IsArrayObject( cx, jsArr), cx, false, "Object must be an array"); + + uint32_t len = 0; + JS_GetArrayLength(cx, jsArr, &len); + + for (uint32_t i=0; i < len; i++) + { + JS::RootedValue value(cx); + if (JS_GetElement(cx, jsArr, i, &value)) + { + if (value.isObject()) + { + JS::RootedObject jsobj(cx, value.toObjectOrNull()); + CCASSERT(jsb_get_js_proxy(jsobj) == nullptr, "Native object should be added!"); + + if (!JS_IsArrayObject(cx, jsobj)) + { + // It's a normal js object. + ValueMap dictVal; + ok = jsval_to_ccvaluemap(cx, value, &dictVal); + if (ok) + { + ret->push_back(Value(dictVal)); + } + } + else { + // It's a js array object. + ValueVector arrVal; + ok = jsval_to_ccvaluevector(cx, value, &arrVal); + if (ok) + { + ret->push_back(Value(arrVal)); + } + } + } + else if (value.isString()) + { + JSStringWrapper valueWapper(value.toString(), cx); + ret->push_back(Value(valueWapper.get())); + } + else if (value.isNumber()) + { + double number = 0.0; + ok = JS::ToNumber(cx, value, &number); + if (ok) + { + ret->push_back(Value(number)); + } + } + else if (value.isBoolean()) + { + bool boolVal = JS::ToBoolean(value); + ret->push_back(Value(boolVal)); + } + else + { + CCASSERT(false, "not supported type"); + } + } + } + + return true; +} + +bool jsval_to_ssize( JSContext *cx, JS::HandleValue vp, ssize_t* size) +{ + bool ret = false; + int32_t sizeInt32 = 0; + ret = jsval_to_int32(cx, vp, &sizeInt32); + *size = sizeInt32; + return ret; +} + +bool jsval_to_std_vector_string( JSContext *cx, JS::HandleValue vp, std::vector* ret) +{ + JS::RootedObject jsobj(cx); + bool ok = vp.isObject() && JS_ValueToObject( cx, vp, &jsobj ); + JSB_PRECONDITION3( ok, cx, false, "Error converting value to object"); + JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, false, "Object must be an array"); + + uint32_t len = 0; + JS_GetArrayLength(cx, jsobj, &len); + + for (uint32_t i=0; i < len; i++) + { + JS::RootedValue value(cx); + if (JS_GetElement(cx, jsobj, i, &value)) + { + if (value.isString()) + { + JSStringWrapper valueWapper(value.toString(), cx); + ret->push_back(valueWapper.get()); + } + else + { + JS_ReportError(cx, "not supported type in array"); + return false; + } + } + } + + return true; +} + +bool jsval_to_std_vector_int( JSContext *cx, JS::HandleValue vp, std::vector* ret) +{ + JS::RootedObject jsobj(cx); + bool ok = vp.isObject() && JS_ValueToObject( cx, vp, &jsobj ); + JSB_PRECONDITION3( ok, cx, false, "Error converting value to object"); + JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, false, "Object must be an array"); + + uint32_t len = 0; + JS_GetArrayLength(cx, jsobj, &len); + + for (uint32_t i=0; i < len; i++) + { + JS::RootedValue value(cx); + if (JS_GetElement(cx, jsobj, i, &value)) + { + if (value.isNumber()) + { + double number = 0.0; + ok = JS::ToNumber(cx, value, &number); + if (ok) + { + ret->push_back(static_cast(number)); + } + } + else + { + JS_ReportError(cx, "not supported type in array"); + return false; + } + } + } + + return true; +} + +bool jsval_to_matrix(JSContext *cx, JS::HandleValue vp, cocos2d::Mat4* ret) +{ + JS::RootedObject jsobj(cx); + bool ok = vp.isObject() && JS_ValueToObject( cx, vp, &jsobj ); + JSB_PRECONDITION3( ok, cx, false, "Error converting value to object"); + JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, false, "Object must be an matrix"); + + uint32_t len = 0; + JS_GetArrayLength(cx, jsobj, &len); + + if (len != 16) + { + JS_ReportError(cx, "array length error: %d, was expecting 16", len); + } + + for (uint32_t i=0; i < len; i++) + { + JS::RootedValue value(cx); + if (JS_GetElement(cx, jsobj, i, &value)) + { + if (value.isNumber()) + { + double number = 0.0; + ok = JS::ToNumber(cx, value, &number); + if (ok) + { + ret->m[i] = static_cast(number); + } + } + else + { + JS_ReportError(cx, "not supported type in matrix"); + return false; + } + } + } + + return true; +} + +bool jsval_to_vector2(JSContext *cx, JS::HandleValue vp, cocos2d::Vec2* ret) +{ + JS::RootedObject tmp(cx); + JS::RootedValue jsx(cx); + JS::RootedValue jsy(cx); + double x, y; + bool ok = vp.isObject() && + JS_ValueToObject(cx, vp, &tmp) && + JS_GetProperty(cx, tmp, "x", &jsx) && + JS_GetProperty(cx, tmp, "y", &jsy) && + JS::ToNumber(cx, jsx, &x) && + JS::ToNumber(cx, jsy, &y); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + ret->x = (float)x; + ret->y = (float)y; + return true; +} + +bool jsval_to_vector3(JSContext *cx, JS::HandleValue vp, cocos2d::Vec3* ret) +{ + JS::RootedObject tmp(cx); + JS::RootedValue jsx(cx); + JS::RootedValue jsy(cx); + JS::RootedValue jsz(cx); + double x, y, z; + bool ok = vp.isObject() && + JS_ValueToObject(cx, vp, &tmp) && + JS_GetProperty(cx, tmp, "x", &jsx) && + JS_GetProperty(cx, tmp, "y", &jsy) && + JS_GetProperty(cx, tmp, "z", &jsz) && + JS::ToNumber(cx, jsx, &x) && + JS::ToNumber(cx, jsy, &y) && + JS::ToNumber(cx, jsz, &z) && + !isnan(x) && !isnan(y) && !isnan(z); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + ret->x = (float)x; + ret->y = (float)y; + ret->z = (float)z; + return true; +} + +bool jsval_to_vector4(JSContext *cx, JS::HandleValue vp, cocos2d::Vec4* ret) +{ + JS::RootedObject tmp(cx); + JS::RootedValue jsx(cx); + JS::RootedValue jsy(cx); + JS::RootedValue jsz(cx); + JS::RootedValue jsw(cx); + double x, y, z, w; + bool ok = vp.isObject() && + JS_ValueToObject(cx, vp, &tmp) && + JS_GetProperty(cx, tmp, "x", &jsx) && + JS_GetProperty(cx, tmp, "y", &jsy) && + JS_GetProperty(cx, tmp, "z", &jsz) && + JS_GetProperty(cx, tmp, "w", &jsw) && + JS::ToNumber(cx, jsx, &x) && + JS::ToNumber(cx, jsy, &y) && + JS::ToNumber(cx, jsz, &z) && + JS::ToNumber(cx, jsw, &w) && + !isnan(x) && !isnan(y) && !isnan(z) && !isnan(w); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + ret->x = (float)x; + ret->y = (float)y; + ret->z = (float)z; + ret->w = (float)w; + return true; +} + +bool jsval_to_blendfunc(JSContext *cx, JS::HandleValue vp, cocos2d::BlendFunc* ret) +{ + JS::RootedObject tmp(cx); + JS::RootedValue jssrc(cx); + JS::RootedValue jsdst(cx); + double src, dst; + bool ok = vp.isObject() && + JS_ValueToObject(cx, vp, &tmp) && + JS_GetProperty(cx, tmp, "src", &jssrc) && + JS_GetProperty(cx, tmp, "dst", &jsdst) && + JS::ToNumber(cx, jssrc, &src) && + JS::ToNumber(cx, jsdst, &dst); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + ret->src = (unsigned int)src; + ret->dst = (unsigned int)dst; + return true; + return true; +} + +// native --> jsval + +jsval ccarray_to_jsval(JSContext* cx, __Array *arr) +{ + JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, 0)); + + Ref* obj; + int i = 0; + CCARRAY_FOREACH(arr, obj) + { + JS::RootedValue arrElement(cx); + + //First, check whether object is associated with js object. + js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); + if (jsproxy) { + arrElement = OBJECT_TO_JSVAL(jsproxy->obj); + } + else { + __String* strVal = NULL; + __Dictionary* dictVal = NULL; + __Array* arrVal = NULL; + __Double* doubleVal = NULL; + __Bool* boolVal = NULL; + __Float* floatVal = NULL; + __Integer* intVal = NULL; + + if ((strVal = dynamic_cast(obj))) { + arrElement = c_string_to_jsval(cx, strVal->getCString()); + } else if ((dictVal = dynamic_cast(obj))) { + arrElement = ccdictionary_to_jsval(cx, dictVal); + } else if ((arrVal = dynamic_cast(obj))) { + arrElement = ccarray_to_jsval(cx, arrVal); + } else if ((doubleVal = dynamic_cast<__Double*>(obj))) { + arrElement = DOUBLE_TO_JSVAL(doubleVal->getValue()); + } else if ((floatVal = dynamic_cast<__Float*>(obj))) { + arrElement = DOUBLE_TO_JSVAL(floatVal->getValue()); + } else if ((intVal = dynamic_cast<__Integer*>(obj))) { + arrElement = INT_TO_JSVAL(intVal->getValue()); + } else if ((boolVal = dynamic_cast<__Bool*>(obj))) { + arrElement = BOOLEAN_TO_JSVAL(boolVal->getValue() ? true : false); + } else { + CCASSERT(false, "the type isn't suppored."); + } + } + if (!JS_SetElement(cx, jsretArr, i, arrElement)) { + break; + } + ++i; + } + return OBJECT_TO_JSVAL(jsretArr); +} + +jsval ccdictionary_to_jsval(JSContext* cx, __Dictionary* dict) +{ + + JS::RootedObject proto(cx); + JS::RootedObject parent(cx); + JS::RootedObject jsRet(cx, JS_NewObject(cx, NULL, proto, parent)); + DictElement* pElement = NULL; + CCDICT_FOREACH(dict, pElement) + { + JS::RootedValue dictElement(cx); + Ref* obj = pElement->getObject(); + //First, check whether object is associated with js object. + js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); + if (jsproxy) { + dictElement = OBJECT_TO_JSVAL(jsproxy->obj); + } + else { + __String* strVal = NULL; + __Dictionary* dictVal = NULL; + __Array* arrVal = NULL; + __Double* doubleVal = NULL; + __Bool* boolVal = NULL; + __Float* floatVal = NULL; + __Integer* intVal = NULL; + + if ((strVal = dynamic_cast(obj))) { + dictElement = c_string_to_jsval(cx, strVal->getCString()); + } else if ((dictVal = dynamic_cast<__Dictionary*>(obj))) { + dictElement = ccdictionary_to_jsval(cx, dictVal); + } else if ((arrVal = dynamic_cast<__Array*>(obj))) { + dictElement = ccarray_to_jsval(cx, arrVal); + } else if ((doubleVal = dynamic_cast<__Double*>(obj))) { + dictElement = DOUBLE_TO_JSVAL(doubleVal->getValue()); + } else if ((floatVal = dynamic_cast<__Float*>(obj))) { + dictElement = DOUBLE_TO_JSVAL(floatVal->getValue()); + } else if ((intVal = dynamic_cast<__Integer*>(obj))) { + dictElement = INT_TO_JSVAL(intVal->getValue()); + } else if ((boolVal = dynamic_cast<__Bool*>(obj))) { + dictElement = BOOLEAN_TO_JSVAL(boolVal->getValue() ? true : false); + } else { + CCASSERT(false, "the type isn't suppored."); + } + } + const char* key = pElement->getStrKey(); + if (key && strlen(key) > 0) + { + JS_SetProperty(cx, jsRet, key, dictElement); + } + } + return OBJECT_TO_JSVAL(jsRet); +} + +bool jsval_to_ccdictionary(JSContext* cx, JS::HandleValue v, __Dictionary** ret) +{ + if (v.isNullOrUndefined()) + { + *ret = NULL; + return true; + } + + JS::RootedObject tmp(cx, v.toObjectOrNull()); + if (!tmp) { + CCLOG("%s", "jsval_to_ccdictionary: the jsval is not an object."); + return false; + } + + JS::RootedObject it(cx, JS_NewPropertyIterator(cx, tmp)); + __Dictionary* dict = NULL; + + while (true) + { + JS::RootedId idp(cx); + JS::RootedValue key(cx); + if (! JS_NextProperty(cx, it, idp.address()) || ! JS_IdToValue(cx, idp, &key)) { + return false; // error + } + + if (key.isNullOrUndefined()) { + break; // end of iteration + } + + if (!key.isString()) { + continue; // ignore integer properties + } + + JSStringWrapper keyWrapper(key.toString(), cx); + if (!dict) { + dict = __Dictionary::create(); + } + + JS::RootedValue value(cx); + JS_GetPropertyById(cx, tmp, idp, &value); + if (value.isObject()) + { + js_proxy_t *proxy; + tmp = value.toObjectOrNull(); + proxy = jsb_get_js_proxy(tmp); + cocos2d::Ref* cobj = (cocos2d::Ref *)(proxy ? proxy->ptr : NULL); + // Don't test it. + //TEST_NATIVE_OBJECT(cx, cobj) + if (cobj) { + // It's a native <-> js glue object. + dict->setObject(cobj, keyWrapper.get()); + } + else if (!JS_IsArrayObject(cx, tmp)){ + // It's a normal js object. + __Dictionary* dictVal = NULL; + bool ok = jsval_to_ccdictionary(cx, value, &dictVal); + if (ok) { + dict->setObject(dictVal, keyWrapper.get()); + } + } + else { + // It's a js array object. + __Array* arrVal = NULL; + bool ok = jsval_to_ccarray(cx, value, &arrVal); + if (ok) { + dict->setObject(arrVal, keyWrapper.get()); + } + } + } + else if (value.isString()) { + JSStringWrapper valueWapper(value.toString(), cx); + dict->setObject(String::create(valueWapper.get()), keyWrapper.get()); + // CCLOG("iterate object: key = %s, value = %s", keyWrapper.get().c_str(), valueWapper.get().c_str()); + } + else if (value.isNumber()) { + double number = 0.0; + bool ok = JS::ToNumber(cx, value, &number); + if (ok) { + dict->setObject(Double::create(number), keyWrapper.get()); + // CCLOG("iterate object: key = %s, value = %lf", keyWrapper.get().c_str(), number); + } + } + else if (value.isBoolean()) { + bool boolVal = JS::ToBoolean(value); + dict->setObject(Bool::create(boolVal), keyWrapper.get()); + // CCLOG("iterate object: key = %s, value = %d", keyWrapper.get().c_str(), boolVal); + } + else { + CCASSERT(false, "not supported type"); + } + } + + *ret = dict; + return true; +} + +bool jsval_to_ccaffinetransform(JSContext* cx, JS::HandleValue v, AffineTransform* ret) +{ + JS::RootedObject tmp(cx); + JS::RootedValue jsa(cx); + JS::RootedValue jsb(cx); + JS::RootedValue jsc(cx); + JS::RootedValue jsd(cx); + JS::RootedValue jstx(cx); + JS::RootedValue jsty(cx); + double a, b, c, d, tx, ty; + bool ok = JS_ValueToObject(cx, v, &tmp) && + JS_GetProperty(cx, tmp, "a", &jsa) && + JS_GetProperty(cx, tmp, "b", &jsb) && + JS_GetProperty(cx, tmp, "c", &jsc) && + JS_GetProperty(cx, tmp, "d", &jsd) && + JS_GetProperty(cx, tmp, "tx", &jstx) && + JS_GetProperty(cx, tmp, "ty", &jsty) && + JS::ToNumber(cx, jsa, &a) && + JS::ToNumber(cx, jsb, &b) && + JS::ToNumber(cx, jsc, &c) && + JS::ToNumber(cx, jsd, &d) && + JS::ToNumber(cx, jstx, &tx) && + JS::ToNumber(cx, jsty, &ty); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + *ret = AffineTransformMake(a, b, c, d, tx, ty); + return true; +} + +// From native type to jsval +jsval int32_to_jsval( JSContext *cx, int32_t number ) +{ + return INT_TO_JSVAL(number); +} + +jsval uint32_to_jsval( JSContext *cx, uint32_t number ) +{ + return UINT_TO_JSVAL(number); +} + +jsval ushort_to_jsval( JSContext *cx, unsigned short number ) +{ + return UINT_TO_JSVAL(number); +} + +jsval std_string_to_jsval(JSContext* cx, const std::string& v) +{ + return c_string_to_jsval(cx, v.c_str(), v.size()); +} + +jsval c_string_to_jsval(JSContext* cx, const char* v, size_t length /* = -1 */) +{ + if (v == NULL) + { + return JSVAL_NULL; + } + if (length == -1) + { + length = strlen(v); + } + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + if (0 == length) + { + auto emptyStr = JS_NewStringCopyZ(cx, ""); + return STRING_TO_JSVAL(emptyStr); + } + + jsval ret = JSVAL_NULL; + + int utf16_size = 0; + const jschar* strUTF16 = (jschar*)cc_utf8_to_utf16(v, (int)length, &utf16_size); + + if (strUTF16 && utf16_size > 0) { + JSString* str = JS_NewUCStringCopyN(cx, strUTF16, (size_t)utf16_size); + if (str) { + ret = STRING_TO_JSVAL(str); + } + delete[] strUTF16; + } + + return ret; +} + +jsval ccpoint_to_jsval(JSContext* cx, const Point& v) +{ + JS::RootedObject proto(cx); + JS::RootedObject parent(cx); + JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, proto, parent)); + if (!tmp) return JSVAL_NULL; + bool ok = JS_DefineProperty(cx, tmp, "x", v.x, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "y", v.y, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +jsval ccacceleration_to_jsval(JSContext* cx, const Acceleration& v) +{ + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JS::RootedObject proto(cx); + JS::RootedObject parent(cx); + JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, proto, parent)); + if (!tmp) return JSVAL_NULL; + bool ok = JS_DefineProperty(cx, tmp, "x", v.x, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "y", v.y, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "z", v.z, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "timestamp", v.timestamp, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +jsval ccrect_to_jsval(JSContext* cx, const Rect& v) +{ + JS::RootedObject proto(cx); + JS::RootedObject parent(cx); + JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, proto, parent)); + if (!tmp) return JSVAL_NULL; + bool ok = JS_DefineProperty(cx, tmp, "x", v.origin.x, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "y", v.origin.y, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "width", v.size.width, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "height", v.size.height, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +jsval ccsize_to_jsval(JSContext* cx, const Size& v) +{ + JS::RootedObject proto(cx); + JS::RootedObject parent(cx); + JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, proto, parent)); + if (!tmp) return JSVAL_NULL; + bool ok = JS_DefineProperty(cx, tmp, "width", v.width, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "height", v.height, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +jsval cccolor4b_to_jsval(JSContext* cx, const Color4B& v) +{ + JS::RootedObject proto(cx); + JS::RootedObject parent(cx); + JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, proto, parent)); + if (!tmp) return JSVAL_NULL; + bool ok = JS_DefineProperty(cx, tmp, "r", (int32_t)v.r, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "g", (int32_t)v.g, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "b", (int32_t)v.b, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "a", (int32_t)v.a, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +jsval cccolor4f_to_jsval(JSContext* cx, const Color4F& v) +{ + JS::RootedObject proto(cx); + JS::RootedObject parent(cx); + JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, proto, parent)); + if (!tmp) return JSVAL_NULL; + bool ok = JS_DefineProperty(cx, tmp, "r", (int32_t)(v.r * 255), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "g", (int32_t)(v.g * 255), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "b", (int32_t)(v.b * 255), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "a", (int32_t)(v.a * 255), JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +jsval cccolor3b_to_jsval(JSContext* cx, const Color3B& v) +{ + JS::RootedObject proto(cx); + JS::RootedObject parent(cx); + JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, proto, parent)); + if (!tmp) return JSVAL_NULL; + bool ok = JS_DefineProperty(cx, tmp, "r", (int32_t)v.r, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "g", (int32_t)v.g, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "b", (int32_t)v.b, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +jsval ccaffinetransform_to_jsval(JSContext* cx, const AffineTransform& t) +{ + JS::RootedObject proto(cx); + JS::RootedObject parent(cx); + JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, proto, parent)); + if (!tmp) return JSVAL_NULL; + bool ok = JS_DefineProperty(cx, tmp, "a", t.a, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "b", t.b, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "c", t.c, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "d", t.d, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "tx", t.tx, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "ty", t.ty, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +jsval quaternion_to_jsval(JSContext* cx, const cocos2d::Quaternion& q) +{ + JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); + if(!tmp) return JSVAL_NULL; + bool ok = JS_DefineProperty(cx, tmp, "x", q.x, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "y", q.y, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "z", q.z, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "w", q.w, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if(ok) + return OBJECT_TO_JSVAL(tmp); + + return JSVAL_NULL; +} + +jsval meshVertexAttrib_to_jsval(JSContext* cx, const cocos2d::MeshVertexAttrib& q) +{ + JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); + if(!tmp) return JSVAL_NULL; + bool ok = JS_DefineProperty(cx, tmp, "size", q.size, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "type", q.type, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "vertexAttrib", q.vertexAttrib, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "attribSizeBytes", q.attribSizeBytes, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if(ok) + return OBJECT_TO_JSVAL(tmp); + + return JSVAL_NULL; +} + +jsval FontDefinition_to_jsval(JSContext* cx, const FontDefinition& t) +{ + JS::RootedObject proto(cx); + JS::RootedObject parent(cx); + JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, proto, parent)); +// if (!tmp) return JSVAL_NULL; + bool ok = true; + + ok &= JS_DefineProperty(cx, tmp, "fontName", JS::RootedValue(cx, std_string_to_jsval(cx, t._fontName)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "fontSize", t._fontSize, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "textAlign", (int32_t)t._alignment, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "verticalAlign", (int32_t)t._vertAlignment, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "fillStyle", JS::RootedValue(cx, cccolor3b_to_jsval(cx, t._fontFillColor)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "boundingWidth", t._dimensions.width, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "boundingHeight", t._dimensions.height, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + // Shadow + ok &= JS_DefineProperty(cx, tmp, "shadowEnabled", JS::RootedValue(cx, BOOLEAN_TO_JSVAL(t._shadow._shadowEnabled)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "shadowOffsetX", t._shadow._shadowOffset.width, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "shadowOffsetY", t._shadow._shadowOffset.height, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "shadowBlur", t._shadow._shadowBlur, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "shadowOpacity", t._shadow._shadowOpacity, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + // Stroke + ok &= JS_DefineProperty(cx, tmp, "strokeEnabled", JS::RootedValue(cx, BOOLEAN_TO_JSVAL(t._stroke._strokeEnabled)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "strokeStyle", JS::RootedValue(cx, cccolor3b_to_jsval(cx, t._stroke._strokeColor)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + + ok &= JS_DefineProperty(cx, tmp, "lineWidth", t._stroke._strokeSize, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +bool jsval_to_FontDefinition( JSContext *cx, JS::HandleValue vp, FontDefinition *out ) +{ + JS::RootedObject jsobj(cx); + + if (!JS_ValueToObject( cx, vp, &jsobj ) ) + return false; + + JSB_PRECONDITION( jsobj, "Not a valid JS object"); + + // defaul values + const char * defautlFontName = "Arial"; + const int defaultFontSize = 32; + TextHAlignment defaultTextAlignment = TextHAlignment::LEFT; + TextVAlignment defaultTextVAlignment = TextVAlignment::TOP; + + // by default shadow and stroke are off + out->_shadow._shadowEnabled = false; + out->_stroke._strokeEnabled = false; + + // white text by default + out->_fontFillColor = Color3B::WHITE; + + // font name + JS::RootedValue jsr(cx); + JS_GetProperty(cx, jsobj, "fontName", &jsr); + JS::ToString(cx, jsr); + JSStringWrapper wrapper(jsr); + const char* fontName = wrapper.get(); + + if (fontName && strlen(fontName) > 0) + { + out->_fontName = fontName; + } + else + { + out->_fontName = defautlFontName; + } + + // font size + bool hasProperty, hasSecondProp; + JS_HasProperty(cx, jsobj, "fontSize", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "fontSize", &jsr); + double fontSize = 0.0; + JS::ToNumber(cx, jsr, &fontSize); + out->_fontSize = fontSize; + } + else + { + out->_fontSize = defaultFontSize; + } + + // font alignment horizontal + JS_HasProperty(cx, jsobj, "textAlign", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "textAlign", &jsr); + double fontAlign = 0.0; + JS::ToNumber(cx, jsr, &fontAlign); + out->_alignment = (TextHAlignment)(int)fontAlign; + } + else + { + out->_alignment = defaultTextAlignment; + } + + // font alignment vertical + JS_HasProperty(cx, jsobj, "verticalAlign", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "verticalAlign", &jsr); + double fontAlign = 0.0; + JS::ToNumber(cx, jsr, &fontAlign); + out->_vertAlignment = (TextVAlignment)(int)fontAlign; + } + else + { + out->_vertAlignment = defaultTextVAlignment; + } + + // font fill color + JS_HasProperty(cx, jsobj, "fillStyle", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "fillStyle", &jsr); + + JS::RootedObject jsobjColor(cx); + if (!JS_ValueToObject( cx, JS::RootedValue(cx, jsr), &jsobjColor ) ) + return false; + + out->_fontFillColor = getColorFromJSObject(cx, jsobjColor); + } + + // font rendering box dimensions + JS_HasProperty(cx, jsobj, "boundingWidth", &hasProperty); + JS_HasProperty(cx, jsobj, "boundingHeight", &hasSecondProp); + if ( hasProperty && hasSecondProp ) + { + JS_GetProperty(cx, jsobj, "boundingWidth", &jsr); + double boundingW = 0.0; + JS::ToNumber(cx, jsr, &boundingW); + + JS_GetProperty(cx, jsobj, "boundingHeight", &jsr); + double boundingH = 0.0; + JS::ToNumber(cx, jsr, &boundingH); + + Size dimension; + dimension.width = boundingW; + dimension.height = boundingH; + out->_dimensions = dimension; + } + + // shadow + JS_HasProperty(cx, jsobj, "shadowEnabled", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "shadowEnabled", &jsr); + out->_shadow._shadowEnabled = ToBoolean(jsr); + + if ( out->_shadow._shadowEnabled ) + { + // default shadow values + out->_shadow._shadowOffset = Size(5, 5); + out->_shadow._shadowBlur = 1; + out->_shadow._shadowOpacity = 1; + + // shado offset + JS_HasProperty(cx, jsobj, "shadowOffsetX", &hasProperty); + JS_HasProperty(cx, jsobj, "shadowOffsetY", &hasSecondProp); + if ( hasProperty && hasSecondProp ) + { + JS_GetProperty(cx, jsobj, "shadowOffsetX", &jsr); + double offx = 0.0; + JS::ToNumber(cx, jsr, &offx); + + JS_GetProperty(cx, jsobj, "shadowOffsetY", &jsr); + double offy = 0.0; + JS::ToNumber(cx, jsr, &offy); + + Size offset; + offset.width = offx; + offset.height = offy; + out->_shadow._shadowOffset = offset; + } + + // shadow blur + JS_HasProperty(cx, jsobj, "shadowBlur", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "shadowBlur", &jsr); + double shadowBlur = 0.0; + JS::ToNumber(cx, jsr, &shadowBlur); + out->_shadow._shadowBlur = shadowBlur; + } + + // shadow intensity + JS_HasProperty(cx, jsobj, "shadowOpacity", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "shadowOpacity", &jsr); + double shadowOpacity = 0.0; + JS::ToNumber(cx, jsr, &shadowOpacity); + out->_shadow._shadowOpacity = shadowOpacity; + } + } + } + + // stroke + JS_HasProperty(cx, jsobj, "strokeEnabled", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "strokeEnabled", &jsr); + out->_stroke._strokeEnabled = ToBoolean(jsr); + + if ( out->_stroke._strokeEnabled ) + { + // default stroke values + out->_stroke._strokeSize = 1; + out->_stroke._strokeColor = Color3B::BLUE; + + // stroke color + JS_HasProperty(cx, jsobj, "strokeStyle", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "strokeStyle", &jsr); + + JS::RootedObject jsobjStrokeColor(cx); + if (!JS_ValueToObject( cx, jsr, &jsobjStrokeColor ) ) + return false; + out->_stroke._strokeColor = getColorFromJSObject(cx, jsobjStrokeColor); + } + + // stroke size + JS_HasProperty(cx, jsobj, "lineWidth", &hasProperty); + if ( hasProperty ) + { + JS_GetProperty(cx, jsobj, "lineWidth", &jsr); + double strokeSize = 0.0; + JS::ToNumber(cx, jsr, &strokeSize); + out->_stroke._strokeSize = strokeSize; + } + } + } + + // we are done here + return true; +} + +bool jsval_to_CCPoint( JSContext *cx, JS::HandleValue vp, Point *ret ) +{ +#ifdef JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + + JS::RootedObject jsobj(cx); + if( ! JS_ValueToObject( cx, vp, &jsobj ) ) + return false; + + JSB_PRECONDITION( jsobj, "Not a valid JS object"); + + JS::RootedValue valx(cx); + JS::RootedValue valy(cx); + bool ok = true; + ok &= JS_GetProperty(cx, jsobj, "x", &valx); + ok &= JS_GetProperty(cx, jsobj, "y", &valy); + + if( ! ok ) + return false; + + double x, y; + ok &= JS::ToNumber(cx, valx, &x); + ok &= JS::ToNumber(cx, valy, &y); + + if( ! ok ) + return false; + + ret->x = x; + ret->y = y; + + return true; + +#else // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + + JSObject *tmp_arg; + if( ! JS_ValueToObject( cx, vp, &tmp_arg ) ) + return false; + + JSB_PRECONDITION( tmp_arg && JS_IsTypedArrayObject( tmp_arg, cx ), "Not a TypedArray object"); + + JSB_PRECONDITION( JS_GetTypedArrayByteLength( tmp_arg, cx ) == sizeof(cpVect), "Invalid length"); + + *ret = *(Point*)JS_GetArrayBufferViewData( tmp_arg, cx ); + + return true; +#endif // #! JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES +} + +jsval ccvalue_to_jsval(JSContext* cx, const cocos2d::Value& v) +{ + jsval ret = JSVAL_NULL; + const Value& obj = v; + + switch (obj.getType()) + { + case Value::Type::BOOLEAN: + ret = BOOLEAN_TO_JSVAL(obj.asBool()); + break; + case Value::Type::FLOAT: + case Value::Type::DOUBLE: + ret = DOUBLE_TO_JSVAL(obj.asDouble()); + break; + case Value::Type::INTEGER: + ret = INT_TO_JSVAL(obj.asInt()); + break; + case Value::Type::STRING: + ret = std_string_to_jsval(cx, obj.asString()); + break; + case Value::Type::VECTOR: + ret = ccvaluevector_to_jsval(cx, obj.asValueVector()); + break; + case Value::Type::MAP: + ret = ccvaluemap_to_jsval(cx, obj.asValueMap()); + break; + case Value::Type::INT_KEY_MAP: + ret = ccvaluemapintkey_to_jsval(cx, obj.asIntKeyMap()); + break; + default: + break; + } + + return ret; +} + +jsval ccvaluemap_to_jsval(JSContext* cx, const cocos2d::ValueMap& v) +{ + JS::RootedObject jsRet(cx, JS_NewArrayObject(cx, 0)); + + for (auto iter = v.begin(); iter != v.end(); ++iter) + { + JS::RootedValue dictElement(cx); + + std::string key = iter->first; + const Value& obj = iter->second; + + switch (obj.getType()) + { + case Value::Type::BOOLEAN: + dictElement = BOOLEAN_TO_JSVAL(obj.asBool()); + break; + case Value::Type::FLOAT: + case Value::Type::DOUBLE: + dictElement = DOUBLE_TO_JSVAL(obj.asDouble()); + break; + case Value::Type::INTEGER: + dictElement = INT_TO_JSVAL(obj.asInt()); + break; + case Value::Type::STRING: + dictElement = std_string_to_jsval(cx, obj.asString()); + break; + case Value::Type::VECTOR: + dictElement = ccvaluevector_to_jsval(cx, obj.asValueVector()); + break; + case Value::Type::MAP: + dictElement = ccvaluemap_to_jsval(cx, obj.asValueMap()); + break; + case Value::Type::INT_KEY_MAP: + dictElement = ccvaluemapintkey_to_jsval(cx, obj.asIntKeyMap()); + break; + default: + break; + } + + if (!key.empty()) + { + JS_SetProperty(cx, jsRet, key.c_str(), dictElement); + } + } + return OBJECT_TO_JSVAL(jsRet); +} + +jsval ccvaluemapintkey_to_jsval(JSContext* cx, const cocos2d::ValueMapIntKey& v) +{ + JS::RootedObject jsRet(cx, JS_NewArrayObject(cx, 0)); + + for (auto iter = v.begin(); iter != v.end(); ++iter) + { + JS::RootedValue dictElement(cx); + std::stringstream keyss; + keyss << iter->first; + std::string key = keyss.str(); + + const Value& obj = iter->second; + + switch (obj.getType()) + { + case Value::Type::BOOLEAN: + dictElement = BOOLEAN_TO_JSVAL(obj.asBool()); + break; + case Value::Type::FLOAT: + case Value::Type::DOUBLE: + dictElement = DOUBLE_TO_JSVAL(obj.asDouble()); + break; + case Value::Type::INTEGER: + dictElement = INT_TO_JSVAL(obj.asInt()); + break; + case Value::Type::STRING: + dictElement = std_string_to_jsval(cx, obj.asString()); + break; + case Value::Type::VECTOR: + dictElement = ccvaluevector_to_jsval(cx, obj.asValueVector()); + break; + case Value::Type::MAP: + dictElement = ccvaluemap_to_jsval(cx, obj.asValueMap()); + break; + case Value::Type::INT_KEY_MAP: + dictElement = ccvaluemapintkey_to_jsval(cx, obj.asIntKeyMap()); + break; + default: + break; + } + + if (!key.empty()) + { + JS_SetProperty(cx, jsRet, key.c_str(), dictElement); + } + } + return OBJECT_TO_JSVAL(jsRet); +} + +jsval ccvaluevector_to_jsval(JSContext* cx, const cocos2d::ValueVector& v) +{ + JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, 0)); + + int i = 0; + for (const auto& obj : v) + { + JS::RootedValue arrElement(cx); + + switch (obj.getType()) + { + case Value::Type::BOOLEAN: + arrElement = BOOLEAN_TO_JSVAL(obj.asBool()); + break; + case Value::Type::FLOAT: + case Value::Type::DOUBLE: + arrElement = DOUBLE_TO_JSVAL(obj.asDouble()); + break; + case Value::Type::INTEGER: + arrElement = INT_TO_JSVAL(obj.asInt()); + break; + case Value::Type::STRING: + arrElement = std_string_to_jsval(cx, obj.asString()); + break; + case Value::Type::VECTOR: + arrElement = ccvaluevector_to_jsval(cx, obj.asValueVector()); + break; + case Value::Type::MAP: + arrElement = ccvaluemap_to_jsval(cx, obj.asValueMap()); + break; + case Value::Type::INT_KEY_MAP: + arrElement = ccvaluemapintkey_to_jsval(cx, obj.asIntKeyMap()); + break; + default: + break; + } + + if (!JS_SetElement(cx, jsretArr, i, arrElement)) { + break; + } + ++i; + } + return OBJECT_TO_JSVAL(jsretArr); +} + +jsval ssize_to_jsval(JSContext *cx, ssize_t v) +{ + CCASSERT(v < INT_MAX, "The size should not bigger than 32 bit (int32_t)."); + return int32_to_jsval(cx, static_cast(v)); +} + +jsval std_vector_string_to_jsval( JSContext *cx, const std::vector& v) +{ + JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, 0)); + + int i = 0; + for (const std::string obj : v) + { + JS::RootedValue arrElement(cx); + arrElement = std_string_to_jsval(cx, obj); + + if (!JS_SetElement(cx, jsretArr, i, arrElement)) { + break; + } + ++i; + } + return OBJECT_TO_JSVAL(jsretArr); +} + +jsval std_vector_int_to_jsval( JSContext *cx, const std::vector& v) +{ + JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, 0)); + + int i = 0; + for (const int obj : v) + { + JS::RootedValue arrElement(cx); + arrElement = int32_to_jsval(cx, obj); + + if (!JS_SetElement(cx, jsretArr, i, arrElement)) { + break; + } + ++i; + } + return OBJECT_TO_JSVAL(jsretArr); +} + +jsval matrix_to_jsval(JSContext *cx, const cocos2d::Mat4& v) +{ + JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, 16)); + + for (int i = 0; i < 16; i++) { + JS::RootedValue arrElement(cx); + arrElement = DOUBLE_TO_JSVAL(v.m[i]); + + if (!JS_SetElement(cx, jsretArr, i, arrElement)) { + break; + } + } + + return OBJECT_TO_JSVAL(jsretArr); +} + +jsval vector2_to_jsval(JSContext *cx, const cocos2d::Vec2& v) +{ + JS::RootedObject proto(cx); + JS::RootedObject parent(cx); + JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, proto, parent)); + if (!tmp) return JSVAL_NULL; + bool ok = JS_DefineProperty(cx, tmp, "x", v.x, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "y", v.y, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +jsval vector3_to_jsval(JSContext *cx, const cocos2d::Vec3& v) +{ + JS::RootedObject proto(cx); + JS::RootedObject parent(cx); + JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, proto, parent)); + if (!tmp) return JSVAL_NULL; + bool ok = JS_DefineProperty(cx, tmp, "x", v.x, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "y", v.y, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "z", v.z, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +jsval blendfunc_to_jsval(JSContext *cx, const cocos2d::BlendFunc& v) +{ + JS::RootedObject proto(cx); + JS::RootedObject parent(cx); + JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, proto, parent)); + if (!tmp) return JSVAL_NULL; + bool ok = JS_DefineProperty(cx, tmp, "src", (uint32_t)v.src, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "dst", (uint32_t)v.dst, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.h b/cocos/scripting/js-bindings/manual/js_manual_conversions.h new file mode 100644 index 0000000000..575dc940c6 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.h @@ -0,0 +1,336 @@ +/* + * Created by Rohan Kuruvilla + * Copyright (c) 2012 Zynga Inc. + * 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. + */ + +#ifndef __JS_MANUAL_CONVERSIONS_H__ +#define __JS_MANUAL_CONVERSIONS_H__ + +#include "jsapi.h" +#include "jsfriendapi.h" +#include "js_bindings_core.h" +#include "js_bindings_config.h" +#include "cocos2d.h" +#include "spidermonkey_specifics.h" + +#define JSB_COMPATIBLE_WITH_COCOS2D_HTML5_BASIC_TYPES + +// just a simple utility to avoid mem leaking when using JSString +class JSStringWrapper +{ +public: + JSStringWrapper(); + JSStringWrapper(JSString* str, JSContext* cx = NULL); + JSStringWrapper(jsval val, JSContext* cx = NULL); + ~JSStringWrapper(); + + void set(jsval val, JSContext* cx); + void set(JSString* str, JSContext* cx); + const char* get(); + +private: + const char* _buffer; + +private: + CC_DISALLOW_COPY_AND_ASSIGN(JSStringWrapper); +}; + +// wraps a function and "this" object +class JSFunctionWrapper +{ +public: + JSFunctionWrapper(JSContext* cx, JSObject *jsthis, jsval fval); + ~JSFunctionWrapper(); + + bool invoke(unsigned int argc, jsval *argv, JS::MutableHandleValue rval); +private: + JSContext *_cx; + JS::Heap _jsthis; + JS::Heap _fval; +private: + CC_DISALLOW_COPY_AND_ASSIGN(JSFunctionWrapper); +}; + +bool jsval_to_opaque( JSContext *cx, JS::HandleValue vp, void **out ); +bool jsval_to_int( JSContext *cx, JS::HandleValue vp, int *out); +bool jsval_to_uint( JSContext *cx, JS::HandleValue vp, unsigned int *out); +bool jsval_to_c_class( JSContext *cx, JS::HandleValue vp, void **out_native, struct jsb_c_proxy_s **out_proxy); +/** converts a jsval (JS string) into a char */ +bool jsval_to_charptr( JSContext *cx, JS::HandleValue vp, const char **out); + +jsval opaque_to_jsval( JSContext *cx, void* opaque); +jsval c_class_to_jsval( JSContext *cx, void* handle, JS::HandleObject object, JSClass *klass, const char* class_name); + +/* Converts a char ptr into a jsval (using JS string) */ +jsval charptr_to_jsval( JSContext *cx, const char *str); +bool JSB_jsval_typedarray_to_dataptr( JSContext *cx, JS::HandleValue vp, GLsizei *count, void **data, js::Scalar::Type t); +bool JSB_get_arraybufferview_dataptr( JSContext *cx, JS::HandleValue vp, GLsizei *count, GLvoid **data ); + +// some utility functions +// to native +bool jsval_to_ushort( JSContext *cx, JS::HandleValue vp, unsigned short *ret ); +bool jsval_to_int32( JSContext *cx, JS::HandleValue vp, int32_t *ret ); +bool jsval_to_uint32( JSContext *cx, JS::HandleValue vp, uint32_t *ret ); +bool jsval_to_uint16( JSContext *cx, JS::HandleValue vp, uint16_t *ret ); +bool jsval_to_long( JSContext *cx, JS::HandleValue vp, long *out); +bool jsval_to_ulong( JSContext *cx, JS::HandleValue vp, unsigned long *out); +bool jsval_to_long_long(JSContext *cx, JS::HandleValue v, long long* ret); +bool jsval_to_std_string(JSContext *cx, JS::HandleValue v, std::string* ret); +bool jsval_to_ccpoint(JSContext *cx, JS::HandleValue v, cocos2d::Point* ret); +bool jsval_to_ccrect(JSContext *cx, JS::HandleValue v, cocos2d::Rect* ret); +bool jsval_to_ccsize(JSContext *cx, JS::HandleValue v, cocos2d::Size* ret); +bool jsval_to_cccolor4b(JSContext *cx, JS::HandleValue v, cocos2d::Color4B* ret); +bool jsval_to_cccolor4f(JSContext *cx, JS::HandleValue v, cocos2d::Color4F* ret); +bool jsval_to_cccolor3b(JSContext *cx, JS::HandleValue v, cocos2d::Color3B* ret); +bool jsval_cccolor_to_opacity(JSContext *cx, JS::HandleValue v, int32_t* ret); +bool jsval_to_ccarray_of_CCPoint(JSContext* cx, JS::HandleValue v, cocos2d::Point **points, int *numPoints); +bool jsval_to_ccarray(JSContext* cx, JS::HandleValue v, cocos2d::__Array** ret); +bool jsval_to_ccdictionary(JSContext* cx, JS::HandleValue v, cocos2d::__Dictionary** ret); +bool jsval_to_ccacceleration(JSContext* cx, JS::HandleValue v, cocos2d::Acceleration* ret); +bool jsvals_variadic_to_ccarray( JSContext *cx, jsval *vp, int argc, cocos2d::__Array** ret); +bool jsval_to_quaternion(JSContext *cx, JS::HandleValue vp, cocos2d::Quaternion* ret); +bool jsval_to_obb(JSContext *cx, JS::HandleValue vp, cocos2d::OBB* ret); +bool jsval_to_ray(JSContext *cx, JS::HandleValue vp, cocos2d::Ray* ret); + +// forward declaration +js_proxy_t* jsb_get_js_proxy(JSObject* jsObj); + +template +bool jsvals_variadic_to_ccvector( JSContext *cx, /*jsval *vp, int argc,*/const JS::CallArgs& args, cocos2d::Vector* ret) +{ + bool ok = true; + + for (int i = 0; i < args.length(); i++) + { + js_proxy_t* p; + JSObject* obj = JS::RootedValue(cx, args.get(i)).toObjectOrNull(); + + p = jsb_get_js_proxy(obj); + CCASSERT(p, "Native object not found!"); + if (p) { + ret->pushBack((T)p->ptr); + } + + } + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + return ok; +} + +bool jsvals_variadic_to_ccvaluevector( JSContext *cx, jsval *vp, int argc, cocos2d::ValueVector* ret); + +bool jsval_to_ccaffinetransform(JSContext* cx, JS::HandleValue v, cocos2d::AffineTransform* ret); +bool jsval_to_FontDefinition( JSContext *cx, JS::HandleValue vp, cocos2d::FontDefinition* ret ); + +template +bool jsval_to_ccvector(JSContext* cx, JS::HandleValue v, cocos2d::Vector* ret) +{ + JS::RootedObject jsobj(cx); + + bool ok = v.isObject() && JS_ValueToObject( cx, v, &jsobj ); + JSB_PRECONDITION3( ok, cx, false, "Error converting value to object"); + JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, false, "Object must be an array"); + + uint32_t len = 0; + JS_GetArrayLength(cx, jsobj, &len); + + for (uint32_t i=0; i < len; i++) + { + JS::RootedValue value(cx); + if (JS_GetElement(cx, jsobj, i, &value)) + { + CCASSERT(value.isObject(), "the element in Vector isn't a native object."); + + js_proxy_t *proxy; + JSObject *tmp = value.toObjectOrNull(); + proxy = jsb_get_js_proxy(tmp); + T cobj = (T)(proxy ? proxy->ptr : nullptr); + if (cobj) + { + ret->pushBack(cobj); + } + } + } + + return true; +} + +bool jsval_to_ccvalue(JSContext* cx, JS::HandleValue v, cocos2d::Value* ret); +bool jsval_to_ccvaluemap(JSContext* cx, JS::HandleValue v, cocos2d::ValueMap* ret); +bool jsval_to_ccvaluemapintkey(JSContext* cx, JS::HandleValue v, cocos2d::ValueMapIntKey* ret); +bool jsval_to_ccvaluevector(JSContext* cx, JS::HandleValue v, cocos2d::ValueVector* ret); +bool jsval_to_ssize( JSContext *cx, JS::HandleValue vp, ssize_t* ret); +bool jsval_to_std_vector_string( JSContext *cx, JS::HandleValue vp, std::vector* ret); +bool jsval_to_std_vector_int( JSContext *cx, JS::HandleValue vp, std::vector* ret); +bool jsval_to_matrix(JSContext *cx, JS::HandleValue vp, cocos2d::Mat4* ret); +bool jsval_to_vector2(JSContext *cx, JS::HandleValue vp, cocos2d::Vec2* ret); +bool jsval_to_vector3(JSContext *cx, JS::HandleValue vp, cocos2d::Vec3* ret); +bool jsval_to_vector4(JSContext *cx, JS::HandleValue vp, cocos2d::Vec4* ret); +bool jsval_to_blendfunc(JSContext *cx, JS::HandleValue vp, cocos2d::BlendFunc* ret); + +template +bool jsval_to_ccmap_string_key(JSContext *cx, JS::HandleValue v, cocos2d::Map* ret) +{ + if (v.isNullOrUndefined()) + { + return true; + } + + JS::RootedObject tmp(cx, v.toObjectOrNull()); + + if (!tmp) { + CCLOG("%s", "jsval_to_ccvaluemap: the jsval is not an object."); + return false; + } + + JS::RootedObject it(cx, JS_NewPropertyIterator(cx, tmp)); + + while (true) + { + JS::RootedId idp(cx); + JS::RootedValue key(cx); + if (! JS_NextProperty(cx, it, idp.address()) || ! JS_IdToValue(cx, idp, &key)) { + return false; // error + } + + if (key.isUndefined()) { + break; // end of iteration + } + + if (!key.isString()) { + continue; // ignore integer properties + } + + JSStringWrapper keyWrapper(key.toString(), cx); + + JS::RootedValue value(cx); + JS_GetPropertyById(cx, tmp, idp, &value); + if (value.isObject()) + { + js_proxy_t *proxy = nullptr; + JSObject* jsobj = value.toObjectOrNull(); + proxy = jsb_get_js_proxy(jsobj); + CCASSERT(proxy, "Native object should be added!"); + T cobj = (T)(proxy ? proxy->ptr : nullptr); + ret->insert(keyWrapper.get(), cobj); + } + else + { + CCASSERT(false, "not supported type"); + } + } + + return true; +} + +// from native +jsval int32_to_jsval( JSContext *cx, int32_t l); +jsval uint32_to_jsval( JSContext *cx, uint32_t number ); +jsval ushort_to_jsval( JSContext *cx, unsigned short number ); +jsval long_to_jsval( JSContext *cx, long number ); +jsval ulong_to_jsval(JSContext* cx, unsigned long v); +jsval long_long_to_jsval(JSContext* cx, long long v); +jsval std_string_to_jsval(JSContext* cx, const std::string& v); +jsval c_string_to_jsval(JSContext* cx, const char* v, size_t length = -1); +jsval ccpoint_to_jsval(JSContext* cx, const cocos2d::Point& v); +jsval ccrect_to_jsval(JSContext* cx, const cocos2d::Rect& v); +jsval ccsize_to_jsval(JSContext* cx, const cocos2d::Size& v); +jsval cccolor4b_to_jsval(JSContext* cx, const cocos2d::Color4B& v); +jsval cccolor4f_to_jsval(JSContext* cx, const cocos2d::Color4F& v); +jsval cccolor3b_to_jsval(JSContext* cx, const cocos2d::Color3B& v); +jsval ccdictionary_to_jsval(JSContext* cx, cocos2d::__Dictionary *dict); +jsval ccarray_to_jsval(JSContext* cx, cocos2d::__Array *arr); +jsval ccacceleration_to_jsval(JSContext* cx, const cocos2d::Acceleration& v); +jsval ccaffinetransform_to_jsval(JSContext* cx, const cocos2d::AffineTransform& t); +jsval FontDefinition_to_jsval(JSContext* cx, const cocos2d::FontDefinition& t); +jsval quaternion_to_jsval(JSContext* cx, const cocos2d::Quaternion& q); +jsval meshVertexAttrib_to_jsval(JSContext* cx, const cocos2d::MeshVertexAttrib& q); + +template +js_proxy_t *js_get_or_create_proxy(JSContext *cx, T *native_obj); + +template +jsval ccvector_to_jsval(JSContext* cx, const cocos2d::Vector& v) +{ + JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, 0)); + + int i = 0; + for (const auto& obj : v) + { + JS::RootedValue arrElement(cx); + + //First, check whether object is associated with js object. + js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); + if (jsproxy) { + arrElement = OBJECT_TO_JSVAL(jsproxy->obj); + } + + if (!JS_SetElement(cx, jsretArr, i, arrElement)) { + break; + } + ++i; + } + return OBJECT_TO_JSVAL(jsretArr); +} + +template +jsval ccmap_string_key_to_jsval(JSContext* cx, const cocos2d::Map& v) +{ + JS::RootedObject proto(cx); + JS::RootedObject parent(cx); + JS::RootedObject jsRet(cx, JS_NewObject(cx, NULL, proto, parent)); + + for (auto iter = v.begin(); iter != v.end(); ++iter) + { + JS::RootedValue element(cx); + + std::string key = iter->first; + T obj = iter->second; + + //First, check whether object is associated with js object. + js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); + if (jsproxy) { + element = OBJECT_TO_JSVAL(jsproxy->obj); + } + + if (!key.empty()) + { + JS_SetProperty(cx, jsRet, key.c_str(), element); + } + } + return OBJECT_TO_JSVAL(jsRet); +} + +jsval ccvalue_to_jsval(JSContext* cx, const cocos2d::Value& v); +jsval ccvaluemap_to_jsval(JSContext* cx, const cocos2d::ValueMap& v); +jsval ccvaluemapintkey_to_jsval(JSContext* cx, const cocos2d::ValueMapIntKey& v); +jsval ccvaluevector_to_jsval(JSContext* cx, const cocos2d::ValueVector& v); +jsval ssize_to_jsval(JSContext *cx, ssize_t v); +jsval std_vector_string_to_jsval( JSContext *cx, const std::vector& v); +jsval std_vector_int_to_jsval( JSContext *cx, const std::vector& v); +jsval matrix_to_jsval(JSContext *cx, const cocos2d::Mat4& v); +jsval vector2_to_jsval(JSContext *cx, const cocos2d::Vec2& v); +jsval vector3_to_jsval(JSContext *cx, const cocos2d::Vec3& v); +jsval blendfunc_to_jsval(JSContext *cx, const cocos2d::BlendFunc& v); + +#endif /* __JS_MANUAL_CONVERSIONS_H__ */ + diff --git a/cocos/scripting/js-bindings/manual/jsb_event_dispatcher_manual.cpp b/cocos/scripting/js-bindings/manual/jsb_event_dispatcher_manual.cpp new file mode 100644 index 0000000000..2481746993 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/jsb_event_dispatcher_manual.cpp @@ -0,0 +1,173 @@ +/* + * 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. + */ + +#include "jsb_event_dispatcher_manual.h" +#include "cocos2d.h" +#include "ScriptingCore.h" +#include "cocos2d_specifics.hpp" + +USING_NS_CC; + +bool js_EventListenerTouchOneByOne_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + auto ret = EventListenerTouchOneByOne::create(); + + ret->onTouchBegan = [cx, ret](Touch* touch, Event* event) -> bool { + JS::RootedValue jsret(cx); + bool ok = ScriptingCore::getInstance()->handleTouchEvent(ret, EventTouch::EventCode::BEGAN, touch, event, &jsret); + + // Not found the method, just return false. + if (!ok) + return false; + + CCASSERT(jsret.isBoolean(), "the return value of onTouchBegan isn't boolean"); + return jsret.toBoolean(); + }; + + ret->onTouchMoved = [ret](Touch* touch, Event* event) { + ScriptingCore::getInstance()->handleTouchEvent(ret, EventTouch::EventCode::MOVED, touch, event); + }; + + ret->onTouchEnded = [ret](Touch* touch, Event* event) { + ScriptingCore::getInstance()->handleTouchEvent(ret, EventTouch::EventCode::ENDED, touch, event); + }; + + ret->onTouchCancelled = [ret](Touch* touch, Event* event) { + ScriptingCore::getInstance()->handleTouchEvent(ret, EventTouch::EventCode::CANCELLED, touch, event); + }; + + jsval jsret = getJSObject(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +bool js_EventListenerTouchAllAtOnce_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + auto ret = EventListenerTouchAllAtOnce::create(); + + ret->onTouchesBegan = [ret](const std::vector& touches, Event* event) { + ScriptingCore::getInstance()->handleTouchesEvent(ret, EventTouch::EventCode::BEGAN, touches, event); + }; + + ret->onTouchesMoved = [ret](const std::vector& touches, Event* event) { + ScriptingCore::getInstance()->handleTouchesEvent(ret, EventTouch::EventCode::MOVED, touches, event); + }; + + ret->onTouchesEnded = [ret](const std::vector& touches, Event* event) { + ScriptingCore::getInstance()->handleTouchesEvent(ret, EventTouch::EventCode::ENDED, touches, event); + }; + + ret->onTouchesCancelled = [ret](const std::vector& touches, Event* event) { + ScriptingCore::getInstance()->handleTouchesEvent(ret, EventTouch::EventCode::CANCELLED, touches, event); + }; + + jsval jsret = getJSObject(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +bool js_EventListenerMouse_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + auto ret = EventListenerMouse::create(); + + ret->onMouseDown = [ret](Event* event) { + ScriptingCore::getInstance()->handleMouseEvent(ret, EventMouse::MouseEventType::MOUSE_DOWN, event); + }; + + ret->onMouseUp = [ret](Event* event) { + ScriptingCore::getInstance()->handleMouseEvent(ret, EventMouse::MouseEventType::MOUSE_UP, event); + }; + + ret->onMouseMove = [ret](Event* event) { + ScriptingCore::getInstance()->handleMouseEvent(ret, EventMouse::MouseEventType::MOUSE_MOVE, event); + }; + + ret->onMouseScroll = [ret](Event* event) { + ScriptingCore::getInstance()->handleMouseEvent(ret, EventMouse::MouseEventType::MOUSE_SCROLL, event); + }; + + jsval jsret = getJSObject(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +bool js_EventListenerKeyboard_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + auto ret = EventListenerKeyboard::create(); + + ret->onKeyPressed = [ret](EventKeyboard::KeyCode keyCode, Event* event) { + ScriptingCore::getInstance()->handleKeybardEvent(ret, keyCode, true, event); + }; + + ret->onKeyReleased = [ret](EventKeyboard::KeyCode keyCode, Event* event) { + ScriptingCore::getInstance()->handleKeybardEvent(ret, keyCode, false, event); + }; + + jsval jsret = getJSObject(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +bool js_EventListenerFocus_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + if(argc == 0) + { + auto ret = EventListenerFocus::create(); + ret->onFocusChanged = [ret](ui::Widget* widgetLoseFocus, ui::Widget* widgetGetFocus){ + ScriptingCore::getInstance()->handleFocusEvent(ret, widgetLoseFocus, widgetGetFocus); + }; + + jsval jsret = getJSObject(cx, ret); + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + diff --git a/cocos/scripting/js-bindings/manual/jsb_event_dispatcher_manual.h b/cocos/scripting/js-bindings/manual/jsb_event_dispatcher_manual.h new file mode 100644 index 0000000000..dd222e34e3 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/jsb_event_dispatcher_manual.h @@ -0,0 +1,35 @@ +/* + * 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. + */ + +#ifndef __cocos2d_js_bindings__jsb_event_dispatcher__ +#define __cocos2d_js_bindings__jsb_event_dispatcher__ + +#include "jsapi.h" +#include "jsfriendapi.h" + +bool js_EventListenerTouchOneByOne_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_EventListenerTouchAllAtOnce_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_EventListenerKeyboard_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_EventListenerMouse_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_EventListenerFocus_create(JSContext *cx, uint32_t argc, jsval *vp); + +#endif /* defined(__cocos2d_js_bindings__jsb_event_dispatcher__) */ diff --git a/cocos/scripting/js-bindings/manual/jsb_helper.h b/cocos/scripting/js-bindings/manual/jsb_helper.h new file mode 100644 index 0000000000..72cc68f551 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/jsb_helper.h @@ -0,0 +1,143 @@ +/* + * 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. + */ + +#ifndef __XMLHTTPHELPER_H__ +#define __XMLHTTPHELPER_H__ + +#include "jsapi.h" +#include "jsfriendapi.h" + +#include +#include +#include + +//#pragma mark - Helpful Macros + +#define JS_BINDED_CLASS_GLUE(klass) \ +static JSClass js_class; \ +static JSObject* js_proto; \ +static JSObject* js_parent; \ +static void _js_register(JSContext* cx, JS::HandleObject global); + +#define JS_BINDED_CLASS_GLUE_IMPL(klass) \ +JSClass klass::js_class = {}; \ +JSObject* klass::js_proto = NULL; \ +JSObject* klass::js_parent = NULL; \ + +#define JS_BINDED_FUNC(klass, name) \ +bool name(JSContext *cx, unsigned argc, jsval *vp) + +#define JS_BINDED_CONSTRUCTOR(klass) \ +static bool _js_constructor(JSContext *cx, unsigned argc, jsval *vp) + +#define JS_BINDED_CONSTRUCTOR_IMPL(klass) \ +bool klass::_js_constructor(JSContext *cx, unsigned argc, jsval *vp) + +#define JS_BINDED_FUNC_IMPL(klass, name) \ +static bool klass##_func_##name(JSContext *cx, unsigned argc, jsval *vp) { \ +JSObject* thisObj = JS_THIS_OBJECT(cx, vp); \ +klass* obj = (klass*)JS_GetPrivate(thisObj); \ +if (obj) { \ +return obj->name(cx, argc, vp); \ +} \ +JS_ReportError(cx, "Invalid object call for function %s", #name); \ +return false; \ +} \ +bool klass::name(JSContext *cx, unsigned argc, jsval *vp) + +#define JS_WRAP_OBJECT_IN_VAL(klass, cobj, out) \ +do { \ +JSObject *obj = JS_NewObject(cx, &klass::js_class, klass::js_proto, klass::js_parent); \ +if (obj) { \ +JS_SetPrivate(obj, cobj); \ +out = OBJECT_TO_JSVAL(obj); \ +} \ +} while(0) \ + +#define JS_BINDED_FUNC_FOR_DEF(klass, name) \ +JS_FN(#name, klass##_func_##name, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT) + +#define JS_BINDED_PROP_GET(klass, propName) \ +bool _js_get_##propName(JSContext *cx, const JS::CallArgs& args) + +#define JS_BINDED_PROP_GET_IMPL(klass, propName) \ +static bool _js_get_##klass##_##propName(JSContext *cx, unsigned argc, jsval *vp) { \ +JS::CallArgs args = JS::CallArgsFromVp(argc, vp); \ +JSObject* obj = args.thisv().toObjectOrNull(); \ +klass* cobj = (klass*)JS_GetPrivate(obj); \ +if (cobj) { \ +return cobj->_js_get_##propName(cx, args); \ +} \ +JS_ReportError(cx, "Invalid getter call for property %s", #propName); \ +return false; \ +} \ +bool klass::_js_get_##propName(JSContext *cx, const JS::CallArgs& args) + +#define JS_BINDED_PROP_SET(klass, propName) \ +bool _js_set_##propName(JSContext *cx, const JS::CallArgs& args) + +#define JS_BINDED_PROP_SET_IMPL(klass, propName) \ +static bool _js_set_##klass##_##propName(JSContext *cx, unsigned argc, jsval *vp) { \ +JS::CallArgs args = JS::CallArgsFromVp(argc, vp); \ +JSObject* obj = args.thisv().toObjectOrNull(); \ +klass* cobj = (klass*)JS_GetPrivate(obj); \ +if (cobj) { \ +return cobj->_js_set_##propName(cx, args); \ +} \ +JS_ReportError(cx, "Invalid setter call for property %s", #propName); \ +return false; \ +} \ +bool klass::_js_set_##propName(JSContext *cx, const JS::CallArgs& args) + +#define JS_BINDED_PROP_ACCESSOR(klass, propName) \ +JS_BINDED_PROP_GET(klass, propName); \ +JS_BINDED_PROP_SET(klass, propName); + +#define JS_BINDED_PROP_DEF_GETTER(klass, propName) \ +JS_PSG(#propName, _js_get_##klass##_##propName, JSPROP_ENUMERATE | JSPROP_PERMANENT) + +#define JS_BINDED_PROP_DEF_ACCESSOR(klass, propName) \ +JS_PSGS(#propName, _js_get_##klass##_##propName, _js_set_##klass##_##propName, JSPROP_ENUMERATE | JSPROP_PERMANENT) + +#define JS_CREATE_UINT_WRAPPED(valOut, propName, val) \ +do { \ +JSObject* jsobj = JS_NewObject(cx, NULL, NULL, NULL); \ +jsval propVal = UINT_TO_JSVAL(val); \ +JS_SetProperty(cx, jsobj, "__" propName, &propVal); \ +valOut = OBJECT_TO_JSVAL(jsobj); \ +} while(0) + +#define JS_GET_UINT_WRAPPED(inVal, propName, out) \ +do { \ +if (inVal.isObject()) {\ +JSObject* jsobj = JSVAL_TO_OBJECT(inVal); \ +jsval outVal; \ +JS_GetProperty(cx, jsobj, "__" propName, &outVal); \ +JS_ValueToECMAUint32(cx, outVal, &out); \ +} else { \ +int32_t tmp; \ +JS_ValueToInt32(cx, inVal, &tmp); \ +out = (uint32_t)tmp; \ +} \ +} while (0) + +#endif /* __XMLHTTPHELPER_H__ */ diff --git a/cocos/scripting/js-bindings/manual/jsb_opengl_functions.cpp b/cocos/scripting/js-bindings/manual/jsb_opengl_functions.cpp new file mode 100644 index 0000000000..3d7004b491 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/jsb_opengl_functions.cpp @@ -0,0 +1,1921 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_jsb.py -c opengl_jsb.ini" on 2013-03-05 +* Script version: v0.6 +*/ +#include "js_bindings_config.h" +#ifdef JSB_INCLUDE_OPENGL + +#include "jsb_opengl_manual.h" + +#include "jsfriendapi.h" +//#include "jsb_config.h" +#include "js_bindings_core.h" +#include "js_manual_conversions.h" +#include "jsb_opengl_functions.h" + +// Arguments: GLenum +// Ret value: void +bool JSB_glActiveTexture(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glActiveTexture((GLenum)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint, GLuint +// Ret value: void +bool JSB_glAttachShader(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glAttachShader((GLuint)arg0 , (GLuint)arg1 ); + + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint, GLuint, char* +// Ret value: void +bool JSB_glBindAttribLocation(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; const char* arg2; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + ok &= jsval_to_charptr(cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glBindAttribLocation((GLuint)arg0 , (GLuint)arg1 , (char*)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLuint +// Ret value: void +bool JSB_glBindBuffer(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glBindBuffer((GLenum)arg0 , (GLuint)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLuint +// Ret value: void +bool JSB_glBindFramebuffer(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glBindFramebuffer((GLenum)arg0 , (GLuint)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLuint +// Ret value: void +bool JSB_glBindRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glBindRenderbuffer((GLenum)arg0 , (GLuint)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLuint +// Ret value: void +bool JSB_glBindTexture(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glBindTexture((GLenum)arg0 , (GLuint)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLclampf, GLclampf, GLclampf, GLclampf +// Ret value: void +bool JSB_glBlendColor(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + ok &= jsval_to_int32( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glBlendColor((GLclampf)arg0 , (GLclampf)arg1 , (GLclampf)arg2 , (GLclampf)arg3 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum +// Ret value: void +bool JSB_glBlendEquation(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glBlendEquation((GLenum)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLenum +// Ret value: void +bool JSB_glBlendEquationSeparate(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glBlendEquationSeparate((GLenum)arg0 , (GLenum)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLenum +// Ret value: void +bool JSB_glBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glBlendFunc((GLenum)arg0 , (GLenum)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLenum, GLenum, GLenum +// Ret value: void +bool JSB_glBlendFuncSeparate(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + ok &= jsval_to_uint32( cx, args.get(2), &arg2 ); + ok &= jsval_to_uint32( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glBlendFuncSeparate((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLenum)arg3 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, ArrayBufferView, GLenum +// Ret value: void +bool JSB_glBufferData(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; void* arg1; uint32_t arg2; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr( cx, args.get(1), &count, &arg1); + ok &= jsval_to_uint32( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glBufferData((GLenum)arg0 , count, (GLvoid*)arg1 , (GLenum)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLintptr, ArrayBufferView +// Ret value: void +bool JSB_glBufferSubData(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; int32_t arg1; void* arg2; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr( cx, args.get(2), &count, &arg2); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glBufferSubData((GLenum)arg0 , (GLintptr)arg1 , count, (GLvoid*)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum +// Ret value: GLenum +bool JSB_glCheckFramebufferStatus(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + GLenum ret_val; + + ret_val = glCheckFramebufferStatus((GLenum)arg0 ); + args.rval().set(UINT_TO_JSVAL((uint32_t)ret_val)); + return true; +} + +// Arguments: GLbitfield +// Ret value: void +bool JSB_glClear(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glClear((GLbitfield)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLclampf, GLclampf, GLclampf, GLclampf +// Ret value: void +bool JSB_glClearColor(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + ok &= jsval_to_int32( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glClearColor((GLclampf)arg0 , (GLclampf)arg1 , (GLclampf)arg2 , (GLclampf)arg3 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLclampf +// Ret value: void +bool JSB_glClearDepthf(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glClearDepthf((GLclampf)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint +// Ret value: void +bool JSB_glClearStencil(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glClearStencil((GLint)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLboolean, GLboolean, GLboolean, GLboolean +// Ret value: void +bool JSB_glColorMask(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint16_t arg0; uint16_t arg1; uint16_t arg2; uint16_t arg3; + + ok &= jsval_to_uint16( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint16( cx, args.get(1), &arg1 ); + ok &= jsval_to_uint16( cx, args.get(2), &arg2 ); + ok &= jsval_to_uint16( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glColorMask((GLboolean)arg0 , (GLboolean)arg1 , (GLboolean)arg2 , (GLboolean)arg3 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint +// Ret value: void +bool JSB_glCompileShader(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glCompileShader((GLuint)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, ArrayBufferView +// Ret value: void +bool JSB_glCompressedTexImage2D(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 8, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; int32_t arg1; uint32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; int32_t arg6; void* arg7; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_uint32( cx, args.get(2), &arg2 ); + ok &= jsval_to_int32( cx, args.get(3), &arg3 ); + ok &= jsval_to_int32( cx, args.get(4), &arg4 ); + ok &= jsval_to_int32( cx, args.get(5), &arg5 ); + ok &= jsval_to_int32( cx, args.get(6), &arg6 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr( cx, args.get(7), &count, &arg7); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glCompressedTexImage2D((GLenum)arg0 , (GLint)arg1 , (GLenum)arg2 , (GLsizei)arg3 , (GLsizei)arg4 , (GLint)arg5 , (GLsizei)arg6 , (GLvoid*)arg7 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, ArrayBufferView +// Ret value: void +bool JSB_glCompressedTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 9, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; uint32_t arg6; int32_t arg7; void* arg8; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + ok &= jsval_to_int32( cx, args.get(3), &arg3 ); + ok &= jsval_to_int32( cx, args.get(4), &arg4 ); + ok &= jsval_to_int32( cx, args.get(5), &arg5 ); + ok &= jsval_to_uint32( cx, args.get(6), &arg6 ); + ok &= jsval_to_int32( cx, args.get(7), &arg7 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr( cx, args.get(8), &count, &arg8); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glCompressedTexSubImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLsizei)arg4 , (GLsizei)arg5 , (GLenum)arg6 , (GLsizei)arg7 , (GLvoid*)arg8 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint +// Ret value: void +bool JSB_glCopyTexImage2D(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 8, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; int32_t arg1; uint32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; int32_t arg6; int32_t arg7; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_uint32( cx, args.get(2), &arg2 ); + ok &= jsval_to_int32( cx, args.get(3), &arg3 ); + ok &= jsval_to_int32( cx, args.get(4), &arg4 ); + ok &= jsval_to_int32( cx, args.get(5), &arg5 ); + ok &= jsval_to_int32( cx, args.get(6), &arg6 ); + ok &= jsval_to_int32( cx, args.get(7), &arg7 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glCopyTexImage2D((GLenum)arg0 , (GLint)arg1 , (GLenum)arg2 , (GLint)arg3 , (GLint)arg4 , (GLsizei)arg5 , (GLsizei)arg6 , (GLint)arg7 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei +// Ret value: void +bool JSB_glCopyTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 8, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; int32_t arg6; int32_t arg7; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + ok &= jsval_to_int32( cx, args.get(3), &arg3 ); + ok &= jsval_to_int32( cx, args.get(4), &arg4 ); + ok &= jsval_to_int32( cx, args.get(5), &arg5 ); + ok &= jsval_to_int32( cx, args.get(6), &arg6 ); + ok &= jsval_to_int32( cx, args.get(7), &arg7 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glCopyTexSubImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLint)arg4 , (GLint)arg5 , (GLsizei)arg6 , (GLsizei)arg7 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: +// Ret value: GLuint +bool JSB_glCreateProgram(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + GLuint ret_val; + + ret_val = glCreateProgram( ); + args.rval().set(UINT_TO_JSVAL((uint32_t)ret_val)); + return true; +} + +// Arguments: GLenum +// Ret value: GLuint +bool JSB_glCreateShader(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + GLuint ret_val; + + ret_val = glCreateShader((GLenum)arg0 ); + args.rval().set(UINT_TO_JSVAL((uint32_t)ret_val)); + return true; +} + +// Arguments: GLenum +// Ret value: void +bool JSB_glCullFace(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glCullFace((GLenum)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint +// Ret value: void +bool JSB_glDeleteProgram(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glDeleteProgram((GLuint)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint +// Ret value: void +bool JSB_glDeleteShader(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glDeleteShader((GLuint)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum +// Ret value: void +bool JSB_glDepthFunc(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glDepthFunc((GLenum)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLboolean +// Ret value: void +bool JSB_glDepthMask(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint16_t arg0; + + ok &= jsval_to_uint16( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glDepthMask((GLboolean)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLclampf, GLclampf +// Ret value: void +bool JSB_glDepthRangef(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glDepthRangef((GLclampf)arg0 , (GLclampf)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint, GLuint +// Ret value: void +bool JSB_glDetachShader(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glDetachShader((GLuint)arg0 , (GLuint)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum +// Ret value: void +bool JSB_glDisable(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glDisable((GLenum)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint +// Ret value: void +bool JSB_glDisableVertexAttribArray(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glDisableVertexAttribArray((GLuint)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLint, GLsizei +// Ret value: void +bool JSB_glDrawArrays(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; int32_t arg1; int32_t arg2; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glDrawArrays((GLenum)arg0 , (GLint)arg1 , (GLsizei)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLsizei, GLenum, ArrayBufferView +// Ret value: void +bool JSB_glDrawElements(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; int32_t arg1; uint32_t arg2; void* arg3; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_uint32( cx, args.get(2), &arg2 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr( cx, args.get(3), &count, &arg3); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glDrawElements((GLenum)arg0 , (GLsizei)arg1 , (GLenum)arg2 , (GLvoid*)arg3 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum +// Ret value: void +bool JSB_glEnable(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glEnable((GLenum)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint +// Ret value: void +bool JSB_glEnableVertexAttribArray(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glEnableVertexAttribArray((GLuint)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: +// Ret value: void +bool JSB_glFinish(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + glFinish( ); + args.rval().setUndefined(); + return true; +} + +// Arguments: +// Ret value: void +bool JSB_glFlush(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + glFlush( ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLenum, GLenum, GLuint +// Ret value: void +bool JSB_glFramebufferRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + ok &= jsval_to_uint32( cx, args.get(2), &arg2 ); + ok &= jsval_to_uint32( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glFramebufferRenderbuffer((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLuint)arg3 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLenum, GLenum, GLuint, GLint +// Ret value: void +bool JSB_glFramebufferTexture2D(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 5, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; int32_t arg4; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + ok &= jsval_to_uint32( cx, args.get(2), &arg2 ); + ok &= jsval_to_uint32( cx, args.get(3), &arg3 ); + ok &= jsval_to_int32( cx, args.get(4), &arg4 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glFramebufferTexture2D((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLuint)arg3 , (GLint)arg4 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum +// Ret value: void +bool JSB_glFrontFace(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glFrontFace((GLenum)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum +// Ret value: void +bool JSB_glGenerateMipmap(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glGenerateMipmap((GLenum)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint, char* +// Ret value: int +bool JSB_glGetAttribLocation(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; const char* arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_charptr( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + int ret_val; + + ret_val = glGetAttribLocation((GLuint)arg0 , (char*)arg1 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: +// Ret value: GLenum +bool JSB_glGetError(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + GLenum ret_val; + + ret_val = glGetError( ); + args.rval().set(UINT_TO_JSVAL((uint32_t)ret_val)); + return true; +} + +// Arguments: GLuint, char* +// Ret value: int +bool JSB_glGetUniformLocation(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; const char* arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_charptr( cx, args.get(1), &arg1 ); + printf("%s ", arg1); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + int ret_val; + + ret_val = glGetUniformLocation((GLuint)arg0 , (char*)arg1 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: GLenum, GLenum +// Ret value: void +bool JSB_glHint(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glHint((GLenum)arg0 , (GLenum)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint +// Ret value: GLboolean +bool JSB_glIsBuffer(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsBuffer((GLuint)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: GLenum +// Ret value: GLboolean +bool JSB_glIsEnabled(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsEnabled((GLenum)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: GLuint +// Ret value: GLboolean +bool JSB_glIsFramebuffer(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsFramebuffer((GLuint)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: GLuint +// Ret value: GLboolean +bool JSB_glIsProgram(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsProgram((GLuint)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: GLuint +// Ret value: GLboolean +bool JSB_glIsRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsRenderbuffer((GLuint)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: GLuint +// Ret value: GLboolean +bool JSB_glIsShader(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsShader((GLuint)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: GLuint +// Ret value: GLboolean +bool JSB_glIsTexture(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsTexture((GLuint)arg0 ); + args.rval().set(INT_TO_JSVAL((int32_t)ret_val)); + return true; +} + +// Arguments: GLfloat +// Ret value: void +bool JSB_glLineWidth(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glLineWidth((GLfloat)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint +// Ret value: void +bool JSB_glLinkProgram(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glLinkProgram((GLuint)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLint +// Ret value: void +bool JSB_glPixelStorei(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; int32_t arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glPixelStorei((GLenum)arg0 , (GLint)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLfloat, GLfloat +// Ret value: void +bool JSB_glPolygonOffset(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glPolygonOffset((GLfloat)arg0 , (GLfloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, ArrayBufferView +// Ret value: void +bool JSB_glReadPixels(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 7, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; uint32_t arg4; uint32_t arg5; void* arg6; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + ok &= jsval_to_int32( cx, args.get(3), &arg3 ); + ok &= jsval_to_uint32( cx, args.get(4), &arg4 ); + ok &= jsval_to_uint32( cx, args.get(5), &arg5 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr( cx, args.get(6), &count, &arg6); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glReadPixels((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 , (GLenum)arg4 , (GLenum)arg5 , (GLvoid*)arg6 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: +// Ret value: void +bool JSB_glReleaseShaderCompiler(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + glReleaseShaderCompiler( ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLenum, GLsizei, GLsizei +// Ret value: void +bool JSB_glRenderbufferStorage(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; int32_t arg2; int32_t arg3; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + ok &= jsval_to_int32( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glRenderbufferStorage((GLenum)arg0 , (GLenum)arg1 , (GLsizei)arg2 , (GLsizei)arg3 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLclampf, GLboolean +// Ret value: void +bool JSB_glSampleCoverage(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; uint16_t arg1; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint16( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glSampleCoverage((GLclampf)arg0 , (GLboolean)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLint, GLsizei, GLsizei +// Ret value: void +bool JSB_glScissor(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + ok &= jsval_to_int32( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glScissor((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLint, GLuint +// Ret value: void +bool JSB_glStencilFunc(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; int32_t arg1; uint32_t arg2; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_uint32( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glStencilFunc((GLenum)arg0 , (GLint)arg1 , (GLuint)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLenum, GLint, GLuint +// Ret value: void +bool JSB_glStencilFuncSeparate(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; int32_t arg2; uint32_t arg3; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + ok &= jsval_to_uint32( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glStencilFuncSeparate((GLenum)arg0 , (GLenum)arg1 , (GLint)arg2 , (GLuint)arg3 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint +// Ret value: void +bool JSB_glStencilMask(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glStencilMask((GLuint)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLuint +// Ret value: void +bool JSB_glStencilMaskSeparate(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glStencilMaskSeparate((GLenum)arg0 , (GLuint)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLenum, GLenum +// Ret value: void +bool JSB_glStencilOp(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; uint32_t arg2; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + ok &= jsval_to_uint32( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glStencilOp((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLenum, GLenum, GLenum +// Ret value: void +bool JSB_glStencilOpSeparate(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + ok &= jsval_to_uint32( cx, args.get(2), &arg2 ); + ok &= jsval_to_uint32( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glStencilOpSeparate((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLenum)arg3 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, ArrayBufferView +// Ret value: void +bool JSB_glTexImage2D(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 9, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; uint32_t arg6; uint32_t arg7; void* arg8; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + ok &= jsval_to_int32( cx, args.get(3), &arg3 ); + ok &= jsval_to_int32( cx, args.get(4), &arg4 ); + ok &= jsval_to_int32( cx, args.get(5), &arg5 ); + ok &= jsval_to_uint32( cx, args.get(6), &arg6 ); + ok &= jsval_to_uint32( cx, args.get(7), &arg7 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr( cx, args.get(8), &count, &arg8); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glTexImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLsizei)arg3 , (GLsizei)arg4 , (GLint)arg5 , (GLenum)arg6 , (GLenum)arg7 , (GLvoid*)arg8 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLenum, GLfloat +// Ret value: void +bool JSB_glTexParameterf(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; int32_t arg2; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glTexParameterf((GLenum)arg0 , (GLenum)arg1 , (GLfloat)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLenum, GLint +// Ret value: void +bool JSB_glTexParameteri(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; uint32_t arg1; int32_t arg2; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glTexParameteri((GLenum)arg0 , (GLenum)arg1 , (GLint)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, ArrayBufferView +// Ret value: void +bool JSB_glTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 9, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; uint32_t arg6; uint32_t arg7; void* arg8; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + ok &= jsval_to_int32( cx, args.get(3), &arg3 ); + ok &= jsval_to_int32( cx, args.get(4), &arg4 ); + ok &= jsval_to_int32( cx, args.get(5), &arg5 ); + ok &= jsval_to_uint32( cx, args.get(6), &arg6 ); + ok &= jsval_to_uint32( cx, args.get(7), &arg7 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr( cx, args.get(8), &count, &arg8); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glTexSubImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLsizei)arg4 , (GLsizei)arg5 , (GLenum)arg6 , (GLenum)arg7 , (GLvoid*)arg8 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLfloat +// Ret value: void +bool JSB_glUniform1f(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUniform1f((GLint)arg0 , (GLfloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +bool JSB_glUniform1fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; void* arg2; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, args.get(2), &count, &arg2, js::Scalar::Float32); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUniform1fv((GLint)arg0 , (GLsizei)arg1 , (GLfloat*)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLint +// Ret value: void +bool JSB_glUniform1i(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUniform1i((GLint)arg0 , (GLint)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +bool JSB_glUniform1iv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; void* arg2; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, args.get(2), &count, &arg2, js::Scalar::Int32); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUniform1iv((GLint)arg0 , (GLsizei)arg1 , (GLint*)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLfloat, GLfloat +// Ret value: void +bool JSB_glUniform2f(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUniform2f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +bool JSB_glUniform2fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; void* arg2; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, args.get(2), &count, &arg2, js::Scalar::Float32); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUniform2fv((GLint)arg0 , (GLsizei)arg1 , (GLfloat*)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLint, GLint +// Ret value: void +bool JSB_glUniform2i(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUniform2i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +bool JSB_glUniform2iv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; void* arg2; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, args.get(2), &count, &arg2, js::Scalar::Int32); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUniform2iv((GLint)arg0 , (GLsizei)arg1 , (GLint*)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLfloat, GLfloat, GLfloat +// Ret value: void +bool JSB_glUniform3f(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + ok &= jsval_to_int32( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUniform3f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +bool JSB_glUniform3fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; void* arg2; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, args.get(2), &count, &arg2, js::Scalar::Float32); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUniform3fv((GLint)arg0 , (GLsizei)arg1 , (GLfloat*)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLint, GLint, GLint +// Ret value: void +bool JSB_glUniform3i(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + ok &= jsval_to_int32( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUniform3i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +bool JSB_glUniform3iv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; void* arg2; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, args.get(2), &count, &arg2, js::Scalar::Int32); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUniform3iv((GLint)arg0 , (GLsizei)arg1 , (GLint*)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLfloat, GLfloat, GLfloat, GLfloat +// Ret value: void +bool JSB_glUniform4f(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 5, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + ok &= jsval_to_int32( cx, args.get(3), &arg3 ); + ok &= jsval_to_int32( cx, args.get(4), &arg4 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUniform4f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 , (GLfloat)arg4 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +bool JSB_glUniform4fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; void* arg2; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, args.get(2), &count, &arg2, js::Scalar::Float32); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUniform4fv((GLint)arg0 , (GLsizei)arg1 , (GLfloat*)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLint, GLint, GLint, GLint +// Ret value: void +bool JSB_glUniform4i(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 5, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + ok &= jsval_to_int32( cx, args.get(3), &arg3 ); + ok &= jsval_to_int32( cx, args.get(4), &arg4 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUniform4i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLint)arg4 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +bool JSB_glUniform4iv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; void* arg2; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, args.get(2), &count, &arg2, js::Scalar::Int32); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUniform4iv((GLint)arg0 , (GLsizei)arg1 , (GLint*)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLboolean, TypedArray/Sequence +// Ret value: void +bool JSB_glUniformMatrix2fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; uint16_t arg1; void* arg2; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint16( cx, args.get(1), &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, args.get(2), &count, &arg2, js::Scalar::Float32); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUniformMatrix2fv(arg0, 1, (GLboolean)arg1 , (GLfloat*)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLboolean, TypedArray/Sequence +// Ret value: void +bool JSB_glUniformMatrix3fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; uint16_t arg1; void* arg2; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint16( cx, args.get(1), &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, args.get(2), &count, &arg2, js::Scalar::Float32); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUniformMatrix3fv(arg0, 1, (GLboolean)arg1 , (GLfloat*)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLboolean, TypedArray/Sequence +// Ret value: void +bool JSB_glUniformMatrix4fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; uint16_t arg1; void* arg2; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint16( cx, args.get(1), &arg1 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, args.get(2), &count, &arg2, js::Scalar::Float32); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUniformMatrix4fv(arg0, 1, (GLboolean)arg1 , (GLfloat*)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint +// Ret value: void +bool JSB_glUseProgram(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glUseProgram((GLuint)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint +// Ret value: void +bool JSB_glValidateProgram(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glValidateProgram((GLuint)arg0 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint, GLfloat +// Ret value: void +bool JSB_glVertexAttrib1f(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; int32_t arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glVertexAttrib1f((GLuint)arg0 , (GLfloat)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint, TypedArray/Sequence +// Ret value: void +bool JSB_glVertexAttrib1fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; void* arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, args.get(1), &count, &arg1, js::Scalar::Float32); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glVertexAttrib1fv((GLuint)arg0 , (GLfloat*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint, GLfloat, GLfloat +// Ret value: void +bool JSB_glVertexAttrib2f(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 3, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; int32_t arg1; int32_t arg2; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glVertexAttrib2f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint, TypedArray/Sequence +// Ret value: void +bool JSB_glVertexAttrib2fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; void* arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, args.get(1), &count, &arg1, js::Scalar::Float32); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glVertexAttrib2fv((GLuint)arg0 , (GLfloat*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint, GLfloat, GLfloat, GLfloat +// Ret value: void +bool JSB_glVertexAttrib3f(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + ok &= jsval_to_int32( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glVertexAttrib3f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint, TypedArray/Sequence +// Ret value: void +bool JSB_glVertexAttrib3fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; void* arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, args.get(1), &count, &arg1, js::Scalar::Float32); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glVertexAttrib3fv((GLuint)arg0 , (GLfloat*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint, GLfloat, GLfloat, GLfloat, GLfloat +// Ret value: void +bool JSB_glVertexAttrib4f(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 5, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + ok &= jsval_to_int32( cx, args.get(3), &arg3 ); + ok &= jsval_to_int32( cx, args.get(4), &arg4 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glVertexAttrib4f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 , (GLfloat)arg4 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint, TypedArray/Sequence +// Ret value: void +bool JSB_glVertexAttrib4fv(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; void* arg1; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + GLsizei count; + ok &= JSB_jsval_typedarray_to_dataptr( cx, args.get(1), &count, &arg1, js::Scalar::Float32); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glVertexAttrib4fv((GLuint)arg0 , (GLfloat*)arg1 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLuint, GLint, GLenum, GLboolean, GLsizei, GLvoid* +// Ret value: void +bool JSB_glVertexAttribPointer(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 6, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; int32_t arg1; uint32_t arg2; uint16_t arg3; int32_t arg4; int32_t arg5; + + ok &= jsval_to_uint32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_uint32( cx, args.get(2), &arg2 ); + ok &= jsval_to_uint16( cx, args.get(3), &arg3 ); + ok &= jsval_to_int32( cx, args.get(4), &arg4 ); + ok &= jsval_to_int32( cx, args.get(5), &arg5 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glVertexAttribPointer((GLuint)arg0 , (GLint)arg1 , (GLenum)arg2 , (GLboolean)arg3 , (GLsizei)arg4 , (GLvoid*)arg5 ); + args.rval().setUndefined(); + return true; +} + +// Arguments: GLint, GLint, GLsizei, GLsizei +// Ret value: void +bool JSB_glViewport(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 4, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= jsval_to_int32( cx, args.get(0), &arg0 ); + ok &= jsval_to_int32( cx, args.get(1), &arg1 ); + ok &= jsval_to_int32( cx, args.get(2), &arg2 ); + ok &= jsval_to_int32( cx, args.get(3), &arg3 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glViewport((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 ); + args.rval().setUndefined(); + return true; +} + + +#endif // JSB_INCLUDE_OPENGL diff --git a/cocos/scripting/js-bindings/manual/jsb_opengl_functions.h b/cocos/scripting/js-bindings/manual/jsb_opengl_functions.h new file mode 100644 index 0000000000..9a4449a7bb --- /dev/null +++ b/cocos/scripting/js-bindings/manual/jsb_opengl_functions.h @@ -0,0 +1,144 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_jsb.py -c opengl_jsb.ini" on 2013-03-05 +* Script version: v0.6 +*/ +#include "js_bindings_config.h" +#ifdef JSB_INCLUDE_OPENGL + +#include "jsb_opengl_manual.h" + +extern "C" { + +bool JSB_glActiveTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glAttachShader(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glBindAttribLocation(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glBindBuffer(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glBindFramebuffer(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glBindRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glBindTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glBlendColor(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glBlendEquation(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glBlendEquationSeparate(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glBlendFuncSeparate(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glBufferData(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glBufferSubData(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glCheckFramebufferStatus(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glClear(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glClearColor(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glClearDepthf(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glClearStencil(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glColorMask(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glCompileShader(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glCompressedTexImage2D(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glCompressedTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glCopyTexImage2D(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glCopyTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glCreateProgram(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glCreateShader(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glCullFace(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glDeleteBuffers(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glDeleteFramebuffers(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glDeleteProgram(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glDeleteRenderbuffers(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glDeleteShader(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glDeleteTextures(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glDepthFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glDepthMask(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glDepthRangef(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glDetachShader(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glDisable(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glDisableVertexAttribArray(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glDrawArrays(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glDrawElements(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glEnable(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glEnableVertexAttribArray(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glFinish(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glFlush(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glFramebufferRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glFramebufferTexture2D(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glFrontFace(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glGenBuffers(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glGenFramebuffers(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glGenRenderbuffers(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glGenTextures(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glGenerateMipmap(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glGetActiveAttrib(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glGetActiveUniform(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glGetAttachedShaders(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glGetAttribLocation(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glGetError(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glGetProgramInfoLog(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glGetProgramiv(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glGetShaderInfoLog(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glGetShaderSource(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glGetShaderiv(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glGetTexParameterfv(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glGetUniformLocation(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glGetUniformfv(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glHint(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glIsBuffer(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glIsEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glIsFramebuffer(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glIsProgram(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glIsRenderbuffer(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glIsShader(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glIsTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glLineWidth(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glLinkProgram(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glPixelStorei(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glPolygonOffset(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glReadPixels(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glReleaseShaderCompiler(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glRenderbufferStorage(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glSampleCoverage(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glScissor(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glShaderSource(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glStencilFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glStencilFuncSeparate(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glStencilMask(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glStencilMaskSeparate(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glStencilOp(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glStencilOpSeparate(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glTexImage2D(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glTexParameterf(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glTexParameteri(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glTexSubImage2D(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUniform1f(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUniform1fv(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUniform1i(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUniform1iv(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUniform2f(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUniform2fv(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUniform2i(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUniform2iv(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUniform3f(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUniform3fv(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUniform3i(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUniform3iv(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUniform4f(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUniform4fv(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUniform4i(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUniform4iv(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUniformMatrix2fv(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUniformMatrix3fv(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUniformMatrix4fv(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glUseProgram(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glValidateProgram(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glVertexAttrib1f(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glVertexAttrib1fv(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glVertexAttrib2f(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glVertexAttrib2fv(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glVertexAttrib3f(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glVertexAttrib3fv(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glVertexAttrib4f(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glVertexAttrib4fv(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glVertexAttribPointer(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_glViewport(JSContext *cx, uint32_t argc, jsval *vp); + +} + + + +#endif // JSB_INCLUDE_OPENGL diff --git a/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp b/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp new file mode 100644 index 0000000000..0da5d5af9f --- /dev/null +++ b/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp @@ -0,0 +1,529 @@ +/* + * Copyright (c) 2013 Zynga Inc. + * 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. + */ + +#include "js_bindings_config.h" +#ifdef JSB_INCLUDE_OPENGL + +#include "jsb_opengl_manual.h" +#include "js_manual_conversions.h" +#include "js_bindings_core.h" +#include "jsb_opengl_functions.h" + + +// Helper functions that link "glGenXXXs" (OpenGL ES 2.0 spec), with "gl.createXXX" (WebGL spec) +bool JSB_glGenTextures(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + GLuint texture; + glGenTextures(1, &texture); + + args.rval().set(INT_TO_JSVAL(texture)); + return true; +} + +bool JSB_glGenBuffers(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + GLuint buffer; + glGenBuffers(1, &buffer); + args.rval().set(INT_TO_JSVAL(buffer)); + return true; +} + +bool JSB_glGenRenderbuffers(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + GLuint renderbuffers; + glGenRenderbuffers(1, &renderbuffers); + args.rval().set(INT_TO_JSVAL(renderbuffers)); + return true; +} + +bool JSB_glGenFramebuffers(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + GLuint framebuffers; + glGenFramebuffers(1, &framebuffers); + args.rval().set(INT_TO_JSVAL(framebuffers)); + return true; +} + +bool JSB_glDeleteTextures(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glDeleteTextures(1, &arg0); + args.rval().set(JSVAL_VOID); + return true; +} + +bool JSB_glDeleteBuffers(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glDeleteBuffers(1, &arg0); + args.rval().set(JSVAL_VOID); + return true; +} + +bool JSB_glDeleteRenderbuffers(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glDeleteRenderbuffers(1, &arg0); + args.rval().set(JSVAL_VOID); + return true; +} + +bool JSB_glDeleteFramebuffers(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glDeleteFramebuffers(1, &arg0); + args.rval().set(JSVAL_VOID); + return true; +} + +bool JSB_glShaderSource(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; const char *arg1; + + ok &= jsval_to_uint( cx, args.get(0), &arg0 ); + ok &= jsval_to_charptr(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + glShaderSource(arg0, 1, &arg1, NULL); + args.rval().set(JSVAL_VOID); + return true; +} + +bool JSB_glGetShaderiv(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0, arg1; + + ok &= jsval_to_uint( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + GLint ret; + glGetShaderiv(arg0, arg1, &ret); + args.rval().set(INT_TO_JSVAL(ret)); + return true; +} + +bool JSB_glGetProgramiv(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0, arg1; + + ok &= jsval_to_uint( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + GLint ret; + glGetProgramiv(arg0, arg1, &ret); + args.rval().set(INT_TO_JSVAL(ret)); + return true; +} + +bool JSB_glGetProgramInfoLog(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + GLsizei length; + glGetProgramiv(arg0, GL_INFO_LOG_LENGTH, &length); + GLchar* src = new GLchar[length]; + glGetProgramInfoLog(arg0, length, NULL, src); + + args.rval().set(charptr_to_jsval(cx, src)); + CC_SAFE_DELETE_ARRAY(src); + return true; +} + +// DOMString? getShaderInfoLog(WebGLShader? shader); +bool JSB_glGetShaderInfoLog(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + GLsizei length; + glGetShaderiv(arg0, GL_INFO_LOG_LENGTH, &length); + GLchar* src = new GLchar[length]; + glGetShaderInfoLog(arg0, length, NULL, src); + + args.rval().set(charptr_to_jsval(cx, src)); + CC_SAFE_DELETE_ARRAY(src); + return true; +} + +// DOMString? getShaderSource(WebGLShader? shader); +bool JSB_glGetShaderSource(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + GLsizei length; + glGetShaderiv(arg0, GL_SHADER_SOURCE_LENGTH, &length); + GLchar* src = new GLchar[length]; + glGetShaderSource(arg0, length, NULL, src); + + args.rval().set(charptr_to_jsval(cx, src)); + CC_SAFE_DELETE_ARRAY(src); + return true; +} + +// interface WebGLActiveInfo { +// readonly attribute GLint size; +// readonly attribute GLenum type; +// readonly attribute DOMString name; +// WebGLActiveInfo? getActiveAttrib(WebGLProgram? program, GLuint index); +bool JSB_glGetActiveAttrib(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0, arg1; + + ok &= jsval_to_uint( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + GLsizei length; + glGetProgramiv(arg0, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length); + GLchar* buffer = new GLchar[length]; + GLint size = -1; + GLenum type = -1; + + glGetActiveAttrib(arg0, arg1, length, NULL, &size, &type, buffer); + + jsval retval = JSVAL_VOID; + + JS::RootedObject object(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr() )); + JSB_PRECONDITION2(ok, cx, false, "Error creating JS Object"); + + if (!JS_DefineProperty(cx, object, "size", (int32_t)size, JSPROP_ENUMERATE | JSPROP_PERMANENT) || + !JS_DefineProperty(cx, object, "type", (int32_t)type, JSPROP_ENUMERATE | JSPROP_PERMANENT) || + !JS_DefineProperty(cx, object, "name", JS::RootedValue(cx, charptr_to_jsval(cx, buffer)), JSPROP_ENUMERATE | JSPROP_PERMANENT) ) + return false; + + retval = OBJECT_TO_JSVAL(object); + + args.rval().set(retval); + CC_SAFE_DELETE_ARRAY(buffer); + return true; +} + + +// interface WebGLActiveInfo { +// readonly attribute GLint size; +// readonly attribute GLenum type; +// readonly attribute DOMString name; +// }; +// WebGLActiveInfo? getActiveUniform(WebGLProgram? program, GLuint index); +bool JSB_glGetActiveUniform(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0, arg1; + + ok &= jsval_to_uint( cx, args.get(0), &arg0 ); + ok &= jsval_to_uint( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + GLsizei length; + glGetProgramiv(arg0, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length); + GLchar* buffer = new GLchar[length]; + GLint size = -1; + GLenum type = -1; + + glGetActiveUniform(arg0, arg1, length, NULL, &size, &type, buffer); + + jsval retval = JSVAL_VOID; + + + JS::RootedObject object(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr() )); + JSB_PRECONDITION2(ok, cx, false, "Error creating JS Object"); + + if (!JS_DefineProperty(cx, object, "size", (int32_t)size, JSPROP_ENUMERATE | JSPROP_PERMANENT) || + !JS_DefineProperty(cx, object, "type", (int32_t)type, JSPROP_ENUMERATE | JSPROP_PERMANENT) || + !JS_DefineProperty(cx, object, "name", JS::RootedValue(cx, charptr_to_jsval(cx, buffer)), JSPROP_ENUMERATE | JSPROP_PERMANENT) ) + return false; + + retval = OBJECT_TO_JSVAL(object); + + args.rval().set(retval); + CC_SAFE_DELETE_ARRAY(buffer); + return true; +} + +// sequence? getAttachedShaders(WebGLProgram? program); +bool JSB_glGetAttachedShaders(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + uint32_t arg0; + + ok &= jsval_to_uint( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + GLsizei length; + glGetProgramiv(arg0, GL_ATTACHED_SHADERS, &length); + GLuint* buffer = new GLuint[length]; + memset(buffer, 0, length * sizeof(GLuint)); + //Fix bug 2448, it seems that glGetAttachedShaders will crash if we send NULL to the third parameter (eg Windows), same as in lua binding + GLsizei realShaderCount = 0; + glGetAttachedShaders(arg0, length, &realShaderCount, buffer); + + JS::RootedObject jsobj(cx, JS_NewArrayObject(cx, length)); + JSB_PRECONDITION2(jsobj, cx, false, "Error creating JS Object"); + + for( int i=0; i? getSupportedExtensions(); +bool JSB_glGetSupportedExtensions(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + const GLubyte *extensions = glGetString(GL_EXTENSIONS); + + JS::RootedObject jsobj(cx, JS_NewArrayObject(cx, 0)); + JSB_PRECONDITION2(jsobj, cx, false, "Error creating JS Object"); + + // copy, to be able to add '\0' + size_t len = strlen((char*)extensions); + GLubyte* copy = new GLubyte[len+1]; + strncpy((char*)copy, (const char*)extensions, len ); + + int start_extension=0; + int element=0; + for( size_t i=0; i +#include "jsapi.h" +#include "jsfriendapi.h" + +#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED +#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) + +// compatible with iOS +#define glClearDepthf glClearDepth +#define glDepthRangef glDepthRange +#ifndef glReleaseShaderCompiler + #define glReleaseShaderCompiler() +#endif + +#endif // __MAC_OS_X_VERSION_MAX_ALLOWED + +// forward declaration of new functions +bool JSB_glGetSupportedExtensions(JSContext *cx, uint32_t argc, jsval *vp); + + +#endif // JSB_INCLUDE_OPENGL + +#endif // __jsb_opengl_manual diff --git a/cocos/scripting/js-bindings/manual/jsb_opengl_registration.cpp b/cocos/scripting/js-bindings/manual/jsb_opengl_registration.cpp new file mode 100644 index 0000000000..aa1d7e815d --- /dev/null +++ b/cocos/scripting/js-bindings/manual/jsb_opengl_registration.cpp @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2012 Zynga Inc. + * 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. + */ + +#include "js_bindings_config.h" +#include "js_bindings_core.h" +#include "jsfriendapi.h" +#include "cocos2d_specifics.hpp" +#include "jsb_opengl_manual.h" +#include "js_bindings_opengl.h" + +//#include "jsb_opengl_functions_registration.h" + +// system +#include "jsb_opengl_functions.h" + +void JSB_register_opengl(JSContext *_cx, JS::HandleObject object) +{ + // + // gl + // + JS::RootedObject opengl(_cx, JS_NewObject(_cx, NULL, JS::NullPtr(), JS::NullPtr())); + + JS::RootedValue openglVal(_cx); + openglVal = OBJECT_TO_JSVAL(opengl); + JS_SetProperty(_cx, object, "gl", openglVal); + + JS::RootedObject ccns(_cx); + get_or_create_js_obj(_cx, object, "cc", &ccns); + + js_register_cocos2dx_GLNode(_cx, ccns); + + // New WebGL functions, not present on OpenGL ES 2.0 + JS_DefineFunction(_cx, opengl, "getSupportedExtensions", JSB_glGetSupportedExtensions, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "activeTexture", JSB_glActiveTexture, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_attachShader", JSB_glAttachShader, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_bindAttribLocation", JSB_glBindAttribLocation, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_bindBuffer", JSB_glBindBuffer, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_bindFramebuffer", JSB_glBindFramebuffer, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_bindRenderbuffer", JSB_glBindRenderbuffer, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_bindTexture", JSB_glBindTexture, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "blendColor", JSB_glBlendColor, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "blendEquation", JSB_glBlendEquation, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "blendEquationSeparate", JSB_glBlendEquationSeparate, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "blendFunc", JSB_glBlendFunc, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "blendFuncSeparate", JSB_glBlendFuncSeparate, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "bufferData", JSB_glBufferData, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "bufferSubData", JSB_glBufferSubData, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "checkFramebufferStatus", JSB_glCheckFramebufferStatus, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "clear", JSB_glClear, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "clearColor", JSB_glClearColor, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "clearDepthf", JSB_glClearDepthf, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "clearStencil", JSB_glClearStencil, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "colorMask", JSB_glColorMask, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_compileShader", JSB_glCompileShader, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "compressedTexImage2D", JSB_glCompressedTexImage2D, 8, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "compressedTexSubImage2D", JSB_glCompressedTexSubImage2D, 9, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "copyTexImage2D", JSB_glCopyTexImage2D, 8, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "copyTexSubImage2D", JSB_glCopyTexSubImage2D, 8, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_createProgram", JSB_glCreateProgram, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_createShader", JSB_glCreateShader, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "cullFace", JSB_glCullFace, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_deleteBuffer", JSB_glDeleteBuffers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_deleteFramebuffer", JSB_glDeleteFramebuffers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_deleteProgram", JSB_glDeleteProgram, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_deleteRenderbuffer", JSB_glDeleteRenderbuffers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_deleteShader", JSB_glDeleteShader, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_deleteTexture", JSB_glDeleteTextures, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "depthFunc", JSB_glDepthFunc, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "depthMask", JSB_glDepthMask, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "depthRangef", JSB_glDepthRangef, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "detachShader", JSB_glDetachShader, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "disable", JSB_glDisable, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "disableVertexAttribArray", JSB_glDisableVertexAttribArray, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "drawArrays", JSB_glDrawArrays, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "drawElements", JSB_glDrawElements, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "enable", JSB_glEnable, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "enableVertexAttribArray", JSB_glEnableVertexAttribArray, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "finish", JSB_glFinish, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "flush", JSB_glFlush, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "framebufferRenderbuffer", JSB_glFramebufferRenderbuffer, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "framebufferTexture2D", JSB_glFramebufferTexture2D, 5, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "frontFace", JSB_glFrontFace, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_createBuffer", JSB_glGenBuffers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_createFramebuffer", JSB_glGenFramebuffers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_createRenderbuffer", JSB_glGenRenderbuffers, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_createTexture", JSB_glGenTextures, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "generateMipmap", JSB_glGenerateMipmap, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getActiveAttrib", JSB_glGetActiveAttrib, 7, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getActiveUniform", JSB_glGetActiveUniform, 7, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getAttachedShaders", JSB_glGetAttachedShaders, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getAttribLocation", JSB_glGetAttribLocation, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "getError", JSB_glGetError, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getProgramInfoLog", JSB_glGetProgramInfoLog, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getProgramParameter", JSB_glGetProgramiv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getShaderInfoLog", JSB_glGetShaderInfoLog, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getShaderSource", JSB_glGetShaderSource, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getShaderParameter", JSB_glGetShaderiv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "getTexParameter", JSB_glGetTexParameterfv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getUniformLocation", JSB_glGetUniformLocation, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_getUniform", JSB_glGetUniformfv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "hint", JSB_glHint, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "isBuffer", JSB_glIsBuffer, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "isEnabled", JSB_glIsEnabled, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "isFramebuffer", JSB_glIsFramebuffer, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "isProgram", JSB_glIsProgram, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "isRenderbuffer", JSB_glIsRenderbuffer, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "isShader", JSB_glIsShader, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "isTexture", JSB_glIsTexture, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "lineWidth", JSB_glLineWidth, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_linkProgram", JSB_glLinkProgram, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "pixelStorei", JSB_glPixelStorei, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "polygonOffset", JSB_glPolygonOffset, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "readPixels", JSB_glReadPixels, 7, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "releaseShaderCompiler", JSB_glReleaseShaderCompiler, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "renderbufferStorage", JSB_glRenderbufferStorage, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "sampleCoverage", JSB_glSampleCoverage, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "scissor", JSB_glScissor, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_shaderSource", JSB_glShaderSource, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "stencilFunc", JSB_glStencilFunc, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "stencilFuncSeparate", JSB_glStencilFuncSeparate, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "stencilMask", JSB_glStencilMask, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "stencilMaskSeparate", JSB_glStencilMaskSeparate, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "stencilOp", JSB_glStencilOp, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "stencilOpSeparate", JSB_glStencilOpSeparate, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_texImage2D", JSB_glTexImage2D, 9, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "texParameterf", JSB_glTexParameterf, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "texParameteri", JSB_glTexParameteri, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_texSubImage2D", JSB_glTexSubImage2D, 9, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform1f", JSB_glUniform1f, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform1fv", JSB_glUniform1fv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform1i", JSB_glUniform1i, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform1iv", JSB_glUniform1iv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform2f", JSB_glUniform2f, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform2fv", JSB_glUniform2fv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform2i", JSB_glUniform2i, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform2iv", JSB_glUniform2iv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform3f", JSB_glUniform3f, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform3fv", JSB_glUniform3fv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform3i", JSB_glUniform3i, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform3iv", JSB_glUniform3iv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform4f", JSB_glUniform4f, 5, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform4fv", JSB_glUniform4fv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform4i", JSB_glUniform4i, 5, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniform4iv", JSB_glUniform4iv, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniformMatrix2fv", JSB_glUniformMatrix2fv, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniformMatrix3fv", JSB_glUniformMatrix3fv, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "uniformMatrix4fv", JSB_glUniformMatrix4fv, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_useProgram", JSB_glUseProgram, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "_validateProgram", JSB_glValidateProgram, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "vertexAttrib1f", JSB_glVertexAttrib1f, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "vertexAttrib1fv", JSB_glVertexAttrib1fv, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "vertexAttrib2f", JSB_glVertexAttrib2f, 3, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "vertexAttrib2fv", JSB_glVertexAttrib2fv, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "vertexAttrib3f", JSB_glVertexAttrib3f, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "vertexAttrib3fv", JSB_glVertexAttrib3fv, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "vertexAttrib4f", JSB_glVertexAttrib4f, 5, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "vertexAttrib4fv", JSB_glVertexAttrib4fv, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "vertexAttribPointer", JSB_glVertexAttribPointer, 6, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(_cx, opengl, "viewport", JSB_glViewport, 4, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + +} + diff --git a/cocos/scripting/js-bindings/manual/jsb_opengl_registration.h b/cocos/scripting/js-bindings/manual/jsb_opengl_registration.h new file mode 100644 index 0000000000..a19f3e75c0 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/jsb_opengl_registration.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2012 Zynga Inc. + * 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. + */ + +#ifndef __JSB_OPENGL_REGISTRATION +#define __JSB_OPENGL_REGISTRATION +#include "jsb_opengl_functions.h" + +void JSB_register_opengl( JSContext *globalC, JS::HandleObject globalO); + +#endif // __JSB_OPENGL_REGISTRATION diff --git a/cocos/scripting/js-bindings/manual/localstorage/js_bindings_system_functions.cpp b/cocos/scripting/js-bindings/manual/localstorage/js_bindings_system_functions.cpp new file mode 100644 index 0000000000..6fe52144c3 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/localstorage/js_bindings_system_functions.cpp @@ -0,0 +1,73 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_js_bindings.py -c system_jsb.ini" on 2012-12-17 +* Script version: v0.5 +*/ +#include "js_bindings_system_functions.h" +#include "js_bindings_config.h" +#include "js_bindings_core.h" +#include "js_manual_conversions.h" +#include "ScriptingCore.h" +#include "local-storage/LocalStorage.h" + +USING_NS_CC; + +// Arguments: char* +// Ret value: const char* +bool JSB_localStorageGetItem(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + std::string arg0; + + ok &= jsval_to_std_string( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + std::string ret_val; + + ok = localStorageGetItem(arg0, &ret_val); + if (ok) { + jsval ret_jsval = std_string_to_jsval(cx, ret_val); + args.rval().set(ret_jsval); + } + else { + args.rval().set(JSVAL_NULL); + } + + return true; +} + +// Arguments: char* +// Ret value: void +bool JSB_localStorageRemoveItem(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + std::string arg0; + + ok &= jsval_to_std_string( cx, args.get(0), &arg0 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + localStorageRemoveItem(arg0); + args.rval().setUndefined(); + return true; +} + +// Arguments: char*, char* +// Ret value: void +bool JSB_localStorageSetItem(JSContext *cx, uint32_t argc, jsval *vp) { + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + std::string arg0; std::string arg1; + + ok &= jsval_to_std_string( cx, args.get(0), &arg0 ); + ok &= jsval_to_std_string( cx, args.get(1), &arg1 ); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + localStorageSetItem(arg0 , arg1); + args.rval().setUndefined(); + return true; +} + + +//#endif // JSB_INCLUDE_SYSTEM diff --git a/cocos/scripting/js-bindings/manual/localstorage/js_bindings_system_functions.h b/cocos/scripting/js-bindings/manual/localstorage/js_bindings_system_functions.h new file mode 100644 index 0000000000..85f9ea55c3 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/localstorage/js_bindings_system_functions.h @@ -0,0 +1,21 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_js_bindings.py -c system_jsb.ini" on 2012-12-17 +* Script version: v0.5 +*/ +#include "js_bindings_config.h" +#include "jsapi.h" + +#ifdef __cplusplus +extern "C" { +#endif +bool JSB_localStorageGetItem(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_localStorageRemoveItem(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_localStorageSetItem(JSContext *cx, uint32_t argc, jsval *vp); + +#ifdef __cplusplus +} +#endif + + +//#endif // JSB_INCLUDE_SYSTEM diff --git a/cocos/scripting/js-bindings/manual/localstorage/js_bindings_system_functions_registration.h b/cocos/scripting/js-bindings/manual/localstorage/js_bindings_system_functions_registration.h new file mode 100644 index 0000000000..5774403878 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/localstorage/js_bindings_system_functions_registration.h @@ -0,0 +1,15 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_js_bindings.py -c system_jsb.ini" on 2012-12-17 +* Script version: v0.5 +*/ +#include "../js_bindings_config.h" +//#ifdef JSB_INCLUDE_SYSTEM + +//#include "LocalStorage.h" +JS_DefineFunction(_cx, system, "getItem", JSB_localStorageGetItem, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, system, "removeItem", JSB_localStorageRemoveItem, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); +JS_DefineFunction(_cx, system, "setItem", JSB_localStorageSetItem, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + + +//#endif // JSB_INCLUDE_SYSTEM diff --git a/cocos/scripting/js-bindings/manual/localstorage/js_bindings_system_registration.cpp b/cocos/scripting/js-bindings/manual/localstorage/js_bindings_system_registration.cpp new file mode 100644 index 0000000000..6474c62a32 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/localstorage/js_bindings_system_registration.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2012 Zynga Inc. + * 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. + */ + +#include "js_bindings_config.h" +#include "js_bindings_core.h" +#include "local-storage/LocalStorage.h" +#include "cocos2d.h" + +// system +#include "js_bindings_system_functions.h" + + +void jsb_register_system( JSContext *_cx, JS::HandleObject object) +{ + // + // sys + // + JS::RootedObject proto(_cx); + JS::RootedObject parent(_cx); + JSObject *sys = JS_NewObject(_cx, nullptr, proto, parent); + JS::RootedValue systemVal(_cx); + systemVal = OBJECT_TO_JSVAL(sys); + JS_SetProperty(_cx, object, "sys", systemVal); + + + // sys.localStorage + JSObject *ls = JS_NewObject(_cx, nullptr, proto, parent); + JS::RootedValue lsVal(_cx); + lsVal = OBJECT_TO_JSVAL(ls); + JS_SetProperty(_cx, JS::RootedObject(_cx, sys), "localStorage", lsVal); + + // sys.localStorage functions + JS::RootedObject system(_cx, ls); +#include "js_bindings_system_functions_registration.h" + + + // Init DB with full path + //NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; + //NSString *fullpath = [path stringByAppendingPathComponent:@"jsb.sqlite"]; + std::string strFilePath = cocos2d::FileUtils::getInstance()->getWritablePath(); + strFilePath += "/jsb.sqlite"; + localStorageInit(strFilePath.c_str()); + +} + diff --git a/cocos/scripting/js-bindings/manual/localstorage/js_bindings_system_registration.h b/cocos/scripting/js-bindings/manual/localstorage/js_bindings_system_registration.h new file mode 100644 index 0000000000..3553a0a1ad --- /dev/null +++ b/cocos/scripting/js-bindings/manual/localstorage/js_bindings_system_registration.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2012 Zynga Inc. + * 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. + */ + + +#ifndef __JSB_SYSTEM_REGISTRATION +#define __JSB_SYSTEM_REGISTRATION + +void jsb_register_system( JSContext *globalC, JS::HandleObject globalO); + +#endif // __JSB_CHIPMUNK_REGISTRATION diff --git a/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp b/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp new file mode 100644 index 0000000000..8d215e1f2d --- /dev/null +++ b/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp @@ -0,0 +1,996 @@ +/* + * Created by Rolando Abarca 2012. + * Copyright (c) 2012 Rolando Abarca. All rights reserved. + * Copyright (c) 2013 Zynga Inc. All rights reserved. + * Copyright (c) 2013-2014 Chukong Technologies Inc. + * + * Heavy based on: https://github.com/funkaster/FakeWebGL/blob/master/FakeWebGL/WebGL/XMLHTTPRequest.cpp + * + * 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 "XMLHTTPRequest.h" +#include +#include + +using namespace std; + + +//#pragma mark - MinXmlHttpRequest + +/** + * @brief Implementation for header retrieving. + * @param header + */ +void MinXmlHttpRequest::_gotHeader(string header) +{ + // Get Header and Set StatusText + // Split String into Tokens + char * cstr = new char [header.length()+1]; + + // check for colon. + size_t found_header_field = header.find_first_of(":"); + + if (found_header_field != std::string::npos) + { + // Found a header field. + string http_field; + string http_value; + + http_field = header.substr(0,found_header_field); + http_value = header.substr(found_header_field+1, header.length()); + + // Get rid of all \n + if (!http_value.empty() && http_value[http_value.size() - 1] == '\n') { + http_value.erase(http_value.size() - 1); + } + + // Get rid of leading space (header is field: value format) + if (!http_value.empty() && http_value[0] == ' ') { + http_value.erase(0, 1); + } + + // Transform field name to lower case as they are case-insensitive + std::transform(http_field.begin(), http_field.end(), http_field.begin(), ::tolower); + + _httpHeader[http_field] = http_value; + + } + else + { + // Seems like we have the response Code! Parse it and check for it. + char * pch; + strcpy(cstr, header.c_str()); + + pch = strtok(cstr," "); + while (pch != NULL) + { + + stringstream ss; + string val; + + ss << pch; + val = ss.str(); + size_t found_http = val.find("HTTP"); + + // Check for HTTP Header to set statusText + if (found_http != std::string::npos) { + + stringstream mystream; + + // Get Response Status + pch = strtok (NULL, " "); + mystream << pch; + + pch = strtok (NULL, " "); + mystream << " " << pch; + + _statusText = mystream.str(); + + } + + pch = strtok (NULL, " "); + } + } + + CC_SAFE_DELETE_ARRAY(cstr); +} + +/** + * @brief Set Request header for next call. + * @param field Name of the Header to be set. + * @param value Value of the Headerfield + */ +void MinXmlHttpRequest::_setRequestHeader(const char* field, const char* value) +{ + stringstream header_s; + stringstream value_s; + string header; + + auto iter = _requestHeader.find(field); + + // Concatenate values when header exists. + if (iter != _requestHeader.end()) + { + value_s << iter->second << "," << value; + } + else + { + value_s << value; + } + + _requestHeader[field] = value_s.str(); +} + +/** + * @brief If headers has been set, pass them to curl. + * + */ +void MinXmlHttpRequest::_setHttpRequestHeader() +{ + std::vector header; + + for (auto it = _requestHeader.begin(); it != _requestHeader.end(); ++it) + { + const char* first = it->first.c_str(); + const char* second = it->second.c_str(); + size_t len = sizeof(char) * (strlen(first) + 3 + strlen(second)); + char* test = (char*) malloc(len); + memset(test, 0,len); + + strcpy(test, first); + strcpy(test + strlen(first) , ": "); + strcpy(test + strlen(first) + 2, second); + + header.push_back(test); + + free(test); + + } + + if (!header.empty()) + { + _httpRequest->setHeaders(header); + } + +} + +void MinXmlHttpRequest::_setHttpRequestData(const char *data, size_t len) +{ + if (len > 0 && + (_meth.compare("post") == 0 || _meth.compare("POST") == 0 || + _meth.compare("put") == 0 || _meth.compare("PUT") == 0)) + { + _httpRequest->setRequestData(data, len); + } +} + +/** + * @brief Callback for HTTPRequest. Handles the response and invokes Callback. + * @param sender Object which initialized callback + * @param respone Response object + */ +void MinXmlHttpRequest::handle_requestResponse(cocos2d::network::HttpClient *sender, cocos2d::network::HttpResponse *response) +{ + _elapsedTime = 0; + _scheduler->unscheduleAllForTarget(this); + + if(_isAborted || _readyState == UNSENT) + { + return; + } + + if (0 != strlen(response->getHttpRequest()->getTag())) + { + CCLOG("%s completed", response->getHttpRequest()->getTag()); + } + + long statusCode = response->getResponseCode(); + char statusString[64] = {0}; + sprintf(statusString, "HTTP Status Code: %ld, tag = %s", statusCode, response->getHttpRequest()->getTag()); + + if (!response->isSucceed()) + { + CCLOG("Response failed, error buffer: %s", response->getErrorBuffer()); + if (statusCode == 0 || statusCode == -1) + { + _errorFlag = true; + _status = 0; + _statusText.clear(); + _notify(_onerrorCallback); + _notify(_onloadendCallback); + return; + } + } + + // set header + std::vector *headers = response->getResponseHeader(); + + std::string header(headers->begin(), headers->end()); + + std::istringstream stream(header); + std::string line; + while(std::getline(stream, line)) { + _gotHeader(line); + } + + /** get the response data **/ + std::vector *buffer = response->getResponseData(); + + _status = statusCode; + _readyState = DONE; + + _dataSize = static_cast(buffer->size()); + CC_SAFE_FREE(_data); + _data = (char*) malloc(_dataSize + 1); + _data[_dataSize] = '\0'; + memcpy((void*)_data, (const void*)buffer->data(), _dataSize); + + _notify(_onreadystateCallback); + _notify(_onloadCallback); + _notify(_onloadendCallback); +} +/** + * @brief Send out request and fire callback when done. + * @param cx Javascript context + */ +void MinXmlHttpRequest::_sendRequest(JSContext *cx) +{ + _httpRequest->setResponseCallback(this, httpresponse_selector(MinXmlHttpRequest::handle_requestResponse)); + cocos2d::network::HttpClient::getInstance()->sendImmediate(_httpRequest); + _httpRequest->release(); +} + +/** + * @brief Constructor initializes cchttprequest and stuff + * + */ +MinXmlHttpRequest::MinXmlHttpRequest() +: _url() +, _cx(ScriptingCore::getInstance()->getGlobalContext()) +, _meth() +, _type() +, _data(nullptr) +, _dataSize() +, _onreadystateCallback(nullptr) +, _onloadstartCallback(nullptr) +, _onabortCallback(nullptr) +, _onerrorCallback(nullptr) +, _onloadCallback(nullptr) +, _onloadendCallback(nullptr) +, _ontimeoutCallback(nullptr) +, _readyState(UNSENT) +, _status(0) +, _statusText() +, _responseType() +, _timeout(0) +, _elapsedTime(.0) +, _isAsync() +, _httpRequest(new cocos2d::network::HttpRequest()) +, _isNetwork(true) +, _withCredentialsValue(true) +, _errorFlag(false) +, _httpHeader() +, _requestHeader() +, _isAborted(false) +{ + _scheduler = cocos2d::Director::getInstance()->getScheduler(); + _scheduler->retain(); +} + +/** + * @brief Destructor cleans up _httpRequest and stuff + * + */ +MinXmlHttpRequest::~MinXmlHttpRequest() +{ + +#define SAFE_REMOVE_OBJECT(callback) if (callback != NULL)\ + {\ + JS::RemoveObjectRoot(_cx, &callback);\ + } + + SAFE_REMOVE_OBJECT(_onreadystateCallback); + SAFE_REMOVE_OBJECT(_onloadstartCallback); + SAFE_REMOVE_OBJECT(_onloadendCallback); + SAFE_REMOVE_OBJECT(_onloadCallback); + SAFE_REMOVE_OBJECT(_onerrorCallback); + SAFE_REMOVE_OBJECT(_onabortCallback); + SAFE_REMOVE_OBJECT(_ontimeoutCallback); + + if (_httpRequest) + { + // We don't need to release _httpRequest here since it will be released in the http callback. +// _httpRequest->release(); + } + + CC_SAFE_FREE(_data); + CC_SAFE_RELEASE_NULL(_scheduler); +} + +/** + * @brief Initialize Object and needed properties. + * + */ +JS_BINDED_CLASS_GLUE_IMPL(MinXmlHttpRequest); + +/** + * @brief Implementation for the Javascript Constructor + * + */ +JS_BINDED_CONSTRUCTOR_IMPL(MinXmlHttpRequest) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + MinXmlHttpRequest* req = new MinXmlHttpRequest(); + req->autorelease(); + + js_proxy_t *p; + jsval out; + + JSObject *obj = JS_NewObject(cx, &MinXmlHttpRequest::js_class, JS::RootedObject(cx, MinXmlHttpRequest::js_proto), JS::RootedObject(cx, MinXmlHttpRequest::js_parent)); + + if (obj) { + JS_SetPrivate(obj, req); + out = OBJECT_TO_JSVAL(obj); + } + + args.rval().set(out); + p =jsb_new_proxy(req, obj); + + JS::AddNamedObjectRoot(cx, &p->obj, "XMLHttpRequest"); + return true; +} + + +/** + * @brief Get Callback function for Javascript + * @brief Set Callback function coming from Javascript + * + */ +#define GETTER_SETTER_FOR_CALLBACK_PROP(x,y) JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, x)\ +{\ + if (y)\ + {\ + jsval out = OBJECT_TO_JSVAL(y);\ + args.rval().set(out);\ + }\ + else\ + {\ + args.rval().set(JSVAL_NULL);\ + }\ + return true;\ +}\ +JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, x)\ +{\ + jsval callback = args.get(0);\ + if (callback != JSVAL_NULL)\ + {\ + y = callback.toObjectOrNull();\ + JS::AddNamedObjectRoot(cx, &y, #y);\ + }\ + return true;\ +} + + +GETTER_SETTER_FOR_CALLBACK_PROP(onreadystatechange, _onreadystateCallback) +GETTER_SETTER_FOR_CALLBACK_PROP(onloadstart, _onloadstartCallback) +GETTER_SETTER_FOR_CALLBACK_PROP(onabort, _onabortCallback) +GETTER_SETTER_FOR_CALLBACK_PROP(onerror, _onerrorCallback) +GETTER_SETTER_FOR_CALLBACK_PROP(onload, _onloadCallback) +GETTER_SETTER_FOR_CALLBACK_PROP(onloadend, _onloadendCallback) +GETTER_SETTER_FOR_CALLBACK_PROP(ontimeout, _ontimeoutCallback) + + +/** + * @brief upload getter - TODO + * + * Placeholder for further implementations!! + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, upload) +{ + args.rval().set(JSVAL_NULL); + return true; +} + +/** + * @brief upload setter - TODO + * + * Placeholder for further implementations + */ +JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, upload) +{ + args.rval().set(JSVAL_NULL); + return true; +} + +/** + * @brief timeout getter - TODO + * + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, timeout) +{ + args.rval().set(long_long_to_jsval(cx, _timeout)); + return true; +} + +/** + * @brief timeout setter - TODO + * + */ +JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, timeout) +{ + long long tmp; + jsval_to_long_long(cx, args.get(0), &tmp); + _timeout = (unsigned long long)tmp; + return true; + +} + +/** + * @brief get response type for actual XHR + * + * + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, responseType) +{ + JSString* str = JS_NewStringCopyN(cx, "", 0); + args.rval().set(STRING_TO_JSVAL(str)); + return true; +} + +/** + * @brief responseXML getter - TODO + * + * Placeholder for further implementation. + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, responseXML) +{ + args.rval().set(JSVAL_NULL); + return true; +} + +/** + * @brief set response type for actual XHR + * + * + */ +JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, responseType) +{ + jsval type = args.get(0); + if (type.isString()) { + JSString* str = type.toString(); + bool equal; + + JS_StringEqualsAscii(cx, str, "text", &equal); + if (equal) + { + _responseType = ResponseType::STRING; + return true; + } + + JS_StringEqualsAscii(cx, str, "arraybuffer", &equal); + if (equal) + { + _responseType = ResponseType::ARRAY_BUFFER; + return true; + } + + JS_StringEqualsAscii(cx, str, "json", &equal); + if (equal) + { + _responseType = ResponseType::JSON; + return true; + } + // ignore the rest of the response types for now + return true; + } + JS_ReportError(cx, "Invalid response type"); + return false; +} + +/** + * @brief get readyState for actual XHR + * + * + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, readyState) +{ + args.rval().set(INT_TO_JSVAL(_readyState)); + return true; +} + +/** + * @brief get status for actual XHR + * + * + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, status) +{ + args.rval().set(INT_TO_JSVAL(_status)); + return true; +} + +/** + * @brief get statusText for actual XHR + * + * + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, statusText) +{ + jsval strVal = std_string_to_jsval(cx, _statusText); + + if (strVal != JSVAL_NULL) + { + args.rval().set(strVal); + return true; + } + else + { + JS_ReportError(cx, "Error trying to create JSString from data"); + return false; + } +} + +/** + * @brief get value of withCredentials property. + * + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, withCredentials) +{ + args.rval().set(BOOLEAN_TO_JSVAL(_withCredentialsValue)); + return true; +} + +/** + * withCredentials - set value of withCredentials property. + * + */ +JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, withCredentials) +{ + jsval credential = args.get(0); + if (credential != JSVAL_NULL) + { + _withCredentialsValue = credential.toBoolean(); + } + + return true; +} + +/** + * @brief get (raw) responseText + * + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, responseText) +{ + if (_data) + { + jsval strVal = std_string_to_jsval(cx, _data); + + if (strVal != JSVAL_NULL) + { + args.rval().set(strVal); + return true; + } + } + + CCLOGERROR("ResponseText was empty, probably there is a network error!"); + + // Return an empty string + args.rval().set(std_string_to_jsval(cx, "")); + + return true; +} + +/** + * @brief get response of latest XHR + * + */ +JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, response) +{ + if (_responseType == ResponseType::STRING) + { + return _js_get_responseText(cx, args); + } + else + { + if (_readyState != DONE || _errorFlag) + { + args.rval().set(JSVAL_NULL); + return true; + } + + if (_responseType == ResponseType::JSON) + { + JS::RootedValue outVal(cx); + + jsval strVal = std_string_to_jsval(cx, _data); + + //size_t utf16Count = 0; + //const jschar* utf16Buf = JS_GetStringCharsZAndLength(cx, JSVAL_TO_STRING(strVal), &utf16Count); + //bool ok = JS_ParseJSON(cx, utf16Buf, static_cast(utf16Count), &outVal); + bool ok = JS_ParseJSON(cx, JS::RootedString(cx, strVal.toString()), &outVal); + + if (ok) + { + args.rval().set(outVal); + return true; + } + } + else if (_responseType == ResponseType::ARRAY_BUFFER) + { + JSObject* tmp = JS_NewArrayBuffer(cx, _dataSize); + uint8_t* tmpData = JS_GetArrayBufferData(tmp); + memcpy((void*)tmpData, (const void*)_data, _dataSize); + jsval outVal = OBJECT_TO_JSVAL(tmp); + + args.rval().set(outVal); + return true; + } + // by default, return text + return _js_get_responseText(cx, args); + } +} + +/** + * @brief initialize new xhr. + * TODO: doesn't supprot username, password arguments now + * http://www.w3.org/TR/XMLHttpRequest/#the-open()-method + * + */ +JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, open) +{ + if (argc >= 2) + { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + const char* method; + const char* urlstr; + bool async = true; + JSString* jsMethod = JS::ToString( cx, args.get(0) ); + JSString* jsURL = JS::ToString( cx, args.get(1) ); + + if (argc > 2) { + async = JS::ToBoolean( args.get(2) ); + } + + JSStringWrapper w1(jsMethod); + JSStringWrapper w2(jsURL); + method = w1.get(); + urlstr = w2.get(); + + _url = urlstr; + _meth = method; + _readyState = 1; + _isAsync = async; + + if (_url.length() > 5 && _url.compare(_url.length() - 5, 5, ".json") == 0) + { + _responseType = ResponseType::JSON; + } + + + { + auto requestType = + (_meth.compare("get") == 0 || _meth.compare("GET") == 0) ? cocos2d::network::HttpRequest::Type::GET : ( + (_meth.compare("post") == 0 || _meth.compare("POST") == 0) ? cocos2d::network::HttpRequest::Type::POST : ( + (_meth.compare("put") == 0 || _meth.compare("PUT") == 0) ? cocos2d::network::HttpRequest::Type::PUT : ( + (_meth.compare("delete") == 0 || _meth.compare("DELETE") == 0) ? cocos2d::network::HttpRequest::Type::DELETE : ( + cocos2d::network::HttpRequest::Type::UNKNOWN)))); + + _httpRequest->setRequestType(requestType); + _httpRequest->setUrl(_url.c_str()); + } + + printf("[XMLHttpRequest] %s %s\n", _meth.c_str(), _url.c_str()); + + _isNetwork = true; + _readyState = OPENED; + _status = 0; + _isAborted = false; + + return true; + } + + JS_ReportError(cx, "invalid call: %s", __FUNCTION__); + return false; + +} + +/** + * @brief send xhr + * + */ +JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, send) +{ + std::string data; + + // Clean up header map. New request, new headers! + _httpHeader.clear(); + + _errorFlag = false; + + if (argc == 1) + { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (args.get(0).isString()) + { + JSStringWrapper strWrap(args.get(0).toString()); + data = strWrap.get(); + _setHttpRequestData(data.c_str(), static_cast(data.length())); + } + else if (args.get(0).isObject()) + { + JSObject *obj = args.get(0).toObjectOrNull(); + if (JS_IsArrayBufferObject(obj)) + { + _setHttpRequestData((const char *)JS_GetArrayBufferData(obj), JS_GetArrayBufferByteLength(obj)); + } + else if (JS_IsArrayBufferViewObject(obj)) + { + _setHttpRequestData((const char *)JS_GetArrayBufferViewData(obj), JS_GetArrayBufferViewByteLength(obj)); + } + else + { + return false; + } + } + else + { + return false; + } + } + + _setHttpRequestHeader(); + _sendRequest(cx); + _notify(_onloadstartCallback); + + //begin schedule for timeout + if(_timeout > 0) + { + _scheduler->scheduleUpdate(this, 0, false); + } + + return true; +} + +void MinXmlHttpRequest::update(float dt) +{ + _elapsedTime += dt; + if(_elapsedTime * 1000 >= _timeout) + { + _notify(_ontimeoutCallback); + _elapsedTime = 0; + _readyState = UNSENT; + _scheduler->unscheduleAllForTarget(this); + } +} + +/** + * @brief abort function + * + */ +JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, abort) +{ + //1.Terminate the request. + _isAborted = true; + + //2.If the state is UNSENT, OPENED with the send() flag being unset, or DONE go to the next step. + //nothing to do + + //3.Change the state to UNSENT. + _readyState = UNSENT; + + _notify(_onabortCallback); + + return true; +} + +/** + * @brief Get all response headers as a string + * + */ +JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, getAllResponseHeaders) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + stringstream responseheaders; + string responseheader; + + for (auto it = _httpHeader.begin(); it != _httpHeader.end(); ++it) + { + responseheaders << it->first << ": " << it->second << "\n"; + } + + responseheader = responseheaders.str(); + + jsval strVal = std_string_to_jsval(cx, responseheader); + if (strVal != JSVAL_NULL) + { + args.rval().set(strVal); + return true; + } + else + { + JS_ReportError(cx, "Error trying to create JSString from data"); + return false; + } + + return true; +} + +/** + * @brief Get all response headers as a string + * + */ +JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, getResponseHeader) +{ + JSString *header_value; + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (!args.get(0).isString()) { + return false; + }; + header_value = args.get(0).toString(); + + std::string data; + JSStringWrapper strWrap(header_value); + data = strWrap.get(); + + stringstream streamdata; + + streamdata << data; + + string value = streamdata.str(); + std::transform(value.begin(), value.end(), value.begin(), ::tolower); + + auto iter = _httpHeader.find(value); + if (iter != _httpHeader.end()) + { + jsval js_ret_val = std_string_to_jsval(cx, iter->second); + args.rval().set(js_ret_val); + return true; + } + else { + args.rval().setUndefined(); + return true; + } +} + +/** + * @brief Set the given Fields to request Header. + * + * + */ +JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, setRequestHeader) +{ + if (argc >= 2) + { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + const char* field; + const char* value; + + JSString* jsField = JS::ToString( cx, args.get(0) ); + JSString* jsValue = JS::ToString( cx, args.get(1) ); + + JSStringWrapper w1(jsField); + JSStringWrapper w2(jsValue); + field = w1.get(); + value = w2.get(); + + // Populate the request_header map. + _setRequestHeader(field, value); + + return true; + } + + return false; + +} + +/** + * @brief overrideMimeType function - TODO! + * + * Just a placeholder for further implementations. + */ +JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, overrideMimeType) +{ + return true; +} + +/** + * @brief destructor for Javascript + * + */ +static void basic_object_finalize(JSFreeOp *freeOp, JSObject *obj) +{ + CCLOG("basic_object_finalize %p ...", obj); +} + +void MinXmlHttpRequest::_notify(JSObject * callback) +{ + js_proxy_t * p; + void* ptr = (void*)this; + p = jsb_get_native_proxy(ptr); + + if(p) + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + + if (callback) + { + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + //JS_IsExceptionPending(cx) && JS_ReportPendingException(cx); + JS::RootedValue fval(cx, OBJECT_TO_JSVAL(callback)); + JS::RootedValue out(cx); + JS_CallFunctionValue(cx, JS::NullPtr(), fval, JS::HandleValueArray::empty(), &out); + } + + } +} + +/** + * @brief Register XMLHttpRequest to be usable in JS and add properties and Mehtods. + * @param cx Global Spidermonkey JS Context. + * @param global Global Spidermonkey Javascript object. + */ +void MinXmlHttpRequest::_js_register(JSContext *cx, JS::HandleObject global) +{ + JSClass jsclass = { + "XMLHttpRequest", JSCLASS_HAS_PRIVATE, JS_PropertyStub, + JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub, + JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, + basic_object_finalize + }; + + MinXmlHttpRequest::js_class = jsclass; + static JSPropertySpec props[] = { + JS_BINDED_PROP_DEF_ACCESSOR(MinXmlHttpRequest, onloadstart), + JS_BINDED_PROP_DEF_ACCESSOR(MinXmlHttpRequest, onabort), + JS_BINDED_PROP_DEF_ACCESSOR(MinXmlHttpRequest, onerror), + JS_BINDED_PROP_DEF_ACCESSOR(MinXmlHttpRequest, onload), + JS_BINDED_PROP_DEF_ACCESSOR(MinXmlHttpRequest, onloadend), + JS_BINDED_PROP_DEF_ACCESSOR(MinXmlHttpRequest, ontimeout), + JS_BINDED_PROP_DEF_ACCESSOR(MinXmlHttpRequest, onreadystatechange), + JS_BINDED_PROP_DEF_ACCESSOR(MinXmlHttpRequest, responseType), + JS_BINDED_PROP_DEF_ACCESSOR(MinXmlHttpRequest, withCredentials), + JS_BINDED_PROP_DEF_ACCESSOR(MinXmlHttpRequest, timeout), + JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, readyState), + JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, status), + JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, statusText), + JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, responseText), + JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, responseXML), + JS_BINDED_PROP_DEF_GETTER(MinXmlHttpRequest, response), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, open), + JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, abort), + JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, send), + JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, setRequestHeader), + JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, getAllResponseHeaders), + JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, getResponseHeader), + JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, overrideMimeType), + JS_FS_END + }; + + MinXmlHttpRequest::js_parent = nullptr; + MinXmlHttpRequest::js_proto = JS_InitClass(cx, global, JS::NullPtr(), &MinXmlHttpRequest::js_class , MinXmlHttpRequest::_js_constructor, 0, props, funcs, nullptr, nullptr); + +} + diff --git a/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.h b/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.h new file mode 100644 index 0000000000..dc255c9ec4 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.h @@ -0,0 +1,129 @@ +/* + * Created by Rolando Abarca 2012. + * Copyright (c) 2012 Rolando Abarca. All rights reserved. + * Copyright (c) 2013 Zynga Inc. All rights reserved. + * Copyright (c) 2013-2014 Chukong Technologies Inc. + * + * Heavy based on: https://github.com/funkaster/FakeWebGL/blob/master/FakeWebGL/WebGL/XMLHTTPRequest.h + * + * 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 __FAKE_XMLHTTPREQUEST_H__ +#define __FAKE_XMLHTTPREQUEST_H__ + +#include "jsapi.h" +#include "jsfriendapi.h" +#include "network/HttpClient.h" +#include "js_bindings_config.h" +#include "ScriptingCore.h" +#include "jsb_helper.h" + +class MinXmlHttpRequest : public cocos2d::Ref +{ +public: + enum class ResponseType + { + STRING, + ARRAY_BUFFER, + BLOB, + DOCUMENT, + JSON + }; + + // Ready States (http://www.w3.org/TR/XMLHttpRequest/#interface-xmlhttprequest) + static const unsigned short UNSENT = 0; + static const unsigned short OPENED = 1; + static const unsigned short HEADERS_RECEIVED = 2; + static const unsigned short LOADING = 3; + static const unsigned short DONE = 4; + + MinXmlHttpRequest(); + ~MinXmlHttpRequest(); + + JS_BINDED_CLASS_GLUE(MinXmlHttpRequest); + JS_BINDED_CONSTRUCTOR(MinXmlHttpRequest); + JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, onloadstart); + JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, onreadystatechange); + JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, onabort); + JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, onerror); + JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, onload); + JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, onloadend); + JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, ontimeout); + JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, withCredentials); + JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, upload); + JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, timeout); + JS_BINDED_PROP_ACCESSOR(MinXmlHttpRequest, responseType); + JS_BINDED_PROP_GET(MinXmlHttpRequest, readyState); + JS_BINDED_PROP_GET(MinXmlHttpRequest, status); + JS_BINDED_PROP_GET(MinXmlHttpRequest, statusText); + JS_BINDED_PROP_GET(MinXmlHttpRequest, responseText); + JS_BINDED_PROP_GET(MinXmlHttpRequest, response); + JS_BINDED_PROP_GET(MinXmlHttpRequest, responseXML); + JS_BINDED_FUNC(MinXmlHttpRequest, open); + JS_BINDED_FUNC(MinXmlHttpRequest, send); + JS_BINDED_FUNC(MinXmlHttpRequest, abort); + JS_BINDED_FUNC(MinXmlHttpRequest, getAllResponseHeaders); + JS_BINDED_FUNC(MinXmlHttpRequest, getResponseHeader); + JS_BINDED_FUNC(MinXmlHttpRequest, setRequestHeader); + JS_BINDED_FUNC(MinXmlHttpRequest, overrideMimeType); + + void handle_requestResponse(cocos2d::network::HttpClient *sender, cocos2d::network::HttpResponse *response); + + void update(float dt); +private: + void _gotHeader(std::string header); + void _setRequestHeader(const char* field, const char* value); + void _setHttpRequestHeader(); + void _setHttpRequestData(const char *data, size_t len); + void _sendRequest(JSContext *cx); + void _notify(JSObject * callback); + + std::string _url; + JSContext* _cx; + std::string _meth; + std::string _type; + char* _data; + uint32_t _dataSize; + JS::Heap _onloadstartCallback; + JS::Heap _onabortCallback; + JS::Heap _onerrorCallback; + JS::Heap _onloadCallback; + JS::Heap _onloadendCallback; + JS::Heap _ontimeoutCallback; + JS::Heap _onreadystateCallback; + int _readyState; + int _status; + std::string _statusText; + ResponseType _responseType; + unsigned long long _timeout; + float _elapsedTime; + bool _isAsync; + cocos2d::network::HttpRequest* _httpRequest; + bool _isNetwork; + bool _withCredentialsValue; + bool _errorFlag; + std::unordered_map _httpHeader; + std::unordered_map _requestHeader; + bool _isAborted; + cocos2d::Scheduler* _scheduler; +}; + +#endif diff --git a/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp b/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp new file mode 100644 index 0000000000..29e1c8f39b --- /dev/null +++ b/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp @@ -0,0 +1,451 @@ +/* + * Created by Chris Hannon 2014 http://www.channon.us + * 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. + */ + +#include "jsb_socketio.h" +#include "jsb_helper.h" +#include "cocos2d.h" +#include "network/WebSocket.h" +#include "network/SocketIO.h" +#include "spidermonkey_specifics.h" +#include "ScriptingCore.h" +#include "cocos2d_specifics.hpp" + +using namespace cocos2d::network; + +class JSB_SIOEvent : public cocos2d::Object { +public: + JSB_SIOEvent(); + virtual ~JSB_SIOEvent(); + void setJSCallbackFunc(jsval obj); + const jsval& getJSCallbackFunc() const; + +private: + JS::Heap _jsCallback; + JS::Heap _extraData; + +}; + +JSB_SIOEvent::JSB_SIOEvent() +: _jsCallback(JSVAL_VOID), _extraData(JSVAL_VOID) +{ + +} + +JSB_SIOEvent::~JSB_SIOEvent() +{ + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RemoveValueRoot(cx, &_jsCallback); +} + +void JSB_SIOEvent::setJSCallbackFunc(jsval func) { + _jsCallback = func; + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + // Root the callback function. + JS::AddNamedValueRoot(cx, &_jsCallback, "JSB_SIOEvent_callback_func"); +} + +const jsval& JSB_SIOEvent::getJSCallbackFunc() const +{ + return _jsCallback; +} + +//c++11 map to callbacks +typedef std::unordered_map JSB_SIOEventRegistry; + +class JSB_SocketIODelegate : public SocketIO::SIODelegate { +public: + + JSB_SocketIODelegate() { + JSB_SIOEvent tmp; + std::string s = "default"; + _eventRegistry[s] = tmp; + } + + virtual void onConnect(SIOClient* client) { + CCLOG("JSB SocketIO::SIODelegate->onConnect method called from native"); + + this->fireEventToScript(client, "connect", ""); + + } + + virtual void onMessage(SIOClient* client, const std::string& data) { + CCLOG("JSB SocketIO::SIODelegate->onMessage method called from native with data: %s", data.c_str()); + + this->fireEventToScript(client, "message", data); + + } + + virtual void onClose(SIOClient* client) { + CCLOG("JSB SocketIO::SIODelegate->onClose method called from native"); + + this->fireEventToScript(client, "disconnect", ""); + + } + + virtual void onError(SIOClient* client, const std::string& data) { + CCLOG("JSB SocketIO::SIODelegate->onError method called from native with data: %s", data.c_str()); + + this->fireEventToScript(client, "error", data); + + } + + virtual void fireEventToScript(SIOClient* client, const std::string& eventName, const std::string& data) { + CCLOG("JSB SocketIO::SIODelegate->fireEventToScript method called from native with name '%s' data: %s", eventName.c_str(), data.c_str()); + + js_proxy_t * p = jsb_get_native_proxy(client); + if (!p) return; + + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + + jsval args; + if(data == "") { + args = JSVAL_NULL; + } else { + args = std_string_to_jsval(cx, data); + } + + //ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), eventName.c_str(), 1, &args); + + JSB_SIOEventRegistry::iterator it = _eventRegistry.find(eventName); + + if(it != _eventRegistry.end()) { + JSB_SIOEvent e = it->second; + JS::RootedValue rval(cx); + ScriptingCore::getInstance()->executeJSFunctionWithThisObj(JS::RootedValue(cx, OBJECT_TO_JSVAL(p->obj)), JS::RootedValue(cx, e.getJSCallbackFunc()), JS::HandleValueArray::fromMarkedLocation(1, &args), &rval); + } + + } + + void setJSDelegate(JSObject* pJSDelegate) { + _JSDelegate = pJSDelegate; + } + + void addEvent(const std::string& eventName, JSB_SIOEvent jsevent) { + _eventRegistry[eventName] = jsevent; + } + +private: + JS::Heap _JSDelegate; + + JSB_SIOEventRegistry _eventRegistry; + +}; + +JSClass *js_cocos2dx_socketio_class; +JSObject *js_cocos2dx_socketio_prototype; + +void js_cocos2dx_SocketIO_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOG("jsbindings: finalizing JS object %p (SocketIO)", obj); +} + +bool js_cocos2dx_SocketIO_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS_ReportError(cx, "SocketIO isn't meant to be instantiated, use SocketIO.connect() instead"); + + return false; +} + +bool js_cocos2dx_SocketIO_connect(JSContext* cx, uint32_t argc, jsval* vp){ + CCLOG("JSB SocketIO.connect method called"); + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + if (argc == 1 || argc == 2) { + + std::string url; + + do { + bool ok = jsval_to_std_string(cx, args.get(0), &url); + JSB_PRECONDITION2( ok, cx, false, "Error processing arguments"); + } while (0); + + JSB_SocketIODelegate* siodelegate = new JSB_SocketIODelegate(); + + CCLOG("Calling native SocketIO.connect method"); + SIOClient* ret = SocketIO::connect(*siodelegate, url); + + jsval jsret; + do{ + if (ret) { + // link the native object with the javascript object + js_proxy_t *p; + HASH_FIND_PTR(_native_js_global_ht, &ret, p); + if(!p) { + //previous connection not found, create a new one + JSObject *obj = JS_NewObject(cx, js_cocos2dx_socketio_class, JS::RootedObject(cx, js_cocos2dx_socketio_prototype), JS::NullPtr()); + p = jsb_new_proxy(ret, obj); + JS::AddNamedObjectRoot(cx, &p->obj, "SocketIO"); + siodelegate->setJSDelegate(p->obj); + } + + jsret = OBJECT_TO_JSVAL(p->obj); + + } + else{ + jsret = JSVAL_NULL; + } + } while(0); + + args.rval().set(jsret); + + return true; + + } + + JS_ReportError(cx, "JSB SocketIO.connect: Wrong number of arguments"); + return false; +} + +bool js_cocos2dx_SocketIO_send(JSContext* cx, uint32_t argc, jsval* vp){ + CCLOG("JSB SocketIO.send method called"); + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + SIOClient* cobj = (SIOClient *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 1) { + + std::string payload; + + do { + bool ok = jsval_to_std_string(cx, args.get(0), &payload); + JSB_PRECONDITION2( ok, cx, false, "Error processing arguments"); + } while (0); + + CCLOG("JSB SocketIO send mesage: %s", payload.c_str()); + + cobj->send(payload); + + return true; + + } + + JS_ReportError(cx, "Wrong number of arguments"); + return false; + +} + +bool js_cocos2dx_SocketIO_emit(JSContext* cx, uint32_t argc, jsval* vp){ + CCLOG("JSB SocketIO.emit method called"); + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + SIOClient* cobj = (SIOClient *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 2) { + + std::string eventName; + + do { + bool ok = jsval_to_std_string(cx, args.get(0), &eventName); + JSB_PRECONDITION2( ok, cx, false, "Error processing arguments"); + } while (0); + + std::string payload; + + do { + bool ok = jsval_to_std_string(cx, args.get(1), &payload); + JSB_PRECONDITION2( ok, cx, false, "Error processing arguments"); + } while (0); + + CCLOG("JSB SocketIO emit event '%s' with payload: %s", eventName.c_str(), payload.c_str()); + + cobj->emit(eventName, payload); + + return true; + + } + + JS_ReportError(cx, "JSB SocketIO.emit: Wrong number of arguments"); + return false; + +} + +bool js_cocos2dx_SocketIO_disconnect(JSContext* cx, uint32_t argc, jsval* vp){ + CCLOG("JSB SocketIO.disconnect method called"); + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + SIOClient* cobj = (SIOClient *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if(argc == 0) { + + cobj->disconnect(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "JSB SocketIO.disconnect: Wrong number of arguments"); + return false; + +} + +bool js_cocos2dx_SocketIO_close(JSContext* cx, uint32_t argc, jsval* vp){ + CCLOG("JSB SocketIO.close method called"); + + if(argc == 0) { + + //This method was previously implemented to take care of the HTTPClient instance not being destroyed properly + //SocketIO::close(); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "JSB SocketIO.close: Wrong number of arguments"); + return false; + +} + +static bool _js_set_SIOClient_tag(JSContext* cx, uint32_t argc, jsval* vp) +{ + CCLOG("JSB SocketIO.setTag method called"); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsobj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(jsobj); + SIOClient* cobj = (SIOClient *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (cobj) { + std::string out = ""; + + jsval_to_std_string(cx, args.get(0), &out); + cobj->setTag(out.c_str()); + return true; + } else { + JS_ReportError(cx, "Error: SocketIO instance is invalid."); + return false; + } + +} + +static bool _js_get_SIOClient_tag(JSContext* cx, uint32_t argc, jsval* vp) +{ + CCLOG("JSB SocketIO.getTag method called"); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsobj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(jsobj); + SIOClient* cobj = (SIOClient *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (cobj) { + args.rval().set(std_string_to_jsval(cx, cobj->getTag())); + return true; + } else { + JS_ReportError(cx, "Error: SocketIO instance is invalid."); + return false; + } + +} + + +bool js_cocos2dx_SocketIO_on(JSContext* cx, uint32_t argc, jsval* vp){ + CCLOG("JSB SocketIO.on method called"); + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + SIOClient* cobj = (SIOClient *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if(argc == 2) { + + std::string eventName; + + do { + bool ok = jsval_to_std_string(cx, args.get(0), &eventName); + JSB_PRECONDITION2( ok, cx, false, "Error processing arguments"); + } while (0); + + CCLOG("JSB SocketIO eventName to: '%s'", eventName.c_str()); + + JSB_SIOEvent tmpCobj; + tmpCobj.setJSCallbackFunc(args.get(1)); + + ((JSB_SocketIODelegate *)cobj->getDelegate())->addEvent(eventName, tmpCobj); + + args.rval().set(OBJECT_TO_JSVAL(proxy->obj)); + + JS_SetReservedSlot(proxy->obj, 0, args.get(1)); + + return true; + } + + JS_ReportError(cx, "JSB SocketIO.close: Wrong number of arguments"); + return false; + +} + +void register_jsb_socketio(JSContext *cx, JS::HandleObject global) { + + js_cocos2dx_socketio_class = (JSClass *)calloc(1, sizeof(JSClass)); + js_cocos2dx_socketio_class->name = "SocketIO"; + js_cocos2dx_socketio_class->addProperty = JS_PropertyStub; + js_cocos2dx_socketio_class->delProperty = JS_DeletePropertyStub; + js_cocos2dx_socketio_class->getProperty = JS_PropertyStub; + js_cocos2dx_socketio_class->setProperty = JS_StrictPropertyStub; + js_cocos2dx_socketio_class->enumerate = JS_EnumerateStub; + js_cocos2dx_socketio_class->resolve = JS_ResolveStub; + js_cocos2dx_socketio_class->convert = JS_ConvertStub; + js_cocos2dx_socketio_class->finalize = js_cocos2dx_SocketIO_finalize; + js_cocos2dx_socketio_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSGS("tag", _js_get_SIOClient_tag, _js_set_SIOClient_tag, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("send", js_cocos2dx_SocketIO_send, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("emit", js_cocos2dx_SocketIO_emit, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("disconnect", js_cocos2dx_SocketIO_disconnect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("on", js_cocos2dx_SocketIO_on, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("connect", js_cocos2dx_SocketIO_connect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("close", js_cocos2dx_SocketIO_close, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + js_cocos2dx_socketio_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), + js_cocos2dx_socketio_class, + js_cocos2dx_SocketIO_constructor, 0, // constructor + nullptr, + funcs, + nullptr, // no static properties + st_funcs); + + JSObject* jsclassObj = anonEvaluate(cx, global, "(function () { return SocketIO; })()").toObjectOrNull(); + +} + diff --git a/cocos/scripting/js-bindings/manual/network/jsb_socketio.h b/cocos/scripting/js-bindings/manual/network/jsb_socketio.h new file mode 100644 index 0000000000..279f54de1f --- /dev/null +++ b/cocos/scripting/js-bindings/manual/network/jsb_socketio.h @@ -0,0 +1,32 @@ +/* + * Created by Chris Hannon 2014 http://www.channon.us + * 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. + */ + +#ifndef __jsb_socketio__ +#define __jsb_socketio__ + +#include "jsapi.h" +#include "jsfriendapi.h" + +void register_jsb_socketio(JSContext* cx, JS::HandleObject global); + +#endif /* defined(__jsb_socketio__) */ diff --git a/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp b/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp new file mode 100644 index 0000000000..fdfb4993c2 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp @@ -0,0 +1,390 @@ +/* + * Created by James Chen + * 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. + */ + +#include "jsb_websocket.h" +#include "cocos2d.h" +#include "network/WebSocket.h" +#include "spidermonkey_specifics.h" +#include "ScriptingCore.h" +#include "cocos2d_specifics.hpp" + +using namespace cocos2d::network; + +/* + [Constructor(in DOMString url, in optional DOMString protocols)] + [Constructor(in DOMString url, in optional DOMString[] protocols)] + interface WebSocket { + readonly attribute DOMString url; + + // ready state + const unsigned short CONNECTING = 0; + const unsigned short OPEN = 1; + const unsigned short CLOSING = 2; + const unsigned short CLOSED = 3; + readonly attribute unsigned short readyState; + readonly attribute unsigned long bufferedAmount; + + // networking + attribute Function onopen; + attribute Function onmessage; + attribute Function onerror; + attribute Function onclose; + readonly attribute DOMString protocol; + void send(in DOMString data); + void close(); + }; + WebSocket implements EventTarget; + */ + +class JSB_WebSocketDelegate : public WebSocket::Delegate +{ +public: + + virtual void onOpen(WebSocket* ws) + { + js_proxy_t * p = jsb_get_native_proxy(ws); + if (!p) return; + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedObject jsobj(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr())); + JS::RootedValue vp(cx); + vp = c_string_to_jsval(cx, "open"); + JS_SetProperty(cx, jsobj, "type", vp); + + jsval args = OBJECT_TO_JSVAL(jsobj); + + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onopen", 1, &args); + } + + virtual void onMessage(WebSocket* ws, const WebSocket::Data& data) + { + js_proxy_t * p = jsb_get_native_proxy(ws); + if (!p) return; + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedObject jsobj(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr())); + JS::RootedValue vp(cx); + vp = c_string_to_jsval(cx, "message"); + JS_SetProperty(cx, jsobj, "type", vp); + + jsval args = OBJECT_TO_JSVAL(jsobj); + + if (data.isBinary) + {// data is binary + JSObject* buffer = JS_NewArrayBuffer(cx, static_cast(data.len)); + uint8_t* bufdata = JS_GetArrayBufferData(buffer); + memcpy((void*)bufdata, (void*)data.bytes, data.len); + JS::RootedValue dataVal(cx); + dataVal = OBJECT_TO_JSVAL(buffer); + JS_SetProperty(cx, jsobj, "data", dataVal); + } + else + {// data is string + JS::RootedValue dataVal(cx); + dataVal = c_string_to_jsval(cx, data.bytes); + JS_SetProperty(cx, jsobj, "data", dataVal); + } + + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onmessage", 1, &args); + } + + virtual void onClose(WebSocket* ws) + { + js_proxy_t * p = jsb_get_native_proxy(ws); + if (!p) return; + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedObject jsobj(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr())); + JS::RootedValue vp(cx); + vp = c_string_to_jsval(cx, "close"); + JS_SetProperty(cx, jsobj, "type", vp); + + jsval args = OBJECT_TO_JSVAL(jsobj); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onclose", 1, &args); + + js_proxy_t* jsproxy = jsb_get_js_proxy(p->obj); + JS::RemoveObjectRoot(cx, &jsproxy->obj); + jsb_remove_proxy(p, jsproxy); + CC_SAFE_DELETE(ws); + } + + virtual void onError(WebSocket* ws, const WebSocket::ErrorCode& error) + { + js_proxy_t * p = jsb_get_native_proxy(ws); + if (!p) return; + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedObject jsobj(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr())); + JS::RootedValue vp(cx); + vp = c_string_to_jsval(cx, "error"); + JS_SetProperty(cx, jsobj, "type", vp); + + jsval args = OBJECT_TO_JSVAL(jsobj); + + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "onerror", 1, &args); + } + + void setJSDelegate(JSObject* pJSDelegate) + { + _JSDelegate = pJSDelegate; + } +private: + JS::Heap _JSDelegate; +}; + +JSClass *js_cocos2dx_websocket_class; +JSObject *js_cocos2dx_websocket_prototype; + +void js_cocos2dx_WebSocket_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOG("jsbindings: finalizing JS object %p (WebSocket)", obj); +} + +bool js_cocos2dx_extension_WebSocket_send(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + WebSocket* cobj = (WebSocket *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if(argc == 1){ + do + { + if (args.get(0).isString()) + { + std::string data; + jsval_to_std_string(cx, args.get(0), &data); + cobj->send(data); + break; + } + + if (args.get(0).isObject()) + { + uint8_t *bufdata = NULL; + uint32_t len = 0; + + JSObject* jsobj = args.get(0).toObjectOrNull(); + if (JS_IsArrayBufferObject(jsobj)) + { + bufdata = JS_GetArrayBufferData(jsobj); + len = JS_GetArrayBufferByteLength(jsobj); + } + else if (JS_IsArrayBufferViewObject(jsobj)) + { + bufdata = (uint8_t*)JS_GetArrayBufferViewData(jsobj); + len = JS_GetArrayBufferViewByteLength(jsobj); + } + + if (bufdata && len > 0) + { + cobj->send(bufdata, len); + break; + } + } + + JS_ReportError(cx, "data type to be sent is unsupported."); + + } while (0); + + args.rval().setUndefined(); + + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return true; +} + +bool js_cocos2dx_extension_WebSocket_close(JSContext *cx, uint32_t argc, jsval *vp){ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + WebSocket* cobj = (WebSocket *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if(argc == 0){ + cobj->close(); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +bool js_cocos2dx_extension_WebSocket_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + if (argc == 1 || argc == 2) + { + + std::string url; + + do { + bool ok = jsval_to_std_string(cx, args.get(0), &url); + JSB_PRECONDITION2( ok, cx, false, "Error processing arguments"); + } while (0); + + JS::RootedObject obj(cx, JS_NewObject(cx, js_cocos2dx_websocket_class, JS::RootedObject(cx, js_cocos2dx_websocket_prototype), JS::NullPtr())); + //JS::RootedObject obj(cx, JS_NewObjectForConstructor(cx, js_cocos2dx_websocket_class, args)); + + WebSocket* cobj = new WebSocket(); + JSB_WebSocketDelegate* delegate = new JSB_WebSocketDelegate(); + delegate->setJSDelegate(obj); + + if (argc == 2) + { + std::vector protocols; + + if (args.get(1).isString()) + { + std::string protocol; + do { + bool ok = jsval_to_std_string(cx, args.get(1), &protocol); + JSB_PRECONDITION2( ok, cx, false, "Error processing arguments"); + } while (0); + protocols.push_back(protocol); + } + else if (args.get(1).isObject()) + { + bool ok = true; + JS::RootedObject arg2(cx, args.get(1).toObjectOrNull()); + JSB_PRECONDITION(JS_IsArrayObject( cx, arg2 ), "Object must be an array"); + + uint32_t len = 0; + JS_GetArrayLength(cx, arg2, &len); + + for( uint32_t i=0; i< len;i++ ) + { + JS::RootedValue valarg(cx); + JS_GetElement(cx, arg2, i, &valarg); + std::string protocol; + do { + ok = jsval_to_std_string(cx, valarg, &protocol); + JSB_PRECONDITION2( ok, cx, false, "Error processing arguments"); + } while (0); + + protocols.push_back(protocol); + } + } + cobj->init(*delegate, url, &protocols); + } + else + { + cobj->init(*delegate, url); + } + + + JS_DefineProperty(cx, obj, "URL", args.get(0), JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); + + //protocol not support yet (always return "") + JS_DefineProperty(cx, obj, "protocol", JS::RootedValue(cx, c_string_to_jsval(cx, "")), JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); + + // link the native object with the javascript object + js_proxy_t *p = jsb_new_proxy(cobj, obj); + JS::AddNamedObjectRoot(cx, &p->obj, "WebSocket"); + + args.rval().set(OBJECT_TO_JSVAL(obj)); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +static bool js_cocos2dx_extension_WebSocket_get_readyState(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsobj = args.thisv().toObjectOrNull(); + js_proxy_t *proxy = jsb_get_js_proxy(jsobj); + WebSocket* cobj = (WebSocket *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (cobj) { + args.rval().set(INT_TO_JSVAL((int)cobj->getReadyState())); + return true; + } else { + JS_ReportError(cx, "Error: WebSocket instance is invalid."); + return false; + } +} + +void register_jsb_websocket(JSContext *cx, JS::HandleObject global) { + + js_cocos2dx_websocket_class = (JSClass *)calloc(1, sizeof(JSClass)); + js_cocos2dx_websocket_class->name = "WebSocket"; + js_cocos2dx_websocket_class->addProperty = JS_PropertyStub; + js_cocos2dx_websocket_class->delProperty = JS_DeletePropertyStub; + js_cocos2dx_websocket_class->getProperty = JS_PropertyStub; + js_cocos2dx_websocket_class->setProperty = JS_StrictPropertyStub; + js_cocos2dx_websocket_class->enumerate = JS_EnumerateStub; + js_cocos2dx_websocket_class->resolve = JS_ResolveStub; + js_cocos2dx_websocket_class->convert = JS_ConvertStub; + js_cocos2dx_websocket_class->finalize = js_cocos2dx_WebSocket_finalize; + js_cocos2dx_websocket_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("readyState", js_cocos2dx_extension_WebSocket_get_readyState, JSPROP_ENUMERATE | JSPROP_PERMANENT), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("send",js_cocos2dx_extension_WebSocket_send, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("close",js_cocos2dx_extension_WebSocket_close, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + js_cocos2dx_websocket_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), + js_cocos2dx_websocket_class, + js_cocos2dx_extension_WebSocket_constructor, 0, // constructor + properties, + funcs, + NULL, // no static properties + st_funcs); + + JS::RootedObject jsclassObj(cx, anonEvaluate(cx, global, "(function () { return WebSocket; })()").toObjectOrNull()); + + JS_DefineProperty(cx, jsclassObj, "CONNECTING", (int)WebSocket::State::CONNECTING, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); + JS_DefineProperty(cx, jsclassObj, "OPEN", (int)WebSocket::State::OPEN, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); + JS_DefineProperty(cx, jsclassObj, "CLOSING", (int)WebSocket::State::CLOSING, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); + JS_DefineProperty(cx, jsclassObj, "CLOSED", (int)WebSocket::State::CLOSED, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY); + + // make the class enumerable in the registered namespace +//FIXME: bool found; +// JS_SetPropertyAttributes(cx, global, "WebSocket", JSPROP_ENUMERATE | JSPROP_READONLY, &found); +} + + diff --git a/cocos/scripting/js-bindings/manual/network/jsb_websocket.h b/cocos/scripting/js-bindings/manual/network/jsb_websocket.h new file mode 100644 index 0000000000..ed517b920f --- /dev/null +++ b/cocos/scripting/js-bindings/manual/network/jsb_websocket.h @@ -0,0 +1,32 @@ +/* + * Created by James Chen + * 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. + */ + +#ifndef __jsb_websocket__ +#define __jsb_websocket__ + +#include "jsapi.h" +#include "jsfriendapi.h" + +void register_jsb_websocket(JSContext* cx, JS::HandleObject global); + +#endif /* defined(__jsb_websocket__) */ diff --git a/cocos/scripting/js-bindings/manual/platform/android/CCJavascriptJavaBridge.cpp b/cocos/scripting/js-bindings/manual/platform/android/CCJavascriptJavaBridge.cpp new file mode 100644 index 0000000000..0bc811356a --- /dev/null +++ b/cocos/scripting/js-bindings/manual/platform/android/CCJavascriptJavaBridge.cpp @@ -0,0 +1,432 @@ +/* + * 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. + */ + +#include +#include "CCJavascriptJavaBridge.h" +#include "cocos2d.h" +#include "platform/android/jni/JniHelper.h" +#include "spidermonkey_specifics.h" +#include "ScriptingCore.h" +#include "js_manual_conversions.h" + +#define LOG_TAG "CCJavascriptJavaBridge" +#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) + +#ifdef __cplusplus +extern "C" { +#endif + +JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxJavascriptJavaBridge_evalString + (JNIEnv *env, jclass cls, jstring value) +{ + const char *_value = env->GetStringUTFChars(value, NULL); + ScriptingCore::getInstance()->evalString(_value,NULL); + env->ReleaseStringUTFChars(value, _value); + + return 1; +} + +#ifdef __cplusplus +} +#endif + +JavascriptJavaBridge::CallInfo::~CallInfo(void) +{ + if (m_returnType == TypeString && m_ret.stringValue) + { + delete m_ret.stringValue; + } +} + +bool JavascriptJavaBridge::CallInfo::execute(void) +{ + switch (m_returnType) + { + case TypeVoid: + m_env->CallStaticVoidMethod(m_classID, m_methodID); + break; + + case TypeInteger: + m_ret.intValue = m_env->CallStaticIntMethod(m_classID, m_methodID); + break; + + case TypeFloat: + m_ret.floatValue = m_env->CallStaticFloatMethod(m_classID, m_methodID); + break; + + case TypeBoolean: + m_ret.boolValue = m_env->CallStaticBooleanMethod(m_classID, m_methodID); + break; + + case TypeString: + m_retjstring = (jstring)m_env->CallStaticObjectMethod(m_classID, m_methodID); + const char *stringBuff = m_env->GetStringUTFChars(m_retjstring, 0); + m_ret.stringValue = new string(stringBuff); + m_env->ReleaseStringUTFChars(m_retjstring, stringBuff); + break; + } + + if (m_env->ExceptionCheck() == JNI_TRUE) + { + m_env->ExceptionDescribe(); + m_env->ExceptionClear(); + m_error = JSJ_ERR_EXCEPTION_OCCURRED; + return false; + } + + return true; +} + + +bool JavascriptJavaBridge::CallInfo::executeWithArgs(jvalue *args) +{ + switch (m_returnType) + { + case TypeVoid: + m_env->CallStaticVoidMethodA(m_classID, m_methodID, args); + break; + + case TypeInteger: + m_ret.intValue = m_env->CallStaticIntMethodA(m_classID, m_methodID, args); + break; + + case TypeFloat: + m_ret.floatValue = m_env->CallStaticFloatMethodA(m_classID, m_methodID, args); + break; + + case TypeBoolean: + m_ret.boolValue = m_env->CallStaticBooleanMethodA(m_classID, m_methodID, args); + break; + + case TypeString: + m_retjstring = (jstring)m_env->CallStaticObjectMethodA(m_classID, m_methodID, args); + const char *stringBuff = m_env->GetStringUTFChars(m_retjstring, 0); + m_ret.stringValue = new string(stringBuff); + m_env->ReleaseStringUTFChars(m_retjstring, stringBuff); + break; + } + + if (m_env->ExceptionCheck() == JNI_TRUE) + { + m_env->ExceptionDescribe(); + m_env->ExceptionClear(); + m_error = JSJ_ERR_EXCEPTION_OCCURRED; + return false; + } + + return true; +} + +bool JavascriptJavaBridge::CallInfo::validateMethodSig() +{ + size_t len = m_methodSig.length(); + if (len < 3 || m_methodSig[0] != '(') // min sig is "()V" + { + m_error = JSJ_ERR_INVALID_SIGNATURES; + return false; + } + + size_t pos = 1; + while (pos < len && m_methodSig[pos] != ')') + { + JavascriptJavaBridge::ValueType type = checkType(m_methodSig, &pos); + if (type == TypeInvalid) return false; + + m_argumentsCount++; + m_argumentsType.push_back(type); + pos++; + } + + if (pos >= len || m_methodSig[pos] != ')') + { + m_error = JSJ_ERR_INVALID_SIGNATURES; + return false; + } + + pos++; + m_returnType = checkType(m_methodSig, &pos); + return true; +} + +JavascriptJavaBridge::ValueType JavascriptJavaBridge::CallInfo::checkType(const string& sig, size_t *pos) +{ + switch (sig[*pos]) + { + case 'I': + return TypeInteger; + case 'F': + return TypeFloat; + case 'Z': + return TypeBoolean; + case 'V': + return TypeVoid; + case 'L': + size_t pos2 = sig.find_first_of(';', *pos + 1); + if (pos2 == string::npos) + { + m_error = JSJ_ERR_INVALID_SIGNATURES; + return TypeInvalid; + } + + const string t = sig.substr(*pos, pos2 - *pos + 1); + if (t.compare("Ljava/lang/String;") == 0) + { + *pos = pos2; + return TypeString; + } + else if (t.compare("Ljava/util/Vector;") == 0) + { + *pos = pos2; + return TypeVector; + } + else + { + m_error = JSJ_ERR_TYPE_NOT_SUPPORT; + return TypeInvalid; + } + } + + m_error = JSJ_ERR_TYPE_NOT_SUPPORT; + return TypeInvalid; +} + + +bool JavascriptJavaBridge::CallInfo::getMethodInfo(void) +{ + m_methodID = 0; + m_env = 0; + + JavaVM* jvm = cocos2d::JniHelper::getJavaVM(); + jint ret = jvm->GetEnv((void**)&m_env, JNI_VERSION_1_4); + switch (ret) { + case JNI_OK: + break; + + case JNI_EDETACHED : + if (jvm->AttachCurrentThread(&m_env, NULL) < 0) + { + LOGD("%s", "Failed to get the environment using AttachCurrentThread()"); + m_error = JSJ_ERR_VM_THREAD_DETACHED; + return false; + } + break; + + case JNI_EVERSION : + default : + LOGD("%s", "Failed to get the environment using GetEnv()"); + m_error = JSJ_ERR_VM_FAILURE; + return false; + } + jstring _jstrClassName = m_env->NewStringUTF(m_className.c_str()); + m_classID = (jclass) m_env->CallObjectMethod(cocos2d::JniHelper::classloader, + cocos2d::JniHelper::loadclassMethod_methodID, + _jstrClassName); + + if (NULL == m_classID) { + LOGD("Classloader failed to find class of %s", m_className.c_str()); + } + + m_env->DeleteLocalRef(_jstrClassName); + m_methodID = m_env->GetStaticMethodID(m_classID, m_methodName.c_str(), m_methodSig.c_str()); + if (!m_methodID) + { + m_env->ExceptionClear(); + LOGD("Failed to find method id of %s.%s %s", + m_className.c_str(), + m_methodName.c_str(), + m_methodSig.c_str()); + m_error = JSJ_ERR_METHOD_NOT_FOUND; + return false; + } + + return true; +} + +JS::Value JavascriptJavaBridge::convertReturnValue(JSContext *cx, ReturnValue retValue, ValueType type) +{ + JS::Value ret = JSVAL_NULL; + + switch (type) + { + case TypeInteger: + return INT_TO_JSVAL(retValue.intValue); + case TypeFloat: + return DOUBLE_TO_JSVAL((double)retValue.floatValue); + case TypeBoolean: + return BOOLEAN_TO_JSVAL(retValue.boolValue); + case TypeString: + return c_string_to_jsval(cx, retValue.stringValue->c_str(),retValue.stringValue->size()); + } + + return ret; +} + +/** + * @brief Initialize Object and needed properties. + * + */ +JS_BINDED_CLASS_GLUE_IMPL(JavascriptJavaBridge); + +/** + * @brief Implementation for the Javascript Constructor + * + */ +JS_BINDED_CONSTRUCTOR_IMPL(JavascriptJavaBridge) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JavascriptJavaBridge* jsj = new JavascriptJavaBridge(); + + js_proxy_t *p; + jsval out; + + JSObject *obj = JS_NewObject(cx, &JavascriptJavaBridge::js_class, JS::RootedObject(cx, JavascriptJavaBridge::js_proto), JS::RootedObject(cx, JavascriptJavaBridge::js_parent)); + + if (obj) { + JS_SetPrivate(obj, jsj); + out = OBJECT_TO_JSVAL(obj); + } + + args.rval().set(out); + p =jsb_new_proxy(jsj, obj); + + JS::AddNamedObjectRoot(cx, &p->obj, "JavascriptJavaBridge"); + return true; +} + +/** + * @brief destructor for Javascript + * + */ +static void basic_object_finalize(JSFreeOp *freeOp, JSObject *obj) +{ + CCLOG("jsbindings: finalizing JS object %p (JavascriptJavaBridge)", obj); + JavascriptJavaBridge* native = (JavascriptJavaBridge*)JS_GetPrivate(obj); + if(native) + { + delete native; + } +} + +/** + * @brief implementation for call java static method + */ +JS_BINDED_FUNC_IMPL(JavascriptJavaBridge, callStaticMethod) +{ + JS::CallArgs argv = JS::CallArgsFromVp(argc, vp); + if (argc == 3) { + JSStringWrapper arg0(argv[0]); + JSStringWrapper arg1(argv[1]); + JSStringWrapper arg2(argv[2]); + + CallInfo call(arg0.get(), arg1.get(), arg2.get()); + if(call.isValid()){ + bool success = call.execute(); + int errorCode = call.getErrorCode(); + if(errorCode < 0) + JS_ReportError(cx, "js_cocos2dx_JSJavaBridge : call result code: %d", errorCode); + argv.rval().set(convertReturnValue(cx, call.getReturnValue(), call.getReturnValueType())); + return success; + } + } + else if(argc > 3){ + JSStringWrapper arg0(argv[0]); + JSStringWrapper arg1(argv[1]); + JSStringWrapper arg2(argv[2]); + + CallInfo call(arg0.get(), arg1.get(), arg2.get()); + if(call.isValid() && call.getArgumentsCount() == (argc - 3)){ + int count = argc - 3; + jvalue *args = new jvalue[count]; + for (int i = 0; i < count; ++i){ + int index = i + 3; + switch (call.argumentTypeAtIndex(i)) + { + case TypeInteger: + double interger; + JS::ToNumber(cx, argv.get(index), &interger); + args[i].i = (int)interger; + break; + + case TypeFloat: + double floatNumber; + JS::ToNumber(cx, argv.get(index), &floatNumber); + args[i].f = (float)floatNumber; + break; + + case TypeBoolean: + args[i].z = JS::ToBoolean(argv.get(index)) ? JNI_TRUE : JNI_FALSE; + break; + + case TypeString: + default: + JSStringWrapper arg(argv.get(index)); + args[i].l = call.getEnv()->NewStringUTF(arg.get()); + break; + } + } + bool success = call.executeWithArgs(args); + if (args) delete []args; + int errorCode = call.getErrorCode(); + if(errorCode < 0) + JS_ReportError(cx, "js_cocos2dx_JSJavaBridge : call result code: %d", errorCode); + argv.rval().set(convertReturnValue(cx, call.getReturnValue(), call.getReturnValueType())); + return success; + } + + }else{ + JS_ReportError(cx, "js_cocos2dx_JSJavaBridge : wrong number of arguments: %d, was expecting more than 3", argc); + } + + return false; +} + +static bool js_is_native_obj(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().setBoolean(true); + return true; +} + +/** + * @brief register JavascriptJavaBridge to be usable in js + * + */ +void JavascriptJavaBridge::_js_register(JSContext *cx, JS::HandleObject global) +{ + JSClass jsclass = { + "JavascriptJavaBridge", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub,basic_object_finalize + }; + + JavascriptJavaBridge::js_class = jsclass; + static JSPropertySpec props[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_BINDED_FUNC_FOR_DEF(JavascriptJavaBridge, callStaticMethod), + JS_FS_END + }; + + JavascriptJavaBridge::js_parent = NULL; + JavascriptJavaBridge::js_proto = JS_InitClass(cx, global, JS::NullPtr(), &JavascriptJavaBridge::js_class , JavascriptJavaBridge::_js_constructor, 0, props, funcs, NULL, NULL); +} \ No newline at end of file diff --git a/cocos/scripting/js-bindings/manual/platform/android/CCJavascriptJavaBridge.h b/cocos/scripting/js-bindings/manual/platform/android/CCJavascriptJavaBridge.h new file mode 100644 index 0000000000..3e69efd1e3 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/platform/android/CCJavascriptJavaBridge.h @@ -0,0 +1,155 @@ +/* + * 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. + */ + +#ifndef __CC_JAVASCRIPT_JAVA_BRIDGE__ +#define __CC_JAVASCRIPT_JAVA_BRIDGE__ + +#include +#include +#include +#include "jsapi.h" +#include "jsfriendapi.h" +#include "js_bindings_config.h" +#include "jsb_helper.h" + +using namespace std; + +#define JSJ_ERR_OK (0) +#define JSJ_ERR_TYPE_NOT_SUPPORT (-1) +#define JSJ_ERR_INVALID_SIGNATURES (-2) +#define JSJ_ERR_METHOD_NOT_FOUND (-3) +#define JSJ_ERR_EXCEPTION_OCCURRED (-4) +#define JSJ_ERR_VM_THREAD_DETACHED (-5) +#define JSJ_ERR_VM_FAILURE (-6) + +class JavascriptJavaBridge +{ + +private: + typedef enum : char + { + TypeInvalid = -1, + TypeVoid = 0, + TypeInteger = 1, + TypeFloat = 2, + TypeBoolean = 3, + TypeString = 4, + TypeVector = 5, + TypeFunction= 6, + } ValueType; + + typedef vector ValueTypes; + + typedef union + { + int intValue; + float floatValue; + int boolValue; + string *stringValue; + } ReturnValue; + + class CallInfo + { + public: + CallInfo(const char *className, const char *methodName, const char *methodSig) + : m_valid(false) + , m_error(JSJ_ERR_OK) + , m_className(className) + , m_methodName(methodName) + , m_methodSig(methodSig) + , m_returnType(TypeVoid) + , m_argumentsCount(0) + , m_retjstring(NULL) + , m_env(NULL) + , m_classID(NULL) + , m_methodID(NULL) + { + memset(&m_ret, 0, sizeof(m_ret)); + m_valid = validateMethodSig() && getMethodInfo(); + } + ~CallInfo(void); + + bool isValid(void) { + return m_valid; + } + + int getErrorCode(void) { + return m_error; + } + + JNIEnv *getEnv(void) { + return m_env; + } + + int argumentTypeAtIndex(size_t index) { + return m_argumentsType.at(index); + } + + int getArgumentsCount(){ + return m_argumentsCount; + } + + ValueType getReturnValueType(){ + return m_returnType; + } + + ReturnValue getReturnValue(){ + return m_ret; + } + + bool execute(void); + bool executeWithArgs(jvalue *args); + + + private: + bool m_valid; + int m_error; + + string m_className; + string m_methodName; + string m_methodSig; + int m_argumentsCount; + ValueTypes m_argumentsType; + ValueType m_returnType; + + ReturnValue m_ret; + jstring m_retjstring; + + JNIEnv *m_env; + jclass m_classID; + jmethodID m_methodID; + + bool validateMethodSig(void); + bool getMethodInfo(void); + ValueType checkType(const string& sig, size_t *pos); + }; + + JS::Value convertReturnValue(JSContext *cx, ReturnValue retValue, ValueType type); +public: + + JS_BINDED_CLASS_GLUE(JavascriptJavaBridge); + JS_BINDED_CONSTRUCTOR(JavascriptJavaBridge); + JS_BINDED_FUNC(JavascriptJavaBridge, callStaticMethod); + +}; + +#endif \ No newline at end of file diff --git a/cocos/scripting/js-bindings/manual/platform/ios/JavaScriptObjCBridge.h b/cocos/scripting/js-bindings/manual/platform/ios/JavaScriptObjCBridge.h new file mode 100644 index 0000000000..5598e1bbe8 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/platform/ios/JavaScriptObjCBridge.h @@ -0,0 +1,108 @@ +/* + * 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. + */ + + + +#include +#include +#include "jsb_helper.h" +#include "jsapi.h" +#include "jsfriendapi.h" +#include "js_bindings_config.h" +using namespace std; + +#define JSO_ERR_OK (0) +#define JSO_ERR_TYPE_NOT_SUPPORT (-1) +#define JSO_ERR_INVALID_AEGUMENTS (-2) +#define JSO_ERR_METHOD_NOT_FOUND (-3) +#define JSO_ERR_EXCEPTION_OCCURRED (-4) +#define JSO_ERR_CLASS_NOT_FOUND (-5) +#define JSO_ERR_VM_FAILURE (-6) + +class JavaScriptObjCBridge{ + +private: + typedef enum : char + { + TypeInvalid = -1, + TypeVoid = 0, + TypeInteger = 1, + TypeFloat = 2, + TypeBoolean = 3, + TypeString = 4, + TypeVector = 5, + TypeFunction= 6, + } ValueType; + typedef vector ValueTypes; + + typedef union + { + int intValue; + float floatValue; + int boolValue; + string *stringValue; + } ReturnValue; + class CallInfo + { + public: + CallInfo(const char *className, const char *methodName) + :m_valid(false) + ,m_error(JSO_ERR_OK) + ,m_argumentsCount(0) + ,m_methodName(methodName) + ,m_className(className) + ,m_returnType(TypeVoid) + { + } + ~CallInfo(void); + bool isValid(void) { + return m_valid; + } + + int getErrorCode(void) { + return m_error; + } + ValueType getReturnValueType(){ + return m_returnType; + } + ReturnValue getReturnValue(){ + return m_ret; + } + bool execute(JSContext *cx,jsval *argv,unsigned argc); + private: + bool m_valid; + int m_error; + int m_argumentsCount; + string m_className; + string m_methodName; + ValueTypes m_argumentsType; + ValueType m_returnType; + ReturnValue m_ret; + string m_retjstring; + void pushValue(void *val); + }; + JS::Value convertReturnValue(JSContext *cx, ReturnValue retValue, ValueType type); +public: + JS_BINDED_CLASS_GLUE(JSObjCBridge); + JS_BINDED_CONSTRUCTOR(JSObjCBridge); + JS_BINDED_FUNC(JSObjCBridge, callStaticMethod); +}; \ No newline at end of file diff --git a/cocos/scripting/js-bindings/manual/platform/ios/JavaScriptObjCBridge.mm b/cocos/scripting/js-bindings/manual/platform/ios/JavaScriptObjCBridge.mm new file mode 100644 index 0000000000..cf5c3a0e9d --- /dev/null +++ b/cocos/scripting/js-bindings/manual/platform/ios/JavaScriptObjCBridge.mm @@ -0,0 +1,299 @@ +/* + * 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. + */ + +#import + +#import "JavaScriptObjCBridge.h" +#include "spidermonkey_specifics.h" +#include "ScriptingCore.h" +#include "js_manual_conversions.h" +#include "cocos2d.h" +JavaScriptObjCBridge::CallInfo::~CallInfo(void) +{ + if (m_returnType == TypeString) + { + delete m_ret.stringValue; + } +} +JS::Value JavaScriptObjCBridge::convertReturnValue(JSContext *cx, ReturnValue retValue, ValueType type) +{ + JS::Value ret = JSVAL_NULL; + + switch (type) + { + case TypeInteger: + return INT_TO_JSVAL(retValue.intValue); + case TypeFloat: + return DOUBLE_TO_JSVAL((double)retValue.floatValue); + case TypeBoolean: + return BOOLEAN_TO_JSVAL(retValue.boolValue); + case TypeString: + return c_string_to_jsval(cx, retValue.stringValue->c_str(),retValue.stringValue->size()); + } + + return ret; +} + +bool JavaScriptObjCBridge::CallInfo::execute(JSContext *cx,jsval *argv,unsigned argc) +{ + + NSString * className =[NSString stringWithCString: m_className.c_str() encoding:NSUTF8StringEncoding]; + NSString *methodName = [NSString stringWithCString: m_methodName.c_str() encoding:NSUTF8StringEncoding]; + + bool ok = true; + NSMutableDictionary *m_dic = [NSMutableDictionary dictionary]; + for(int i = 2;i0){ + if (strcmp(returnType, "@") == 0) + { + id ret; + [invocation getReturnValue:&ret]; + pushValue(ret); + } + else if (strcmp(returnType, "c") == 0 || strcmp(returnType, "B") == 0) // BOOL + { + char ret; + [invocation getReturnValue:&ret]; + m_ret.boolValue = ret; + m_returnType = TypeBoolean; + } + else if (strcmp(returnType, "i") == 0) // int + { + int ret; + [invocation getReturnValue:&ret]; + m_ret.intValue = ret; + m_returnType = TypeInteger; + } + else if (strcmp(returnType, "f") == 0) // float + { + float ret; + [invocation getReturnValue:&ret]; + m_ret.floatValue = ret; + m_returnType = TypeFloat; + } + else + { + m_error = JSO_ERR_TYPE_NOT_SUPPORT; + NSLog(@"not support return type = %s", returnType); + return false; + } + }else{ + m_returnType = TypeVoid; + } + }@catch(NSException *exception){ + NSLog(@"EXCEPTION THROW: %@", exception); + m_error = JSO_ERR_EXCEPTION_OCCURRED; + return false; + } + + return true; +} +void JavaScriptObjCBridge::CallInfo::pushValue(void *val){ + id oval = (id)val; + if (oval == nil) + { + return; + } + else if ([oval isKindOfClass:[NSNumber class]]) + { + NSNumber *number = (NSNumber *)oval; + const char *numberType = [number objCType]; + if (strcmp(numberType, @encode(BOOL)) == 0) + { + m_ret.boolValue = [number boolValue]; + m_returnType = TypeBoolean; + } + else if (strcmp(numberType, @encode(int)) == 0) + { + m_ret.intValue = [number intValue]; + m_returnType = TypeInteger; + } + else + { + m_ret.floatValue = [number floatValue]; + m_returnType = TypeFloat; + } + } + else if ([oval isKindOfClass:[NSString class]]) + { + const char *content = [oval cStringUsingEncoding:NSUTF8StringEncoding]; + m_ret.stringValue = new string(content); + m_returnType = TypeString; + } + else if ([oval isKindOfClass:[NSDictionary class]]) + { + + } + else + { + const char *content = [[NSString stringWithFormat:@"%@", oval] cStringUsingEncoding:NSUTF8StringEncoding]; + m_ret.stringValue = new string(content); + m_returnType = TypeString; + } +} +/** + * @brief Initialize Object and needed properties. + * + */ +JS_BINDED_CLASS_GLUE_IMPL(JavaScriptObjCBridge); + +/** + * @brief Implementation for the Javascript Constructor + * + */ +JS_BINDED_CONSTRUCTOR_IMPL(JavaScriptObjCBridge) +{ + JavaScriptObjCBridge* jsj = new JavaScriptObjCBridge(); + + js_proxy_t *p; + jsval out; + + JSObject *obj = JS_NewObject(cx, &JavaScriptObjCBridge::js_class, JS::RootedObject(cx, JavaScriptObjCBridge::js_proto), JS::RootedObject(cx, JavaScriptObjCBridge::js_parent)); + + if (obj) { + JS_SetPrivate(obj, jsj); + out = OBJECT_TO_JSVAL(obj); + } + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().set(out); + p =jsb_new_proxy(jsj, obj); + + JS::AddNamedObjectRoot(cx, &p->obj, "JavaScriptObjCBridge"); + return true; +} + +/** + * @brief destructor for Javascript + * + */ +static void basic_object_finalize(JSFreeOp *freeOp, JSObject *obj) +{ + CCLOG("basic_object_finalize %p ...", obj); +} + +JS_BINDED_FUNC_IMPL(JavaScriptObjCBridge, callStaticMethod){ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc >= 2) { + JSStringWrapper arg0(args.get(0)); + JSStringWrapper arg1(args.get(1)); + CallInfo call(arg0.get(),arg1.get()); + bool ok = call.execute(cx,args.array(),argc); + if(!ok){ + JS_ReportError(cx, "js_cocos2dx_JSObjCBridge : call result code: %d", call.getErrorCode()); + return false; + } + args.rval().set(convertReturnValue(cx, call.getReturnValue(), call.getReturnValueType())); + return ok; + } + return false; +} + +static bool js_is_native_obj(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().setBoolean(true); + return true; +} + +/** + * @brief register JavascriptJavaBridge to be usable in js + * + */ +void JavaScriptObjCBridge::_js_register(JSContext *cx, JS::HandleObject global) +{ + JSClass jsclass = { + "JavaScriptObjCBridge", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub,basic_object_finalize + }; + + JavaScriptObjCBridge::js_class = jsclass; + static JSPropertySpec props[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE ), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_BINDED_FUNC_FOR_DEF(JavaScriptObjCBridge, callStaticMethod), + JS_FS_END + }; + + JavaScriptObjCBridge::js_parent = NULL; + JavaScriptObjCBridge::js_proto = JS_InitClass(cx, global, JS::NullPtr(), &JavaScriptObjCBridge::js_class , JavaScriptObjCBridge::_js_constructor, 0, props, funcs, NULL, NULL); +} + + diff --git a/cocos/scripting/js-bindings/manual/spidermonkey_specifics.h b/cocos/scripting/js-bindings/manual/spidermonkey_specifics.h new file mode 100644 index 0000000000..a196189731 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/spidermonkey_specifics.h @@ -0,0 +1,104 @@ +/* + * 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. + */ + +#ifndef __SPIDERMONKEY_SPECIFICS_H__ +#define __SPIDERMONKEY_SPECIFICS_H__ + +#include "jsapi.h" +#include "jsfriendapi.h" +#include "uthash.h" +#include + +typedef struct js_proxy { + void *ptr; + JS::Heap obj; + UT_hash_handle hh; +} js_proxy_t; + +extern js_proxy_t *_native_js_global_ht; +extern js_proxy_t *_js_native_global_ht; + +typedef struct js_type_class { + JSClass *jsclass; + JS::Heap proto; + JS::Heap parentProto; +} js_type_class_t; + +extern std::unordered_map _js_global_type_map; + +template< typename DERIVED > +class TypeTest +{ +public: + static const char* s_name() + { + // return id unique for DERIVED + // ALWAYS VALID BUT STRING, NOT INT - BUT VALID AND CROSS-PLATFORM/CROSS-VERSION COMPATBLE + // AS FAR AS YOU KEEP THE CLASS NAME + return typeid( DERIVED ).name(); + } +}; + + +#define JS_NEW_PROXY(p, native_obj, js_obj) \ +do { \ + p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); \ + assert(p); \ + js_proxy_t* native_obj##js_obj##tmp = NULL; \ + HASH_FIND_PTR(_native_js_global_ht, &native_obj, native_obj##js_obj##tmp); \ + assert(!native_obj##js_obj##tmp); \ + p->ptr = native_obj; \ + p->obj = js_obj; \ + HASH_ADD_PTR(_native_js_global_ht, ptr, p); \ + p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); \ + assert(p); \ + native_obj##js_obj##tmp = NULL; \ + HASH_FIND_PTR(_js_native_global_ht, &js_obj, native_obj##js_obj##tmp); \ + assert(!native_obj##js_obj##tmp); \ + p->ptr = native_obj; \ + p->obj = js_obj; \ + HASH_ADD_PTR(_js_native_global_ht, obj, p); \ +} while(0) \ + +#define JS_GET_PROXY(p, native_obj) \ +do { \ + HASH_FIND_PTR(_native_js_global_ht, &native_obj, p); \ +} while (0) + +#define JS_GET_NATIVE_PROXY(p, js_obj) \ +do { \ + HASH_FIND_PTR(_js_native_global_ht, &js_obj, p); \ +} while (0) + +#define JS_REMOVE_PROXY(nproxy, jsproxy) \ +do { \ + if (nproxy) { HASH_DEL(_native_js_global_ht, nproxy); free(nproxy); } \ + if (jsproxy) { HASH_DEL(_js_native_global_ht, jsproxy); free(jsproxy); } \ +} while (0) + +#define TEST_NATIVE_OBJECT(cx, native_obj) \ +if (!native_obj) { \ + JS_ReportError(cx, "Invalid Native Object"); \ + return false; \ +} + +#endif diff --git a/cocos/scripting/js-bindings/manual/spine/jsb_cocos2dx_spine_manual.cpp b/cocos/scripting/js-bindings/manual/spine/jsb_cocos2dx_spine_manual.cpp new file mode 100644 index 0000000000..22881421c7 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/spine/jsb_cocos2dx_spine_manual.cpp @@ -0,0 +1,614 @@ +/* + * Created by ucchen on 2/12/14. + * 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. + */ + +#include "jsb_cocos2dx_spine_manual.h" +#include "ScriptingCore.h" +#include "cocos2d_specifics.hpp" +#include "spine/spine-cocos2dx.h" + +using namespace spine; + +jsval speventdata_to_jsval(JSContext* cx, spEventData& v) +{ + JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); + if (!tmp) return JSVAL_NULL; + bool ok = JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, c_string_to_jsval(cx, v.name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "intValue", v.intValue, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "floatValue", v.floatValue, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "stringValue", JS::RootedValue(cx, c_string_to_jsval(cx, v.stringValue)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + + if (ok) + { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + +jsval spevent_to_jsval(JSContext* cx, spEvent& v) +{ + JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); + if (!tmp) return JSVAL_NULL; + + bool ok = JS_DefineProperty(cx, tmp, "data", JS::RootedValue(cx, speventdata_to_jsval(cx, *v.data)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "intValue", v.intValue, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "floatValue", v.floatValue, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "stringValue", JS::RootedValue(cx, c_string_to_jsval(cx, v.stringValue)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + + if (ok) + { + return OBJECT_TO_JSVAL(tmp); + } + + return JSVAL_NULL; +} + +jsval spbonedata_to_jsval(JSContext* cx, const spBoneData* v) +{ + JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); + if (!tmp) return JSVAL_NULL; + + // root haven't parent + JS::RootedValue parentVal(cx); + if (strcmp(v->name, "root")) + parentVal = spbonedata_to_jsval(cx, v->parent); + + bool ok = JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, c_string_to_jsval(cx, v->name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "parent", parentVal,JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "length", v->length, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "x", v->x, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "y", v->y, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "rotation", v->rotation, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "scaleX", v->scaleX, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "scaleY", v->scaleY, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "inheritScale", v->inheritScale, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "inheritRotation", v->inheritRotation, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + if (ok) + { + return OBJECT_TO_JSVAL(tmp); + } + + return JSVAL_NULL; +} + +jsval spbone_to_jsval(JSContext* cx, spBone& v) +{ + JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); + if (!tmp) return JSVAL_NULL; + + // root haven't parent + JS::RootedValue parentVal(cx); + if (strcmp(v.data->name, "root")) + parentVal = spbone_to_jsval(cx, *v.parent); + + bool ok = JS_DefineProperty(cx, tmp, "data", JS::RootedValue(cx, spbonedata_to_jsval(cx, v.data)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "parent", parentVal, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "x", v.x, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "y", v.y, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "rotation", v.rotation, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "scaleX", v.scaleX, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "scaleY", v.scaleY, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "m00", v.m00, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "m01", v.m01, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "worldX", v.worldX, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "m10", v.m10, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "m11", v.m11, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "worldY", v.worldY, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "worldRotation", v.worldRotation, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "worldScaleX", v.worldScaleX, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "worldScaleY", v.worldScaleY, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + if (ok) + { + return OBJECT_TO_JSVAL(tmp); + } + + return JSVAL_NULL; +} + +jsval spskeleton_to_jsval(JSContext* cx, spSkeleton& v) +{ + JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); + if (!tmp) return JSVAL_NULL; + + bool ok = JS_DefineProperty(cx, tmp, "x", v.x, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "y", v.y, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "flipX", v.flipX, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "flipY", v.flipY, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "time", v.time, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "boneCount", v.bonesCount, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "slotCount", v.slotsCount, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + if (ok) + { + return OBJECT_TO_JSVAL(tmp); + } + + return JSVAL_NULL; +} + +jsval spattachment_to_jsval(JSContext* cx, spAttachment& v) +{ + JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); + if (!tmp) return JSVAL_NULL; + + bool ok = JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, c_string_to_jsval(cx, v.name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "type", v.type, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + if (ok) + { + return OBJECT_TO_JSVAL(tmp); + } + + return JSVAL_NULL; +} + +jsval spslotdata_to_jsval(JSContext* cx, spSlotData& v) +{ + JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); + if (!tmp) return JSVAL_NULL; + + bool ok = JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, c_string_to_jsval(cx, v.name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "attachmentName", JS::RootedValue(cx, c_string_to_jsval(cx, v.attachmentName)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "r", v.r, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "g", v.g, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "b", v.b, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "a", v.a, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "additiveBlending", v.additiveBlending, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "boneData", JS::RootedValue(cx, spbonedata_to_jsval(cx, v.boneData)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + + if (ok) + { + return OBJECT_TO_JSVAL(tmp); + } + + return JSVAL_NULL; +} + +jsval spslot_to_jsval(JSContext* cx, spSlot& v) +{ + JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); + if (!tmp) return JSVAL_NULL; + + bool ok = JS_DefineProperty(cx, tmp, "r", v.r, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "g", v.g, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "b", v.b, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "a", v.a, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "bone", JS::RootedValue(cx, spbone_to_jsval(cx, *v.bone)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + //JS_DefineProperty(cx, tmp, "skeleton", spskeleton_to_jsval(cx, *v.skeleton), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "attachment", JS::RootedValue(cx, spattachment_to_jsval(cx, *v.attachment)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "data", JS::RootedValue(cx, spslotdata_to_jsval(cx, *v.data)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + + if (ok) + { + return OBJECT_TO_JSVAL(tmp); + } + + return JSVAL_NULL; +} + +jsval sptimeline_to_jsval(JSContext* cx, spTimeline& v) +{ + JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); + if (!tmp) return JSVAL_NULL; + + bool ok = JS_DefineProperty(cx, tmp, "type", v.type, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + if (ok) + { + return OBJECT_TO_JSVAL(tmp); + } + + return JSVAL_NULL; +} + +jsval spanimationstate_to_jsval(JSContext* cx, spAnimationState& v) +{ + JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); + if (!tmp) return JSVAL_NULL; + + bool ok = JS_DefineProperty(cx, tmp, "timeScale", v.timeScale, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "trackCount", v.tracksCount, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + if (ok) + { + return OBJECT_TO_JSVAL(tmp); + } + + return JSVAL_NULL; +} + +jsval spanimation_to_jsval(JSContext* cx, spAnimation& v) +{ + JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); + if (!tmp) return JSVAL_NULL; + + bool ok = JS_DefineProperty(cx, tmp, "duration", v.duration, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "timelineCount", v.timelinesCount, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, c_string_to_jsval(cx, v.name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "timelines", JS::RootedValue(cx, sptimeline_to_jsval(cx, **v.timelines)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + + if (ok) + { + return OBJECT_TO_JSVAL(tmp); + } + + return JSVAL_NULL; +} + +jsval sptrackentry_to_jsval(JSContext* cx, spTrackEntry& v) +{ + JS::RootedObject tmp(cx, JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr())); + if (!tmp) return JSVAL_NULL; + + JS::RootedValue nextVal(cx); + if (v.next) + nextVal = sptrackentry_to_jsval(cx, *v.next); + + JS::RootedValue previousVal(cx); + if (v.previous) + previousVal = sptrackentry_to_jsval(cx, *v.previous); + + bool ok = JS_DefineProperty(cx, tmp, "delay", v.delay, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "time", v.time, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "lastTime", v.lastTime, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "endTime", v.endTime, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "timeScale", v.timeScale, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "mixTime", v.mixTime, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "mixDuration", v.mixDuration, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "animation", JS::RootedValue(cx, spanimation_to_jsval(cx, *v.animation)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "next", nextVal, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "previous", previousVal, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + if (ok) + { + return OBJECT_TO_JSVAL(tmp); + } + + return JSVAL_NULL; +} + +bool jsb_cocos2dx_spine_findBone(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + SkeletonRenderer* cobj = (SkeletonRenderer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + spBone* ret = cobj->findBone(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) + { + jsret = spbone_to_jsval(cx, *ret); + } + } while (0); + + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool jsb_cocos2dx_spine_findSlot(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + SkeletonRenderer* cobj = (SkeletonRenderer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + spSlot* ret = cobj->findSlot(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) + { + jsret = spslot_to_jsval(cx, *ret); + } + } while (0); + + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool jsb_cocos2dx_spine_setDebugBones(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + SkeletonRenderer* cobj = (SkeletonRenderer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + if (argc == 1) { + bool enable = args.get(0).toBoolean(); + cobj->setDebugBonesEnabled(enable); + + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool jsb_cocos2dx_spine_setDebugSolots(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + SkeletonRenderer* cobj = (SkeletonRenderer *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + if (argc == 1) { + bool enable = args.get(0).toBoolean(); + cobj->setDebugSlotsEnabled(enable); + + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool jsb_cocos2dx_spine_getAttachment(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + SkeletonRenderer* cobj = (SkeletonRenderer*)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + if (argc == 2) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, args.get(0), &arg0_tmp); arg0 = arg0_tmp.c_str(); + const char* arg1; + std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + spAttachment* ret = cobj->getAttachment(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) + { + jsret = spattachment_to_jsval(cx, *ret); + } + } while(0); + + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool jsb_cocos2dx_spine_getCurrent(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + 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, "Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + spTrackEntry* ret = cobj->getCurrent(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) + { + jsret = sptrackentry_to_jsval(cx, *ret); + } + } while (0); + + args.rval().set(jsret); + return true; + } + else if (argc == 0) { + spTrackEntry* ret = cobj->getCurrent(); + jsval jsret = JSVAL_NULL; + do { + if (ret) + { + jsret = sptrackentry_to_jsval(cx, *ret); + } + } while (0); + + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool jsb_cocos2dx_spine_setAnimation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + 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, "Invalid Native Object"); + if (argc == 3) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + + const char* arg1; + std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + + bool arg2 = JS::ToBoolean(JS::RootedValue(cx, args.get(2))); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + spTrackEntry* ret = cobj->setAnimation(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + + do { + if (ret) + { + jsret = sptrackentry_to_jsval(cx, *ret); + } + } while(0); + + args.rval().set(jsret); + return true; + } + + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool jsb_cocos2dx_spine_addAnimation(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + 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, "Invalid Native Object"); + if (argc == 3) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + + const char* arg1; + std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + + bool arg2 = JS::ToBoolean(args.get(2)); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + spTrackEntry* ret = cobj->addAnimation(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + + do { + if (ret) + { + jsret = sptrackentry_to_jsval(cx, *ret); + } + } while(0); + + args.rval().set(jsret); + return true; + } else if (argc == 4) { + int arg0; + ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0); + + const char* arg1; + std::string arg1_tmp; ok &= jsval_to_std_string(cx, args.get(1), &arg1_tmp); arg1 = arg1_tmp.c_str(); + + bool arg2 = JS::ToBoolean(args.get(2)); + + double arg3; + ok &= JS::ToNumber(cx, args.get(3), &arg3); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + spTrackEntry* ret = cobj->addAnimation(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + + do { + if (ret) + { + jsret = sptrackentry_to_jsval(cx, *ret); + } + } while(0); + + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + + +class JSSkeletonAnimationWrapper: public JSCallbackWrapper +{ +public: + JSSkeletonAnimationWrapper() {} + virtual ~JSSkeletonAnimationWrapper() {} + + void animationCallbackFunc(spine::SkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount) const { + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedObject thisObj(cx, _jsThisObj.toObjectOrNull()); + js_proxy_t *proxy = js_get_or_create_proxy(cx, node); + JS::RootedValue retval(cx); + if (_jsCallback != JSVAL_VOID) + { + jsval nodeVal = OBJECT_TO_JSVAL(proxy->obj); + jsval trackIndexVal = INT_TO_JSVAL(trackIndex); + int tmpType = (int)type; + jsval typeVal = INT_TO_JSVAL(tmpType); + jsval eventVal = JSVAL_NULL; + if (event) + eventVal = spevent_to_jsval(cx, *event); + jsval loopCountVal = INT_TO_JSVAL(loopCount); + + jsval valArr[5]; + valArr[0] = nodeVal; + valArr[1] = trackIndexVal; + valArr[2] = typeVal; + valArr[3] = eventVal; + valArr[4] = loopCountVal; + + //JS_AddValueRoot(cx, valArr); + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + JS_CallFunctionValue(cx, thisObj, JS::RootedValue(cx, _jsCallback), JS::HandleValueArray::fromMarkedLocation(5, valArr), &retval); + //JS_RemoveValueRoot(cx, valArr); + } + } +}; + + +extern JSObject* jsb_spine_SkeletonRenderer_prototype; +extern JSObject* jsb_spine_SkeletonAnimation_prototype; + +void register_all_cocos2dx_spine_manual(JSContext* cx, JS::HandleObject global) +{ + JS::RootedObject skeletonRenderer(cx, jsb_spine_SkeletonRenderer_prototype); + JS_DefineFunction(cx, skeletonRenderer, "findBone", jsb_cocos2dx_spine_findBone, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, skeletonRenderer, "findSlot", jsb_cocos2dx_spine_findSlot, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, skeletonRenderer, "setDebugBones", jsb_cocos2dx_spine_setDebugBones, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, skeletonRenderer, "setDebugSolots", jsb_cocos2dx_spine_setDebugSolots, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, skeletonRenderer, "getAttachment", jsb_cocos2dx_spine_getAttachment, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS::RootedObject skeletonAnimation(cx, jsb_spine_SkeletonAnimation_prototype); + JS_DefineFunction(cx, skeletonAnimation, "getCurrent", jsb_cocos2dx_spine_getCurrent, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, skeletonAnimation, "setAnimation", jsb_cocos2dx_spine_setAnimation, 3, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, skeletonAnimation, "addAnimation", jsb_cocos2dx_spine_addAnimation, 4, JSPROP_ENUMERATE | JSPROP_PERMANENT); + +} diff --git a/cocos/scripting/js-bindings/manual/spine/jsb_cocos2dx_spine_manual.h b/cocos/scripting/js-bindings/manual/spine/jsb_cocos2dx_spine_manual.h new file mode 100644 index 0000000000..6ccf87be76 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/spine/jsb_cocos2dx_spine_manual.h @@ -0,0 +1,45 @@ +/* + * Created by ucchen on 2/12/14. + * 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. + */ + +#ifndef __jsb_cocos2dx_spine_manual__ +#define __jsb_cocos2dx_spine_manual__ + +#include "jsapi.h" +#include "spine/spine-cocos2dx.h" + +void register_all_cocos2dx_spine_manual(JSContext* cx, JS::HandleObject global); + +extern jsval speventdata_to_jsval(JSContext* cx, spEventData& v); +extern jsval spevent_to_jsval(JSContext* cx, spEvent& v); +extern jsval spbonedata_to_jsval(JSContext* cx, const spBoneData* v); +extern jsval spbone_to_jsval(JSContext* cx, spBone& v); +extern jsval spskeleton_to_jsval(JSContext* cx, spSkeleton& v); +extern jsval spattachment_to_jsval(JSContext* cx, spAttachment& v); +extern jsval spslotdata_to_jsval(JSContext* cx, spSlotData& v); +extern jsval spslot_to_jsval(JSContext* cx, spSlot& v); +extern jsval sptimeline_to_jsval(JSContext* cx, spTimeline& v); +extern jsval spanimationstate_to_jsval(JSContext* cx, spAnimationState& v); +extern jsval spanimation_to_jsval(JSContext* cx, spAnimation& v); +extern jsval sptrackentry_to_jsval(JSContext* cx, spTrackEntry& v); + +#endif /* defined(__jsb_cocos2dx_spine_manual__) */ diff --git a/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp b/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp new file mode 100755 index 0000000000..07b338d760 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp @@ -0,0 +1,713 @@ +/* + * Created by LinWenhai on 17/11/13. + * 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. + */ + +#include "jsb_cocos2dx_ui_manual.h" +#include "ScriptingCore.h" +#include "cocos2d_specifics.hpp" +#include "ui/CocosGUI.h" + +using namespace cocos2d; +using namespace cocos2d::ui; + +class JSStudioEventListenerWrapper: public JSCallbackWrapper { +public: + JSStudioEventListenerWrapper(); + virtual ~JSStudioEventListenerWrapper(); + + virtual void setJSCallbackThis(jsval thisObj); + + virtual void eventCallbackFunc(Ref*,int); + +private: + bool m_bNeedUnroot; +}; + +JSStudioEventListenerWrapper::JSStudioEventListenerWrapper() + : m_bNeedUnroot(false) +{ + +} + +JSStudioEventListenerWrapper::~JSStudioEventListenerWrapper() +{ + if (m_bNeedUnroot) + { + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RemoveValueRoot(cx, &_jsThisObj); + } +} + +void JSStudioEventListenerWrapper::setJSCallbackThis(jsval jsThisObj) +{ + JSCallbackWrapper::setJSCallbackThis(jsThisObj); + + JSObject *thisObj = jsThisObj.toObjectOrNull(); + js_proxy *p = jsb_get_js_proxy(thisObj); + if (!p) + { + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + m_bNeedUnroot = true; + m_bNeedUnroot &= JS::AddValueRoot(cx, &_jsThisObj); + } +} + +void JSStudioEventListenerWrapper::eventCallbackFunc(Ref* sender,int eventType) +{ + JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RootedObject thisObj(cx, _jsThisObj.isNullOrUndefined() ? NULL : _jsThisObj.toObjectOrNull()); + js_proxy_t *proxy = js_get_or_create_proxy(cx, sender); + JS::RootedValue retval(cx); + if (!_jsCallback.isNullOrUndefined()) + { + jsval touchVal = INT_TO_JSVAL(eventType); + + jsval valArr[2]; + valArr[0] = OBJECT_TO_JSVAL(proxy->obj); + valArr[1] = touchVal; + + //JS::AddValueRoot(cx, valArr); + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JS_CallFunctionValue(cx, thisObj, JS::RootedValue(cx, _jsCallback), JS::HandleValueArray::fromMarkedLocation(2, valArr), &retval); + //JS::RemoveValueRoot(cx, valArr); + } +} + +class CallbacksComponent: public cocos2d::Component { +public: + CallbacksComponent(); + virtual ~CallbacksComponent(); + + cocos2d::__Dictionary* callbacks; + static const std::string NAME; +}; + +const std::string CallbacksComponent::NAME = "JSB_Callbacks"; + +CallbacksComponent::CallbacksComponent() +{ + setName(NAME); + callbacks = cocos2d::__Dictionary::create(); + CC_SAFE_RETAIN(callbacks); +} + +CallbacksComponent::~CallbacksComponent() +{ + CC_SAFE_RELEASE(callbacks); +} + +static bool js_cocos2dx_UIWidget_addTouchEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + ui::Widget* cobj = (ui::Widget *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 2) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); + tmpObj->autorelease(); + + CallbacksComponent *comp = static_cast(cobj->getComponent(CallbacksComponent::NAME)); + if (nullptr == comp) + { + comp = new CallbacksComponent(); + comp->autorelease(); + cobj->addComponent(comp); + } + cocos2d::__Dictionary* dict = comp->callbacks; + dict->setObject(tmpObj, "widgetTouchEvent"); + + tmpObj->setJSCallbackFunc(args.get(0)); + tmpObj->setJSCallbackThis(args.get(1)); + + cobj->addTouchEventListener(tmpObj, toucheventselector(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->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); + JS::RootedValue rval(cx); + + 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; +} + +static bool js_cocos2dx_UICheckBox_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + ui::CheckBox* cobj = (ui::CheckBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 2) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); + tmpObj->autorelease(); + + CallbacksComponent *comp = static_cast(cobj->getComponent(CallbacksComponent::NAME)); + if (nullptr == comp) + { + comp = new CallbacksComponent(); + comp->autorelease(); + cobj->addComponent(comp); + } + cocos2d::__Dictionary* dict = comp->callbacks; + dict->setObject(tmpObj, "checkBoxEventListener"); + + tmpObj->setJSCallbackFunc(args.get(0)); + tmpObj->setJSCallbackThis(args.get(1)); + + cobj->addEventListenerCheckBox(tmpObj, checkboxselectedeventselector(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, 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); + JS::RootedValue rval(cx); + + 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; +} + +static bool js_cocos2dx_UISlider_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + ui::Slider* cobj = (ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 2) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); + tmpObj->autorelease(); + + CallbacksComponent *comp = static_cast(cobj->getComponent(CallbacksComponent::NAME)); + if (nullptr == comp) + { + comp = new CallbacksComponent(); + comp->autorelease(); + cobj->addComponent(comp); + } + cocos2d::__Dictionary* dict = comp->callbacks; + dict->setObject(tmpObj, "sliderEventListener"); + + tmpObj->setJSCallbackFunc(args.get(0)); + tmpObj->setJSCallbackThis(args.get(1)); + + cobj->addEventListenerSlider(tmpObj, sliderpercentchangedselector(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, 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); + JS::RootedValue rval(cx); + + 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; +} + +static bool js_cocos2dx_UITextField_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + ui::TextField* cobj = (ui::TextField *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 2) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); + tmpObj->autorelease(); + + CallbacksComponent *comp = static_cast(cobj->getComponent(CallbacksComponent::NAME)); + if (nullptr == comp) + { + comp = new CallbacksComponent(); + comp->autorelease(); + cobj->addComponent(comp); + } + cocos2d::__Dictionary* dict = comp->callbacks; + dict->setObject(tmpObj, "textfieldEventListener"); + + tmpObj->setJSCallbackFunc(args.get(0)); + tmpObj->setJSCallbackThis(args.get(1)); + + cobj->addEventListenerTextField(tmpObj, textfieldeventselector(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, 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); + JS::RootedValue rval(cx); + + 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; +} + +static bool js_cocos2dx_UIPageView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + ui::PageView* cobj = (ui::PageView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 2) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); + tmpObj->autorelease(); + + CallbacksComponent *comp = static_cast(cobj->getComponent(CallbacksComponent::NAME)); + if (nullptr == comp) + { + comp = new CallbacksComponent(); + comp->autorelease(); + cobj->addComponent(comp); + } + cocos2d::__Dictionary* dict = comp->callbacks; + dict->setObject(tmpObj, "pageViewEventListener"); + + tmpObj->setJSCallbackFunc(args.get(0)); + tmpObj->setJSCallbackThis(args.get(1)); + + cobj->addEventListenerPageView(tmpObj, pagevieweventselector(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, 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); + JS::RootedValue rval(cx); + + 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; +} + +static bool js_cocos2dx_UIScrollView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + ui::ScrollView* cobj = (ui::ScrollView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 2) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); + tmpObj->autorelease(); + + CallbacksComponent *comp = static_cast(cobj->getComponent(CallbacksComponent::NAME)); + if (nullptr == comp) + { + comp = new CallbacksComponent(); + comp->autorelease(); + cobj->addComponent(comp); + } + cocos2d::__Dictionary* dict = comp->callbacks; + dict->setObject(tmpObj, "scrollViewEventListener"); + + tmpObj->setJSCallbackFunc(args.get(0)); + tmpObj->setJSCallbackThis(args.get(1)); + + 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); + JS::RootedValue rval(cx); + + 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; +} + +static bool js_cocos2dx_UIListView_addEventListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + ui::ListView* cobj = (ui::ListView *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 2) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + JSStudioEventListenerWrapper *tmpObj = new JSStudioEventListenerWrapper(); + tmpObj->autorelease(); + + CallbacksComponent *comp = static_cast(cobj->getComponent(CallbacksComponent::NAME)); + if (nullptr == comp) + { + comp = new CallbacksComponent(); + comp->autorelease(); + cobj->addComponent(comp); + } + cocos2d::__Dictionary* dict = comp->callbacks; + dict->setObject(tmpObj, "listViewEventListener"); + + tmpObj->setJSCallbackFunc(args.get(0)); + tmpObj->setJSCallbackThis(args.get(1)); + + cobj->addEventListenerListView(tmpObj, listvieweventselector(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))); + 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); + JS::RootedValue rval(cx); + + 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; +} + +static bool js_cocos2dx_LayoutParameter_setMargin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + ui::LayoutParameter* cobj = (ui::LayoutParameter *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 1) { + JS::CallArgs argv = CallArgsFromVp(argc, vp); + + JS::RootedObject tmp(cx); + JS::RootedValue jsleft(cx), jstop(cx),jsright(cx),jsbottom(cx); + double left, top,right,bottom; + bool ok = argv[0].isObject() && + JS_ValueToObject(cx, argv[0], &tmp) && + JS_GetProperty(cx, tmp, "left", &jsleft) && + JS_GetProperty(cx, tmp, "top", &jstop) && + JS_GetProperty(cx, tmp, "right", &jsright) && + JS_GetProperty(cx, tmp, "bottom", &jsbottom); + + left = jsleft.toNumber(); + top = jstop.toNumber(); + right = jsright.toNumber(); + bottom = jsbottom.toNumber(); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + cobj->setMargin(ui::Margin(left,top,right,bottom)); + return true; + } + else if (argc == 4) { + JS::CallArgs argv = CallArgsFromVp(argc, vp); + bool ok = true; + double left, top,right,bottom; + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[0]), &left); + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[1]), &top); + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[2]), &right); + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[3]), &bottom); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + cobj->setMargin(ui::Margin(left,top,right,bottom)); + return true; + } + JS_ReportError(cx, "Invalid number of arguments"); + return false; +} + +static bool js_cocos2dx_LayoutParameter_getMargin(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + ui::LayoutParameter* cobj = (ui::LayoutParameter *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 0) { + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr())); + if (!tmp) return false; + ui::Margin margin = cobj->getMargin(); + bool ok = JS_DefineProperty(cx, tmp, "left", margin.left, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "top", margin.top, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "right", margin.right, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "bottom", margin.bottom, JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) + { + //JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); + args.rval().set(OBJECT_TO_JSVAL(tmp)); + } + else + { + return false; + } + return true; + } + JS_ReportError(cx, "Invalid number of arguments"); + return false; +} + +class JSB_EditBoxDelegate +: public Ref +, public EditBoxDelegate +{ +public: + JSB_EditBoxDelegate() + : _JSDelegate(nullptr) + , _needUnroot(false) + {} + + virtual ~JSB_EditBoxDelegate() + { + if (_needUnroot) + { + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::RemoveObjectRoot(cx, &_JSDelegate); + } + } + + virtual void editBoxEditingDidBegin(EditBox* editBox) override + { + js_proxy_t * p = jsb_get_native_proxy(editBox); + if (!p) return; + + jsval arg = OBJECT_TO_JSVAL(p->obj); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxEditingDidBegin", 1, &arg); + } + + virtual void editBoxEditingDidEnd(EditBox* editBox) override + { + js_proxy_t * p = jsb_get_native_proxy(editBox); + if (!p) return; + + jsval arg = OBJECT_TO_JSVAL(p->obj); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxEditingDidEnd", 1, &arg); + } + + virtual void editBoxTextChanged(EditBox* editBox, const std::string& text) override + { + js_proxy_t * p = jsb_get_native_proxy(editBox); + if (!p) return; + + jsval dataVal[2]; + dataVal[0] = OBJECT_TO_JSVAL(p->obj); + std::string arg1 = text; + dataVal[1] = std_string_to_jsval(ScriptingCore::getInstance()->getGlobalContext(), arg1); + + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxTextChanged", 2, dataVal); + } + + virtual void editBoxReturn(EditBox* editBox) override + { + js_proxy_t * p = jsb_get_native_proxy(editBox); + if (!p) return; + + jsval arg = OBJECT_TO_JSVAL(p->obj); + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxReturn", 1, &arg); + } + + void setJSDelegate(JSObject* pJSDelegate) + { + _JSDelegate = pJSDelegate; + + // Check whether the js delegate is a pure js object. + js_proxy_t* p = jsb_get_js_proxy(_JSDelegate); + if (!p) + { + _needUnroot = true; + JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); + JS::AddNamedObjectRoot(cx, &_JSDelegate, "TableViewDelegate"); + } + } +private: + JS::Heap _JSDelegate; + bool _needUnroot; +}; + +static bool js_cocos2dx_CCEditBox_setDelegate(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::EditBox* cobj = (cocos2d::ui::EditBox *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "Invalid Native Object"); + + if (argc == 1) + { + // save the delegate + JSObject *jsDelegate = args.get(0).toObjectOrNull(); + JSB_EditBoxDelegate* nativeDelegate = new JSB_EditBoxDelegate(); + nativeDelegate->setJSDelegate(jsDelegate); + + cobj->setUserObject(nativeDelegate); + cobj->setDelegate(nativeDelegate); + + nativeDelegate->release(); + + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +extern JSObject* jsb_cocos2d_ui_Widget_prototype; +extern JSObject* jsb_cocos2d_ui_CheckBox_prototype; +extern JSObject* jsb_cocos2d_ui_Slider_prototype; +extern JSObject* jsb_cocos2d_ui_TextField_prototype; +extern JSObject* jsb_cocos2d_ui_LayoutParameter_prototype; +extern JSObject* jsb_cocos2d_ui_PageView_prototype; +extern JSObject* jsb_cocos2d_ui_ScrollView_prototype; +extern JSObject* jsb_cocos2d_ui_ListView_prototype; +extern JSObject* jsb_cocos2d_ui_EditBox_prototype; + +void register_all_cocos2dx_ui_manual(JSContext* cx, JS::HandleObject global) +{ + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_Widget_prototype), "addTouchEventListener", js_cocos2dx_UIWidget_addTouchEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_CheckBox_prototype), "addEventListener", js_cocos2dx_UICheckBox_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_Slider_prototype), "addEventListener", js_cocos2dx_UISlider_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_TextField_prototype), "addEventListener", js_cocos2dx_UITextField_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_PageView_prototype), "addEventListener", js_cocos2dx_UIPageView_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_ScrollView_prototype), "addEventListener", js_cocos2dx_UIScrollView_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_ListView_prototype), "addEventListener", js_cocos2dx_UIListView_addEventListener, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_LayoutParameter_prototype), "setMargin", js_cocos2dx_LayoutParameter_setMargin, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_LayoutParameter_prototype), "getMargin", js_cocos2dx_LayoutParameter_getMargin, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + + JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_ui_EditBox_prototype), "setDelegate", js_cocos2dx_CCEditBox_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); +} diff --git a/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.h b/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.h new file mode 100644 index 0000000000..a4822433bc --- /dev/null +++ b/cocos/scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.h @@ -0,0 +1,32 @@ +/* + * Created by LinWenhai on 17/11/13. + * 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. + */ + +#ifndef __jsb_cocos2dx_ui_manual__ +#define __jsb_cocos2dx_ui_manual__ + +#include "jsapi.h" +#include "jsfriendapi.h" + +void register_all_cocos2dx_ui_manual(JSContext* cx, JS::HandleObject global); + +#endif /* defined(__jsb_cocos2dx_ui_manual__) */ diff --git a/cocos/scripting/js-bindings/proj.android/Android.mk b/cocos/scripting/js-bindings/proj.android/Android.mk new file mode 100755 index 0000000000..328a7a1cb1 --- /dev/null +++ b/cocos/scripting/js-bindings/proj.android/Android.mk @@ -0,0 +1,105 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := cocos2d_js_android_static + +LOCAL_MODULE_FILENAME := libjscocos2dandroid + +ifeq ($(COCOS_SIMULATOR_BUILD),1) +LOCAL_ARM_MODE := arm +endif + +LOCAL_SRC_FILES := ../manual/platform/android/CCJavascriptJavaBridge.cpp + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../.. \ + $(LOCAL_PATH)/../manual \ + $(LOCAL_PATH)/../manual/platform/android \ + $(LOCAL_PATH)/../../../base \ + $(LOCAL_PATH)/../../../../external/chipmunk/include/chipmunk + +LOCAL_EXPORT_LDLIBS := -lGLESv2 \ + -llog \ + -lz \ + -landroid + +LOCAL_STATIC_LIBRARIES := spidermonkey_static + +include $(BUILD_STATIC_LIBRARY) + +#============================================================== + +include $(CLEAR_VARS) + +LOCAL_MODULE := cocos2d_js_static + +LOCAL_MODULE_FILENAME := libjscocos2d + +LOCAL_SRC_FILES := ../auto/jsb_cocos2dx_3d_auto.cpp \ + ../auto/jsb_cocos2dx_extension_auto.cpp \ + ../auto/jsb_cocos2dx_3d_extension_auto.cpp \ + ../auto/jsb_cocos2dx_spine_auto.cpp \ + ../auto/jsb_cocos2dx_auto.cpp \ + ../auto/jsb_cocos2dx_studio_auto.cpp \ + ../auto/jsb_cocos2dx_builder_auto.cpp \ + ../auto/jsb_cocos2dx_ui_auto.cpp \ + ../manual/ScriptingCore.cpp \ \ + ../manual/cocos2d_specifics.cpp \ + ../manual/js_manual_conversions.cpp \ + ../manual/js_bindings_core.cpp \ + ../manual/js_bindings_opengl.cpp \ + ../manual/jsb_opengl_functions.cpp \ + ../manual/jsb_opengl_manual.cpp \ + ../manual/jsb_opengl_registration.cpp \ + ../manual/jsb_event_dispatcher_manual.cpp \ + ../manual/3d/jsb_cocos2dx_3d_manual.cpp \ + ../manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp \ + ../manual/chipmunk/js_bindings_chipmunk_functions.cpp \ + ../manual/chipmunk/js_bindings_chipmunk_manual.cpp \ + ../manual/chipmunk/js_bindings_chipmunk_registration.cpp \ + ../manual/cocosbuilder/js_bindings_ccbreader.cpp \ + ../manual/cocostudio/jsb_cocos2dx_studio_conversions.cpp \ + ../manual/cocostudio/jsb_cocos2dx_studio_manual.cpp \ + ../manual/extension/jsb_cocos2dx_extension_manual.cpp \ + ../manual/localstorage/js_bindings_system_functions.cpp \ + ../manual/localstorage/js_bindings_system_registration.cpp \ + ../manual/network/jsb_socketio.cpp \ + ../manual/network/jsb_websocket.cpp \ + ../manual/network/XMLHTTPRequest.cpp \ + ../manual/spine/jsb_cocos2dx_spine_manual.cpp \ + ../manual/ui/jsb_cocos2dx_ui_manual.cpp + + +LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT + +LOCAL_EXPORT_CFLAGS := -DCOCOS2D_JAVASCRIPT + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../manual \ + $(LOCAL_PATH)/../manual/cocostudio \ + $(LOCAL_PATH)/../manual/spine \ + $(LOCAL_PATH)/../auto \ + $(LOCAL_PATH)/../../../2d \ + $(LOCAL_PATH)/../../../base \ + $(LOCAL_PATH)/../../../ui \ + $(LOCAL_PATH)/../../../audio/include \ + $(LOCAL_PATH)/../../../storage \ + $(LOCAL_PATH)/../../../../extensions \ + $(LOCAL_PATH)/../../../editor-support/spine \ + $(LOCAL_PATH)/../../../editor-support/cocosbuilder \ + $(LOCAL_PATH)/../../../editor-support/cocostudio + + +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../manual \ + $(LOCAL_PATH)/../auto \ + $(LOCAL_PATH)/../../../audio/include + +LOCAL_WHOLE_STATIC_LIBRARIES := cocos2d_js_android_static + +LOCAL_STATIC_LIBRARIES := cocos2dx_static +LOCAL_STATIC_LIBRARIES += cocos_localstorage_static + +include $(BUILD_STATIC_LIBRARY) + +$(call import-module,.) +$(call import-module,external/spidermonkey/prebuilt/android) +$(call import-module,storage/local-storage) diff --git a/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..1cb63bee57 --- /dev/null +++ b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj @@ -0,0 +1,1002 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 0541A74F1973876100E45470 /* JavaScriptObjCBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 0541A74D1973876100E45470 /* JavaScriptObjCBridge.h */; }; + 0541A7501973876100E45470 /* JavaScriptObjCBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0541A74E1973876100E45470 /* JavaScriptObjCBridge.mm */; }; + 0541A75B19738AD200E45470 /* JavaScriptObjCBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0541A74E1973876100E45470 /* JavaScriptObjCBridge.mm */; }; + 1A119E8318BDF19200352BAA /* jsb_cocos2dx_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E2F18BDF19200352BAA /* jsb_cocos2dx_auto.cpp */; }; + 1A119E8418BDF19200352BAA /* jsb_cocos2dx_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E2F18BDF19200352BAA /* jsb_cocos2dx_auto.cpp */; }; + 1A119E8518BDF19200352BAA /* jsb_cocos2dx_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E3018BDF19200352BAA /* jsb_cocos2dx_auto.hpp */; }; + 1A119E8618BDF19200352BAA /* jsb_cocos2dx_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E3018BDF19200352BAA /* jsb_cocos2dx_auto.hpp */; }; + 1A119E8918BDF19200352BAA /* jsb_cocos2dx_builder_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E3218BDF19200352BAA /* jsb_cocos2dx_builder_auto.cpp */; }; + 1A119E8A18BDF19200352BAA /* jsb_cocos2dx_builder_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E3218BDF19200352BAA /* jsb_cocos2dx_builder_auto.cpp */; }; + 1A119E8B18BDF19200352BAA /* jsb_cocos2dx_builder_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E3318BDF19200352BAA /* jsb_cocos2dx_builder_auto.hpp */; }; + 1A119E8C18BDF19200352BAA /* jsb_cocos2dx_builder_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E3318BDF19200352BAA /* jsb_cocos2dx_builder_auto.hpp */; }; + 1A119E8F18BDF19200352BAA /* jsb_cocos2dx_extension_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E3518BDF19200352BAA /* jsb_cocos2dx_extension_auto.cpp */; }; + 1A119E9018BDF19200352BAA /* jsb_cocos2dx_extension_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E3518BDF19200352BAA /* jsb_cocos2dx_extension_auto.cpp */; }; + 1A119E9118BDF19200352BAA /* jsb_cocos2dx_extension_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E3618BDF19200352BAA /* jsb_cocos2dx_extension_auto.hpp */; }; + 1A119E9218BDF19200352BAA /* jsb_cocos2dx_extension_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E3618BDF19200352BAA /* jsb_cocos2dx_extension_auto.hpp */; }; + 1A119E9B18BDF19200352BAA /* jsb_cocos2dx_spine_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E3B18BDF19200352BAA /* jsb_cocos2dx_spine_auto.cpp */; }; + 1A119E9C18BDF19200352BAA /* jsb_cocos2dx_spine_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E3B18BDF19200352BAA /* jsb_cocos2dx_spine_auto.cpp */; }; + 1A119E9D18BDF19200352BAA /* jsb_cocos2dx_spine_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E3C18BDF19200352BAA /* jsb_cocos2dx_spine_auto.hpp */; }; + 1A119E9E18BDF19200352BAA /* jsb_cocos2dx_spine_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E3C18BDF19200352BAA /* jsb_cocos2dx_spine_auto.hpp */; }; + 1A119EA118BDF19200352BAA /* jsb_cocos2dx_studio_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E3E18BDF19200352BAA /* jsb_cocos2dx_studio_auto.cpp */; }; + 1A119EA218BDF19200352BAA /* jsb_cocos2dx_studio_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E3E18BDF19200352BAA /* jsb_cocos2dx_studio_auto.cpp */; }; + 1A119EA318BDF19200352BAA /* jsb_cocos2dx_studio_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E3F18BDF19200352BAA /* jsb_cocos2dx_studio_auto.hpp */; }; + 1A119EA418BDF19200352BAA /* jsb_cocos2dx_studio_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E3F18BDF19200352BAA /* jsb_cocos2dx_studio_auto.hpp */; }; + 1A119EA718BDF19200352BAA /* js_bindings_chipmunk_auto_classes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E4418BDF19200352BAA /* js_bindings_chipmunk_auto_classes.cpp */; }; + 1A119EA818BDF19200352BAA /* js_bindings_chipmunk_auto_classes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E4418BDF19200352BAA /* js_bindings_chipmunk_auto_classes.cpp */; }; + 1A119EA918BDF19200352BAA /* js_bindings_chipmunk_auto_classes.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E4518BDF19200352BAA /* js_bindings_chipmunk_auto_classes.h */; }; + 1A119EAA18BDF19200352BAA /* js_bindings_chipmunk_auto_classes.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E4518BDF19200352BAA /* js_bindings_chipmunk_auto_classes.h */; }; + 1A119EAB18BDF19200352BAA /* js_bindings_chipmunk_auto_classes_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E4618BDF19200352BAA /* js_bindings_chipmunk_auto_classes_registration.h */; }; + 1A119EAC18BDF19200352BAA /* js_bindings_chipmunk_auto_classes_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E4618BDF19200352BAA /* js_bindings_chipmunk_auto_classes_registration.h */; }; + 1A119EAD18BDF19200352BAA /* js_bindings_chipmunk_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E4718BDF19200352BAA /* js_bindings_chipmunk_functions.cpp */; }; + 1A119EAE18BDF19200352BAA /* js_bindings_chipmunk_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E4718BDF19200352BAA /* js_bindings_chipmunk_functions.cpp */; }; + 1A119EAF18BDF19200352BAA /* js_bindings_chipmunk_functions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E4818BDF19200352BAA /* js_bindings_chipmunk_functions.h */; }; + 1A119EB018BDF19200352BAA /* js_bindings_chipmunk_functions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E4818BDF19200352BAA /* js_bindings_chipmunk_functions.h */; }; + 1A119EB118BDF19200352BAA /* js_bindings_chipmunk_functions_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E4918BDF19200352BAA /* js_bindings_chipmunk_functions_registration.h */; }; + 1A119EB218BDF19200352BAA /* js_bindings_chipmunk_functions_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E4918BDF19200352BAA /* js_bindings_chipmunk_functions_registration.h */; }; + 1A119EB318BDF19200352BAA /* js_bindings_chipmunk_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E4A18BDF19200352BAA /* js_bindings_chipmunk_manual.cpp */; }; + 1A119EB418BDF19200352BAA /* js_bindings_chipmunk_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E4A18BDF19200352BAA /* js_bindings_chipmunk_manual.cpp */; }; + 1A119EB518BDF19200352BAA /* js_bindings_chipmunk_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E4B18BDF19200352BAA /* js_bindings_chipmunk_manual.h */; }; + 1A119EB618BDF19200352BAA /* js_bindings_chipmunk_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E4B18BDF19200352BAA /* js_bindings_chipmunk_manual.h */; }; + 1A119EB718BDF19200352BAA /* js_bindings_chipmunk_registration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E4C18BDF19200352BAA /* js_bindings_chipmunk_registration.cpp */; }; + 1A119EB818BDF19200352BAA /* js_bindings_chipmunk_registration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E4C18BDF19200352BAA /* js_bindings_chipmunk_registration.cpp */; }; + 1A119EB918BDF19200352BAA /* js_bindings_chipmunk_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E4D18BDF19200352BAA /* js_bindings_chipmunk_registration.h */; }; + 1A119EBA18BDF19200352BAA /* js_bindings_chipmunk_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E4D18BDF19200352BAA /* js_bindings_chipmunk_registration.h */; }; + 1A119EBB18BDF19200352BAA /* cocos2d_specifics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E4E18BDF19200352BAA /* cocos2d_specifics.cpp */; }; + 1A119EBC18BDF19200352BAA /* cocos2d_specifics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E4E18BDF19200352BAA /* cocos2d_specifics.cpp */; }; + 1A119EBD18BDF19200352BAA /* cocos2d_specifics.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E4F18BDF19200352BAA /* cocos2d_specifics.hpp */; }; + 1A119EBE18BDF19200352BAA /* cocos2d_specifics.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E4F18BDF19200352BAA /* cocos2d_specifics.hpp */; }; + 1A119EBF18BDF19200352BAA /* cocosbuilder_specifics.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E5218BDF19200352BAA /* cocosbuilder_specifics.hpp */; }; + 1A119EC018BDF19200352BAA /* cocosbuilder_specifics.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E5218BDF19200352BAA /* cocosbuilder_specifics.hpp */; }; + 1A119EC118BDF19200352BAA /* js_bindings_ccbreader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E5318BDF19200352BAA /* js_bindings_ccbreader.cpp */; }; + 1A119EC218BDF19200352BAA /* js_bindings_ccbreader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E5318BDF19200352BAA /* js_bindings_ccbreader.cpp */; }; + 1A119EC318BDF19200352BAA /* js_bindings_ccbreader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E5418BDF19200352BAA /* js_bindings_ccbreader.h */; }; + 1A119EC418BDF19200352BAA /* js_bindings_ccbreader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E5418BDF19200352BAA /* js_bindings_ccbreader.h */; }; + 1A119EC518BDF19200352BAA /* jsb_cocos2dx_studio_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E5718BDF19200352BAA /* jsb_cocos2dx_studio_manual.cpp */; }; + 1A119EC618BDF19200352BAA /* jsb_cocos2dx_studio_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E5718BDF19200352BAA /* jsb_cocos2dx_studio_manual.cpp */; }; + 1A119EC718BDF19200352BAA /* jsb_cocos2dx_studio_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E5818BDF19200352BAA /* jsb_cocos2dx_studio_manual.h */; }; + 1A119EC818BDF19200352BAA /* jsb_cocos2dx_studio_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E5818BDF19200352BAA /* jsb_cocos2dx_studio_manual.h */; }; + 1A119EC918BDF19200352BAA /* jsb_cocos2dx_extension_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E5B18BDF19200352BAA /* jsb_cocos2dx_extension_manual.cpp */; }; + 1A119ECA18BDF19200352BAA /* jsb_cocos2dx_extension_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E5B18BDF19200352BAA /* jsb_cocos2dx_extension_manual.cpp */; }; + 1A119ECB18BDF19200352BAA /* jsb_cocos2dx_extension_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E5C18BDF19200352BAA /* jsb_cocos2dx_extension_manual.h */; }; + 1A119ECC18BDF19200352BAA /* jsb_cocos2dx_extension_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E5C18BDF19200352BAA /* jsb_cocos2dx_extension_manual.h */; }; + 1A119ED118BDF19200352BAA /* js_bindings_config.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E6118BDF19200352BAA /* js_bindings_config.h */; }; + 1A119ED218BDF19200352BAA /* js_bindings_config.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E6118BDF19200352BAA /* js_bindings_config.h */; }; + 1A119ED318BDF19200352BAA /* js_bindings_core.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E6218BDF19200352BAA /* js_bindings_core.cpp */; }; + 1A119ED418BDF19200352BAA /* js_bindings_core.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E6218BDF19200352BAA /* js_bindings_core.cpp */; }; + 1A119ED518BDF19200352BAA /* js_bindings_core.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E6318BDF19200352BAA /* js_bindings_core.h */; }; + 1A119ED618BDF19200352BAA /* js_bindings_core.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E6318BDF19200352BAA /* js_bindings_core.h */; }; + 1A119ED718BDF19200352BAA /* js_bindings_opengl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E6418BDF19200352BAA /* js_bindings_opengl.cpp */; }; + 1A119ED818BDF19200352BAA /* js_bindings_opengl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E6418BDF19200352BAA /* js_bindings_opengl.cpp */; }; + 1A119ED918BDF19200352BAA /* js_bindings_opengl.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E6518BDF19200352BAA /* js_bindings_opengl.h */; }; + 1A119EDA18BDF19200352BAA /* js_bindings_opengl.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E6518BDF19200352BAA /* js_bindings_opengl.h */; }; + 1A119EDB18BDF19200352BAA /* js_manual_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E6618BDF19200352BAA /* js_manual_conversions.cpp */; }; + 1A119EDC18BDF19200352BAA /* js_manual_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E6618BDF19200352BAA /* js_manual_conversions.cpp */; }; + 1A119EDD18BDF19200352BAA /* js_manual_conversions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E6718BDF19200352BAA /* js_manual_conversions.h */; }; + 1A119EDE18BDF19200352BAA /* js_manual_conversions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E6718BDF19200352BAA /* js_manual_conversions.h */; }; + 1A119EDF18BDF19200352BAA /* jsb_helper.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E6818BDF19200352BAA /* jsb_helper.h */; }; + 1A119EE018BDF19200352BAA /* jsb_helper.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E6818BDF19200352BAA /* jsb_helper.h */; }; + 1A119EE118BDF19200352BAA /* jsb_opengl_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E6918BDF19200352BAA /* jsb_opengl_functions.cpp */; }; + 1A119EE218BDF19200352BAA /* jsb_opengl_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E6918BDF19200352BAA /* jsb_opengl_functions.cpp */; }; + 1A119EE318BDF19200352BAA /* jsb_opengl_functions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E6A18BDF19200352BAA /* jsb_opengl_functions.h */; }; + 1A119EE418BDF19200352BAA /* jsb_opengl_functions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E6A18BDF19200352BAA /* jsb_opengl_functions.h */; }; + 1A119EE518BDF19200352BAA /* jsb_opengl_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E6B18BDF19200352BAA /* jsb_opengl_manual.cpp */; }; + 1A119EE618BDF19200352BAA /* jsb_opengl_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E6B18BDF19200352BAA /* jsb_opengl_manual.cpp */; }; + 1A119EE718BDF19200352BAA /* jsb_opengl_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E6C18BDF19200352BAA /* jsb_opengl_manual.h */; }; + 1A119EE818BDF19200352BAA /* jsb_opengl_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E6C18BDF19200352BAA /* jsb_opengl_manual.h */; }; + 1A119EE918BDF19200352BAA /* jsb_opengl_registration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E6D18BDF19200352BAA /* jsb_opengl_registration.cpp */; }; + 1A119EEA18BDF19200352BAA /* jsb_opengl_registration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E6D18BDF19200352BAA /* jsb_opengl_registration.cpp */; }; + 1A119EEB18BDF19200352BAA /* jsb_opengl_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E6E18BDF19200352BAA /* jsb_opengl_registration.h */; }; + 1A119EEC18BDF19200352BAA /* jsb_opengl_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E6E18BDF19200352BAA /* jsb_opengl_registration.h */; }; + 1A119EED18BDF19200352BAA /* js_bindings_system_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E7118BDF19200352BAA /* js_bindings_system_functions.cpp */; }; + 1A119EEE18BDF19200352BAA /* js_bindings_system_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E7118BDF19200352BAA /* js_bindings_system_functions.cpp */; }; + 1A119EEF18BDF19200352BAA /* js_bindings_system_functions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E7218BDF19200352BAA /* js_bindings_system_functions.h */; }; + 1A119EF018BDF19200352BAA /* js_bindings_system_functions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E7218BDF19200352BAA /* js_bindings_system_functions.h */; }; + 1A119EF118BDF19200352BAA /* js_bindings_system_functions_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E7318BDF19200352BAA /* js_bindings_system_functions_registration.h */; }; + 1A119EF218BDF19200352BAA /* js_bindings_system_functions_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E7318BDF19200352BAA /* js_bindings_system_functions_registration.h */; }; + 1A119EF318BDF19200352BAA /* js_bindings_system_registration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E7418BDF19200352BAA /* js_bindings_system_registration.cpp */; }; + 1A119EF418BDF19200352BAA /* js_bindings_system_registration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E7418BDF19200352BAA /* js_bindings_system_registration.cpp */; }; + 1A119EF518BDF19200352BAA /* js_bindings_system_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E7518BDF19200352BAA /* js_bindings_system_registration.h */; }; + 1A119EF618BDF19200352BAA /* js_bindings_system_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E7518BDF19200352BAA /* js_bindings_system_registration.h */; }; + 1A119EF718BDF19200352BAA /* jsb_websocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E7818BDF19200352BAA /* jsb_websocket.cpp */; }; + 1A119EF818BDF19200352BAA /* jsb_websocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E7818BDF19200352BAA /* jsb_websocket.cpp */; }; + 1A119EF918BDF19200352BAA /* jsb_websocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E7918BDF19200352BAA /* jsb_websocket.h */; }; + 1A119EFA18BDF19200352BAA /* jsb_websocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E7918BDF19200352BAA /* jsb_websocket.h */; }; + 1A119EFB18BDF19200352BAA /* XMLHTTPRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E7A18BDF19200352BAA /* XMLHTTPRequest.cpp */; }; + 1A119EFC18BDF19200352BAA /* XMLHTTPRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E7A18BDF19200352BAA /* XMLHTTPRequest.cpp */; }; + 1A119EFD18BDF19200352BAA /* XMLHTTPRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E7B18BDF19200352BAA /* XMLHTTPRequest.h */; }; + 1A119EFE18BDF19200352BAA /* XMLHTTPRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E7B18BDF19200352BAA /* XMLHTTPRequest.h */; }; + 1A119EFF18BDF19200352BAA /* ScriptingCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E7C18BDF19200352BAA /* ScriptingCore.cpp */; }; + 1A119F0018BDF19200352BAA /* ScriptingCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E7C18BDF19200352BAA /* ScriptingCore.cpp */; }; + 1A119F0118BDF19200352BAA /* ScriptingCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E7D18BDF19200352BAA /* ScriptingCore.h */; }; + 1A119F0218BDF19200352BAA /* ScriptingCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E7D18BDF19200352BAA /* ScriptingCore.h */; }; + 1A119F0318BDF19200352BAA /* spidermonkey_specifics.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E7E18BDF19200352BAA /* spidermonkey_specifics.h */; }; + 1A119F0418BDF19200352BAA /* spidermonkey_specifics.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E7E18BDF19200352BAA /* spidermonkey_specifics.h */; }; + 1A119F0518BDF19200352BAA /* jsb_cocos2dx_spine_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E8118BDF19200352BAA /* jsb_cocos2dx_spine_manual.cpp */; }; + 1A119F0618BDF19200352BAA /* jsb_cocos2dx_spine_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E8118BDF19200352BAA /* jsb_cocos2dx_spine_manual.cpp */; }; + 1A119F0718BDF19200352BAA /* jsb_cocos2dx_spine_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E8218BDF19200352BAA /* jsb_cocos2dx_spine_manual.h */; }; + 1A119F0818BDF19200352BAA /* jsb_cocos2dx_spine_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E8218BDF19200352BAA /* jsb_cocos2dx_spine_manual.h */; }; + 1A119F0E18BDF1FF00352BAA /* libjs_static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A119F0D18BDF1FF00352BAA /* libjs_static.a */; }; + 1A119F1018BDF20900352BAA /* libjs_static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A119F0F18BDF20900352BAA /* libjs_static.a */; }; + 1A1D3B7818C44FD000922D3C /* jsb_event_dispatcher_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A1D3B7618C44FD000922D3C /* jsb_event_dispatcher_manual.cpp */; }; + 1A1D3B7918C44FD000922D3C /* jsb_event_dispatcher_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A1D3B7618C44FD000922D3C /* jsb_event_dispatcher_manual.cpp */; }; + 1A1D3B7A18C44FD000922D3C /* jsb_event_dispatcher_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A1D3B7718C44FD000922D3C /* jsb_event_dispatcher_manual.h */; }; + 1A1D3B7B18C44FD000922D3C /* jsb_event_dispatcher_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A1D3B7718C44FD000922D3C /* jsb_event_dispatcher_manual.h */; }; + 1AB5E62B18D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AB5E62918D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.cpp */; }; + 1AB5E62C18D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AB5E62918D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.cpp */; }; + 1AB5E62D18D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1AB5E62A18D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.hpp */; }; + 1AB5E62E18D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1AB5E62A18D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.hpp */; }; + 1AB5E63318D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AB5E63118D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.cpp */; }; + 1AB5E63418D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AB5E63118D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.cpp */; }; + 1AB5E63518D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AB5E63218D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.h */; }; + 1AB5E63618D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AB5E63218D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.h */; }; + 420BBCF01AA48EDE00493976 /* jsb_cocos2dx_3d_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBCEE1AA48EDE00493976 /* jsb_cocos2dx_3d_auto.cpp */; }; + 420BBCF11AA48EDE00493976 /* jsb_cocos2dx_3d_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBCEE1AA48EDE00493976 /* jsb_cocos2dx_3d_auto.cpp */; }; + 420BBCF21AA48EDE00493976 /* jsb_cocos2dx_3d_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 420BBCEF1AA48EDE00493976 /* jsb_cocos2dx_3d_auto.hpp */; }; + 420BBCF31AA48EDE00493976 /* jsb_cocos2dx_3d_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 420BBCEF1AA48EDE00493976 /* jsb_cocos2dx_3d_auto.hpp */; }; + 420BBCF71AA48EE900493976 /* jsb_cocos2dx_3d_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBCF51AA48EE900493976 /* jsb_cocos2dx_3d_manual.cpp */; }; + 420BBCF81AA48EE900493976 /* jsb_cocos2dx_3d_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBCF51AA48EE900493976 /* jsb_cocos2dx_3d_manual.cpp */; }; + 420BBCF91AA48EE900493976 /* jsb_cocos2dx_3d_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 420BBCF61AA48EE900493976 /* jsb_cocos2dx_3d_manual.h */; }; + 420BBCFA1AA48EE900493976 /* jsb_cocos2dx_3d_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 420BBCF61AA48EE900493976 /* jsb_cocos2dx_3d_manual.h */; }; + 83A5661918DA878400FC31A0 /* jsb_socketio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83A5661718DA878400FC31A0 /* jsb_socketio.cpp */; }; + 83A5661A18DA878400FC31A0 /* jsb_socketio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83A5661718DA878400FC31A0 /* jsb_socketio.cpp */; }; + 83A5661B18DA878400FC31A0 /* jsb_socketio.h in Headers */ = {isa = PBXBuildFile; fileRef = 83A5661818DA878400FC31A0 /* jsb_socketio.h */; }; + 83A5661C18DA878400FC31A0 /* jsb_socketio.h in Headers */ = {isa = PBXBuildFile; fileRef = 83A5661818DA878400FC31A0 /* jsb_socketio.h */; }; + BA4095C21A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA4095C01A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.cpp */; }; + BA4095C31A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA4095C01A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.cpp */; }; + BA4095C41A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.h in Headers */ = {isa = PBXBuildFile; fileRef = BA4095C11A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.h */; }; + BA4095C51A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.h in Headers */ = {isa = PBXBuildFile; fileRef = BA4095C11A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.h */; }; + BA623E09191A195F00761F37 /* jsb_pluginx_basic_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA623DFC191A195F00761F37 /* jsb_pluginx_basic_conversions.cpp */; }; + BA623E0A191A195F00761F37 /* jsb_pluginx_basic_conversions.h in Headers */ = {isa = PBXBuildFile; fileRef = BA623DFD191A195F00761F37 /* jsb_pluginx_basic_conversions.h */; }; + BA623E0B191A195F00761F37 /* jsb_pluginx_extension_registration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA623DFE191A195F00761F37 /* jsb_pluginx_extension_registration.cpp */; }; + BA623E0C191A195F00761F37 /* jsb_pluginx_extension_registration.h in Headers */ = {isa = PBXBuildFile; fileRef = BA623DFF191A195F00761F37 /* jsb_pluginx_extension_registration.h */; }; + BA623E0D191A195F00761F37 /* jsb_pluginx_manual_callback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA623E00191A195F00761F37 /* jsb_pluginx_manual_callback.cpp */; }; + BA623E0E191A195F00761F37 /* jsb_pluginx_manual_callback.h in Headers */ = {isa = PBXBuildFile; fileRef = BA623E01191A195F00761F37 /* jsb_pluginx_manual_callback.h */; }; + BA623E0F191A195F00761F37 /* jsb_pluginx_manual_protocols.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA623E02191A195F00761F37 /* jsb_pluginx_manual_protocols.cpp */; }; + BA623E10191A195F00761F37 /* jsb_pluginx_manual_protocols.h in Headers */ = {isa = PBXBuildFile; fileRef = BA623E03191A195F00761F37 /* jsb_pluginx_manual_protocols.h */; }; + BA623E11191A195F00761F37 /* jsb_pluginx_spidermonkey_specifics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA623E04191A195F00761F37 /* jsb_pluginx_spidermonkey_specifics.cpp */; }; + BA623E12191A195F00761F37 /* jsb_pluginx_spidermonkey_specifics.h in Headers */ = {isa = PBXBuildFile; fileRef = BA623E05191A195F00761F37 /* jsb_pluginx_spidermonkey_specifics.h */; }; + BA623E13191A195F00761F37 /* pluginxUTF8.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA623E06191A195F00761F37 /* pluginxUTF8.cpp */; }; + BA623E14191A195F00761F37 /* pluginxUTF8.h in Headers */ = {isa = PBXBuildFile; fileRef = BA623E07191A195F00761F37 /* pluginxUTF8.h */; }; + BA623E15191A195F00761F37 /* uthash.h in Headers */ = {isa = PBXBuildFile; fileRef = BA623E08191A195F00761F37 /* uthash.h */; }; + BA623E18191A196F00761F37 /* jsb_cocos2dx_pluginx_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA623E16191A196F00761F37 /* jsb_cocos2dx_pluginx_auto.cpp */; }; + BA623E19191A196F00761F37 /* jsb_cocos2dx_pluginx_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BA623E17191A196F00761F37 /* jsb_cocos2dx_pluginx_auto.hpp */; }; + BAEE4D711AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BAEE4D6F1AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.cpp */; }; + BAEE4D721AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BAEE4D6F1AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.cpp */; }; + BAEE4D731AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BAEE4D701AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.hpp */; }; + BAEE4D741AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BAEE4D701AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.hpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 0541A74D1973876100E45470 /* JavaScriptObjCBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JavaScriptObjCBridge.h; sourceTree = ""; }; + 0541A74E1973876100E45470 /* JavaScriptObjCBridge.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = JavaScriptObjCBridge.mm; sourceTree = ""; }; + 1A119E2F18BDF19200352BAA /* jsb_cocos2dx_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_auto.cpp; sourceTree = ""; }; + 1A119E3018BDF19200352BAA /* jsb_cocos2dx_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_auto.hpp; sourceTree = ""; }; + 1A119E3218BDF19200352BAA /* jsb_cocos2dx_builder_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_builder_auto.cpp; sourceTree = ""; }; + 1A119E3318BDF19200352BAA /* jsb_cocos2dx_builder_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_builder_auto.hpp; sourceTree = ""; }; + 1A119E3518BDF19200352BAA /* jsb_cocos2dx_extension_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_extension_auto.cpp; sourceTree = ""; }; + 1A119E3618BDF19200352BAA /* jsb_cocos2dx_extension_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_extension_auto.hpp; sourceTree = ""; }; + 1A119E3B18BDF19200352BAA /* jsb_cocos2dx_spine_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_spine_auto.cpp; sourceTree = ""; }; + 1A119E3C18BDF19200352BAA /* jsb_cocos2dx_spine_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_spine_auto.hpp; sourceTree = ""; }; + 1A119E3E18BDF19200352BAA /* jsb_cocos2dx_studio_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_studio_auto.cpp; sourceTree = ""; }; + 1A119E3F18BDF19200352BAA /* jsb_cocos2dx_studio_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_studio_auto.hpp; sourceTree = ""; }; + 1A119E4318BDF19200352BAA /* Android.mk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Android.mk; sourceTree = ""; }; + 1A119E4418BDF19200352BAA /* js_bindings_chipmunk_auto_classes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_chipmunk_auto_classes.cpp; sourceTree = ""; }; + 1A119E4518BDF19200352BAA /* js_bindings_chipmunk_auto_classes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_chipmunk_auto_classes.h; sourceTree = ""; }; + 1A119E4618BDF19200352BAA /* js_bindings_chipmunk_auto_classes_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_chipmunk_auto_classes_registration.h; sourceTree = ""; }; + 1A119E4718BDF19200352BAA /* js_bindings_chipmunk_functions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_chipmunk_functions.cpp; sourceTree = ""; }; + 1A119E4818BDF19200352BAA /* js_bindings_chipmunk_functions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_chipmunk_functions.h; sourceTree = ""; }; + 1A119E4918BDF19200352BAA /* js_bindings_chipmunk_functions_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_chipmunk_functions_registration.h; sourceTree = ""; }; + 1A119E4A18BDF19200352BAA /* js_bindings_chipmunk_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_chipmunk_manual.cpp; sourceTree = ""; }; + 1A119E4B18BDF19200352BAA /* js_bindings_chipmunk_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_chipmunk_manual.h; sourceTree = ""; }; + 1A119E4C18BDF19200352BAA /* js_bindings_chipmunk_registration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_chipmunk_registration.cpp; sourceTree = ""; }; + 1A119E4D18BDF19200352BAA /* js_bindings_chipmunk_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_chipmunk_registration.h; sourceTree = ""; }; + 1A119E4E18BDF19200352BAA /* cocos2d_specifics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocos2d_specifics.cpp; sourceTree = ""; }; + 1A119E4F18BDF19200352BAA /* cocos2d_specifics.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cocos2d_specifics.hpp; sourceTree = ""; }; + 1A119E5118BDF19200352BAA /* Android.mk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Android.mk; sourceTree = ""; }; + 1A119E5218BDF19200352BAA /* cocosbuilder_specifics.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cocosbuilder_specifics.hpp; sourceTree = ""; }; + 1A119E5318BDF19200352BAA /* js_bindings_ccbreader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_ccbreader.cpp; sourceTree = ""; }; + 1A119E5418BDF19200352BAA /* js_bindings_ccbreader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_ccbreader.h; sourceTree = ""; }; + 1A119E5718BDF19200352BAA /* jsb_cocos2dx_studio_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_studio_manual.cpp; sourceTree = ""; }; + 1A119E5818BDF19200352BAA /* jsb_cocos2dx_studio_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_cocos2dx_studio_manual.h; sourceTree = ""; }; + 1A119E5A18BDF19200352BAA /* Android.mk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Android.mk; sourceTree = ""; }; + 1A119E5B18BDF19200352BAA /* jsb_cocos2dx_extension_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_extension_manual.cpp; sourceTree = ""; }; + 1A119E5C18BDF19200352BAA /* jsb_cocos2dx_extension_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_cocos2dx_extension_manual.h; sourceTree = ""; }; + 1A119E6118BDF19200352BAA /* js_bindings_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_config.h; sourceTree = ""; }; + 1A119E6218BDF19200352BAA /* js_bindings_core.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_core.cpp; sourceTree = ""; }; + 1A119E6318BDF19200352BAA /* js_bindings_core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_core.h; sourceTree = ""; }; + 1A119E6418BDF19200352BAA /* js_bindings_opengl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_opengl.cpp; sourceTree = ""; }; + 1A119E6518BDF19200352BAA /* js_bindings_opengl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_opengl.h; sourceTree = ""; }; + 1A119E6618BDF19200352BAA /* js_manual_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_manual_conversions.cpp; sourceTree = ""; }; + 1A119E6718BDF19200352BAA /* js_manual_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_manual_conversions.h; sourceTree = ""; }; + 1A119E6818BDF19200352BAA /* jsb_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_helper.h; sourceTree = ""; }; + 1A119E6918BDF19200352BAA /* jsb_opengl_functions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_opengl_functions.cpp; sourceTree = ""; }; + 1A119E6A18BDF19200352BAA /* jsb_opengl_functions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_opengl_functions.h; sourceTree = ""; }; + 1A119E6B18BDF19200352BAA /* jsb_opengl_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_opengl_manual.cpp; sourceTree = ""; }; + 1A119E6C18BDF19200352BAA /* jsb_opengl_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_opengl_manual.h; sourceTree = ""; }; + 1A119E6D18BDF19200352BAA /* jsb_opengl_registration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_opengl_registration.cpp; sourceTree = ""; }; + 1A119E6E18BDF19200352BAA /* jsb_opengl_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_opengl_registration.h; sourceTree = ""; }; + 1A119E7018BDF19200352BAA /* Android.mk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Android.mk; sourceTree = ""; }; + 1A119E7118BDF19200352BAA /* js_bindings_system_functions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_system_functions.cpp; sourceTree = ""; }; + 1A119E7218BDF19200352BAA /* js_bindings_system_functions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_system_functions.h; sourceTree = ""; }; + 1A119E7318BDF19200352BAA /* js_bindings_system_functions_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_system_functions_registration.h; sourceTree = ""; }; + 1A119E7418BDF19200352BAA /* js_bindings_system_registration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_system_registration.cpp; sourceTree = ""; }; + 1A119E7518BDF19200352BAA /* js_bindings_system_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_system_registration.h; sourceTree = ""; }; + 1A119E7718BDF19200352BAA /* Android.mk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Android.mk; sourceTree = ""; }; + 1A119E7818BDF19200352BAA /* jsb_websocket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_websocket.cpp; sourceTree = ""; }; + 1A119E7918BDF19200352BAA /* jsb_websocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_websocket.h; sourceTree = ""; }; + 1A119E7A18BDF19200352BAA /* XMLHTTPRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLHTTPRequest.cpp; sourceTree = ""; }; + 1A119E7B18BDF19200352BAA /* XMLHTTPRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLHTTPRequest.h; sourceTree = ""; }; + 1A119E7C18BDF19200352BAA /* ScriptingCore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptingCore.cpp; sourceTree = ""; }; + 1A119E7D18BDF19200352BAA /* ScriptingCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptingCore.h; sourceTree = ""; }; + 1A119E7E18BDF19200352BAA /* spidermonkey_specifics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spidermonkey_specifics.h; sourceTree = ""; }; + 1A119E8018BDF19200352BAA /* Android.mk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Android.mk; sourceTree = ""; }; + 1A119E8118BDF19200352BAA /* jsb_cocos2dx_spine_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_spine_manual.cpp; sourceTree = ""; }; + 1A119E8218BDF19200352BAA /* jsb_cocos2dx_spine_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_cocos2dx_spine_manual.h; sourceTree = ""; }; + 1A119F0D18BDF1FF00352BAA /* libjs_static.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libjs_static.a; path = ../../external/spidermonkey/prebuilt/ios/libjs_static.a; sourceTree = ""; }; + 1A119F0F18BDF20900352BAA /* libjs_static.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libjs_static.a; path = ../../external/spidermonkey/prebuilt/mac/libjs_static.a; sourceTree = ""; }; + 1A1D3B7618C44FD000922D3C /* jsb_event_dispatcher_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_event_dispatcher_manual.cpp; sourceTree = ""; }; + 1A1D3B7718C44FD000922D3C /* jsb_event_dispatcher_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_event_dispatcher_manual.h; sourceTree = ""; }; + 1A5410A418B785A10016A3AF /* libjscocos2d Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libjscocos2d Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 1A5410A518B785A10016A3AF /* libjscocos2d iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libjscocos2d iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 1AB5E62918D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_ui_auto.cpp; sourceTree = ""; }; + 1AB5E62A18D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_ui_auto.hpp; sourceTree = ""; }; + 1AB5E63118D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_ui_manual.cpp; sourceTree = ""; }; + 1AB5E63218D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_cocos2dx_ui_manual.h; sourceTree = ""; }; + 420BBCEE1AA48EDE00493976 /* jsb_cocos2dx_3d_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_3d_auto.cpp; sourceTree = ""; }; + 420BBCEF1AA48EDE00493976 /* jsb_cocos2dx_3d_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_3d_auto.hpp; sourceTree = ""; }; + 420BBCF51AA48EE900493976 /* jsb_cocos2dx_3d_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_3d_manual.cpp; sourceTree = ""; }; + 420BBCF61AA48EE900493976 /* jsb_cocos2dx_3d_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_cocos2dx_3d_manual.h; sourceTree = ""; }; + 83A5661718DA878400FC31A0 /* jsb_socketio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_socketio.cpp; sourceTree = ""; }; + 83A5661818DA878400FC31A0 /* jsb_socketio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_socketio.h; sourceTree = ""; }; + BA4095C01A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_studio_conversions.cpp; sourceTree = ""; }; + BA4095C11A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_cocos2dx_studio_conversions.h; sourceTree = ""; }; + BA623DFC191A195F00761F37 /* jsb_pluginx_basic_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jsb_pluginx_basic_conversions.cpp; path = ../../../../plugin/jsbindings/manual/jsb_pluginx_basic_conversions.cpp; sourceTree = ""; }; + BA623DFD191A195F00761F37 /* jsb_pluginx_basic_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = jsb_pluginx_basic_conversions.h; path = ../../../../plugin/jsbindings/manual/jsb_pluginx_basic_conversions.h; sourceTree = ""; }; + BA623DFE191A195F00761F37 /* jsb_pluginx_extension_registration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jsb_pluginx_extension_registration.cpp; path = ../../../../plugin/jsbindings/manual/jsb_pluginx_extension_registration.cpp; sourceTree = ""; }; + BA623DFF191A195F00761F37 /* jsb_pluginx_extension_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = jsb_pluginx_extension_registration.h; path = ../../../../plugin/jsbindings/manual/jsb_pluginx_extension_registration.h; sourceTree = ""; }; + BA623E00191A195F00761F37 /* jsb_pluginx_manual_callback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jsb_pluginx_manual_callback.cpp; path = ../../../../plugin/jsbindings/manual/jsb_pluginx_manual_callback.cpp; sourceTree = ""; }; + BA623E01191A195F00761F37 /* jsb_pluginx_manual_callback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = jsb_pluginx_manual_callback.h; path = ../../../../plugin/jsbindings/manual/jsb_pluginx_manual_callback.h; sourceTree = ""; }; + BA623E02191A195F00761F37 /* jsb_pluginx_manual_protocols.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jsb_pluginx_manual_protocols.cpp; path = ../../../../plugin/jsbindings/manual/jsb_pluginx_manual_protocols.cpp; sourceTree = ""; }; + BA623E03191A195F00761F37 /* jsb_pluginx_manual_protocols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = jsb_pluginx_manual_protocols.h; path = ../../../../plugin/jsbindings/manual/jsb_pluginx_manual_protocols.h; sourceTree = ""; }; + BA623E04191A195F00761F37 /* jsb_pluginx_spidermonkey_specifics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jsb_pluginx_spidermonkey_specifics.cpp; path = ../../../../plugin/jsbindings/manual/jsb_pluginx_spidermonkey_specifics.cpp; sourceTree = ""; }; + BA623E05191A195F00761F37 /* jsb_pluginx_spidermonkey_specifics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = jsb_pluginx_spidermonkey_specifics.h; path = ../../../../plugin/jsbindings/manual/jsb_pluginx_spidermonkey_specifics.h; sourceTree = ""; }; + BA623E06191A195F00761F37 /* pluginxUTF8.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pluginxUTF8.cpp; path = ../../../../plugin/jsbindings/manual/pluginxUTF8.cpp; sourceTree = ""; }; + BA623E07191A195F00761F37 /* pluginxUTF8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pluginxUTF8.h; path = ../../../../plugin/jsbindings/manual/pluginxUTF8.h; sourceTree = ""; }; + BA623E08191A195F00761F37 /* uthash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = uthash.h; path = ../../../../plugin/jsbindings/manual/uthash.h; sourceTree = ""; }; + BA623E16191A196F00761F37 /* jsb_cocos2dx_pluginx_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jsb_cocos2dx_pluginx_auto.cpp; path = ../../../../plugin/jsbindings/auto/jsb_cocos2dx_pluginx_auto.cpp; sourceTree = ""; }; + BA623E17191A196F00761F37 /* jsb_cocos2dx_pluginx_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = jsb_cocos2dx_pluginx_auto.hpp; path = ../../../../plugin/jsbindings/auto/jsb_cocos2dx_pluginx_auto.hpp; sourceTree = ""; }; + BAEE4D6F1AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_3d_extension_auto.cpp; sourceTree = ""; }; + BAEE4D701AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_3d_extension_auto.hpp; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + A03F31F01781479B006731B9 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 1A119F1018BDF20900352BAA /* libjs_static.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A07A4FCC178387750073F6A7 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 1A119F0E18BDF1FF00352BAA /* libjs_static.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 0541A74C1973876100E45470 /* ios */ = { + isa = PBXGroup; + children = ( + 0541A74D1973876100E45470 /* JavaScriptObjCBridge.h */, + 0541A74E1973876100E45470 /* JavaScriptObjCBridge.mm */, + ); + name = ios; + path = platform/ios; + sourceTree = ""; + }; + 1551A334158F2AB200E66CFE = { + isa = PBXGroup; + children = ( + 1A119E2E18BDF19200352BAA /* auto */, + 1A119F0918BDF1D400352BAA /* external */, + 1A5410A518B785A10016A3AF /* libjscocos2d iOS.a */, + 1A5410A418B785A10016A3AF /* libjscocos2d Mac.a */, + 1A119E4118BDF19200352BAA /* manual */, + ); + sourceTree = ""; + }; + 1A119E2E18BDF19200352BAA /* auto */ = { + isa = PBXGroup; + children = ( + 420BBCEE1AA48EDE00493976 /* jsb_cocos2dx_3d_auto.cpp */, + 420BBCEF1AA48EDE00493976 /* jsb_cocos2dx_3d_auto.hpp */, + BAEE4D6F1AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.cpp */, + BAEE4D701AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.hpp */, + 1A119E2F18BDF19200352BAA /* jsb_cocos2dx_auto.cpp */, + 1A119E3018BDF19200352BAA /* jsb_cocos2dx_auto.hpp */, + 1A119E3218BDF19200352BAA /* jsb_cocos2dx_builder_auto.cpp */, + 1A119E3318BDF19200352BAA /* jsb_cocos2dx_builder_auto.hpp */, + 1A119E3518BDF19200352BAA /* jsb_cocos2dx_extension_auto.cpp */, + 1A119E3618BDF19200352BAA /* jsb_cocos2dx_extension_auto.hpp */, + 1A119E3B18BDF19200352BAA /* jsb_cocos2dx_spine_auto.cpp */, + 1A119E3C18BDF19200352BAA /* jsb_cocos2dx_spine_auto.hpp */, + 1A119E3E18BDF19200352BAA /* jsb_cocos2dx_studio_auto.cpp */, + 1A119E3F18BDF19200352BAA /* jsb_cocos2dx_studio_auto.hpp */, + 1AB5E62918D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.cpp */, + 1AB5E62A18D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.hpp */, + BA623E16191A196F00761F37 /* jsb_cocos2dx_pluginx_auto.cpp */, + BA623E17191A196F00761F37 /* jsb_cocos2dx_pluginx_auto.hpp */, + ); + name = auto; + path = ../auto; + sourceTree = ""; + }; + 1A119E4118BDF19200352BAA /* manual */ = { + isa = PBXGroup; + children = ( + 420BBCF41AA48EE900493976 /* 3d */, + 0541A74C1973876100E45470 /* ios */, + 1A119E4218BDF19200352BAA /* chipmunk */, + 1A119E4E18BDF19200352BAA /* cocos2d_specifics.cpp */, + 1A119E4F18BDF19200352BAA /* cocos2d_specifics.hpp */, + 1A119E5018BDF19200352BAA /* cocosbuilder */, + 1A119E5518BDF19200352BAA /* cocostudio */, + 1A119E5918BDF19200352BAA /* extension */, + 1A119E6118BDF19200352BAA /* js_bindings_config.h */, + 1A119E6218BDF19200352BAA /* js_bindings_core.cpp */, + 1A119E6318BDF19200352BAA /* js_bindings_core.h */, + 1A119E6418BDF19200352BAA /* js_bindings_opengl.cpp */, + 1A119E6518BDF19200352BAA /* js_bindings_opengl.h */, + 1A119E6618BDF19200352BAA /* js_manual_conversions.cpp */, + 1A119E6718BDF19200352BAA /* js_manual_conversions.h */, + 1A1D3B7618C44FD000922D3C /* jsb_event_dispatcher_manual.cpp */, + 1A1D3B7718C44FD000922D3C /* jsb_event_dispatcher_manual.h */, + 1A119E6818BDF19200352BAA /* jsb_helper.h */, + 1A119E6918BDF19200352BAA /* jsb_opengl_functions.cpp */, + 1A119E6A18BDF19200352BAA /* jsb_opengl_functions.h */, + 1A119E6B18BDF19200352BAA /* jsb_opengl_manual.cpp */, + 1A119E6C18BDF19200352BAA /* jsb_opengl_manual.h */, + 1A119E6D18BDF19200352BAA /* jsb_opengl_registration.cpp */, + 1A119E6E18BDF19200352BAA /* jsb_opengl_registration.h */, + 1A119E6F18BDF19200352BAA /* localstorage */, + 1A119E7618BDF19200352BAA /* network */, + 1A119E7C18BDF19200352BAA /* ScriptingCore.cpp */, + 1A119E7D18BDF19200352BAA /* ScriptingCore.h */, + 1A119E7E18BDF19200352BAA /* spidermonkey_specifics.h */, + 1A119E7F18BDF19200352BAA /* spine */, + 1AB5E62F18D05BF30088DAA4 /* ui */, + BA623DFB191A192700761F37 /* pluginx */, + ); + name = manual; + path = ../manual; + sourceTree = ""; + }; + 1A119E4218BDF19200352BAA /* chipmunk */ = { + isa = PBXGroup; + children = ( + 1A119E4318BDF19200352BAA /* Android.mk */, + 1A119E4418BDF19200352BAA /* js_bindings_chipmunk_auto_classes.cpp */, + 1A119E4518BDF19200352BAA /* js_bindings_chipmunk_auto_classes.h */, + 1A119E4618BDF19200352BAA /* js_bindings_chipmunk_auto_classes_registration.h */, + 1A119E4718BDF19200352BAA /* js_bindings_chipmunk_functions.cpp */, + 1A119E4818BDF19200352BAA /* js_bindings_chipmunk_functions.h */, + 1A119E4918BDF19200352BAA /* js_bindings_chipmunk_functions_registration.h */, + 1A119E4A18BDF19200352BAA /* js_bindings_chipmunk_manual.cpp */, + 1A119E4B18BDF19200352BAA /* js_bindings_chipmunk_manual.h */, + 1A119E4C18BDF19200352BAA /* js_bindings_chipmunk_registration.cpp */, + 1A119E4D18BDF19200352BAA /* js_bindings_chipmunk_registration.h */, + ); + path = chipmunk; + sourceTree = ""; + }; + 1A119E5018BDF19200352BAA /* cocosbuilder */ = { + isa = PBXGroup; + children = ( + 1A119E5118BDF19200352BAA /* Android.mk */, + 1A119E5218BDF19200352BAA /* cocosbuilder_specifics.hpp */, + 1A119E5318BDF19200352BAA /* js_bindings_ccbreader.cpp */, + 1A119E5418BDF19200352BAA /* js_bindings_ccbreader.h */, + ); + path = cocosbuilder; + sourceTree = ""; + }; + 1A119E5518BDF19200352BAA /* cocostudio */ = { + isa = PBXGroup; + children = ( + 1A119E5718BDF19200352BAA /* jsb_cocos2dx_studio_manual.cpp */, + 1A119E5818BDF19200352BAA /* jsb_cocos2dx_studio_manual.h */, + BA4095C01A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.cpp */, + BA4095C11A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.h */, + ); + path = cocostudio; + sourceTree = ""; + }; + 1A119E5918BDF19200352BAA /* extension */ = { + isa = PBXGroup; + children = ( + 1A119E5A18BDF19200352BAA /* Android.mk */, + 1A119E5B18BDF19200352BAA /* jsb_cocos2dx_extension_manual.cpp */, + 1A119E5C18BDF19200352BAA /* jsb_cocos2dx_extension_manual.h */, + ); + path = extension; + sourceTree = ""; + }; + 1A119E6F18BDF19200352BAA /* localstorage */ = { + isa = PBXGroup; + children = ( + 1A119E7018BDF19200352BAA /* Android.mk */, + 1A119E7118BDF19200352BAA /* js_bindings_system_functions.cpp */, + 1A119E7218BDF19200352BAA /* js_bindings_system_functions.h */, + 1A119E7318BDF19200352BAA /* js_bindings_system_functions_registration.h */, + 1A119E7418BDF19200352BAA /* js_bindings_system_registration.cpp */, + 1A119E7518BDF19200352BAA /* js_bindings_system_registration.h */, + ); + path = localstorage; + sourceTree = ""; + }; + 1A119E7618BDF19200352BAA /* network */ = { + isa = PBXGroup; + children = ( + 1A119E7718BDF19200352BAA /* Android.mk */, + 83A5661718DA878400FC31A0 /* jsb_socketio.cpp */, + 83A5661818DA878400FC31A0 /* jsb_socketio.h */, + 1A119E7818BDF19200352BAA /* jsb_websocket.cpp */, + 1A119E7918BDF19200352BAA /* jsb_websocket.h */, + 1A119E7A18BDF19200352BAA /* XMLHTTPRequest.cpp */, + 1A119E7B18BDF19200352BAA /* XMLHTTPRequest.h */, + ); + path = network; + sourceTree = ""; + }; + 1A119E7F18BDF19200352BAA /* spine */ = { + isa = PBXGroup; + children = ( + 1A119E8018BDF19200352BAA /* Android.mk */, + 1A119E8118BDF19200352BAA /* jsb_cocos2dx_spine_manual.cpp */, + 1A119E8218BDF19200352BAA /* jsb_cocos2dx_spine_manual.h */, + ); + path = spine; + sourceTree = ""; + }; + 1A119F0918BDF1D400352BAA /* external */ = { + isa = PBXGroup; + children = ( + 1A119F0A18BDF1E200352BAA /* spidermonkey */, + ); + name = external; + sourceTree = ""; + }; + 1A119F0A18BDF1E200352BAA /* spidermonkey */ = { + isa = PBXGroup; + children = ( + 1A119F0B18BDF1E900352BAA /* ios */, + 1A119F0C18BDF1F000352BAA /* mac */, + ); + name = spidermonkey; + sourceTree = ""; + }; + 1A119F0B18BDF1E900352BAA /* ios */ = { + isa = PBXGroup; + children = ( + 1A119F0D18BDF1FF00352BAA /* libjs_static.a */, + ); + name = ios; + sourceTree = ""; + }; + 1A119F0C18BDF1F000352BAA /* mac */ = { + isa = PBXGroup; + children = ( + 1A119F0F18BDF20900352BAA /* libjs_static.a */, + ); + name = mac; + sourceTree = ""; + }; + 1AB5E62F18D05BF30088DAA4 /* ui */ = { + isa = PBXGroup; + children = ( + 1AB5E63118D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.cpp */, + 1AB5E63218D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.h */, + ); + path = ui; + sourceTree = ""; + }; + 420BBCF41AA48EE900493976 /* 3d */ = { + isa = PBXGroup; + children = ( + 420BBCF51AA48EE900493976 /* jsb_cocos2dx_3d_manual.cpp */, + 420BBCF61AA48EE900493976 /* jsb_cocos2dx_3d_manual.h */, + ); + path = 3d; + sourceTree = ""; + }; + BA623DFB191A192700761F37 /* pluginx */ = { + isa = PBXGroup; + children = ( + BA623DFC191A195F00761F37 /* jsb_pluginx_basic_conversions.cpp */, + BA623DFD191A195F00761F37 /* jsb_pluginx_basic_conversions.h */, + BA623DFE191A195F00761F37 /* jsb_pluginx_extension_registration.cpp */, + BA623DFF191A195F00761F37 /* jsb_pluginx_extension_registration.h */, + BA623E00191A195F00761F37 /* jsb_pluginx_manual_callback.cpp */, + BA623E01191A195F00761F37 /* jsb_pluginx_manual_callback.h */, + BA623E02191A195F00761F37 /* jsb_pluginx_manual_protocols.cpp */, + BA623E03191A195F00761F37 /* jsb_pluginx_manual_protocols.h */, + BA623E04191A195F00761F37 /* jsb_pluginx_spidermonkey_specifics.cpp */, + BA623E05191A195F00761F37 /* jsb_pluginx_spidermonkey_specifics.h */, + BA623E06191A195F00761F37 /* pluginxUTF8.cpp */, + BA623E07191A195F00761F37 /* pluginxUTF8.h */, + BA623E08191A195F00761F37 /* uthash.h */, + ); + name = pluginx; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + A03F31F11781479B006731B9 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 1A119EA318BDF19200352BAA /* jsb_cocos2dx_studio_auto.hpp in Headers */, + 1A119F0118BDF19200352BAA /* ScriptingCore.h in Headers */, + 1A119EBD18BDF19200352BAA /* cocos2d_specifics.hpp in Headers */, + 83A5661B18DA878400FC31A0 /* jsb_socketio.h in Headers */, + 1A1D3B7A18C44FD000922D3C /* jsb_event_dispatcher_manual.h in Headers */, + 1A119EF518BDF19200352BAA /* js_bindings_system_registration.h in Headers */, + 1A119EBF18BDF19200352BAA /* cocosbuilder_specifics.hpp in Headers */, + 1A119ED118BDF19200352BAA /* js_bindings_config.h in Headers */, + 1A119EB518BDF19200352BAA /* js_bindings_chipmunk_manual.h in Headers */, + 1A119EF918BDF19200352BAA /* jsb_websocket.h in Headers */, + 1A119E9118BDF19200352BAA /* jsb_cocos2dx_extension_auto.hpp in Headers */, + 1A119E8B18BDF19200352BAA /* jsb_cocos2dx_builder_auto.hpp in Headers */, + 1A119EA918BDF19200352BAA /* js_bindings_chipmunk_auto_classes.h in Headers */, + 1A119E9D18BDF19200352BAA /* jsb_cocos2dx_spine_auto.hpp in Headers */, + BAEE4D731AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.hpp in Headers */, + 1A119EEB18BDF19200352BAA /* jsb_opengl_registration.h in Headers */, + 1A119F0318BDF19200352BAA /* spidermonkey_specifics.h in Headers */, + 1A119EE718BDF19200352BAA /* jsb_opengl_manual.h in Headers */, + 1A119ED518BDF19200352BAA /* js_bindings_core.h in Headers */, + 1A119EC318BDF19200352BAA /* js_bindings_ccbreader.h in Headers */, + 1A119EDF18BDF19200352BAA /* jsb_helper.h in Headers */, + 1A119ECB18BDF19200352BAA /* jsb_cocos2dx_extension_manual.h in Headers */, + 1A119EEF18BDF19200352BAA /* js_bindings_system_functions.h in Headers */, + 1A119EDD18BDF19200352BAA /* js_manual_conversions.h in Headers */, + 1A119EFD18BDF19200352BAA /* XMLHTTPRequest.h in Headers */, + 1AB5E63518D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.h in Headers */, + 1A119EE318BDF19200352BAA /* jsb_opengl_functions.h in Headers */, + 0541A74F1973876100E45470 /* JavaScriptObjCBridge.h in Headers */, + 1AB5E62D18D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.hpp in Headers */, + 420BBCF91AA48EE900493976 /* jsb_cocos2dx_3d_manual.h in Headers */, + 1A119ED918BDF19200352BAA /* js_bindings_opengl.h in Headers */, + BA4095C41A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.h in Headers */, + 1A119EC718BDF19200352BAA /* jsb_cocos2dx_studio_manual.h in Headers */, + 1A119EAB18BDF19200352BAA /* js_bindings_chipmunk_auto_classes_registration.h in Headers */, + 1A119EB918BDF19200352BAA /* js_bindings_chipmunk_registration.h in Headers */, + 420BBCF21AA48EDE00493976 /* jsb_cocos2dx_3d_auto.hpp in Headers */, + 1A119EAF18BDF19200352BAA /* js_bindings_chipmunk_functions.h in Headers */, + 1A119EB118BDF19200352BAA /* js_bindings_chipmunk_functions_registration.h in Headers */, + 1A119EF118BDF19200352BAA /* js_bindings_system_functions_registration.h in Headers */, + 1A119E8518BDF19200352BAA /* jsb_cocos2dx_auto.hpp in Headers */, + 1A119F0718BDF19200352BAA /* jsb_cocos2dx_spine_manual.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A07A4FCE178387750073F6A7 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 1A119EA418BDF19200352BAA /* jsb_cocos2dx_studio_auto.hpp in Headers */, + 1A119F0218BDF19200352BAA /* ScriptingCore.h in Headers */, + 1A119EBE18BDF19200352BAA /* cocos2d_specifics.hpp in Headers */, + 83A5661C18DA878400FC31A0 /* jsb_socketio.h in Headers */, + 1A1D3B7B18C44FD000922D3C /* jsb_event_dispatcher_manual.h in Headers */, + 1A119EF618BDF19200352BAA /* js_bindings_system_registration.h in Headers */, + BA4095C51A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.h in Headers */, + 1A119EC018BDF19200352BAA /* cocosbuilder_specifics.hpp in Headers */, + 1A119ED218BDF19200352BAA /* js_bindings_config.h in Headers */, + BAEE4D741AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.hpp in Headers */, + 1A119EB618BDF19200352BAA /* js_bindings_chipmunk_manual.h in Headers */, + 1A119EFA18BDF19200352BAA /* jsb_websocket.h in Headers */, + 1A119E9218BDF19200352BAA /* jsb_cocos2dx_extension_auto.hpp in Headers */, + 1A119E8C18BDF19200352BAA /* jsb_cocos2dx_builder_auto.hpp in Headers */, + BA623E19191A196F00761F37 /* jsb_cocos2dx_pluginx_auto.hpp in Headers */, + 1A119EAA18BDF19200352BAA /* js_bindings_chipmunk_auto_classes.h in Headers */, + 1A119E9E18BDF19200352BAA /* jsb_cocos2dx_spine_auto.hpp in Headers */, + 1A119EEC18BDF19200352BAA /* jsb_opengl_registration.h in Headers */, + BA623E15191A195F00761F37 /* uthash.h in Headers */, + 1A119F0418BDF19200352BAA /* spidermonkey_specifics.h in Headers */, + 1A119EE818BDF19200352BAA /* jsb_opengl_manual.h in Headers */, + 1A119ED618BDF19200352BAA /* js_bindings_core.h in Headers */, + 1A119EC418BDF19200352BAA /* js_bindings_ccbreader.h in Headers */, + 1A119EE018BDF19200352BAA /* jsb_helper.h in Headers */, + 1A119ECC18BDF19200352BAA /* jsb_cocos2dx_extension_manual.h in Headers */, + 1A119EF018BDF19200352BAA /* js_bindings_system_functions.h in Headers */, + 1A119EDE18BDF19200352BAA /* js_manual_conversions.h in Headers */, + 1A119EFE18BDF19200352BAA /* XMLHTTPRequest.h in Headers */, + 1AB5E63618D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.h in Headers */, + 1A119EE418BDF19200352BAA /* jsb_opengl_functions.h in Headers */, + BA623E10191A195F00761F37 /* jsb_pluginx_manual_protocols.h in Headers */, + 1AB5E62E18D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.hpp in Headers */, + 1A119EDA18BDF19200352BAA /* js_bindings_opengl.h in Headers */, + 1A119EC818BDF19200352BAA /* jsb_cocos2dx_studio_manual.h in Headers */, + 420BBCFA1AA48EE900493976 /* jsb_cocos2dx_3d_manual.h in Headers */, + BA623E0C191A195F00761F37 /* jsb_pluginx_extension_registration.h in Headers */, + 1A119EAC18BDF19200352BAA /* js_bindings_chipmunk_auto_classes_registration.h in Headers */, + 420BBCF31AA48EDE00493976 /* jsb_cocos2dx_3d_auto.hpp in Headers */, + 1A119EBA18BDF19200352BAA /* js_bindings_chipmunk_registration.h in Headers */, + 1A119EB018BDF19200352BAA /* js_bindings_chipmunk_functions.h in Headers */, + BA623E0E191A195F00761F37 /* jsb_pluginx_manual_callback.h in Headers */, + 1A119EB218BDF19200352BAA /* js_bindings_chipmunk_functions_registration.h in Headers */, + 1A119EF218BDF19200352BAA /* js_bindings_system_functions_registration.h in Headers */, + 1A119E8618BDF19200352BAA /* jsb_cocos2dx_auto.hpp in Headers */, + BA623E12191A195F00761F37 /* jsb_pluginx_spidermonkey_specifics.h in Headers */, + 1A119F0818BDF19200352BAA /* jsb_cocos2dx_spine_manual.h in Headers */, + BA623E0A191A195F00761F37 /* jsb_pluginx_basic_conversions.h in Headers */, + BA623E14191A195F00761F37 /* pluginxUTF8.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + A03F31E81781479B006731B9 /* libjscocos2d Mac */ = { + isa = PBXNativeTarget; + buildConfigurationList = A03F31FA1781479B006731B9 /* Build configuration list for PBXNativeTarget "libjscocos2d Mac" */; + buildPhases = ( + A03F31E91781479B006731B9 /* Sources */, + A03F31F01781479B006731B9 /* Frameworks */, + A03F31F11781479B006731B9 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "libjscocos2d Mac"; + productName = cocos2dx; + productReference = 1A5410A418B785A10016A3AF /* libjscocos2d Mac.a */; + productType = "com.apple.product-type.library.static"; + }; + A07A4FB5178387750073F6A7 /* libjscocos2d iOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = A07A502D178387750073F6A7 /* Build configuration list for PBXNativeTarget "libjscocos2d iOS" */; + buildPhases = ( + A07A4FB6178387750073F6A7 /* Sources */, + A07A4FCC178387750073F6A7 /* Frameworks */, + A07A4FCE178387750073F6A7 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "libjscocos2d iOS"; + productName = cocos2dx; + productReference = 1A5410A518B785A10016A3AF /* libjscocos2d iOS.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 1551A336158F2AB200E66CFE /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0510; + ORGANIZATIONNAME = ""; + }; + buildConfigurationList = 1551A339158F2AB200E66CFE /* Build configuration list for PBXProject "cocos2d_js_bindings" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 1551A334158F2AB200E66CFE; + productRefGroup = 1551A334158F2AB200E66CFE; + projectDirPath = ""; + projectRoot = ""; + targets = ( + A03F31E81781479B006731B9 /* libjscocos2d Mac */, + A07A4FB5178387750073F6A7 /* libjscocos2d iOS */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + A03F31E91781479B006731B9 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1A119E8918BDF19200352BAA /* jsb_cocos2dx_builder_auto.cpp in Sources */, + 1A119EAD18BDF19200352BAA /* js_bindings_chipmunk_functions.cpp in Sources */, + 1A119EED18BDF19200352BAA /* js_bindings_system_functions.cpp in Sources */, + 0541A7501973876100E45470 /* JavaScriptObjCBridge.mm in Sources */, + 1A119EB318BDF19200352BAA /* js_bindings_chipmunk_manual.cpp in Sources */, + 1A119EE918BDF19200352BAA /* jsb_opengl_registration.cpp in Sources */, + 1A119EF718BDF19200352BAA /* jsb_websocket.cpp in Sources */, + 1A119ED318BDF19200352BAA /* js_bindings_core.cpp in Sources */, + 1A119EC118BDF19200352BAA /* js_bindings_ccbreader.cpp in Sources */, + 1A119EFB18BDF19200352BAA /* XMLHTTPRequest.cpp in Sources */, + BAEE4D711AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.cpp in Sources */, + 1A119EC518BDF19200352BAA /* jsb_cocos2dx_studio_manual.cpp in Sources */, + 1A119E8F18BDF19200352BAA /* jsb_cocos2dx_extension_auto.cpp in Sources */, + 1A119ED718BDF19200352BAA /* js_bindings_opengl.cpp in Sources */, + 1AB5E62B18D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.cpp in Sources */, + 1A119E9B18BDF19200352BAA /* jsb_cocos2dx_spine_auto.cpp in Sources */, + 1A119EF318BDF19200352BAA /* js_bindings_system_registration.cpp in Sources */, + 1A119EBB18BDF19200352BAA /* cocos2d_specifics.cpp in Sources */, + 1A119EE518BDF19200352BAA /* jsb_opengl_manual.cpp in Sources */, + 1A119F0518BDF19200352BAA /* jsb_cocos2dx_spine_manual.cpp in Sources */, + 1A119EB718BDF19200352BAA /* js_bindings_chipmunk_registration.cpp in Sources */, + 420BBCF71AA48EE900493976 /* jsb_cocos2dx_3d_manual.cpp in Sources */, + BA4095C21A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.cpp in Sources */, + 1A119E8318BDF19200352BAA /* jsb_cocos2dx_auto.cpp in Sources */, + 1AB5E63318D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.cpp in Sources */, + 1A119EC918BDF19200352BAA /* jsb_cocos2dx_extension_manual.cpp in Sources */, + 1A119EA118BDF19200352BAA /* jsb_cocos2dx_studio_auto.cpp in Sources */, + 1A119EDB18BDF19200352BAA /* js_manual_conversions.cpp in Sources */, + 420BBCF01AA48EDE00493976 /* jsb_cocos2dx_3d_auto.cpp in Sources */, + 83A5661918DA878400FC31A0 /* jsb_socketio.cpp in Sources */, + 1A119EE118BDF19200352BAA /* jsb_opengl_functions.cpp in Sources */, + 1A119EA718BDF19200352BAA /* js_bindings_chipmunk_auto_classes.cpp in Sources */, + 1A119EFF18BDF19200352BAA /* ScriptingCore.cpp in Sources */, + 1A1D3B7818C44FD000922D3C /* jsb_event_dispatcher_manual.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A07A4FB6178387750073F6A7 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0541A75B19738AD200E45470 /* JavaScriptObjCBridge.mm in Sources */, + 420BBCF81AA48EE900493976 /* jsb_cocos2dx_3d_manual.cpp in Sources */, + 1A119E8A18BDF19200352BAA /* jsb_cocos2dx_builder_auto.cpp in Sources */, + 1A119EAE18BDF19200352BAA /* js_bindings_chipmunk_functions.cpp in Sources */, + 1A119EEE18BDF19200352BAA /* js_bindings_system_functions.cpp in Sources */, + 1A119EB418BDF19200352BAA /* js_bindings_chipmunk_manual.cpp in Sources */, + 1A119EEA18BDF19200352BAA /* jsb_opengl_registration.cpp in Sources */, + 1A119EF818BDF19200352BAA /* jsb_websocket.cpp in Sources */, + 1A119ED418BDF19200352BAA /* js_bindings_core.cpp in Sources */, + 420BBCF11AA48EDE00493976 /* jsb_cocos2dx_3d_auto.cpp in Sources */, + 1A119EC218BDF19200352BAA /* js_bindings_ccbreader.cpp in Sources */, + 1A119EFC18BDF19200352BAA /* XMLHTTPRequest.cpp in Sources */, + 1A119EC618BDF19200352BAA /* jsb_cocos2dx_studio_manual.cpp in Sources */, + 1A119E9018BDF19200352BAA /* jsb_cocos2dx_extension_auto.cpp in Sources */, + 1A119ED818BDF19200352BAA /* js_bindings_opengl.cpp in Sources */, + 1AB5E62C18D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.cpp in Sources */, + 1A119E9C18BDF19200352BAA /* jsb_cocos2dx_spine_auto.cpp in Sources */, + 1A119EF418BDF19200352BAA /* js_bindings_system_registration.cpp in Sources */, + 1A119EBC18BDF19200352BAA /* cocos2d_specifics.cpp in Sources */, + 1A119EE618BDF19200352BAA /* jsb_opengl_manual.cpp in Sources */, + 1A119F0618BDF19200352BAA /* jsb_cocos2dx_spine_manual.cpp in Sources */, + BA623E0F191A195F00761F37 /* jsb_pluginx_manual_protocols.cpp in Sources */, + BA623E13191A195F00761F37 /* pluginxUTF8.cpp in Sources */, + BAEE4D721AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.cpp in Sources */, + 1A119EB818BDF19200352BAA /* js_bindings_chipmunk_registration.cpp in Sources */, + 1A119E8418BDF19200352BAA /* jsb_cocos2dx_auto.cpp in Sources */, + 1AB5E63418D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.cpp in Sources */, + 1A119ECA18BDF19200352BAA /* jsb_cocos2dx_extension_manual.cpp in Sources */, + 1A119EA218BDF19200352BAA /* jsb_cocos2dx_studio_auto.cpp in Sources */, + 1A119EDC18BDF19200352BAA /* js_manual_conversions.cpp in Sources */, + 83A5661A18DA878400FC31A0 /* jsb_socketio.cpp in Sources */, + 1A119EE218BDF19200352BAA /* jsb_opengl_functions.cpp in Sources */, + 1A119EA818BDF19200352BAA /* js_bindings_chipmunk_auto_classes.cpp in Sources */, + BA4095C31A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.cpp in Sources */, + BA623E0B191A195F00761F37 /* jsb_pluginx_extension_registration.cpp in Sources */, + BA623E11191A195F00761F37 /* jsb_pluginx_spidermonkey_specifics.cpp in Sources */, + BA623E18191A196F00761F37 /* jsb_cocos2dx_pluginx_auto.cpp in Sources */, + 1A119F0018BDF19200352BAA /* ScriptingCore.cpp in Sources */, + BA623E09191A195F00761F37 /* jsb_pluginx_basic_conversions.cpp in Sources */, + BA623E0D191A195F00761F37 /* jsb_pluginx_manual_callback.cpp in Sources */, + 1A1D3B7918C44FD000922D3C /* jsb_event_dispatcher_manual.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 1551A34A158F2AB200E66CFE /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = YES; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "COCOS2D_DEBUG=1", + USE_FILE32API, + "CC_ENABLE_CHIPMUNK_INTEGRATION=1", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; + GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; + GCC_WARN_NON_VIRTUAL_DESTRUCTOR = NO; + GCC_WARN_SHADOW = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ""; + MACOSX_DEPLOYMENT_TARGET = 10.7; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + SKIP_INSTALL = YES; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../.. $(SRCROOT)/../../../../cocos $(SRCROOT)/../../../../cocos/base $(SRCROOT)/../../../../cocos/2d $(SRCROOT)/../../../../cocos/physics $(SRCROOT)/../../../../cocos/math/kazmath $(SRCROOT)/../../../../cocos/platform $(SRCROOT)/../../../../cocos/audio/include $(SRCROOT)/../../../../cocos/editor-support $(SRCROOT)/../../../../cocos/editor-support/cocosbuilder $(SRCROOT)/../../../../cocos/editor-support/cocostudio $(SRCROOT)/../../../../cocos/editor-support/spine $(SRCROOT)/../../../../cocos/ui $(SRCROOT)/../../../../cocos/storage $(SRCROOT)/../../../../extensions $(SRCROOT)/../../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../../external $(SRCROOT)/../auto $(SRCROOT)/../manual"; + }; + name = Debug; + }; + 1551A34B158F2AB200E66CFE /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = YES; + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_PREPROCESSOR_DEFINITIONS = ( + "CC_ENABLE_CHIPMUNK_INTEGRATION=1", + NDEBUG, + USE_FILE32API, + ); + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; + GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; + GCC_WARN_NON_VIRTUAL_DESTRUCTOR = NO; + GCC_WARN_SHADOW = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ""; + MACOSX_DEPLOYMENT_TARGET = 10.7; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + SKIP_INSTALL = YES; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../.. $(SRCROOT)/../../../../cocos $(SRCROOT)/../../../../cocos/base $(SRCROOT)/../../../../cocos/2d $(SRCROOT)/../../../../cocos/physics $(SRCROOT)/../../../../cocos/math/kazmath $(SRCROOT)/../../../../cocos/platform $(SRCROOT)/../../../../cocos/audio/include $(SRCROOT)/../../../../cocos/editor-support $(SRCROOT)/../../../../cocos/editor-support/cocosbuilder $(SRCROOT)/../../../../cocos/editor-support/cocostudio $(SRCROOT)/../../../../cocos/editor-support/spine $(SRCROOT)/../../../../cocos/ui $(SRCROOT)/../../../../cocos/storage $(SRCROOT)/../../../../extensions $(SRCROOT)/../../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../../external $(SRCROOT)/../auto $(SRCROOT)/../manual"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + A03F31FB1781479B006731B9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = YES; + EXECUTABLE_PREFIX = ""; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + COCOS2D_JAVASCRIPT, + CC_TARGET_OS_MAC, + CC_KEYBOARD_SUPPORT, + ); + HEADER_SEARCH_PATHS = ""; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(SRCROOT)/../../../../external/spidermonkey/prebuilt/mac", + ); + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../../external/spidermonkey/include/mac $(SRCROOT)/../../../../cocos/platform/mac $(SRCROOT)/../../../../external/glfw3/include/mac"; + }; + name = Debug; + }; + A03F31FC1781479B006731B9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = YES; + EXECUTABLE_PREFIX = ""; + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + COCOS2D_JAVASCRIPT, + CC_TARGET_OS_MAC, + CC_KEYBOARD_SUPPORT, + ); + HEADER_SEARCH_PATHS = ""; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(SRCROOT)/../../../../external/spidermonkey/prebuilt/mac", + ); + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../../external/spidermonkey/include/mac $(SRCROOT)/../../../../cocos/platform/mac $(SRCROOT)/../../../../external/glfw3/include/mac"; + }; + name = Release; + }; + A07A502E178387750073F6A7 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = YES; + EXECUTABLE_PREFIX = ""; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + COCOS2D_JAVASCRIPT, + CC_TARGET_OS_IPHONE, + ); + HEADER_SEARCH_PATHS = ""; + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(SRCROOT)/../../../../external/spidermonkey/prebuilt/ios", + ); + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../../external/spidermonkey/include/ios $(SRCROOT)/../../../../cocos/platform/ios $(SRCROOT)/../../../../plugin/protocols/include"; + VALID_ARCHS = "arm64 armv7"; + }; + name = Debug; + }; + A07A502F178387750073F6A7 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = YES; + EXECUTABLE_PREFIX = ""; + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + COCOS2D_JAVASCRIPT, + CC_TARGET_OS_IPHONE, + ); + HEADER_SEARCH_PATHS = ""; + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(SRCROOT)/../../../../external/spidermonkey/prebuilt/ios", + ); + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../../external/spidermonkey/include/ios $(SRCROOT)/../../../../cocos/platform/ios $(SRCROOT)/../../../../plugin/protocols/include"; + VALID_ARCHS = "arm64 armv7"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1551A339158F2AB200E66CFE /* Build configuration list for PBXProject "cocos2d_js_bindings" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1551A34A158F2AB200E66CFE /* Debug */, + 1551A34B158F2AB200E66CFE /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + A03F31FA1781479B006731B9 /* Build configuration list for PBXNativeTarget "libjscocos2d Mac" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A03F31FB1781479B006731B9 /* Debug */, + A03F31FC1781479B006731B9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + A07A502D178387750073F6A7 /* Build configuration list for PBXNativeTarget "libjscocos2d iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A07A502E178387750073F6A7 /* Debug */, + A07A502F178387750073F6A7 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 1551A336158F2AB200E66CFE /* Project object */; +} diff --git a/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/xcshareddata/xcschemes/libjscocos2d Mac.xcscheme b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/xcshareddata/xcschemes/libjscocos2d Mac.xcscheme new file mode 100644 index 0000000000..84b28321b5 --- /dev/null +++ b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/xcshareddata/xcschemes/libjscocos2d Mac.xcscheme @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/xcshareddata/xcschemes/libjscocos2d iOS.xcscheme b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/xcshareddata/xcschemes/libjscocos2d iOS.xcscheme new file mode 100644 index 0000000000..e20e252800 --- /dev/null +++ b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/xcshareddata/xcschemes/libjscocos2d iOS.xcscheme @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj new file mode 100644 index 0000000000..85efe5adb5 --- /dev/null +++ b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj @@ -0,0 +1,193 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} + + + + {39379840-825A-45A0-B363-C09FFEF864BD} + Win32Proj + libjscocos2d + + + + StaticLibrary + true + Unicode + v120 + v120_xp + + + StaticLibrary + false + Unicode + v120 + v120_xp + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration).win32\ + + + $(Configuration).win32\$(ProjectName)\ + + + $(SolutionDir)$(Configuration).win32\ + + + $(Configuration).win32\$(ProjectName)\ + + + + + + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;_LIB;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)external;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\spine;$(ProjectDir)..\..\..\..\external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4068;4101;4800;4251;4244;4099;4083;4700;%(DisableSpecificWarnings) + true + false + ProgramDatabase + + + Windows + true + + + if not exist "$(OutDir)" mkdir "$(OutDir)" + +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" + + + + + + Level3 + + + MinSpace + true + true + WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)external;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\spine;$(ProjectDir)..\..\..\..\external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4068;4101;4800;4251;4244;4099;4083;4700;%(DisableSpecificWarnings) + true + None + + + Windows + true + true + true + + + if not exist "$(OutDir)" mkdir "$(OutDir)" + +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" + + + + + + + \ No newline at end of file diff --git a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters new file mode 100644 index 0000000000..889f76b99f --- /dev/null +++ b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters @@ -0,0 +1,263 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {05fe556b-0330-48c1-bfe1-0e7119db20a1} + + + {1a494d10-c2d0-498c-8b80-2f45fee36640} + + + {af265b68-4f27-4561-b7ab-299f21212e08} + + + {f4329991-ce95-4f10-9442-92d63bd6aea1} + + + {3248ad6e-d03d-4cce-8846-81aa376fc480} + + + {7b278f66-4153-44d8-ba60-d7b7feed8a17} + + + {59756149-2598-457f-ae42-ad675d5f3783} + + + {db4d6533-8c6a-4a18-bdd6-c9b98b897458} + + + {3d1a97d2-47a9-4fc2-8458-a58c4f1fc111} + + + + + auto + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + auto + + + auto + + + auto + + + auto + + + auto + + + manual\chipmunk + + + manual\chipmunk + + + manual\chipmunk + + + manual\chipmunk + + + manual\cocosbuilder + + + manual\cocostudio + + + manual\extension + + + manual\localstorage + + + manual\localstorage + + + manual\network + + + manual\network + + + manual\network + + + manual\spine + + + manual\ui + + + manual\cocostudio + + + auto + + + auto + + + manual\3d + + + + + auto + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + auto + + + auto + + + auto + + + auto + + + auto + + + manual\chipmunk + + + manual\chipmunk + + + manual\chipmunk + + + manual\chipmunk + + + manual\chipmunk + + + manual\chipmunk + + + manual\cocosbuilder + + + manual\cocosbuilder + + + manual\cocostudio + + + manual\extension + + + manual\localstorage + + + manual\localstorage + + + manual\localstorage + + + manual\network + + + manual\network + + + manual\network + + + manual\spine + + + manual\ui + + + manual\cocostudio + + + auto + + + auto + + + manual\3d + + + \ No newline at end of file diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems new file mode 100644 index 0000000000..1a1d65f4a9 --- /dev/null +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems @@ -0,0 +1,106 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + {bea66276-51dd-4c53-92a8-f3d1fea50892} + libjscocos2d + libjscocos2d.Shared + 248F659F-DAC5-46E8-AC09-60EC9FC95053 + + + + %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems.filters b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems.filters new file mode 100644 index 0000000000..73f33d2237 --- /dev/null +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems.filters @@ -0,0 +1,288 @@ + + + + + + auto + + + auto + + + auto + + + auto + + + auto + + + auto + + + auto + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual\chipmunk + + + manual\chipmunk + + + manual\chipmunk + + + manual\chipmunk + + + manual\chipmunk + + + manual\chipmunk + + + manual\cocosbuilder + + + manual\cocosbuilder + + + manual\cocostudio + + + manual\cocostudio + + + manual\extension + + + manual\localstorage + + + manual\localstorage + + + manual\localstorage + + + manual\network + + + manual\network + + + manual\network + + + manual\ui + + + manual\spine + + + auto + + + + + auto + + + auto + + + auto + + + auto + + + auto + + + auto + + + auto + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual + + + manual\chipmunk + + + manual\chipmunk + + + manual\chipmunk + + + manual\chipmunk + + + manual\cocosbuilder + + + manual\cocostudio + + + manual\cocostudio + + + manual\extension + + + manual\localstorage + + + manual\localstorage + + + manual\network + + + manual\network + + + manual\network + + + manual\ui + + + manual\spine + + + auto + + + + + {c82eec33-f18d-4e3b-aa7e-4f75fd188ccc} + + + {69cfef88-18f0-4cc3-946e-26e1b5617cc0} + + + {68194864-f409-45ce-97d8-25ce6ffb220d} + + + {2e5c2cc9-45ed-4be9-a5df-3425a4bd9f9f} + + + {1c2fc87d-036e-4de9-a530-d6088e34e905} + + + {363afad8-dbaf-400e-b9a8-e27a06423c7c} + + + {1342560f-e950-4f9e-ad6b-253d35430ea4} + + + {c4db8dfe-e868-4e05-abf8-454496eee310} + + + {fc1ed5ab-66bf-472f-9467-06b41e3eec47} + + + {b55ad312-2220-4a48-bcf3-b048b39d8176} + + + {1455b26b-f54b-4a98-80c5-bb4cf0052afe} + + + {d5fa188f-db09-4c4b-a366-682bf76fcea2} + + + + + auto\api + + + auto\api + + + auto\api + + + auto\api + + + auto\api + + + auto\api + + + auto\api + + + \ No newline at end of file diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/targetver.h b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/targetver.h new file mode 100644 index 0000000000..a66ecb00f1 --- /dev/null +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj new file mode 100644 index 0000000000..b89f99e5a3 --- /dev/null +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj @@ -0,0 +1,253 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + {bcf5546d-66a0-4998-afd6-c5514f618930} + libjscocos2d + en-US + 12.0 + true + Windows Store + 8.1 + CodeSharingStaticLibrary + + + + StaticLibrary + true + v120 + + + StaticLibrary + true + v120 + + + StaticLibrary + true + v120 + + + StaticLibrary + false + true + v120 + + + StaticLibrary + false + true + v120 + + + StaticLibrary + false + true + v120 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + false + + + false + + + false + + + false + + + false + + + + NotUsing + true + false + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4800;4703;4101;4083;4700;4068;%(DisableSpecificWarnings) + Level3 + CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + true + + + Console + false + false + + + /IGNORE:4264 %(AdditionalOptions) + + + + + NotUsing + true + false + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4800;4703;4101;4083;4700;4068;%(DisableSpecificWarnings) + Level3 + CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + false + OldStyle + + + Console + false + false + + + false + /IGNORE:4264 %(AdditionalOptions) + + + + + NotUsing + true + false + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\wp8;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4800;4703;4101;4083;4700;4068;%(DisableSpecificWarnings) + Level3 + CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + true + + + Console + false + false + + + /IGNORE:4264 %(AdditionalOptions) + + + + + NotUsing + true + false + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\wp8;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4800;4703;4101;4083;4700;4068;%(DisableSpecificWarnings) + Level3 + CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + false + OldStyle + + + Console + false + false + + + false + /IGNORE:4264 %(AdditionalOptions) + + + + + NotUsing + true + false + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\wp8;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4800;4703;4101;4083;4700;4068;%(DisableSpecificWarnings) + Level3 + CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + true + + + Console + false + false + + + /IGNORE:4264 %(AdditionalOptions) + + + + + NotUsing + true + false + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\wp8;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4800;4703;4101;4083;4700;4068;%(DisableSpecificWarnings) + Level3 + CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + false + OldStyle + + + Console + false + false + + + false + /IGNORE:4264 %(AdditionalOptions) + + + + + + \ No newline at end of file diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj.filters b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj.filters new file mode 100644 index 0000000000..a7761ab018 --- /dev/null +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj.filters @@ -0,0 +1,5 @@ + + + + + diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj new file mode 100644 index 0000000000..474cff9448 --- /dev/null +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj @@ -0,0 +1,176 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Release + ARM + + + Release + Win32 + + + + {ca082ec4-17ce-430b-8207-d1e947a5d1e9} + libjscocos2d + en-US + 12.0 + true + Windows Phone + 8.1 + CodeSharingStaticLibrary + + + + StaticLibrary + true + v120_wp81 + + + StaticLibrary + true + v120_wp81 + + + StaticLibrary + false + true + v120_wp81 + + + StaticLibrary + false + true + v120_wp81 + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + false + + + false + + + false + + + + NotUsing + true + false + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\wp_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4800;4703;4101;4083;4700;4068;%(DisableSpecificWarnings) + Level3 + CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + true + + + Console + false + false + + + /IGNORE:4264 %(AdditionalOptions) + + + + + NotUsing + true + false + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\wp_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4800;4703;4101;4083;4700;4068;%(DisableSpecificWarnings) + Level3 + CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + false + OldStyle + + + Console + false + false + + + false + /IGNORE:4264 %(AdditionalOptions) + + + + + NotUsing + true + false + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\wp8;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4800;4703;4101;4083;4700;4068;%(DisableSpecificWarnings) + Level3 + CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + true + + + Console + false + false + + + /IGNORE:4264 %(AdditionalOptions) + + + + + NotUsing + true + false + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\wp8;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + 4800;4703;4101;4083;4700;4068;%(DisableSpecificWarnings) + Level3 + CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + false + OldStyle + + + Console + false + false + + + false + /IGNORE:4264 %(AdditionalOptions) + + + + + + \ No newline at end of file diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj.filters b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj.filters new file mode 100644 index 0000000000..a7761ab018 --- /dev/null +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj.filters @@ -0,0 +1,5 @@ + + + + + diff --git a/cocos/scripting/js-bindings/script/3d/jsb_cocos2d_3d.js b/cocos/scripting/js-bindings/script/3d/jsb_cocos2d_3d.js new file mode 100644 index 0000000000..855055fa63 --- /dev/null +++ b/cocos/scripting/js-bindings/script/3d/jsb_cocos2d_3d.js @@ -0,0 +1,281 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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. + ****************************************************************************/ +cc.CameraFlag = { + DEFAULT : 1, + USER1 : 1 << 1, + USER2 : 1 << 2, + USER3 : 1 << 3, + USER4 : 1 << 4, + USER5 : 1 << 5, + USER6 : 1 << 6, + USER7 : 1 << 7, + USER8 : 1 << 8 +}; + +cc.LightType = { + DIRECTIONAL : 0, + POINT : 1, + SPOT : 2, + AMBIENT : 3, +}; + +cc.LightFlag = { + LIGHT0 : 1, + LIGHT1 : 1 << 1, + LIGHT2 : 1 << 2, + LIGHT3 : 1 << 3, + LIGHT4 : 1 << 4, + LIGHT5 : 1 << 5, + LIGHT6 : 1 << 6, + LIGHT7 : 1 << 7, + LIGHT8 : 1 << 8, + LIGHT9 : 1 << 9, + LIGHT10 : 1 << 10, + LIGHT11 : 1 << 11, + LIGHT12 : 1 << 12, + LIGHT13 : 1 << 13, + LIGHT14 : 1 << 14, + LIGHT15 : 1 << 15, +}; + +cc.AsyncTaskPool.TaskType = { + TASK_IO : 0, + TASK_NETWORK : 1, + TASK_OTHER : 2, + TASK_MAX_TYPE : 3 +}; + +jsb.BillBoard.Mode = { + VIEW_POINT_ORIENTED : 0, // orient to the camera + VIEW_PLANE_ORIENTED : 1 // orient to the XOY plane of camera +}; + +jsb.Terrain.CrackFixedType = { + SKIRT : 0, + INCREASE_LOWER : 1 +}; + +jsb.Terrain.DetailMap = function(file, size = 35){ + this.file = file; + this.size = size; +}; +jsb.Terrain.detailMap = function(file, size){ + return new jsb.Terrain.DetailMap(file, size); +}; + +jsb.Terrain.TerrainData = function(heightMap, alphaMap, detailMap, chunkSize = cc.size(32, 32), mapHeight = 2, mapScale = 0.1){ + this.heightMap = heightMap; + this.alphaMap = alphaMap; + this.detailMap = detailMap; + this.chunkSize = chunkSize; + this.mapHeight = mapHeight; + this.mapScale = mapScale; +}; +jsb.Terrain.terrainData = function(heightMap, alphaMap, detailMap, chunkSize, mapHeight, mapScale){ + return new jsb.Terrain.TerrainData(heightMap, alphaMap, detailMap, chunkSize, mapHeight, mapScale); +}; + +cc.attributeNames = [cc.ATTRIBUTE_NAME_POSITION, + cc.ATTRIBUTE_NAME_COLOR, + cc.ATTRIBUTE_NAME_TEX_COORD, + cc.ATTRIBUTE_NAME_TEX_COORD1, + cc.ATTRIBUTE_NAME_TEX_COORD2, + cc.ATTRIBUTE_NAME_TEX_COORD3, + cc.ATTRIBUTE_NAME_NORMAL, + cc.ATTRIBUTE_NAME_BLEND_WEIGHT, + cc.ATTRIBUTE_NAME_BLEND_INDEX]; + +cc.math = cc.math || {}; + +cc.math.Vec3 = function(x=0, y=0, z=0){ + this.x = x; + this.y = y; + this.z = z; +}; + +cc.math.Vec3.prototype.normalize = function(){ + var n = this.x * this.x + this.y * this.y + this.z * this.z; + n = 1 / Math.sqrt(n); + this.x *= n; + this.y *= n; + this.z *= n; +}; + +cc.math.vec3 = function(x, y, z){ + return new cc.math.Vec3(x, y, z); +}; + +cc.math.vec3Cross = function(v1, v2){ + return new cc.math.Vec3(v1.y * v2.z - v1.z * v2.y, + v1.z * v2.x - v1.x * v2.z, + v1.x * v2.y - v1.y * v2.x); +}; + +cc.math.vec3Dot = function(v1, v2){ + return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; +}; + +cc.math.vec3Length = function(v){ + return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z); +}; + +cc.math.vec3Normalize = function(v){ + var n = v.x * v.x + v.y * v.y + v.z * v.z; + n = 1 / Math.sqrt(n); + return cc.math.vec3(v.x * n, v.y * n, v.z * n); +}; + +cc.math.vec3Add = function(v1, v2){ + return new cc.math.Vec3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); +}; + +cc.math.vec3Sub = function(v1, v2){ + return new cc.math.Vec3(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); +}; + +cc.math.Quaternion = function(x=0, y=0, z=0, w=0){ + this.x = x; + this.y = y; + this.z = z; + this.w = w; +}; + +cc.math.quaternion = function(xOrAxis, yOrAngle, z, w){ + if(w !== undefined){ + return new cc.math.Quaternion(xOrAxis, yOrAngle, z, w); + } + else if(yOrAngle !== undefined){ + var sinHalfAngle = Math.sin(yOrAngle / 2); + var normal = cc.math.vec3(xOrAxis.x, xOrAxis.y, xOrAxis.z); + normal.normalize(); + return cc.math.quaternion(normal.x * sinHalfAngle, normal.y * sinHalfAngle, normal.z * sinHalfAngle, Math.cos(yOrAngle / 2)); + } +}; + +cc.math.AABB = function(min=cc.math.vec3(99999, 99999, 99999), max=cc.math.vec3(-99999, -99999, -99999)){ + this.min = min; + this.max = max; +}; + +cc.math.aabb = function(min, max){ + return new cc.math.AABB(min, max); +}; + +cc.math.aabbGetCorners = function(aabb){ + var corners = new Array(8); + corners[0] = cc.math.vec3(aabb.min.x, aabb.max.y, aabb.max.z); + corners[1] = cc.math.vec3(aabb.min.x, aabb.min.y, aabb.max.z); + corners[2] = cc.math.vec3(aabb.max.x, aabb.min.y, aabb.max.z); + corners[3] = cc.math.vec3(aabb.max.x, aabb.max.y, aabb.max.z); + + corners[4] = cc.math.vec3(aabb.max.x, aabb.max.y, aabb.min.z); + corners[5] = cc.math.vec3(aabb.max.x, aabb.min.y, aabb.min.z); + corners[6] = cc.math.vec3(aabb.min.x, aabb.min.y, aabb.min.z); + corners[7] = cc.math.vec3(aabb.min.x, aabb.max.y, aabb.min.z); + return corners; +}; + +cc.math.OBB = function(aabb){ + this.center = cc.math.vec3((aabb.min.x + aabb.max.x)/2, (aabb.min.y + aabb.max.y)/2, (aabb.min.z + aabb.max.z)/2); // obb center + this.xAxis = cc.math.vec3(1, 0, 0); // x axis of obb, unit vector + this.yAxis = cc.math.vec3(0, 1, 0); // y axis of obb, unit vecotr + this.zAxis = cc.math.vec3(0, 0, 1); // z axis of obb, unit vector + this.extents = cc.math.vec3((aabb.max.x - aabb.min.x)/2, (aabb.max.y - aabb.min.y)/2, (aabb.max.z - aabb.min.z)/2); // obb length along each axis + this.extentX = cc.math.vec3((aabb.max.x - aabb.min.x)/2, 0, 0); // _xAxis * _extents.x + this.extentY = cc.math.vec3(0, (aabb.max.y - aabb.min.y)/2, 0); // _yAxis * _extents.y + this.extentZ = cc.math.vec3(0, 0, (aabb.max.z - aabb.min.z)/2); // _zAxis * _extents.z +}; + +cc.math.obb = function(aabb){ + return new cc.math.OBB(aabb); +}; + +cc.math.Ray = function(origin = cc.math.vec3(0, 0, 0), direction = cc.math.vec3(0, 0, 1)){ + this.origin = origin; + this.direction = direction; +}; + +cc.math.ray = function(origin, direction){ + return new cc.math.Ray(origin, direction); +}; + +cc.math.Vec4 = cc.math.Quaternion; + +cc.math.vec4 = function(x, y, z, w){ + return new cc.math.Vec4(x, y, z, w); +}; + +jsb.sprite3DCache = jsb.Sprite3DCache.getInstance(); + +jsb.Sprite3D.extend = cc.Class.extend; + +jsb.Sprite3D.prototype._setBlendFunc = jsb.Sprite3D.prototype.setBlendFunc; +jsb.Sprite3D.prototype.setBlendFunc = templateSetBlendFunc; + +jsb.Mesh.prototype._setBlendFunc = jsb.Mesh.prototype.setBlendFunc; +jsb.Mesh.prototype.setBlendFunc = templateSetBlendFunc; + +jsb.Sprite3D.prototype._ctor = function(modelPath, texturePath){ + if(modelPath === undefined){ + this.init(); + }else{ + if(modelPath.length < 4){ + cc.log("invalid filename for Sprite3D"); + return; + } + this.initWithFile(modelPath); + var bb = this.getBoundingBox(); + this.setContentSize(cc.size(bb.width, bb.height)); + + if(texturePath !== undefined) + this.setTexture(texturePath); + } +}; + +jsb.BillBoard.prototype._ctor = function(filename, rect, mode = jsb.BillBoard.Mode.VIEW_POINT_ORIENTED){ + if(filename !== undefined && filename instanceof cc.Texture2D){ + rect = rect || jsb.BillBoard.Mode.VIEW_POINT_ORIENTED; + this.initWithTexture(filename); + this.setMode(rect); + }else if(filename !== undefined && typeof filename === "string"){ + if(rect !== undefined){ + if(typeof rect === "object"){ + this.initWithFile(filename, rect); + this.setMode(mode); + }else{ + this.initWithFile(filename); + this.setMode(rect); + } + }else{ + this.initWithFile(filename); + this.setMode(jsb.BillBoard.Mode.VIEW_POINT_ORIENTED); + } + }else{ + filename = filename || jsb.BillBoard.Mode.VIEW_POINT_ORIENTED; + this.init(); + this.setMode(filename); + } +} diff --git a/cocos/scripting/js-bindings/script/3d/jsb_cocos2d_3d_ext.js b/cocos/scripting/js-bindings/script/3d/jsb_cocos2d_3d_ext.js new file mode 100644 index 0000000000..653e88fdbe --- /dev/null +++ b/cocos/scripting/js-bindings/script/3d/jsb_cocos2d_3d_ext.js @@ -0,0 +1,28 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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. + ****************************************************************************/ + +jsb.ParticleSystem3D.prototype._setBlendFunc = jsb.ParticleSystem3D.prototype.setBlendFunc; +jsb.ParticleSystem3D.prototype.setBlendFunc = templateSetBlendFunc; \ No newline at end of file diff --git a/cocos/scripting/js-bindings/script/ccui/jsb_ccui_create_apis.js b/cocos/scripting/js-bindings/script/ccui/jsb_ccui_create_apis.js new file mode 100644 index 0000000000..86bd8f6ab7 --- /dev/null +++ b/cocos/scripting/js-bindings/script/ccui/jsb_ccui_create_apis.js @@ -0,0 +1,159 @@ +/* + * 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) { + if(texType !== undefined) + ccui.Button.prototype.init.call(this, normalImage, selectedImage, disableImage, texType); + else if(disableImage !== undefined) + ccui.Button.prototype.init.call(this, normalImage, selectedImage, disableImage); + else if(selectedImage !== undefined) + ccui.Button.prototype.init.call(this, normalImage, selectedImage); + else if(normalImage !== undefined) + ccui.Button.prototype.init.call(this, normalImage); + else + 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 if(backGroundSelected !== undefined){ + texType = ccui.Widget.LOCAL_TEXTURE; + cross = backGroundSelected; + backGroundSelected = backGroundDisabled = frontCrossDisabled = backGround; + 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(imageFileName !== undefined){ + texType = texType || ccui.Widget.LOCAL_TEXTURE; + 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); +}; diff --git a/cocos/scripting/js-bindings/script/ccui/jsb_ccui_deprecated.js b/cocos/scripting/js-bindings/script/ccui/jsb_ccui_deprecated.js new file mode 100644 index 0000000000..5144d54931 --- /dev/null +++ b/cocos/scripting/js-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/cocos/scripting/js-bindings/script/ccui/jsb_ccui_property_apis.js b/cocos/scripting/js-bindings/script/ccui/jsb_ccui_property_apis.js new file mode 100644 index 0000000000..4fd8a4861c --- /dev/null +++ b/cocos/scripting/js-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/cocos/scripting/js-bindings/script/ccui/jsb_ccui_property_impls.js b/cocos/scripting/js-bindings/script/ccui/jsb_ccui_property_impls.js new file mode 100644 index 0000000000..17ec7140b2 --- /dev/null +++ b/cocos/scripting/js-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/cocos/scripting/js-bindings/script/ccui/jsb_cocos2d_ui.js b/cocos/scripting/js-bindings/script/ccui/jsb_cocos2d_ui.js new file mode 100644 index 0000000000..8a4d52fdd2 --- /dev/null +++ b/cocos/scripting/js-bindings/script/ccui/jsb_cocos2d_ui.js @@ -0,0 +1,382 @@ +/* + * 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. + */ + +// +// cocos2d ui constants +// +// This helper file should be required after jsb_cocos2d.js +// + +var ccui = ccui || {}; + +// =====================Constants===================== + +/* + * UILayout + */ +//layoutBackGround color type +ccui.Layout.BG_COLOR_NONE = 0; +ccui.Layout.BG_COLOR_SOLID = 1; +ccui.Layout.BG_COLOR_GRADIENT = 2; + +//Layout type +ccui.Layout.ABSOLUTE = 0; +ccui.Layout.LINEAR_VERTICAL = 1; +ccui.Layout.LINEAR_HORIZONTAL = 2; +ccui.Layout.RELATIVE = 3; + +//Layout clipping type +ccui.Layout.CLIPPING_STENCIL = 0; +ccui.Layout.CLIPPING_SCISSOR = 1; + +ccui.Layout.BACKGROUND_IMAGE_ZORDER = -2; +ccui.Layout.BACKGROUND_RENDERER_ZORDER = -2; + +/* + * UILayoutDefine + */ +//LinearGravity +//old +ccui.LINEAR_GRAVITY_NONE = 0; +ccui.LINEAR_GRAVITY_LEFT = 1; +ccui.LINEAR_GRAVITY_TOP = 2; +ccui.LINEAR_GRAVITY_RIGHT = 3; +ccui.LINEAR_GRAVITY_BOTTOM = 4; +ccui.LINEAR_GRAVITY_CENTER_VERTICAL = 5; +ccui.LINEAR_GRAVITY_CENTER_HORIZONTAL = 6; +//new +ccui.LinearLayoutParameter.NONE = 0; +ccui.LinearLayoutParameter.LEFT = 1; +ccui.LinearLayoutParameter.TOP = 2; +ccui.LinearLayoutParameter.RIGHT = 3; +ccui.LinearLayoutParameter.BOTTOM = 4; +ccui.LinearLayoutParameter.CENTER_VERTICAL = 5; +ccui.LinearLayoutParameter.CENTER_HORIZONTAL = 6; + +//RelativeAlign +//old +ccui.RELATIVE_ALIGN_NONE = 0; +ccui.RELATIVE_ALIGN_PARENT_TOP_LEFT = 1; +ccui.RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL = 2; +ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT = 3; +ccui.RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL = 4; +ccui.RELATIVE_ALIGN_PARENT_CENTER = 5; +ccui.RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL = 6; +ccui.RELATIVE_ALIGN_PARENT_LEFT_BOTTOM = 7; +ccui.RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL = 8; +ccui.RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM = 9; + +ccui.RELATIVE_ALIGN_LOCATION_ABOVE_LEFT = 10; +ccui.RELATIVE_ALIGN_LOCATION_ABOVE_CENTER = 11; +ccui.RELATIVE_ALIGN_LOCATION_ABOVE_RIGHT = 12; + +ccui.RELATIVE_ALIGN_LOCATION_LEFT_TOP = 13; +ccui.RELATIVE_ALIGN_LOCATION_LEFT_CENTER = 14; +ccui.RELATIVE_ALIGN_LOCATION_LEFT_BOTTOM = 15; + +ccui.RELATIVE_ALIGN_LOCATION_RIGHT_TOP = 16; +ccui.RELATIVE_ALIGN_LOCATION_RIGHT_CENTER = 17; +ccui.RELATIVE_ALIGN_LOCATION_RIGHT_BOTTOM = 18; + +ccui.RELATIVE_ALIGN_LOCATION_BELOW_TOP = 19; +ccui.RELATIVE_ALIGN_LOCATION_BELOW_CENTER = 20; +ccui.RELATIVE_ALIGN_LOCATION_BELOW_BOTTOM = 21; + +//new +ccui.RelativeLayoutParameter.NONE = 0; +ccui.RelativeLayoutParameter.PARENT_TOP_LEFT = 1; +ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL = 2; +ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT = 3; +ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL = 4; + +ccui.RelativeLayoutParameter.CENTER_IN_PARENT = 5; + +ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL = 6; +ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM = 7; +ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL = 8; +ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM = 9; + +ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN = 10; +ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER = 11; +ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN = 12; +ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN = 13; +ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER = 14; +ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN = 15; +ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN = 16; +ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER = 17; +ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN = 18; +ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN = 19; +ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER = 20; +ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN = 21; + +/* + * LayoutParameter + */ +//layout parameter type +ccui.LayoutParameter.NONE = 0; +ccui.LayoutParameter.LINEAR = 1; +ccui.LayoutParameter.RELATIVE = 2; + +//LayoutComponent +ccui.LayoutComponent.horizontalEdge = {}; +ccui.LayoutComponent.horizontalEdge.NONE = 0; +ccui.LayoutComponent.horizontalEdge.LEFT = 1; +ccui.LayoutComponent.horizontalEdge.RIGHT = 2; +ccui.LayoutComponent.horizontalEdge.CENTER = 3; + +ccui.LayoutComponent.verticalEdge = {}; +ccui.LayoutComponent.verticalEdge.NONE = 0; +ccui.LayoutComponent.verticalEdge.BOTTOM = 1; +ccui.LayoutComponent.verticalEdge.TOP = 2; +ccui.LayoutComponent.verticalEdge.CENTER = 3; +/* + * UIWidget + */ +//bright style +ccui.Widget.BRIGHT_STYLE_NONE = -1; +ccui.Widget.BRIGHT_STYLE_NORMAL = 0; +ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT = 1; + +//widget type +ccui.Widget.TYPE_WIDGET = 0; +ccui.Widget.TYPE_CONTAINER = 1; + +//texture resource type +ccui.Widget.LOCAL_TEXTURE = 0; +ccui.Widget.PLIST_TEXTURE = 1; + +//touch event type +ccui.Widget.TOUCH_BEGAN = 0; +ccui.Widget.TOUCH_MOVED = 1; +ccui.Widget.TOUCH_ENDED = 2; +ccui.Widget.TOUCH_CANCELED = 3; + +//size type +ccui.Widget.SIZE_ABSOLUTE = 0; +ccui.Widget.SIZE_PERCENT = 1; + +//position type +ccui.Widget.POSITION_ABSOLUTE = 0; +ccui.Widget.POSITION_PERCENT = 1; + +//focus direction +ccui.Widget.LEFT = 0; +ccui.Widget.RIGHT = 1; +ccui.Widget.UP = 2; +ccui.Widget.DOWN = 3; + +/* + * UIListView + */ +//listView event type +ccui.ListView.EVENT_SELECTED_ITEM = 0; +ccui.ListView.ON_SELECTED_ITEM_START = 0; +ccui.ListView.ON_SELECTED_ITEM_END = 1; + +//listView gravity +ccui.ListView.GRAVITY_LEFT = 0; +ccui.ListView.GRAVITY_RIGHT = 1; +ccui.ListView.GRAVITY_CENTER_HORIZONTAL = 2; +ccui.ListView.GRAVITY_TOP = 3; +ccui.ListView.GRAVITY_BOTTOM = 4; +ccui.ListView.GRAVITY_CENTER_VERTICAL = 5; + +/* + * UIScrollView + */ +//ScrollView direction +ccui.ScrollView.DIR_NONE = 0; +ccui.ScrollView.DIR_VERTICAL = 1; +ccui.ScrollView.DIR_HORIZONTAL = 2; +ccui.ScrollView.DIR_BOTH = 3; + +//ScrollView event +ccui.ScrollView.EVENT_SCROLL_TO_TOP = 0; +ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM = 1; +ccui.ScrollView.EVENT_SCROLL_TO_LEFT = 2; +ccui.ScrollView.EVENT_SCROLL_TO_RIGHT = 3; +ccui.ScrollView.EVENT_SCROLLING = 4; +ccui.ScrollView.EVENT_BOUNCE_TOP = 5; +ccui.ScrollView.EVENT_BOUNCE_BOTTOM = 6; +ccui.ScrollView.EVENT_BOUNCE_LEFT = 7; +ccui.ScrollView.EVENT_BOUNCE_RIGHT = 8; + + +ccui.ScrollView.AUTO_SCROLL_MAX_SPEED = 1000; +ccui.ScrollView.SCROLLDIR_UP = cc.p(0, 1); +ccui.ScrollView.SCROLLDIR_DOWN = cc.p(0, -1); +ccui.ScrollView.SCROLLDIR_LEFT = cc.p(-1, 0); +ccui.ScrollView.SCROLLDIR_RIGHT = cc.p(1, 0); + +/* + * UIPageView + */ +//PageView event +ccui.PageView.EVENT_TURNING = 0; + +//PageView touch direction +ccui.PageView.TOUCH_DIR_LEFT = 0; +ccui.PageView.TOUCH_DIR_RIGHT = 1; + +/* + * UIButton + */ +ccui.NORMAL_RENDERER_ZORDER = -2; +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 + */ +//CheckBoxEvent type +ccui.CheckBox.EVENT_SELECTED = 0; +ccui.CheckBox.EVENT_UNSELECTED = 1; + +//Render zorder +ccui.CheckBox.BOX_RENDERER_ZORDER = -1; +ccui.CheckBox.BOX_SELECTED_RENDERER_ZORDER = -1; +ccui.CheckBox.BOX_DISABLED_RENDERER_ZORDER = -1; +ccui.CheckBox.FRONT_CROSS_RENDERER_ZORDER = -1; +ccui.CheckBox.FRONT_CROSS_DISABLED_RENDERER_ZORDER = -1; + +/* + * UIImageView + */ +ccui.ImageView.RENDERER_ZORDER = -1; + +/* + * UILoadingBar + */ +//loadingBar Type +ccui.LoadingBar.TYPE_LEFT = 0; +ccui.LoadingBar.TYPE_RIGHT = 1; + +ccui.LoadingBar.RENDERER_ZORDER = -1; + +/* + * UIRichElement + */ +//Rich element type +//ccui.RichElement.TYPE_TEXT = 0; +//ccui.RichElement.TYPE_IMAGE = 1; +//ccui.RichElement.TYPE_CUSTOM = 2; + +/* + * UISlider + */ +//Slider event type +ccui.Slider.EVENT_PERCENT_CHANGED = 0; + +//Render zorder +ccui.Slider.BASEBAR_RENDERER_ZORDER = -3; +ccui.Slider.PROGRESSBAR_RENDERER_ZORDER = -2; +ccui.Slider.BALL_RENDERER_ZORDER = -1; + +/* + * UIText + */ +ccui.Text.RENDERER_ZORDER = -1; + +/* + * UITextAtlas + */ +ccui.TextAtlas.RENDERER_ZORDER = -1; + +/* + * UITextBMFont + */ +ccui.TextBMFont.RENDERER_ZORDER = -1; + +/* + * UITextField + */ +//TextField event +ccui.TextField.EVENT_ATTACH_WITH_IME = 0; +ccui.TextField.EVENT_DETACH_WITH_IME = 1; +ccui.TextField.EVENT_INSERT_TEXT = 2; +ccui.TextField.EVENT_DELETE_BACKWARD = 3; + +ccui.TextField.RENDERER_ZORDER = -1; + + +/* + * UIMargin + */ +ccui.Margin = cc.Class.extend({ + left: 0, + top: 0, + right: 0, + bottom: 0, + ctor: function () { + if (arguments.length == 1) { + var uiMargin = arguments[0]; + this.left = uiMargin.left; + this.top = uiMargin.top; + this.right = uiMargin.right; + this.bottom = uiMargin.bottom; + } + if (arguments.length == 4) { + this.left = arguments[0]; + this.top = arguments[1]; + this.right = arguments[2]; + this.bottom = arguments[3]; + } + }, + setMargin: function (l, t, r, b) { + this.left = l; + this.top = t; + this.right = r; + this.bottom = b; + }, + equals: function (target) { + return (this.left == target.left && this.top == target.top && this.right == target.right && this.bottom == target.bottom); + } +}); + +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 + * addNode and addChild function should be merged in ccui.Widget + */ +ccui.Widget.prototype.addNode = ccui.Widget.prototype.addChild; +ccui.Widget.prototype.getSize = ccui.Widget.prototype.getContentSize; +ccui.Widget.prototype.setSize = ccui.Widget.prototype.setContentSize; \ No newline at end of file diff --git a/cocos/scripting/js-bindings/script/chipmunk/jsb_chipmunk.js b/cocos/scripting/js-bindings/script/chipmunk/jsb_chipmunk.js new file mode 100644 index 0000000000..fa7bedc59a --- /dev/null +++ b/cocos/scripting/js-bindings/script/chipmunk/jsb_chipmunk.js @@ -0,0 +1,376 @@ +/* + * 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. + */ + +// +// Chipmunk defines +// + +var cp = cp || {}; + +cp.Vect = function(x, y){ + this.x = x; + this.y = y; +} +cp.Vect.prototype.add = function(v){ + this.x += v.x; + this.y += v.y; + return this; +} +cp.Vect.prototype.sub = function(v){ + this.x -= v.x; + this.y -= v.y; + return this; +} +cp.Vect.prototype.neg = function(){ + this.x = -this.x; + this.y = -this.y; + return this; +} +cp.Vect.prototype.mult = function(s){ + this.x *= s; + this.y *= s; + return this; +} +cp.Vect.prototype.rotate = function(v){ + this.x = this.x * v.x - this.y * v.y; + this.y = this.x * v.y + this.y * v.x; + return this; +} +cp.Vect.prototype.project = function(v){ + this.mult(cp.vdot(this, v) / cp.vlengthsq(v)); + return this; +} + +cp.v = function(x, y){ + return new cp.Vect(x, y); +} +cp.vzero = cp.v(0,0); + +// Vector: Compatibility with Chipmunk-JS +cp.v.add = cp.vadd; +cp.v.clamp = cp.vclamp; +cp.v.cross = cp.vcross; +cp.v.dist = cp.vdist; +cp.v.distsq = cp.vdistsq; +cp.v.dot = cp.vdot; +cp.v.eql = cp.veql; +cp.v.forangle = cp.vforangle; +cp.v.len = cp.vlength; +cp.v.lengthsq = cp.vlengthsq; +cp.v.lerp = cp.vlerp; +cp.v.lerpconst = cp.vlerpconst; +cp.v.mult = cp.vmult; +cp.v.near = cp.vnear; +cp.v.neg = cp.vneg; +cp.v.normalize = cp.vnormalize; +cp.v.normalize_safe = cp.vnormalize_safe; +cp.v.perp = cp.vperp; +cp.v.project = cp.vproject; +cp.v.rotate = cp.vrotate; +cp.v.pvrperp = cp.vrperp; +cp.v.slerp = cp.vslerp; +cp.v.slerpconst = cp.vslerpconst; +cp.v.sub = cp.vsub; +cp.v.toangle = cp.vtoangle; +cp.v.unrotate = cp.vunrotate; +cp.v.str = function(v){ + return "(" + v.x.toFixed(3) + ", " + v.y.toFixed(3) + ")"; +} + +// XXX: renaming functions should be supported in JSB +cp.clamp01 = cp.fclamp01; + + +/// Initialize an offset box shaped polygon shape. +cp.BoxShape2 = function(body, box) +{ + var verts = [ + box.l, box.b, + box.l, box.t, + box.r, box.t, + box.r, box.b + ]; + + return new cp.PolyShape(body, verts, cp.vzero); +}; + +/// Initialize a box shaped polygon shape. +cp.BoxShape = function(body, width, height) +{ + var hw = width/2; + var hh = height/2; + + return cp.BoxShape2(body, new cp.BB(-hw, -hh, hw, hh)); +}; + + +/// Initialize an static body +cp.StaticBody = function() +{ + return new cp.Body(Infinity, Infinity); +}; + + +// "Bounding Box" compatibility with Chipmunk-JS +cp.BB = function(l, b, r, t) +{ + this.l = l; + this.b = b; + this.r = r; + this.t = t; +}; + +// helper function to create a BB +cp.bb = function(l, b, r, t) { + return new cp.BB(l, b, r, t); +}; + +// +// Some properties +// +var _proto = cp.Base.prototype; +// "handle" needed in some cases +cc.defineGetterSetter(_proto, "handle", _proto.getHandle); + +// Properties, for Chipmunk-JS compatibility +// Space properties +Object.defineProperties(cp.Space.prototype, + { + "gravity" : { + get : function(){ + return this.getGravity(); + }, + set : function(newValue){ + this.setGravity(newValue); + }, + enumerable : true, + configurable : true + }, + "iterations" : { + get : function(){ + return this.getIterations(); + }, + set : function(newValue){ + this.setIterations(newValue); + }, + enumerable : true, + configurable : true + }, + "damping" : { + get : function(){ + return this.getDamping(); + }, + set : function(newValue){ + this.setDamping(newValue); + }, + enumerable : true, + configurable : true + }, + "staticBody" : { + get : function(){ + return this.getStaticBody(); + }, + enumerable : true, + configurable : true + }, + "idleSpeedThreshold" : { + get : function(){ + return this.getIdleSpeedThreshold(); + }, + set : function(newValue){ + this.setIdleSpeedThreshold(newValue); + }, + enumerable : true, + configurable : true + }, + "sleepTimeThreshold": { + get : function(){ + return this.getSleepTimeThreshold(); + }, + set : function(newValue){ + this.setSleepTimeThreshold(newValue); + }, + enumerable : true, + configurable : true + }, + "collisionSlop": { + get : function(){ + return this.getCollisionSlop(); + }, + set : function(newValue){ + this.setCollisionSlop(newValue); + }, + enumerable : true, + configurable : true + }, + "collisionBias": { + get : function(){ + return this.getCollisionBias(); + }, + set : function(newValue){ + this.setCollisionBias(newValue); + }, + enumerable : true, + configurable : true + }, + "collisionPersistence": { + get : function(){ + return this.getCollisionPersistence(); + }, + set : function(newValue){ + this.setCollisionPersistence(newValue); + }, + enumerable : true, + configurable : true + }, + "enableContactGraph": { + get : function(){ + return this.getEnableContactGraph(); + }, + set : function(newValue){ + this.setEnableContactGraph(newValue); + }, + enumerable : true, + configurable : true + } + }); + +// Body properties +_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; +cc.defineGetterSetter(_proto, "body", _proto.getBody, _proto.setBody); +cc.defineGetterSetter(_proto, "group", _proto.getGroup, _proto.setGroup); +cc.defineGetterSetter(_proto, "collision_type", _proto.getCollisionType, _proto.setCollisionType); +cc.defineGetterSetter(_proto, "layers", _proto.getLayers, _proto.setLayers); +cc.defineGetterSetter(_proto, "sensor", _proto.getSensor, _proto.setSensor); +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 +_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 +_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; diff --git a/cocos/scripting/js-bindings/script/chipmunk/jsb_chipmunk_constants.js b/cocos/scripting/js-bindings/script/chipmunk/jsb_chipmunk_constants.js new file mode 100644 index 0000000000..1aa9aa0d7b --- /dev/null +++ b/cocos/scripting/js-bindings/script/chipmunk/jsb_chipmunk_constants.js @@ -0,0 +1,22 @@ +/* +* AUTOGENERATED FILE. DO NOT EDIT IT +* Generated by "generate_jsb.py -c chipmunk_jsb.ini" on 2013-03-05 +* Script version: v0.6 +*/ + +var cp = cp || {}; +cp.ALLOW_PRIVATE_ACCESS = 0x1; +cp.ALL_LAYERS = 0xffffffff; +cp.BUFFER_BYTES = 0x8000; +cp.CIRCLE_SHAPE = 0x0; +cp.HASH_COEF = 0xc75f71e1; +cp.MAX_CONTACTS_PER_ARBITER = 0x4; +cp.NO_GROUP = 0x0; +cp.NUM_SHAPES = 0x3; +cp.POLY_SHAPE = 0x2; +cp.SEGMENT_SHAPE = 0x1; +cp.USE_CGPOINTS = 0x1; +cp.USE_DOUBLES = 0x0; +cp.VERSION_MAJOR = 0x6; +cp.VERSION_MINOR = 0x1; +cp.VERSION_RELEASE = 0x1; diff --git a/cocos/scripting/js-bindings/script/debugger/DevToolsUtils.js b/cocos/scripting/js-bindings/script/debugger/DevToolsUtils.js new file mode 100644 index 0000000000..c3649c569a --- /dev/null +++ b/cocos/scripting/js-bindings/script/debugger/DevToolsUtils.js @@ -0,0 +1,230 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +function utf16to8(str) { + var out, i, len, c; + + out = ""; + len = str.length; + for(i = 0; i < len; i++) + { + c = str.charCodeAt(i); + if ((c >= 0x0001) && (c <= 0x007F)) + { + out += str.charAt(i); + } + else if (c > 0x07FF) + { + out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F)); + out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F)); + out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); + } + else + { + out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F)); + out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); + } + } + return out; +} + +function utf8to16(str) { + var out, i, len, c; + var char2, char3; + + out = ""; + len = str.length; + i = 0; + while(i < len) { c = str.charCodeAt(i++); switch(c >> 4) + { + case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: + // 0xxxxxxx + out += str.charAt(i-1); + break; + case 12: case 13: + // 110x xxxx 10xx xxxx + char2 = str.charCodeAt(i++); + out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F)); + break; + case 14: + // 1110 xxxx 10xx xxxx 10xx xxxx + char2 = str.charCodeAt(i++); + char3 = str.charCodeAt(i++); + out += String.fromCharCode(((c & 0x0F) << 12) | + ((char2 & 0x3F) << 6) | + ((char3 & 0x3F) << 0)); + break; + } + } + + return out; + } + +var dump = function(msg) { + log(msg); +}; + +/* General utilities used throughout devtools. */ + +/** + * Turn the error |aError| into a string, without fail. + */ +this.safeErrorString = function safeErrorString(aError) { + try { + let errorString = aError.toString(); + if (typeof errorString === "string") { + // Attempt to attach a stack to |errorString|. If it throws an error, or + // isn't a string, don't use it. + try { + if (aError.stack) { + let stack = aError.stack.toString(); + if (typeof stack === "string") { + errorString += "\nStack: " + stack; + } + } + } catch (ee) { } + + return errorString; + } + } catch (ee) { } + + return ""; +} + + +/** + * Report that |aWho| threw an exception, |aException|. + */ +this.reportException = function reportException(aWho, aException) { + let msg = aWho + " threw an exception: " + safeErrorString(aException); + + dump(msg + "\n"); + + // if (Components.utils.reportError) { + // /* + // * Note that the xpcshell test harness registers an observer for + // * console messages, so when we're running tests, this will cause + // * the test to quit. + // */ + // Components.utils.reportError(msg); + // } +} + +/** + * Given a handler function that may throw, return an infallible handler + * function that calls the fallible handler, and logs any exceptions it + * throws. + * + * @param aHandler function + * A handler function, which may throw. + * @param aName string + * A name for aHandler, for use in error messages. If omitted, we use + * aHandler.name. + * + * (SpiderMonkey does generate good names for anonymous functions, but we + * don't have a way to get at them from JavaScript at the moment.) + */ +this.makeInfallible = function makeInfallible(aHandler, aName) { + if (!aName) + aName = aHandler.name; + + return function (/* arguments */) { + try { + return aHandler.apply(this, arguments); + } catch (ex) { + let who = "Handler function"; + if (aName) { + who += " " + aName; + } + reportException(who, ex); + } + } +} + +const executeSoon = aFn => { + Services.tm.mainThread.dispatch({ + run: this.makeInfallible(aFn) + }, Components.interfaces.nsIThread.DISPATCH_NORMAL); +} + +/** + * Like Array.prototype.forEach, but doesn't cause jankiness when iterating over + * very large arrays by yielding to the browser and continuing execution on the + * next tick. + * + * @param Array aArray + * The array being iterated over. + * @param Function aFn + * The function called on each item in the array. + * @returns Promise + * A promise that is resolved once the whole array has been iterated + * over. + */ +this.yieldingEach = function yieldingEach(aArray, aFn) { + const deferred = promise.defer(); + + let i = 0; + let len = aArray.length; + + (function loop() { + const start = Date.now(); + + while (i < len) { + // Don't block the main thread for longer than 16 ms at a time. To + // maintain 60fps, you have to render every frame in at least 16ms; we + // aren't including time spent in non-JS here, but this is Good + // Enough(tm). + if (Date.now() - start > 16) { + executeSoon(loop); + return; + } + + try { + aFn(aArray[i++]); + } catch (e) { + deferred.reject(e); + return; + } + } + + deferred.resolve(); + }()); + + return deferred.promise; +} + + +/** + * Like XPCOMUtils.defineLazyGetter, but with a |this| sensitive getter that + * allows the lazy getter to be defined on a prototype and work correctly with + * instances. + * + * @param Object aObject + * The prototype object to define the lazy getter on. + * @param String aKey + * The key to define the lazy getter on. + * @param Function aCallback + * The callback that will be called to determine the value. Will be + * called with the |this| value of the current instance. + */ +this.defineLazyPrototypeGetter = +function defineLazyPrototypeGetter(aObject, aKey, aCallback) { + Object.defineProperty(aObject, aKey, { + configurable: true, + get: function() { + const value = aCallback.call(this); + + Object.defineProperty(this, aKey, { + configurable: true, + writable: true, + value: value + }); + + return value; + } + }); +} + diff --git a/cocos/scripting/js-bindings/script/debugger/README.md b/cocos/scripting/js-bindings/script/debugger/README.md new file mode 100644 index 0000000000..9e1d7bebd0 --- /dev/null +++ b/cocos/scripting/js-bindings/script/debugger/README.md @@ -0,0 +1,54 @@ +Remote Debugging By Using FireFox +================================= + +Requirement +----------- + +* Firefox: From v24 + +How To Use +---------- + +### Prepare ### + +Please refer to https://developer.mozilla.org/en-US/docs/Tools/Remote_Debugging . + +### Enable Debugger Support For Your JSB Project ### + +``` +bool AppDelegate::applicationDidFinishLaunching() +{ + ... + + ScriptingCore* sc = ScriptingCore::getInstance(); + sc->addRegisterCallback(register_all_cocos2dx); + sc->addRegisterCallback(register_all_cocos2dx_extension); + sc->addRegisterCallback(register_cocos2dx_js_extensions); + sc->addRegisterCallback(jsb_register_chipmunk); + sc->addRegisterCallback(register_all_cocos2dx_extension_manual); + sc->addRegisterCallback(register_CCBuilderReader); + sc->addRegisterCallback(jsb_register_system); + sc->addRegisterCallback(JSB_register_opengl); + + sc->start(); + +#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) + sc->enableDebugger(); // Enable debugger here +#endif + + ... +} +``` + +Run your game. + +### Open Firefox And Follow The Step As Follows ### + + +![pic 1](https://lh5.googleusercontent.com/-HoxLGBdV2J0/UlZ7ZoFUjyI/AAAAAAAAADM/68GDaCQ1vP0/s0-I/Firefox-Remote-Debug01.jpg) +![pic 2](https://lh6.googleusercontent.com/-7FDIHAYsKAY/UlZ7Yf8W-pI/AAAAAAAAAFQ/joG0AymnuBk/s0-I/Firefox-Remote-Debug02.jpg) +![pic 3](https://lh4.googleusercontent.com/-idvnMRGcGy8/UlZ7Wj6DDuI/AAAAAAAAAC0/L9IVyHLNqeQ/s0-I/Firefox-Remote-Debug04.jpg) +![pic 4](https://lh6.googleusercontent.com/-YuZj7JGAtFE/UlZ9DDGDczI/AAAAAAAAAEQ/D2qIedjP5FU/s0-I/Firefox-Remote-Debug04.png.png) +![pic 5](https://lh3.googleusercontent.com/-cdIcNa3jT5c/UlZ9uapf3OI/AAAAAAAAAEg/MGq3vLHsauw/s0-I/Firefox-Remote-Debug05.png) +![pic 6](https://lh5.googleusercontent.com/-T79-o5ylJKI/UlZ_JJQe3MI/AAAAAAAAAE8/F63fSVxlJKs/s0-I/Firefox-Remote-Debug06.png) + diff --git a/cocos/scripting/js-bindings/script/debugger/actors/root.js b/cocos/scripting/js-bindings/script/debugger/actors/root.js new file mode 100644 index 0000000000..66b3814fd1 --- /dev/null +++ b/cocos/scripting/js-bindings/script/debugger/actors/root.js @@ -0,0 +1,385 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +/* Root actor for the remote debugging protocol. */ + +/** + * Methods shared between RootActor and BrowserTabActor. + */ + +/** + * Populate |this._extraActors| as specified by |aFactories|, reusing whatever + * actors are already there. Add all actors in the final extra actors table to + * |aPool|. + * + * The root actor and the tab actor use this to instantiate actors that other + * parts of the browser have specified with DebuggerServer.addTabActor antd + * DebuggerServer.addGlobalActor. + * + * @param aFactories + * An object whose own property names are the names of properties to add to + * some reply packet (say, a tab actor grip or the "listTabs" response + * form), and whose own property values are actor constructor functions, as + * documented for addTabActor and addGlobalActor. + * + * @param this + * The BrowserRootActor or BrowserTabActor with which the new actors will + * be associated. It should support whatever API the |aFactories| + * constructor functions might be interested in, as it is passed to them. + * For the sake of CommonCreateExtraActors itself, it should have at least + * the following properties: + * + * - _extraActors + * An object whose own property names are factory table (and packet) + * property names, and whose values are no-argument actor constructors, + * of the sort that one can add to an ActorPool. + * + * - conn + * The DebuggerServerConnection in which the new actors will participate. + * + * - actorID + * The actor's name, for use as the new actors' parentID. + */ +function CommonCreateExtraActors(aFactories, aPool) { + // Walk over global actors added by extensions. + for (let name in aFactories) { + let actor = this._extraActors[name]; + if (!actor) { + actor = aFactories[name].bind(null, this.conn, this); + actor.prototype = aFactories[name].prototype; + actor.parentID = this.actorID; + this._extraActors[name] = actor; + } + aPool.addActor(actor); + } +} + +/** + * Append the extra actors in |this._extraActors|, constructed by a prior call + * to CommonCreateExtraActors, to |aObject|. + * + * @param aObject + * The object to which the extra actors should be added, under the + * property names given in the |aFactories| table passed to + * CommonCreateExtraActors. + * + * @param this + * The BrowserRootActor or BrowserTabActor whose |_extraActors| table we + * should use; see above. + */ +function CommonAppendExtraActors(aObject) { + for (let name in this._extraActors) { + let actor = this._extraActors[name]; + aObject[name] = actor.actorID; + } +} + +/** + * Create a remote debugging protocol root actor. + * + * @param aConnection + * The DebuggerServerConnection whose root actor we are constructing. + * + * @param aParameters + * The properties of |aParameters| provide backing objects for the root + * actor's requests; if a given property is omitted from |aParameters|, the + * root actor won't implement the corresponding requests or notifications. + * Supported properties: + * + * - tabList: a live list (see below) of tab actors. If present, the + * new root actor supports the 'listTabs' request, providing the live + * list's elements as its tab actors, and sending 'tabListChanged' + * notifications when the live list's contents change. One actor in + * this list must have a true '.selected' property. + * + * - globalActorFactories: an object |A| describing further actors to + * attach to the 'listTabs' reply. This is the type accumulated by + * DebuggerServer.addGlobalActor. For each own property |P| of |A|, + * the root actor adds a property named |P| to the 'listTabs' + * reply whose value is the name of an actor constructed by + * |A[P]|. + * + * - onShutdown: a function to call when the root actor is disconnected. + * + * Instance properties: + * + * - applicationType: the string the root actor will include as the + * "applicationType" property in the greeting packet. By default, this + * is "browser". + * + * Live lists: + * + * A "live list", as used for the |tabList|, is an object that presents a + * list of actors, and also notifies its clients of changes to the list. A + * live list's interface is two properties: + * + * - iterator: a method that returns an iterator. A for-of loop will call + * this method to obtain an iterator for the loop, so if LL is + * a live list, one can simply write 'for (i of LL) ...'. + * + * - onListChanged: a handler called, with no arguments, when the set of + * values the iterator would produce has changed since the last + * time 'iterator' was called. This may only be set to null or a + * callable value (one for which the typeof operator returns + * 'function'). (Note that the live list will not call the + * onListChanged handler until the list has been iterated over + * once; if nobody's seen the list in the first place, nobody + * should care if its contents have changed!) + * + * When the list changes, the list implementation should ensure that any + * actors yielded in previous iterations whose referents (tabs) still exist + * get yielded again in subsequent iterations. If the underlying referent + * is the same, the same actor should be presented for it. + * + * The root actor registers an 'onListChanged' handler on the appropriate + * list when it may need to send the client 'tabListChanged' notifications, + * and is careful to remove the handler whenever it does not need to send + * such notifications (including when it is disconnected). This means that + * live list implementations can use the state of the handler property (set + * or null) to install and remove observers and event listeners. + * + * Note that, as the only way for the root actor to see the members of the + * live list is to begin an iteration over the list, the live list need not + * actually produce any actors until they are reached in the course of + * iteration: alliterative lazy live lists. + */ +function RootActor(aConnection, aParameters) { + this.conn = aConnection; + this._parameters = aParameters; + this._onTabListChanged = this.onTabListChanged.bind(this); + this._onAddonListChanged = this.onAddonListChanged.bind(this); + this._extraActors = {}; +} + +RootActor.prototype = { + constructor: RootActor, + applicationType: "browser", + + /** + * Return a 'hello' packet as specified by the Remote Debugging Protocol. + */ + sayHello: function() { + return { + from: this.actorID, + applicationType: this.applicationType, + /* This is not in the spec, but it's used by tests. */ + testConnectionPrefix: this.conn.prefix, + traits: { + sources: true, + editOuterHTML: true + } + }; + }, + + /** + * This is true for the root actor only, used by some child actors + */ + get isRootActor() true, + + /** + * The (chrome) window, for use by child actors + */ + get window() Services.wm.getMostRecentWindow(DebuggerServer.chromeWindowType), + + /** + * Disconnects the actor from the browser window. + */ + disconnect: function() { + /* Tell the live lists we aren't watching any more. */ + if (this._parameters.tabList) { + this._parameters.tabList.onListChanged = null; + } + if (this._parameters.addonList) { + this._parameters.addonList.onListChanged = null; + } + if (typeof this._parameters.onShutdown === 'function') { + this._parameters.onShutdown(); + } + this._extraActors = null; + }, + + /* The 'listTabs' request and the 'tabListChanged' notification. */ + + /** + * Handles the listTabs request. The actors will survive until at least + * the next listTabs request. + */ + onListTabs: function() { + let tabList = this._parameters.tabList; + if (!tabList) { + return { from: this.actorID, error: "noTabs", + message: "This root actor has no browser tabs." }; + } + + /* + * Walk the tab list, accumulating the array of tab actors for the + * reply, and moving all the actors to a new ActorPool. We'll + * replace the old tab actor pool with the one we build here, thus + * retiring any actors that didn't get listed again, and preparing any + * new actors to receive packets. + */ + let newActorPool = new ActorPool(this.conn); + let tabActorList = []; + let selected; + return tabList.getList().then((tabActors) => { + for (let tabActor of tabActors) { + if (tabActor.selected) { + selected = tabActorList.length; + } + tabActor.parentID = this.actorID; + newActorPool.addActor(tabActor); + tabActorList.push(tabActor); + } + + /* DebuggerServer.addGlobalActor support: create actors. */ + this._createExtraActors(this._parameters.globalActorFactories, newActorPool); + + /* + * Drop the old actorID -> actor map. Actors that still mattered were + * added to the new map; others will go away. + */ + if (this._tabActorPool) { + this.conn.removeActorPool(this._tabActorPool); + } + this._tabActorPool = newActorPool; + this.conn.addActorPool(this._tabActorPool); + + let reply = { + "from": this.actorID, + "selected": selected || 0, + "tabs": [actor.form() for (actor of tabActorList)], + }; + + /* DebuggerServer.addGlobalActor support: name actors in 'listTabs' reply. */ + this._appendExtraActors(reply); + + /* + * Now that we're actually going to report the contents of tabList to + * the client, we're responsible for letting the client know if it + * changes. + */ + tabList.onListChanged = this._onTabListChanged; + + return reply; + }); + }, + + onTabListChanged: function () { + this.conn.send({ from: this.actorID, type:"tabListChanged" }); + /* It's a one-shot notification; no need to watch any more. */ + this._parameters.tabList.onListChanged = null; + }, + + onListAddons: function () { + let addonList = this._parameters.addonList; + if (!addonList) { + return { from: this.actorID, error: "noAddons", + message: "This root actor has no browser addons." }; + } + + return addonList.getList().then((addonActors) => { + let addonActorPool = new ActorPool(this.conn); + for (let addonActor of addonActors) { + addonActorPool.addActor(addonActor); + } + + if (this._addonActorPool) { + this.conn.removeActorPool(this._addonActorPool); + } + this._addonActorPool = addonActorPool; + this.conn.addActorPool(this._addonActorPool); + + addonList.onListChanged = this._onAddonListChanged; + + return { + "from": this.actorID, + "addons": [addonActor.form() for (addonActor of addonActors)] + }; + }); + }, + + onAddonListChanged: function () { + this.conn.send({ from: this.actorID, type: "addonListChanged" }); + this._parameters.addonList.onListChanged = null; + }, + + /* This is not in the spec, but it's used by tests. */ + onEcho: function (aRequest) { + /* + * Request packets are frozen. Copy aRequest, so that + * DebuggerServerConnection.onPacket can attach a 'from' property. + */ + return JSON.parse(JSON.stringify(aRequest)); + }, + + /* Support for DebuggerServer.addGlobalActor. */ + _createExtraActors: CommonCreateExtraActors, + _appendExtraActors: CommonAppendExtraActors, + + /* ThreadActor hooks. */ + + /** + * Prepare to enter a nested event loop by disabling debuggee events. + */ + preNest: function() { + // Disable events in all open windows. + let e = windowMediator.getEnumerator(null); + while (e.hasMoreElements()) { + let win = e.getNext(); + let windowUtils = win.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIDOMWindowUtils); + windowUtils.suppressEventHandling(true); + windowUtils.suspendTimeouts(); + } + }, + + /** + * Prepare to exit a nested event loop by enabling debuggee events. + */ + postNest: function(aNestData) { + // Enable events in all open windows. + let e = windowMediator.getEnumerator(null); + while (e.hasMoreElements()) { + let win = e.getNext(); + let windowUtils = win.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIDOMWindowUtils); + windowUtils.resumeTimeouts(); + windowUtils.suppressEventHandling(false); + } + }, + + /* ChromeDebuggerActor hooks. */ + + /** + * Add the specified actor to the default actor pool connection, in order to + * keep it alive as long as the server is. This is used by breakpoints in the + * thread and chrome debugger actors. + * + * @param actor aActor + * The actor object. + */ + addToParentPool: function(aActor) { + this.conn.addActor(aActor); + }, + + /** + * Remove the specified actor from the default actor pool. + * + * @param BreakpointActor aActor + * The actor object. + */ + removeFromParentPool: function(aActor) { + this.conn.removeActor(aActor); + } +} + +RootActor.prototype.requestTypes = { + "listTabs": RootActor.prototype.onListTabs, + "listAddons": RootActor.prototype.onListAddons, + "echo": RootActor.prototype.onEcho +}; diff --git a/cocos/scripting/js-bindings/script/debugger/actors/script.js b/cocos/scripting/js-bindings/script/debugger/actors/script.js new file mode 100644 index 0000000000..853fc1ce7a --- /dev/null +++ b/cocos/scripting/js-bindings/script/debugger/actors/script.js @@ -0,0 +1,4382 @@ +/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; js-indent-level: 2; -*- */ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +/** + * BreakpointStore objects keep track of all breakpoints that get set so that we + * can reset them when the same script is introduced to the thread again (such + * as after a refresh). + */ +function BreakpointStore() { + // If we have a whole-line breakpoint set at LINE in URL, then + // + // this._wholeLineBreakpoints[URL][LINE] + // + // is an object + // + // { url, line[, actor] } + // + // where the `actor` property is optional. + this._wholeLineBreakpoints = Object.create(null); + + // If we have a breakpoint set at LINE, COLUMN in URL, then + // + // this._breakpoints[URL][LINE][COLUMN] + // + // is an object + // + // { url, line[, actor] } + // + // where the `actor` property is optional. + this._breakpoints = Object.create(null); +} + +BreakpointStore.prototype = { + + /** + * Add a breakpoint to the breakpoint store. + * + * @param Object aBreakpoint + * The breakpoint to be added (not copied). It is an object with the + * following properties: + * - url + * - line + * - column (optional; omission implies that the breakpoint is for + * the whole line) + * - actor (optional) + */ + addBreakpoint: function BS_addBreakpoint(aBreakpoint) { + let { url, line, column } = aBreakpoint; + + if (column != null) { + if (!this._breakpoints[url]) { + this._breakpoints[url] = []; + } + if (!this._breakpoints[url][line]) { + this._breakpoints[url][line] = []; + } + this._breakpoints[url][line][column] = aBreakpoint; + } else { + // Add a breakpoint that breaks on the whole line. + if (!this._wholeLineBreakpoints[url]) { + this._wholeLineBreakpoints[url] = []; + } + this._wholeLineBreakpoints[url][line] = aBreakpoint; + } + }, + + /** + * Remove a breakpoint from the breakpoint store. + * + * @param Object aBreakpoint + * The breakpoint to be removed. It is an object with the following + * properties: + * - url + * - line + * - column (optional) + */ + removeBreakpoint: function BS_removeBreakpoint({ url, line, column }) { + if (column != null) { + if (this._breakpoints[url]) { + if (this._breakpoints[url][line]) { + delete this._breakpoints[url][line][column]; + + // If this was the last breakpoint on this line, delete the line from + // `this._breakpoints[url]` as well. Otherwise `_iterLines` will yield + // this line even though we no longer have breakpoints on + // it. Furthermore, we use Object.keys() instead of just checking + // `this._breakpoints[url].length` directly, because deleting + // properties from sparse arrays doesn't update the `length` property + // like adding them does. + if (Object.keys(this._breakpoints[url][line]).length === 0) { + delete this._breakpoints[url][line]; + } + } + } + } else { + if (this._wholeLineBreakpoints[url]) { + delete this._wholeLineBreakpoints[url][line]; + } + } + }, + + /** + * Get a breakpoint from the breakpoint store. Will throw an error if the + * breakpoint is not found. + * + * @param Object aLocation + * The location of the breakpoint you are retrieving. It is an object + * with the following properties: + * - url + * - line + * - column (optional) + */ + getBreakpoint: function BS_getBreakpoint(aLocation) { + let { url, line, column } = aLocation; + dbg_assert(url != null); + dbg_assert(line != null); + + var foundBreakpoint = this.hasBreakpoint(aLocation); + if (foundBreakpoint == null) { + throw new Error("No breakpoint at url = " + url + + ", line = " + line + + ", column = " + column); + } + + return foundBreakpoint; + }, + + /** + * Checks if the breakpoint store has a requested breakpoint. + * + * @param Object aLocation + * The location of the breakpoint you are retrieving. It is an object + * with the following properties: + * - url + * - line + * - column (optional) + * @returns The stored breakpoint if it exists, null otherwise. + */ + hasBreakpoint: function BS_hasBreakpoint(aLocation) { + let { url, line, column } = aLocation; + dbg_assert(url != null); + dbg_assert(line != null); + for (let bp of this.findBreakpoints(aLocation)) { + // We will get whole line breakpoints before individual columns, so just + // return the first one and if they didn't specify a column then they will + // get the whole line breakpoint, and otherwise we will find the correct + // one. + return bp; + } + + return null; + }, + + /** + * Iterate over the breakpoints in this breakpoint store. You can optionally + * provide search parameters to filter the set of breakpoints down to those + * that match your parameters. + * + * @param Object aSearchParams + * Optional. An object with the following properties: + * - url + * - line (optional; requires the url property) + * - column (optional; requires the line property) + */ + findBreakpoints: function BS_findBreakpoints(aSearchParams={}) { + if (aSearchParams.column != null) { + dbg_assert(aSearchParams.line != null); + } + if (aSearchParams.line != null) { + dbg_assert(aSearchParams.url != null); + } + + for (let url of this._iterUrls(aSearchParams.url)) { + for (let line of this._iterLines(url, aSearchParams.line)) { + // Always yield whole line breakpoints first. See comment in + // |BreakpointStore.prototype.hasBreakpoint|. + if (aSearchParams.column == null + && this._wholeLineBreakpoints[url] + && this._wholeLineBreakpoints[url][line]) { + yield this._wholeLineBreakpoints[url][line]; + } + for (let column of this._iterColumns(url, line, aSearchParams.column)) { + yield this._breakpoints[url][line][column]; + } + } + } + }, + + _iterUrls: function BS__iterUrls(aUrl) { + if (aUrl) { + if (this._breakpoints[aUrl] || this._wholeLineBreakpoints[aUrl]) { + yield aUrl; + } + } else { + for (let url of Object.keys(this._wholeLineBreakpoints)) { + yield url; + } + for (let url of Object.keys(this._breakpoints)) { + if (url in this._wholeLineBreakpoints) { + continue; + } + yield url; + } + } + }, + + _iterLines: function BS__iterLines(aUrl, aLine) { + if (aLine != null) { + if ((this._wholeLineBreakpoints[aUrl] + && this._wholeLineBreakpoints[aUrl][aLine]) + || (this._breakpoints[aUrl] && this._breakpoints[aUrl][aLine])) { + yield aLine; + } + } else { + const wholeLines = this._wholeLineBreakpoints[aUrl] + ? Object.keys(this._wholeLineBreakpoints[aUrl]) + : []; + const columnLines = this._breakpoints[aUrl] + ? Object.keys(this._breakpoints[aUrl]) + : []; + + const lines = wholeLines.concat(columnLines).sort(); + + let lastLine; + for (let line of lines) { + if (line === lastLine) { + continue; + } + yield line; + lastLine = line; + } + } + }, + + _iterColumns: function BS__iterColumns(aUrl, aLine, aColumn) { + if (!this._breakpoints[aUrl] || !this._breakpoints[aUrl][aLine]) { + return; + } + + if (aColumn != null) { + if (this._breakpoints[aUrl][aLine][aColumn]) { + yield aColumn; + } + } else { + for (let column in this._breakpoints[aUrl][aLine]) { + yield column; + } + } + }, +}; + +/** + * Manages pushing event loops and automatically pops and exits them in the + * correct order as they are resolved. + * + * @param nsIJSInspector inspector + * The underlying JS inspector we use to enter and exit nested event + * loops. + * @param Object hooks + * An object with the following properties: + * - url: The URL string of the debuggee we are spinning an event loop + * for. + * - preNest: function called before entering a nested event loop + * - postNest: function called after exiting a nested event loop + * @param ThreadActor thread + * The thread actor instance that owns this EventLoopStack. + */ +function EventLoopStack({ inspector, thread, hooks }) { + this._inspector = inspector; + this._hooks = hooks; + this._thread = thread; +} + +EventLoopStack.prototype = { + /** + * The number of nested event loops on the stack. + */ + get size() { + return this._inspector.eventLoopNestLevel(); + }, + + /** + * The URL of the debuggee who pushed the event loop on top of the stack. + */ + get lastPausedUrl() { + let url = null; + if (this.size > 0) { + try { + url = this._inspector.lastNestRequestor.url + } catch (e) { + // The tab's URL getter may throw if the tab is destroyed by the time + // this code runs, but we don't really care at this point. + dumpn(e); + } + } + return url; + }, + + /** + * Push a new nested event loop onto the stack. + * + * @returns EventLoop + */ + push: function () { + return new EventLoop({ + inspector: this._inspector, + thread: this._thread, + hooks: this._hooks + }); + } +}; + +/** + * An object that represents a nested event loop. It is used as the nest + * requestor with nsIJSInspector instances. + * + * @param nsIJSInspector inspector + * The JS Inspector that runs nested event loops. + * @param ThreadActor thread + * The thread actor that is creating this nested event loop. + * @param Object hooks + * The same hooks object passed into EventLoopStack during its + * initialization. + */ +function EventLoop({ inspector, thread, hooks }) { + this._inspector = inspector; + this._thread = thread; + this._hooks = hooks; + + this.enter = this.enter.bind(this); + this.resolve = this.resolve.bind(this); +} + +EventLoop.prototype = { + entered: false, + resolved: false, + get url() { return this._hooks.url; }, + + /** + * Enter this nested event loop. + */ + enter: function () { + let nestData = this._hooks.preNest + ? this._hooks.preNest() + : null; + + this.entered = true; + this._inspector.enterNestedEventLoop(this); + + // Keep exiting nested event loops while the last requestor is resolved. + // James commented. + // if (this._inspector.eventLoopNestLevel() > 0) { + // const { resolved } = this._inspector.lastNestRequestor; + // if (resolved) { + // this._inspector.exitNestedEventLoop(); + // } + // } + + dbg_assert(this._thread.state === "running", + "Should be in the running state"); + + if (this._hooks.postNest) { + this._hooks.postNest(nestData); + } + }, + + /** + * Resolve this nested event loop. + * + * @returns boolean + * True if we exited this nested event loop because it was on top of + * the stack, false if there is another nested event loop above this + * one that hasn't resolved yet. + */ + resolve: function () { + if (!this.entered) { + throw new Error("Can't resolve an event loop before it has been entered!"); + } + if (this.resolved) { + throw new Error("Already resolved this nested event loop!"); + } + this.resolved = true; + // James commented. if (this === this._inspector.lastNestRequestor) + { + this._inspector.exitNestedEventLoop(); + return true; + } + return false; + }, +}; + +/** + * JSD2 actors. + */ +/** + * Creates a ThreadActor. + * + * ThreadActors manage a JSInspector object and manage execution/inspection + * of debuggees. + * + * @param aHooks object + * An object with preNest and postNest methods for calling when entering + * and exiting a nested event loop, addToParentPool and + * removeFromParentPool methods for handling the lifetime of actors that + * will outlive the thread, like breakpoints. + * @param aGlobal object [optional] + * An optional (for content debugging only) reference to the content + * window. + */ +function ThreadActor(aHooks, aGlobal) +{ + this._state = "detached"; + this._frameActors = []; + this._hooks = aHooks; + this.global = aGlobal; + this._nestedEventLoops = new EventLoopStack({ + inspector: DebuggerServer.xpcInspector, + hooks: aHooks, + thread: this + }); + // A map of actorID -> actor for breakpoints created and managed by the server. + this._hiddenBreakpoints = new Map(); + + this.findGlobals = this.globalManager.findGlobals.bind(this); + this.onNewGlobal = this.globalManager.onNewGlobal.bind(this); + this.onNewSource = this.onNewSource.bind(this); + this._allEventsListener = this._allEventsListener.bind(this); + + this._options = { + useSourceMaps: false + }; +} + +/** + * The breakpoint store must be shared across instances of ThreadActor so that + * page reloads don't blow away all of our breakpoints. + */ +ThreadActor.breakpointStore = new BreakpointStore(); + +ThreadActor.prototype = { + actorPrefix: "context", + + get state() { return this._state; }, + get attached() this.state == "attached" || + this.state == "running" || + this.state == "paused", + + get breakpointStore() { return ThreadActor.breakpointStore; }, + + get threadLifetimePool() { + if (!this._threadLifetimePool) { + this._threadLifetimePool = new ActorPool(this.conn); + this.conn.addActorPool(this._threadLifetimePool); + this._threadLifetimePool.objectActors = new WeakMap(); + } + return this._threadLifetimePool; + }, + + get sources() { + if (!this._sources) { + this._sources = new ThreadSources(this, this._options.useSourceMaps, + this._allowSource, this.onNewSource); + } + return this._sources; + }, + + get youngestFrame() { + if (!this.state == "paused") { + return null; + } + return this.dbg.getNewestFrame(); + }, + + _prettyPrintWorker: null, + get prettyPrintWorker() { + if (!this._prettyPrintWorker) { + this._prettyPrintWorker = new ChromeWorker( + "resource://gre/modules/devtools/server/actors/pretty-print-worker.js"); + + this._prettyPrintWorker.addEventListener( + "error", this._onPrettyPrintError, false); + + if (wantLogging) { + this._prettyPrintWorker.addEventListener("message", this._onPrettyPrintMsg, false); + + const postMsg = this._prettyPrintWorker.postMessage; + this._prettyPrintWorker.postMessage = data => { + dumpn("Sending message to prettyPrintWorker: " + + JSON.stringify(data, null, 2) + "\n"); + return postMsg.call(this._prettyPrintWorker, data); + }; + } + } + return this._prettyPrintWorker; + }, + + _onPrettyPrintError: function ({ message, filename, lineno }) { + reportError(new Error(message + " @ " + filename + ":" + lineno)); + }, + + _onPrettyPrintMsg: function ({ data }) { + dumpn("Received message from prettyPrintWorker: " + + JSON.stringify(data, null, 2) + "\n"); + }, + + /** + * Keep track of all of the nested event loops we use to pause the debuggee + * when we hit a breakpoint/debugger statement/etc in one place so we can + * resolve them when we get resume packets. We have more than one (and keep + * them in a stack) because we can pause within client evals. + */ + _threadPauseEventLoops: null, + _pushThreadPause: function TA__pushThreadPause() { + if (!this._threadPauseEventLoops) { + this._threadPauseEventLoops = []; + } + const eventLoop = this._nestedEventLoops.push(); + this._threadPauseEventLoops.push(eventLoop); + eventLoop.enter(); + }, + _popThreadPause: function TA__popThreadPause() { + const eventLoop = this._threadPauseEventLoops.pop(); + dbg_assert(eventLoop, "Should have an event loop."); + eventLoop.resolve(); + }, + + clearDebuggees: function TA_clearDebuggees() { + if (this.dbg) { + this.dbg.removeAllDebuggees(); + } + this.conn.removeActorPool(this._threadLifetimePool || undefined); + this._threadLifetimePool = null; + this._sources = null; + }, + + /** + * Add a debuggee global to the Debugger object. + * + * @returns the Debugger.Object that corresponds to the global. + */ + addDebuggee: function TA_addDebuggee(aGlobal) { + let globalDebugObject; + try { + globalDebugObject = this.dbg.addDebuggee(aGlobal); + } catch (e) { + // Ignore attempts to add the debugger's compartment as a debuggee. + dumpn("Ignoring request to add the debugger's compartment as a debuggee"); + } + return globalDebugObject; + }, + + /** + * Initialize the Debugger. + */ + _initDebugger: function TA__initDebugger() { + this.dbg = new Debugger(); + this.dbg.uncaughtExceptionHook = this.uncaughtExceptionHook.bind(this); + this.dbg.onDebuggerStatement = this.onDebuggerStatement.bind(this); + this.dbg.onNewScript = this.onNewScript.bind(this); + this.dbg.onNewGlobalObject = this.globalManager.onNewGlobal.bind(this); + // Keep the debugger disabled until a client attaches. + this.dbg.enabled = this._state != "detached"; + }, + + /** + * Remove a debuggee global from the JSInspector. + */ + removeDebugee: function TA_removeDebuggee(aGlobal) { + try { + this.dbg.removeDebuggee(aGlobal); + } catch(ex) { + // XXX: This debuggee has code currently executing on the stack, + // we need to save this for later. + } + }, + + /** + * Add the provided window and all windows in its frame tree as debuggees. + * + * @returns the Debugger.Object that corresponds to the window. + */ + _addDebuggees: function TA__addDebuggees(aWindow) { + let globalDebugObject = this.addDebuggee(aWindow); + let frames = aWindow.frames; + if (frames) { + for (let i = 0; i < frames.length; i++) { + this._addDebuggees(frames[i]); + } + } + return globalDebugObject; + }, + + /** + * An object that will be used by ThreadActors to tailor their behavior + * depending on the debugging context being required (chrome or content). + */ + globalManager: { + findGlobals: function TA_findGlobals() { + this.globalDebugObject = this._addDebuggees(this.global); + }, + + /** + * A function that the engine calls when a new global object has been + * created. + * + * @param aGlobal Debugger.Object + * The new global object that was created. + */ + onNewGlobal: function TA_onNewGlobal(aGlobal) { + // Content debugging only cares about new globals in the contant window, + // like iframe children. + if (aGlobal.hostAnnotations && + aGlobal.hostAnnotations.type == "document" && + aGlobal.hostAnnotations.element === this.global) { + this.addDebuggee(aGlobal); + // Notify the client. + this.conn.send({ + from: this.actorID, + type: "newGlobal", + // TODO: after bug 801084 lands see if we need to JSONify this. + hostAnnotations: aGlobal.hostAnnotations + }); + } + } + }, + + disconnect: function TA_disconnect() { + dumpn("in ThreadActor.prototype.disconnect"); + if (this._state == "paused") { + this.onResume(); + } + + this._state = "exited"; + + this.clearDebuggees(); + + if (this._prettyPrintWorker) { + this._prettyPrintWorker.removeEventListener( + "error", this._onPrettyPrintError, false); + this._prettyPrintWorker.removeEventListener( + "message", this._onPrettyPrintMsg, false); + this._prettyPrintWorker.terminate(); + this._prettyPrintWorker = null; + } + + if (!this.dbg) { + return; + } + this.dbg.enabled = false; + this.dbg = null; + }, + + /** + * Disconnect the debugger and put the actor in the exited state. + */ + exit: function TA_exit() { + this.disconnect(); + }, + + // Request handlers + onAttach: function TA_onAttach(aRequest) { + if (this.state === "exited") { + return { type: "exited" }; + } + + if (this.state !== "detached") { + return { error: "wrongState" }; + } + + this._state = "attached"; + + update(this._options, aRequest.options || {}); + + if (!this.dbg) { + this._initDebugger(); + } + this.findGlobals(); + this.dbg.enabled = true; + try { + // Put ourselves in the paused state. + let packet = this._paused(); + if (!packet) { + return { error: "notAttached" }; + } + packet.why = { type: "attached" }; + + this._restoreBreakpoints(); + + // Send the response to the attach request now (rather than + // returning it), because we're going to start a nested event loop + // here. + this.conn.send(packet); + + // Start a nested event loop. + this._pushThreadPause(); + + // We already sent a response to this request, don't send one + // now. + return null; + } catch (e) { + reportError(e); + return { error: "notAttached", message: e.toString() }; + } + }, + + onDetach: function TA_onDetach(aRequest) { + this.disconnect(); + dumpn("ThreadActor.prototype.onDetach: returning 'detached' packet"); + return { + type: "detached" + }; + }, + + onReconfigure: function TA_onReconfigure(aRequest) { + if (this.state == "exited") { + return { error: "wrongState" }; + } + + update(this._options, aRequest.options || {}); + // Clear existing sources, so they can be recreated on next access. + this._sources = null; + + return {}; + }, + + /** + * Pause the debuggee, by entering a nested event loop, and return a 'paused' + * packet to the client. + * + * @param Debugger.Frame aFrame + * The newest debuggee frame in the stack. + * @param object aReason + * An object with a 'type' property containing the reason for the pause. + * @param function onPacket + * Hook to modify the packet before it is sent. Feel free to return a + * promise. + */ + _pauseAndRespond: function TA__pauseAndRespond(aFrame, aReason, + onPacket=function (k) { return k; }) { + try { + let packet = this._paused(aFrame); + if (!packet) { + return undefined; + } + packet.why = aReason; + + this.sources.getOriginalLocation(packet.frame.where).then(aOrigPosition => { + packet.frame.where = aOrigPosition; + resolve(onPacket(packet)) + .then(null, error => { + reportError(error); + return { + error: "unknownError", + message: error.message + "\n" + error.stack + }; + }) + .then(packet => { + this.conn.send(packet); + }); + }); + + this._pushThreadPause(); + } catch(e) { + reportError(e, "Got an exception during TA__pauseAndRespond: "); + } + + return undefined; + }, + + /** + * Handle resume requests that include a forceCompletion request. + * + * @param Object aRequest + * The request packet received over the RDP. + * @returns A response packet. + */ + _forceCompletion: function TA__forceCompletion(aRequest) { + // TODO: remove this when Debugger.Frame.prototype.pop is implemented in + // bug 736733. + return { + error: "notImplemented", + message: "forced completion is not yet implemented." + }; + }, + + _makeOnEnterFrame: function TA__makeOnEnterFrame({ pauseAndRespond }) { + return aFrame => { + const generatedLocation = getFrameLocation(aFrame); + let { url } = this.synchronize(this.sources.getOriginalLocation( + generatedLocation)); + + return this.sources.isBlackBoxed(url) + ? undefined + : pauseAndRespond(aFrame); + }; + }, + + _makeOnPop: function TA__makeOnPop({ thread, pauseAndRespond, createValueGrip }) { + return function (aCompletion) { + // onPop is called with 'this' set to the current frame. + + const generatedLocation = getFrameLocation(this); + const { url } = thread.synchronize(thread.sources.getOriginalLocation( + generatedLocation)); + + if (thread.sources.isBlackBoxed(url)) { + return undefined; + } + + // Note that we're popping this frame; we need to watch for + // subsequent step events on its caller. + this.reportedPop = true; + + return pauseAndRespond(this, aPacket => { + aPacket.why.frameFinished = {}; + if (!aCompletion) { + aPacket.why.frameFinished.terminated = true; + } else if (aCompletion.hasOwnProperty("return")) { + aPacket.why.frameFinished.return = createValueGrip(aCompletion.return); + } else if (aCompletion.hasOwnProperty("yield")) { + aPacket.why.frameFinished.return = createValueGrip(aCompletion.yield); + } else { + aPacket.why.frameFinished.throw = createValueGrip(aCompletion.throw); + } + return aPacket; + }); + }; + }, + + _makeOnStep: function TA__makeOnStep({ thread, pauseAndRespond, startFrame, + startLocation }) { + return function () { + // onStep is called with 'this' set to the current frame. + + const generatedLocation = getFrameLocation(this); + const newLocation = thread.synchronize(thread.sources.getOriginalLocation( + generatedLocation)); + + // Cases when we should pause because we have executed enough to consider + // a "step" to have occured: + // + // 1.1. We change frames. + // 1.2. We change URLs (can happen without changing frames thanks to + // source mapping). + // 1.3. We change lines. + // + // Cases when we should always continue execution, even if one of the + // above cases is true: + // + // 2.1. We are in a source mapped region, but inside a null mapping + // (doesn't correlate to any region of original source) + // 2.2. The source we are in is black boxed. + + // Cases 2.1 and 2.2 + if (newLocation.url == null + || thread.sources.isBlackBoxed(newLocation.url)) { + return undefined; + } + + // Cases 1.1, 1.2 and 1.3 + if (this !== startFrame + || startLocation.url !== newLocation.url + || startLocation.line !== newLocation.line) { + return pauseAndRespond(this); + } + + // Otherwise, let execution continue (we haven't executed enough code to + // consider this a "step" yet). + return undefined; + }; + }, + + /** + * Define the JS hook functions for stepping. + */ + _makeSteppingHooks: function TA__makeSteppingHooks(aStartLocation) { + // Bind these methods and state because some of the hooks are called + // with 'this' set to the current frame. Rather than repeating the + // binding in each _makeOnX method, just do it once here and pass it + // in to each function. + const steppingHookState = { + pauseAndRespond: (aFrame, onPacket=(k)=>k) => { + this._pauseAndRespond(aFrame, { type: "resumeLimit" }, onPacket); + }, + createValueGrip: this.createValueGrip.bind(this), + thread: this, + startFrame: this.youngestFrame, + startLocation: aStartLocation + }; + + return { + onEnterFrame: this._makeOnEnterFrame(steppingHookState), + onPop: this._makeOnPop(steppingHookState), + onStep: this._makeOnStep(steppingHookState) + }; + }, + + /** + * Handle attaching the various stepping hooks we need to attach when we + * receive a resume request with a resumeLimit property. + * + * @param Object aRequest + * The request packet received over the RDP. + * @returns A promise that resolves to true once the hooks are attached, or is + * rejected with an error packet. + */ + _handleResumeLimit: function TA__handleResumeLimit(aRequest) { + let steppingType = aRequest.resumeLimit.type; + if (["step", "next", "finish"].indexOf(steppingType) == -1) { + return reject({ error: "badParameterType", + message: "Unknown resumeLimit type" }); + } + + const generatedLocation = getFrameLocation(this.youngestFrame); + return this.sources.getOriginalLocation(generatedLocation) + .then(originalLocation => { + const { onEnterFrame, onPop, onStep } = this._makeSteppingHooks(originalLocation); + + // Make sure there is still a frame on the stack if we are to continue + // stepping. + let stepFrame = this._getNextStepFrame(this.youngestFrame); + if (stepFrame) { + switch (steppingType) { + case "step": + this.dbg.onEnterFrame = onEnterFrame; + // Fall through. + case "next": + if (stepFrame.script) { + stepFrame.onStep = onStep; + } + stepFrame.onPop = onPop; + break; + case "finish": + stepFrame.onPop = onPop; + } + } + + return true; + }); + }, + + /** + * Clear the onStep and onPop hooks from the given frame and all of the frames + * below it. + * + * @param Debugger.Frame aFrame + * The frame we want to clear the stepping hooks from. + */ + _clearSteppingHooks: function TA__clearSteppingHooks(aFrame) { + while (aFrame) { + aFrame.onStep = undefined; + aFrame.onPop = undefined; + aFrame = aFrame.older; + } + }, + + /** + * Listen to the debuggee's DOM events if we received a request to do so. + * + * @param Object aRequest + * The resume request packet received over the RDP. + */ + _maybeListenToEvents: function TA__maybeListenToEvents(aRequest) { + // Break-on-DOMEvents is only supported in content debugging. + let events = aRequest.pauseOnDOMEvents; + if (this.global && events && + (events == "*" || + (Array.isArray(events) && events.length))) { + this._pauseOnDOMEvents = events; + let els = Cc["@mozilla.org/eventlistenerservice;1"] + .getService(Ci.nsIEventListenerService); + els.addListenerForAllEvents(this.global, this._allEventsListener, true); + } + }, + + /** + * Handle a protocol request to resume execution of the debuggee. + */ + onResume: function TA_onResume(aRequest) { + if (this._state !== "paused") { + return { + error: "wrongState", + message: "Can't resume when debuggee isn't paused. Current state is '" + + this._state + "'" + }; + } + + // In case of multiple nested event loops (due to multiple debuggers open in + // different tabs or multiple debugger clients connected to the same tab) + // only allow resumption in a LIFO order. + // James commented + // if (this._nestedEventLoops.size && this._nestedEventLoops.lastPausedUrl + // && this._nestedEventLoops.lastPausedUrl !== this._hooks.url) { + // return { + // error: "wrongOrder", + // message: "trying to resume in the wrong order.", + // lastPausedUrl: this._nestedEventLoops.lastPausedUrl + // }; + // } + + if (aRequest && aRequest.forceCompletion) { + return this._forceCompletion(aRequest); + } + + let resumeLimitHandled; + if (aRequest && aRequest.resumeLimit) { + resumeLimitHandled = this._handleResumeLimit(aRequest) + } else { + this._clearSteppingHooks(this.youngestFrame); + resumeLimitHandled = resolve(true); + } + + return resumeLimitHandled.then(() => { + if (aRequest) { + this._options.pauseOnExceptions = aRequest.pauseOnExceptions; + this._options.ignoreCaughtExceptions = aRequest.ignoreCaughtExceptions; + this.maybePauseOnExceptions(); + this._maybeListenToEvents(aRequest); + } + + let packet = this._resumed(); + this._popThreadPause(); + return packet; + }, error => { + return error instanceof Error + ? { error: "unknownError", + message: safeErrorString(error) } + // It is a known error, and the promise was rejected with an error + // packet. + : error; + }); + }, + + /** + * Spin up a nested event loop so we can synchronously resolve a promise. + * + * @param aPromise + * The promise we want to resolve. + * @returns The promise's resolution. + */ + synchronize: function(aPromise) { + let needNest = true; + let eventLoop; + let returnVal; + + aPromise + .then((aResolvedVal) => { + needNest = false; + returnVal = aResolvedVal; + }) + .then(null, (aError) => { + reportError(aError, "Error inside synchronize:"); + }) + .then(() => { + if (eventLoop) { + eventLoop.resolve(); + } + }); + + if (needNest) { + eventLoop = this._nestedEventLoops.push(); + eventLoop.enter(); + } + + return returnVal; + }, + + /** + * Set the debugging hook to pause on exceptions if configured to do so. + */ + maybePauseOnExceptions: function() { + if (this._options.pauseOnExceptions) { + this.dbg.onExceptionUnwind = this.onExceptionUnwind.bind(this); + } + }, + + /** + * A listener that gets called for every event fired on the page, when a list + * of interesting events was provided with the pauseOnDOMEvents property. It + * is used to set server-managed breakpoints on any existing event listeners + * for those events. + * + * @param Event event + * The event that was fired. + */ + _allEventsListener: function(event) { + if (this._pauseOnDOMEvents == "*" || + this._pauseOnDOMEvents.indexOf(event.type) != -1) { + for (let listener of this._getAllEventListeners(event.target)) { + if (event.type == listener.type || this._pauseOnDOMEvents == "*") { + this._breakOnEnter(listener.script); + } + } + } + }, + + /** + * Return an array containing all the event listeners attached to the + * specified event target and its ancestors in the event target chain. + * + * @param EventTarget eventTarget + * The target the event was dispatched on. + * @returns Array + */ + _getAllEventListeners: function(eventTarget) { + let els = Cc["@mozilla.org/eventlistenerservice;1"] + .getService(Ci.nsIEventListenerService); + + let targets = els.getEventTargetChainFor(eventTarget); + let listeners = []; + + for (let target of targets) { + let handlers = els.getListenerInfoFor(target); + for (let handler of handlers) { + // Null is returned for all-events handlers, and native event listeners + // don't provide any listenerObject, which makes them not that useful to + // a JS debugger. + if (!handler || !handler.listenerObject || !handler.type) + continue; + // Create a listener-like object suitable for our purposes. + let l = Object.create(null); + l.type = handler.type; + let listener = handler.listenerObject; + l.script = this.globalDebugObject.makeDebuggeeValue(listener).script; + // Chrome listeners won't be converted to debuggee values, since their + // compartment is not added as a debuggee. + if (!l.script) + continue; + listeners.push(l); + } + } + return listeners; + }, + + /** + * Set a breakpoint on the first bytecode offset in the provided script. + */ + _breakOnEnter: function(script) { + let offsets = script.getAllOffsets(); + for (let line = 0, n = offsets.length; line < n; line++) { + if (offsets[line]) { + let location = { url: script.url, line: line }; + let resp = this._createAndStoreBreakpoint(location); + dbg_assert(!resp.actualLocation, "No actualLocation should be returned"); + if (resp.error) { + reportError(new Error("Unable to set breakpoint on event listener")); + return; + } + let bp = this.breakpointStore.getBreakpoint(location); + let bpActor = bp.actor; + dbg_assert(bp, "Breakpoint must exist"); + dbg_assert(bpActor, "Breakpoint actor must be created"); + this._hiddenBreakpoints.set(bpActor.actorID, bpActor); + break; + } + } + }, + + /** + * Helper method that returns the next frame when stepping. + */ + _getNextStepFrame: function TA__getNextStepFrame(aFrame) { + let stepFrame = aFrame.reportedPop ? aFrame.older : aFrame; + if (!stepFrame || !stepFrame.script) { + stepFrame = null; + } + return stepFrame; + }, + + onClientEvaluate: function TA_onClientEvaluate(aRequest) { + if (this.state !== "paused") { + return { error: "wrongState", + message: "Debuggee must be paused to evaluate code." }; + } + + let frame = this._requestFrame(aRequest.frame); + if (!frame) { + return { error: "unknownFrame", + message: "Evaluation frame not found" }; + } + + if (!frame.environment) { + return { error: "notDebuggee", + message: "cannot access the environment of this frame." }; + } + + let youngest = this.youngestFrame; + + // Put ourselves back in the running state and inform the client. + let resumedPacket = this._resumed(); + this.conn.send(resumedPacket); + + // Run the expression. + // XXX: test syntax errors + let completion = frame.eval(aRequest.expression); + + // Put ourselves back in the pause state. + let packet = this._paused(youngest); + packet.why = { type: "clientEvaluated", + frameFinished: this.createProtocolCompletionValue(completion) }; + + // Return back to our previous pause's event loop. + return packet; + }, + + onFrames: function TA_onFrames(aRequest) { + if (this.state !== "paused") { + return { error: "wrongState", + message: "Stack frames are only available while the debuggee is paused."}; + } + + let start = aRequest.start ? aRequest.start : 0; + let count = aRequest.count; + + // Find the starting frame... + let frame = this.youngestFrame; + let i = 0; + while (frame && (i < start)) { + frame = frame.older; + i++; + } + + // Return request.count frames, or all remaining + // frames if count is not defined. + let frames = []; + let promises = []; + for (; frame && (!count || i < (start + count)); i++, frame=frame.older) { + let form = this._createFrameActor(frame).form(); + form.depth = i; + frames.push(form); + + let promise = this.sources.getOriginalLocation(form.where) + .then((aOrigLocation) => { + form.where = aOrigLocation; + let source = this.sources.source({ url: form.where.url }); + if (source) { + form.source = source.form(); + } + }); + promises.push(promise); + } + + return all(promises).then(function () { + return { frames: frames }; + }); + }, + + onReleaseMany: function TA_onReleaseMany(aRequest) { + if (!aRequest.actors) { + return { error: "missingParameter", + message: "no actors were specified" }; + } + + let res; + for each (let actorID in aRequest.actors) { + let actor = this.threadLifetimePool.get(actorID); + if (!actor) { + if (!res) { + res = { error: "notReleasable", + message: "Only thread-lifetime actors can be released." }; + } + continue; + } + actor.onRelease(); + } + return res ? res : {}; + }, + + /** + * Handle a protocol request to set a breakpoint. + */ + onSetBreakpoint: function TA_onSetBreakpoint(aRequest) { + if (this.state !== "paused") { + return { error: "wrongState", + message: "Breakpoints can only be set while the debuggee is paused."}; + } + + let { url: originalSource, + line: originalLine, + column: originalColumn } = aRequest.location; + + let locationPromise = this.sources.getGeneratedLocation(aRequest.location); + return locationPromise.then(({url, line, column}) => { + if (line == null || + line < 0 || + this.dbg.findScripts({ url: url }).length == 0) { + return { error: "noScript" }; + } + + let response = this._createAndStoreBreakpoint({ + url: url, + line: line, + column: column + }); + // If the original location of our generated location is different from + // the original location we attempted to set the breakpoint on, we will + // need to know so that we can set actualLocation on the response. + let originalLocation = this.sources.getOriginalLocation({ + url: url, + line: line, + column: column + }); + + return all([response, originalLocation]) + .then(([aResponse, {url, line}]) => { + if (aResponse.actualLocation) { + let actualOrigLocation = this.sources.getOriginalLocation(aResponse.actualLocation); + return actualOrigLocation.then(({ url, line, column }) => { + if (url !== originalSource + || line !== originalLine + || column !== originalColumn) { + aResponse.actualLocation = { + url: url, + line: line, + column: column + }; + } + return aResponse; + }); + } + + if (url !== originalSource || line !== originalLine) { + aResponse.actualLocation = { url: url, line: line }; + } + + return aResponse; + }); + }); + }, + + /** + * Create a breakpoint at the specified location and store it in the + * cache. Takes ownership of `aLocation`. + * + * @param Object aLocation + * An object of the form { url, line[, column] } + */ + _createAndStoreBreakpoint: function (aLocation) { + // Add the breakpoint to the store for later reuse, in case it belongs to a + // script that hasn't appeared yet. + this.breakpointStore.addBreakpoint(aLocation); + return this._setBreakpoint(aLocation); + }, + + /** + * Set a breakpoint using the jsdbg2 API. If the line on which the breakpoint + * is being set contains no code, then the breakpoint will slide down to the + * next line that has runnable code. In this case the server breakpoint cache + * will be updated, so callers that iterate over the breakpoint cache should + * take that into account. + * + * @param object aLocation + * The location of the breakpoint (in the generated source, if source + * mapping). + */ + _setBreakpoint: function TA__setBreakpoint(aLocation) { + let actor; + let storedBp = this.breakpointStore.getBreakpoint(aLocation); + if (storedBp.actor) { + actor = storedBp.actor; + } else { + storedBp.actor = actor = new BreakpointActor(this, { + url: aLocation.url, + line: aLocation.line, + column: aLocation.column + }); + this._hooks.addToParentPool(actor); + } + + // Find all scripts matching the given location + let scripts = this.dbg.findScripts(aLocation); + if (scripts.length == 0) { + return { + error: "noScript", + actor: actor.actorID + }; + } + + /** + * For each script, if the given line has at least one entry point, set a + * breakpoint on the bytecode offets for each of them. + */ + + // Debugger.Script -> array of offset mappings + let scriptsAndOffsetMappings = new Map(); + + for (let script of scripts) { + this._findClosestOffsetMappings(aLocation, + script, + scriptsAndOffsetMappings); + } + + if (scriptsAndOffsetMappings.size > 0) { + for (let [script, mappings] of scriptsAndOffsetMappings) { + for (let offsetMapping of mappings) { + script.setBreakpoint(offsetMapping.offset, actor); + } + actor.addScript(script, this); + } + + return { + actor: actor.actorID + }; + } + + /** + * If we get here, no breakpoint was set. This is because the given line + * has no entry points, for example because it is empty. As a fallback + * strategy, we try to set the breakpoint on the smallest line greater + * than or equal to the given line that as at least one entry point. + */ + + // Find all innermost scripts matching the given location + let scripts = this.dbg.findScripts({ + url: aLocation.url, + line: aLocation.line, + innermost: true + }); + + /** + * For each innermost script, look for the smallest line greater than or + * equal to the given line that has one or more entry points. If found, set + * a breakpoint on the bytecode offset for each of its entry points. + */ + let actualLocation; + let found = false; + for (let script of scripts) { + let offsets = script.getAllOffsets(); + for (let line = aLocation.line; line < offsets.length; ++line) { + if (offsets[line]) { + for (let offset of offsets[line]) { + script.setBreakpoint(offset, actor); + } + actor.addScript(script, this); + if (!actualLocation) { + actualLocation = { + url: aLocation.url, + line: line, + column: 0 + }; + } + found = true; + break; + } + } + } + if (found) { + let existingBp = this.breakpointStore.hasBreakpoint(actualLocation); + + if (existingBp && existingBp.actor) { + /** + * We already have a breakpoint actor for the actual location, so + * actor we created earlier is now redundant. Delete it, update the + * breakpoint store, and return the actor for the actual location. + */ + actor.onDelete(); + this.breakpointStore.removeBreakpoint(aLocation); + return { + actor: existingBp.actor.actorID, + actualLocation: actualLocation + }; + } else { + /** + * We don't have a breakpoint actor for the actual location yet. + * Instead or creating a new actor, reuse the actor we created earlier, + * and update the breakpoint store. + */ + actor.location = actualLocation; + this.breakpointStore.addBreakpoint({ + actor: actor, + url: actualLocation.url, + line: actualLocation.line, + column: actualLocation.column + }); + this.breakpointStore.removeBreakpoint(aLocation); + return { + actor: actor.actorID, + actualLocation: actualLocation + }; + } + } + + /** + * If we get here, no line matching the given line was found, so just + * fail epically. + */ + return { + error: "noCodeAtLineColumn", + actor: actor.actorID + }; + }, + + /** + * Find all of the offset mappings associated with `aScript` that are closest + * to `aTargetLocation`. If new offset mappings are found that are closer to + * `aTargetOffset` than the existing offset mappings inside + * `aScriptsAndOffsetMappings`, we empty that map and only consider the + * closest offset mappings. If there is no column in `aTargetLocation`, we add + * all offset mappings that are on the given line. + * + * @param Object aTargetLocation + * An object of the form { url, line[, column] }. + * @param Debugger.Script aScript + * The script in which we are searching for offsets. + * @param Map aScriptsAndOffsetMappings + * A Map object which maps Debugger.Script instances to arrays of + * offset mappings. This is an out param. + */ + _findClosestOffsetMappings: function TA__findClosestOffsetMappings(aTargetLocation, + aScript, + aScriptsAndOffsetMappings) { + // If we are given a column, we will try and break only at that location, + // otherwise we will break anytime we get on that line. + + if (aTargetLocation.column == null) { + let offsetMappings = aScript.getLineOffsets(aTargetLocation.line) + .map(o => ({ + line: aTargetLocation.line, + offset: o + })); + if (offsetMappings.length) { + aScriptsAndOffsetMappings.set(aScript, offsetMappings); + } + return; + } + + let offsetMappings = aScript.getAllColumnOffsets() + .filter(({ lineNumber }) => lineNumber === aTargetLocation.line); + + // Attempt to find the current closest offset distance from the target + // location by grabbing any offset mapping in the map by doing one iteration + // and then breaking (they all have the same distance from the target + // location). + let closestDistance = Infinity; + if (aScriptsAndOffsetMappings.size) { + for (let mappings of aScriptsAndOffsetMappings.values()) { + closestDistance = Math.abs(aTargetLocation.column - mappings[0].columnNumber); + break; + } + } + + for (let mapping of offsetMappings) { + let currentDistance = Math.abs(aTargetLocation.column - mapping.columnNumber); + + if (currentDistance > closestDistance) { + continue; + } else if (currentDistance < closestDistance) { + closestDistance = currentDistance; + aScriptsAndOffsetMappings.clear(); + aScriptsAndOffsetMappings.set(aScript, [mapping]); + } else { + if (!aScriptsAndOffsetMappings.has(aScript)) { + aScriptsAndOffsetMappings.set(aScript, []); + } + aScriptsAndOffsetMappings.get(aScript).push(mapping); + } + } + }, + + /** + * Get the script and source lists from the debugger. + * + * TODO bug 637572: we should be dealing with sources directly, not inferring + * them through scripts. + */ + _discoverSources: function TA__discoverSources() { + // Only get one script per url. + let scriptsByUrl = {}; + for (let s of this.dbg.findScripts()) { + scriptsByUrl[s.url] = s; + } + + return all([this.sources.sourcesForScript(scriptsByUrl[s]) + for (s of Object.keys(scriptsByUrl))]); + }, + + onSources: function TA_onSources(aRequest) { + return this._discoverSources().then(() => { + return { + sources: [s.form() for (s of this.sources.iter())] + }; + }); + }, + + /** + * Disassociate all breakpoint actors from their scripts and clear the + * breakpoint handlers. This method can be used when the thread actor intends + * to keep the breakpoint store, but needs to clear any actual breakpoints, + * e.g. due to a page navigation. This way the breakpoint actors' script + * caches won't hold on to the Debugger.Script objects leaking memory. + */ + disableAllBreakpoints: function () { + for (let bp of this.breakpointStore.findBreakpoints()) { + if (bp.actor) { + bp.actor.removeScripts(); + } + } + }, + + /** + * Handle a protocol request to pause the debuggee. + */ + onInterrupt: function TA_onInterrupt(aRequest) { + if (this.state == "exited") { + return { type: "exited" }; + } else if (this.state == "paused") { + // TODO: return the actual reason for the existing pause. + return { type: "paused", why: { type: "alreadyPaused" } }; + } else if (this.state != "running") { + return { error: "wrongState", + message: "Received interrupt request in " + this.state + + " state." }; + } + + try { + // Put ourselves in the paused state. + let packet = this._paused(); + if (!packet) { + return { error: "notInterrupted" }; + } + packet.why = { type: "interrupted" }; + + // Send the response to the interrupt request now (rather than + // returning it), because we're going to start a nested event loop + // here. + this.conn.send(packet); + + // Start a nested event loop. + this._pushThreadPause(); + + // We already sent a response to this request, don't send one + // now. + return null; + } catch (e) { + reportError(e); + return { error: "notInterrupted", message: e.toString() }; + } + }, + + /** + * Handle a protocol request to retrieve all the event listeners on the page. + */ + onEventListeners: function TA_onEventListeners(aRequest) { + // This request is only supported in content debugging. + if (!this.global) { + return { + error: "notImplemented", + message: "eventListeners request is only supported in content debugging" + }; + } + + let els = Cc["@mozilla.org/eventlistenerservice;1"] + .getService(Ci.nsIEventListenerService); + + let nodes = this.global.document.getElementsByTagName("*"); + nodes = [this.global].concat([].slice.call(nodes)); + let listeners = []; + + for (let node of nodes) { + let handlers = els.getListenerInfoFor(node); + + for (let handler of handlers) { + // Create a form object for serializing the listener via the protocol. + let listenerForm = Object.create(null); + let listener = handler.listenerObject; + // Native event listeners don't provide any listenerObject and are not + // that useful to a JS debugger. + if (!listener) { + continue; + } + + // There will be no tagName if the event listener is set on the window. + let selector = node.tagName ? findCssSelector(node) : "window"; + let nodeDO = this.globalDebugObject.makeDebuggeeValue(node); + listenerForm.node = { + selector: selector, + object: this.createValueGrip(nodeDO) + }; + listenerForm.type = handler.type; + listenerForm.capturing = handler.capturing; + listenerForm.allowsUntrusted = handler.allowsUntrusted; + listenerForm.inSystemEventGroup = handler.inSystemEventGroup; + listenerForm.isEventHandler = !!node["on" + listenerForm.type]; + // Get the Debugger.Object for the listener object. + let listenerDO = this.globalDebugObject.makeDebuggeeValue(listener); + listenerForm.function = this.createValueGrip(listenerDO); + listeners.push(listenerForm); + } + } + return { listeners: listeners }; + }, + + /** + * Return the Debug.Frame for a frame mentioned by the protocol. + */ + _requestFrame: function TA_requestFrame(aFrameID) { + if (!aFrameID) { + return this.youngestFrame; + } + + if (this._framePool.has(aFrameID)) { + return this._framePool.get(aFrameID).frame; + } + + return undefined; + }, + + _paused: function TA__paused(aFrame) { + // We don't handle nested pauses correctly. Don't try - if we're + // paused, just continue running whatever code triggered the pause. + // We don't want to actually have nested pauses (although we + // have nested event loops). If code runs in the debuggee during + // a pause, it should cause the actor to resume (dropping + // pause-lifetime actors etc) and then repause when complete. + + if (this.state === "paused") { + return undefined; + } + + // Clear stepping hooks. + this.dbg.onEnterFrame = undefined; + this.dbg.onExceptionUnwind = undefined; + if (aFrame) { + aFrame.onStep = undefined; + aFrame.onPop = undefined; + } + // Clear DOM event breakpoints. + // XPCShell tests don't use actual DOM windows for globals and cause + // removeListenerForAllEvents to throw. + if (this.global && !this.global.toString().contains("Sandbox")) { + // let els = Cc["@mozilla.org/eventlistenerservice;1"] + // .getService(Ci.nsIEventListenerService); + // els.removeListenerForAllEvents(this.global, this._allEventsListener, true); + for (let [,bp] of this._hiddenBreakpoints) { + bp.onDelete(); + } + this._hiddenBreakpoints.clear(); + } + + this._state = "paused"; + + // Create the actor pool that will hold the pause actor and its + // children. + dbg_assert(!this._pausePool, "No pause pool should exist yet"); + this._pausePool = new ActorPool(this.conn); + this.conn.addActorPool(this._pausePool); + + // Give children of the pause pool a quick link back to the + // thread... + this._pausePool.threadActor = this; + + // Create the pause actor itself... + dbg_assert(!this._pauseActor, "No pause actor should exist yet"); + this._pauseActor = new PauseActor(this._pausePool); + this._pausePool.addActor(this._pauseActor); + + // Update the list of frames. + let poppedFrames = this._updateFrames(); + + // Send off the paused packet and spin an event loop. + let packet = { from: this.actorID, + type: "paused", + actor: this._pauseActor.actorID }; + if (aFrame) { + packet.frame = this._createFrameActor(aFrame).form(); + } + + if (poppedFrames) { + packet.poppedFrames = poppedFrames; + } + + return packet; + }, + + _resumed: function TA_resumed() { + this._state = "running"; + + // Drop the actors in the pause actor pool. + this.conn.removeActorPool(this._pausePool); + + this._pausePool = null; + this._pauseActor = null; + + return { from: this.actorID, type: "resumed" }; + }, + + /** + * Expire frame actors for frames that have been popped. + * + * @returns A list of actor IDs whose frames have been popped. + */ + _updateFrames: function TA_updateFrames() { + let popped = []; + + // Create the actor pool that will hold the still-living frames. + let framePool = new ActorPool(this.conn); + let frameList = []; + + for each (let frameActor in this._frameActors) { + if (frameActor.frame.live) { + framePool.addActor(frameActor); + frameList.push(frameActor); + } else { + popped.push(frameActor.actorID); + } + } + + // Remove the old frame actor pool, this will expire + // any actors that weren't added to the new pool. + if (this._framePool) { + this.conn.removeActorPool(this._framePool); + } + + this._frameActors = frameList; + this._framePool = framePool; + this.conn.addActorPool(framePool); + + return popped; + }, + + _createFrameActor: function TA_createFrameActor(aFrame) { + if (aFrame.actor) { + return aFrame.actor; + } + + let actor = new FrameActor(aFrame, this); + this._frameActors.push(actor); + this._framePool.addActor(actor); + aFrame.actor = actor; + + return actor; + }, + + /** + * Create and return an environment actor that corresponds to the provided + * Debugger.Environment. + * @param Debugger.Environment aEnvironment + * The lexical environment we want to extract. + * @param object aPool + * The pool where the newly-created actor will be placed. + * @return The EnvironmentActor for aEnvironment or undefined for host + * functions or functions scoped to a non-debuggee global. + */ + createEnvironmentActor: + function TA_createEnvironmentActor(aEnvironment, aPool) { + if (!aEnvironment) { + return undefined; + } + + if (aEnvironment.actor) { + return aEnvironment.actor; + } + + let actor = new EnvironmentActor(aEnvironment, this); + aPool.addActor(actor); + aEnvironment.actor = actor; + + return actor; + }, + + /** + * Create a grip for the given debuggee value. If the value is an + * object, will create an actor with the given lifetime. + */ + createValueGrip: function TA_createValueGrip(aValue, aPool=false) { + if (!aPool) { + aPool = this._pausePool; + } + + switch (typeof aValue) { + case "boolean": + return aValue; + case "string": + if (this._stringIsLong(aValue)) { + return this.longStringGrip(aValue, aPool); + } + return aValue; + case "number": + if (aValue === Infinity) { + return { type: "Infinity" }; + } else if (aValue === -Infinity) { + return { type: "-Infinity" }; + } else if (Number.isNaN(aValue)) { + return { type: "NaN" }; + } else if (!aValue && 1 / aValue === -Infinity) { + return { type: "-0" }; + } + return aValue; + case "undefined": + return { type: "undefined" }; + case "object": + if (aValue === null) { + return { type: "null" }; + } + return this.objectGrip(aValue, aPool); + default: + dbg_assert(false, "Failed to provide a grip for: " + aValue); + return null; + } + }, + + /** + * Return a protocol completion value representing the given + * Debugger-provided completion value. + */ + createProtocolCompletionValue: + function TA_createProtocolCompletionValue(aCompletion) { + let protoValue = {}; + if ("return" in aCompletion) { + protoValue.return = this.createValueGrip(aCompletion.return); + } else if ("yield" in aCompletion) { + protoValue.return = this.createValueGrip(aCompletion.yield); + } else if ("throw" in aCompletion) { + protoValue.throw = this.createValueGrip(aCompletion.throw); + } else { + protoValue.terminated = true; + } + return protoValue; + }, + + /** + * Create a grip for the given debuggee object. + * + * @param aValue Debugger.Object + * The debuggee object value. + * @param aPool ActorPool + * The actor pool where the new object actor will be added. + */ + objectGrip: function TA_objectGrip(aValue, aPool) { + if (!aPool.objectActors) { + aPool.objectActors = new WeakMap(); + } + + if (aPool.objectActors.has(aValue)) { + return aPool.objectActors.get(aValue).grip(); + } else if (this.threadLifetimePool.objectActors.has(aValue)) { + return this.threadLifetimePool.objectActors.get(aValue).grip(); + } + + let actor = new PauseScopedObjectActor(aValue, this); + aPool.addActor(actor); + aPool.objectActors.set(aValue, actor); + return actor.grip(); + }, + + /** + * Create a grip for the given debuggee object with a pause lifetime. + * + * @param aValue Debugger.Object + * The debuggee object value. + */ + pauseObjectGrip: function TA_pauseObjectGrip(aValue) { + if (!this._pausePool) { + throw "Object grip requested while not paused."; + } + + return this.objectGrip(aValue, this._pausePool); + }, + + /** + * Extend the lifetime of the provided object actor to thread lifetime. + * + * @param aActor object + * The object actor. + */ + threadObjectGrip: function TA_threadObjectGrip(aActor) { + // We want to reuse the existing actor ID, so we just remove it from the + // current pool's weak map and then let pool.addActor do the rest. + aActor.registeredPool.objectActors.delete(aActor.obj); + this.threadLifetimePool.addActor(aActor); + this.threadLifetimePool.objectActors.set(aActor.obj, aActor); + }, + + /** + * Handle a protocol request to promote multiple pause-lifetime grips to + * thread-lifetime grips. + * + * @param aRequest object + * The protocol request object. + */ + onThreadGrips: function OA_onThreadGrips(aRequest) { + if (this.state != "paused") { + return { error: "wrongState" }; + } + + if (!aRequest.actors) { + return { error: "missingParameter", + message: "no actors were specified" }; + } + + for (let actorID of aRequest.actors) { + let actor = this._pausePool.get(actorID); + if (actor) { + this.threadObjectGrip(actor); + } + } + return {}; + }, + + /** + * Create a grip for the given string. + * + * @param aString String + * The string we are creating a grip for. + * @param aPool ActorPool + * The actor pool where the new actor will be added. + */ + longStringGrip: function TA_longStringGrip(aString, aPool) { + if (!aPool.longStringActors) { + aPool.longStringActors = {}; + } + + if (aPool.longStringActors.hasOwnProperty(aString)) { + return aPool.longStringActors[aString].grip(); + } + + let actor = new LongStringActor(aString, this); + aPool.addActor(actor); + aPool.longStringActors[aString] = actor; + return actor.grip(); + }, + + /** + * Create a long string grip that is scoped to a pause. + * + * @param aString String + * The string we are creating a grip for. + */ + pauseLongStringGrip: function TA_pauseLongStringGrip (aString) { + return this.longStringGrip(aString, this._pausePool); + }, + + /** + * Create a long string grip that is scoped to a thread. + * + * @param aString String + * The string we are creating a grip for. + */ + threadLongStringGrip: function TA_pauseLongStringGrip (aString) { + return this.longStringGrip(aString, this._threadLifetimePool); + }, + + /** + * Returns true if the string is long enough to use a LongStringActor instead + * of passing the value directly over the protocol. + * + * @param aString String + * The string we are checking the length of. + */ + _stringIsLong: function TA__stringIsLong(aString) { + return aString.length >= DebuggerServer.LONG_STRING_LENGTH; + }, + + // JS Debugger API hooks. + + /** + * A function that the engine calls when a call to a debug event hook, + * breakpoint handler, watchpoint handler, or similar function throws some + * exception. + * + * @param aException exception + * The exception that was thrown in the debugger code. + */ + uncaughtExceptionHook: function TA_uncaughtExceptionHook(aException) { + dumpn("Got an exception: " + aException.message + "\n" + aException.stack); + }, + + /** + * A function that the engine calls when a debugger statement has been + * executed in the specified frame. + * + * @param aFrame Debugger.Frame + * The stack frame that contained the debugger statement. + */ + onDebuggerStatement: function TA_onDebuggerStatement(aFrame) { + // Don't pause if we are currently stepping (in or over) or the frame is + // black-boxed. + const generatedLocation = getFrameLocation(aFrame); + const { url } = this.synchronize(this.sources.getOriginalLocation( + generatedLocation)); + + return this.sources.isBlackBoxed(url) || aFrame.onStep + ? undefined + : this._pauseAndRespond(aFrame, { type: "debuggerStatement" }); + }, + + /** + * A function that the engine calls when an exception has been thrown and has + * propagated to the specified frame. + * + * @param aFrame Debugger.Frame + * The youngest remaining stack frame. + * @param aValue object + * The exception that was thrown. + */ + onExceptionUnwind: function TA_onExceptionUnwind(aFrame, aValue) { + let willBeCaught = false; + for (let frame = aFrame; frame != null; frame = frame.older) { + if (frame.script.isInCatchScope(frame.offset)) { + willBeCaught = true; + break; + } + } + + if (willBeCaught && this._options.ignoreCaughtExceptions) { + return undefined; + } + + const generatedLocation = getFrameLocation(aFrame); + const { url } = this.synchronize(this.sources.getOriginalLocation( + generatedLocation)); + + if (this.sources.isBlackBoxed(url)) { + return undefined; + } + + try { + let packet = this._paused(aFrame); + if (!packet) { + return undefined; + } + + packet.why = { type: "exception", + exception: this.createValueGrip(aValue) }; + this.conn.send(packet); + + this._pushThreadPause(); + } catch(e) { + reportError(e, "Got an exception during TA_onExceptionUnwind: "); + } + + return undefined; + }, + + /** + * A function that the engine calls when a new script has been loaded into the + * scope of the specified debuggee global. + * + * @param aScript Debugger.Script + * The source script that has been loaded into a debuggee compartment. + * @param aGlobal Debugger.Object + * A Debugger.Object instance whose referent is the global object. + */ + onNewScript: function TA_onNewScript(aScript, aGlobal) { + this._addScript(aScript); + this.sources.sourcesForScript(aScript); + }, + + onNewSource: function TA_onNewSource(aSource) { + this.conn.send({ + from: this.actorID, + type: "newSource", + source: aSource.form() + }); + }, + + /** + * Check if scripts from the provided source URL are allowed to be stored in + * the cache. + * + * @param aSourceUrl String + * The url of the script's source that will be stored. + * @returns true, if the script can be added, false otherwise. + */ + _allowSource: function TA__allowSource(aSourceUrl) { + // Ignore anything we don't have a URL for (eval scripts, for example). + if (!aSourceUrl) + return false; + // Ignore XBL bindings for content debugging. + if (aSourceUrl.indexOf("chrome://") == 0) { + return false; + } + // Ignore about:* pages for content debugging. + if (aSourceUrl.indexOf("about:") == 0) { + return false; + } + return true; + }, + + /** + * Restore any pre-existing breakpoints to the scripts that we have access to. + */ + _restoreBreakpoints: function TA__restoreBreakpoints() { + for (let s of this.dbg.findScripts()) { + this._addScript(s); + } + }, + + /** + * Add the provided script to the server cache. + * + * @param aScript Debugger.Script + * The source script that will be stored. + * @returns true, if the script was added; false otherwise. + */ + _addScript: function TA__addScript(aScript) { + if (!this._allowSource(aScript.url)) { + return false; + } + + // Set any stored breakpoints. + + let endLine = aScript.startLine + aScript.lineCount - 1; + for (let bp of this.breakpointStore.findBreakpoints({ url: aScript.url })) { + // Only consider breakpoints that are not already associated with + // scripts, and limit search to the line numbers contained in the new + // script. + if (!bp.actor.scripts.length + && bp.line >= aScript.startLine + && bp.line <= endLine) { + this._setBreakpoint(bp); + } + } + + return true; + }, + + + /** + * Get prototypes and properties of multiple objects. + */ + onPrototypesAndProperties: function TA_onPrototypesAndProperties(aRequest) { + let result = {}; + for (let actorID of aRequest.actors) { + // This code assumes that there are no lazily loaded actors returned + // by this call. + let actor = this.conn.getActor(actorID); + if (!actor) { + return { from: this.actorID, + error: "noSuchActor" }; + } + let handler = actor.onPrototypeAndProperties; + if (!handler) { + return { from: this.actorID, + error: "unrecognizedPacketType", + message: ('Actor "' + actorID + + '" does not recognize the packet type ' + + '"prototypeAndProperties"') }; + } + result[actorID] = handler.call(actor, {}); + } + return { from: this.actorID, + actors: result }; + } + +}; + +ThreadActor.prototype.requestTypes = { + "attach": ThreadActor.prototype.onAttach, + "detach": ThreadActor.prototype.onDetach, + "reconfigure": ThreadActor.prototype.onReconfigure, + "resume": ThreadActor.prototype.onResume, + "clientEvaluate": ThreadActor.prototype.onClientEvaluate, + "frames": ThreadActor.prototype.onFrames, + "interrupt": ThreadActor.prototype.onInterrupt, + "eventListeners": ThreadActor.prototype.onEventListeners, + "releaseMany": ThreadActor.prototype.onReleaseMany, + "setBreakpoint": ThreadActor.prototype.onSetBreakpoint, + "sources": ThreadActor.prototype.onSources, + "threadGrips": ThreadActor.prototype.onThreadGrips, + "prototypesAndProperties": ThreadActor.prototype.onPrototypesAndProperties +}; + + +/** + * Creates a PauseActor. + * + * PauseActors exist for the lifetime of a given debuggee pause. Used to + * scope pause-lifetime grips. + * + * @param ActorPool aPool + * The actor pool created for this pause. + */ +function PauseActor(aPool) +{ + this.pool = aPool; +} + +PauseActor.prototype = { + actorPrefix: "pause" +}; + + +/** + * A base actor for any actors that should only respond receive messages in the + * paused state. Subclasses may expose a `threadActor` which is used to help + * determine when we are in a paused state. Subclasses should set their own + * "constructor" property if they want better error messages. You should never + * instantiate a PauseScopedActor directly, only through subclasses. + */ +function PauseScopedActor() +{ +} + +/** + * A function decorator for creating methods to handle protocol messages that + * should only be received while in the paused state. + * + * @param aMethod Function + * The function we are decorating. + */ +PauseScopedActor.withPaused = function PSA_withPaused(aMethod) { + return function () { + if (this.isPaused()) { + return aMethod.apply(this, arguments); + } else { + return this._wrongState(); + } + }; +}; + +PauseScopedActor.prototype = { + + /** + * Returns true if we are in the paused state. + */ + isPaused: function PSA_isPaused() { + // When there is not a ThreadActor available (like in the webconsole) we + // have to be optimistic and assume that we are paused so that we can + // respond to requests. + return this.threadActor ? this.threadActor.state === "paused" : true; + }, + + /** + * Returns the wrongState response packet for this actor. + */ + _wrongState: function PSA_wrongState() { + return { + error: "wrongState", + message: this.constructor.name + + " actors can only be accessed while the thread is paused." + }; + } +}; + + +/** + * A SourceActor provides information about the source of a script. + * + * @param String url + * The url of the source we are representing. + * @param ThreadActor thread + * The current thread actor. + * @param SourceMapConsumer sourceMap + * Optional. The source map that introduced this source, if available. + * @param String generatedSource + * Optional, passed in when aSourceMap is also passed in. The generated + * source url that introduced this source. + * @param String text + * Optional. The content text of this source, if immediately available. + * @param String contentType + * Optional. The content type of this source, if immediately available. + */ +function SourceActor({ url, thread, sourceMap, generatedSource, text, + contentType }) { + this._threadActor = thread; + this._url = url; + this._sourceMap = sourceMap; + this._generatedSource = generatedSource; + this._text = text; + this._contentType = contentType; + + this.onSource = this.onSource.bind(this); + this._invertSourceMap = this._invertSourceMap.bind(this); + this._saveMap = this._saveMap.bind(this); + this._getSourceText = this._getSourceText.bind(this); + + if (this.threadActor.sources.isPrettyPrinted(this.url)) { + this._init = this.onPrettyPrint({ + indent: this.threadActor.sources.prettyPrintIndent(this.url) + }).then(null, error => { + DevToolsUtils.reportException("SourceActor", error); + }); + } else { + this._init = null; + } +} + +SourceActor.prototype = { + constructor: SourceActor, + actorPrefix: "source", + + _oldSourceMap: null, + _init: null, + + get threadActor() this._threadActor, + get url() this._url, + + get prettyPrintWorker() { + return this.threadActor.prettyPrintWorker; + }, + + form: function SA_form() { + return { + actor: this.actorID, + url: this._url, + isBlackBoxed: this.threadActor.sources.isBlackBoxed(this.url), + isPrettyPrinted: this.threadActor.sources.isPrettyPrinted(this.url) + // TODO bug 637572: introductionScript + }; + }, + + disconnect: function SA_disconnect() { + if (this.registeredPool && this.registeredPool.sourceActors) { + delete this.registeredPool.sourceActors[this.actorID]; + } + }, + + _getSourceText: function SA__getSourceText() { + const toResolvedContent = t => resolve({ + content: t, + contentType: this._contentType + }); + + let sc; + if (this._sourceMap && (sc = this._sourceMap.sourceContentFor(this._url))) { + return toResolvedContent(sc); + } + + if (this._text) { + return toResolvedContent(this._text); + } + + // XXX bug 865252: Don't load from the cache if this is a source mapped + // source because we can't guarantee that the cache has the most up to date + // content for this source like we can if it isn't source mapped. + return fetch(this._url, { loadFromCache: !this._sourceMap }); + }, + + /** + * Handler for the "source" packet. + */ + onSource: function SA_onSource() { + return resolve(this._init) + .then(this._getSourceText) + .then(({ content, contentType }) => { + return { + from: this.actorID, + source: this.threadActor.createValueGrip( + content, this.threadActor.threadLifetimePool), + contentType: contentType + }; + }) + .then(null, aError => { + reportError(aError, "Got an exception during SA_onSource: "); + return { + "from": this.actorID, + "error": "loadSourceError", + "message": "Could not load the source for " + this._url + ".\n" + + safeErrorString(aError) + }; + }); + }, + + /** + * Handler for the "prettyPrint" packet. + */ + onPrettyPrint: function ({ indent }) { + this.threadActor.sources.prettyPrint(this._url, indent); + return this._getSourceText() + .then(this._sendToPrettyPrintWorker(indent)) + .then(this._invertSourceMap) + .then(this._saveMap) + .then(() => { + // We need to reset `_init` now because we have already done the work of + // pretty printing, and don't want onSource to wait forever for + // initialization to complete. + this._init = null; + }) + .then(this.onSource) + .then(null, error => { + this.onDisablePrettyPrint(); + return { + from: this.actorID, + error: "prettyPrintError", + message: DevToolsUtils.safeErrorString(error) + }; + }); + }, + + /** + * Return a function that sends a request to the pretty print worker, waits on + * the worker's response, and then returns the pretty printed code. + * + * @param Number aIndent + * The number of spaces to indent by the code by, when we send the + * request to the pretty print worker. + * @returns Function + * Returns a function which takes an AST, and returns a promise that + * is resolved with `{ code, mappings }` where `code` is the pretty + * printed code, and `mappings` is an array of source mappings. + */ + _sendToPrettyPrintWorker: function SA__sendToPrettyPrintWorker(aIndent) { + return ({ content }) => { + const deferred = promise.defer(); + const id = Math.random(); + + const onReply = ({ data }) => { + if (data.id !== id) { + return; + } + this.prettyPrintWorker.removeEventListener("message", onReply, false); + + if (data.error) { + deferred.reject(new Error(data.error)); + } else { + deferred.resolve(data); + } + }; + + this.prettyPrintWorker.addEventListener("message", onReply, false); + this.prettyPrintWorker.postMessage({ + id: id, + url: this._url, + indent: aIndent, + source: content + }); + + return deferred.promise; + }; + }, + + /** + * Invert a source map. So if a source map maps from a to b, return a new + * source map from b to a. We need to do this because the source map we get + * from _generatePrettyCodeAndMap goes the opposite way we want it to for + * debugging. + * + * Note that the source map is modified in place. + */ + _invertSourceMap: function SA__invertSourceMap({ code, mappings }) { + const generator = new SourceMapGenerator({ file: this._url }); + return DevToolsUtils.yieldingEach(mappings, m => { + let mapping = { + generated: { + line: m.generatedLine, + column: m.generatedColumn + } + }; + if (m.source) { + mapping.source = m.source; + mapping.original = { + line: m.originalLine, + column: m.originalColumn + }; + mapping.name = m.name; + } + generator.addMapping(mapping); + }).then(() => { + generator.setSourceContent(this._url, code); + const consumer = SourceMapConsumer.fromSourceMap(generator); + + // XXX bug 918802: Monkey punch the source map consumer, because iterating + // over all mappings and inverting each of them, and then creating a new + // SourceMapConsumer is slow. + + const getOrigPos = consumer.originalPositionFor.bind(consumer); + const getGenPos = consumer.generatedPositionFor.bind(consumer); + + consumer.originalPositionFor = ({ line, column }) => { + const location = getGenPos({ + line: line, + column: column, + source: this._url + }); + location.source = this._url; + return location; + }; + + consumer.generatedPositionFor = ({ line, column }) => getOrigPos({ + line: line, + column: column + }); + + return { + code: code, + map: consumer + }; + }); + }, + + /** + * Save the source map back to our thread's ThreadSources object so that + * stepping, breakpoints, debugger statements, etc can use it. If we are + * pretty printing a source mapped source, we need to compose the existing + * source map with our new one. + */ + _saveMap: function SA__saveMap({ map }) { + if (this._sourceMap) { + // Compose the source maps + this._oldSourceMap = this._sourceMap; + this._sourceMap = SourceMapGenerator.fromSourceMap(this._sourceMap); + this._sourceMap.applySourceMap(map, this._url); + this._sourceMap = SourceMapConsumer.fromSourceMap(this._sourceMap); + this._threadActor.sources.saveSourceMap(this._sourceMap, + this._generatedSource); + } else { + this._sourceMap = map; + this._threadActor.sources.saveSourceMap(this._sourceMap, this._url); + } + }, + + /** + * Handler for the "disablePrettyPrint" packet. + */ + onDisablePrettyPrint: function SA_onDisablePrettyPrint() { + this._sourceMap = this._oldSourceMap; + this.threadActor.sources.saveSourceMap(this._sourceMap, + this._generatedSource || this._url); + this.threadActor.sources.disablePrettyPrint(this._url); + return this.onSource(); + }, + + /** + * Handler for the "blackbox" packet. + */ + onBlackBox: function SA_onBlackBox(aRequest) { + this.threadActor.sources.blackBox(this.url); + let packet = { + from: this.actorID + }; + if (this.threadActor.state == "paused" + && this.threadActor.youngestFrame + && this.threadActor.youngestFrame.script.url == this.url) { + packet.pausedInSource = true; + } + return packet; + }, + + /** + * Handler for the "unblackbox" packet. + */ + onUnblackBox: function SA_onUnblackBox(aRequest) { + this.threadActor.sources.unblackBox(this.url); + return { + from: this.actorID + }; + } +}; + +SourceActor.prototype.requestTypes = { + "source": SourceActor.prototype.onSource, + "blackbox": SourceActor.prototype.onBlackBox, + "unblackbox": SourceActor.prototype.onUnblackBox, + "prettyPrint": SourceActor.prototype.onPrettyPrint, + "disablePrettyPrint": SourceActor.prototype.onDisablePrettyPrint +}; + + +/** + * Creates an actor for the specified object. + * + * @param aObj Debugger.Object + * The debuggee object. + * @param aThreadActor ThreadActor + * The parent thread actor for this object. + */ +function ObjectActor(aObj, aThreadActor) +{ + this.obj = aObj; + this.threadActor = aThreadActor; +} + +ObjectActor.prototype = { + actorPrefix: "obj", + + _forcedMagicProps: false, + + /** + * Returns a grip for this actor for returning in a protocol message. + */ + grip: function OA_grip() { + let g = { + "type": "object", + "class": this.obj.class, + "actor": this.actorID, + "extensible": this.obj.isExtensible && typeof this.obj.isExtensible == 'function' ? this.obj.isExtensible() : true, + "frozen": this.obj.isFrozen && typeof this.obj.isFrozen == 'function' ? this.obj.isFrozen() : false, + "sealed": this.obj.isSealed && typeof this.obj.isSealed == 'function' ? this.obj.isSealed() : false + }; + + // Add additional properties for functions. + if (this.obj.class === "Function") { + if (this.obj.name) { + g.name = this.obj.name; + } + if (this.obj.displayName) { + g.displayName = this.obj.displayName; + } + + // Check if the developer has added a de-facto standard displayName + // property for us to use. + try { + let desc = this.obj.getOwnPropertyDescriptor("displayName"); + if (desc && desc.value && typeof desc.value == "string") { + g.userDisplayName = this.threadActor.createValueGrip(desc.value); + } + } catch (e) { + // Calling getOwnPropertyDescriptor with displayName might throw + // with "permission denied" errors for some functions. + dumpn(e); + } + + // Add source location information. + if (this.obj.script) { + g.url = this.obj.script.url; + g.line = this.obj.script.startLine; + } + } + + return g; + }, + + /** + * Releases this actor from the pool. + */ + release: function OA_release() { + if (this.registeredPool.objectActors) { + this.registeredPool.objectActors.delete(this.obj); + } + this.registeredPool.removeActor(this); + }, + + /** + * Force the magic Error properties to appear. + */ + _forceMagicProperties: function OA__forceMagicProperties() { + if (this._forcedMagicProps) { + return; + } + + const MAGIC_ERROR_PROPERTIES = [ + "message", "stack", "fileName", "lineNumber", "columnNumber" + ]; + + if (this.obj.class.endsWith("Error")) { + for (let property of MAGIC_ERROR_PROPERTIES) { + this._propertyDescriptor(property); + } + } + + this._forcedMagicProps = true; + }, + + /** + * Handle a protocol request to provide the names of the properties defined on + * the object and not its prototype. + * + * @param aRequest object + * The protocol request object. + */ + onOwnPropertyNames: function OA_onOwnPropertyNames(aRequest) { + this._forceMagicProperties(); + return { from: this.actorID, + ownPropertyNames: this.obj.getOwnPropertyNames() }; + }, + + /** + * Handle a protocol request to provide the prototype and own properties of + * the object. + * + * @param aRequest object + * The protocol request object. + */ + onPrototypeAndProperties: function OA_onPrototypeAndProperties(aRequest) { + this._forceMagicProperties(); + let ownProperties = Object.create(null); + let names; + try { + names = this.obj.getOwnPropertyNames(); + } catch (ex) { + // The above can throw if this.obj points to a dead object. + // TODO: we should use Cu.isDeadWrapper() - see bug 885800. + return { from: this.actorID, + prototype: this.threadActor.createValueGrip(null), + ownProperties: ownProperties, + safeGetterValues: Object.create(null) }; + } + for (let name of names) { + ownProperties[name] = this._propertyDescriptor(name); + } + return { from: this.actorID, + prototype: this.threadActor.createValueGrip(this.obj.proto), + ownProperties: ownProperties, + safeGetterValues: this._findSafeGetterValues(ownProperties) }; + }, + + /** + * Find the safe getter values for the current Debugger.Object, |this.obj|. + * + * @private + * @param object aOwnProperties + * The object that holds the list of known ownProperties for + * |this.obj|. + * @return object + * An object that maps property names to safe getter descriptors as + * defined by the remote debugging protocol. + */ + _findSafeGetterValues: function OA__findSafeGetterValues(aOwnProperties) + { + let safeGetterValues = Object.create(null); + let obj = this.obj; + let level = 0; + + while (obj) { + let getters = this._findSafeGetters(obj); + for (let name of getters) { + // Avoid overwriting properties from prototypes closer to this.obj. Also + // avoid providing safeGetterValues from prototypes if property |name| + // is already defined as an own property. + if (name in safeGetterValues || + (obj != this.obj && name in aOwnProperties)) { + continue; + } + + let desc = null, getter = null; + try { + desc = obj.getOwnPropertyDescriptor(name); + getter = desc.get; + } catch (ex) { + // The above can throw if the cache becomes stale. + } + if (!getter) { + obj._safeGetters = null; + continue; + } + + let result = getter.call(this.obj); + if (result && !("throw" in result)) { + let getterValue = undefined; + if ("return" in result) { + getterValue = result.return; + } else if ("yield" in result) { + getterValue = result.yield; + } + // WebIDL attributes specified with the LenientThis extended attribute + // return undefined and should be ignored. + if (getterValue !== undefined) { + safeGetterValues[name] = { + getterValue: this.threadActor.createValueGrip(getterValue), + getterPrototypeLevel: level, + enumerable: desc.enumerable, + writable: level == 0 ? desc.writable : true, + }; + } + } + } + + obj = obj.proto; + level++; + } + + return safeGetterValues; + }, + + /** + * Find the safe getters for a given Debugger.Object. Safe getters are native + * getters which are safe to execute. + * + * @private + * @param Debugger.Object aObject + * The Debugger.Object where you want to find safe getters. + * @return Set + * A Set of names of safe getters. This result is cached for each + * Debugger.Object. + */ + _findSafeGetters: function OA__findSafeGetters(aObject) + { + if (aObject._safeGetters) { + return aObject._safeGetters; + } + + let getters = new Set(); + for (let name of aObject.getOwnPropertyNames()) { + let desc = null; + try { + desc = aObject.getOwnPropertyDescriptor(name); + } catch (e) { + // Calling getOwnPropertyDescriptor on wrapped native prototypes is not + // allowed (bug 560072). + } + if (!desc || desc.value !== undefined || !("get" in desc)) { + continue; + } + + let fn = desc.get; + if (fn && fn.callable && fn.class == "Function" && + fn.script === undefined) { + getters.add(name); + } + } + + aObject._safeGetters = getters; + return getters; + }, + + /** + * Handle a protocol request to provide the prototype of the object. + * + * @param aRequest object + * The protocol request object. + */ + onPrototype: function OA_onPrototype(aRequest) { + return { from: this.actorID, + prototype: this.threadActor.createValueGrip(this.obj.proto) }; + }, + + /** + * Handle a protocol request to provide the property descriptor of the + * object's specified property. + * + * @param aRequest object + * The protocol request object. + */ + onProperty: function OA_onProperty(aRequest) { + if (!aRequest.name) { + return { error: "missingParameter", + message: "no property name was specified" }; + } + + return { from: this.actorID, + descriptor: this._propertyDescriptor(aRequest.name) }; + }, + + /** + * Handle a protocol request to provide the display string for the object. + * + * @param aRequest object + * The protocol request object. + */ + onDisplayString: function OA_onDisplayString(aRequest) { + let toString; + try { + // Attempt to locate the object's "toString" method. + let obj = this.obj; + do { + let desc = obj.getOwnPropertyDescriptor("toString"); + if (desc) { + toString = desc.value; + break; + } + obj = obj.proto; + } while ((obj)); + } catch (e) { + dumpn(e); + } + + let result = null; + if (toString && toString.callable) { + // If a toString method was found then call it on the object. + let ret = toString.call(this.obj).return; + if (typeof ret == "string") { + // Only use the result if it was a returned string. + result = ret; + } + } + + return { from: this.actorID, + displayString: this.threadActor.createValueGrip(result) }; + }, + + /** + * A helper method that creates a property descriptor for the provided object, + * properly formatted for sending in a protocol response. + * + * @param string aName + * The property that the descriptor is generated for. + */ + _propertyDescriptor: function OA_propertyDescriptor(aName) { + let desc; + try { + desc = this.obj.getOwnPropertyDescriptor(aName); + } catch (e) { + // Calling getOwnPropertyDescriptor on wrapped native prototypes is not + // allowed (bug 560072). Inform the user with a bogus, but hopefully + // explanatory, descriptor. + return { + configurable: false, + writable: false, + enumerable: false, + value: e.name + }; + } + + if (!desc) { + return undefined; + } + + let retval = { + configurable: desc.configurable, + enumerable: desc.enumerable + }; + + if ("value" in desc) { + retval.writable = desc.writable; + retval.value = this.threadActor.createValueGrip(desc.value); + } else { + if ("get" in desc) { + retval.get = this.threadActor.createValueGrip(desc.get); + } + if ("set" in desc) { + retval.set = this.threadActor.createValueGrip(desc.set); + } + } + return retval; + }, + + /** + * Handle a protocol request to provide the source code of a function. + * + * @param aRequest object + * The protocol request object. + */ + onDecompile: function OA_onDecompile(aRequest) { + if (this.obj.class !== "Function") { + return { error: "objectNotFunction", + message: "decompile request is only valid for object grips " + + "with a 'Function' class." }; + } + + return { from: this.actorID, + decompiledCode: this.obj.decompile(!!aRequest.pretty) }; + }, + + /** + * Handle a protocol request to provide the parameters of a function. + * + * @param aRequest object + * The protocol request object. + */ + onParameterNames: function OA_onParameterNames(aRequest) { + if (this.obj.class !== "Function") { + return { error: "objectNotFunction", + message: "'parameterNames' request is only valid for object " + + "grips with a 'Function' class." }; + } + + return { parameterNames: this.obj.parameterNames }; + }, + + /** + * Handle a protocol request to release a thread-lifetime grip. + * + * @param aRequest object + * The protocol request object. + */ + onRelease: function OA_onRelease(aRequest) { + this.release(); + return {}; + }, + + /** + * Handle a protocol request to provide the lexical scope of a function. + * + * @param aRequest object + * The protocol request object. + */ + onScope: function OA_onScope(aRequest) { + if (this.obj.class !== "Function") { + return { error: "objectNotFunction", + message: "scope request is only valid for object grips with a" + + " 'Function' class." }; + } + + let envActor = this.threadActor.createEnvironmentActor(this.obj.environment, + this.registeredPool); + if (!envActor) { + return { error: "notDebuggee", + message: "cannot access the environment of this function." }; + } + + return { from: this.actorID, scope: envActor.form() }; + } +}; + +ObjectActor.prototype.requestTypes = { + "parameterNames": ObjectActor.prototype.onParameterNames, + "prototypeAndProperties": ObjectActor.prototype.onPrototypeAndProperties, + "prototype": ObjectActor.prototype.onPrototype, + "property": ObjectActor.prototype.onProperty, + "displayString": ObjectActor.prototype.onDisplayString, + "ownPropertyNames": ObjectActor.prototype.onOwnPropertyNames, + "decompile": ObjectActor.prototype.onDecompile, + "release": ObjectActor.prototype.onRelease, + "scope": ObjectActor.prototype.onScope, +}; + + +/** + * Creates a pause-scoped actor for the specified object. + * @see ObjectActor + */ +function PauseScopedObjectActor() +{ + ObjectActor.apply(this, arguments); +} + +PauseScopedObjectActor.prototype = Object.create(PauseScopedActor.prototype); + +update(PauseScopedObjectActor.prototype, ObjectActor.prototype); + +update(PauseScopedObjectActor.prototype, { + constructor: PauseScopedObjectActor, + actorPrefix: "pausedobj", + + onOwnPropertyNames: + PauseScopedActor.withPaused(ObjectActor.prototype.onOwnPropertyNames), + + onPrototypeAndProperties: + PauseScopedActor.withPaused(ObjectActor.prototype.onPrototypeAndProperties), + + onPrototype: PauseScopedActor.withPaused(ObjectActor.prototype.onPrototype), + onProperty: PauseScopedActor.withPaused(ObjectActor.prototype.onProperty), + onDecompile: PauseScopedActor.withPaused(ObjectActor.prototype.onDecompile), + + onDisplayString: + PauseScopedActor.withPaused(ObjectActor.prototype.onDisplayString), + + onParameterNames: + PauseScopedActor.withPaused(ObjectActor.prototype.onParameterNames), + + /** + * Handle a protocol request to promote a pause-lifetime grip to a + * thread-lifetime grip. + * + * @param aRequest object + * The protocol request object. + */ + onThreadGrip: PauseScopedActor.withPaused(function OA_onThreadGrip(aRequest) { + this.threadActor.threadObjectGrip(this); + return {}; + }), + + /** + * Handle a protocol request to release a thread-lifetime grip. + * + * @param aRequest object + * The protocol request object. + */ + onRelease: PauseScopedActor.withPaused(function OA_onRelease(aRequest) { + if (this.registeredPool !== this.threadActor.threadLifetimePool) { + return { error: "notReleasable", + message: "Only thread-lifetime actors can be released." }; + } + + this.release(); + return {}; + }), +}); + +update(PauseScopedObjectActor.prototype.requestTypes, { + "threadGrip": PauseScopedObjectActor.prototype.onThreadGrip, +}); + + +/** + * Creates an actor for the specied "very long" string. "Very long" is specified + * at the server's discretion. + * + * @param aString String + * The string. + */ +function LongStringActor(aString) +{ + this.string = aString; + this.stringLength = aString.length; +} + +LongStringActor.prototype = { + + actorPrefix: "longString", + + disconnect: function LSA_disconnect() { + // Because longStringActors is not a weak map, we won't automatically leave + // it so we need to manually leave on disconnect so that we don't leak + // memory. + if (this.registeredPool && this.registeredPool.longStringActors) { + delete this.registeredPool.longStringActors[this.actorID]; + } + }, + + /** + * Returns a grip for this actor for returning in a protocol message. + */ + grip: function LSA_grip() { + return { + "type": "longString", + "initial": this.string.substring( + 0, DebuggerServer.LONG_STRING_INITIAL_LENGTH), + "length": this.stringLength, + "actor": this.actorID + }; + }, + + /** + * Handle a request to extract part of this actor's string. + * + * @param aRequest object + * The protocol request object. + */ + onSubstring: function LSA_onSubString(aRequest) { + return { + "from": this.actorID, + "substring": this.string.substring(aRequest.start, aRequest.end) + }; + }, + + /** + * Handle a request to release this LongStringActor instance. + */ + onRelease: function LSA_onRelease() { + // TODO: also check if registeredPool === threadActor.threadLifetimePool + // when the web console moves aray from manually releasing pause-scoped + // actors. + if (this.registeredPool.longStringActors) { + delete this.registeredPool.longStringActors[this.actorID]; + } + this.registeredPool.removeActor(this); + return {}; + }, +}; + +LongStringActor.prototype.requestTypes = { + "substring": LongStringActor.prototype.onSubstring, + "release": LongStringActor.prototype.onRelease +}; + + +/** + * Creates an actor for the specified stack frame. + * + * @param aFrame Debugger.Frame + * The debuggee frame. + * @param aThreadActor ThreadActor + * The parent thread actor for this frame. + */ +function FrameActor(aFrame, aThreadActor) +{ + this.frame = aFrame; + this.threadActor = aThreadActor; +} + +FrameActor.prototype = { + actorPrefix: "frame", + + /** + * A pool that contains frame-lifetime objects, like the environment. + */ + _frameLifetimePool: null, + get frameLifetimePool() { + if (!this._frameLifetimePool) { + this._frameLifetimePool = new ActorPool(this.conn); + this.conn.addActorPool(this._frameLifetimePool); + } + return this._frameLifetimePool; + }, + + /** + * Finalization handler that is called when the actor is being evicted from + * the pool. + */ + disconnect: function FA_disconnect() { + this.conn.removeActorPool(this._frameLifetimePool); + this._frameLifetimePool = null; + }, + + /** + * Returns a frame form for use in a protocol message. + */ + form: function FA_form() { + let form = { actor: this.actorID, + type: this.frame.type }; + if (this.frame.type === "call") { + form.callee = this.threadActor.createValueGrip(this.frame.callee); + } + + if (this.frame.environment) { + let envActor = this.threadActor + .createEnvironmentActor(this.frame.environment, + this.frameLifetimePool); + form.environment = envActor.form(); + } + form.this = this.threadActor.createValueGrip(this.frame.this); + form.arguments = this._args(); + if (this.frame.script) { + form.where = getFrameLocation(this.frame); + } + + if (!this.frame.older) { + form.oldest = true; + } + + return form; + }, + + _args: function FA__args() { + if (!this.frame.arguments) { + return []; + } + + return [this.threadActor.createValueGrip(arg) + for each (arg in this.frame.arguments)]; + }, + + /** + * Handle a protocol request to pop this frame from the stack. + * + * @param aRequest object + * The protocol request object. + */ + onPop: function FA_onPop(aRequest) { + // TODO: remove this when Debugger.Frame.prototype.pop is implemented + if (typeof this.frame.pop != "function") { + return { error: "notImplemented", + message: "Popping frames is not yet implemented." }; + } + + while (this.frame != this.threadActor.dbg.getNewestFrame()) { + this.threadActor.dbg.getNewestFrame().pop(); + } + this.frame.pop(aRequest.completionValue); + + // TODO: return the watches property when frame pop watch actors are + // implemented. + return { from: this.actorID }; + } +}; + +FrameActor.prototype.requestTypes = { + "pop": FrameActor.prototype.onPop, +}; + + +/** + * Creates a BreakpointActor. BreakpointActors exist for the lifetime of their + * containing thread and are responsible for deleting breakpoints, handling + * breakpoint hits and associating breakpoints with scripts. + * + * @param ThreadActor aThreadActor + * The parent thread actor that contains this breakpoint. + * @param object aLocation + * The location of the breakpoint as specified in the protocol. + */ +function BreakpointActor(aThreadActor, aLocation) +{ + this.scripts = []; + this.threadActor = aThreadActor; + this.location = aLocation; +} + +BreakpointActor.prototype = { + actorPrefix: "breakpoint", + + /** + * Called when this same breakpoint is added to another Debugger.Script + * instance, in the case of a page reload. + * + * @param aScript Debugger.Script + * The new source script on which the breakpoint has been set. + * @param ThreadActor aThreadActor + * The parent thread actor that contains this breakpoint. + */ + addScript: function BA_addScript(aScript, aThreadActor) { + this.threadActor = aThreadActor; + this.scripts.push(aScript); + }, + + /** + * Remove the breakpoints from associated scripts and clear the script cache. + */ + removeScripts: function () { + for (let script of this.scripts) { + script.clearBreakpoint(this); + } + this.scripts = []; + }, + + /** + * A function that the engine calls when a breakpoint has been hit. + * + * @param aFrame Debugger.Frame + * The stack frame that contained the breakpoint. + */ + hit: function BA_hit(aFrame) { + // Don't pause if we are currently stepping (in or over) or the frame is + // black-boxed. + let { url } = this.threadActor.synchronize( + this.threadActor.sources.getOriginalLocation({ + url: this.location.url, + line: this.location.line, + column: this.location.column + })); + + if (this.threadActor.sources.isBlackBoxed(url) || aFrame.onStep) { + return undefined; + } + + let reason = {}; + if (this.threadActor._hiddenBreakpoints.has(this.actorID)) { + reason.type = "pauseOnDOMEvents"; + } else { + reason.type = "breakpoint"; + // TODO: add the rest of the breakpoints on that line (bug 676602). + reason.actors = [ this.actorID ]; + } + return this.threadActor._pauseAndRespond(aFrame, reason); + }, + + /** + * Handle a protocol request to remove this breakpoint. + * + * @param aRequest object + * The protocol request object. + */ + onDelete: function BA_onDelete(aRequest) { + // Remove from the breakpoint store. + this.threadActor.breakpointStore.removeBreakpoint(this.location); + this.threadActor._hooks.removeFromParentPool(this); + // Remove the actual breakpoint from the associated scripts. + this.removeScripts(); + return { from: this.actorID }; + } +}; + +BreakpointActor.prototype.requestTypes = { + "delete": BreakpointActor.prototype.onDelete +}; + + +/** + * Creates an EnvironmentActor. EnvironmentActors are responsible for listing + * the bindings introduced by a lexical environment and assigning new values to + * those identifier bindings. + * + * @param Debugger.Environment aEnvironment + * The lexical environment that will be used to create the actor. + * @param ThreadActor aThreadActor + * The parent thread actor that contains this environment. + */ +function EnvironmentActor(aEnvironment, aThreadActor) +{ + this.obj = aEnvironment; + this.threadActor = aThreadActor; +} + +EnvironmentActor.prototype = { + actorPrefix: "environment", + + /** + * Return an environment form for use in a protocol message. + */ + form: function EA_form() { + let form = { actor: this.actorID }; + + // What is this environment's type? + if (this.obj.type == "declarative") { + form.type = this.obj.callee ? "function" : "block"; + } else { + form.type = this.obj.type; + } + + // Does this environment have a parent? + if (this.obj.parent) { + form.parent = (this.threadActor + .createEnvironmentActor(this.obj.parent, + this.registeredPool) + .form()); + } + + // Does this environment reflect the properties of an object as variables? + if (this.obj.type == "object" || this.obj.type == "with") { + form.object = this.threadActor.createValueGrip(this.obj.object); + } + + // Is this the environment created for a function call? + if (this.obj.callee) { + form.function = this.threadActor.createValueGrip(this.obj.callee); + } + + // Shall we list this environment's bindings? + if (this.obj.type == "declarative") { + form.bindings = this._bindings(); + } + + return form; + }, + + /** + * Return the identifier bindings object as required by the remote protocol + * specification. + */ + _bindings: function EA_bindings() { + let bindings = { arguments: [], variables: {} }; + + // TODO: this part should be removed in favor of the commented-out part + // below when getVariableDescriptor lands (bug 725815). + if (typeof this.obj.getVariable != "function") { + //if (typeof this.obj.getVariableDescriptor != "function") { + return bindings; + } + + let parameterNames; + if (this.obj.callee) { + parameterNames = this.obj.callee.parameterNames; + } + for each (let name in parameterNames) { + let arg = {}; + // TODO: this part should be removed in favor of the commented-out part + // below when getVariableDescriptor lands (bug 725815). + let desc = { + value: this.obj.getVariable(name), + configurable: false, + writable: true, + enumerable: true + }; + + // let desc = this.obj.getVariableDescriptor(name); + let descForm = { + enumerable: true, + configurable: desc.configurable + }; + if ("value" in desc) { + descForm.value = this.threadActor.createValueGrip(desc.value); + descForm.writable = desc.writable; + } else { + descForm.get = this.threadActor.createValueGrip(desc.get); + descForm.set = this.threadActor.createValueGrip(desc.set); + } + arg[name] = descForm; + bindings.arguments.push(arg); + } + + for each (let name in this.obj.names()) { + if (bindings.arguments.some(function exists(element) { + return !!element[name]; + })) { + continue; + } + + // TODO: this part should be removed in favor of the commented-out part + // below when getVariableDescriptor lands. + let desc = { + configurable: false, + writable: true, + enumerable: true + }; + try { + desc.value = this.obj.getVariable(name); + } catch (e) { + // Avoid "Debugger scope is not live" errors for |arguments|, introduced + // in bug 746601. + if (name != "arguments") { + throw e; + } + } + //let desc = this.obj.getVariableDescriptor(name); + let descForm = { + enumerable: true, + configurable: desc.configurable + }; + if ("value" in desc) { + descForm.value = this.threadActor.createValueGrip(desc.value); + descForm.writable = desc.writable; + } else { + descForm.get = this.threadActor.createValueGrip(desc.get); + descForm.set = this.threadActor.createValueGrip(desc.set); + } + bindings.variables[name] = descForm; + } + + return bindings; + }, + + /** + * Handle a protocol request to change the value of a variable bound in this + * lexical environment. + * + * @param aRequest object + * The protocol request object. + */ + onAssign: function EA_onAssign(aRequest) { + // TODO: enable the commented-out part when getVariableDescriptor lands + // (bug 725815). + /*let desc = this.obj.getVariableDescriptor(aRequest.name); + + if (!desc.writable) { + return { error: "immutableBinding", + message: "Changing the value of an immutable binding is not " + + "allowed" }; + }*/ + + try { + this.obj.setVariable(aRequest.name, aRequest.value); + } catch (e if e instanceof Debugger.DebuggeeWouldRun) { + return { error: "threadWouldRun", + cause: e.cause ? e.cause : "setter", + message: "Assigning a value would cause the debuggee to run" }; + } + return { from: this.actorID }; + }, + + /** + * Handle a protocol request to fully enumerate the bindings introduced by the + * lexical environment. + * + * @param aRequest object + * The protocol request object. + */ + onBindings: function EA_onBindings(aRequest) { + return { from: this.actorID, + bindings: this._bindings() }; + } +}; + +EnvironmentActor.prototype.requestTypes = { + "assign": EnvironmentActor.prototype.onAssign, + "bindings": EnvironmentActor.prototype.onBindings +}; + +/** + * Override the toString method in order to get more meaningful script output + * for debugging the debugger. + */ +Debugger.Script.prototype.toString = function() { + let output = ""; + if (this.url) { + output += this.url; + } + if (typeof this.startLine != "undefined") { + output += ":" + this.startLine; + if (this.lineCount && this.lineCount > 1) { + output += "-" + (this.startLine + this.lineCount - 1); + } + } + if (this.strictMode) { + output += ":strict"; + } + return output; +}; + +/** + * Helper property for quickly getting to the line number a stack frame is + * currently paused at. + */ +Object.defineProperty(Debugger.Frame.prototype, "line", { + configurable: true, + get: function() { + if (this.script) { + return this.script.getOffsetLine(this.offset); + } else { + return null; + } + } +}); + + +/** + * Creates an actor for handling chrome debugging. ChromeDebuggerActor is a + * thin wrapper over ThreadActor, slightly changing some of its behavior. + * + * @param aConnection object + * The DebuggerServerConnection with which this ChromeDebuggerActor + * is associated. (Currently unused, but required to make this + * constructor usable with addGlobalActor.) + * + * @param aHooks object + * An object with preNest and postNest methods for calling when entering + * and exiting a nested event loop and also addToParentPool and + * removeFromParentPool methods for handling the lifetime of actors that + * will outlive the thread, like breakpoints. + */ +function ChromeDebuggerActor(aConnection, aHooks) +{ + ThreadActor.call(this, aHooks); +} + +ChromeDebuggerActor.prototype = Object.create(ThreadActor.prototype); + +update(ChromeDebuggerActor.prototype, { + constructor: ChromeDebuggerActor, + + // A constant prefix that will be used to form the actor ID by the server. + actorPrefix: "chromeDebugger", + + /** + * Override the eligibility check for scripts and sources to make sure every + * script and source with a URL is stored when debugging chrome. + */ + _allowSource: function(aSourceURL) !!aSourceURL, + + /** + * An object that will be used by ThreadActors to tailor their behavior + * depending on the debugging context being required (chrome or content). + * The methods that this object provides must be bound to the ThreadActor + * before use. + */ + globalManager: { + findGlobals: function CDA_findGlobals() { + // Add every global known to the debugger as debuggee. + this.dbg.addAllGlobalsAsDebuggees(); + }, + + /** + * A function that the engine calls when a new global object has been + * created. + * + * @param aGlobal Debugger.Object + * The new global object that was created. + */ + onNewGlobal: function CDA_onNewGlobal(aGlobal) { + this.addDebuggee(aGlobal); + // Notify the client. + this.conn.send({ + from: this.actorID, + type: "newGlobal", + // TODO: after bug 801084 lands see if we need to JSONify this. + hostAnnotations: aGlobal.hostAnnotations + }); + } + } +}); + + +/** + * Manages the sources for a thread. Handles source maps, locations in the + * sources, etc for ThreadActors. + */ +function ThreadSources(aThreadActor, aUseSourceMaps, aAllowPredicate, + aOnNewSource) { + this._thread = aThreadActor; + this._useSourceMaps = aUseSourceMaps; + this._allow = aAllowPredicate; + this._onNewSource = aOnNewSource; + + // generated source url --> promise of SourceMapConsumer + this._sourceMapsByGeneratedSource = Object.create(null); + // original source url --> promise of SourceMapConsumer + this._sourceMapsByOriginalSource = Object.create(null); + // source url --> SourceActor + this._sourceActors = Object.create(null); + // original url --> generated url + this._generatedUrlsByOriginalUrl = Object.create(null); +} + +/** + * Must be a class property because it needs to persist across reloads, same as + * the breakpoint store. + */ +ThreadSources._blackBoxedSources = new Set(["self-hosted"]); +ThreadSources._prettyPrintedSources = new Map(); + +ThreadSources.prototype = { + /** + * Return the source actor representing |url|, creating one if none + * exists already. Returns null if |url| is not allowed by the 'allow' + * predicate. + * + * Right now this takes a URL, but in the future it should + * take a Debugger.Source. See bug 637572. + * + * @param String url + * The source URL. + * @param optional SourceMapConsumer sourceMap + * The source map that introduced this source, if any. + * @param optional String generatedSource + * The generated source url that introduced this source via source map, + * if any. + * @param optional String text + * The text content of the source, if immediately available. + * @param optional String contentType + * The content type of the source, if immediately available. + * @returns a SourceActor representing the source at aURL or null. + */ + source: function TS_source({ url, sourceMap, generatedSource, text, + contentType }) { + if (!this._allow(url)) { + return null; + } + + if (url in this._sourceActors) { + return this._sourceActors[url]; + } + + let actor = new SourceActor({ + url: url, + thread: this._thread, + sourceMap: sourceMap, + generatedSource: generatedSource, + text: text, + contentType: contentType + }); + this._thread.threadLifetimePool.addActor(actor); + this._sourceActors[url] = actor; + try { + this._onNewSource(actor); + } catch (e) { + reportError(e); + } + return actor; + }, + + /** + * Only to be used when we aren't source mapping. + */ + _sourceForScript: function TS__sourceForScript(aScript) { + const spec = { + url: aScript.url + }; + + // XXX bug 915433: We can't rely on Debugger.Source.prototype.text if the + // source is an HTML-embedded + + + + + diff --git a/templates/js-template-default/main.js b/templates/js-template-default/main.js new file mode 100644 index 0000000000..95f14b8224 --- /dev/null +++ b/templates/js-template-default/main.js @@ -0,0 +1,67 @@ +/** + * A brief explanation for "project.json": + * Here is the content of project.json file, this is the global configuration for your game, you can modify it to customize some behavior. + * The detail of each field is under it. + { + "project_type": "javascript", + // "project_type" indicate the program language of your project, you can ignore this field + + "debugMode" : 1, + // "debugMode" possible values : + // 0 - No message will be printed. + // 1 - cc.error, cc.assert, cc.warn, cc.log will print in console. + // 2 - cc.error, cc.assert, cc.warn will print in console. + // 3 - cc.error, cc.assert will print in console. + // 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web. + // 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web. + // 6 - cc.error, cc.assert will print on canvas, available only on web. + + "showFPS" : true, + // Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide. + + "frameRate" : 60, + // "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment. + + "id" : "gameCanvas", + // "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web. + + "renderMode" : 0, + // "renderMode" sets the renderer type, only useful on web : + // 0 - Automatically chosen by engine + // 1 - Forced to use canvas renderer + // 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers + + "engineDir" : "frameworks/cocos2d-html5/", + // In debug mode, if you use the whole engine to develop your game, you should specify its relative path with "engineDir", + // but if you are using a single engine file, you can ignore it. + + "modules" : ["cocos2d"], + // "modules" defines which modules you will need in your game, it's useful only on web, + // using this can greatly reduce your game's resource size, and the cocos console tool can package your game with only the modules you set. + // For details about modules definitions, you can refer to "../../frameworks/cocos2d-html5/modulesConfig.json". + + "jsList" : [ + ] + // "jsList" sets the list of js files in your game. + } + * + */ + +cc.game.onStart = function(){ + if(!cc.sys.isNative && document.getElementById("cocosLoading")) //If referenced loading.js, please remove it + document.body.removeChild(document.getElementById("cocosLoading")); + + // Pass true to enable retina display, disabled by default to improve performance + cc.view.enableRetina(false); + // Adjust viewport meta + cc.view.adjustViewPort(true); + // Setup the resolution policy and design resolution size + cc.view.setDesignResolutionSize(800, 450, cc.ResolutionPolicy.SHOW_ALL); + // The game will be resized when browser size change + cc.view.resizeWithBrowserSize(true); + //load resources + cc.LoaderScene.preload(g_resources, function () { + cc.director.runScene(new HelloWorldScene()); + }, this); +}; +cc.game.run(); \ No newline at end of file diff --git a/templates/js-template-default/manifest.webapp b/templates/js-template-default/manifest.webapp new file mode 100644 index 0000000000..e9ecf73f0b --- /dev/null +++ b/templates/js-template-default/manifest.webapp @@ -0,0 +1,19 @@ +{ + "version": "1.0", + "name": "HelloJavascript", + "description": "HelloJavascript", + "launch_path": "/index.html", + "icons": { + "128": "/res/icon.png" + }, + "developer": { + "name": "Cocos2d-html5", + "url": "http://cocos2d-x.org/" + }, + "default_locale": "en", + "installs_allowed_from": [ + "*" + ], + "orientation": "portrait-primary", + "fullscreen": "true" +} diff --git a/templates/js-template-default/project.json b/templates/js-template-default/project.json new file mode 100644 index 0000000000..e54f870660 --- /dev/null +++ b/templates/js-template-default/project.json @@ -0,0 +1,17 @@ +{ + "project_type": "javascript", + + "debugMode" : 1, + "showFPS" : true, + "frameRate" : 60, + "id" : "gameCanvas", + "renderMode" : 0, + "engineDir":"frameworks/cocos2d-html5", + + "modules" : ["cocos2d"], + + "jsList" : [ + "src/resource.js", + "src/app.js" + ] +} diff --git a/templates/js-template-default/res/CloseNormal.png b/templates/js-template-default/res/CloseNormal.png new file mode 100644 index 0000000000..5657a13b58 Binary files /dev/null and b/templates/js-template-default/res/CloseNormal.png differ diff --git a/templates/js-template-default/res/CloseSelected.png b/templates/js-template-default/res/CloseSelected.png new file mode 100644 index 0000000000..e4c82da775 Binary files /dev/null and b/templates/js-template-default/res/CloseSelected.png differ diff --git a/templates/js-template-default/res/HelloWorld.png b/templates/js-template-default/res/HelloWorld.png new file mode 100644 index 0000000000..3a20f2538a Binary files /dev/null and b/templates/js-template-default/res/HelloWorld.png differ diff --git a/templates/js-template-default/res/favicon.ico b/templates/js-template-default/res/favicon.ico new file mode 100644 index 0000000000..1ad6a0907b Binary files /dev/null and b/templates/js-template-default/res/favicon.ico differ diff --git a/templates/js-template-default/res/loading.js b/templates/js-template-default/res/loading.js new file mode 100644 index 0000000000..d17a700344 --- /dev/null +++ b/templates/js-template-default/res/loading.js @@ -0,0 +1 @@ +(function(){var createStyle=function(){return".cocosLoading{position:absolute;margin:-30px -60px;padding:0;top:50%;left:50%}"+".cocosLoading ul{margin:0;padding:0;}"+".cocosLoading span{color:#FFF;text-align:center;display:block;}"+".cocosLoading li{list-style:none;float:left;border-radius:15px;width:15px;height:15px;background:#FFF;margin:5px 0 0 10px}"+".cocosLoading li .ball,.cocosLoading li .unball{background-color:#2187e7;background-image:-moz-linear-gradient(90deg,#2187e7 25%,#a0eaff);background-image:-webkit-linear-gradient(90deg,#2187e7 25%,#a0eaff);width:15px;height:15px;border-radius:50px}"+".cocosLoading li .ball{transform:scale(0);-moz-transform:scale(0);-webkit-transform:scale(0);animation:showDot 1s linear forwards;-moz-animation:showDot 1s linear forwards;-webkit-animation:showDot 1s linear forwards}"+".cocosLoading li .unball{transform:scale(1);-moz-transform:scale(1);-webkit-transform:scale(1);animation:hideDot 1s linear forwards;-moz-animation:hideDot 1s linear forwards;-webkit-animation:hideDot 1s linear forwards}"+"@keyframes showDot{0%{transform:scale(0,0)}100%{transform:scale(1,1)}}"+"@-moz-keyframes showDot{0%{-moz-transform:scale(0,0)}100%{-moz-transform:scale(1,1)}}"+"@-webkit-keyframes showDot{0%{-webkit-transform:scale(0,0)}100%{-webkit-transform:scale(1,1)}}"+"@keyframes hideDot{0%{transform:scale(1,1)}100%{transform:scale(0,0)}}"+"@-moz-keyframes hideDot{0%{-moz-transform:scale(1,1)}100%{-moz-transform:scale(0,0)}}"+"@-webkit-keyframes hideDot{0%{-webkit-transform:scale(1,1)}100%{-webkit-transform:scale(0,0)}}"};var createDom=function(id,num){id=id||"cocosLoading";num=num||5;var i,item;var div=document.createElement("div");div.className="cocosLoading";div.id=id;var bar=document.createElement("ul");var list=[];for(i=0;i=list.length){direction=!direction;index=0;time=1000}else{time=300}animation()},time)};animation()};(function(){var bgColor=document.body.style.background;document.body.style.background="#000";var style=document.createElement("style");style.type="text/css";style.innerHTML=createStyle();document.head.appendChild(style);var list=createDom();startAnimation(list,function(){var div=document.getElementById("cocosLoading");if(!div){document.body.style.background=bgColor}return !!div})})()})(); \ No newline at end of file diff --git a/templates/js-template-default/src/app.js b/templates/js-template-default/src/app.js new file mode 100644 index 0000000000..8df4e42ce8 --- /dev/null +++ b/templates/js-template-default/src/app.js @@ -0,0 +1,78 @@ + +var HelloWorldLayer = cc.Layer.extend({ + sprite:null, + ctor:function () { + ////////////////////////////// + // 1. super init first + this._super(); + + ///////////////////////////// + // 2. add a menu item with "X" image, which is clicked to quit the program + // you may modify it. + // ask the window size + var size = cc.winSize; + + // add a "close" icon to exit the progress. it's an autorelease object + var closeItem = new cc.MenuItemImage( + res.CloseNormal_png, + res.CloseSelected_png, + function () { + cc.log("Menu is clicked!"); + }, this); + closeItem.attr({ + x: size.width - 20, + y: 20, + anchorX: 0.5, + anchorY: 0.5 + }); + + var menu = new cc.Menu(closeItem); + menu.x = 0; + menu.y = 0; + this.addChild(menu, 1); + + ///////////////////////////// + // 3. add your codes below... + // add a label shows "Hello World" + // create and initialize a label + var helloLabel = new cc.LabelTTF("Hello World", "Arial", 38); + // position the label on the center of the screen + helloLabel.x = size.width / 2; + helloLabel.y = 0; + // add the label as a child to this layer + this.addChild(helloLabel, 5); + + // add "HelloWorld" splash screen" + this.sprite = new cc.Sprite(res.HelloWorld_png); + this.sprite.attr({ + x: size.width / 2, + y: size.height / 2, + scale: 0.5, + rotation: 180 + }); + this.addChild(this.sprite, 0); + + this.sprite.runAction( + cc.sequence( + cc.rotateTo(2, 0), + cc.scaleTo(2, 1, 1) + ) + ); + helloLabel.runAction( + cc.spawn( + cc.moveBy(2.5, cc.p(0, size.height - 40)), + cc.tintTo(2.5,255,125,0) + ) + ); + return true; + } +}); + +var HelloWorldScene = cc.Scene.extend({ + onEnter:function () { + this._super(); + var layer = new HelloWorldLayer(); + this.addChild(layer); + } +}); + diff --git a/templates/js-template-default/src/resource.js b/templates/js-template-default/src/resource.js new file mode 100644 index 0000000000..4438ab1b86 --- /dev/null +++ b/templates/js-template-default/src/resource.js @@ -0,0 +1,10 @@ +var res = { + HelloWorld_png : "res/HelloWorld.png", + CloseNormal_png : "res/CloseNormal.png", + CloseSelected_png : "res/CloseSelected.png" +}; + +var g_resources = []; +for (var i in res) { + g_resources.push(res[i]); +} \ No newline at end of file diff --git a/templates/lua-template-default/frameworks/CMakeLists.txt b/templates/lua-template-default/frameworks/CMakeLists.txt index 9f43fc9529..9e0621aba5 100644 --- a/templates/lua-template-default/frameworks/CMakeLists.txt +++ b/templates/lua-template-default/frameworks/CMakeLists.txt @@ -45,6 +45,7 @@ endif(DEBUG_MODE) # libcocos2d set(BUILD_CPP_TESTS OFF CACHE BOOL "turn off build cpp-tests") set(BUILD_LUA_TESTS OFF CACHE BOOL "turn off build lua-tests") +set(BUILD_JS_LIBS OFF CACHE BOOL "turn off build js releated targets") add_subdirectory(${COCOS2D_ROOT}) diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj b/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj index d20fd7ce2e..7a7c05a379 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj +++ b/templates/lua-template-default/frameworks/runtime-src/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj @@ -191,7 +191,7 @@ 5023811517EBBCAC00990C9B /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; 5023811617EBBCAC00990C9B /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; 5023811717EBBCAC00990C9B /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; - 5023816B17EBBCE400990C9B /* HelloLua Mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "HelloLua Mac.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 5023816B17EBBCE400990C9B /* HelloLua-desktop.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "HelloLua-desktop.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 5023817217EBBE3400990C9B /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; }; 5023817317EBBE3400990C9B /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 5023817517EBBE3400990C9B /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; @@ -232,7 +232,7 @@ C07828F718B4D72E00BD2287 /* SimulatorApp.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SimulatorApp.mm; sourceTree = ""; }; D6B061341803AC000077942B /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/CoreMotion.framework; sourceTree = DEVELOPER_DIR; }; DA9E7D871AB1ABCC004B27C8 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; - F293B3C815EB7BE500256477 /* HelloLua iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "HelloLua iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + F293B3C815EB7BE500256477 /* HelloLua-mobile.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "HelloLua-mobile.app"; sourceTree = BUILT_PRODUCTS_DIR; }; F293B3CC15EB7BE500256477 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; F293B3CE15EB7BE500256477 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; F293B3D015EB7BE500256477 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; @@ -410,8 +410,8 @@ F293B3C915EB7BE500256477 /* Products */ = { isa = PBXGroup; children = ( - F293B3C815EB7BE500256477 /* HelloLua iOS.app */, - 5023816B17EBBCE400990C9B /* HelloLua Mac.app */, + F293B3C815EB7BE500256477 /* HelloLua-mobile.app */, + 5023816B17EBBCE400990C9B /* HelloLua-desktop.app */, ); name = Products; sourceTree = ""; @@ -469,9 +469,9 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 5023812617EBBCE400990C9B /* HelloLua Mac */ = { + 5023812617EBBCE400990C9B /* HelloLua-desktop */ = { isa = PBXNativeTarget; - buildConfigurationList = 5023816817EBBCE400990C9B /* Build configuration list for PBXNativeTarget "HelloLua Mac" */; + buildConfigurationList = 5023816817EBBCE400990C9B /* Build configuration list for PBXNativeTarget "HelloLua-desktop" */; buildPhases = ( 5023813117EBBCE400990C9B /* Sources */, 5023813617EBBCE400990C9B /* Frameworks */, @@ -485,14 +485,14 @@ 152A34B9199CE758004B68DC /* PBXTargetDependency */, C0A2F04118975FF80072A7AB /* PBXTargetDependency */, ); - name = "HelloLua Mac"; + name = "HelloLua-desktop"; productName = HelloLua; - productReference = 5023816B17EBBCE400990C9B /* HelloLua Mac.app */; + productReference = 5023816B17EBBCE400990C9B /* HelloLua-desktop.app */; productType = "com.apple.product-type.application"; }; - F293B3C715EB7BE500256477 /* HelloLua iOS */ = { + F293B3C715EB7BE500256477 /* HelloLua-mobile */ = { isa = PBXNativeTarget; - buildConfigurationList = F293B6C415EB7BEA00256477 /* Build configuration list for PBXNativeTarget "HelloLua iOS" */; + buildConfigurationList = F293B6C415EB7BEA00256477 /* Build configuration list for PBXNativeTarget "HelloLua-mobile" */; buildPhases = ( F293B3C415EB7BE500256477 /* Sources */, F293B3C515EB7BE500256477 /* Frameworks */, @@ -506,9 +506,9 @@ 152A349F199CE72E004B68DC /* PBXTargetDependency */, 15D1F3091994BBCA00302043 /* PBXTargetDependency */, ); - name = "HelloLua iOS"; + name = "HelloLua-mobile"; productName = HelloLua; - productReference = F293B3C815EB7BE500256477 /* HelloLua iOS.app */; + productReference = F293B3C815EB7BE500256477 /* HelloLua-mobile.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -552,8 +552,8 @@ ); projectRoot = ""; targets = ( - F293B3C715EB7BE500256477 /* HelloLua iOS */, - 5023812617EBBCE400990C9B /* HelloLua Mac */, + F293B3C715EB7BE500256477 /* HelloLua-mobile */, + 5023812617EBBCE400990C9B /* HelloLua-desktop */, ); }; /* End PBXProject section */ @@ -946,7 +946,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 5023816817EBBCE400990C9B /* Build configuration list for PBXNativeTarget "HelloLua Mac" */ = { + 5023816817EBBCE400990C9B /* Build configuration list for PBXNativeTarget "HelloLua-desktop" */ = { isa = XCConfigurationList; buildConfigurations = ( 5023816917EBBCE400990C9B /* Debug */, @@ -964,7 +964,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - F293B6C415EB7BEA00256477 /* Build configuration list for PBXNativeTarget "HelloLua iOS" */ = { + F293B6C415EB7BEA00256477 /* Build configuration list for PBXNativeTarget "HelloLua-mobile" */ = { isa = XCConfigurationList; buildConfigurations = ( F293B6C515EB7BEA00256477 /* Debug */, diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.win32/HelloLua.sln b/templates/lua-template-default/frameworks/runtime-src/proj.win32/HelloLua.sln index 07902498c9..d7ef682815 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.win32/HelloLua.sln +++ b/templates/lua-template-default/frameworks/runtime-src/proj.win32/HelloLua.sln @@ -1,8 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio 2013 VisualStudioVersion = 12.0.30501.0 -MinimumVisualStudioVersion = 10.0.40219.1 +MinimumVisualStudioVersion = 12.0.21005.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloLua", "HelloLua.vcxproj", "{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}" ProjectSection(ProjectDependencies) = postProject {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.win32/HelloLua.vcxproj b/templates/lua-template-default/frameworks/runtime-src/proj.win32/HelloLua.vcxproj index 8b4eaaa1d1..c27fd7f6c1 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.win32/HelloLua.vcxproj +++ b/templates/lua-template-default/frameworks/runtime-src/proj.win32/HelloLua.vcxproj @@ -19,18 +19,14 @@ Application true Unicode - v110 v120 - v110_xp v120_xp Application false Unicode - v110 v120 - v110_xp v120_xp diff --git a/tests/cpp-empty-test/.cocos-project.json b/tests/cpp-empty-test/.cocos-project.json index 0c934452c6..97103e9e8f 100644 --- a/tests/cpp-empty-test/.cocos-project.json +++ b/tests/cpp-empty-test/.cocos-project.json @@ -1,7 +1,7 @@ { "win32_cfg": { "project_path": "../../build", - "sln_file": "cocos2d-win32.vc2012.sln", + "sln_file": "cocos2d-win32.vc2013.sln", "project_name": "cpp-empty-test", "build_cfg_path": "proj.win32" }, @@ -26,14 +26,6 @@ "android_cfg": { "project_path": "proj.android" }, - "wp8_cfg" : { - "project_path": "../../build", - "sln_file": "cocos2d-wp8.sln", - "project_name": "cpp-empty-test", - "wp8_proj_path" : "proj-wp8-xaml", - "build_folder_path": "cpp-empty-test/Bin/x86", - "manifest_path": "cpp-empty-test/Properties/WMAppManifest.xml" - }, "wp8_1_cfg" : { "project_path": "../../build", "sln_file": "cocos2d-win8.1-universal.sln", diff --git a/tests/cpp-empty-test/Classes/AppDelegate.cpp b/tests/cpp-empty-test/Classes/AppDelegate.cpp index b1208d79f5..740b147211 100644 --- a/tests/cpp-empty-test/Classes/AppDelegate.cpp +++ b/tests/cpp-empty-test/Classes/AppDelegate.cpp @@ -36,12 +36,7 @@ bool AppDelegate::applicationDidFinishLaunching() { director->setOpenGLView(glview); // Set the design resolution -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) - // a bug in DirectX 11 level9-x on the device prevents ResolutionPolicy::NO_BORDER from working correctly - glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::SHOW_ALL); -#else glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER); -#endif Size frameSize = glview->getFrameSize(); diff --git a/tests/cpp-empty-test/proj.win32/cpp-empty-test.vcxproj b/tests/cpp-empty-test/proj.win32/cpp-empty-test.vcxproj index 6d6907763d..d2bfe579f3 100644 --- a/tests/cpp-empty-test/proj.win32/cpp-empty-test.vcxproj +++ b/tests/cpp-empty-test/proj.win32/cpp-empty-test.vcxproj @@ -20,18 +20,12 @@ Application Unicode true - v100 - v110 - v110_xp v120 v120_xp Application Unicode - v100 - v110 - v110_xp v120 v120_xp @@ -49,7 +43,7 @@ - <_ProjectFileVersion>10.0.40219.1 + <_ProjectFileVersion>12.0.21005.1 $(SolutionDir)$(Configuration).win32\cpp-empty-test\ $(Configuration).win32\ true diff --git a/tests/cpp-tests/.cocos-project.json b/tests/cpp-tests/.cocos-project.json index e7c71f562f..34e7c97a15 100644 --- a/tests/cpp-tests/.cocos-project.json +++ b/tests/cpp-tests/.cocos-project.json @@ -1,7 +1,7 @@ { "win32_cfg": { "project_path": "../../build", - "sln_file": "cocos2d-win32.vc2012.sln", + "sln_file": "cocos2d-win32.vc2013.sln", "project_name": "cpp-tests", "build_cfg_path": "proj.win32" }, @@ -26,14 +26,6 @@ "android_cfg": { "project_path": "proj.android" }, - "wp8_cfg" : { - "project_path": "../../build", - "sln_file": "cocos2d-wp8.sln", - "project_name": "cpp-tests", - "wp8_proj_path" : "proj.wp8-xaml", - "build_folder_path": "cpp-tests/Bin/x86", - "manifest_path": "cpp-tests/Properties/WMAppManifest.xml" - }, "wp8_1_cfg" : { "project_path": "../../build", "sln_file": "cocos2d-win8.1-universal.sln", diff --git a/tests/cpp-tests/CMakeLists.txt b/tests/cpp-tests/CMakeLists.txt index 06d2606712..b5705ba2d8 100644 --- a/tests/cpp-tests/CMakeLists.txt +++ b/tests/cpp-tests/CMakeLists.txt @@ -21,12 +21,13 @@ else() endif() set(TESTS_SRC - Classes/CocosStudio3DTest/CocosStudio3DTest.cpp Classes/ActionManagerTest/ActionManagerTest.cpp Classes/ActionsEaseTest/ActionsEaseTest.cpp Classes/ActionsProgressTest/ActionsProgressTest.cpp Classes/ActionsTest/ActionsTest.cpp Classes/AllocatorTest/AllocatorTest.cpp + Classes/AppDelegate.cpp + Classes/BaseTest.cpp Classes/BillBoardTest/BillBoardTest.cpp Classes/BugsTest/Bug-1159.cpp Classes/BugsTest/Bug-1174.cpp @@ -38,41 +39,26 @@ set(TESTS_SRC Classes/BugsTest/Bug-886.cpp Classes/BugsTest/Bug-899.cpp Classes/BugsTest/Bug-914.cpp - Classes/BugsTest/BugsTest.cpp Classes/BugsTest/Bug-Child.cpp + Classes/BugsTest/BugsTest.cpp Classes/Camera3DTest/Camera3DTest.cpp Classes/ChipmunkTest/ChipmunkTest.cpp Classes/ClickAndMoveTest/ClickAndMoveTest.cpp Classes/ClippingNodeTest/ClippingNodeTest.cpp Classes/CocosDenshionTest/CocosDenshionTest.cpp + Classes/CocosStudio3DTest/CocosStudio3DTest.cpp + Classes/CocosStudio3DTest/CocosStudio3DTest.cpp + Classes/ConfigurationTest/ConfigurationTest.cpp + Classes/ConsoleTest/ConsoleTest.cpp Classes/CurlTest/CurlTest.cpp Classes/CurrentLanguageTest/CurrentLanguageTest.cpp + Classes/DataVisitorTest/DataVisitorTest.cpp Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp Classes/EffectsTest/EffectsTest.cpp Classes/ExtensionsTest/AssetsManagerExTest/AssetsManagerExTest.cpp - Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp - Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp - Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp - Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp - Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp - Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp - Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp - Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp - Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp - Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp - Classes/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.cpp - Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp - Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp - Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp - Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp - Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp - Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp - Classes/ExtensionsTest/ExtensionsTest.cpp - Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp - Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp - Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp + Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp @@ -82,91 +68,61 @@ set(TESTS_SRC Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.cpp Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.cpp - Classes/UITest/CocoStudioGUITest/CocoStudioGUITest.cpp - Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp - Classes/UITest/CocoStudioGUITest/GUIEditorTest.cpp - Classes/UITest/CocoStudioGUITest/CustomGUIScene.cpp - Classes/UITest/CocoStudioGUITest/UIScene.cpp - Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp - Classes/UITest/CocoStudioGUITest/UISceneManager.cpp - Classes/UITest/CocoStudioGUITest/CocostudioParserTest/CocostudioParserJsonTest.cpp - Classes/UITest/CocoStudioGUITest/CocostudioParserTest.cpp - Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp - Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp - Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp - Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp - Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp - Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp - Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp - Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp - Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp - Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp - Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp - Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp - Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp - Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp - Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest.cpp - Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.cpp - Classes/UITest/CocoStudioGUITest/UIScene_Editor.cpp - Classes/UITest/CocoStudioGUITest/UISceneManager_Editor.cpp - Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp - Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp - Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest_Editor.cpp - Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest_Editor.cpp - Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest_Editor.cpp - Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp - Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest_Editor.cpp - Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest_Editor.cpp - Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp - Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.cpp - Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.cpp - Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.cpp - Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp - Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp - Classes/UITest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp - Classes/UITest/CocoStudioGUITest/CustomWidget/CustomImageViewReader.cpp - Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp - Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidgetReader.cpp - Classes/UITest/CocoStudioGUITest/CustomWidget/CustomReader.cpp - Classes/UITest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.cpp - Classes/UITest/CocoStudioGUITest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.cpp - Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomRootNode.cpp - Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomRootNodeReader.cpp - Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomWidgetCallbackBindTest.cpp - Classes/NewRendererTest/NewRendererTest.cpp - Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp - Classes/NewAudioEngineTest/NewAudioEngineTest.cpp + Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp + Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp + Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp + Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp + Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp + Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp + Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp + Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp + Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp + Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp + Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp + Classes/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.cpp + Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp + Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp + Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp + Classes/ExtensionsTest/ExtensionsTest.cpp + Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp + Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp + Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp + Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp + Classes/FileUtilsTest/FileUtilsTest.cpp Classes/FontTest/FontTest.cpp - Classes/IntervalTest/IntervalTest.cpp Classes/InputTest/MouseTest.cpp + Classes/IntervalTest/IntervalTest.cpp Classes/LabelTest/LabelTest.cpp Classes/LabelTest/LabelTestNew.cpp Classes/LayerTest/LayerTest.cpp Classes/LightTest/LightTest.cpp + Classes/MaterialSystemTest/MaterialSystemTest Classes/MenuTest/MenuTest.cpp Classes/MotionStreakTest/MotionStreakTest.cpp Classes/MutiTouchTest/MutiTouchTest.cpp + Classes/NewAudioEngineTest/NewAudioEngineTest.cpp + Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp + Classes/NewRendererTest/NewRendererTest.cpp Classes/NodeTest/NodeTest.cpp Classes/OpenURLTest/OpenURLTest.cpp Classes/ParallaxTest/ParallaxTest.cpp - Classes/ParticleTest/ParticleTest.cpp Classes/Particle3DTest/Particle3DTest.cpp - Classes/CocosStudio3DTest/CocosStudio3DTest.cpp + Classes/ParticleTest/ParticleTest.cpp Classes/PerformanceTest/PerformanceAllocTest.cpp + Classes/PerformanceTest/PerformanceCallbackTest.cpp + Classes/PerformanceTest/PerformanceContainerTest.cpp + Classes/PerformanceTest/PerformanceEventDispatcherTest.cpp + Classes/PerformanceTest/PerformanceLabelTest.cpp + Classes/PerformanceTest/PerformanceMathTest.cpp Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp - Classes/PerformanceTest/PerformanceParticleTest.cpp Classes/PerformanceTest/PerformanceParticle3DTest.cpp + Classes/PerformanceTest/PerformanceParticleTest.cpp + Classes/PerformanceTest/PerformanceRendererTest.cpp + Classes/PerformanceTest/PerformanceScenarioTest.cpp Classes/PerformanceTest/PerformanceSpriteTest.cpp Classes/PerformanceTest/PerformanceTest.cpp Classes/PerformanceTest/PerformanceTextureTest.cpp Classes/PerformanceTest/PerformanceTouchesTest.cpp - Classes/PerformanceTest/PerformanceLabelTest.cpp - Classes/PerformanceTest/PerformanceRendererTest.cpp - Classes/PerformanceTest/PerformanceContainerTest.cpp - Classes/PerformanceTest/PerformanceEventDispatcherTest.cpp - Classes/PerformanceTest/PerformanceScenarioTest.cpp - Classes/PerformanceTest/PerformanceCallbackTest.cpp - Classes/PerformanceTest/PerformanceMathTest.cpp Classes/PhysicsTest/PhysicsTest.cpp Classes/ReleasePoolTest/ReleasePoolTest.cpp Classes/RenderTextureTest/RenderTextureTest.cpp @@ -175,36 +131,81 @@ set(TESTS_SRC Classes/SchedulerTest/SchedulerTest.cpp Classes/ShaderTest/ShaderTest.cpp Classes/ShaderTest/ShaderTest2.cpp - Classes/SpriteTest/SpriteTest.cpp - Classes/SpritePolygonTest/SpritePolygonTest.cpp - Classes/Sprite3DTest/Sprite3DTest.cpp + Classes/SpineTest/SpineTest.cpp Classes/Sprite3DTest/DrawNode3D.cpp + Classes/Sprite3DTest/Sprite3DTest.cpp + Classes/SpritePolygonTest/SpritePolygonTest.cpp + Classes/SpriteTest/SpriteTest.cpp Classes/TerrainTest/TerrainTest.cpp Classes/TextInputTest/TextInputTest.cpp Classes/Texture2dTest/Texture2dTest.cpp - Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp Classes/TextureCacheTest/TextureCacheTest.cpp + Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp Classes/TileMapTest/TileMapTest.cpp Classes/TileMapTest/TileMapTest2.cpp Classes/TouchesTest/Ball.cpp Classes/TouchesTest/Paddle.cpp Classes/TouchesTest/TouchesTest.cpp Classes/TransitionsTest/TransitionsTest.cpp - Classes/UserDefaultTest/UserDefaultTest.cpp - Classes/ZwoptexTest/ZwoptexTest.cpp - Classes/FileUtilsTest/FileUtilsTest.cpp - Classes/SpineTest/SpineTest.cpp - Classes/DataVisitorTest/DataVisitorTest.cpp - Classes/ConfigurationTest/ConfigurationTest.cpp - Classes/ConsoleTest/ConsoleTest.cpp + Classes/UITest/CocoStudioGUITest/CocoStudioGUITest.cpp + Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp + Classes/UITest/CocoStudioGUITest/CocostudioParserTest.cpp + Classes/UITest/CocoStudioGUITest/CocostudioParserTest/CocostudioParserJsonTest.cpp + Classes/UITest/CocoStudioGUITest/CustomGUIScene.cpp + Classes/UITest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.cpp + Classes/UITest/CocoStudioGUITest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.cpp + Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomRootNode.cpp + Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomRootNodeReader.cpp + Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomWidgetCallbackBindTest.cpp + Classes/UITest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp + Classes/UITest/CocoStudioGUITest/CustomWidget/CustomImageViewReader.cpp + Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp + Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidgetReader.cpp + Classes/UITest/CocoStudioGUITest/CustomWidget/CustomReader.cpp + Classes/UITest/CocoStudioGUITest/GUIEditorTest.cpp + Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp + Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp + Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp + Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp + Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp + Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp + Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest_Editor.cpp + Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp + Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest_Editor.cpp + Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp + Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest_Editor.cpp + Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp + Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp + Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp + Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest_Editor.cpp + Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.cpp + Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp + Classes/UITest/CocoStudioGUITest/UIScene.cpp + Classes/UITest/CocoStudioGUITest/UISceneManager.cpp + Classes/UITest/CocoStudioGUITest/UISceneManager_Editor.cpp + Classes/UITest/CocoStudioGUITest/UIScene_Editor.cpp + Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp + Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest_Editor.cpp + Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp + Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp + Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp + Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.cpp + Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp + Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.cpp + Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp + Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp + Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp + Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.cpp + Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest.cpp + Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp + Classes/UITest/UITest.cpp Classes/UnitTest/RefPtrTest.cpp Classes/UnitTest/UnitTest.cpp - Classes/UITest/UITest.cpp + Classes/UserDefaultTest/UserDefaultTest.cpp + Classes/VisibleRect.cpp + Classes/ZwoptexTest/ZwoptexTest.cpp Classes/controller.cpp Classes/testBasic.cpp - Classes/AppDelegate.cpp - Classes/BaseTest.cpp - Classes/VisibleRect.cpp ${PLATFORM_SRC} ) @@ -222,6 +223,12 @@ if(USE_BOX2D) ) endif() +if(USE_BULLET) + list(APPEND TESTS_SRC + Classes/Physics3DTest/Physics3DTest.cpp + ) +endif() + if(LINUX) set(EXTENDED_TESTS_SRC ) diff --git a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp index 52bb9e2c5e..21af5b7b5b 100644 --- a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp +++ b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp @@ -86,6 +86,7 @@ ActionsTests::ActionsTests() ADD_TEST_CASE(Issue1327); ADD_TEST_CASE(Issue1398); ADD_TEST_CASE(Issue2599) + ADD_TEST_CASE(ActionFloatTest); } std::string ActionsDemo::title() const @@ -2218,3 +2219,43 @@ std::string ActionRemoveSelf::subtitle() const { return "Sequence: Move + Rotate + Scale + RemoveSelf"; } + +//------------------------------------------------------------------ +// +// ActionFloat +// +//------------------------------------------------------------------ +void ActionFloatTest::onEnter() +{ + ActionsDemo::onEnter(); + + centerSprites(3); + + auto s = Director::getInstance()->getWinSize(); + + // create float action with duration and from to value, using lambda function we can easly animate any property of the Node. + auto actionFloat = ActionFloat::create(2.f, 0, 3, [this](float value) { + _tamara->setScale(value); + }); + + float grossiniY = _grossini->getPositionY(); + + auto actionFloat1 = ActionFloat::create(3.f, grossiniY, grossiniY + 50, [this](float value) { + _grossini->setPositionY(value); + }); + + auto actionFloat2 = ActionFloat::create(3.f, 3, 1, [this] (float value) { + _kathia->setScale(value); + }); + + _tamara->runAction(actionFloat); + _grossini->runAction(actionFloat1); + _kathia->runAction(actionFloat2); +} + +std::string ActionFloatTest::subtitle() const +{ + return "ActionFloat"; +} + + diff --git a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h index c639ced391..2bd1e6a6f0 100644 --- a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h +++ b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h @@ -580,4 +580,13 @@ private: cocos2d::Vector _pausedTargets; }; +class ActionFloatTest : public ActionsDemo +{ +public: + CREATE_FUNC(ActionFloatTest); + + virtual void onEnter() override; + virtual std::string subtitle() const override; +}; + #endif diff --git a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp index e23dc463b5..5a3500ec21 100644 --- a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp +++ b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp @@ -39,10 +39,7 @@ Camera3DTests::Camera3DTests() ADD_TEST_CASE(CameraRotationTest); ADD_TEST_CASE(Camera3DTestDemo); ADD_TEST_CASE(CameraCullingDemo); -#if (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) - // 3DEffect use custom shader which is not supported on WP8 yet. ADD_TEST_CASE(FogTestDemo); -#endif ADD_TEST_CASE(CameraArcBallDemo); } @@ -1317,7 +1314,7 @@ void FogTestDemo::onEnter() _layer3D->setCameraMask(2); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) _backToForegroundListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom*) { @@ -1380,7 +1377,7 @@ void FogTestDemo::onExit() _camera = nullptr; } -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundListener); #endif } diff --git a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.h b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.h index f2350b11f4..6017d88ae9 100644 --- a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.h +++ b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.h @@ -250,7 +250,7 @@ protected: cocos2d::GLProgram* _shader; cocos2d::GLProgramState* _state; -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) cocos2d::EventListenerCustom* _backToForegroundListener; #endif }; diff --git a/tests/cpp-tests/Classes/CocosDenshionTest/CocosDenshionTest.cpp b/tests/cpp-tests/Classes/CocosDenshionTest/CocosDenshionTest.cpp index 74dae4179e..7a6be1b285 100644 --- a/tests/cpp-tests/Classes/CocosDenshionTest/CocosDenshionTest.cpp +++ b/tests/cpp-tests/Classes/CocosDenshionTest/CocosDenshionTest.cpp @@ -14,7 +14,7 @@ #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #define MUSIC_FILE "music.mid" -#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) #define MUSIC_FILE "background.wav" #elif (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX ) #define MUSIC_FILE "background.ogg" diff --git a/tests/cpp-tests/Classes/ConsoleTest/ConsoleTest.cpp b/tests/cpp-tests/Classes/ConsoleTest/ConsoleTest.cpp index 638e0c93aa..811da5a521 100644 --- a/tests/cpp-tests/Classes/ConsoleTest/ConsoleTest.cpp +++ b/tests/cpp-tests/Classes/ConsoleTest/ConsoleTest.cpp @@ -26,7 +26,7 @@ #include "../testResource.h" #include #include -#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) && (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) && (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) #include #include #include @@ -36,11 +36,6 @@ #include #endif -#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 -#include "CCWinRTUtils.h" -#include -#endif - USING_NS_CC; //------------------------------------------------------------------ @@ -86,24 +81,6 @@ ConsoleCustomCommand::ConsoleCustomCommand() }}, }; _console->addCommand(commands[0]); - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) - - std::stringstream ss; - ss << "WP8 Device IP Addresses:" << std::endl; - ss << getDeviceIPAddresses(); - - auto origin = Director::getInstance()->getVisibleOrigin(); - auto visibleSize = Director::getInstance()->getVisibleSize(); - auto label = LabelTTF::create(ss.str(), "Arial", 12); - - // position the label on the center of the screen - label->setPosition(origin.x + visibleSize.width/2, - origin.y + visibleSize.height/2 + (label->getContentSize().height/2)); - - // add the label as a child to this layer - this->addChild(label, 1); -#endif } ConsoleCustomCommand::~ConsoleCustomCommand() @@ -122,11 +99,7 @@ std::string ConsoleCustomCommand::title() const std::string ConsoleCustomCommand::subtitle() const { -#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 - return "telnet [ip address] 5678"; -#else return "telnet localhost 5678"; -#endif } @@ -174,7 +147,7 @@ void ConsoleUploadFile::uploadFile() hints.ai_flags = 0; hints.ai_protocol = 0; /* Any protocol */ -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) WSADATA wsaData; WSAStartup(MAKEWORD(2, 2),&wsaData); #endif @@ -200,7 +173,7 @@ void ConsoleUploadFile::uploadFile() if (connect(sfd, rp->ai_addr, rp->ai_addrlen) != -1) break; /* Success */ -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) closesocket(sfd); #else close(sfd); @@ -260,7 +233,7 @@ void ConsoleUploadFile::uploadFile() // terminate fclose (fp); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) closesocket(sfd); WSACleanup(); #else diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp index 6ed0cf7aa3..e7a677109d 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp @@ -84,7 +84,7 @@ void SceneController::spriteMoveFinished(Node* sender) auto gameOverScene = GameOverScene::create(); gameOverScene->getLayer()->getLabel()->setString("You Lose :["); - director->replaceScene(gameOverScene); + director->replaceScene(gameOverScene); } else if (sprite->getTag() == 3) { diff --git a/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.cpp index f7f2ffdced..dd35fe5e95 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.cpp @@ -14,7 +14,7 @@ #include "CocoStudioComponentsTest/ComponentsTestScene.h" #include "CocoStudioSceneTest/SceneEditorTest.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) #include "NetworkTest/WebSocketTest.h" #include "NetworkTest/SocketIOTest.h" #endif @@ -28,7 +28,7 @@ ExtensionsTests::ExtensionsTests() #if (CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN) && (CC_TARGET_PLATFORM != CC_PLATFORM_NACL) addTest("HttpClientTest", [](){ return new (std::nothrow) HttpClientTests; }); #endif -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) addTest("WebSocketTest", [](){ return new (std::nothrow) WebSocketTests; }); addTest("SocketIOTest", [](){ return new (std::nothrow) SocketIOTests; }); #endif diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp index aeec43fc3f..4c68128863 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.cpp @@ -75,6 +75,9 @@ NewLabelTests::NewLabelTests() ADD_TEST_CASE(LabelSmallDimensionsTest); ADD_TEST_CASE(LabelIssue10089Test); ADD_TEST_CASE(LabelSystemFontColor); + ADD_TEST_CASE(LabelIssue10773Test); + ADD_TEST_CASE(LabelIssue11576Test); + ADD_TEST_CASE(LabelIssue11699Test); }; LabelTTFAlignmentNew::LabelTTFAlignmentNew() @@ -1862,3 +1865,72 @@ std::string LabelSystemFontColor::subtitle() const { return "Testing text color of system font"; } + +LabelIssue10773Test::LabelIssue10773Test() +{ + auto center = VisibleRect::center(); + + auto label = Label::createWithTTF("create label with TTF", "fonts/arial.ttf", 24); + label->getLetter(5); + label->setString("Hi"); + label->setPosition(center.x, center.y); + addChild(label); +} + +std::string LabelIssue10773Test::title() const +{ + return "Test for Issue #10773"; +} + +std::string LabelIssue10773Test::subtitle() const +{ + return "Should not crash!"; +} + +LabelIssue11576Test::LabelIssue11576Test() +{ + auto center = VisibleRect::center(); + + auto label = Label::createWithTTF("abcdefg", "fonts/arial.ttf", 24); + for (int index = 0; index < label->getStringLength(); ++index) + { + label->getLetter(index); + } + + this->runAction(Sequence::create(DelayTime::create(2.0f), CallFunc::create([label](){ + label->setString("Hello World!"); + }), nullptr)); + + label->setPosition(center.x, center.y); + addChild(label); +} + +std::string LabelIssue11576Test::title() const +{ + return "Test for Issue #11576"; +} + +std::string LabelIssue11576Test::subtitle() const +{ + return "You should see another string displayed correctly after 2 seconds."; +} + +LabelIssue11699Test::LabelIssue11699Test() +{ + auto center = VisibleRect::center(); + + auto label = Label::createWithTTF("中国", "fonts/HKYuanMini.ttf", 150); + label->enableOutline(Color4B::RED, 2); + label->setPosition(center.x, center.y); + addChild(label); +} + +std::string LabelIssue11699Test::title() const +{ + return "Test for Issue #11699"; +} + +std::string LabelIssue11699Test::subtitle() const +{ + return "Outline should match with the characters exactly."; +} diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h index 3661a56fc6..54bcb92be4 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h +++ b/tests/cpp-tests/Classes/LabelTest/LabelTestNew.h @@ -554,4 +554,37 @@ public: virtual std::string subtitle() const override; }; +class LabelIssue10773Test : public AtlasDemoNew +{ +public: + CREATE_FUNC(LabelIssue10773Test); + + LabelIssue10773Test(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + +class LabelIssue11576Test : public AtlasDemoNew +{ +public: + CREATE_FUNC(LabelIssue11576Test); + + LabelIssue11576Test(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + +class LabelIssue11699Test : public AtlasDemoNew +{ +public: + CREATE_FUNC(LabelIssue11699Test); + + LabelIssue11699Test(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + #endif diff --git a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp new file mode 100644 index 0000000000..ad372eef32 --- /dev/null +++ b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.cpp @@ -0,0 +1,136 @@ +/**************************************************************************** + Copyright (c) 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 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 "MaterialSystemTest.h" +#include "../testResource.h" +#include "cocos2d.h" + + +USING_NS_CC; + +MaterialSystemTest::MaterialSystemTest() +{ + ADD_TEST_CASE(Material_MultipleSprite3D); + ADD_TEST_CASE(Material_Sprite3DTest); + +// ADD_TEST_CASE(Material_SpriteTest); + +} + +// MARK: + +std::string MaterialSystemBaseTest::title() const +{ + return "Material System"; +} + +// MARK: Tests start here + +void Material_SpriteTest::onEnter() +{ + // Material remove from Sprite since it is hacking. + // Sprite (or Node) should have "Effect" instead of "Material" + + MaterialSystemBaseTest::onEnter(); + auto layer = LayerColor::create(Color4B::BLUE); + this->addChild(layer); + + + auto sprite = Sprite::create("Images/grossini.png"); + sprite->setNormalizedPosition(Vec2(0.5, 0.5)); + this->addChild(sprite); + +// auto material = Material::createWithFilename("Materials/effects.material"); +// sprite->setMaterial(material); + +// material->setTechnique("blur"); +// material->setTechnique("outline"); +// material->setTechnique("noise"); +// material->setTechnique("edge detect"); +// material->setTechnique("gray+blur"); +} + +std::string Material_SpriteTest::subtitle() const +{ + return "Material System on Sprite"; +} + + +void Material_Sprite3DTest::onEnter() +{ + MaterialSystemBaseTest::onEnter(); + + auto sprite = Sprite3D::create("Sprite3DTest/boss1.obj"); + sprite->setScale(8.f); + sprite->setTexture("Sprite3DTest/boss.png"); + this->addChild(sprite); + sprite->setNormalizedPosition(Vec2(0.5,0.5)); + +// auto material = Material::createWithFilename("Materials/spaceship.material"); +// sprite->setMaterial(material); +} + +std::string Material_Sprite3DTest::subtitle() const +{ + return "Material System on Sprite3D"; +} + + +// +// +// +void Material_MultipleSprite3D::onEnter() +{ + MaterialSystemBaseTest::onEnter(); + + const char* names[] = { + "Sprite3DTest/ReskinGirl.c3b", + "Sprite3DTest/ReskinGirl.c3b", + "Sprite3DTest/ReskinGirl.c3b", + "Sprite3DTest/ReskinGirl.c3b", + "Sprite3DTest/ReskinGirl.c3b", + "Sprite3DTest/ReskinGirl.c3b", + "Sprite3DTest/ReskinGirl.c3b", + "Sprite3DTest/ReskinGirl.c3b", + }; + + const int totalNames = sizeof(names) / sizeof(names[0]); + + auto size = Director::getInstance()->getWinSize(); + + for(int i=0;iaddChild(sprite); + sprite->setPosition(Vec2((size.width/(totalNames+1))*(i+1), size.height/4)); + sprite->setScale(3); + } +} + +std::string Material_MultipleSprite3D::subtitle() const +{ + return "Sprites with multiple meshes"; +} + diff --git a/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.h b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.h new file mode 100644 index 0000000000..7ff09279d5 --- /dev/null +++ b/tests/cpp-tests/Classes/MaterialSystemTest/MaterialSystemTest.h @@ -0,0 +1,65 @@ +/**************************************************************************** + Copyright (c) 2015 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 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. + ****************************************************************************/ + +#pragma once + +#include "../testBasic.h" +#include "../BaseTest.h" + +DEFINE_TEST_SUITE(MaterialSystemTest); + +class MaterialSystemBaseTest : public TestCase +{ +public: + virtual std::string title() const override; +}; + +class Material_SpriteTest : public MaterialSystemBaseTest +{ +public: + CREATE_FUNC(Material_SpriteTest); + + virtual void onEnter() override; + virtual std::string subtitle() const override; +}; + +class Material_Sprite3DTest : public MaterialSystemBaseTest +{ +public: + CREATE_FUNC(Material_Sprite3DTest); + + virtual void onEnter() override; + virtual std::string subtitle() const override; +}; + +class Material_MultipleSprite3D : public MaterialSystemBaseTest +{ +public: + CREATE_FUNC(Material_MultipleSprite3D); + + virtual void onEnter() override; + virtual std::string subtitle() const override; +}; + + diff --git a/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.cpp b/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.cpp index a5a3d34cf4..3f794bd566 100644 --- a/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.cpp +++ b/tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.cpp @@ -78,8 +78,8 @@ namespace { private: TextButton() - : _enabled(true) - , _onTriggered(nullptr) + : _onTriggered(nullptr) + , _enabled(true) { auto listener = EventListenerTouchOneByOne::create(); listener->setSwallowTouches(true); diff --git a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.h b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.h index 830eb0a44e..f9e798693f 100644 --- a/tests/cpp-tests/Classes/ParticleTest/ParticleTest.h +++ b/tests/cpp-tests/Classes/ParticleTest/ParticleTest.h @@ -287,8 +287,6 @@ public: virtual void update(float dt) override; virtual std::string title() const override; virtual std::string subtitle() const override; -private: - cocos2d::ParticleBatchNode* _batchNode; }; class AddAndDeleteParticleSystems : public ParticleDemo diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceAllocTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceAllocTest.cpp index 392d234b55..fe39b0f78a 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceAllocTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceAllocTest.cpp @@ -35,21 +35,17 @@ using namespace cocos2d::ui; #undef CC_PROFILER_RESET_INSTANCE #define CC_PROFILER_RESET_INSTANCE(__id__, __name__) do{ ProfilingResetTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0) -static std::function createFunctions[] = +PerformceAllocTests::PerformceAllocTests() { - CL(NodeCreateTest), - CL(NodeDeallocTest), - CL(SpriteCreateEmptyTest), - CL(SpriteCreateTest), - CL(SpriteDeallocTest), -}; - -#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) + ADD_TEST_CASE(NodeCreateTest); + ADD_TEST_CASE(NodeDeallocTest); + ADD_TEST_CASE(SpriteCreateEmptyTest); + ADD_TEST_CASE(SpriteCreateTest); + ADD_TEST_CASE(SpriteDeallocTest); +} enum { kTagInfoLayer = 1, - - kTagBase = 20000, }; enum { @@ -57,59 +53,29 @@ enum { kNodesIncrease = 500, }; -static int g_curCase = 0; - -//////////////////////////////////////////////////////// -// -// AllocBasicLayer -// -//////////////////////////////////////////////////////// - -AllocBasicLayer::AllocBasicLayer(bool bControlMenuVisible, int nMaxCases, int nCurCase) -: PerformBasicLayer(bControlMenuVisible, nMaxCases, nCurCase) -{ -} - -void AllocBasicLayer::showCurrentTest() -{ - int nodes = ((PerformceAllocScene*)getParent())->getQuantityOfNodes(); - - auto scene = createFunctions[_curCase](); - - g_curCase = _curCase; - - if (scene) - { - scene->initWithQuantityOfNodes(nodes); - - Director::getInstance()->replaceScene(scene); - } -} +int PerformceAllocScene::quantityOfNodes = kNodesIncrease; //////////////////////////////////////////////////////// // // PerformceAllocScene // //////////////////////////////////////////////////////// +bool PerformceAllocScene::init() +{ + if (TestCase::init()) + { + initWithQuantityOfNodes(quantityOfNodes); + return true; + } + + return false; +} + void PerformceAllocScene::initWithQuantityOfNodes(unsigned int nNodes) { //srand(time()); auto s = Director::getInstance()->getWinSize(); - // Title - auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); - addChild(label, 1); - label->setPosition(Vec2(s.width/2, s.height-50)); - - // Subtitle - std::string strSubTitle = subtitle(); - if(strSubTitle.length()) - { - auto l = Label::createWithTTF(strSubTitle.c_str(), "fonts/Thonburi.ttf", 16); - addChild(l, 1); - l->setPosition(Vec2(s.width/2, s.height-80)); - } - lastRenderedCount = 0; currentQuantityOfNodes = 0; quantityOfNodes = nNodes; @@ -150,10 +116,6 @@ void PerformceAllocScene::initWithQuantityOfNodes(unsigned int nNodes) infoLabel->setPosition(Vec2(s.width/2, s.height/2-15)); addChild(infoLabel, 1, kTagInfoLayer); - auto menuLayer = new (std::nothrow) AllocBasicLayer(true, MAX_LAYER, g_curCase); - addChild(menuLayer); - menuLayer->release(); - updateQuantityLabel(); updateQuantityOfNodes(); updateProfilerName(); @@ -472,12 +434,3 @@ const char* SpriteDeallocTest::testName() { return "Sprite::~Sprite()"; } - -///---------------------------------------- -void runAllocPerformanceTest() -{ - auto scene = createFunctions[g_curCase](); - scene->initWithQuantityOfNodes(kNodesIncrease); - - Director::getInstance()->replaceScene(scene); -} diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceAllocTest.h b/tests/cpp-tests/Classes/PerformanceTest/PerformanceAllocTest.h index 751dc289dd..fd70b950df 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceAllocTest.h +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceAllocTest.h @@ -4,19 +4,14 @@ #ifndef __PERFORMANCE_ALLOC_TEST_H__ #define __PERFORMANCE_ALLOC_TEST_H__ -#include "PerformanceTest.h" +#include "BaseTest.h" -class AllocBasicLayer : public PerformBasicLayer -{ -public: - AllocBasicLayer(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0); - - virtual void showCurrentTest(); -}; - -class PerformceAllocScene : public cocos2d::Scene +DEFINE_TEST_SUITE(PerformceAllocTests); + +class PerformceAllocScene : public TestCase { public: + virtual bool init() override; virtual void initWithQuantityOfNodes(unsigned int nNodes); virtual std::string title() const; virtual std::string subtitle() const; @@ -41,7 +36,7 @@ public: protected: char _profilerName[256]; int lastRenderedCount; - int quantityOfNodes; + static int quantityOfNodes; int currentQuantityOfNodes; }; @@ -115,7 +110,4 @@ public: virtual std::string subtitle() const override; }; - -void runAllocPerformanceTest(); - #endif // __PERFORMANCE_ALLOC_TEST_H__ diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceCallbackTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceCallbackTest.cpp index 1ca4d3f649..20da0f7f0a 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceCallbackTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceCallbackTest.cpp @@ -34,39 +34,11 @@ USING_NS_CC; #undef CC_PROFILER_RESET_INSTANCE #define CC_PROFILER_RESET_INSTANCE(__id__, __name__) do{ ProfilingResetTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0) -static std::function createFunctions[] = +PerformceCallbackTests::PerformceCallbackTests() { - CL(SimulateNewSchedulerCallbackPerfTest), - CL(InvokeMemberFunctionPerfTest), - CL(InvokeStdFunctionPerfTest), -}; - -#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) - - -static int g_curCase = 0; - -//////////////////////////////////////////////////////// -// -// CallbackBasicLayer -// -//////////////////////////////////////////////////////// - -CallbackBasicLayer::CallbackBasicLayer(bool bControlMenuVisible, int nMaxCases, int nCurCase) -: PerformBasicLayer(bControlMenuVisible, nMaxCases, nCurCase) -{ -} - -void CallbackBasicLayer::showCurrentTest() -{ - auto scene = createFunctions[_curCase](); - - g_curCase = _curCase; - - if (scene) - { - Director::getInstance()->replaceScene(scene); - } + ADD_TEST_CASE(SimulateNewSchedulerCallbackPerfTest); + ADD_TEST_CASE(InvokeMemberFunctionPerfTest); + ADD_TEST_CASE(InvokeStdFunctionPerfTest); } //////////////////////////////////////////////////////// @@ -81,26 +53,6 @@ void PerformanceCallbackScene::onEnter() CC_PROFILER_PURGE_ALL(); - auto s = Director::getInstance()->getWinSize(); - - auto menuLayer = new (std::nothrow) CallbackBasicLayer(true, MAX_LAYER, g_curCase); - addChild(menuLayer); - menuLayer->release(); - - // Title - auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); - addChild(label, 1); - label->setPosition(Vec2(s.width/2, s.height-50)); - - // Subtitle - std::string strSubTitle = subtitle(); - if(strSubTitle.length()) - { - auto l = Label::createWithTTF(strSubTitle.c_str(), "fonts/Thonburi.ttf", 16); - addChild(l, 1); - l->setPosition(Vec2(s.width/2, s.height-80)); - } - getScheduler()->schedule(CC_SCHEDULE_SELECTOR(PerformanceCallbackScene::onUpdate), this, 0.0f, false); getScheduler()->schedule(CC_SCHEDULE_SELECTOR(PerformanceCallbackScene::dumpProfilerInfo), this, 2, false); } @@ -210,10 +162,3 @@ void InvokeStdFunctionPerfTest::onUpdate(float dt) } CC_PROFILER_STOP(_profileName.c_str()); } - -void runCallbackPerformanceTest() -{ - auto scene = createFunctions[g_curCase](); - - Director::getInstance()->replaceScene(scene); -} diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceCallbackTest.h b/tests/cpp-tests/Classes/PerformanceTest/PerformanceCallbackTest.h index 4db4b7c58b..bed606e66f 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceCallbackTest.h +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceCallbackTest.h @@ -4,17 +4,11 @@ #ifndef __PERFORMANCE_CALLBACK_TEST_H__ #define __PERFORMANCE_CALLBACK_TEST_H__ -#include "PerformanceTest.h" +#include "BaseTest.h" -class CallbackBasicLayer : public PerformBasicLayer -{ -public: - CallbackBasicLayer(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0); - - virtual void showCurrentTest(); -}; +DEFINE_TEST_SUITE(PerformceCallbackTests); -class PerformanceCallbackScene : public cocos2d::Scene +class PerformanceCallbackScene : public TestCase { public: virtual void onEnter() override; @@ -96,6 +90,4 @@ private: std::function _callback; }; -void runCallbackPerformanceTest(); - #endif /* __PERFORMANCE_CALLBACK_TEST_H__ */ diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceContainerTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceContainerTest.cpp index 84d1e020b2..5cd1753122 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceContainerTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceContainerTest.cpp @@ -33,17 +33,15 @@ USING_NS_CC; #undef CC_PROFILER_RESET_INSTANCE #define CC_PROFILER_RESET_INSTANCE(__id__, __name__) do{ ProfilingResetTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0) -static std::function createFunctions[] = +PerformceContainerTests::PerformceContainerTests() { - CL(TemplateVectorPerfTest), - CL(ArrayPerfTest), - CL(TemplateMapStringKeyPerfTest), - CL(DictionaryStringKeyPerfTest), - CL(TemplateMapIntKeyPerfTest), - CL(DictionaryIntKeyPerfTest) -}; - -#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) + ADD_TEST_CASE(TemplateVectorPerfTest); + ADD_TEST_CASE(ArrayPerfTest); + ADD_TEST_CASE(TemplateMapStringKeyPerfTest); + ADD_TEST_CASE(DictionaryStringKeyPerfTest); + ADD_TEST_CASE(TemplateMapIntKeyPerfTest); + ADD_TEST_CASE(DictionaryIntKeyPerfTest); +} enum { kTagInfoLayer = 1, @@ -56,60 +54,30 @@ enum { kNodesIncrease = 500, }; -static int g_curCase = 0; - -//////////////////////////////////////////////////////// -// -// ContainerBasicLayer -// -//////////////////////////////////////////////////////// - -ContainerBasicLayer::ContainerBasicLayer(bool bControlMenuVisible, int nMaxCases, int nCurCase) -: PerformBasicLayer(bControlMenuVisible, nMaxCases, nCurCase) -{ -} - -void ContainerBasicLayer::showCurrentTest() -{ - int nodes = ((PerformanceContainerScene*)getParent())->getQuantityOfNodes(); - - auto scene = createFunctions[_curCase](); - - g_curCase = _curCase; - - if (scene) - { - scene->initWithQuantityOfNodes(nodes); - - Director::getInstance()->replaceScene(scene); - } -} +int PerformanceContainerScene::quantityOfNodes = kNodesIncrease; //////////////////////////////////////////////////////// // // PerformanceContainerScene // //////////////////////////////////////////////////////// +bool PerformanceContainerScene::init() +{ + if (TestCase::init()) + { + initWithQuantityOfNodes(quantityOfNodes); + return true; + } + + return false; +} + void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes) { _type = 0; //srand(time()); auto s = Director::getInstance()->getWinSize(); - // Title - auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); - addChild(label, 1, TAG_TITLE); - label->setPosition(Vec2(s.width/2, s.height-50)); - - // Subtitle - std::string strSubTitle = subtitle(); - if(strSubTitle.length()) - { - auto l = Label::createWithTTF(strSubTitle.c_str(), "fonts/Thonburi.ttf", 16); - addChild(l, 1, TAG_SUBTITLE); - l->setPosition(Vec2(s.width/2, s.height-80)); - } - lastRenderedCount = 0; currentQuantityOfNodes = 0; quantityOfNodes = nNodes; @@ -153,10 +121,6 @@ void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes) infoLabel->setPosition(Vec2(s.width/2, s.height/2-15)); addChild(infoLabel, 1, kTagInfoLayer); - auto menuLayer = new (std::nothrow) ContainerBasicLayer(true, MAX_LAYER, g_curCase); - addChild(menuLayer); - menuLayer->release(); - log("Size of Node: %d\n", (int)sizeof(Node)); int oldFontSize = MenuItemFont::getFontSize(); @@ -177,8 +141,7 @@ void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes) auto toggle = MenuItemToggle::createWithCallback([this](Ref* sender){ auto toggle = static_cast(sender); this->_type = toggle->getSelectedIndex(); - auto label = static_cast(this->getChildByTag(TAG_SUBTITLE)); - label->setString(StringUtils::format("Test '%s', See console", this->_testFunctions[this->_type].name)); + _subtitleLabel->setString(StringUtils::format("Test '%s', See console", this->_testFunctions[this->_type].name)); this->updateProfilerName(); }, toggleItems); @@ -1357,13 +1320,3 @@ std::string DictionaryIntKeyPerfTest::subtitle() const { return "Test `setObject`, See console"; } - - -///---------------------------------------- -void runContainerPerformanceTest() -{ - auto scene = createFunctions[g_curCase](); - scene->initWithQuantityOfNodes(kNodesIncrease); - - Director::getInstance()->replaceScene(scene); -} diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceContainerTest.h b/tests/cpp-tests/Classes/PerformanceTest/PerformanceContainerTest.h index 9a301f61ec..6fc135a7e0 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceContainerTest.h +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceContainerTest.h @@ -4,17 +4,11 @@ #ifndef __PERFORMANCE_CONTAINER_TEST_H__ #define __PERFORMANCE_CONTAINER_TEST_H__ -#include "PerformanceTest.h" +#include "BaseTest.h" -class ContainerBasicLayer : public PerformBasicLayer -{ -public: - ContainerBasicLayer(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0); - - virtual void showCurrentTest(); -}; +DEFINE_TEST_SUITE(PerformceContainerTests); -class PerformanceContainerScene : public cocos2d::Scene +class PerformanceContainerScene : public TestCase { public: static const int TAG_TITLE = 100; @@ -26,6 +20,7 @@ public: std::function func; }; + virtual bool init() override; virtual void initWithQuantityOfNodes(unsigned int nNodes); virtual void generateTestFunctions() = 0; @@ -46,9 +41,10 @@ public: virtual void update(float dt) override; protected: + static int quantityOfNodes; + char _profilerName[256]; int lastRenderedCount; - int quantityOfNodes; int currentQuantityOfNodes; unsigned int _type; std::vector _testFunctions; @@ -126,6 +122,4 @@ public: virtual std::string subtitle() const override; }; -void runContainerPerformanceTest(); - #endif // __PERFORMANCE_CONTAINER_TEST_H__ diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceEventDispatcherTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceEventDispatcherTest.cpp index 6852448a51..71e7b12c5b 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceEventDispatcherTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceEventDispatcherTest.cpp @@ -34,14 +34,12 @@ USING_NS_CC; #undef CC_PROFILER_RESET_INSTANCE #define CC_PROFILER_RESET_INSTANCE(__id__, __name__) do{ ProfilingResetTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0) -static std::function createFunctions[] = +PerformceEventDispatcherTests::PerformceEventDispatcherTests() { - CL(TouchEventDispatchingPerfTest), - CL(KeyboardEventDispatchingPerfTest), - CL(CustomEventDispatchingPerfTest), -}; - -#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) + ADD_TEST_CASE(TouchEventDispatchingPerfTest); + ADD_TEST_CASE(KeyboardEventDispatchingPerfTest); + ADD_TEST_CASE(CustomEventDispatchingPerfTest); +} enum { kTagInfoLayer = 1, @@ -54,69 +52,39 @@ enum { kNodesIncrease = 500, }; -static int g_curCase = 0; - -//////////////////////////////////////////////////////// -// -// EventDispatcherBasicLayer -// -//////////////////////////////////////////////////////// - -EventDispatcherBasicLayer::EventDispatcherBasicLayer(bool bControlMenuVisible, int nMaxCases, int nCurCase) -: PerformBasicLayer(bControlMenuVisible, nMaxCases, nCurCase) -{ -} - -void EventDispatcherBasicLayer::showCurrentTest() -{ - int nodes = ((PerformanceEventDispatcherScene*)getParent())->getQuantityOfNodes(); - - auto scene = createFunctions[_curCase](); - - g_curCase = _curCase; - - if (scene) - { - scene->initWithQuantityOfNodes(nodes); - - Director::getInstance()->replaceScene(scene); - } -} +int PerformanceEventDispatcherScene::quantityOfNodes = kNodesIncrease; //////////////////////////////////////////////////////// // // PerformanceEventDispatcherScene // //////////////////////////////////////////////////////// +bool PerformanceEventDispatcherScene::init() +{ + if (TestCase::init()) + { + initWithQuantityOfNodes(quantityOfNodes); + return true; + } + + return false; +} + void PerformanceEventDispatcherScene::initWithQuantityOfNodes(unsigned int nNodes) { _type = 0; srand((unsigned)time(nullptr)); auto s = Director::getInstance()->getWinSize(); - // Title - auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); - addChild(label, 1, TAG_TITLE); - label->setPosition(Vec2(s.width/2, s.height-50)); - - // Subtitle - std::string strSubTitle = subtitle(); - if(strSubTitle.length()) - { - auto l = Label::createWithTTF(strSubTitle.c_str(), "fonts/Thonburi.ttf", 16); - addChild(l, 1, TAG_SUBTITLE); - l->setPosition(Vec2(s.width/2, s.height-80)); - } - _lastRenderedCount = 0; _currentQuantityOfNodes = 0; - _quantityOfNodes = nNodes; + quantityOfNodes = nNodes; MenuItemFont::setFontSize(65); auto decrease = MenuItemFont::create(" - ", [&](Ref *sender) { - _quantityOfNodes -= kNodesIncrease; - if( _quantityOfNodes < 0 ) - _quantityOfNodes = 0; + quantityOfNodes -= kNodesIncrease; + if( quantityOfNodes < 0 ) + quantityOfNodes = 0; updateQuantityLabel(); updateQuantityOfNodes(); @@ -128,9 +96,9 @@ void PerformanceEventDispatcherScene::initWithQuantityOfNodes(unsigned int nNode _decrease = decrease; auto increase = MenuItemFont::create(" + ", [&](Ref *sender) { - _quantityOfNodes += kNodesIncrease; - if( _quantityOfNodes > kMaxNodes ) - _quantityOfNodes = kMaxNodes; + quantityOfNodes += kNodesIncrease; + if( quantityOfNodes > kMaxNodes ) + quantityOfNodes = kMaxNodes; updateQuantityLabel(); updateQuantityOfNodes(); @@ -151,10 +119,6 @@ void PerformanceEventDispatcherScene::initWithQuantityOfNodes(unsigned int nNode infoLabel->setPosition(Vec2(s.width/2, s.height/2-15)); addChild(infoLabel, 1, kTagInfoLayer); - auto menuLayer = new (std::nothrow) EventDispatcherBasicLayer(true, MAX_LAYER, g_curCase); - addChild(menuLayer); - menuLayer->release(); - int oldFontSize = MenuItemFont::getFontSize(); MenuItemFont::setFontSize(24); @@ -191,8 +155,7 @@ void PerformanceEventDispatcherScene::initWithQuantityOfNodes(unsigned int nNode auto toggle = MenuItemToggle::createWithCallback([=](Ref* sender){ auto toggle = static_cast(sender); this->_type = toggle->getSelectedIndex(); - auto label = static_cast(this->getChildByTag(TAG_SUBTITLE)); - label->setString(StringUtils::format("Test '%s', See console", this->_testFunctions[this->_type].name)); + _subtitleLabel->setString(StringUtils::format("Test '%s', See console", this->_testFunctions[this->_type].name)); this->updateProfilerName(); reset(); }, toggleItems); @@ -264,11 +227,11 @@ std::string PerformanceEventDispatcherScene::subtitle() const void PerformanceEventDispatcherScene::updateQuantityLabel() { - if( _quantityOfNodes != _lastRenderedCount ) + if( quantityOfNodes != _lastRenderedCount ) { auto infoLabel = static_cast( getChildByTag(kTagInfoLayer) ); char str[20] = {0}; - sprintf(str, "%u listeners", _quantityOfNodes); + sprintf(str, "%u listeners", quantityOfNodes); infoLabel->setString(str); } } @@ -280,7 +243,7 @@ const char * PerformanceEventDispatcherScene::profilerName() void PerformanceEventDispatcherScene::updateProfilerName() { - snprintf(_profilerName, sizeof(_profilerName)-1, "%s(%d)", testName(), _quantityOfNodes); + snprintf(_profilerName, sizeof(_profilerName)-1, "%s(%d)", testName(), quantityOfNodes); } void PerformanceEventDispatcherScene::dumpProfilerInfo(float dt) @@ -295,7 +258,7 @@ void PerformanceEventDispatcherScene::update(float dt) void PerformanceEventDispatcherScene::updateQuantityOfNodes() { - _currentQuantityOfNodes = _quantityOfNodes; + _currentQuantityOfNodes = quantityOfNodes; } const char* PerformanceEventDispatcherScene::testName() @@ -315,7 +278,7 @@ void TouchEventDispatchingPerfTest::generateTestFunctions() TestFunction testFunctions[] = { { "OneByOne-scenegraph", [=](){ auto dispatcher = Director::getInstance()->getEventDispatcher(); - if (_quantityOfNodes != _lastRenderedCount) + if (quantityOfNodes != _lastRenderedCount) { auto listener = EventListenerTouchOneByOne::create(); listener->onTouchBegan = [](Touch* touch, Event* event){ @@ -326,7 +289,7 @@ void TouchEventDispatchingPerfTest::generateTestFunctions() listener->onTouchEnded = [](Touch* touch, Event* event){}; // Create new touchable nodes - for (int i = 0; i < this->_quantityOfNodes; ++i) + for (int i = 0; i < this->quantityOfNodes; ++i) { auto node = Node::create(); node->setTag(1000 + i); @@ -335,7 +298,7 @@ void TouchEventDispatchingPerfTest::generateTestFunctions() dispatcher->addEventListenerWithSceneGraphPriority(listener->clone(), node); } - _lastRenderedCount = _quantityOfNodes; + _lastRenderedCount = quantityOfNodes; } Size size = Director::getInstance()->getWinSize(); @@ -359,7 +322,7 @@ void TouchEventDispatchingPerfTest::generateTestFunctions() { "OneByOne-fixed", [=](){ auto dispatcher = Director::getInstance()->getEventDispatcher(); - if (_quantityOfNodes != _lastRenderedCount) + if (quantityOfNodes != _lastRenderedCount) { auto listener = EventListenerTouchOneByOne::create(); listener->onTouchBegan = [](Touch* touch, Event* event){ @@ -369,14 +332,14 @@ void TouchEventDispatchingPerfTest::generateTestFunctions() listener->onTouchMoved = [](Touch* touch, Event* event){}; listener->onTouchEnded = [](Touch* touch, Event* event){}; - for (int i = 0; i < this->_quantityOfNodes; ++i) + for (int i = 0; i < this->quantityOfNodes; ++i) { auto l = listener->clone(); this->_fixedPriorityListeners.push_back(l); dispatcher->addEventListenerWithFixedPriority(l, i+1); } - _lastRenderedCount = _quantityOfNodes; + _lastRenderedCount = quantityOfNodes; } Size size = Director::getInstance()->getWinSize(); @@ -400,7 +363,7 @@ void TouchEventDispatchingPerfTest::generateTestFunctions() { "AllAtOnce-scenegraph", [=](){ auto dispatcher = Director::getInstance()->getEventDispatcher(); - if (_quantityOfNodes != _lastRenderedCount) + if (quantityOfNodes != _lastRenderedCount) { auto listener = EventListenerTouchAllAtOnce::create(); listener->onTouchesBegan = [](const std::vector touches, Event* event){}; @@ -408,7 +371,7 @@ void TouchEventDispatchingPerfTest::generateTestFunctions() listener->onTouchesEnded = [](const std::vector touches, Event* event){}; // Create new touchable nodes - for (int i = 0; i < this->_quantityOfNodes; ++i) + for (int i = 0; i < this->quantityOfNodes; ++i) { auto node = Node::create(); node->setTag(1000 + i); @@ -417,7 +380,7 @@ void TouchEventDispatchingPerfTest::generateTestFunctions() dispatcher->addEventListenerWithSceneGraphPriority(listener->clone(), node); } - _lastRenderedCount = _quantityOfNodes; + _lastRenderedCount = quantityOfNodes; } Size size = Director::getInstance()->getWinSize(); @@ -441,21 +404,21 @@ void TouchEventDispatchingPerfTest::generateTestFunctions() { "AllAtOnce-fixed", [=](){ auto dispatcher = Director::getInstance()->getEventDispatcher(); - if (_quantityOfNodes != _lastRenderedCount) + if (quantityOfNodes != _lastRenderedCount) { auto listener = EventListenerTouchAllAtOnce::create(); listener->onTouchesBegan = [](const std::vector touches, Event* event){}; listener->onTouchesMoved = [](const std::vector touches, Event* event){}; listener->onTouchesEnded = [](const std::vector touches, Event* event){}; - for (int i = 0; i < this->_quantityOfNodes; ++i) + for (int i = 0; i < this->quantityOfNodes; ++i) { auto l = listener->clone(); this->_fixedPriorityListeners.push_back(l); dispatcher->addEventListenerWithFixedPriority(l, i+1); } - _lastRenderedCount = _quantityOfNodes; + _lastRenderedCount = quantityOfNodes; } Size size = Director::getInstance()->getWinSize(); @@ -479,7 +442,7 @@ void TouchEventDispatchingPerfTest::generateTestFunctions() { "TouchModeMix-scenegraph", [=](){ auto dispatcher = Director::getInstance()->getEventDispatcher(); - if (_quantityOfNodes != _lastRenderedCount) + if (quantityOfNodes != _lastRenderedCount) { auto listenerOneByOne = EventListenerTouchOneByOne::create(); listenerOneByOne->onTouchBegan = [](Touch* touch, Event* event){ @@ -496,7 +459,7 @@ void TouchEventDispatchingPerfTest::generateTestFunctions() int i = 0; // Create new touchable nodes - for (; i < this->_quantityOfNodes/2; ++i) + for (; i < this->quantityOfNodes/2; ++i) { auto node = Node::create(); node->setTag(1000 + i); @@ -505,7 +468,7 @@ void TouchEventDispatchingPerfTest::generateTestFunctions() dispatcher->addEventListenerWithSceneGraphPriority(listenerOneByOne->clone(), node); } - for (; i < this->_quantityOfNodes; ++i) + for (; i < this->quantityOfNodes; ++i) { auto node = Node::create(); node->setTag(1000 + i); @@ -514,7 +477,7 @@ void TouchEventDispatchingPerfTest::generateTestFunctions() dispatcher->addEventListenerWithSceneGraphPriority(listenerAllAtOnce->clone(), node); } - _lastRenderedCount = _quantityOfNodes; + _lastRenderedCount = quantityOfNodes; } Size size = Director::getInstance()->getWinSize(); @@ -538,7 +501,7 @@ void TouchEventDispatchingPerfTest::generateTestFunctions() { "TouchModeMix-fixed", [=](){ auto dispatcher = Director::getInstance()->getEventDispatcher(); - if (_quantityOfNodes != _lastRenderedCount) + if (quantityOfNodes != _lastRenderedCount) { auto listenerOneByOne = EventListenerTouchOneByOne::create(); listenerOneByOne->onTouchBegan = [](Touch* touch, Event* event){ @@ -555,21 +518,21 @@ void TouchEventDispatchingPerfTest::generateTestFunctions() int i = 0; - for (; i < this->_quantityOfNodes/2; ++i) + for (; i < this->quantityOfNodes/2; ++i) { auto l = listenerOneByOne->clone(); this->_fixedPriorityListeners.push_back(l); dispatcher->addEventListenerWithFixedPriority(l, i+1); } - for (; i < this->_quantityOfNodes; ++i) + for (; i < this->quantityOfNodes; ++i) { auto l = listenerAllAtOnce->clone(); this->_fixedPriorityListeners.push_back(l); dispatcher->addEventListenerWithFixedPriority(l, i+1); } - _lastRenderedCount = _quantityOfNodes; + _lastRenderedCount = quantityOfNodes; } Size size = Director::getInstance()->getWinSize(); @@ -619,14 +582,14 @@ void KeyboardEventDispatchingPerfTest::generateTestFunctions() TestFunction testFunctions[] = { { "keyboard-scenegraph", [=](){ auto dispatcher = Director::getInstance()->getEventDispatcher(); - if (_quantityOfNodes != _lastRenderedCount) + if (quantityOfNodes != _lastRenderedCount) { auto listener = EventListenerKeyboard::create(); listener->onKeyPressed = [](EventKeyboard::KeyCode keyCode, Event* event){}; listener->onKeyReleased = [](EventKeyboard::KeyCode keyCode, Event* event){}; // Create new nodes listen to keyboard event - for (int i = 0; i < this->_quantityOfNodes; ++i) + for (int i = 0; i < this->quantityOfNodes; ++i) { auto node = Node::create(); node->setTag(1000 + i); @@ -635,7 +598,7 @@ void KeyboardEventDispatchingPerfTest::generateTestFunctions() dispatcher->addEventListenerWithSceneGraphPriority(listener->clone(), node); } - _lastRenderedCount = _quantityOfNodes; + _lastRenderedCount = quantityOfNodes; } EventKeyboard event(EventKeyboard::KeyCode::KEY_RETURN, true); @@ -647,20 +610,20 @@ void KeyboardEventDispatchingPerfTest::generateTestFunctions() { "keyboard-fixed", [=](){ auto dispatcher = Director::getInstance()->getEventDispatcher(); - if (_quantityOfNodes != _lastRenderedCount) + if (quantityOfNodes != _lastRenderedCount) { auto listener = EventListenerKeyboard::create(); listener->onKeyPressed = [](EventKeyboard::KeyCode keyCode, Event* event){}; listener->onKeyReleased = [](EventKeyboard::KeyCode keyCode, Event* event){}; - for (int i = 0; i < this->_quantityOfNodes; ++i) + for (int i = 0; i < this->quantityOfNodes; ++i) { auto l = listener->clone(); this->_fixedPriorityListeners.push_back(l); dispatcher->addEventListenerWithFixedPriority(l, i+1); } - _lastRenderedCount = _quantityOfNodes; + _lastRenderedCount = quantityOfNodes; } EventKeyboard event(EventKeyboard::KeyCode::KEY_RETURN, true); @@ -719,12 +682,12 @@ void CustomEventDispatchingPerfTest::generateTestFunctions() TestFunction testFunctions[] = { { "custom-scenegraph", [=](){ auto dispatcher = Director::getInstance()->getEventDispatcher(); - if (_quantityOfNodes != _lastRenderedCount) + if (quantityOfNodes != _lastRenderedCount) { auto listener = EventListenerCustom::create("custom_event_test_scenegraph", [](EventCustom* event){}); // Create new nodes listen to custom event - for (int i = 0; i < this->_quantityOfNodes; ++i) + for (int i = 0; i < this->quantityOfNodes; ++i) { auto node = Node::create(); node->setTag(1000 + i); @@ -733,7 +696,7 @@ void CustomEventDispatchingPerfTest::generateTestFunctions() dispatcher->addEventListenerWithSceneGraphPriority(listener->clone(), node); } - _lastRenderedCount = _quantityOfNodes; + _lastRenderedCount = quantityOfNodes; } EventCustom event("custom_event_test_scenegraph"); @@ -744,18 +707,18 @@ void CustomEventDispatchingPerfTest::generateTestFunctions() } } , { "custom-fixed", [=](){ auto dispatcher = Director::getInstance()->getEventDispatcher(); - if (_quantityOfNodes != _lastRenderedCount) + if (quantityOfNodes != _lastRenderedCount) { auto listener = EventListenerCustom::create("custom_event_test_fixed", [](EventCustom* event){}); - for (int i = 0; i < this->_quantityOfNodes; ++i) + for (int i = 0; i < this->quantityOfNodes; ++i) { auto l = listener->clone(); this->_fixedPriorityListeners.push_back(l); dispatcher->addEventListenerWithFixedPriority(l, i+1); } - _lastRenderedCount = _quantityOfNodes; + _lastRenderedCount = quantityOfNodes; } EventCustom event("custom_event_test_fixed"); @@ -781,13 +744,3 @@ std::string CustomEventDispatchingPerfTest::subtitle() const { return "Test 'custom-scenegraph', See console"; } - -///---------------------------------------- -void runEventDispatcherPerformanceTest() -{ - auto scene = createFunctions[g_curCase](); - scene->initWithQuantityOfNodes(kNodesIncrease); - - Director::getInstance()->replaceScene(scene); -} - diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceEventDispatcherTest.h b/tests/cpp-tests/Classes/PerformanceTest/PerformanceEventDispatcherTest.h index 54ac11e0ad..f840ca50cb 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceEventDispatcherTest.h +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceEventDispatcherTest.h @@ -4,17 +4,11 @@ #ifndef __PERFORMANCE_EVENTDISPATCHER_TEST_H__ #define __PERFORMANCE_EVENTDISPATCHER_TEST_H__ -#include "PerformanceTest.h" +#include "BaseTest.h" -class EventDispatcherBasicLayer : public PerformBasicLayer -{ -public: - EventDispatcherBasicLayer(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0); - - virtual void showCurrentTest(); -}; +DEFINE_TEST_SUITE(PerformceEventDispatcherTests); -class PerformanceEventDispatcherScene : public cocos2d::Scene +class PerformanceEventDispatcherScene : public TestCase { public: static const int TAG_TITLE = 100; @@ -26,6 +20,7 @@ public: std::function func; }; + virtual bool init() override; virtual void initWithQuantityOfNodes(unsigned int nNodes); virtual void generateTestFunctions() = 0; @@ -39,16 +34,16 @@ public: // for the profiler virtual const char* testName(); void updateQuantityLabel(); - int getQuantityOfNodes() { return _quantityOfNodes; } void dumpProfilerInfo(float dt); // overrides virtual void update(float dt) override; protected: + static int quantityOfNodes; + char _profilerName[256]; int _lastRenderedCount; - int _quantityOfNodes; int _currentQuantityOfNodes; unsigned int _type; std::vector _testFunctions; @@ -100,6 +95,4 @@ private: std::vector _customListeners; }; -void runEventDispatcherPerformanceTest(); - #endif /* defined(__PERFORMANCE_EVENTDISPATCHER_TEST_H__) */ diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceLabelTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceLabelTest.cpp index 15f9bc17f6..019df97a28 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceLabelTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceLabelTest.cpp @@ -28,50 +28,16 @@ enum { Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." - -//////////////////////////////////////////////////////// -// -// LabelMenuLayer -// -//////////////////////////////////////////////////////// -void LabelMenuLayer::restartCallback(Ref* sender) +PerformceLabelTests::PerformceLabelTests() { - if ( LabelMainScene::_s_autoTest ) - { - log("It's auto label performance testing,so this operation is invalid"); - return; - } - - PerformBasicLayer::restartCallback(sender); + LabelMainScene::_s_labelCurCase = 0; + addTestCase("LabelTTF Performance Test", [](){ return LabelMainScene::create(); }); + addTestCase("LabelBMFont Performance Test", [](){ return LabelMainScene::create(); }); + addTestCase("Label Performance Test", [](){ return LabelMainScene::create(); }); + addTestCase("LabelBMFont large text Performance", [](){ return LabelMainScene::create(); }); + addTestCase("Label large text Performance", [](){ return LabelMainScene::create(); }); } -void LabelMenuLayer::nextCallback(Ref* sender) -{ - if ( LabelMainScene::_s_autoTest ) - { - log("It's auto label performance testing,so this operation is invalid"); - return; - } - - PerformBasicLayer::nextCallback(sender); -} - -void LabelMenuLayer::backCallback(Ref* sender) -{ - if ( LabelMainScene::_s_autoTest ) - { - log("It's auto label performance testing,so this operation is invalid"); - return; - } - - PerformBasicLayer::backCallback(sender); -} - -void LabelMenuLayer::showCurrentTest() -{ - auto scene = (LabelMainScene*) getParent(); - scene->autoShowLabelTests(_curCase,LabelMainScene::AUTO_TEST_NODE_NUM); -} //////////////////////////////////////////////////////// // // LabelMainScene @@ -80,10 +46,16 @@ void LabelMenuLayer::showCurrentTest() bool LabelMainScene::_s_autoTest = false; int LabelMainScene::_s_labelCurCase = 0; +int LabelMainScene::NODE_TEST_COUNT = AUTO_TEST_NODE_NUM; -void LabelMainScene::initWithSubTest(int nodes) +bool LabelMainScene::init() { //srandom(0); + if (!TestCase::init()) + { + return false; + } + auto s = Director::getInstance()->getWinSize(); _lastRenderedCount = 0; @@ -108,11 +80,6 @@ void LabelMainScene::initWithSubTest(int nodes) infoLabel->setColor(Color3B(0,200,20)); infoLabel->setPosition(Vec2(s.width/2, s.height-90)); addChild(infoLabel, 1, kTagInfoLayer); - - // add menu - auto menuLayer = new (std::nothrow) LabelMenuLayer(true, TEST_COUNT, LabelMainScene::_s_labelCurCase); - addChild(menuLayer, 1, kTagMenuLayer); - menuLayer->release(); /** * auto test menu @@ -137,13 +104,11 @@ void LabelMainScene::initWithSubTest(int nodes) autoTestItem->setColor(Color3B::RED); menuAutoTest->addChild(autoTestItem); addChild( menuAutoTest, 3, kTagAutoTestMenu ); - - _title = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); - addChild(_title, 1); - _title->setPosition(Vec2(s.width/2, s.height-50)); - while(_quantityNodes < nodes) + while (_quantityNodes < NODE_TEST_COUNT) onIncrease(this); + + return true; } std::string LabelMainScene::title() const @@ -190,7 +155,6 @@ void LabelMainScene::onIncrease(Ref* sender) return; auto size = Director::getInstance()->getWinSize(); - switch (_s_labelCurCase) { case kCaseLabelTTFUpdate: @@ -369,20 +333,6 @@ void LabelMainScene::onExit() Scene::onExit(); } -void LabelMainScene::autoShowLabelTests(int curCase,int nodes) -{ - LabelMainScene::_s_labelCurCase = curCase; - _title->setString(title()); - _vecFPS.clear(); - _executeTimes = 0; - _labelContainer->removeAllChildren(); - _lastRenderedCount = 0; - _quantityNodes = 0; - _accumulativeTime = 0.0f; - while(_quantityNodes < nodes) - onIncrease(this); -} - void LabelMainScene::endAutoTest() { LabelMainScene::_s_autoTest = false; @@ -395,8 +345,7 @@ void LabelMainScene::nextAutoTest() { if ( LabelMainScene::_s_labelCurCase + 1 < LabelMainScene::MAX_SUB_TEST_NUMS ) { - LabelMainScene::_s_labelCurCase += 1; - autoShowLabelTests(LabelMainScene::_s_labelCurCase, _quantityNodes); + nextTestCallback(nullptr); } else { @@ -407,7 +356,9 @@ void LabelMainScene::nextAutoTest() void LabelMainScene::finishAutoTest() { LabelMainScene::_s_autoTest = false; - + _vecFPS.clear(); + _executeTimes = 0; + auto autoTestMenu = dynamic_cast(getChildByTag(kTagAutoTestMenu)); if (nullptr != autoTestMenu) { @@ -424,13 +375,14 @@ void LabelMainScene::finishAutoTest() void LabelMainScene::onAutoTest(Ref* sender) { LabelMainScene::_s_autoTest = !LabelMainScene::_s_autoTest; + _vecFPS.clear(); + _executeTimes = 0; MenuItemFont* menuItem = dynamic_cast(sender); if (nullptr != menuItem) { if (LabelMainScene::_s_autoTest) { menuItem->setString("Auto Test On"); - autoShowLabelTests(0,_quantityNodes); } else { @@ -440,11 +392,23 @@ void LabelMainScene::onAutoTest(Ref* sender) } } -void runLabelTest() +void LabelMainScene::nextTestCallback(cocos2d::Ref* sender) { - LabelMainScene::_s_autoTest = false; - auto scene = new (std::nothrow) LabelMainScene; - scene->initWithSubTest(LabelMainScene::AUTO_TEST_NODE_NUM); - Director::getInstance()->replaceScene(scene); - scene->release(); + NODE_TEST_COUNT = _quantityNodes; + _s_labelCurCase = (_s_labelCurCase + 1) % MAX_SUB_TEST_NUMS; + TestCase::nextTestCallback(sender); +} + +void LabelMainScene::priorTestCallback(cocos2d::Ref* sender) +{ + NODE_TEST_COUNT = _quantityNodes; + if (_s_labelCurCase > 0) + { + _s_labelCurCase -= 1; + } + else + { + _s_labelCurCase = MAX_SUB_TEST_NUMS - 1; + } + TestCase::priorTestCallback(sender); } diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceLabelTest.h b/tests/cpp-tests/Classes/PerformanceTest/PerformanceLabelTest.h index 0020103733..51ced55498 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceLabelTest.h +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceLabelTest.h @@ -1,31 +1,21 @@ #ifndef __PERFORMANCE_LABEL_TEST_H__ #define __PERFORMANCE_LABEL_TEST_H__ -#include "PerformanceTest.h" +#include "BaseTest.h" -class LabelMenuLayer : public PerformBasicLayer -{ -public: - LabelMenuLayer(bool controlMenuVisible, int maxCases = 0, int curCase = 0) - : PerformBasicLayer(controlMenuVisible, maxCases, curCase) - { - } +DEFINE_TEST_SUITE(PerformceLabelTests); - virtual void restartCallback(cocos2d::Ref* sender) override; - virtual void nextCallback(cocos2d::Ref* sender) override; - virtual void backCallback(cocos2d::Ref* sender) override; - virtual void showCurrentTest() override; -}; - -class LabelMainScene : public cocos2d::Scene +class LabelMainScene : public TestCase { public: static const int AUTO_TEST_NODE_NUM = 20; + CREATE_FUNC(LabelMainScene); + virtual ~LabelMainScene(); std::string title() const; - void initWithSubTest(int nodes); + virtual bool init() override; void updateNodes(); void onIncrease(cocos2d::Ref* sender); @@ -38,18 +28,19 @@ public: void updateText(float dt); void onAutoTest(cocos2d::Ref* sender); - void autoShowLabelTests(int curCase,int nodes); - virtual void onEnter() override; virtual void onExit() override; + virtual void nextTestCallback(cocos2d::Ref* sender) override; + virtual void priorTestCallback(cocos2d::Ref* sender) override; + static bool _s_autoTest; static int _s_labelCurCase; private: static const int MAX_AUTO_TEST_TIMES = 35; static const int MAX_SUB_TEST_NUMS = 5; - + static int NODE_TEST_COUNT; void dumpProfilerFPS(); @@ -57,8 +48,7 @@ private: void nextAutoTest(); void finishAutoTest(); - cocos2d::Layer* _labelContainer; - cocos2d::Label* _title; + cocos2d::Layer* _labelContainer; int _lastRenderedCount; int _quantityNodes; @@ -69,6 +59,4 @@ private: float _accumulativeTime; }; -void runLabelTest(); - #endif diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceMathTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceMathTest.cpp index db42a63201..4cb1ba50ce 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceMathTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceMathTest.cpp @@ -29,43 +29,18 @@ USING_NS_CC; #undef CC_PROFILER_RESET_INSTANCE #define CC_PROFILER_RESET_INSTANCE(__id__, __name__) do{ ProfilingResetTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0) -static const int TEST_COUNT = 2; -static int s_nTouchCurCase = 0; - static const int K_INFO_LOOP_TAG = 1581; -static PerformanceMathLayer* createLayer() +PerformceMathTests::PerformceMathTests() { - s_nTouchCurCase = s_nTouchCurCase % TEST_COUNT; - - PerformanceMathLayer* result = nullptr; - - switch (s_nTouchCurCase) { - case 0: - result = new PerformanceMathLayer1(true, TEST_COUNT, s_nTouchCurCase); - break; - case 1: - result = new PerformanceMathLayer2(true, TEST_COUNT, s_nTouchCurCase); - break; - default: - result = new PerformanceMathLayer1(true, TEST_COUNT, s_nTouchCurCase); - break; - } - - if(result) - { - result->autorelease(); - return result; - } - else - { - return nullptr; - } + ADD_TEST_CASE(PerformanceMathLayer1); + ADD_TEST_CASE(PerformanceMathLayer2); + ADD_TEST_CASE(PerformanceMathLayer1); } void PerformanceMathLayer::onEnter() { - PerformBasicLayer::onEnter(); + TestCase::onEnter(); _loopCount = 10000; _stepCount = 10000; @@ -73,19 +48,6 @@ void PerformanceMathLayer::onEnter() CC_PROFILER_PURGE_ALL(); auto s = Director::getInstance()->getWinSize(); - // Title - auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); - addChild(label, 1); - label->setPosition(Vec2(s.width/2, s.height-50)); - - // Subtitle - std::string strSubTitle = subtitle(); - if(strSubTitle.length()) - { - auto l = Label::createWithTTF(strSubTitle.c_str(), "fonts/Thonburi.ttf", 16); - addChild(l, 1); - l->setPosition(Vec2(s.width/2, s.height-80)); - } MenuItemFont::setFontSize(65); auto decrease = MenuItemFont::create(" - ", CC_CALLBACK_1(PerformanceMathLayer::subLoopCount, this)); @@ -131,26 +93,6 @@ void PerformanceMathLayer::updateLoopLabel() } -void PerformanceMathLayer::restartCallback(Ref* sender) -{ - s_nTouchCurCase = 0; - runMathPerformanceTest(); -} - -void PerformanceMathLayer::nextCallback(Ref* sender) -{ - ++s_nTouchCurCase; - s_nTouchCurCase = s_nTouchCurCase % TEST_COUNT; - runMathPerformanceTest(); -} - -void PerformanceMathLayer::backCallback(Ref* sender) -{ - s_nTouchCurCase = s_nTouchCurCase + TEST_COUNT -1; - s_nTouchCurCase = s_nTouchCurCase % TEST_COUNT; - runMathPerformanceTest(); -} - void PerformanceMathLayer::dumpProfilerInfo(float dt) { CC_PROFILER_DISPLAY_TIMERS(); @@ -183,13 +125,3 @@ void PerformanceMathLayer2::doPerformanceTest(float dt) CC_PROFILER_STOP(_profileName.c_str()); } - -void runMathPerformanceTest() -{ - auto scene = Scene::create(); - auto layer = createLayer(); - - scene->addChild(layer); - - Director::getInstance()->replaceScene(scene); -} diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceMathTest.h b/tests/cpp-tests/Classes/PerformanceTest/PerformanceMathTest.h index c0b331de66..beb22fa5bf 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceMathTest.h +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceMathTest.h @@ -1,14 +1,15 @@ #ifndef __PERFORMANCE_MATH_TEST_H__ #define __PERFORMANCE_MATH_TEST_H__ -#include "PerformanceTest.h" +#include "BaseTest.h" -class PerformanceMathLayer : public PerformBasicLayer +DEFINE_TEST_SUITE(PerformceMathTests); + +class PerformanceMathLayer : public TestCase { public: - PerformanceMathLayer(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0): - PerformBasicLayer(bControlMenuVisible, nMaxCases, nCurCase) - , _loopCount(1000) + PerformanceMathLayer() + : _loopCount(1000) , _stepCount(500) , _profileName("") { @@ -16,11 +17,6 @@ public: } virtual void onEnter() override; - virtual void restartCallback(cocos2d::Ref* sender) override; - virtual void nextCallback(cocos2d::Ref* sender) override; - virtual void backCallback(cocos2d::Ref* sender) override; - - virtual void showCurrentTest() {} virtual std::string title() const { return "Math Performance Test"; } virtual std::string subtitle() const { return "PerformanceMathLayer subTitle"; } @@ -41,8 +37,9 @@ protected: class PerformanceMathLayer1 : public PerformanceMathLayer { public: - PerformanceMathLayer1(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0): - PerformanceMathLayer(bControlMenuVisible, nMaxCases, nCurCase) + CREATE_FUNC(PerformanceMathLayer1); + + PerformanceMathLayer1() { _profileName = "profile_Mat4*Mat4"; } @@ -56,8 +53,9 @@ private: class PerformanceMathLayer2 : public PerformanceMathLayer { public: - PerformanceMathLayer2(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0): - PerformanceMathLayer(bControlMenuVisible, nMaxCases, nCurCase) + CREATE_FUNC(PerformanceMathLayer2); + + PerformanceMathLayer2() { _profileName = "profile_MatTransformVec4"; } @@ -68,6 +66,4 @@ public: }; -void runMathPerformanceTest(); - #endif //__PERFORMANCE_MATH_TEST_H__ diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp index 5593c14d20..0a615d8868 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -30,26 +30,21 @@ USING_NS_CC; #undef CC_PROFILER_RESET_INSTANCE #define CC_PROFILER_RESET_INSTANCE(__id__, __name__) do{ ProfilingResetTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0) -static std::function createFunctions[] = +PerformceNodeChildrenTests::PerformceNodeChildrenTests() { - CL(IterateSpriteSheetForLoop), - CL(IterateSpriteSheetIterator), - CL(IterateSpriteSheetForEach), - - CL(CallFuncsSpriteSheetForEach), - - CL(AddSprite), - CL(AddSpriteSheet), - CL(GetSpriteSheet), - CL(RemoveSprite), - CL(RemoveSpriteSheet), - CL(ReorderSpriteSheet), - CL(SortAllChildrenSpriteSheet), - - CL(VisitSceneGraph), -}; - -#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) + ADD_TEST_CASE(IterateSpriteSheetForLoop); + ADD_TEST_CASE(IterateSpriteSheetIterator); + ADD_TEST_CASE(IterateSpriteSheetForEach); + ADD_TEST_CASE(CallFuncsSpriteSheetForEach); + ADD_TEST_CASE(AddSprite); + ADD_TEST_CASE(AddSpriteSheet); + ADD_TEST_CASE(GetSpriteSheet); + ADD_TEST_CASE(RemoveSprite); + ADD_TEST_CASE(RemoveSpriteSheet); + ADD_TEST_CASE(ReorderSpriteSheet); + ADD_TEST_CASE(SortAllChildrenSpriteSheet); + ADD_TEST_CASE(VisitSceneGraph); +} enum { kTagInfoLayer = 1, @@ -62,81 +57,51 @@ enum { kNodesIncrease = 500, }; -static int g_curCase = 0; - -//////////////////////////////////////////////////////// -// -// NodeChildrenMenuLayer -// -//////////////////////////////////////////////////////// -NodeChildrenMenuLayer::NodeChildrenMenuLayer(bool bControlMenuVisible, int nMaxCases, int nCurCase) -: PerformBasicLayer(bControlMenuVisible, nMaxCases, nCurCase) -{ -} - -void NodeChildrenMenuLayer::onExitTransitionDidStart() -{ - auto director = Director::getInstance(); - auto sched = director->getScheduler(); - - sched->unschedule(CC_SCHEDULE_SELECTOR(NodeChildrenMenuLayer::dumpProfilerInfo), this); -} - -void NodeChildrenMenuLayer::onEnterTransitionDidFinish() -{ - auto director = Director::getInstance(); - auto sched = director->getScheduler(); - - CC_PROFILER_PURGE_ALL(); - sched->schedule(CC_SCHEDULE_SELECTOR(NodeChildrenMenuLayer::dumpProfilerInfo), this, 2, false); -} - - -void NodeChildrenMenuLayer::dumpProfilerInfo(float dt) -{ - CC_PROFILER_DISPLAY_TIMERS(); -} - -void NodeChildrenMenuLayer::showCurrentTest() -{ - int nodes = ((NodeChildrenMainScene*)getParent())->getQuantityOfNodes(); - - auto scene = createFunctions[_curCase](); - - g_curCase = _curCase; - - if (scene) - { - scene->initWithQuantityOfNodes(nodes); - - Director::getInstance()->replaceScene(scene); - } -} +int NodeChildrenMainScene::quantityOfNodes = kNodesIncrease; //////////////////////////////////////////////////////// // // NodeChildrenMainScene // //////////////////////////////////////////////////////// +bool NodeChildrenMainScene::init() +{ + if (TestCase::init()) + { + initWithQuantityOfNodes(quantityOfNodes); + return true; + } + + return false; +} + +void NodeChildrenMainScene::onExitTransitionDidStart() +{ + auto director = Director::getInstance(); + auto sched = director->getScheduler(); + + sched->unschedule(CC_SCHEDULE_SELECTOR(NodeChildrenMainScene::dumpProfilerInfo), this); +} + +void NodeChildrenMainScene::onEnterTransitionDidFinish() +{ + auto director = Director::getInstance(); + auto sched = director->getScheduler(); + + CC_PROFILER_PURGE_ALL(); + sched->schedule(CC_SCHEDULE_SELECTOR(NodeChildrenMainScene::dumpProfilerInfo), this, 2, false); +} + +void NodeChildrenMainScene::dumpProfilerInfo(float dt) +{ + CC_PROFILER_DISPLAY_TIMERS(); +} + void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) { //srand(time()); auto s = Director::getInstance()->getWinSize(); - // Title - auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); - addChild(label, 1); - label->setPosition(Vec2(s.width/2, s.height-50)); - - // Subtitle - std::string strSubTitle = subtitle(); - if(strSubTitle.length()) - { - auto l = Label::createWithTTF(strSubTitle.c_str(), "fonts/Thonburi.ttf", 16); - addChild(l, 1); - l->setPosition(Vec2(s.width/2, s.height-80)); - } - lastRenderedCount = 0; currentQuantityOfNodes = 0; quantityOfNodes = nNodes; @@ -177,10 +142,6 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) infoLabel->setPosition(Vec2(s.width/2, s.height/2-15)); addChild(infoLabel, 1, kTagInfoLayer); - auto menuLayer = new (std::nothrow) NodeChildrenMenuLayer(true, MAX_LAYER, g_curCase); - addChild(menuLayer); - menuLayer->release(); - updateQuantityLabel(); updateQuantityOfNodes(); updateProfilerName(); @@ -968,12 +929,3 @@ const char* VisitSceneGraph::testName() { return "visit()"; } - -///---------------------------------------- -void runNodeChildrenTest() -{ - auto scene = createFunctions[g_curCase](); - scene->initWithQuantityOfNodes(kNodesIncrease); - - Director::getInstance()->replaceScene(scene); -} diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceNodeChildrenTest.h b/tests/cpp-tests/Classes/PerformanceTest/PerformanceNodeChildrenTest.h index eccb337b53..b23b312487 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceNodeChildrenTest.h +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceNodeChildrenTest.h @@ -1,29 +1,17 @@ #ifndef __PERFORMANCE_NODE_CHILDREN_TEST_H__ #define __PERFORMANCE_NODE_CHILDREN_TEST_H__ -#include "PerformanceTest.h" +#include "BaseTest.h" -class NodeChildrenMenuLayer : public PerformBasicLayer -{ -public: - CREATE_FUNC(NodeChildrenMenuLayer); - - NodeChildrenMenuLayer(); - NodeChildrenMenuLayer(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0); - virtual void showCurrentTest(); - void dumpProfilerInfo(float dt); - - // overrides - virtual void onExitTransitionDidStart() override; - virtual void onEnterTransitionDidFinish() override; -}; - -class NodeChildrenMainScene : public cocos2d::Scene +DEFINE_TEST_SUITE(PerformceNodeChildrenTests); + +class NodeChildrenMainScene : public TestCase { public: + virtual bool init() override; virtual void initWithQuantityOfNodes(unsigned int nNodes); - virtual std::string title() const; - virtual std::string subtitle() const; + virtual std::string title() const override; + virtual std::string subtitle() const override; virtual void updateQuantityOfNodes() = 0; const char* profilerName(); @@ -34,19 +22,21 @@ public: void updateQuantityLabel(); - int getQuantityOfNodes() { return quantityOfNodes; } + void dumpProfilerInfo(float dt); + virtual void onExitTransitionDidStart() override; + virtual void onEnterTransitionDidFinish() override; protected: + static int quantityOfNodes; char _profilerName[256]; int lastRenderedCount; - int quantityOfNodes; int currentQuantityOfNodes; }; class IterateSpriteSheet : public NodeChildrenMainScene { public: - ~IterateSpriteSheet(); + virtual ~IterateSpriteSheet(); virtual void updateQuantityOfNodes(); virtual void initWithQuantityOfNodes(unsigned int nNodes); virtual void update(float dt) = 0; @@ -98,7 +88,7 @@ public: class AddRemoveSpriteSheet : public NodeChildrenMainScene { public: - ~AddRemoveSpriteSheet(); + virtual ~AddRemoveSpriteSheet(); virtual void updateQuantityOfNodes(); virtual void initWithQuantityOfNodes(unsigned int nNodes); virtual void update(float dt) = 0; @@ -226,6 +216,4 @@ public: virtual const char* testName() override; }; -void runNodeChildrenTest(); - #endif // __PERFORMANCE_NODE_CHILDREN_TEST_H__ diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticle3DTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticle3DTest.cpp index 49e91a2c2d..ead94295aa 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticle3DTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticle3DTest.cpp @@ -5,49 +5,14 @@ USING_NS_CC; using namespace cocos2d::ui; static int kTagInfoLayer = 1; -static int kTagMenuLayer = 1000; static int kTagParticleSystem = 1001; -static int test_Count = 2; static int kMaxParticles = 14000; static int kNodesIncrease = 1; -static int s_parCurIdx = 0; - -//////////////////////////////////////////////////////// -// -// ParticleMenuLayer -// -//////////////////////////////////////////////////////// -Particle3DMenuLayer::Particle3DMenuLayer(bool isControlMenuVisible, int maxCases, int curCase) -: PerformBasicLayer(isControlMenuVisible, maxCases, curCase) +PerformceParticle3DTests::PerformceParticle3DTests() { - -} - -void Particle3DMenuLayer::showCurrentTest() -{ - auto scene = (Particle3DMainScene*)getParent(); - int subTest = scene->getSubTestNum(); - int parNum = scene->getParticlesNum(); - - Particle3DMainScene* pNewScene = nullptr; - - switch (_curCase) - { - case 0: - pNewScene = new (std::nothrow) Particle3DPerformTest; - break; - } - - s_parCurIdx = _curCase; - if (pNewScene) - { - pNewScene->initWithSubTest(subTest, parNum); - - Director::getInstance()->replaceScene(pNewScene); - pNewScene->release(); - } + ADD_TEST_CASE(Particle3DPerformTest); } //////////////////////////////////////////////////////// @@ -95,15 +60,6 @@ void Particle3DMainScene::initWithSubTest(int asubtest, int particles) infoLabel->setPosition(Vec2(s.width/2, s.height - 90)); addChild(infoLabel, 1, kTagInfoLayer); - // Next Prev Test - auto menuLayer = new (std::nothrow) Particle3DMenuLayer(true, test_Count, s_parCurIdx); - addChild(menuLayer, 1, kTagMenuLayer); - menuLayer->release(); - - auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); - addChild(label, 1); - label->setPosition(Vec2(s.width/2, s.height-50)); - auto camera = Camera::createPerspective(30.0f, s.width / s.height, 1.0f, 1000.0f); camera->setPosition3D(Vec3(0.0f, 0.0f, 150.0f)); camera->lookAt(Vec3(0.0f, 0.0f, 0.0f), Vec3(0.0f, 1.0f, 0.0f)); @@ -122,11 +78,6 @@ void Particle3DMainScene::initWithSubTest(int asubtest, int particles) schedule(CC_SCHEDULE_SELECTOR(Particle3DMainScene::step)); } -std::string Particle3DMainScene::title() const -{ - return "No title"; -} - void Particle3DMainScene::step(float dt) { unsigned int count = 0; @@ -158,14 +109,6 @@ void Particle3DMainScene::createParticleSystem(int idx) addChild(ps, 0, kTagParticleSystem + idx); } -void Particle3DMainScene::testNCallback(Ref* sender) -{ - _subtestNumber = static_cast(sender)->getTag(); - - auto menu = static_cast( getChildByTag(kTagMenuLayer) ); - menu->restartCallback(sender); -} - void Particle3DMainScene::updateQuantityLabel() { if( _quantityParticles != _lastRenderedCount ) @@ -186,22 +129,16 @@ void Particle3DMainScene::updateQuantityLabel() //////////////////////////////////////////////////////// std::string Particle3DPerformTest::title() const { - char str[20] = {0}; - sprintf(str, "Particle3D Test"/*, subtestNumber*/); - std::string strRet = str; - return strRet; + return "Particle3D Test"; } -void Particle3DPerformTest::doTest() +bool Particle3DPerformTest::init() { - auto s = Director::getInstance()->getWinSize(); -} + if (Particle3DMainScene::init()) + { + initWithSubTest(1, kNodesIncrease); + return true; + } -void runParticle3DTest() -{ - auto scene = new (std::nothrow) Particle3DPerformTest; - scene->initWithSubTest(1, kNodesIncrease); - - Director::getInstance()->replaceScene(scene); - scene->release(); + return false; } diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticle3DTest.h b/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticle3DTest.h index 8152aa9c4b..5cb6a733c4 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticle3DTest.h +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticle3DTest.h @@ -1,20 +1,14 @@ #ifndef __PERFORMANCE_PARTICLE_3D_TEST_H__ #define __PERFORMANCE_PARTICLE_3D_TEST_H__ -#include "PerformanceTest.h" +#include "BaseTest.h" -class Particle3DMenuLayer : public PerformBasicLayer -{ -public: - Particle3DMenuLayer(bool isControlMenuVisible, int maxCases = 0, int curCase = 0); - virtual void showCurrentTest(); -}; +DEFINE_TEST_SUITE(PerformceParticle3DTests); -class Particle3DMainScene : public cocos2d::Scene +class Particle3DMainScene : public TestCase { public: virtual void initWithSubTest(int subtest, int particles); - virtual std::string title() const; void step(float dt); void createParticleSystem(int idx); @@ -34,10 +28,11 @@ protected: class Particle3DPerformTest : public Particle3DMainScene { public: + CREATE_FUNC(Particle3DPerformTest); + + virtual bool init() override; virtual std::string title() const override; - virtual void doTest(); + virtual void doTest(){}; }; -void runParticle3DTest(); - #endif diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticleTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticleTest.cpp index 3791afbd61..d225d8ea3e 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticleTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticleTest.cpp @@ -17,51 +17,15 @@ enum { kNodesIncrease = 500, }; -static int s_nParCurIdx = 0; +int ParticleMainScene::quantityParticles = kNodesIncrease; +int ParticleMainScene::subtestNumber = 1; -//////////////////////////////////////////////////////// -// -// ParticleMenuLayer -// -//////////////////////////////////////////////////////// -ParticleMenuLayer::ParticleMenuLayer(bool bControlMenuVisible, int nMaxCases, int nCurCase) -: PerformBasicLayer(bControlMenuVisible, nMaxCases, nCurCase) +PerformceParticleTests::PerformceParticleTests() { - -} - -void ParticleMenuLayer::showCurrentTest() -{ - auto scene = (ParticleMainScene*)getParent(); - int subTest = scene->getSubTestNum(); - int parNum = scene->getParticlesNum(); - - ParticleMainScene* pNewScene = nullptr; - - switch (_curCase) - { - case 0: - pNewScene = new (std::nothrow) ParticlePerformTest1; - break; - case 1: - pNewScene = new (std::nothrow) ParticlePerformTest2; - break; - case 2: - pNewScene = new (std::nothrow) ParticlePerformTest3; - break; - case 3: - pNewScene = new (std::nothrow) ParticlePerformTest4; - break; - } - - s_nParCurIdx = _curCase; - if (pNewScene) - { - pNewScene->initWithSubTest(subTest, parNum); - - Director::getInstance()->replaceScene(pNewScene); - pNewScene->release(); - } + ADD_TEST_CASE(ParticlePerformTest1); + ADD_TEST_CASE(ParticlePerformTest2); + ADD_TEST_CASE(ParticlePerformTest3); + ADD_TEST_CASE(ParticlePerformTest4); } //////////////////////////////////////////////////////// @@ -69,6 +33,17 @@ void ParticleMenuLayer::showCurrentTest() // ParticleMainScene // //////////////////////////////////////////////////////// +bool ParticleMainScene::init() +{ + if (TestCase::init()) + { + initWithSubTest(subtestNumber, quantityParticles); + return true; + } + + return false; +} + void ParticleMainScene::initWithSubTest(int asubtest, int particles) { //srandom(0); @@ -114,11 +89,6 @@ void ParticleMainScene::initWithSubTest(int asubtest, int particles) addChild(labelAtlas, 0, kTagLabelAtlas); labelAtlas->setPosition(Vec2(s.width-66,50)); - // Next Prev Test - auto menuLayer = new (std::nothrow) ParticleMenuLayer(true, TEST_COUNT, s_nParCurIdx); - addChild(menuLayer, 1, kTagMenuLayer); - menuLayer->release(); - // Sub Tests MenuItemFont::setFontSize(40); auto pSubMenu = Menu::create(); @@ -153,11 +123,6 @@ void ParticleMainScene::initWithSubTest(int asubtest, int particles) schedule(CC_SCHEDULE_SELECTOR(ParticleMainScene::step)); } -std::string ParticleMainScene::title() const -{ - return "No title"; -} - void ParticleMainScene::step(float dt) { auto atlas = (LabelAtlas*) getChildByTag(kTagLabelAtlas); @@ -251,8 +216,7 @@ void ParticleMainScene::testNCallback(Ref* sender) { subtestNumber = static_cast(sender)->getTag(); - auto menu = static_cast( getChildByTag(kTagMenuLayer) ); - menu->restartCallback(sender); + this->restartTestCallback(sender); } void ParticleMainScene::updateQuantityLabel() @@ -548,12 +512,3 @@ void ParticlePerformTest4::doTest() particleSystem->setBlendAdditive(false); } - -void runParticleTest() -{ - auto scene = new (std::nothrow) ParticlePerformTest1; - scene->initWithSubTest(1, kNodesIncrease); - - Director::getInstance()->replaceScene(scene); - scene->release(); -} diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticleTest.h b/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticleTest.h index ba51b7b608..fae1cdcc0f 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticleTest.h +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceParticleTest.h @@ -1,38 +1,33 @@ #ifndef __PERFORMANCE_PARTICLE_TEST_H__ #define __PERFORMANCE_PARTICLE_TEST_H__ -#include "PerformanceTest.h" +#include "BaseTest.h" -class ParticleMenuLayer : public PerformBasicLayer -{ -public: - ParticleMenuLayer(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0); - virtual void showCurrentTest(); -}; - -class ParticleMainScene : public cocos2d::Scene +DEFINE_TEST_SUITE(PerformceParticleTests); + +class ParticleMainScene : public TestCase { public: + virtual bool init() override; virtual void initWithSubTest(int subtest, int particles); - virtual std::string title() const; void step(float dt); void createParticleSystem(); void testNCallback(cocos2d::Ref* sender); void updateQuantityLabel(); - int getSubTestNum() { return subtestNumber; } - int getParticlesNum() { return quantityParticles; } virtual void doTest() = 0; protected: int lastRenderedCount; - int quantityParticles; - int subtestNumber; + static int quantityParticles; + static int subtestNumber; }; class ParticlePerformTest1 : public ParticleMainScene { public: + CREATE_FUNC(ParticlePerformTest1); + virtual std::string title() const override; virtual void doTest(); }; @@ -40,6 +35,8 @@ public: class ParticlePerformTest2 : public ParticleMainScene { public: + CREATE_FUNC(ParticlePerformTest2); + virtual std::string title() const override; virtual void doTest(); }; @@ -47,6 +44,8 @@ public: class ParticlePerformTest3 : public ParticleMainScene { public: + CREATE_FUNC(ParticlePerformTest3); + virtual std::string title() const override; virtual void doTest(); }; @@ -54,10 +53,10 @@ public: class ParticlePerformTest4 : public ParticleMainScene { public: + CREATE_FUNC(ParticlePerformTest4); + virtual std::string title() const override; virtual void doTest(); }; -void runParticleTest(); - #endif diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceRendererTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceRendererTest.cpp index c2f64a14d3..df44d1e833 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceRendererTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceRendererTest.cpp @@ -12,46 +12,18 @@ USING_NS_CC; -RenderTestLayer::RenderTestLayer() -: PerformBasicLayer(true, 1, 1) +PerformceRenderTests::PerformceRenderTests() { + ADD_TEST_CASE(RenderPerformceTest); } -RenderTestLayer::~RenderTestLayer() +void RenderPerformceTest::onEnter() { -} - -Scene* RenderTestLayer::scene() -{ - auto scene = Scene::create(); - RenderTestLayer *layer = new (std::nothrow) RenderTestLayer(); - scene->addChild(layer); - layer->release(); - - return scene; -} - -void RenderTestLayer::onEnter() -{ - PerformBasicLayer::onEnter(); + TestCase::onEnter(); auto map = TMXTiledMap::create("TileMaps/map/sl.tmx"); Size CC_UNUSED s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); addChild(map,-1); - - //map->setAnchorPoint( Vec2(0, 0) ); - //map->setPosition( Vec2(-20,-200) ); -} - -void RenderTestLayer::showCurrentTest() -{ - -} - -void runRendererTest() -{ - auto scene = RenderTestLayer::scene(); - Director::getInstance()->replaceScene(scene); } diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceRendererTest.h b/tests/cpp-tests/Classes/PerformanceTest/PerformanceRendererTest.h index 011a5d0f00..fbcf7a04f6 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceRendererTest.h +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceRendererTest.h @@ -9,20 +9,16 @@ #ifndef __PERFORMANCE_RENDERER_TEST_H__ #define __PERFORMANCE_RENDERER_TEST_H__ -#include "PerformanceTest.h" +#include "BaseTest.h" -class RenderTestLayer : public PerformBasicLayer +DEFINE_TEST_SUITE(PerformceRenderTests); + +class RenderPerformceTest : public TestCase { - public: - RenderTestLayer(); - virtual ~RenderTestLayer(); + CREATE_FUNC(RenderPerformceTest); virtual void onEnter() override; - virtual void showCurrentTest() override; -public: - static cocos2d::Scene* scene(); }; -void runRendererTest(); #endif diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceScenarioTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceScenarioTest.cpp index 09bc211d30..1f6a503333 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceScenarioTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceScenarioTest.cpp @@ -3,67 +3,9 @@ USING_NS_CC; -enum +PerformceScenarioTests::PerformceScenarioTests() { - TEST_COUNT = 1, -}; - -static int s_nScenarioCurCase = 0; - -//////////////////////////////////////////////////////// -// -// ScenarioMenuLayer -// -//////////////////////////////////////////////////////// -void ScenarioMenuLayer::showCurrentTest() -{ - Scene* scene = nullptr; - - switch (_curCase) - { - case 0: - scene = ScenarioTest::scene(); - break; - } - s_nScenarioCurCase = _curCase; - - if (scene) - { - Director::getInstance()->replaceScene(scene); - } -} - -void ScenarioMenuLayer::onEnter() -{ - PerformBasicLayer::onEnter(); - - auto s = Director::getInstance()->getWinSize(); - - // Title - auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); - addChild(label, 1); - label->setPosition(Vec2(s.width/2, s.height-50)); - - // Subtitle - std::string strSubTitle = subtitle(); - if(strSubTitle.length()) - { - auto l = Label::createWithTTF(strSubTitle.c_str(), "fonts/Thonburi.ttf", 16); - addChild(l, 1); - l->setPosition(Vec2(s.width/2, s.height-80)); - } - - performTests(); -} - -std::string ScenarioMenuLayer::title() const -{ - return "no title"; -} - -std::string ScenarioMenuLayer::subtitle() const -{ - return ""; + ADD_TEST_CASE(ScenarioTest); } //////////////////////////////////////////////////////// @@ -78,6 +20,17 @@ int ScenarioTest::_spriteStepNum = 500; int ScenarioTest::_initParsysNum = 10; int ScenarioTest::_parsysStepNum = 5; +bool ScenarioTest::init() +{ + if (TestCase::init()) + { + performTests(); + return true; + } + + return false; +} + void ScenarioTest::performTests() { auto listener = EventListenerTouchAllAtOnce::create(); @@ -347,26 +300,3 @@ std::string ScenarioTest::title() const { return "Scenario Performance Test"; } - -// -//std::string ScenarioTest::subtitle() const -//{ -// return "See console for results"; -//} - -Scene* ScenarioTest::scene() -{ - auto scene = Scene::create(); - ScenarioTest *layer = new (std::nothrow) ScenarioTest(false, TEST_COUNT, s_nScenarioCurCase); - scene->addChild(layer); - layer->release(); - - return scene; -} - -void runScenarioTest() -{ - s_nScenarioCurCase = 0; - auto scene = ScenarioTest::scene(); - Director::getInstance()->replaceScene(scene); -} diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceScenarioTest.h b/tests/cpp-tests/Classes/PerformanceTest/PerformanceScenarioTest.h index 2d64275362..ffecf6680b 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceScenarioTest.h +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceScenarioTest.h @@ -1,36 +1,20 @@ #ifndef __PERFORMANCE_SCENARIO_TEST_H__ #define __PERFORMANCE_SCENARIO_TEST_H__ -#include "PerformanceTest.h" +#include "BaseTest.h" -class ScenarioMenuLayer : public PerformBasicLayer +DEFINE_TEST_SUITE(PerformceScenarioTests); + +class ScenarioTest : public TestCase { public: - ScenarioMenuLayer(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0) - :PerformBasicLayer(bControlMenuVisible, nMaxCases, nCurCase) - { - } - - virtual void showCurrentTest() override; - - virtual void onEnter() override; - virtual std::string title() const; - virtual std::string subtitle() const; - virtual void performTests() = 0; -}; - -class ScenarioTest : public ScenarioMenuLayer -{ -public: - ScenarioTest(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0) - :ScenarioMenuLayer(bControlMenuVisible, nMaxCases, nCurCase) - { - } + CREATE_FUNC(ScenarioTest); + virtual bool init() override; virtual std::string title() const override; - virtual void performTests() override; + virtual void performTests(); - void onTouchesMoved(const std::vector& touches, cocos2d::Event* event) override; + void onTouchesMoved(const std::vector& touches, cocos2d::Event* event) ; static cocos2d::Scene* scene(); @@ -64,6 +48,4 @@ private: int _particleNumber; }; -void runScenarioTest(); - #endif diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceSpriteTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceSpriteTest.cpp index a11c7d8f39..883126a27e 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceSpriteTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceSpriteTest.cpp @@ -51,6 +51,20 @@ enum { kTagMenuLayer = (kMaxNodes + 1000), }; +PerformceSpriteTests::PerformceSpriteTests() +{ + ADD_TEST_CASE(SpritePerformTestA); + ADD_TEST_CASE(SpritePerformTestB); + ADD_TEST_CASE(SpritePerformTestC); + ADD_TEST_CASE(SpritePerformTestD); + ADD_TEST_CASE(SpritePerformTestE); + ADD_TEST_CASE(SpritePerformTestF); + ADD_TEST_CASE(SpritePerformTestG); +} + +int SpriteMainScene::_quantityNodes = 50; +int SpriteMainScene::_subtestNumber = 1; + //////////////////////////////////////////////////////// // // SubTest @@ -293,83 +307,6 @@ void SubTest::removeByTag(int tag) _parentNode->removeChildByTag(tag+100, true); } -//////////////////////////////////////////////////////// -// -// SpriteMenuLayer -// -//////////////////////////////////////////////////////// -void SpriteMenuLayer::restartCallback(Ref* sender) -{ - if ( SpriteMainScene::_s_autoTest ) - { - log("It's auto sprite performace testing,so this operation is invalid"); - return; - } - - PerformBasicLayer::restartCallback(sender); -} -void SpriteMenuLayer::nextCallback(Ref* sender) -{ - if ( SpriteMainScene::_s_autoTest ) - { - log("It's auto sprite performace testing,so this operation is invalid"); - return; - } - - PerformBasicLayer::nextCallback(sender); -} -void SpriteMenuLayer::backCallback(Ref* sender) -{ - if ( SpriteMainScene::_s_autoTest ) - { - log("It's auto sprite performace testing,so this operation is invalid"); - return; - } - - PerformBasicLayer::backCallback(sender); -} - -void SpriteMenuLayer::showCurrentTest() -{ - SpriteMainScene* scene = nullptr; - auto pPreScene = (SpriteMainScene*) getParent(); - int nSubTest = pPreScene->getSubTestNum(); - int nNodes = pPreScene->getNodesNum(); - - switch (_curCase) - { - case 0: - scene = new (std::nothrow) SpritePerformTestA; - break; - case 1: - scene = new (std::nothrow) SpritePerformTestB; - break; - case 2: - scene = new (std::nothrow) SpritePerformTestC; - break; - case 3: - scene = new (std::nothrow) SpritePerformTestD; - break; - case 4: - scene = new (std::nothrow) SpritePerformTestE; - break; - case 5: - scene = new (std::nothrow) SpritePerformTestF; - break; - case 6: - scene = new (std::nothrow) SpritePerformTestG; - break; - } - - SpriteMainScene::_s_nSpriteCurCase = _curCase; - - if (scene) - { - scene->initWithSubTest(nSubTest, nNodes); - Director::getInstance()->replaceScene(scene); - scene->release(); - } -} //////////////////////////////////////////////////////// // // SpriteMainScene @@ -389,6 +326,17 @@ int SpriteMainScene::_s_spritesQuanityArray[] = {1000, 3000, 0}; // FIXME: to make VS2012 happy. Once VS2012 is deprecated, we can just simply replace it with {} std::vector SpriteMainScene::_s_saved_fps = std::vector(); +bool SpriteMainScene::init() +{ + if (TestCase::init()) + { + initWithSubTest(_subtestNumber, _quantityNodes); + return true; + } + + return false; +} + void SpriteMainScene::initWithSubTest(int asubtest, int nNodes) { std::srand(0); @@ -417,11 +365,6 @@ void SpriteMainScene::initWithSubTest(int asubtest, int nNodes) infoLabel->setColor(Color3B(0,200,20)); infoLabel->setPosition(Vec2(s.width/2, s.height-90)); addChild(infoLabel, 1, kTagInfoLayer); - - // add menu - auto menuLayer = new (std::nothrow) SpriteMenuLayer(true, TEST_COUNT, SpriteMainScene::_s_nSpriteCurCase); - addChild(menuLayer, 1, kTagMenuLayer); - menuLayer->release(); /** * auto test menu @@ -514,13 +457,11 @@ void SpriteMainScene::testNCallback(Ref* sender) { if (SpriteMainScene::_s_autoTest) { - log("It's auto sprite performace testing,so this operation is invalid"); + log("It's auto sprite performance testing,so this operation is invalid"); return; } - _subtestNumber = static_cast(sender)->getTag(); - auto menu = static_cast( getChildByTag(kTagMenuLayer) ); - menu->restartCallback(sender); + this->restartTestCallback(sender); } void SpriteMainScene::updateNodes() @@ -975,12 +916,3 @@ void SpritePerformTestG::doTest(Sprite* sprite) { performanceActions20(sprite); } - -void runSpriteTest() -{ - SpriteMainScene::_s_autoTest = false; - auto scene = new (std::nothrow) SpritePerformTestA; - scene->initWithSubTest(1, 50); - Director::getInstance()->replaceScene(scene); - scene->release(); -} diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceSpriteTest.h b/tests/cpp-tests/Classes/PerformanceTest/PerformanceSpriteTest.h index 8ec6eb62df..ea109613a4 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceSpriteTest.h +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceSpriteTest.h @@ -30,8 +30,9 @@ #include -#include "PerformanceTest.h" +#include "BaseTest.h" +DEFINE_TEST_SUITE(PerformceSpriteTests); class SubTest { @@ -46,24 +47,11 @@ protected: cocos2d::Node* _parentNode; }; -class SpriteMenuLayer : public PerformBasicLayer -{ -public: - SpriteMenuLayer(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0) - : PerformBasicLayer(bControlMenuVisible, nMaxCases, nCurCase) - { - } - - virtual void restartCallback(cocos2d::Ref* sender) override; - virtual void nextCallback(cocos2d::Ref* sender) override; - virtual void backCallback(cocos2d::Ref* sender) override; - virtual void showCurrentTest(); -}; - -class SpriteMainScene : public cocos2d::Scene +class SpriteMainScene : public TestCase { public: virtual ~SpriteMainScene(); + virtual bool init() override; virtual std::string title() const; virtual std::string subtitle() const; @@ -75,9 +63,6 @@ public: void onDecrease(cocos2d::Ref* sender); virtual void doTest(cocos2d::Sprite* sprite) = 0; - - int getSubTestNum() { return _subtestNumber; } - int getNodesNum() { return _quantityNodes; } virtual void onEnter() override; virtual void onExit() override; @@ -92,6 +77,9 @@ public: static std::vector _s_saved_fps; protected: + static int _quantityNodes; + static int _subtestNumber; + void dumpProfilerFPS(); void saveFPS(); void beginAutoTest(); @@ -101,14 +89,14 @@ protected: void autoShowSpriteTests(int curCase, int subTest,int nodes); int _lastRenderedCount; - int _quantityNodes; SubTest* _subTest; - int _subtestNumber; }; class SpritePerformTestA : public SpriteMainScene { public: + CREATE_FUNC(SpritePerformTestA); + virtual void doTest(cocos2d::Sprite* sprite) override; virtual std::string title() const override; }; @@ -116,6 +104,8 @@ public: class SpritePerformTestB : public SpriteMainScene { public: + CREATE_FUNC(SpritePerformTestB); + virtual void doTest(cocos2d::Sprite* sprite) override; virtual std::string title() const override; }; @@ -123,6 +113,8 @@ public: class SpritePerformTestC : public SpriteMainScene { public: + CREATE_FUNC(SpritePerformTestC); + virtual void doTest(cocos2d::Sprite* sprite) override; virtual std::string title() const override; }; @@ -130,6 +122,8 @@ public: class SpritePerformTestD : public SpriteMainScene { public: + CREATE_FUNC(SpritePerformTestD); + virtual void doTest(cocos2d::Sprite* sprite) override; virtual std::string title() const override; }; @@ -137,6 +131,8 @@ public: class SpritePerformTestE : public SpriteMainScene { public: + CREATE_FUNC(SpritePerformTestE); + virtual void doTest(cocos2d::Sprite* sprite) override; virtual std::string title() const override; }; @@ -144,6 +140,8 @@ public: class SpritePerformTestF : public SpriteMainScene { public: + CREATE_FUNC(SpritePerformTestF); + virtual void doTest(cocos2d::Sprite* sprite) override; virtual std::string title() const override; }; @@ -151,10 +149,10 @@ public: class SpritePerformTestG : public SpriteMainScene { public: + CREATE_FUNC(SpritePerformTestG); + virtual void doTest(cocos2d::Sprite* sprite) override; virtual std::string title() const override; }; -void runSpriteTest(); - #endif diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTest.cpp index e59c9e5bc0..07fa5b2486 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTest.cpp @@ -8,7 +8,6 @@ #include "PerformanceTouchesTest.h" #include "PerformanceAllocTest.h" #include "PerformanceLabelTest.h" -#include "PerformanceRendererTest.h" #include "PerformanceContainerTest.h" #include "PerformanceEventDispatcherTest.h" #include "PerformanceScenarioTest.h" @@ -17,210 +16,19 @@ USING_NS_CC; -enum +PerformanceTests::PerformanceTests() { - LINE_SPACE = 40, - kItemTagBasic = 1000, -}; - -struct { - const char *name; - std::function callback; -} g_testsName[] = -{ - { "Alloc Test", [](Ref*sender){runAllocPerformanceTest(); } }, - { "NodeChildren Test", [](Ref*sender){runNodeChildrenTest();} }, - { "Particle Test",[](Ref*sender){runParticleTest();} }, - { "Particle3D Perf Test",[](Ref*sender){runParticle3DTest();} }, - { "Sprite Perf Test",[](Ref*sender){runSpriteTest();} }, - { "Texture Perf Test",[](Ref*sender){runTextureTest();} }, - { "Touches Perf Test",[](Ref*sender){runTouchesTest();} }, - { "Label Perf Test",[](Ref*sender){runLabelTest();} }, - //{ "Renderer Perf Test",[](Ref*sender){runRendererTest();} }, - { "Container Perf Test", [](Ref* sender ) { runContainerPerformanceTest(); } }, - { "EventDispatcher Perf Test", [](Ref* sender ) { runEventDispatcherPerformanceTest(); } }, - { "Scenario Perf Test", [](Ref* sender ) { runScenarioTest(); } }, - { "Callback Perf Test", [](Ref* sender ) { runCallbackPerformanceTest(); } }, - { "Math Perf Test", [](Ref* sender ) { runMathPerformanceTest(); } }, -}; - -static const int g_testMax = sizeof(g_testsName)/sizeof(g_testsName[0]); - -Vec2 PerformanceMainLayer::_CurrentPos = Vec2::ZERO; - -//////////////////////////////////////////////////////// -// -// PerformanceMainLayer -// -//////////////////////////////////////////////////////// -void PerformanceMainLayer::onEnter() -{ - Layer::onEnter(); - - auto s = Director::getInstance()->getWinSize(); - - _itemMenu = Menu::create(); - _itemMenu->setPosition(_CurrentPos); - MenuItemFont::setFontName("fonts/arial.ttf"); - MenuItemFont::setFontSize(24); - for (int i = 0; i < g_testMax; ++i) - { - auto pItem = MenuItemFont::create(g_testsName[i].name, g_testsName[i].callback); - pItem->setPosition(Vec2(s.width / 2, s.height - (i + 1) * LINE_SPACE)); - _itemMenu->addChild(pItem, kItemTagBasic + i); - } - - addChild(_itemMenu); - - // Register Touch Event - auto listener = EventListenerTouchOneByOne::create(); - listener->setSwallowTouches(true); - - listener->onTouchBegan = CC_CALLBACK_2(PerformanceMainLayer::onTouchBegan, this); - listener->onTouchMoved = CC_CALLBACK_2(PerformanceMainLayer::onTouchMoved, this); - - _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); - - auto mouseListener = EventListenerMouse::create(); - mouseListener->onMouseScroll = CC_CALLBACK_1(PerformanceMainLayer::onMouseScroll, this); - _eventDispatcher->addEventListenerWithSceneGraphPriority(mouseListener, this); -} - -bool PerformanceMainLayer::onTouchBegan(Touch* touches, Event *event) -{ - _beginPos = touches->getLocation(); - return true; -} -void PerformanceMainLayer::onTouchMoved(Touch* touches, Event *event) -{ - auto touchLocation = touches->getLocation(); - float nMoveY = touchLocation.y - _beginPos.y; - - auto curPos = _itemMenu->getPosition(); - auto nextPos = Vec2(curPos.x, curPos.y + nMoveY); - - if (nextPos.y < 0.0f) - { - _itemMenu->setPosition(Vec2::ZERO); - return; - } - - if (nextPos.y > ((g_testMax + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height)) - { - _itemMenu->setPosition(Vec2(0, ((g_testMax + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))); - return; - } - - _itemMenu->setPosition(nextPos); - _beginPos = touchLocation; - _CurrentPos = nextPos; -} - -void PerformanceMainLayer::onMouseScroll(Event *event) -{ - auto mouseEvent = static_cast(event); - float nMoveY = mouseEvent->getScrollY() * 6; - - auto curPos = _itemMenu->getPosition(); - auto nextPos = Vec2(curPos.x, curPos.y + nMoveY); - - if (nextPos.y < 0.0f) - { - _itemMenu->setPosition(Vec2::ZERO); - return; - } - - if (nextPos.y > ((g_testMax + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height)) - { - _itemMenu->setPosition(Vec2(0, ((g_testMax + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))); - return; - } - - _itemMenu->setPosition(nextPos); - _CurrentPos = nextPos; -} - -//////////////////////////////////////////////////////// -// -// PerformBasicLayer -// -//////////////////////////////////////////////////////// -PerformBasicLayer::PerformBasicLayer(bool bControlMenuVisible, int nMaxCases, int nCurCase) -: _controlMenuVisible(bControlMenuVisible) -, _maxCases(nMaxCases) -, _curCase(nCurCase) -{ - -} - -void PerformBasicLayer::onEnter() -{ - Layer::onEnter(); - - MenuItemFont::setFontName("fonts/arial.ttf"); - MenuItemFont::setFontSize(24); - auto pMainItem = MenuItemFont::create("Back", CC_CALLBACK_1(PerformBasicLayer::toMainLayer, this)); - pMainItem->setPosition(Vec2(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); - auto menu = Menu::create(pMainItem, nullptr); - menu->setPosition( Vec2::ZERO ); - - if (_controlMenuVisible) - { - auto item1 = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(PerformBasicLayer::backCallback, this)); - auto item2 = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(PerformBasicLayer::restartCallback, this)); - auto item3 = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(PerformBasicLayer::nextCallback, this)); - item1->setPosition(Vec2(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); - item2->setPosition(Vec2(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); - item3->setPosition(Vec2(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); - - menu->addChild(item1, kItemTagBasic); - menu->addChild(item2, kItemTagBasic); - menu->addChild(item3, kItemTagBasic); - } - addChild(menu); -} - -void PerformBasicLayer::toMainLayer(Ref* sender) -{ - auto scene = new (std::nothrow) PerformanceTestScene(); - scene->runThisTest(); - - scene->release(); -} - -void PerformBasicLayer::restartCallback(Ref* sender) -{ - showCurrentTest(); -} - -void PerformBasicLayer::nextCallback(Ref* sender) -{ - _curCase++; - _curCase = _curCase % _maxCases; - - showCurrentTest(); -} - -void PerformBasicLayer::backCallback(Ref* sender) -{ - _curCase--; - if( _curCase < 0 ) - _curCase += _maxCases; - - showCurrentTest(); -} - -//////////////////////////////////////////////////////// -// -// PerformanceTestScene -// -//////////////////////////////////////////////////////// - -void PerformanceTestScene::runThisTest() -{ - auto layer = new (std::nothrow) PerformanceMainLayer(); - addChild(layer); - layer->release(); - - Director::getInstance()->replaceScene(this); + addTest("Alloc Test", [](){ return new (std::nothrow) PerformceAllocTests; }); + addTest("NodeChildren Test", [](){ return new (std::nothrow) PerformceNodeChildrenTests; }); + addTest("Particle Test", [](){ return new (std::nothrow) PerformceParticleTests; }); + addTest("Particle3D Perf Test", [](){ return new (std::nothrow) PerformceParticle3DTests; }); + addTest("Sprite Perf Test", [](){ return new (std::nothrow) PerformceSpriteTests; }); + addTest("Texture Perf Test", [](){ return new (std::nothrow) PerformceTextureTests; }); + addTest("Touches Perf Test", [](){ return new (std::nothrow) PerformceTouchesTests; }); + addTest("Label Perf Test", [](){ return new (std::nothrow) PerformceLabelTests; }); + addTest("Container Perf Test", []() { return new (std::nothrow) PerformceContainerTests; }); + addTest("EventDispatcher Perf Test", []() { return new (std::nothrow) PerformceEventDispatcherTests; }); + addTest("Scenario Perf Test", []() { return new (std::nothrow) PerformceScenarioTests; }); + addTest("Callback Perf Test", []() { return new (std::nothrow) PerformceCallbackTests; }); + addTest("Math Perf Test", []() { return new (std::nothrow) PerformceMathTests; }); } diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTest.h b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTest.h index dd8377a75e..3c357c0ac4 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTest.h +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTest.h @@ -1,48 +1,8 @@ #ifndef __PERFORMANCE_TEST_H__ #define __PERFORMANCE_TEST_H__ -#include "../testBasic.h" +#include "BaseTest.h" -class PerformanceMainLayer : public cocos2d::Layer -{ -public: - virtual void onEnter() override; - - bool onTouchBegan(cocos2d::Touch* touches, cocos2d::Event* event) override; - void onTouchMoved(cocos2d::Touch* touches, cocos2d::Event* event) override; - - void onMouseScroll(cocos2d::Event* event); -protected: - cocos2d::Vec2 _beginPos; - cocos2d::Menu* _itemMenu; - - static cocos2d::Vec2 _CurrentPos; -}; - -class PerformBasicLayer : public cocos2d::Layer -{ -public: - PerformBasicLayer(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0); - - virtual void onEnter() override; - - virtual void restartCallback(cocos2d::Ref* sender); - virtual void nextCallback(cocos2d::Ref* sender); - virtual void backCallback(cocos2d::Ref* sender); - virtual void showCurrentTest() = 0; - - virtual void toMainLayer(cocos2d::Ref* sender); - -protected: - bool _controlMenuVisible; - int _maxCases; - int _curCase; -}; - -class PerformanceTestScene : public TestScene -{ -public: - virtual void runThisTest(); -}; +DEFINE_TEST_LIST(PerformanceTests); #endif diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTextureTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTextureTest.cpp index 5a4fa998f1..22a1f76f6f 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTextureTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTextureTest.cpp @@ -2,14 +2,12 @@ USING_NS_CC; -enum +PerformceTextureTests::PerformceTextureTests() { - TEST_COUNT = 1, -}; + ADD_TEST_CASE(TexturePerformceTest); +} -static int s_nTexCurCase = 0; - -float calculateDeltaTime( struct timeval *lastUpdate ) +static float calculateDeltaTime( struct timeval *lastUpdate ) { struct timeval now; @@ -22,66 +20,10 @@ float calculateDeltaTime( struct timeval *lastUpdate ) //////////////////////////////////////////////////////// // -// TextureMenuLayer +// TexturePerformceTest // //////////////////////////////////////////////////////// -void TextureMenuLayer::showCurrentTest() -{ - Scene* scene = nullptr; - - switch (_curCase) - { - case 0: - scene = TextureTest::scene(); - break; - } - s_nTexCurCase = _curCase; - - if (scene) - { - Director::getInstance()->replaceScene(scene); - } -} - -void TextureMenuLayer::onEnter() -{ - PerformBasicLayer::onEnter(); - - auto s = Director::getInstance()->getWinSize(); - - // Title - auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); - addChild(label, 1); - label->setPosition(Vec2(s.width/2, s.height-50)); - - // Subtitle - std::string strSubTitle = subtitle(); - if(strSubTitle.length()) - { - auto l = Label::createWithTTF(strSubTitle.c_str(), "fonts/Thonburi.ttf", 16); - addChild(l, 1); - l->setPosition(Vec2(s.width/2, s.height-80)); - } - - performTests(); -} - -std::string TextureMenuLayer::title() const -{ - return "no title"; -} - -std::string TextureMenuLayer::subtitle() const -{ - return "no subtitle"; -} - -//////////////////////////////////////////////////////// -// -// TextureTest -// -//////////////////////////////////////////////////////// -void TextureTest::performTestsPNG(const char* filename) +void TexturePerformceTest::performTestsPNG(const char* filename) { struct timeval now; Texture2D *texture; @@ -132,7 +74,7 @@ void TextureTest::performTestsPNG(const char* filename) Texture2D::setDefaultAlphaPixelFormat(defaultFormat); } -void TextureTest::performTests() +void TexturePerformceTest::performTests() { // Texture2D *texture; // struct timeval now; @@ -337,29 +279,19 @@ void TextureTest::performTests() // cache->removeTexture(texture); } -std::string TextureTest::title() const +void TexturePerformceTest::onEnter() +{ + TestCase::onEnter(); + + performTests(); +} + +std::string TexturePerformceTest::title() const { return "Texture Performance Test"; } -std::string TextureTest::subtitle() const +std::string TexturePerformceTest::subtitle() const { return "See console for results"; } - -Scene* TextureTest::scene() -{ - auto scene = Scene::create(); - TextureTest *layer = new (std::nothrow) TextureTest(false, TEST_COUNT, s_nTexCurCase); - scene->addChild(layer); - layer->release(); - - return scene; -} - -void runTextureTest() -{ - s_nTexCurCase = 0; - auto scene = TextureTest::scene(); - Director::getInstance()->replaceScene(scene); -} diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTextureTest.h b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTextureTest.h index 7ebcc5ba17..83f858e07c 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTextureTest.h +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTextureTest.h @@ -1,40 +1,21 @@ #ifndef __PERFORMANCE_TEXTURE_TEST_H__ #define __PERFORMANCE_TEXTURE_TEST_H__ -#include "PerformanceTest.h" +#include "BaseTest.h" -class TextureMenuLayer : public PerformBasicLayer +DEFINE_TEST_SUITE(PerformceTextureTests); + +class TexturePerformceTest : public TestCase { public: - TextureMenuLayer(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0) - :PerformBasicLayer(bControlMenuVisible, nMaxCases, nCurCase) - { - } - - virtual void showCurrentTest(); - - virtual void onEnter() override; - virtual std::string title() const; - virtual std::string subtitle() const; - virtual void performTests() = 0; -}; - -class TextureTest : public TextureMenuLayer -{ -public: - TextureTest(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0) - :TextureMenuLayer(bControlMenuVisible, nMaxCases, nCurCase) - { - } + CREATE_FUNC(TexturePerformceTest); virtual void performTests(); - virtual std::string title() const override; - virtual std::string subtitle() const override; void performTestsPNG(const char* filename); - static cocos2d::Scene* scene(); + virtual std::string title() const override; + virtual std::string subtitle() const override; + virtual void onEnter() override; }; -void runTextureTest(); - #endif diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTouchesTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTouchesTest.cpp index f4bde5637b..bedb5693bf 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTouchesTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTouchesTest.cpp @@ -29,56 +29,25 @@ USING_NS_CC; #undef CC_PROFILER_RESET_INSTANCE #define CC_PROFILER_RESET_INSTANCE(__id__, __name__) do{ ProfilingResetTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0) -enum +PerformceTouchesTests::PerformceTouchesTests() { - TEST_COUNT = 3, -}; - -static int s_nTouchCurCase = 0; + ADD_TEST_CASE(TouchesPerformTest1); + ADD_TEST_CASE(TouchesPerformTest2); + ADD_TEST_CASE(TouchesPerformTest3); +} //////////////////////////////////////////////////////// // // TouchesMainScene // //////////////////////////////////////////////////////// -void TouchesMainScene::showCurrentTest() -{ - Layer* layer = nullptr; - switch (_curCase) - { - case 0: - layer = new (std::nothrow) TouchesPerformTest1(true, TEST_COUNT, _curCase); - break; - case 1: - layer = new (std::nothrow) TouchesPerformTest2(true, TEST_COUNT, _curCase); - break; - case 2: - layer = new (std::nothrow) TouchesPerformTest3(true, TEST_COUNT, _curCase); - break; - } - s_nTouchCurCase = _curCase; - - if (layer) - { - auto scene = Scene::create(); - scene->addChild(layer); - layer->release(); - - Director::getInstance()->replaceScene(scene); - } -} void TouchesMainScene::onEnter() { - PerformBasicLayer::onEnter(); + TestCase::onEnter(); auto s = Director::getInstance()->getWinSize(); - // add title - auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); - addChild(label, 1); - label->setPosition(Vec2(s.width/2, s.height-50)); - scheduleUpdate(); _plabel = Label::createWithBMFont("fonts/arial16.fnt","00.0"); @@ -108,11 +77,6 @@ void TouchesMainScene::update(float dt) } } -std::string TouchesMainScene::title() const -{ - return "No title"; -} - //////////////////////////////////////////////////////// // // TouchesPerformTest1 @@ -215,20 +179,12 @@ public: void onTouchCancelled(Touch *touch, Event *event) {} }; - - void TouchesPerformTest3::onEnter() { - PerformBasicLayer::onEnter(); - + TestCase::onEnter(); auto s = Director::getInstance()->getWinSize(); - // add title - auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32); - addChild(label, 1); - label->setPosition(Vec2(s.width/2, s.height-50)); - #define TOUCH_PROFILER_NAME "TouchProfileName" #define TOUCHABLE_NODE_NUM 1000 @@ -293,42 +249,3 @@ std::string TouchesPerformTest3::title() const { return "Touch Event Perf Test"; } - -void TouchesPerformTest3::showCurrentTest() -{ - Layer* layer = nullptr; - switch (_curCase) - { - case 0: - layer = new (std::nothrow) TouchesPerformTest1(true, TEST_COUNT, _curCase); - break; - case 1: - layer = new (std::nothrow) TouchesPerformTest2(true, TEST_COUNT, _curCase); - break; - case 2: - layer = new (std::nothrow) TouchesPerformTest3(true, TEST_COUNT, _curCase); - break; - } - s_nTouchCurCase = _curCase; - - if (layer) - { - auto scene = Scene::create(); - scene->addChild(layer); - layer->release(); - - Director::getInstance()->replaceScene(scene); - } -} - -void runTouchesTest() -{ - s_nTouchCurCase = 0; - auto scene = Scene::create(); - auto layer = new (std::nothrow) TouchesPerformTest1(true, TEST_COUNT, s_nTouchCurCase); - - scene->addChild(layer); - layer->release(); - - Director::getInstance()->replaceScene(scene); -} diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTouchesTest.h b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTouchesTest.h index 57cb579799..af32666b38 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceTouchesTest.h +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceTouchesTest.h @@ -1,19 +1,13 @@ #ifndef __PERFORMANCE_TOUCHES_TEST_H__ #define __PERFORMANCE_TOUCHES_TEST_H__ -#include "PerformanceTest.h" +#include "BaseTest.h" -class TouchesMainScene : public PerformBasicLayer +DEFINE_TEST_SUITE(PerformceTouchesTests); + +class TouchesMainScene : public TestCase { public: - TouchesMainScene(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0) - : PerformBasicLayer(bControlMenuVisible, nMaxCases, nCurCase) - { - } - - virtual std::string title() const; - - virtual void showCurrentTest() override; virtual void onEnter() override; virtual void update(float dt) override; @@ -29,50 +23,39 @@ protected: class TouchesPerformTest1 : public TouchesMainScene { public: - TouchesPerformTest1(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0) - : TouchesMainScene(bControlMenuVisible, nMaxCases, nCurCase) - { - } + CREATE_FUNC(TouchesPerformTest1); virtual void onEnter() override; virtual std::string title() const override; - bool onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event) override; - void onTouchMoved(cocos2d::Touch* touch, cocos2d::Event* event) override; - void onTouchEnded(cocos2d::Touch* touch, cocos2d::Event* event) override; - void onTouchCancelled(cocos2d::Touch* touch, cocos2d::Event* event) override; + bool onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event); + void onTouchMoved(cocos2d::Touch* touch, cocos2d::Event* event); + void onTouchEnded(cocos2d::Touch* touch, cocos2d::Event* event); + void onTouchCancelled(cocos2d::Touch* touch, cocos2d::Event* event); }; class TouchesPerformTest2 : public TouchesMainScene { public: - TouchesPerformTest2(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0) - : TouchesMainScene(bControlMenuVisible, nMaxCases, nCurCase) - { - } + CREATE_FUNC(TouchesPerformTest2); virtual void onEnter() override; virtual std::string title() const override; - void onTouchesBegan(const std::vector& touches, cocos2d::Event* event) override; - void onTouchesMoved(const std::vector& touches, cocos2d::Event* event) override; - void onTouchesEnded(const std::vector& touches, cocos2d::Event* event) override; - void onTouchesCancelled(const std::vector& touches, cocos2d::Event* event) override; + void onTouchesBegan(const std::vector& touches, cocos2d::Event* event); + void onTouchesMoved(const std::vector& touches, cocos2d::Event* event); + void onTouchesEnded(const std::vector& touches, cocos2d::Event* event); + void onTouchesCancelled(const std::vector& touches, cocos2d::Event* event); }; -class TouchesPerformTest3 : public PerformBasicLayer +class TouchesPerformTest3 : public TestCase { public: - TouchesPerformTest3(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0) - : PerformBasicLayer(bControlMenuVisible, nMaxCases, nCurCase) - { - } - + CREATE_FUNC(TouchesPerformTest3); + virtual void onEnter() override; virtual std::string title() const; - virtual void showCurrentTest() override; }; -void runTouchesTest(); #endif diff --git a/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp b/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp new file mode 100644 index 0000000000..9a44f80a64 --- /dev/null +++ b/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.cpp @@ -0,0 +1,767 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2015 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 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 "Physics3DTest.h" + +#include "3d/CCTerrain.h" +#include "3d/CCBundle3D.h" +#include "physics3d/CCPhysics3D.h" +#include "extensions/Particle3D/PU/CCPUParticleSystem3D.h" +USING_NS_CC_EXT; +USING_NS_CC; + +enum +{ + IDC_NEXT = 100, + IDC_BACK, + IDC_RESTART +}; + +static cocos2d::Scene* physicsScene = nullptr; + +#define START_POS_X -0.5 +#define START_POS_Y -2.5 +#define START_POS_Z -0.5 + +#define ARRAY_SIZE_X 4 +#define ARRAY_SIZE_Y 3 +#define ARRAY_SIZE_Z 4 + +Physics3DTests::Physics3DTests() +{ +#if CC_USE_3D_PHYSICS == 0 + ADD_TEST_CASE(Physics3DDemoDisabled); +#else + ADD_TEST_CASE(BasicPhysics3DDemo); + ADD_TEST_CASE(Physics3DConstraintDemo); + ADD_TEST_CASE(Physics3DKinematicDemo); + ADD_TEST_CASE(Physics3DCollisionCallbackDemo); + ADD_TEST_CASE(Physics3DTerrainDemo); +#endif +}; + +#if CC_USE_3D_PHYSICS == 0 +void Physics3DDemoDisabled::onEnter() +{ + TTFConfig ttfConfig("fonts/arial.ttf", 16); + auto label = Label::createWithTTF(ttfConfig, "Should define CC_USE_3D_PHYSICS\n to run this test case"); + + auto size = Director::getInstance()->getWinSize(); + label->setPosition(Vec2(size.width / 2, size.height / 2)); + + addChild(label); + + TestCase::onEnter(); +} +#else +std::string Physics3DTestDemo::title() const +{ + return "Physics3D Test"; +} + +std::string Physics3DTestDemo::subtitle() const +{ + return ""; +} + +bool Physics3DTestDemo::init() +{ + if (!TestCase::init()) return false; + + if (initWithPhysics()) + { + getPhysics3DWorld()->setDebugDrawEnable(false); + + physicsScene = this; + Size size = Director::getInstance()->getWinSize(); + _camera = Camera::createPerspective(30.0f, size.width / size.height, 1.0f, 1000.0f); + _camera->setPosition3D(Vec3(0.0f, 50.0f, 100.0f)); + _camera->lookAt(Vec3(0.0f, 0.0f, 0.0f), Vec3(0.0f, 1.0f, 0.0f)); + _camera->setCameraFlag(CameraFlag::USER1); + this->addChild(_camera); + + auto listener = EventListenerTouchAllAtOnce::create(); + listener->onTouchesBegan = CC_CALLBACK_2(Physics3DTestDemo::onTouchesBegan, this); + listener->onTouchesMoved = CC_CALLBACK_2(Physics3DTestDemo::onTouchesMoved, this); + listener->onTouchesEnded = CC_CALLBACK_2(Physics3DTestDemo::onTouchesEnded, this); + _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); + + TTFConfig ttfConfig("fonts/arial.ttf", 10); + auto label = Label::createWithTTF(ttfConfig,"DebugDraw OFF"); + auto menuItem = MenuItemLabel::create(label, [=](Ref *ref){ + if (getPhysics3DWorld()->isDebugDrawEnabled()){ + getPhysics3DWorld()->setDebugDrawEnable(false); + label->setString("DebugDraw OFF"); + }else{ + getPhysics3DWorld()->setDebugDrawEnable(true); + label->setString("DebugDraw ON"); + } + }); + + auto menu = Menu::create(menuItem, nullptr); + menu->setPosition(Vec2::ZERO); + menuItem->setAnchorPoint(Vec2::ANCHOR_TOP_LEFT); + menuItem->setPosition( Vec2(VisibleRect::left().x, VisibleRect::top().y-50) ); + this->addChild(menu); + + _angle = 0.0f; + return true; + } + physicsScene = nullptr; + return false; +} + +void Physics3DTestDemo::onTouchesBegan(const std::vector& touches, cocos2d::Event *event) +{ + _needShootBox = true; +} + +void Physics3DTestDemo::onTouchesMoved(const std::vector& touches, cocos2d::Event *event) +{ + if (touches.size() && _camera) + { + auto touch = touches[0]; + auto delta = touch->getDelta(); + + _angle -= CC_DEGREES_TO_RADIANS(delta.x); + _camera->setPosition3D(Vec3(100.0f * sinf(_angle), 50.0f, 100.0f * cosf(_angle))); + _camera->lookAt(Vec3(0.0f, 0.0f, 0.0f), Vec3(0.0f, 1.0f, 0.0f)); + + if (delta.lengthSquared() > 16) + { + _needShootBox = false; + } + } +} + +void Physics3DTestDemo::onTouchesEnded(const std::vector& touches, cocos2d::Event *event) +{ + if (!_needShootBox) return; + if (!touches.empty()) + { + auto location = touches[0]->getLocationInView(); + + Vec3 nearP(location.x, location.y, -1.0f), farP(location.x, location.y, 1.0f); + nearP = _camera->unproject(nearP); + farP = _camera->unproject(farP); + Vec3 dir(farP - nearP); + shootBox(_camera->getPosition3D() + dir * 10.0f); + } +} + +Physics3DTestDemo::Physics3DTestDemo( void ) +: _angle(0.0f) +, _camera(nullptr) +{ + +} + +void Physics3DTestDemo::update( float delta ) +{ + +} + +Physics3DTestDemo::~Physics3DTestDemo( void ) +{ + +} + +void Physics3DTestDemo::shootBox( const cocos2d::Vec3 &des ) +{ + Physics3DRigidBodyDes rbDes; + Vec3 linearVel = des - _camera->getPosition3D(); + linearVel.normalize(); + linearVel *= 100.0f; + rbDes.originalTransform.translate(_camera->getPosition3D()); + rbDes.mass = 1.f; + rbDes.shape = Physics3DShape::createBox(Vec3(0.5f, 0.5f, 0.5f)); + auto sprite = PhysicsSprite3D::create("Sprite3DTest/box.c3t", &rbDes); + sprite->setTexture("Images/Icon.png"); + + auto rigidBody = static_cast(sprite->getPhysicsObj()); + rigidBody->setLinearFactor(Vec3::ONE); + rigidBody->setLinearVelocity(linearVel); + rigidBody->setAngularVelocity(Vec3::ZERO); + rigidBody->setCcdMotionThreshold(0.5f); + rigidBody->setCcdSweptSphereRadius(0.4f); + + this->addChild(sprite); + sprite->setPosition3D(_camera->getPosition3D()); + sprite->setScale(0.5f); + sprite->syncToNode(); + + //optimize, only sync node to physics + sprite->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::PHYSICS_TO_NODE); //sync node to physics + + sprite->setCameraMask((unsigned short)CameraFlag::USER1); +} + +std::string BasicPhysics3DDemo::subtitle() const +{ + return "Basic Physics3D"; +} + +bool BasicPhysics3DDemo::init() +{ + if (!Physics3DTestDemo::init()) + return false; + + //create floor + Physics3DRigidBodyDes rbDes; + rbDes.mass = 0.0f; + rbDes.shape = Physics3DShape::createBox(Vec3(60.0f, 1.0f, 60.0f)); + + auto floor = PhysicsSprite3D::create("Sprite3DTest/box.c3t", &rbDes); + floor->setTexture("Sprite3DTest/plane.png"); + floor->setScaleX(60); + floor->setScaleZ(60); + this->addChild(floor); + floor->setCameraMask((unsigned short)CameraFlag::USER1); + floor->syncToNode(); + //static object sync is not needed + floor->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::NONE); + + //create several boxes using PhysicsSprite3D + rbDes.mass = 1.f; + rbDes.shape = Physics3DShape::createBox(Vec3(0.8f, 0.8f, 0.8f)); + float start_x = START_POS_X - ARRAY_SIZE_X/2; + float start_y = START_POS_Y; + float start_z = START_POS_Z - ARRAY_SIZE_Z/2; + + for (int k=0;ksetTexture("Images/CyanSquare.png"); + sprite->setPosition3D(Vec3(x, y, z)); + sprite->syncToNode(); + sprite->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::PHYSICS_TO_NODE); + sprite->setCameraMask((unsigned short)CameraFlag::USER1); + sprite->setScale(0.8f); + this->addChild(sprite); + } + } + } + + physicsScene->setPhysics3DDebugCamera(_camera); + + return true; +} + +std::string Physics3DConstraintDemo::subtitle() const +{ + return "Physics3D Constraint"; +} + +std::string Physics3DKinematicDemo::subtitle() const +{ + return "Physics3D Kinematic"; +} + +bool Physics3DKinematicDemo::init() +{ + if (!Physics3DTestDemo::init()) + return false; + + //create floor + Physics3DRigidBodyDes rbDes; + rbDes.mass = 0.0f; + rbDes.shape = Physics3DShape::createBox(Vec3(60.0f, 1.0f, 60.0f)); + auto floor = PhysicsSprite3D::create("Sprite3DTest/box.c3t", &rbDes); + floor->setTexture("Sprite3DTest/plane.png"); + floor->setScaleX(60); + floor->setScaleZ(60); + floor->setPosition3D(Vec3(0.f, -1.f, 0.f)); + this->addChild(floor); + floor->setCameraMask((unsigned short)CameraFlag::USER1); + floor->syncToNode(); + //static object sync is not needed + floor->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::NONE); + + //create Kinematics + for (unsigned int i = 0; i < 3; ++i) + { + rbDes.mass = 0.f; //kinematic objects. zero mass so that it can not be affected by other dynamic objects + rbDes.shape = Physics3DShape::createBox(Vec3(2.0f, 2.0f, 2.0f)); + + auto sprite = PhysicsSprite3D::create("Sprite3DTest/box.c3t", &rbDes); + sprite->setTexture("Images/CyanSquare.png"); + sprite->setCameraMask((unsigned short)CameraFlag::USER1); + auto rigidBody = static_cast(sprite->getPhysicsObj()); + rigidBody->setKinematic(true); + + this->addChild(sprite); + + sprite->setScale(2.0f); + sprite->setPosition3D(Vec3(-15.0f, 0.0f, 15.0f - 15.0f * i)); + auto moveby = MoveBy::create(2.0f + i, Vec3(30.0f, 0.0f, 0.0f)); + sprite->runAction(RepeatForever::create(Sequence::create(moveby, moveby->reverse(), nullptr))); + } + + //create Dynamic + { + //create several spheres + rbDes.mass = 1.f; + rbDes.shape = Physics3DShape::createSphere(0.5f); + float start_x = START_POS_X - ARRAY_SIZE_X/2; + float start_y = START_POS_Y + 5.0f; + float start_z = START_POS_Z - ARRAY_SIZE_Z/2; + + for (int k=0;ksetTexture("Sprite3DTest/plane.png"); + sprite->setCameraMask((unsigned short)CameraFlag::USER1); + sprite->setScale(1.0f / sprite->getContentSize().width); + this->addChild(sprite); + sprite->setPosition3D(Vec3(x, y, z)); + sprite->syncToNode(); + + sprite->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::PHYSICS_TO_NODE); + } + } + } + } + + + physicsScene->setPhysics3DDebugCamera(_camera); + return true; +} + + +bool Physics3DConstraintDemo::init() +{ + if (!Physics3DTestDemo::init()) + return false; + + //PhysicsSprite3D = Sprite3D + Physics3DComponent + Physics3DRigidBodyDes rbDes; + rbDes.disableSleep = true; + //create box + auto sprite = Sprite3D::create("Sprite3DTest/orc.c3b"); + rbDes.mass = 10.f; + rbDes.shape = Physics3DShape::createBox(Vec3(5.0f, 5.0f, 5.0f)); + auto rigidBody = Physics3DRigidBody::create(&rbDes); + Quaternion quat; + Quaternion::createFromAxisAngle(Vec3(0.f, 1.f, 0.f), CC_DEGREES_TO_RADIANS(180), &quat); + auto component = Physics3DComponent::create(rigidBody, Vec3(0.f, -3.f, 0.f), quat); + + sprite->addComponent(component); + addChild(sprite); + sprite->setCameraMask((unsigned short)CameraFlag::USER1); + sprite->setScale(0.4f); + sprite->setPosition3D(Vec3(-20.f, 5.f, 0.f)); + //sync node position to physics + component->syncToNode(); + //physics controlled, we will not set position for it, so we can skip sync node position to physics + component->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::PHYSICS_TO_NODE); + + physicsScene->setPhysics3DDebugCamera(_camera); + + //create point to point constraint + Physics3DConstraint* constraint = Physics3DPointToPointConstraint::create(rigidBody, Vec3(2.5f, 2.5f, 2.5f)); + physicsScene->getPhysics3DWorld()->addPhysics3DConstraint(constraint); + + //create hinge constraint + rbDes.mass = 1.0f; + rbDes.shape = Physics3DShape::createBox(Vec3(8.0f, 8.0f, 1.f)); + rigidBody = Physics3DRigidBody::create(&rbDes); + component = Physics3DComponent::create(rigidBody); + sprite = Sprite3D::create("Sprite3DTest/box.c3t"); + sprite->setTexture("Sprite3DTest/plane.png"); + sprite->setScaleX(8.f); + sprite->setScaleY(8.f); + sprite->setPosition3D(Vec3(5.f, 0.f, 0.f)); + sprite->addComponent(component); + sprite->setCameraMask((unsigned short)CameraFlag::USER1); + this->addChild(sprite); + component->syncToNode(); + rigidBody->setAngularVelocity(Vec3(0,3,0)); + constraint = Physics3DHingeConstraint::create(rigidBody, Vec3(4.f, 4.f, 0.5f), Vec3(0.f, 1.f, 0.f)); + physicsScene->getPhysics3DWorld()->addPhysics3DConstraint(constraint); + + + //create slider constraint + rbDes.mass = 1.0f; + rbDes.shape = Physics3DShape::createBox(Vec3(3.0f, 2.0f, 3.f)); + rigidBody = Physics3DRigidBody::create(&rbDes); + component = Physics3DComponent::create(rigidBody); + sprite = Sprite3D::create("Sprite3DTest/box.c3t"); + sprite->setTexture("Sprite3DTest/plane.png"); + sprite->setScaleX(3.f); + sprite->setScaleZ(3.f); + sprite->setPosition3D(Vec3(30.f, 15.f, 0.f)); + sprite->addComponent(component); + sprite->setCameraMask((unsigned short)CameraFlag::USER1); + this->addChild(sprite); + component->syncToNode(); + rigidBody->setLinearVelocity(Vec3(0,3,0)); + + rbDes.mass = 0.0f; + rbDes.shape = Physics3DShape::createBox(Vec3(3.0f, 3.0f, 3.f)); + auto rigidBodyB = Physics3DRigidBody::create(&rbDes); + component = Physics3DComponent::create(rigidBodyB); + sprite = Sprite3D::create("Sprite3DTest/box.c3t"); + sprite->setTexture("Sprite3DTest/plane.png"); + sprite->setScale(3.f); + sprite->setPosition3D(Vec3(30.f, 5.f, 0.f)); + sprite->addComponent(component); + sprite->setCameraMask((unsigned short)CameraFlag::USER1); + this->addChild(sprite); + component->syncToNode(); + + Mat4 frameInA, frameInB; + Mat4::createRotationZ(CC_DEGREES_TO_RADIANS(90), &frameInA); + frameInB = frameInA; + frameInA.m[13] = -5.f; + frameInB.m[13] = 5.f; + constraint = Physics3DSliderConstraint::create(rigidBody, rigidBodyB, frameInA, frameInB, false); + physicsScene->getPhysics3DWorld()->addPhysics3DConstraint(constraint); + ((Physics3DSliderConstraint*)constraint)->setLowerLinLimit(-5.f); + ((Physics3DSliderConstraint*)constraint)->setUpperLinLimit(5.f); + + //create ConeTwist constraint + rbDes.mass = 1.f; + rbDes.shape = Physics3DShape::createBox(Vec3(3.f, 3.f, 3.f)); + rigidBody = Physics3DRigidBody::create(&rbDes); + component = Physics3DComponent::create(rigidBody); + sprite = Sprite3D::create("Sprite3DTest/box.c3t"); + sprite->setTexture("Sprite3DTest/plane.png"); + sprite->setScale(3.f); + sprite->setPosition3D(Vec3(-10.f, 5.f, 0.f)); + sprite->addComponent(component); + sprite->setCameraMask((unsigned short)CameraFlag::USER1); + this->addChild(sprite); + component->syncToNode(); + + Mat4::createRotationZ(CC_DEGREES_TO_RADIANS(90), &frameInA); + frameInA.m[12] = 0.f; + frameInA.m[13] = -10.f; + frameInA.m[14] = 0.f; + constraint = Physics3DConeTwistConstraint::create(rigidBody, frameInA); + physicsScene->getPhysics3DWorld()->addPhysics3DConstraint(constraint, true); + ((Physics3DConeTwistConstraint*)constraint)->setLimit(CC_DEGREES_TO_RADIANS(10), CC_DEGREES_TO_RADIANS(10), CC_DEGREES_TO_RADIANS(40)); + + //create 6 dof constraint + rbDes.mass = 1.0f; + rbDes.shape = Physics3DShape::createBox(Vec3(3.0f, 3.0f, 3.f)); + rigidBody = Physics3DRigidBody::create(&rbDes); + component = Physics3DComponent::create(rigidBody); + sprite = Sprite3D::create("Sprite3DTest/box.c3t"); + sprite->setTexture("Sprite3DTest/plane.png"); + sprite->setScale(3.f); + sprite->setPosition3D(Vec3(30.f, -5.f, 0.f)); + sprite->addComponent(component); + sprite->setCameraMask((unsigned short)CameraFlag::USER1); + this->addChild(sprite); + component->syncToNode(); + frameInA.setIdentity(); + constraint = Physics3D6DofConstraint::create(rigidBody, frameInA, false); + physicsScene->getPhysics3DWorld()->addPhysics3DConstraint(constraint); + ((Physics3D6DofConstraint*)constraint)->setAngularLowerLimit(Vec3(0,0,0)); + ((Physics3D6DofConstraint*)constraint)->setAngularUpperLimit(Vec3(0,0,0)); + ((Physics3D6DofConstraint*)constraint)->setLinearLowerLimit(Vec3(-10,0,0)); + ((Physics3D6DofConstraint*)constraint)->setLinearUpperLimit(Vec3(10,0,0)); + + return true; +} + +void Physics3DConstraintDemo::onTouchesBegan(const std::vector& touches, cocos2d::Event *event) +{ + //ray trace + if(_camera) + { + auto touch = touches[0]; + auto location = touch->getLocationInView(); + Vec3 nearP(location.x, location.y, 0.0f), farP(location.x, location.y, 1.0f); + + auto size = Director::getInstance()->getWinSize(); + _camera->unproject(size, &nearP, &nearP); + _camera->unproject(size, &farP, &farP); + + Physics3DWorld::HitResult result; + bool ret = physicsScene->getPhysics3DWorld()->rayCast(nearP, farP, &result); + if (ret && result.hitObj->getObjType() == Physics3DObject::PhysicsObjType::RIGID_BODY) + { + auto mat = result.hitObj->getWorldTransform().getInversed(); + Vec3 position; + mat.transformPoint(result.hitPosition, &position); + + _constraint = Physics3DPointToPointConstraint::create(static_cast(result.hitObj), position); + physicsScene->getPhysics3DWorld()->addPhysics3DConstraint(_constraint, true); + _pickingDistance = (result.hitPosition - nearP).length(); + return; + } + } + Physics3DTestDemo::onTouchesBegan(touches, event); + _needShootBox = false; +} +void Physics3DConstraintDemo::onTouchesMoved(const std::vector& touches, cocos2d::Event *event) +{ + if (_constraint) + { + auto p2pConstraint = ((Physics3DPointToPointConstraint*)_constraint); + + auto touch = touches[0]; + auto location = touch->getLocationInView(); + Vec3 nearP(location.x, location.y, 0.0f), farP(location.x, location.y, 1.0f); + + auto size = Director::getInstance()->getWinSize(); + _camera->unproject(size, &nearP, &nearP); + _camera->unproject(size, &farP, &farP); + auto dir = (farP - nearP).getNormalized(); + p2pConstraint->setPivotPointInB(nearP + dir * _pickingDistance); + return; + } + Physics3DTestDemo::onTouchesMoved(touches, event); +} +void Physics3DConstraintDemo::onTouchesEnded(const std::vector& touches, cocos2d::Event *event) +{ + if (_constraint) + { + physicsScene->getPhysics3DWorld()->removePhysics3DConstraint(_constraint); + _constraint = nullptr; + return; + } + Physics3DTestDemo::onTouchesEnded(touches, event); +} + +bool Physics3DTerrainDemo::init() +{ + if (!Physics3DTestDemo::init()) + return false; + + Terrain::DetailMap r("TerrainTest/dirt.jpg"),g("TerrainTest/Grass2.jpg",10),b("TerrainTest/road.jpg"),a("TerrainTest/GreenSkin.jpg",20); + + Terrain::TerrainData data("TerrainTest/heightmap129.jpg","TerrainTest/alphamap.png",r,g,b,a,Size(32,32), 20.0f, 1.0f); + auto terrain = Terrain::create(data,Terrain::CrackFixedType::SKIRT); + terrain->setMaxDetailMapAmount(4); + terrain->setCameraMask(2); + terrain->setDrawWire(false); + + terrain->setSkirtHeightRatio(3); + terrain->setLODDistance(64,128,192); + terrain->setCameraMask((unsigned short)CameraFlag::USER1); + + //create terrain + Physics3DRigidBodyDes rbDes; + rbDes.mass = 0.0f; + std::vector heidata = terrain->getHeightData(); + auto size = terrain->getTerrainSize(); + rbDes.shape = Physics3DShape::createHeightfield(size.width, size.height, &heidata[0], 1.0f, terrain->getMinHeight(), terrain->getMaxHeight(), true, false, true); + auto rigidBody = Physics3DRigidBody::create(&rbDes); + auto component = Physics3DComponent::create(rigidBody); + terrain->addComponent(component); + this->addChild(terrain); + component->syncToNode(); + component->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::NONE); + + + //create several spheres + rbDes.mass = 1.f; + rbDes.shape = Physics3DShape::createSphere(0.5f); + float start_x = START_POS_X - ARRAY_SIZE_X/2 + 5.0f; + float start_y = START_POS_Y + 20.0f; + float start_z = START_POS_Z - ARRAY_SIZE_Z/2; + + for (int k=0;ksetTexture("Sprite3DTest/plane.png"); + sprite->setCameraMask((unsigned short)CameraFlag::USER1); + sprite->setScale(1.0f / sprite->getContentSize().width); + sprite->setPosition3D(Vec3(x, y, z)); + this->addChild(sprite); + sprite->syncToNode(); + sprite->setSyncFlag(Physics3DComponent::PhysicsSyncFlag::PHYSICS_TO_NODE); + } + } + } + + //create mesh + std::vector trianglesList; + auto bundle = Bundle3D::createBundle(); + bundle->load("Sprite3DTest/boss.c3b"); + MeshDatas meshs; + bundle->loadMeshDatas(meshs); + Bundle3D::destroyBundle(bundle); + for (auto iter : meshs.meshDatas){ + int preVertexSize = iter->getPerVertexSize() / sizeof(float); + for (auto indexArray : iter->subMeshIndices){ + for (auto i : indexArray){ + trianglesList.push_back(Vec3(iter->vertex[i * preVertexSize], iter->vertex[i * preVertexSize + 1], iter->vertex[i * preVertexSize + 2])); + } + } + } + + rbDes.mass = 0.0f; + rbDes.shape = Physics3DShape::createMesh(&trianglesList[0], (int)trianglesList.size() / 3); + rigidBody = Physics3DRigidBody::create(&rbDes); + component = Physics3DComponent::create(rigidBody); + auto sprite = Sprite3D::create("Sprite3DTest/boss.c3b"); + sprite->addComponent(component); + sprite->setRotation3D(Vec3(-90.0f, 0.0f, 0.0f)); + sprite->setPosition3D(Vec3(0.0f, 15.0f, 0.0f)); + sprite->setCameraMask(2); + this->addChild(sprite); + + std::vector > shapeList; + { + Mat4 localTrans; + auto bodyshape = Physics3DShape::createBox(Vec3(2.0f, 4.0f, 2.0f)); + Mat4::createTranslation(0.0f, 2.0f, 0.0f, &localTrans); + shapeList.push_back(std::make_pair(bodyshape, localTrans)); + auto headshape = Physics3DShape::createSphere(1.5f); + Mat4::createTranslation(0.6f, 5.0f, -1.5f, &localTrans); + shapeList.push_back(std::make_pair(headshape, localTrans)); + auto lhandshape = Physics3DShape::createBox(Vec3(1.0f, 3.0f, 1.0f)); + Mat4::createRotation(Vec3(1.0f, 0.0f, 0.0f), CC_DEGREES_TO_RADIANS(15.0f), &localTrans); + localTrans.m[12] = -1.5f; localTrans.m[13] = 2.5f; localTrans.m[14] = -2.5f; + shapeList.push_back(std::make_pair(lhandshape, localTrans)); + auto rhandshape = Physics3DShape::createBox(Vec3(1.0f, 3.0f, 1.0f)); + Mat4::createRotation(Vec3(1.0f, 0.0f, 0.0f), CC_DEGREES_TO_RADIANS(-15.0f), &localTrans); + localTrans.m[12] = 2.0f; localTrans.m[13] = 2.5f; localTrans.m[14] = 1.f; + shapeList.push_back(std::make_pair(rhandshape, localTrans)); + + rbDes.mass = 10.0f; + rbDes.shape = Physics3DShape::createCompoundShape(shapeList); + rigidBody = Physics3DRigidBody::create(&rbDes); + component = Physics3DComponent::create(rigidBody); + auto sprite = Sprite3D::create("Sprite3DTest/orc.c3b"); + sprite->addComponent(component); + sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f)); + sprite->setPosition3D(Vec3(-5.0f, 20.0f, 0.0f)); + sprite->setScale(0.4f); + sprite->setCameraMask(2); + this->addChild(sprite); + } + + + physicsScene->setPhysics3DDebugCamera(_camera); + return true; +} + +std::string Physics3DTerrainDemo::subtitle() const +{ + return "Physics3D Terrain"; +} + +std::string Physics3DCollisionCallbackDemo::subtitle() const +{ + return "Physics3D CollisionCallback"; +} + +bool Physics3DCollisionCallbackDemo::init() +{ + if (!Physics3DTestDemo::init()) + return false; + + { + Physics3DRigidBodyDes rbDes; + + float scale = 2.0f; + std::vector trianglesList; + auto bundle = Bundle3D::createBundle(); + bundle->load("Sprite3DTest/boss.c3b"); + MeshDatas meshs; + bundle->loadMeshDatas(meshs); + Bundle3D::destroyBundle(bundle); + for (auto iter : meshs.meshDatas){ + int preVertexSize = iter->getPerVertexSize() / sizeof(float); + for (auto indexArray : iter->subMeshIndices){ + for (auto i : indexArray){ + trianglesList.push_back(Vec3(iter->vertex[i * preVertexSize], iter->vertex[i * preVertexSize + 1], iter->vertex[i * preVertexSize + 2]) * scale); + } + } + } + + rbDes.mass = 0.0f; + rbDes.shape = Physics3DShape::createMesh(&trianglesList[0], (int)trianglesList.size() / 3); + auto rigidBody = Physics3DRigidBody::create(&rbDes); + auto component = Physics3DComponent::create(rigidBody); + auto sprite = Sprite3D::create("Sprite3DTest/boss.c3b"); + sprite->addComponent(component); + sprite->setRotation3D(Vec3(-90.0f, 0.0f, 0.0f)); + sprite->setScale(scale); + sprite->setCameraMask((unsigned short)CameraFlag::USER1); + this->addChild(sprite); + //preload + // + rigidBody->setCollisionCallback([=](const Physics3DCollisionInfo &ci){ + if (!ci.collisionPointList.empty()){ + if (ci.objA->getMask() != 0){ + auto ps = PUParticleSystem3D::create("Particle3D/scripts/mp_hit_04.pu"); + ps->setPosition3D(ci.collisionPointList[0].worldPositionOnB); + ps->setScale(0.05f); + ps->startParticleSystem(); + ps->setCameraMask(2); + this->addChild(ps); + ps->runAction(Sequence::create(DelayTime::create(1.0f), CallFunc::create([=](){ + ps->removeFromParent(); + }), nullptr)); + ci.objA->setMask(0); + } + } + //CCLOG("------------BoxB Collision Info------------"); + //CCLOG("Collision Point Num: %d", ci.collisionPointList.size()); + //for (auto &iter : ci.collisionPointList){ + // CCLOG("Collision Position On A: (%.2f, %.2f, %.2f)", iter.worldPositionOnA.x, iter.worldPositionOnA.y, iter.worldPositionOnA.z); + // CCLOG("Collision Position On B: (%.2f, %.2f, %.2f)", iter.worldPositionOnB.x, iter.worldPositionOnB.y, iter.worldPositionOnB.z); + // CCLOG("Collision Normal On B: (%.2f, %.2f, %.2f)", iter.worldNormalOnB.x, iter.worldNormalOnB.y, iter.worldNormalOnB.z); + //} + //CCLOG("------------BoxB Collision Info------------"); + }); + } + + physicsScene->setPhysics3DDebugCamera(_camera); + return true; +} + +#endif diff --git a/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.h b/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.h new file mode 100644 index 0000000000..03c77a6ffd --- /dev/null +++ b/tests/cpp-tests/Classes/Physics3DTest/Physics3DTest.h @@ -0,0 +1,153 @@ +/**************************************************************************** + 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 _PHYSICS3D_TEST_H_ +#define _PHYSICS3D_TEST_H_ + +#include "../testBasic.h" +#include "../BaseTest.h" +#include + +namespace cocos2d { + class Physics3DConstraint; +} + +DEFINE_TEST_SUITE(Physics3DTests); + +#if CC_USE_3D_PHYSICS == 0 +class Physics3DDemoDisabled : public TestCase +{ +public: + CREATE_FUNC(Physics3DDemoDisabled); + + virtual void onEnter() override; +}; +#else + +class Physics3DTestDemo : public TestCase +{ +public: + CREATE_FUNC(Physics3DTestDemo); + Physics3DTestDemo(void); + virtual ~Physics3DTestDemo(void); + + // overrides + virtual bool init() override; + virtual std::string title() const override; + virtual std::string subtitle() const override; + virtual void update(float delta) override; + + virtual void onTouchesBegan(const std::vector& touches, cocos2d::Event *event); + virtual void onTouchesMoved(const std::vector& touches, cocos2d::Event *event); + virtual void onTouchesEnded(const std::vector& touches, cocos2d::Event *event); + +protected: + + void shootBox(const cocos2d::Vec3 &des); + +protected: + std::string _title; + cocos2d::Camera *_camera; + float _angle; + bool _needShootBox; +}; + +class BasicPhysics3DDemo : public Physics3DTestDemo +{ +public: + + CREATE_FUNC(BasicPhysics3DDemo); + BasicPhysics3DDemo(){}; + virtual ~BasicPhysics3DDemo(){}; + + virtual std::string subtitle() const override; + + virtual bool init() override; +}; + +class Physics3DConstraintDemo : public Physics3DTestDemo +{ +public: + + CREATE_FUNC(Physics3DConstraintDemo); + Physics3DConstraintDemo():_constraint(nullptr), _pickingDistance(0.f){}; + virtual ~Physics3DConstraintDemo(){}; + + virtual std::string subtitle() const override; + + virtual bool init() override; + + virtual void onTouchesBegan(const std::vector& touches, cocos2d::Event *event) override; + virtual void onTouchesMoved(const std::vector& touches, cocos2d::Event *event) override; + virtual void onTouchesEnded(const std::vector& touches, cocos2d::Event *event) override; + +protected: + cocos2d::Physics3DConstraint* _constraint; //for picking + float _pickingDistance; //picking distance +}; + +class Physics3DKinematicDemo : public Physics3DTestDemo +{ +public: + + CREATE_FUNC(Physics3DKinematicDemo); + Physics3DKinematicDemo(){}; + virtual ~Physics3DKinematicDemo(){}; + + virtual std::string subtitle() const override; + + virtual bool init() override; +}; + +class Physics3DCollisionCallbackDemo : public Physics3DTestDemo +{ +public: + + CREATE_FUNC(Physics3DCollisionCallbackDemo); + Physics3DCollisionCallbackDemo(){}; + virtual ~Physics3DCollisionCallbackDemo(){}; + + virtual std::string subtitle() const override; + + virtual bool init() override; +}; + +class Physics3DTerrainDemo : public Physics3DTestDemo +{ +public: + + CREATE_FUNC(Physics3DTerrainDemo); + Physics3DTerrainDemo(){}; + virtual ~Physics3DTerrainDemo(){}; + + virtual std::string subtitle() const override; + + virtual bool init() override; + +private: +}; + +#endif + +#endif \ No newline at end of file diff --git a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp index 924708cd4e..c599ff06af 100644 --- a/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp +++ b/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp @@ -54,9 +54,9 @@ void PhysicsDemoDisabled::onEnter() #else PhysicsDemo::PhysicsDemo() -: _debugDraw(false) -, _spriteTexture(nullptr) +: _spriteTexture(nullptr) , _ball(nullptr) +, _debugDraw(false) { } diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp index fd05a23ff2..46a6ee9c8d 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest.cpp @@ -129,6 +129,7 @@ void ShaderNode::onDraw(const Mat4 &transform, uint32_t flags) auto glProgramState = getGLProgramState(); glProgramState->setVertexAttribPointer("a_position", 2, GL_FLOAT, GL_FALSE, 0, vertices); + glProgramState->apply(transform); glDrawArrays(GL_TRIANGLES, 0, 6); @@ -181,7 +182,7 @@ bool ShaderMandelbrot::init() { if (ShaderTestDemo::init()) { -#if CC_TARGET_PLATFORM != CC_PLATFORM_WINRT && CC_TARGET_PLATFORM != CC_PLATFORM_WP8 +#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) auto sn = ShaderNode::shaderNodeWithVertex("", "Shaders/example_Mandelbrot.fsh"); auto s = Director::getInstance()->getWinSize(); @@ -215,7 +216,7 @@ bool ShaderJulia::init() { if (ShaderTestDemo::init()) { -#if CC_TARGET_PLATFORM != CC_PLATFORM_WINRT && CC_TARGET_PLATFORM != CC_PLATFORM_WP8 +#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) auto sn = ShaderNode::shaderNodeWithVertex("", "Shaders/example_Julia.fsh"); auto s = Director::getInstance()->getWinSize(); @@ -486,7 +487,7 @@ bool ShaderBlur::init() { if( ShaderTestDemo::init() ) { -#if CC_TARGET_PLATFORM != CC_PLATFORM_WINRT && CC_TARGET_PLATFORM != CC_PLATFORM_WP8 +#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) _blurSprite = SpriteBlur::create("Images/grossini.png"); auto sprite = Sprite::create("Images/grossini.png"); auto s = Director::getInstance()->getWinSize(); diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index db078d8fdd..769f706afe 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -140,7 +140,7 @@ bool Effect::initGLProgramState(const std::string &fragmentFilename) auto fragSource = fileUtiles->getStringFromFile(fragmentFullPath); auto glprogram = GLProgram::createWithByteArrays(ccPositionTextureColor_noMVP_vert, fragSource.c_str()); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) _fragSource = fragSource; #endif @@ -153,7 +153,7 @@ bool Effect::initGLProgramState(const std::string &fragmentFilename) Effect::Effect() : _glprogramstate(nullptr) { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) _backgroundListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom*) { @@ -171,7 +171,7 @@ Effect::Effect() Effect::~Effect() { CC_SAFE_RELEASE_NULL(_glprogramstate); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) Director::getInstance()->getEventDispatcher()->removeEventListener(_backgroundListener); #endif } @@ -441,6 +441,9 @@ EffectSpriteTest::EffectSpriteTest() { if (ShaderTestDemo2::init()) { + auto layer = LayerColor::create(Color4B::BLUE); + this->addChild(layer); + auto s = Director::getInstance()->getWinSize(); auto itemPrev = MenuItemImage::create("Images/b1.png", "Images/b2.png", diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h index 4abdbdd80a..7144ba78f7 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h @@ -29,7 +29,7 @@ protected: Effect(); virtual ~Effect(); cocos2d::GLProgramState* _glprogramstate; -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) std::string _fragSource; cocos2d::EventListenerCustom* _backgroundListener; #endif diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index 2e38ba4279..9338a4b299 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -24,15 +24,6 @@ ****************************************************************************/ #include "Sprite3DTest.h" -#include "base/CCAsyncTaskPool.h" -#include "3d/CCAnimation3D.h" -#include "3d/CCAnimate3D.h" -#include "3d/CCAttachNode.h" -#include "3d/CCRay.h" -#include "3d/CCSprite3D.h" -#include "3d/CCTextureCube.h" -#include "3d/CCSkybox.h" -#include "renderer/CCVertexIndexBuffer.h" #include "DrawNode3D.h" #include @@ -45,18 +36,14 @@ Sprite3DTests::Sprite3DTests() ADD_TEST_CASE(Sprite3DBasicTest); ADD_TEST_CASE(Sprite3DHitTest); ADD_TEST_CASE(AsyncLoadSprite3DTest); -#if (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) // 3DEffect use custom shader which is not supported on WP8/WinRT yet. ADD_TEST_CASE(Sprite3DEffectTest); ADD_TEST_CASE(Sprite3DUVAnimationTest); ADD_TEST_CASE(Sprite3DFakeShadowTest); ADD_TEST_CASE(Sprite3DBasicToonShaderTest); ADD_TEST_CASE(Sprite3DLightMapTest); -#endif ADD_TEST_CASE(Sprite3DWithSkinTest); -#if (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) ADD_TEST_CASE(Sprite3DWithSkinOutlineTest); -#endif ADD_TEST_CASE(Animate3DTest); ADD_TEST_CASE(AttachmentTest); ADD_TEST_CASE(Sprite3DReskinTest); @@ -283,7 +270,7 @@ Sprite3DUVAnimationTest::Sprite3DUVAnimationTest() //the callback function update cylinder's texcoord schedule(schedule_selector(Sprite3DUVAnimationTest::cylinderUpdate)); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) _backToForegroundListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom*) { @@ -311,7 +298,7 @@ Sprite3DUVAnimationTest::Sprite3DUVAnimationTest() Sprite3DUVAnimationTest::~Sprite3DUVAnimationTest() { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundListener); #endif } @@ -419,7 +406,7 @@ Sprite3DFakeShadowTest::Sprite3DFakeShadowTest() schedule(CC_SCHEDULE_SELECTOR(Sprite3DFakeShadowTest::updateCamera), 0.0f); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) _backToForegroundListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom*) { @@ -448,7 +435,7 @@ Sprite3DFakeShadowTest::Sprite3DFakeShadowTest() Sprite3DFakeShadowTest::~Sprite3DFakeShadowTest() { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundListener); #endif } @@ -648,7 +635,7 @@ Sprite3DBasicToonShaderTest::Sprite3DBasicToonShaderTest() addChild(_camera); setCameraMask(2); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) _backToForegroundListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom*) { @@ -665,7 +652,7 @@ Sprite3DBasicToonShaderTest::Sprite3DBasicToonShaderTest() Sprite3DBasicToonShaderTest::~Sprite3DBasicToonShaderTest() { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundListener); #endif } @@ -951,7 +938,7 @@ Effect3DOutline::Effect3DOutline() , _outlineWidth(1.0f) , _sprite(nullptr) { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) _backToForegroundListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom*) { @@ -968,7 +955,7 @@ Effect3DOutline::Effect3DOutline() Effect3DOutline::~Effect3DOutline() { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundListener); #endif } @@ -2186,8 +2173,8 @@ void UseCaseSprite3D::switchCase() circleBack->setScale(0.5f); circleBack->addChild(circle); circle->runAction(RepeatForever::create(RotateBy::create(3, Vec3(0.f, 0.f, 360.f)))); - - circleBack->setRotation3D(Vec3(90, 0, 0)); + + circleBack->setRotation3D(Vec3(90, 90, 0)); auto pos = sprite->getPosition3D(); circleBack->setPosition3D(Vec3(pos.x, pos.y, pos.z - 1)); @@ -2395,7 +2382,7 @@ Sprite3DCubeMapTest::Sprite3DCubeMapTest() : Sprite3DCubeMapTest::~Sprite3DCubeMapTest() { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundListener); #endif @@ -2444,8 +2431,8 @@ void Sprite3DCubeMapTest::addNewSpriteWithCoords(Vec2 p) Texture2D::TexParams tRepeatParams; tRepeatParams.magFilter = GL_LINEAR; tRepeatParams.minFilter = GL_LINEAR; - tRepeatParams.wrapS = GL_MIRRORED_REPEAT; - tRepeatParams.wrapT = GL_MIRRORED_REPEAT; + tRepeatParams.wrapS = GL_CLAMP_TO_EDGE; + tRepeatParams.wrapT = GL_CLAMP_TO_EDGE; _textureCube->setTexParameters(tRepeatParams); // pass the texture sampler to our custom shader @@ -2489,7 +2476,7 @@ void Sprite3DCubeMapTest::addNewSpriteWithCoords(Vec2 p) addChild(_camera); setCameraMask(2); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) _backToForegroundListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom*) { @@ -2505,8 +2492,8 @@ void Sprite3DCubeMapTest::addNewSpriteWithCoords(Vec2 p) Texture2D::TexParams tRepeatParams; tRepeatParams.magFilter = GL_NEAREST; tRepeatParams.minFilter = GL_NEAREST; - tRepeatParams.wrapS = GL_MIRRORED_REPEAT; - tRepeatParams.wrapT = GL_MIRRORED_REPEAT; + tRepeatParams.wrapS = GL_CLAMP_TO_EDGE; + tRepeatParams.wrapT = GL_CLAMP_TO_EDGE; _textureCube->setTexParameters(tRepeatParams); state->setUniformTexture("u_cubeTex", _textureCube); diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h index 5e1602383f..5670b7c8cf 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h @@ -92,7 +92,7 @@ protected: float _shining_duraion; cocos2d::GLProgramState * _state; -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) cocos2d::EventListenerCustom* _backToForegroundListener; #endif }; @@ -128,7 +128,7 @@ private: cocos2d::Sprite3D * _orc; cocos2d::GLProgramState * _state; -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) cocos2d::EventListenerCustom* _backToForegroundListener; #endif }; @@ -158,7 +158,7 @@ public: protected: cocos2d::GLProgramState * _state; -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) cocos2d::EventListenerCustom* _backToForegroundListener; #endif @@ -202,7 +202,7 @@ protected: float _outlineWidth; //weak reference EffectSprite3D* _sprite; -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) cocos2d::EventListenerCustom* _backToForegroundListener; #endif @@ -527,7 +527,7 @@ protected: cocos2d::Sprite3D* _teapot; cocos2d::Camera *_camera; -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) cocos2d::EventListenerCustom* _backToForegroundListener; #endif }; diff --git a/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp b/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp index ee67a9cac2..b175e94e4f 100644 --- a/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp +++ b/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp @@ -227,7 +227,7 @@ void SpritePolygonTestDemo::initDefaultSprite(const std::string &filename, cocos positions[1] = Vec2(spSize); positions[2] = Vec2(spSize.width, 0); positions[3] = Vec2(0,0); - debugForNormalSprite->drawPoints(positions, 4, 8, Color4F{0.0,1.0,1.0,1.0}); + debugForNormalSprite->drawPoints(positions, 4, 8, Color4F(0.0,1.0,1.0,1.0)); debugForNormalSprite->drawLine(positions[0], positions[1], Color4F::GREEN); debugForNormalSprite->drawLine(positions[1], positions[2], Color4F::GREEN); debugForNormalSprite->drawLine(positions[2], positions[3], Color4F::GREEN); diff --git a/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp b/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp index 8ec489c3fa..7454a02903 100644 --- a/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp +++ b/tests/cpp-tests/Classes/SpriteTest/SpriteTest.cpp @@ -3332,32 +3332,26 @@ class MySprite1 : public Sprite { public: CREATE_FUNC(MySprite1); - MySprite1() : ivar(10) {} + MySprite1() {} static MySprite1* createWithSpriteFrameName(const std::string& spriteFrameName) { auto sprite = MySprite1::create(); sprite->setSpriteFrame(spriteFrameName); return sprite; } - -private: - int ivar; }; class MySprite2 : public Sprite { public: CREATE_FUNC(MySprite2); - MySprite2() : ivar(10) {} + MySprite2() {} static MySprite2* create(const std::string& name) { auto sprite = MySprite2::create(); sprite ->setTexture(name); return sprite; } - -private: - int ivar; }; //------------------------------------------------------------------ diff --git a/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.cpp b/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.cpp index 1bb1908e66..3000f80348 100644 --- a/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.cpp +++ b/tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.cpp @@ -81,7 +81,7 @@ Texture2DTests::Texture2DTests() ADD_TEST_CASE(TextureJPEG); ADD_TEST_CASE(TextureTIFF); ADD_TEST_CASE(TextureTGA); -#if (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) && (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) ADD_TEST_CASE(TextureWEBP); #endif ADD_TEST_CASE(TexturePixelFormat); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp index 99765e720d..580dddba9a 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp @@ -23,7 +23,7 @@ #include "UIWebViewTest/UIWebViewTest.h" #endif #include "UIScale9SpriteTest.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) #include "UIEditBoxTest.h" #endif @@ -35,7 +35,7 @@ GUIDynamicCreateTests::GUIDynamicCreateTests() #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) addTest("WebView Test", [](){ return new (std::nothrow) WebViewTests; }); #endif -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) addTest("EditBox Test", [](){ return new (std::nothrow) UIEditBoxTests; }); #endif addTest("Focus Test", [](){ return new (std::nothrow) UIFocusTests; }); diff --git a/tests/cpp-tests/Classes/controller.cpp b/tests/cpp-tests/Classes/controller.cpp index 0bf04cfbf5..7a41b9fdb8 100644 --- a/tests/cpp-tests/Classes/controller.cpp +++ b/tests/cpp-tests/Classes/controller.cpp @@ -46,6 +46,7 @@ public: addTest("FileUtils", []() { return new FileUtilsTests(); }); addTest("Fonts", []() { return new FontTests(); }); addTest("Interval", [](){return new IntervalTests(); }); + addTest("Material System", [](){return new MaterialSystemTest(); }); addTest("Node: BillBoard Test", [](){ return new BillBoardTests(); }); addTest("Node: Camera 3D Test", [](){ return new Camera3DTests(); }); addTest("Node: Clipping", []() { return new ClippingNodeTests(); }); @@ -61,11 +62,13 @@ public: addTest("Node: Particles", [](){return new ParticleTests(); }); addTest("Node: Particle3D (PU)", [](){return new Particle3DTests(); }); addTest("Node: Physics", []() { return new PhysicsTests(); }); + addTest( "Node: Physics3D", []() { return new Physics3DTests(); } ); addTest("Node: RenderTexture", [](){return new RenderTextureTests(); }); addTest("Node: Scene", [](){return new SceneTests(); }); addTest("Node: Spine", [](){return new SpineTests(); }); addTest("Node: Sprite", [](){return new SpriteTests(); }); addTest("Node: Sprite3D", [](){ return new Sprite3DTests(); }); + addTest("Node: SpritePolygon", [](){return new (std::nothrow) SpritePolygonTest(); }); addTest("Node: Terrain", [](){ return new TerrainTests(); }); addTest("Node: TileMap", [](){return new TileMapTests(); }); addTest("Node: FastTileMap", [](){return new FastTileMapTests(); }); @@ -73,7 +76,7 @@ public: addTest("Node: UI", [](){ return new UITests(); }); addTest("Mouse", []() { return new MouseTests(); }); addTest("MultiTouch", []() { return new MutiTouchTests(); }); - //addTest("Performance tests", []() { return new PerformanceTests(); }); + addTest("Performance tests", []() { return new PerformanceTests(); }); addTest("Renderer", []() { return new NewRendererTests(); }); addTest("ReleasePool", [](){ return new ReleasePoolTests(); }); addTest("Rotate World", [](){return new RotateWorldTests(); }); @@ -395,7 +398,7 @@ void TestController::logEx(const char * format, ...) #if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID __android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", "%s", buff); -#elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT +#elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT WCHAR wszBuf[1024] = { 0 }; MultiByteToWideChar(CP_UTF8, 0, buff, -1, wszBuf, sizeof(wszBuf)); OutputDebugStringW(wszBuf); diff --git a/tests/cpp-tests/Classes/tests.h b/tests/cpp-tests/Classes/tests.h index 31ff7672b7..b4fba11740 100644 --- a/tests/cpp-tests/Classes/tests.h +++ b/tests/cpp-tests/Classes/tests.h @@ -81,10 +81,13 @@ #include "BillBoardTest/BillBoardTest.h" #include "LightTest/LightTest.h" #include "Particle3DTest/Particle3DTest.h" +#include "Physics3DTest/Physics3DTest.h" #include "OpenURLTest/OpenURLTest.h" #include "AllocatorTest/AllocatorTest.h" #include "CocosStudio3DTest/CocosStudio3DTest.h" #include "UITest/UITest.h" +#include "MaterialSystemTest/MaterialSystemTest.h" + #endif diff --git a/tests/cpp-tests/Resources/Images/cocos2dbanner.png b/tests/cpp-tests/Resources/Images/cocos2dbanner.png new file mode 100644 index 0000000000..f60ca47c57 Binary files /dev/null and b/tests/cpp-tests/Resources/Images/cocos2dbanner.png differ diff --git a/tests/cpp-tests/Resources/Images/favicon.ico b/tests/cpp-tests/Resources/Images/favicon.ico new file mode 100644 index 0000000000..1ad6a0907b Binary files /dev/null and b/tests/cpp-tests/Resources/Images/favicon.ico differ diff --git a/tests/cpp-tests/Resources/Images/heightfield64x64.raw b/tests/cpp-tests/Resources/Images/heightfield64x64.raw new file mode 100644 index 0000000000..48db5e35ea Binary files /dev/null and b/tests/cpp-tests/Resources/Images/heightfield64x64.raw differ diff --git a/tests/cpp-tests/Resources/Materials/effects.material b/tests/cpp-tests/Resources/Materials/effects.material new file mode 100644 index 0000000000..bb5ff81a6f --- /dev/null +++ b/tests/cpp-tests/Resources/Materials/effects.material @@ -0,0 +1,177 @@ +{ + "metadata" : { + "version" : 1, + "type" : "material" + }, + "name" : "simple effects", + "techniques" : [ + { + "name": "blur", + "passes": [ + { + "renderState": { + "blend": "true", + "blendSrc": "ONE", + "blendDst": "ONE_MINUS_SRC_ALPHA" + }, + "shader" : { + "defines": "THIS_IS_AN_EXAMPLE 1;TOMORROW_IS_HOLIDAY 2", + "vertexShader": "Shaders/example_simple.vsh", + "fragmentShader": "Shaders/example_Blur.fsh", + "blurRadius": 10, + "sampleNum": 5, + "resolution": [100,100] + }, + "textures": [ + { + "path": "Images/grossinis_sister1.png", + "wrapS": "CLAMP_TO_EDGE", + "wrapT": "CLAMP_TO_EDGE", + "minFilter": "LINEAR", + "magFilter": "LINEAR", + "mipmap": "false" + } + ] + } + ] + }, + { + "name": "outline", + "passes": [ + { + "renderState": { + "blend": "true", + "blendSrc": "ONE", + "blendDst": "ONE_MINUS_SRC_ALPHA" + }, + "shader" : { + "defines": "", + "vertexShader": "Shaders/example_simple.vsh", + "fragmentShader": "Shaders/example_outline.fsh", + "u_outlineColor": [0.1, 0.2, 0.3], + "u_radius": 0.01, + "u_threshold": 1.75 + }, + "textures": [ + { + "path": "Images/grossinis_sister1.png", + "wrapS": "CLAMP_TO_EDGE", + "wrapT": "CLAMP_TO_EDGE", + "minFilter": "LINEAR", + "magFilter": "LINEAR", + "mipmap": "false" + } + ] + } + ] + }, + { + "name": "noise", + "passes": [ + { + "renderState": { + "blend": "true", + "blendSrc": "ONE", + "blendDst": "ONE_MINUS_SRC_ALPHA" + }, + "shader" : { + "defines": "", + "vertexShader": "Shaders/example_simple.vsh", + "fragmentShader": "Shaders/example_Noisy.fsh", + "resolution": [100,100] + }, + "textures": [ + { + "path": "Images/grossinis_sister1.png", + "wrapS": "CLAMP_TO_EDGE", + "wrapT": "CLAMP_TO_EDGE", + "minFilter": "LINEAR", + "magFilter": "LINEAR", + "mipmap": "false" + } + ] + } + ] + }, + { + "name": "edge detect", + "passes": [ + { + "renderState": { + "blend": "true", + "blendSrc": "ONE", + "blendDst": "ONE_MINUS_SRC_ALPHA" + }, + "shader" : { + "defines": "", + "vertexShader": "Shaders/example_simple.vsh", + "fragmentShader": "Shaders/example_edgeDetection.fsh", + "resolution": [100,100] + }, + "textures": [ + { + "path": "Images/grossinis_sister1.png", + "wrapS": "CLAMP_TO_EDGE", + "wrapT": "CLAMP_TO_EDGE", + "minFilter": "LINEAR", + "magFilter": "LINEAR", + "mipmap": "false" + } + ] + } + ] + }, + { + "name": "gray+blur", + "passes": [ + { + "renderState": { + "blend": "true", + "blendSrc": "ONE", + "blendDst": "ONE_MINUS_SRC_ALPHA" + }, + "shader" : { + "defines": "TEXTURE_REPEAT", + "vertexShader": "Shaders/example_simple.vsh", + "fragmentShader": "Shaders/example_Blur.fsh", + "blurRadius": 10, + "sampleNum": 5, + "resolution": [100,100] + }, + "textures": [ + { + "path": "Images/grossinis_sister1.png", + "wrapS": "CLAMP_TO_EDGE", + "wrapT": "CLAMP_TO_EDGE", + "minFilter": "LINEAR", + "magFilter": "LINEAR", + "mipmap": "false" + } + ] + }, + { + "renderState": { + "blend": "true", + "blendSrc": "ONE_MINUS_SRC_ALPHA", + "blendDst": "ONE_MINUS_SRC_ALPHA" + }, + "shader" : { + "defines": "", + "vertexShader": "Shaders/example_simple.vsh", + "fragmentShader": "Shaders/example_greyScale.fsh" + }, + "textures": [ + { + "path": "Images/grossinis_sister1.png", + "wrapS": "CLAMP_TO_EDGE", + "wrapT": "CLAMP_TO_EDGE", + "minFilter": "LINEAR", + "magFilter": "LINEAR", + "mipmap": "false" + } + ] + } + ] + } + ] +} diff --git a/tests/cpp-tests/Resources/Materials/spaceship.material b/tests/cpp-tests/Resources/Materials/spaceship.material new file mode 100644 index 0000000000..285a1ea5e3 --- /dev/null +++ b/tests/cpp-tests/Resources/Materials/spaceship.material @@ -0,0 +1,37 @@ +{ + "metadata" : { + "version" : 1, + "type" : "material" + }, + "name" : "spaceship", + "techniques" : [ + { + "name": "simple", + "passes": [ + { + "renderState": { + "blend": "true", + "blendSrc": "ONE_MINUS_SRC_ALPHA", + "blendDst": "ONE_MINUS_SRC_ALPHA" + }, + "shader" : { + "defines": "", + "vertexShader": "Shaders/example_3D_PositionTex.vsh", + "fragmentShader": "Shaders/example_3D_PositionTex.fsh", + "u_color": [1,1,1,1] + }, + "textures": [ + { + "path": "Sprite3DTest/boss.png", + "wrapS": "CLAMP_TO_EDGE", + "wrapT": "CLAMP_TO_EDGE", + "minFilter": "LINEAR", + "magFilter": "LINEAR", + "mipmap": "false" + } + ] + } + ] + } + ] +} diff --git a/tests/cpp-tests/Resources/Particle3D/scripts/mp_hit_04.pu b/tests/cpp-tests/Resources/Particle3D/scripts/mp_hit_04.pu new file mode 100644 index 0000000000..dbe1f2cc42 --- /dev/null +++ b/tests/cpp-tests/Resources/Particle3D/scripts/mp_hit_04.pu @@ -0,0 +1,56 @@ +system mp_hit_04 +{ + keep_local true + technique + { + visual_particle_quota 10 + material PUMediaPack/Star_05 + renderer Billboard + { + billboard_type oriented_self + billboard_rotation_type vertex + } + emitter Point + { + emission_rate 6 + angle 360 + time_to_live 0.3 + velocity 1e-006 + duration 0.1 + particle_width dyn_random + { + min 60 + max 200 + } + particle_height dyn_random + { + min 100 + max 400 + } + start_colour_range 0.415686 0.678431 1 1 + end_colour_range 0.643137 0.317647 1 1 + force_emission true + } + affector Colour + { + time_colour 0 1 1 1 1 + time_colour 1 0 0 0 1 + colour_operation multiply + } + affector Scale + { + xyz_scale dyn_random + { + min 800 + max 1000 + } + } + observer OnClear + { + observe_until_event true + handler DoStopSystem + { + } + } + } +} diff --git a/tests/cpp-tests/Resources/Shaders/example_3D_PositionTex.fsh b/tests/cpp-tests/Resources/Shaders/example_3D_PositionTex.fsh new file mode 100644 index 0000000000..0d87c7e229 --- /dev/null +++ b/tests/cpp-tests/Resources/Shaders/example_3D_PositionTex.fsh @@ -0,0 +1,12 @@ +#ifdef GL_ES +varying mediump vec2 TextureCoordOut; +#else +varying vec2 TextureCoordOut; +#endif +uniform vec4 u_color; + +void main(void) +{ + gl_FragColor = texture2D(CC_Texture0, TextureCoordOut) * u_color; +} + diff --git a/tests/cpp-tests/Resources/Shaders/example_3D_PositionTex.vsh b/tests/cpp-tests/Resources/Shaders/example_3D_PositionTex.vsh new file mode 100644 index 0000000000..7180be8fa8 --- /dev/null +++ b/tests/cpp-tests/Resources/Shaders/example_3D_PositionTex.vsh @@ -0,0 +1,11 @@ +attribute vec4 a_position; +attribute vec2 a_texCoord; + +varying vec2 TextureCoordOut; + +void main(void) +{ + gl_Position = CC_MVPMatrix * a_position; + TextureCoordOut = a_texCoord; + TextureCoordOut.y = 1.0 - TextureCoordOut.y; +} diff --git a/tests/cpp-tests/Resources/Shaders/example_Blur.fsh b/tests/cpp-tests/Resources/Shaders/example_Blur.fsh index 74eefdf0fe..3841f862b7 100644 --- a/tests/cpp-tests/Resources/Shaders/example_Blur.fsh +++ b/tests/cpp-tests/Resources/Shaders/example_Blur.fsh @@ -9,19 +9,19 @@ uniform vec2 resolution; uniform float blurRadius; uniform float sampleNum; -vec3 blur(vec2); +vec4 blur(vec2); void main(void) { - vec3 col = blur(v_texCoord); - gl_FragColor = vec4(col, 1.0) * v_fragmentColor; + vec4 col = blur(v_texCoord); //* v_fragmentColor.rgb; + gl_FragColor = vec4(col) * v_fragmentColor; } -vec3 blur(vec2 p) +vec4 blur(vec2 p) { if (blurRadius > 0.0 && sampleNum > 1.0) { - vec3 col = vec3(0); + vec4 col = vec4(0); vec2 unit = 1.0 / resolution.xy; float r = blurRadius; @@ -34,7 +34,7 @@ vec3 blur(vec2 p) for(float y = -r; y < r; y += sampleStep) { float weight = (r - abs(x)) * (r - abs(y)); - col += texture2D(CC_Texture0, p + vec2(x * unit.x, y * unit.y)).rgb * weight; + col += texture2D(CC_Texture0, p + vec2(x * unit.x, y * unit.y)) * weight; count += weight; } } @@ -42,5 +42,5 @@ vec3 blur(vec2 p) return col / count; } - return texture2D(CC_Texture0, p).rgb; + return texture2D(CC_Texture0, p); } diff --git a/tests/cpp-tests/Resources/Shaders/example_simple.vsh b/tests/cpp-tests/Resources/Shaders/example_simple.vsh new file mode 100644 index 0000000000..d6b899fd45 --- /dev/null +++ b/tests/cpp-tests/Resources/Shaders/example_simple.vsh @@ -0,0 +1,18 @@ +attribute vec4 a_position; +attribute vec2 a_texCoord; +attribute vec4 a_color; + +#ifdef GL_ES +varying lowp vec4 v_fragmentColor; +varying mediump vec2 v_texCoord; +#else +varying vec4 v_fragmentColor; +varying vec2 v_texCoord; +#endif + +void main() +{ + gl_Position = CC_PMatrix * a_position; + v_fragmentColor = a_color; + v_texCoord = a_texCoord; +} diff --git a/tests/cpp-tests/Resources/Sprite3DTest/box.c3t b/tests/cpp-tests/Resources/Sprite3DTest/box.c3t new file mode 100644 index 0000000000..876194acca --- /dev/null +++ b/tests/cpp-tests/Resources/Sprite3DTest/box.c3t @@ -0,0 +1,94 @@ +{ + "version": "0.6", + "id": "", + "meshes": [ + { + "attributes": [{ + "size": 3, + "type": "GL_FLOAT", + "attribute": "VERTEX_ATTRIB_POSITION" + }, { + "size": 3, + "type": "GL_FLOAT", + "attribute": "VERTEX_ATTRIB_NORMAL" + }, { + "size": 2, + "type": "GL_FLOAT", + "attribute": "VERTEX_ATTRIB_TEX_COORD" + }], + "vertices": [ + 0.500000, -0.500000, -0.500000, 0.000000, 0.000000, -1.000000, 0.000000, 0.000000, + -0.500000, -0.500000, -0.500000, 0.000000, 0.000000, -1.000000, 1.000000, 0.000000, + 0.500000, 0.500000, -0.500000, 0.000000, 0.000000, -1.000000, 0.000000, 1.000000, + -0.500000, 0.500000, -0.500000, 0.000000, 0.000000, -1.000000, 1.000000, 1.000000, + 0.500000, 0.500000, 0.500000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000, + -0.500000, 0.500000, 0.500000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, + -0.500000, -0.500000, 0.500000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, + 0.500000, -0.500000, 0.500000, 0.000000, 0.000000, 1.000000, 1.000000, 0.000000, + 0.500000, -0.500000, 0.500000, 0.000000, -1.000000, 0.000000, 1.000000, 1.000000, + -0.500000, -0.500000, 0.500000, 0.000000, -1.000000, 0.000000, 0.000000, 1.000000, + -0.500000, -0.500000, -0.500000, 0.000000, -1.000000, 0.000000, 0.000000, 0.000000, + 0.500000, -0.500000, -0.500000, 0.000000, -1.000000, 0.000000, 1.000000, 0.000000, + 0.500000, 0.500000, 0.500000, 1.000000, 0.000000, 0.000000, 1.000000, 1.000000, + 0.500000, -0.500000, 0.500000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, + 0.500000, -0.500000, -0.500000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, + 0.500000, 0.500000, -0.500000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, + -0.500000, 0.500000, 0.500000, 0.000000, 1.000000, 0.000000, 1.000000, 1.000000, + 0.500000, 0.500000, 0.500000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, + 0.500000, 0.500000, -0.500000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, + -0.500000, 0.500000, -0.500000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, + -0.500000, -0.500000, 0.500000, -1.000000, 0.000000, 0.000000, 1.000000, 1.000000, + -0.500000, 0.500000, 0.500000, -1.000000, 0.000000, 0.000000, 0.000000, 1.000000, + -0.500000, 0.500000, -0.500000, -1.000000, 0.000000, 0.000000, 0.000000, 0.000000, + -0.500000, -0.500000, -0.500000, -1.000000, 0.000000, 0.000000, 1.000000, 0.000000 + ], + "parts": [ + { + "id": "shape1_part1", + "type": "TRIANGLES", + "indices": [ + 0, 1, 2, 1, 3, 2, 4, 5, 6, 4, 6, 7, + 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, + 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23 + ], + "aabb": [-0.500000, -0.500000, -0.500000, 0.500000, 0.500000, 0.500000] + } + ] + } + ], + "materials": [ + { + "id": "01 - Default", + "ambient": [ 0.588235, 0.588235, 0.588235], + "diffuse": [ 0.588235, 0.588235, 0.588235], + "emissive": [ 0.000000, 0.000000, 0.000000], + "opacity": 1.000000, + "specular": [ 0.900000, 0.900000, 0.900000], + "shininess": 2.000000, + "textures": [ + { + "id": "Map #1", + "filename": "", + "type": "DIFFUSE", + "wrapModeU": "REPEAT", + "wrapModeV": "REPEAT" + } + ] + } + ], + "nodes": [ + { + "id": "Box001", + "skeleton": false, + "transform": [ 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000], + "parts": [ + { + "meshpartid": "shape1_part1", + "materialid": "01 - Default", + "uvMapping": [[ 0]] + } + ] + } + ], + "animations": [] +} \ No newline at end of file diff --git a/tests/cpp-tests/Resources/TerrainTest/heightMap129.jpg b/tests/cpp-tests/Resources/TerrainTest/heightmap129.jpg similarity index 100% rename from tests/cpp-tests/Resources/TerrainTest/heightMap129.jpg rename to tests/cpp-tests/Resources/TerrainTest/heightmap129.jpg diff --git a/tests/cpp-tests/proj.android/jni/Android.mk b/tests/cpp-tests/proj.android/jni/Android.mk index e1236363f4..b0d1ab7f81 100644 --- a/tests/cpp-tests/proj.android/jni/Android.mk +++ b/tests/cpp-tests/proj.android/jni/Android.mk @@ -7,16 +7,13 @@ LOCAL_MODULE := cpp_tests_shared LOCAL_MODULE_FILENAME := libcpp_tests LOCAL_SRC_FILES := main.cpp \ -../../Classes/AppDelegate.cpp \ -../../Classes/BaseTest.cpp \ -../../Classes/controller.cpp \ -../../Classes/testBasic.cpp \ -../../Classes/VisibleRect.cpp \ ../../Classes/ActionManagerTest/ActionManagerTest.cpp \ ../../Classes/ActionsEaseTest/ActionsEaseTest.cpp \ ../../Classes/ActionsProgressTest/ActionsProgressTest.cpp \ ../../Classes/ActionsTest/ActionsTest.cpp \ ../../Classes/AllocatorTest/AllocatorTest.cpp \ +../../Classes/AppDelegate.cpp \ +../../Classes/BaseTest.cpp \ ../../Classes/BillBoardTest/BillBoardTest.cpp \ ../../Classes/Box2DTest/Box2dTest.cpp \ ../../Classes/Box2DTestBed/Box2dView.cpp \ @@ -27,20 +24,20 @@ LOCAL_SRC_FILES := main.cpp \ ../../Classes/BugsTest/Bug-1174.cpp \ ../../Classes/BugsTest/Bug-350.cpp \ ../../Classes/BugsTest/Bug-422.cpp \ +../../Classes/BugsTest/Bug-458/Bug-458.cpp \ +../../Classes/BugsTest/Bug-458/QuestionContainerSprite.cpp \ ../../Classes/BugsTest/Bug-624.cpp \ ../../Classes/BugsTest/Bug-886.cpp \ ../../Classes/BugsTest/Bug-899.cpp \ ../../Classes/BugsTest/Bug-914.cpp \ -../../Classes/BugsTest/BugsTest.cpp \ ../../Classes/BugsTest/Bug-Child.cpp \ -../../Classes/BugsTest/Bug-458/Bug-458.cpp \ -../../Classes/BugsTest/Bug-458/QuestionContainerSprite.cpp \ +../../Classes/BugsTest/BugsTest.cpp \ ../../Classes/Camera3DTest/Camera3DTest.cpp \ ../../Classes/ChipmunkTest/ChipmunkTest.cpp \ ../../Classes/ClickAndMoveTest/ClickAndMoveTest.cpp \ ../../Classes/ClippingNodeTest/ClippingNodeTest.cpp \ ../../Classes/CocosDenshionTest/CocosDenshionTest.cpp \ -../../Classes/NewAudioEngineTest/NewAudioEngineTest.cpp \ +../../Classes/CocosStudio3DTest/CocosStudio3DTest.cpp \ ../../Classes/ConfigurationTest/ConfigurationTest.cpp \ ../../Classes/ConsoleTest/ConsoleTest.cpp \ ../../Classes/CurlTest/CurlTest.cpp \ @@ -49,88 +46,34 @@ LOCAL_SRC_FILES := main.cpp \ ../../Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp \ ../../Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp \ ../../Classes/EffectsTest/EffectsTest.cpp \ -../../Classes/ExtensionsTest/ExtensionsTest.cpp \ ../../Classes/ExtensionsTest/AssetsManagerExTest/AssetsManagerExTest.cpp \ -../../Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp \ -../../Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp \ -../../Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp \ -../../Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp \ -../../Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp \ -../../Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp \ -../../Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp \ -../../Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp \ ../../Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp \ +../../Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp \ ../../Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp \ ../../Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp \ ../../Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp \ ../../Classes/ExtensionsTest/CocoStudioComponentsTest/PlayerController.cpp \ ../../Classes/ExtensionsTest/CocoStudioComponentsTest/ProjectileController.cpp \ ../../Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp \ -../../Classes/UITest/CocoStudioGUITest/CocoStudioGUITest.cpp \ -../../Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp \ -../../Classes/UITest/CocoStudioGUITest/CocostudioParserTest/CocostudioParserJsonTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/CocostudioParserTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/GUIEditorTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/CustomGUIScene.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIScene.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIEditBoxTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/UISceneManager.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIScene_Editor.cpp \ -../../Classes/UITest/CocoStudioGUITest/UISceneManager_Editor.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp \ -../../Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest_Editor.cpp \ -../../Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest_Editor.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest_Editor.cpp \ -../../Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest_Editor.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest_Editor.cpp \ -../../Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp \ -../../Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.cpp \ -../../Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.cpp \ -../../Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.cpp \ -../../Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIVideoPlayerTest/UIVideoPlayerTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/UIWebViewTest/UIWebViewTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp \ -../../Classes/UITest/CocoStudioGUITest/CustomWidget/CustomImageViewReader.cpp \ -../../Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp \ -../../Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidgetReader.cpp \ -../../Classes/UITest/CocoStudioGUITest/CustomWidget/CustomReader.cpp \ -../../Classes/UITest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.cpp \ -../../Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomRootNode.cpp \ -../../Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomRootNodeReader.cpp \ -../../Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomWidgetCallbackBindTest.cpp \ ../../Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp \ ../../Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.cpp \ ../../Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.cpp \ -../../Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp \ -../../Classes/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.cpp \ +../../Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp \ +../../Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp \ +../../Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp \ +../../Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp \ +../../Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp \ +../../Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp \ +../../Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp \ ../../Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp \ ../../Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp \ ../../Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp \ +../../Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp \ +../../Classes/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.cpp \ ../../Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp \ ../../Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp \ ../../Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp \ +../../Classes/ExtensionsTest/ExtensionsTest.cpp \ ../../Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp \ ../../Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp \ ../../Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp \ @@ -145,32 +88,35 @@ LOCAL_SRC_FILES := main.cpp \ ../../Classes/LabelTest/LabelTestNew.cpp \ ../../Classes/LayerTest/LayerTest.cpp \ ../../Classes/LightTest/LightTest.cpp \ +../../Classes/MaterialSystemTest/MaterialSystemTest.cpp \ ../../Classes/MenuTest/MenuTest.cpp \ ../../Classes/MotionStreakTest/MotionStreakTest.cpp \ ../../Classes/MutiTouchTest/MutiTouchTest.cpp \ +../../Classes/NewAudioEngineTest/NewAudioEngineTest.cpp \ ../../Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp \ ../../Classes/NewRendererTest/NewRendererTest.cpp \ ../../Classes/NodeTest/NodeTest.cpp \ +../../Classes/OpenURLTest/OpenURLTest.cpp \ ../../Classes/ParallaxTest/ParallaxTest.cpp \ -../../Classes/ParticleTest/ParticleTest.cpp \ ../../Classes/Particle3DTest/Particle3DTest.cpp \ -../../Classes/CocosStudio3DTest/CocosStudio3DTest.cpp \ +../../Classes/ParticleTest/ParticleTest.cpp \ ../../Classes/PerformanceTest/PerformanceAllocTest.cpp \ +../../Classes/PerformanceTest/PerformanceCallbackTest.cpp \ +../../Classes/PerformanceTest/PerformanceContainerTest.cpp \ +../../Classes/PerformanceTest/PerformanceEventDispatcherTest.cpp \ +../../Classes/PerformanceTest/PerformanceLabelTest.cpp \ +../../Classes/PerformanceTest/PerformanceMathTest.cpp \ ../../Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp \ -../../Classes/PerformanceTest/PerformanceParticleTest.cpp \ ../../Classes/PerformanceTest/PerformanceParticle3DTest.cpp \ +../../Classes/PerformanceTest/PerformanceParticleTest.cpp \ +../../Classes/PerformanceTest/PerformanceRendererTest.cpp \ +../../Classes/PerformanceTest/PerformanceScenarioTest.cpp \ ../../Classes/PerformanceTest/PerformanceSpriteTest.cpp \ ../../Classes/PerformanceTest/PerformanceTest.cpp \ ../../Classes/PerformanceTest/PerformanceTextureTest.cpp \ ../../Classes/PerformanceTest/PerformanceTouchesTest.cpp \ -../../Classes/PerformanceTest/PerformanceLabelTest.cpp \ -../../Classes/PerformanceTest/PerformanceRendererTest.cpp \ -../../Classes/PerformanceTest/PerformanceContainerTest.cpp \ -../../Classes/PerformanceTest/PerformanceEventDispatcherTest.cpp \ -../../Classes/PerformanceTest/PerformanceScenarioTest.cpp \ -../../Classes/PerformanceTest/PerformanceCallbackTest.cpp \ -../../Classes/PerformanceTest/PerformanceMathTest.cpp \ ../../Classes/PhysicsTest/PhysicsTest.cpp \ +../../Classes/Physics3DTest/Physics3DTest.cpp \ ../../Classes/ReleasePoolTest/ReleasePoolTest.cpp \ ../../Classes/RenderTextureTest/RenderTextureTest.cpp \ ../../Classes/RotateWorldTest/RotateWorldTest.cpp \ @@ -179,9 +125,11 @@ LOCAL_SRC_FILES := main.cpp \ ../../Classes/ShaderTest/ShaderTest.cpp \ ../../Classes/ShaderTest/ShaderTest2.cpp \ ../../Classes/SpineTest/SpineTest.cpp \ -../../Classes/SpriteTest/SpriteTest.cpp \ ../../Classes/Sprite3DTest/DrawNode3D.cpp \ ../../Classes/Sprite3DTest/Sprite3DTest.cpp \ +../../Classes/SpritePolygonTest/SpritePolygonTest.cpp \ +../../Classes/SpriteTest/SpriteTest.cpp \ +../../Classes/TerrainTest/TerrainTest.cpp \ ../../Classes/TextInputTest/TextInputTest.cpp \ ../../Classes/Texture2dTest/Texture2dTest.cpp \ ../../Classes/TextureCacheTest/TextureCacheTest.cpp \ @@ -192,14 +140,68 @@ LOCAL_SRC_FILES := main.cpp \ ../../Classes/TouchesTest/Paddle.cpp \ ../../Classes/TouchesTest/TouchesTest.cpp \ ../../Classes/TransitionsTest/TransitionsTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/CocoStudioGUITest.cpp \ +../../Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp \ +../../Classes/UITest/CocoStudioGUITest/CocostudioParserTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/CocostudioParserTest/CocostudioParserJsonTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/CustomGUIScene.cpp \ +../../Classes/UITest/CocoStudioGUITest/CustomTest/CustomImageTest/CustomImageTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomRootNode.cpp \ +../../Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomRootNodeReader.cpp \ +../../Classes/UITest/CocoStudioGUITest/CustomTest/CustomWidgetCallbackBindTest/CustomWidgetCallbackBindTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp \ +../../Classes/UITest/CocoStudioGUITest/CustomWidget/CustomImageViewReader.cpp \ +../../Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp \ +../../Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidgetReader.cpp \ +../../Classes/UITest/CocoStudioGUITest/CustomWidget/CustomReader.cpp \ +../../Classes/UITest/CocoStudioGUITest/GUIEditorTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp \ +../../Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIEditBoxTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest_Editor.cpp \ +../../Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest_Editor.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIListViewTest/UIListViewTest_Editor.cpp \ +../../Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest_Editor.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest_Editor.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIRichTextTest/UIRichTextTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIScene.cpp \ +../../Classes/UITest/CocoStudioGUITest/UISceneManager.cpp \ +../../Classes/UITest/CocoStudioGUITest/UISceneManager_Editor.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIScene_Editor.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest_Editor.cpp \ +../../Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp \ +../../Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest_Editor.cpp \ +../../Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.cpp \ +../../Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp \ +../../Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest_Editor.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIVideoPlayerTest/UIVideoPlayerTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIWebViewTest/UIWebViewTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest.cpp \ +../../Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp \ +../../Classes/UITest/UITest.cpp \ ../../Classes/UnitTest/RefPtrTest.cpp \ ../../Classes/UnitTest/UnitTest.cpp \ -../../Classes/UITest/UITest.cpp \ ../../Classes/UserDefaultTest/UserDefaultTest.cpp \ -../../Classes/OpenURLTest/OpenURLTest.cpp \ +../../Classes/VisibleRect.cpp \ ../../Classes/ZwoptexTest/ZwoptexTest.cpp \ -../../Classes/TerrainTest/TerrainTest.cpp \ -../../Classes/SpritePolygonTest/SpritePolygonTest.cpp +../../Classes/controller.cpp \ +../../Classes/testBasic.cpp LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \ $(LOCAL_PATH)/../../../.. diff --git a/tests/cpp-tests/proj.android/jni/Application.mk b/tests/cpp-tests/proj.android/jni/Application.mk index f80e3bad04..85aaa1e860 100644 --- a/tests/cpp-tests/proj.android/jni/Application.mk +++ b/tests/cpp-tests/proj.android/jni/Application.mk @@ -1,6 +1,6 @@ APP_STL := gnustl_static -APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char +APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCC_ENABLE_BULLET_INTEGRATION=1 -std=c++11 -fsigned-char APP_LDFLAGS := -latomic ifeq ($(NDK_DEBUG),1) diff --git a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj index 6aca5d4516..85e35502e5 100644 --- a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj +++ b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj @@ -20,18 +20,12 @@ Application Unicode true - v100 - v110 - v110_xp v120 v120_xp Application Unicode - v100 - v110 - v110_xp v120 v120_xp @@ -50,7 +44,7 @@ - <_ProjectFileVersion>10.0.40219.1 + <_ProjectFileVersion>12.0.21005.1 $(SolutionDir)$(Configuration).win32\cpp-tests\ $(Configuration).win32\ true @@ -74,7 +68,7 @@ Disabled ..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\network;$(EngineRoot)external;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\curl\include\win32;$(EngineRoot)external\websockets\win32\include;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;COCOS2DXWIN32_EXPORTS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;COCOS2DXWIN32_EXPORTS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL @@ -113,7 +107,7 @@ xcopy "$(OutDir)..\*.dll" "$(OutDir)" /D /Y MaxSpeed true ..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\network;$(EngineRoot)external;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\curl\include\win32;$(EngineRoot)external\websockets\win32\include;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL true Level3 @@ -185,6 +179,7 @@ xcopy "$(OutDir)..\*.dll" "$(OutDir)" /D /Y + @@ -198,6 +193,7 @@ xcopy "$(OutDir)..\*.dll" "$(OutDir)" /D /Y + @@ -387,6 +383,7 @@ xcopy "$(OutDir)..\*.dll" "$(OutDir)" /D /Y + @@ -400,6 +397,7 @@ xcopy "$(OutDir)..\*.dll" "$(OutDir)" /D /Y + diff --git a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters index dba5f683ff..a16708a0d2 100644 --- a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters +++ b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters @@ -352,12 +352,18 @@ {eed1887a-757e-4625-b21c-bbfcfaa5200f} + + {31d7c504-94c7-43ab-818d-996f957a3741} + {3f5069e6-78e5-4388-b614-04c0ea943b4c} {b35cfbde-9e13-4981-8458-f7596f089bde} + + {4fd79779-ff32-4400-aa05-af4fd7f0f4a0} + @@ -933,9 +939,15 @@ Classes\PerformanceTest + + Classes\Physics3DTest + Classes\SpritePolygonTest + + Classes\MaterialSystemTest + @@ -1709,8 +1721,14 @@ Classes\PerformanceTest + + Classes\Physics3DTest + Classes\SpritePolygonTest + + Classes\MaterialSystemTest + \ No newline at end of file diff --git a/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Shared/cpp-tests.Shared.vcxitems b/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Shared/cpp-tests.Shared.vcxitems index d9dff30ddb..14006413a7 100644 --- a/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Shared/cpp-tests.Shared.vcxitems +++ b/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Shared/cpp-tests.Shared.vcxitems @@ -106,6 +106,7 @@ + @@ -132,6 +133,7 @@ + @@ -369,6 +371,7 @@ + @@ -395,6 +398,7 @@ + diff --git a/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Shared/cpp-tests.Shared.vcxitems.filters b/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Shared/cpp-tests.Shared.vcxitems.filters index f830e58e62..ffb4e449e8 100644 --- a/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Shared/cpp-tests.Shared.vcxitems.filters +++ b/tests/cpp-tests/proj.win8.1-universal/cpp-tests.Shared/cpp-tests.Shared.vcxitems.filters @@ -781,6 +781,12 @@ Classes\SpritePolygonTest + + Classes\MaterialSystemTest + + + Classes\Physics3DTest + @@ -1689,6 +1695,12 @@ {ee1c5d87-3c80-4a10-892e-985fcd93a6c1} + + {9113774a-5e49-433b-b851-11533bc178ec} + + + {dbeed6f6-158b-4f99-8196-61616f724ae1} + @@ -1725,5 +1737,11 @@ Classes\SpritePolygonTest + + Classes\MaterialSystemTest + + + Classes\Physics3DTest + \ No newline at end of file diff --git a/tests/js-tests/.cocos-project.json b/tests/js-tests/.cocos-project.json new file mode 100644 index 0000000000..bd34889d3f --- /dev/null +++ b/tests/js-tests/.cocos-project.json @@ -0,0 +1,46 @@ +{ + "project_type": "js", + "has_native": true, + "win32_cfg": { + "project_path": "../../build", + "sln_file": "cocos2d-js-win32.vc2013.sln", + "project_name": "js-tests", + "build_cfg_path": "project/proj.win32" + }, + "ios_cfg": { + "project_path": "../../build", + "project_file": "cocos2d_js_tests.xcodeproj", + "target_name": "js-tests iOS" + }, + "mac_cfg": { + "project_path": "../../build", + "project_file": "cocos2d_js_tests.xcodeproj", + "target_name": "js-tests Mac" + }, + "android_cfg": { + "project_path": "project/proj.android" + }, + "web_cfg": { + "project_path": "", + "run_root_dir": "../../", + "sub_url": "/tests/js-tests/" + }, + "linux_cfg": { + "project_path": "project/proj.linux", + "project_name": "js-tests", + "cmake_path": "../../", + "build_dir": "../../build/linux-build", + "build_result_dir": "js-tests" + }, + "wp8_1_cfg" : { + "project_path": "../../build", + "sln_file": "cocos2d-js-win8.1-universal.sln", + "project_name": "js-tests.WindowsPhone" + }, + "metro_cfg" : { + "project_path": "../../build", + "sln_file": "cocos2d-js-win8.1-universal.sln", + "project_name": "js-tests.Windows" + }, + "engine_dir": "../../" +} diff --git a/tests/js-tests/TestCase.html b/tests/js-tests/TestCase.html new file mode 100644 index 0000000000..0614fecf74 --- /dev/null +++ b/tests/js-tests/TestCase.html @@ -0,0 +1,71 @@ + + + + + Cocos2d Testcase + + + + + + + + +
+ + +
+ +
+ +
+ +
+
+
+
+ + + + + + + diff --git a/tests/js-tests/index.html b/tests/js-tests/index.html new file mode 100644 index 0000000000..06941312d9 --- /dev/null +++ b/tests/js-tests/index.html @@ -0,0 +1,21 @@ + + + + + Cocos2d-HTML5 Test Cases + + + + +
+
+ + + +
+ + + + diff --git a/tests/js-tests/main.js b/tests/js-tests/main.js new file mode 100644 index 0000000000..56c5b83d1a --- /dev/null +++ b/tests/js-tests/main.js @@ -0,0 +1,132 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011 Zynga 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 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. + ****************************************************************************/ + +/** + * A brief explanation for "project.json": + * Here is the content of project.json file, this is the global configuration for your game, you can modify it to customize some behavior. + * The detail of each field is under it. + { + "debugMode" : 1, + // "debugMode" possible values : + // 0 - No message will be printed. + // 1 - cc.error, cc.assert, cc.warn, cc.log will print in console. + // 2 - cc.error, cc.assert, cc.warn will print in console. + // 3 - cc.error, cc.assert will print in console. + // 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web. + // 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web. + // 6 - cc.error, cc.assert will print on canvas, available only on web. + + "showFPS" : true, + // Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide. + + "frameRate" : 60, + // "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment. + + "id" : "gameCanvas", + // "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web. + + "renderMode" : 0, + // "renderMode" sets the renderer type, only useful on web : + // 0 - Automatically chosen by engine + // 1 - Forced to use canvas renderer + // 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers + + "engineDir" : "../../frameworks/cocos2d-html5/", + // In debug mode, if you use the whole engine to develop your game, you should specify its relative path with "engineDir", + // but if you are using a single engine file, you can ignore it. + + "modules" : ["cocos2d", "extensions", "external"], + // "modules" defines which modules you will need in your game, it's useful only on web, + // using this can greatly reduce your game's resource size, and the cocos console tool can package your game with only the modules you set. + // For details about modules definitions, you can refer to "../../frameworks/cocos2d-html5/modulesConfig.json". + + "plugin": { + "facebook": { + "appId" : "1426774790893461", + "xfbml" : true, + "version" : "v2.0" + } + }, + // "plugin" is used by plugin-x for its settings, if you don't use it, you can ignore it. + + "jsList" : [ + ] + // "jsList" sets the list of js files in your game. + } + * + */ + +if(cc.sys){ + var scene3SearchPaths = cc.sys.localStorage.getItem("Scene3SearchPaths"); + if (scene3SearchPaths) + jsb.fileUtils.setSearchPaths(JSON.parse(scene3SearchPaths)); +} + +cc.game.onStart = function(){ + cc.view.enableRetina(false); + if (cc.sys.isNative) { + var resolutionPolicy = (cc.sys.os == cc.sys.OS_WP8 || cc.sys.os == cc.sys.OS_WINRT) ? cc.ResolutionPolicy.SHOW_ALL : cc.ResolutionPolicy.FIXED_HEIGHT; + cc.view.setDesignResolutionSize(800, 450, resolutionPolicy); + cc.view.resizeWithBrowserSize(true); + var searchPaths = jsb.fileUtils.getSearchPaths(); + searchPaths.push('script'); + searchPaths.push('src'); + var paths = [ + 'res', + 'res/scenetest', + 'res/scenetest/ArmatureComponentTest', + 'res/scenetest/AttributeComponentTest', + 'res/scenetest/BackgroundComponentTest', + 'res/scenetest/EffectComponentTest', + 'res/scenetest/LoadSceneEdtiorFileTest', + 'res/scenetest/ParticleComponentTest', + 'res/scenetest/SpriteComponentTest', + 'res/scenetest/TmxMapComponentTest', + 'res/scenetest/UIComponentTest', + 'res/scenetest/TriggerTest' + ]; + for (var i = 0; i < paths.length; i++) { + searchPaths.push(paths[i]); + } + jsb.fileUtils.setSearchPaths(searchPaths); + } + else + { + cc.loader.resPath = '../cpp-tests/Resources' + } + + cc.LoaderScene.preload(g_resources, function () { + if(window.sideIndexBar && typeof sideIndexBar.start === 'function'){ + sideIndexBar.start(); + }else{ + var scene = new cc.Scene(); + scene.addChild(new TestController()); + cc.director.runScene(scene); + } + }, this); +}; +cc.game.run(); diff --git a/tests/js-tests/mobilePage.html b/tests/js-tests/mobilePage.html new file mode 100644 index 0000000000..da50765119 --- /dev/null +++ b/tests/js-tests/mobilePage.html @@ -0,0 +1,25 @@ + + + + + Cocos2d-HTML5 Test Cases + + + + + + + + + + diff --git a/tests/js-tests/project.json b/tests/js-tests/project.json new file mode 100644 index 0000000000..3659dcb298 --- /dev/null +++ b/tests/js-tests/project.json @@ -0,0 +1,186 @@ +{ + "debugMode" : 1, + "showFPS" : true, + "frameRate" : 60, + "id" : "gameCanvas", + "renderMode" : 0, + "engineDir" : "../../web/", + + "modules" : ["cocos2d", "extensions", "external"], + + "plugin": { + "facebook": { + "appId" : "1426774790893461", + "xfbml" : true, + "version" : "v2.0" + } + }, + + "jsList" : [ + "src/BaseTestLayer/BaseTestLayer.js", + + "src/tests_resources.js", + "src/tests-main.js", + + "src/PathTest/PathTest.js", + "src/LoaderTest/LoaderTest.js", + + "src/BakeLayerTest/BakeLayerTest.js", + + "src/TouchesTest/Ball.js", + "src/TouchesTest/Paddle.js", + "src/TouchesTest/TouchesTest.js", + "src/SchedulerTest/SchedulerTest.js", + "src/ClickAndMoveTest/ClickAndMoveTest.js", + "src/MenuTest/MenuTest.js", + "src/ActionsTest/ActionsTest.js", + "src/TileMapTest/TileMapTest.js", + "src/TransitionsTest/TransitionsTest.js", + "src/DrawPrimitivesTest/DrawPrimitivesTest.js", + "src/ParticleTest/ParticleTest.js", + "src/ProgressActionsTest/ProgressActionsTest.js", + "src/LayerTest/LayerTest.js", + "src/SceneTest/SceneTest.js", + "src/SpineTest/SpineTest.js", + "src/SpriteTest/SpriteTest.js", + "src/Sprite3DTest/Sprite3DTest.js", + "src/LightTest/LightTest.js", + "src/BillBoardTest/BillBoardTest.js", + "src/Camera3DTest/Camera3DTest.js", + "src/TextureCacheTest/TextureCacheTest.js", + "src/CocosDenshionTest/CocosDenshionTest.js", + "src/CocosNodeTest/CocosNodeTest.js", + "src/RotateWorldTest/RotateWorldTest.js", + "src/RenderTextureTest/RenderTextureTest.js", + "src/IntervalTest/IntervalTest.js", + "src/ActionManagerTest/ActionManagerTest.js", + "src/EaseActionsTest/EaseActionsTest.js", + "src/ParallaxTest/ParallaxTest.js", + "src/PerformanceTest/PerformanceTest.js", + "src/PerformanceTest/PerformanceSpriteTest.js", + "src/PerformanceTest/PerformanceSpriteTest2.js", + "src/PerformanceTest/PerformanceParticleTest.js", + "src/PerformanceTest/PerformanceNodeChildrenTest.js", + "src/PerformanceTest/PerformanceTextureTest.js", + "src/PerformanceTest/PerformanceAnimationTest.js", + "src/PerformanceTest/PerformanceVirtualMachineTest.js", + "src/PerformanceTest/seedrandom.js", + "src/FontTest/FontTest.js", + "src/PerformanceTest/PerformanceTouchesTest.js", + "src/LabelTest/LabelTest.js", + "src/CurrentLanguageTest/CurrentLanguageTest.js", + "src/TextInputTest/TextInputTest.js", + "src/NewEventManagerTest/NewEventManagerTest.js", + "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", + "src/ClippingNodeTest/ClippingNodeTest.js", + "src/OpenGLTest/OpenGLTest.js", + + "src/FacebookTest/FacebookTest.js", + "src/FacebookTest/FacebookShareTest.js", + "src/FacebookTest/FacebookUserTest.js", + "src/FacebookTest/FacebookTestsManager.js", + + "src/ExtensionsTest/ExtensionsTest.js", + "src/ExtensionsTest/AssetsManagerTest/AssetsManagerTest.js", + "src/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.js", + "src/ExtensionsTest/ControlExtensionTest/CCControlScene.js", + "src/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.js", + "src/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.js", + "src/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.js", + "src/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.js", + "src/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.js", + "src/ExtensionsTest/ControlExtensionTest/CCControlColourPickerTest/CCControlColourPickerTest.js", + "src/ExtensionsTest/TableViewTest/TableViewTestScene.js", + "src/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.js", + "src/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.js", + "src/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.js", + "src/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.js", + "src/ExtensionsTest/CocosBuilderTest/SpriteTest/SpriteTestLayer.js", + "src/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.js", + "src/ExtensionsTest/CocosBuilderTest/LabelTest/LabelTestLayer.js", + "src/ExtensionsTest/CocosBuilderTest/ParticleSystemTest/ParticleSystemTestLayer.js", + "src/ExtensionsTest/CocosBuilderTest/ScrollViewTest/ScrollViewTestLayer.js", + "src/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.js", + "src/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.js", + "src/ExtensionsTest/CCPoolTest/CCPoolTest.js", + "src/ExtensionsTest/EditBoxTest/EditBoxTest.js", + "src/ExtensionsTest/S9SpriteTest/S9SpriteTest.js", + "src/ExtensionsTest/NetworkTest/WebSocketTest.js", + "src/ExtensionsTest/NetworkTest/SocketIOTest.js", + "src/ExtensionsTest/PluginXTest/PluginXTest.js", + "src/ExtensionsTest/PluginXTest/PluginXTestsManager.js", + "src/ExtensionsTest/PluginXTest/IOSIAPTest.js", + "src/ExtensionsTest/PluginXTest/AnalyticsTest.js", + "src/CocoStudioTest/ArmatureTest/ArmatureTest.js", + "src/CocoStudioTest/ComponentsTest/ComponentsTestScene.js", + "src/CocoStudioTest/ComponentsTest/EnemyController.js", + "src/CocoStudioTest/ComponentsTest/GameOverScene.js", + "src/CocoStudioTest/ComponentsTest/PlayerController.js", + "src/CocoStudioTest/ComponentsTest/ProjectileController.js", + "src/CocoStudioTest/ComponentsTest/SceneController.js", + "src/CocoStudioTest/GUITest/UISceneTest.js", + "src/CocoStudioTest/GUITest/UIBaseLayer.js", + "src/CocoStudioTest/GUITest/UIButtonTest/UIButtonTest.js", + "src/CocoStudioTest/GUITest/UICheckBoxTest/UICheckBoxTest.js", + "src/CocoStudioTest/GUITest/UIImageViewTest/UIImageViewTest.js", + "src/CocoStudioTest/GUITest/UITextTest/UITextTest.js", + "src/CocoStudioTest/GUITest/UITextAtlasTest/UITextAtlasTest.js", + "src/CocoStudioTest/GUITest/UITextBMFontTest/UITextBMFontTest.js", + "src/CocoStudioTest/GUITest/UILoadingBarTest/UILoadingBarTest.js", + "src/CocoStudioTest/GUITest/UISliderTest/UISliderTest.js", + "src/CocoStudioTest/GUITest/UITextFieldTest/UITextFieldTest.js", + "src/CocoStudioTest/GUITest/UINodeContainerTest/UINodeContainerTest.js", + "src/CocoStudioTest/GUITest/UILayoutTest/UILayoutTest.js", + "src/CocoStudioTest/GUITest/UIListViewTest/UIListViewTest.js", + "src/CocoStudioTest/GUITest/UIPageViewTest/UIPageViewTest.js", + "src/CocoStudioTest/GUITest/UIScrollViewTest/UIScrollViewTest.js", + "src/CocoStudioTest/ParserTest/ParserTest.js", + "src/CocoStudioTest/CustomTest/CustomImageView/CustomImageView.js", + "src/CocoStudioTest/CustomTest/CustomImageView/CustomImageViewReader.js", + "src/CocoStudioTest/CustomTest/CustomImageView/CustomParticleWidget.js", + "src/CocoStudioTest/CustomTest/CustomImageView/CustomParticWidgetReader.js", + "src/CocoStudioTest/CustomTest/CustomImageView/CustomReader.js", + "src/CocoStudioTest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.js", + "src/CocoStudioTest/CustomTest/CustomImageScene/CustomImageScene.js", + "src/CocoStudioTest/CustomTest/CustomGUIScene.js", + "src/GUITest/UIScene.js", + "src/GUITest/UIButtonTest/UIButtonTest.js", + "src/GUITest/UICheckBoxTest/UICheckBoxTest.js", + "src/GUITest/UIFocusTest/UIFocusTest.js", + "src/GUITest/UIImageViewTest/UIImageViewTest.js", + "src/GUITest/UILabelAtlasTest/UILabelAtlasTest.js", + "src/GUITest/UILabelBMFontTest/UILabelBMFontTest.js", + "src/GUITest/UILabelTest/UILabelTest.js", + "src/GUITest/UILayoutTest/UILayoutTest.js", + "src/GUITest/UIListViewTest/UIListViewTest.js", + "src/GUITest/UILoadingBarTest/UILoadingBarTest.js", + "src/GUITest/UINodeContainerTest/UINodeContainerTest.js", + "src/GUITest/UIPageViewTest/UIPageViewTest.js", + "src/GUITest/UISceneManager.js", + "src/GUITest/UIScrollViewTest/UIScrollViewTest.js", + "src/GUITest/UISliderTest/UISliderTest.js", + "src/GUITest/UITextFieldTest/UITextFieldTest.js", + "src/GUITest/UIRichTextTest/UIRichTextTest.js", + "src/GUITest/UITextTest/UITextTest.js", + + "src/CocoStudioTest/SceneTest/TriggerCode/Acts.js", + "src/CocoStudioTest/SceneTest/TriggerCode/Cons.js", + "src/CocoStudioTest/SceneTest/TriggerCode/EventDef.js", + "src/CocoStudioTest/SceneTest/SceneEditorTest.js", + "src/CocoStudioTest/CocoStudioTest.js", + "src/XHRTest/XHRTest.js", + "src/XHRTest/XHRArrayBufferTest.js", + + "src/Box2dTest/Box2dTest.js", + "src/ChipmunkTest/ChipmunkTest.js", + + "src/Presentation/Presentation.js", + "src/ReflectionTest/ReflectionTest.js" + ] +} diff --git a/tests/js-tests/project/CMakeLists.txt b/tests/js-tests/project/CMakeLists.txt new file mode 100644 index 0000000000..0aa7cfacfc --- /dev/null +++ b/tests/js-tests/project/CMakeLists.txt @@ -0,0 +1,79 @@ +#/**************************************************************************** +# Copyright (c) 2015 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 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. +# ****************************************************************************/ + +set(APP_NAME js-tests) + +if(WIN32) + +else() + set(PLATFORM_SRC + proj.linux/main.cpp + ) +endif() + +set(SAMPLE_SRC + Classes/AppDelegate.cpp + Classes/js_DrawNode3D_bindings.cpp + Classes/js_Effect3D_bindings.cpp + ${PLATFORM_SRC} +) + +include_directories( + Classes + ../../../cocos/scripting/js-bindings/auto + ../../../cocos/scripting/js-bindings/manual + ../../../cocos/base + ../../../cocos/editor-support + ../../../cocos/audio/include + ../../../external/spidermonkey/include/${PLATFORM_FOLDER} + ../../../external/chipmunk/include/chipmunk +) + +# add the executable +add_executable(${APP_NAME} + ${SAMPLE_SRC} +) + +target_link_libraries(${APP_NAME} + jscocos2d + cocos2d +) + +set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin/${APP_NAME}") + +set_target_properties(${APP_NAME} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}") + +pre_build(${APP_NAME} + COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/script + COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/res + COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/src + COMMAND ${CMAKE_COMMAND} -E remove ${APP_BIN_DIR}/*.js + COMMAND ${CMAKE_COMMAND} -E remove ${APP_BIN_DIR}/*.json + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../../cpp-tests/Resources ${APP_BIN_DIR}/res + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../src ${APP_BIN_DIR}/src + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../../../cocos/scripting/js-bindings/script ${APP_BIN_DIR}/script + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../main.js ${APP_BIN_DIR}/main.js + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../project.json ${APP_BIN_DIR}/project.json + ) diff --git a/tests/js-tests/project/Classes/AppDelegate.cpp b/tests/js-tests/project/Classes/AppDelegate.cpp new file mode 100644 index 0000000000..053a51c7ee --- /dev/null +++ b/tests/js-tests/project/Classes/AppDelegate.cpp @@ -0,0 +1,151 @@ +#include "AppDelegate.h" + +#include "cocos2d.h" +#include "SimpleAudioEngine.h" +#include "ScriptingCore.h" +#include "jsb_cocos2dx_auto.hpp" +#include "jsb_cocos2dx_extension_auto.hpp" +#include "jsb_cocos2dx_builder_auto.hpp" +#include "jsb_cocos2dx_spine_auto.hpp" +#include "jsb_cocos2dx_3d_auto.hpp" +#include "jsb_cocos2dx_3d_extension_auto.hpp" +#include "3d/jsb_cocos2dx_3d_manual.h" +#include "extension/jsb_cocos2dx_extension_manual.h" +#include "cocostudio/jsb_cocos2dx_studio_manual.h" +#include "jsb_cocos2dx_studio_auto.hpp" +#include "jsb_cocos2dx_ui_auto.hpp" +#include "ui/jsb_cocos2dx_ui_manual.h" +#include "spine/jsb_cocos2dx_spine_manual.h" +#include "cocos2d_specifics.hpp" +#include "cocosbuilder/cocosbuilder_specifics.hpp" +#include "chipmunk/js_bindings_chipmunk_registration.h" +#include "localstorage/js_bindings_system_registration.h" +#include "jsb_opengl_registration.h" +#include "network/XMLHTTPRequest.h" +#include "network/jsb_websocket.h" +#include "network/jsb_socketio.h" +#include "cocosbuilder/js_bindings_ccbreader.h" +#include "js_DrawNode3D_bindings.h" + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +#include "platform/android/CCJavascriptJavaBridge.h" +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) +#include "platform/ios/JavaScriptObjCBridge.h" +#endif + +#if(CC_TARGET_PLATFORM != CC_PLATFORM_WP8) +#include "js_Effect3D_bindings.h" +#endif + +USING_NS_CC; +USING_NS_CC_EXT; +using namespace CocosDenshion; + +AppDelegate::AppDelegate() +{ +} + +AppDelegate::~AppDelegate() +{ + ScriptEngineManager::destroyInstance(); +} + +void AppDelegate::initGLContextAttrs() +{ + GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8}; + + GLView::setGLContextAttrs(glContextAttrs); +} + +bool AppDelegate::applicationDidFinishLaunching() +{ + // initialize director + auto director = Director::getInstance(); + auto glview = director->getOpenGLView(); + if(!glview) { +#if(CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) + glview = cocos2d::GLViewImpl::create("js-tests"); +#else + glview = cocos2d::GLViewImpl::createWithRect("js-tests", Rect(0,0,900,640)); +#endif + 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(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(MinXmlHttpRequest::_js_register); + sc->addRegisterCallback(register_jsb_websocket); + sc->addRegisterCallback(register_jsb_socketio); + + 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); + + sc->addRegisterCallback(register_all_cocos2dx_spine); + sc->addRegisterCallback(register_all_cocos2dx_spine_manual); + + sc->addRegisterCallback(register_all_cocos2dx_3d); + sc->addRegisterCallback(register_all_cocos2dx_3d_manual); + + sc->addRegisterCallback(register_all_cocos2dx_3d_extension); + +#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->addRegisterCallback(register_DrawNode3D_bindings); +#if(CC_TARGET_PLATFORM != CC_PLATFORM_WP8) + sc->addRegisterCallback(register_Effect3D_bindings); +#endif + + 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); + + ScriptingCore::getInstance()->runScript("main.js"); + + return true; +} + +// This function will be called when the app is inactive. When comes a phone call,it's be invoked too +void AppDelegate::applicationDidEnterBackground() +{ + auto director = Director::getInstance(); + director->stopAnimation(); + director->getEventDispatcher()->dispatchCustomEvent("game_on_hide"); + SimpleAudioEngine::getInstance()->pauseBackgroundMusic(); + SimpleAudioEngine::getInstance()->pauseAllEffects(); +} + +// this function will be called when the app is active again +void AppDelegate::applicationWillEnterForeground() +{ + auto director = Director::getInstance(); + director->startAnimation(); + director->getEventDispatcher()->dispatchCustomEvent("game_on_show"); + SimpleAudioEngine::getInstance()->resumeBackgroundMusic(); + SimpleAudioEngine::getInstance()->resumeAllEffects(); +} diff --git a/tests/js-tests/project/Classes/AppDelegate.h b/tests/js-tests/project/Classes/AppDelegate.h new file mode 100644 index 0000000000..ee146a75d9 --- /dev/null +++ b/tests/js-tests/project/Classes/AppDelegate.h @@ -0,0 +1,39 @@ +#ifndef _APP_DELEGATE_H_ +#define _APP_DELEGATE_H_ + +#include "platform/CCApplication.h" +/** + @brief The cocos2d Application. + + The reason for implement as private inheritance is to hide some interface call by Director. + */ +class AppDelegate : private cocos2d::Application +{ +public: + AppDelegate(); + virtual ~AppDelegate(); + + void initGLContextAttrs() override; + + /** + @brief Implement Director and Scene init code here. + @return true Initialize success, app continue. + @return false Initialize failed, app terminate. + */ + virtual bool applicationDidFinishLaunching(); + + /** + @brief The function be called when the application enter background + @param the pointer of the application + */ + virtual void applicationDidEnterBackground(); + + /** + @brief The function be called when the application enter foreground + @param the pointer of the application + */ + virtual void applicationWillEnterForeground(); +}; + +#endif // _APP_DELEGATE_H_ + diff --git a/tests/js-tests/project/Classes/js_DrawNode3D_bindings.cpp b/tests/js-tests/project/Classes/js_DrawNode3D_bindings.cpp new file mode 100644 index 0000000000..b8cd8a42e4 --- /dev/null +++ b/tests/js-tests/project/Classes/js_DrawNode3D_bindings.cpp @@ -0,0 +1,593 @@ +/**************************************************************************** + Copyright (c) 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 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 "cocos2d.h" +#include "cocos2d_specifics.hpp" +#include "js_DrawNode3D_bindings.h" + +NS_CC_BEGIN + +/** + * Copy DrawNode for 3D geometry drawing. + */ +class DrawNode3D: public Node +{ +public: + /** creates and initialize a DrawNode3D node */ + static DrawNode3D* create(); + + /** + * Draw 3D Line + */ + void drawLine(const Vec3 &from, const Vec3 &to, const Color4F &color); + + /** + * Draw 3D cube + * @param point to a vertex array who has 8 element. + * vertices[0]:Left-top-front, + * vertices[1]:Left-bottom-front, + * vertices[2]:Right-bottom-front, + * vertices[3]:Right-top-front, + * vertices[4]:Right-top-back, + * vertices[5]:Right-bottom-back, + * vertices[6]:Left-bottom-back, + * vertices[7]:Left-top-back. + * @param color + */ + void drawCube(Vec3* vertices, const Color4F &color); + + /** Clear the geometry in the node's buffer. */ + void clear(); + + /** + * @js NA + * @lua NA + */ + const BlendFunc& getBlendFunc() const; + + /** + * @code + * When this function bound into js or lua,the parameter will be changed + * In js: var setBlendFunc(var src, var dst) + * @endcode + * @lua NA + */ + void setBlendFunc(const BlendFunc &blendFunc); + + void onDraw(const Mat4 &transform, uint32_t flags); + + // Overrides + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; + +CC_CONSTRUCTOR_ACCESS: + DrawNode3D(); + virtual ~DrawNode3D(); + virtual bool init(); + +protected: + struct V3F_C4B + { + Vec3 vertices; + Color4B colors; + }; + void ensureCapacity(int count); + + GLuint _vao; + GLuint _vbo; + + int _bufferCapacity; + GLsizei _bufferCount; + V3F_C4B* _buffer; + + BlendFunc _blendFunc; + CustomCommand _customCommand; + + bool _dirty; + +private: + CC_DISALLOW_COPY_AND_ASSIGN(DrawNode3D); +}; + + +DrawNode3D::DrawNode3D() +: _vao(0) +, _vbo(0) +, _bufferCapacity(0) +, _bufferCount(0) +, _buffer(nullptr) +, _dirty(false) +{ + _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; +} + +DrawNode3D::~DrawNode3D() +{ + free(_buffer); + _buffer = nullptr; + + glDeleteBuffers(1, &_vbo); + _vbo = 0; + + if (Configuration::getInstance()->supportsShareableVAO()) + { + glDeleteVertexArrays(1, &_vao); + GL::bindVAO(0); + _vao = 0; + } +} + +DrawNode3D* DrawNode3D::create() +{ + DrawNode3D* ret = new (std::nothrow) DrawNode3D(); + if (ret && ret->init()) + { + ret->autorelease(); + } + else + { + CC_SAFE_DELETE(ret); + } + + return ret; +} + +void DrawNode3D::ensureCapacity(int count) +{ + CCASSERT(count>=0, "capacity must be >= 0"); + + if(_bufferCount + count > _bufferCapacity) + { + _bufferCapacity += MAX(_bufferCapacity, count); + _buffer = (V3F_C4B*)realloc(_buffer, _bufferCapacity*sizeof(V3F_C4B)); + } +} + +bool DrawNode3D::init() +{ + _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; + + setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_COLOR)); + + ensureCapacity(512); + + if (Configuration::getInstance()->supportsShareableVAO()) + { + glGenVertexArrays(1, &_vao); + GL::bindVAO(_vao); + } + + glGenBuffers(1, &_vbo); + glBindBuffer(GL_ARRAY_BUFFER, _vbo); + glBufferData(GL_ARRAY_BUFFER, sizeof(V3F_C4B)* _bufferCapacity, _buffer, GL_STREAM_DRAW); + + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B), (GLvoid *)offsetof(V3F_C4B, vertices)); + + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V3F_C4B), (GLvoid *)offsetof(V3F_C4B, colors)); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + + if (Configuration::getInstance()->supportsShareableVAO()) + { + GL::bindVAO(0); + } + + CHECK_GL_ERROR_DEBUG(); + + _dirty = true; + +#if CC_ENABLE_CACHE_TEXTURE_DATA + // Need to listen the event only when not use batchnode, because it will use VBO + auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){ + /** listen the event that coming to foreground on Android */ + this->init(); + }); + + _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); +#endif + + return true; +} + +void DrawNode3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) +{ + _customCommand.init(_globalZOrder, transform, flags); + _customCommand.func = CC_CALLBACK_0(DrawNode3D::onDraw, this, transform, flags); + renderer->addCommand(&_customCommand); +} + +void DrawNode3D::onDraw(const Mat4 &transform, uint32_t flags) +{ + auto glProgram = getGLProgram(); + glProgram->use(); + glProgram->setUniformsForBuiltins(transform); + glEnable(GL_DEPTH_TEST); + GL::blendFunc(_blendFunc.src, _blendFunc.dst); + + if (_dirty) + { + glBindBuffer(GL_ARRAY_BUFFER, _vbo); + glBufferData(GL_ARRAY_BUFFER, sizeof(V3F_C4B)*_bufferCapacity, _buffer, GL_STREAM_DRAW); + _dirty = false; + } + if (Configuration::getInstance()->supportsShareableVAO()) + { + GL::bindVAO(_vao); + } + else + { + GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + + glBindBuffer(GL_ARRAY_BUFFER, _vbo); + // vertex + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B), (GLvoid *)offsetof(V3F_C4B, vertices)); + + // color + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V3F_C4B), (GLvoid *)offsetof(V3F_C4B, colors)); + } + + glDrawArrays(GL_LINES, 0, _bufferCount); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,_bufferCount); + glDisable(GL_DEPTH_TEST); + CHECK_GL_ERROR_DEBUG(); +} + +void DrawNode3D::drawLine(const Vec3 &from, const Vec3 &to, const Color4F &color) +{ + unsigned int vertex_count = 2; + ensureCapacity(vertex_count); + + Color4B col = Color4B(color); + V3F_C4B a = {Vec3(from.x, from.y, from.z), col}; + V3F_C4B b = {Vec3(to.x, to.y, to.z), col, }; + + V3F_C4B *lines = (V3F_C4B *)(_buffer + _bufferCount); + lines[0] = a; + lines[1] = b; + + _bufferCount += vertex_count; + _dirty = true; + +} + +void DrawNode3D::drawCube(Vec3* vertices, const Color4F &color) +{ + // front face + drawLine(vertices[0], vertices[1], color); + drawLine(vertices[1], vertices[2], color); + drawLine(vertices[2], vertices[3], color); + drawLine(vertices[3], vertices[0], color); + + // back face + drawLine(vertices[4], vertices[5], color); + drawLine(vertices[5], vertices[6], color); + drawLine(vertices[6], vertices[7], color); + drawLine(vertices[7], vertices[4], color); + + // edge + drawLine(vertices[0], vertices[7], color); + drawLine(vertices[1], vertices[6], color); + drawLine(vertices[2], vertices[5], color); + drawLine(vertices[3], vertices[4], color); +} + +void DrawNode3D::clear() +{ + _bufferCount = 0; + _dirty = true; +} + +const BlendFunc& DrawNode3D::getBlendFunc() const +{ + return _blendFunc; +} + +void DrawNode3D::setBlendFunc(const BlendFunc &blendFunc) +{ + _blendFunc = blendFunc; +} + +NS_CC_END + +/** + * bindings for cc.DrawNode3D + **/ +JSClass *jsb_cocos2d_DrawNode3D_class; +JSObject *jsb_cocos2d_DrawNode3D_prototype; + +bool js_cocos2dx_DrawNode3D_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode3D* cobj = (cocos2d::DrawNode3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode3D_getBlendFunc : Invalid Native Object"); + if (argc == 0) { + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode3D_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_DrawNode3D_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode3D* cobj = (cocos2d::DrawNode3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode3D_setBlendFunc : Invalid Native Object"); + if (argc == 1) { + cocos2d::BlendFunc arg0; + ok &= jsval_to_blendfunc(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode3D_setBlendFunc : Error processing arguments"); + cobj->setBlendFunc(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode3D_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_DrawNode3D_drawLine(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode3D* cobj = (cocos2d::DrawNode3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode3D_drawLine : Invalid Native Object"); + if (argc == 3) { + cocos2d::Vec3 arg0; + cocos2d::Vec3 arg1; + cocos2d::Color4F arg2; + ok &= jsval_to_vector3(cx, args.get(0), &arg0); + ok &= jsval_to_vector3(cx, args.get(1), &arg1); + ok &= jsval_to_cccolor4f(cx, args.get(2), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode3D_drawLine : Error processing arguments"); + cobj->drawLine(arg0, arg1, arg2); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode3D_drawLine : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} +bool js_cocos2dx_DrawNode3D_clear(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode3D* cobj = (cocos2d::DrawNode3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode3D_clear : Invalid Native Object"); + if (argc == 0) { + cobj->clear(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode3D_clear : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_DrawNode3D_onDraw(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode3D* cobj = (cocos2d::DrawNode3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode3D_onDraw : Invalid Native Object"); + if (argc == 2) { + cocos2d::Mat4 arg0; + unsigned int arg1; + ok &= jsval_to_matrix(cx, args.get(0), &arg0); + ok &= jsval_to_uint32(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode3D_onDraw : Error processing arguments"); + cobj->onDraw(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode3D_onDraw : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_DrawNode3D_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode3D* cobj = (cocos2d::DrawNode3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode3D_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode3D_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_DrawNode3D_drawCube(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::DrawNode3D* cobj = (cocos2d::DrawNode3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_DrawNode3D_drawCube : Invalid Native Object"); + if (argc == 2) { + cocos2d::Vec3 arg0[8]; + cocos2d::Color4F arg1; + + JS::RootedObject jsVec3Array(cx, args.get(0).toObjectOrNull()); + JSB_PRECONDITION3( jsVec3Array && JS_IsArrayObject( cx, jsVec3Array), cx, false, "augument must be an array"); + uint32_t len = 0; + JS_GetArrayLength(cx, jsVec3Array, &len); + + if (len != 8) + { + JS_ReportError(cx, "array length error: %d, was expecting 8", len); + } + for (uint32_t i=0; i < len; i++) + { + JS::RootedValue value(cx); + if (JS_GetElement(cx, jsVec3Array, i, &value)) + { + ok &= jsval_to_vector3(cx, value, &arg0[i]); + if(!ok) + break; + } + } + + ok &= jsval_to_cccolor4f(cx, args.get(1), &arg1); + + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_DrawNode3D_drawCube : Error processing arguments"); + cobj->drawCube(arg0, arg1); + + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_DrawNode3D_drawCube : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} + +bool js_cocos2dx_DrawNode3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::DrawNode3D* cobj = new (std::nothrow) cocos2d::DrawNode3D(); + cobj->init(); + 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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::DrawNode3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + +static bool js_is_native_obj(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().setBoolean(true); + return true; +} + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_DrawNode3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (DrawNode3D)", obj); +} + +void js_register_cocos2dx_DrawNode3D(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_DrawNode3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_DrawNode3D_class->name = "DrawNode3D"; + jsb_cocos2d_DrawNode3D_class->addProperty = JS_PropertyStub; + jsb_cocos2d_DrawNode3D_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_DrawNode3D_class->getProperty = JS_PropertyStub; + jsb_cocos2d_DrawNode3D_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_DrawNode3D_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_DrawNode3D_class->resolve = JS_ResolveStub; + jsb_cocos2d_DrawNode3D_class->convert = JS_ConvertStub; + jsb_cocos2d_DrawNode3D_class->finalize = js_cocos2d_DrawNode3D_finalize; + jsb_cocos2d_DrawNode3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("getBlendFunc", js_cocos2dx_DrawNode3D_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBlendFunc", js_cocos2dx_DrawNode3D_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawLine", js_cocos2dx_DrawNode3D_drawLine, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("clear", js_cocos2dx_DrawNode3D_clear, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("onDraw", js_cocos2dx_DrawNode3D_onDraw, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_DrawNode3D_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawCube", js_cocos2dx_DrawNode3D_drawCube, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + jsb_cocos2d_DrawNode3D_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Node_prototype), + jsb_cocos2d_DrawNode3D_class, + js_cocos2dx_DrawNode3D_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, "DrawNode3D", 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_DrawNode3D_class; + p->proto = jsb_cocos2d_DrawNode3D_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +void register_DrawNode3D_bindings(JSContext *cx, JS::HandleObject global) +{ + JS::RootedObject ccobj(cx); + get_or_create_js_obj(cx, global, "cc", &ccobj); + js_register_cocos2dx_DrawNode3D(cx, ccobj); +} \ No newline at end of file diff --git a/tests/js-tests/project/Classes/js_DrawNode3D_bindings.h b/tests/js-tests/project/Classes/js_DrawNode3D_bindings.h new file mode 100644 index 0000000000..810e186765 --- /dev/null +++ b/tests/js-tests/project/Classes/js_DrawNode3D_bindings.h @@ -0,0 +1,31 @@ +/**************************************************************************** + Copyright (c) 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 NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +#ifndef __js_tests_bindings_h__ +#define __js_tests_bindings_h__ + +#include "jsapi.h" + +void register_DrawNode3D_bindings(JSContext *cx, JS::HandleObject global); + +#endif diff --git a/tests/js-tests/project/Classes/js_Effect3D_bindings.cpp b/tests/js-tests/project/Classes/js_Effect3D_bindings.cpp new file mode 100644 index 0000000000..f83aeca744 --- /dev/null +++ b/tests/js-tests/project/Classes/js_Effect3D_bindings.cpp @@ -0,0 +1,777 @@ +/**************************************************************************** + Copyright (c) 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 NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "js_Effect3D_bindings.h" +#include "cocos2d_specifics.hpp" + +using namespace cocos2d; + +class EffectSprite3D; + +class Effect3D : public Ref +{ +public: + virtual void draw(const Mat4 &transform) = 0; + virtual void setTarget(EffectSprite3D *sprite) = 0; +protected: + Effect3D() : _glProgramState(nullptr) {} + virtual ~Effect3D() + { + CC_SAFE_RELEASE(_glProgramState); + } +protected: + GLProgramState* _glProgramState; +}; + +class Effect3DOutline: public Effect3D +{ +public: + static Effect3DOutline* create(); + + void setOutlineColor(const Vec3& color); + + void setOutlineWidth(float width); + + virtual void draw(const Mat4 &transform) override; + virtual void setTarget(EffectSprite3D *sprite) override; + + + Effect3DOutline(); + virtual ~Effect3DOutline(); + + bool init(); +protected: + Vec3 _outlineColor; + float _outlineWidth; + //weak reference + EffectSprite3D* _sprite; +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) + EventListenerCustom* _backToForegroundListener; +#endif + +protected: + static const std::string _vertShaderFile; + static const std::string _fragShaderFile; + static const std::string _keyInGLProgramCache; + + static const std::string _vertSkinnedShaderFile; + static const std::string _fragSkinnedShaderFile; + static const std::string _keySkinnedInGLProgramCache; + + static GLProgram* getOrCreateProgram(bool isSkinned = false); +}; + +class EffectSprite3D : public Sprite3D +{ +public: + static EffectSprite3D* createFromObjFileAndTexture(const std::string& objFilePath, const std::string& textureFilePath); + static EffectSprite3D* create(const std::string& path); + + void setEffect3D(Effect3D* effect); + void addEffect(Effect3DOutline* effect, ssize_t order); + virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override; + + EffectSprite3D(); + virtual ~EffectSprite3D(); +protected: + std::vector> _effects; + Effect3D* _defaultEffect; + CustomCommand _command; +}; + + +EffectSprite3D* EffectSprite3D::createFromObjFileAndTexture(const std::string &objFilePath, const std::string &textureFilePath) +{ + auto sprite = new (std::nothrow) EffectSprite3D(); + if (sprite && sprite->initWithFile(objFilePath)) + { + sprite->autorelease(); + if(textureFilePath.size() > 0) + sprite->setTexture(textureFilePath); + return sprite; + } + CC_SAFE_DELETE(sprite); + return nullptr; +} + +EffectSprite3D* EffectSprite3D::create(const std::string &path) +{ + if (path.length() < 4) + CCASSERT(false, "improper name specified when creating Sprite3D"); + + auto sprite = new (std::nothrow) EffectSprite3D(); + if (sprite && sprite->initWithFile(path)) + { + sprite->autorelease(); + return sprite; + } + CC_SAFE_DELETE(sprite); + return nullptr; +} + +EffectSprite3D::EffectSprite3D() +: _defaultEffect(nullptr) +{ + +} + +EffectSprite3D::~EffectSprite3D() +{ + for(auto effect : _effects) + { + CC_SAFE_RELEASE_NULL(std::get<1>(effect)); + } + CC_SAFE_RELEASE(_defaultEffect); +} + +void EffectSprite3D::setEffect3D(Effect3D *effect) +{ + if(_defaultEffect == effect) return; + CC_SAFE_RETAIN(effect); + CC_SAFE_RELEASE(_defaultEffect); + _defaultEffect = effect; +} + +static int tuple_sort( const std::tuple &tuple1, const std::tuple &tuple2 ) +{ + return std::get<0>(tuple1) < std::get<0>(tuple2); +} + +void EffectSprite3D::addEffect(Effect3DOutline* effect, ssize_t order) +{ + if(nullptr == effect) return; + effect->retain(); + effect->setTarget(this); + + _effects.push_back(std::make_tuple(order,effect,CustomCommand())); + + std::sort(std::begin(_effects), std::end(_effects), tuple_sort); +} + +const std::string Effect3DOutline::_vertShaderFile = "Shaders3D/OutLine.vert"; +const std::string Effect3DOutline::_fragShaderFile = "Shaders3D/OutLine.frag"; +const std::string Effect3DOutline::_keyInGLProgramCache = "Effect3DLibrary_Outline"; + +const std::string Effect3DOutline::_vertSkinnedShaderFile = "Shaders3D/SkinnedOutline.vert"; +const std::string Effect3DOutline::_fragSkinnedShaderFile = "Shaders3D/OutLine.frag"; +const std::string Effect3DOutline::_keySkinnedInGLProgramCache = "Effect3DLibrary_Outline"; +GLProgram* Effect3DOutline::getOrCreateProgram(bool isSkinned /* = false */ ) +{ + if(isSkinned) + { + auto program = GLProgramCache::getInstance()->getGLProgram(_keySkinnedInGLProgramCache); + if(program == nullptr) + { + program = GLProgram::createWithFilenames(_vertSkinnedShaderFile, _fragSkinnedShaderFile); + GLProgramCache::getInstance()->addGLProgram(program, _keySkinnedInGLProgramCache); + } + return program; + } + else + { + auto program = GLProgramCache::getInstance()->getGLProgram(_keyInGLProgramCache); + if(program == nullptr) + { + program = GLProgram::createWithFilenames(_vertShaderFile, _fragShaderFile); + GLProgramCache::getInstance()->addGLProgram(program, _keyInGLProgramCache); + } + return program; + } + +} + +Effect3DOutline* Effect3DOutline::create() +{ + Effect3DOutline* effect = new (std::nothrow) Effect3DOutline(); + if(effect && effect->init()) + { + effect->autorelease(); + return effect; + } + else + { + CC_SAFE_DELETE(effect); + return nullptr; + } +} + +bool Effect3DOutline::init() +{ + + return true; +} + +Effect3DOutline::Effect3DOutline() +: _outlineWidth(1.0f) +, _outlineColor(1, 1, 1) +, _sprite(nullptr) +{ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) + _backToForegroundListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, + [this](EventCustom*) + { + auto glProgram = _glProgramState->getGLProgram(); + glProgram->reset(); + glProgram->initWithFilenames(_vertShaderFile, _fragShaderFile); + glProgram->link(); + glProgram->updateUniforms(); + } + ); + Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundListener, -1); +#endif +} + +Effect3DOutline::~Effect3DOutline() +{ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) + Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundListener); +#endif +} + +void Effect3DOutline::setOutlineColor(const Vec3& color) +{ + if(_outlineColor != color) + { + _outlineColor = color; + if(_glProgramState) + _glProgramState->setUniformVec3("OutLineColor", _outlineColor); + } +} + +void Effect3DOutline::setOutlineWidth(float width) +{ + if(_outlineWidth != width) + { + _outlineWidth = width; + if(_glProgramState) + _glProgramState->setUniformFloat("OutlineWidth", _outlineWidth); + } +} + +void Effect3DOutline::setTarget(EffectSprite3D *sprite) +{ + CCASSERT(nullptr != sprite && nullptr != sprite->getMesh(),"Error: Setting a null pointer or a null mesh EffectSprite3D to Effect3D"); + + if(sprite != _sprite) + { + GLProgram* glprogram; + if(!sprite->getMesh()->getSkin()) + glprogram = GLProgram::createWithFilenames(_vertShaderFile, _fragShaderFile); + else + glprogram = GLProgram::createWithFilenames(_vertSkinnedShaderFile, _fragSkinnedShaderFile); + + _glProgramState = GLProgramState::create(glprogram); + + _glProgramState->retain(); + _glProgramState->setUniformVec3("OutLineColor", _outlineColor); + _glProgramState->setUniformFloat("OutlineWidth", _outlineWidth); + + + _sprite = sprite; + + auto mesh = sprite->getMesh(); + long offset = 0; + for (auto i = 0; i < mesh->getMeshVertexAttribCount(); i++) + { + auto meshvertexattrib = mesh->getMeshVertexAttribute(i); + + _glProgramState->setVertexAttribPointer(s_attributeNames[meshvertexattrib.vertexAttrib], + meshvertexattrib.size, + meshvertexattrib.type, + GL_FALSE, + mesh->getVertexSizeInBytes(), + (void*)offset); + offset += meshvertexattrib.attribSizeBytes; + } + + Color4F color(_sprite->getDisplayedColor()); + color.a = _sprite->getDisplayedOpacity() / 255.0f; + _glProgramState->setUniformVec4("u_color", Vec4(color.r, color.g, color.b, color.a)); + } + +} + +static void MatrixPalleteCallBack( GLProgram* glProgram, Uniform* uniform, int paletteSize, const float* palette) +{ + glUniform4fv( uniform->location, (GLsizei)paletteSize, (const float*)palette ); +} + +void Effect3DOutline::draw(const Mat4 &transform) +{ + //draw + Color4F color(_sprite->getDisplayedColor()); + color.a = _sprite->getDisplayedOpacity() / 255.0f; + _glProgramState->setUniformVec4("u_color", Vec4(color.r, color.g, color.b, color.a)); + if(_sprite && _sprite->getMesh()) + { + glEnable(GL_CULL_FACE); + glCullFace(GL_FRONT); + glEnable(GL_DEPTH_TEST); + + auto mesh = _sprite->getMesh(); + glBindBuffer(GL_ARRAY_BUFFER, mesh->getVertexBuffer()); + + auto skin = _sprite->getMesh()->getSkin(); + if(_sprite && skin) + { + auto function = std::bind(MatrixPalleteCallBack, std::placeholders::_1, std::placeholders::_2, + skin->getMatrixPaletteSize(), (float*)skin->getMatrixPalette()); + _glProgramState->setUniformCallback("u_matrixPalette", function); + } + + if(_sprite) + _glProgramState->apply(transform); + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh->getIndexBuffer()); + glDrawElements(mesh->getPrimitiveType(), (GLsizei)mesh->getIndexCount(), mesh->getIndexFormat(), 0); + CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, mesh->getIndexCount()); + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + glDisable(GL_DEPTH_TEST); + glCullFace(GL_BACK); + glDisable(GL_CULL_FACE); + } +} + +void EffectSprite3D::draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) +{ + for(auto &effect : _effects) + { + if(std::get<0>(effect) >=0) + break; + CustomCommand &cc = std::get<2>(effect); + cc.func = CC_CALLBACK_0(Effect3D::draw,std::get<1>(effect),transform); + renderer->addCommand(&cc); + + } + + if(!_defaultEffect) + { + Sprite3D::draw(renderer, transform, flags); + } + else + { + _command.init(_globalZOrder, transform, flags); + _command.func = CC_CALLBACK_0(Effect3D::draw, _defaultEffect, transform); + renderer->addCommand(&_command); + } + + for(auto &effect : _effects) + { + if(std::get<0>(effect) <=0) + continue; + CustomCommand &cc = std::get<2>(effect); + cc.func = CC_CALLBACK_0(Effect3D::draw,std::get<1>(effect),transform); + renderer->addCommand(&cc); + + } +} + +// js bindings + +static bool js_is_native_obj(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + args.rval().setBoolean(true); + return true; +} + +JSClass *jsb_Effect3DOutline_class; +JSObject *jsb_Effect3DOutline_prototype; + +bool js_cocos2dx_Effect3DOutline_setOutlineWidth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + Effect3DOutline* cobj = (Effect3DOutline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Effect3DOutline_setOutlineWidth : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, args.get(0), &arg0) && !isnan(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Effect3DOutline_setOutlineWidth : Error processing arguments"); + cobj->setOutlineWidth(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Effect3DOutline_setOutlineWidth : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Effect3DOutline_setOutlineColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + Effect3DOutline* cobj = (Effect3DOutline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Effect3DOutline_setOutlineColor : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec3 arg0; + ok &= jsval_to_vector3(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Effect3DOutline_setOutlineColor : Error processing arguments"); + cobj->setOutlineColor(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Effect3DOutline_setOutlineColor : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Effect3DOutline_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + if (argc == 0) { + Effect3DOutline* ret = Effect3DOutline::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (Effect3DOutline*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Effect3DOutline_create : wrong number of arguments"); + return false; +} + + +JSObject *jsb_Effect3D_prototype; + +void js_Effect3DOutline_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Effect3DOutline)", obj); +} + +bool jsb_Effect3DOutline_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + Effect3DOutline* cobj = new (std::nothrow) Effect3DOutline(); + cobj->init(); + cobj->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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Effect3DOutline"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + +void js_register_cocos2dx_Effect3DOutline(JSContext *cx, JS::HandleObject global) { + jsb_Effect3DOutline_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_Effect3DOutline_class->name = "Effect3DOutline"; + jsb_Effect3DOutline_class->addProperty = JS_PropertyStub; + jsb_Effect3DOutline_class->delProperty = JS_DeletePropertyStub; + jsb_Effect3DOutline_class->getProperty = JS_PropertyStub; + jsb_Effect3DOutline_class->setProperty = JS_StrictPropertyStub; + jsb_Effect3DOutline_class->enumerate = JS_EnumerateStub; + jsb_Effect3DOutline_class->resolve = JS_ResolveStub; + jsb_Effect3DOutline_class->convert = JS_ConvertStub; + jsb_Effect3DOutline_class->finalize = js_Effect3DOutline_finalize; + jsb_Effect3DOutline_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setOutlineWidth", js_cocos2dx_Effect3DOutline_setOutlineWidth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setOutlineColor", js_cocos2dx_Effect3DOutline_setOutlineColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_Effect3DOutline_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_Effect3DOutline_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_Effect3D_prototype), + jsb_Effect3DOutline_class, + jsb_Effect3DOutline_constructor, 0, + 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, "Effect3DOutline", 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_Effect3DOutline_class; + p->proto = jsb_Effect3DOutline_prototype; + p->parentProto = jsb_Effect3D_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + + +JSClass *jsb_EffectSprite3D_class; +JSObject *jsb_EffectSprite3D_prototype; + +bool js_cocos2dx_EffectSprite3D_setEffect3D(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + EffectSprite3D* cobj = (EffectSprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EffectSprite3D_setEffect3D : Invalid Native Object"); + if (argc == 1) { + Effect3D* arg0; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (Effect3D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EffectSprite3D_setEffect3D : Error processing arguments"); + cobj->setEffect3D(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EffectSprite3D_setEffect3D : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_EffectSprite3D_addEffect(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + EffectSprite3D* cobj = (EffectSprite3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_EffectSprite3D_addEffect : Invalid Native Object"); + if (argc == 2) { + Effect3DOutline* arg0; + ssize_t arg1; + do { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (Effect3DOutline*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_ssize(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EffectSprite3D_addEffect : Error processing arguments"); + cobj->addEffect(arg0, arg1); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_EffectSprite3D_addEffect : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_EffectSprite3D_createFromObjFileAndTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 2) { + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_std_string(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EffectSprite3D_createFromObjFileAndTexture : Error processing arguments"); + EffectSprite3D* ret = EffectSprite3D::createFromObjFileAndTexture(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (EffectSprite3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EffectSprite3D_createFromObjFileAndTexture : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_EffectSprite3D_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EffectSprite3D_create : Error processing arguments"); + EffectSprite3D* ret = EffectSprite3D::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (EffectSprite3D*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_EffectSprite3D_create : wrong number of arguments"); + return false; +} + + +extern JSObject *jsb_cocos2d_Sprite3D_prototype; + +void js_EffectSprite3D_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (EffectSprite3D)", obj); +} + +bool jsb_EffectSprite3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + EffectSprite3D* cobj = new (std::nothrow) EffectSprite3D(); + if(argc == 1 || argc == 2) + { + std::string path; + jsval_to_std_string(cx, args.get(0), &path); + cobj->initWithFile(path); + if(argc == 2) + { + std::string texture; + jsval_to_std_string(cx, args.get(1), &texture); + cobj->setTexture(texture); + } + } + cobj->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::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::EffectSprite3D"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + +void js_register_cocos2dx_EffectSprite3D(JSContext *cx, JS::HandleObject global) { + jsb_EffectSprite3D_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_EffectSprite3D_class->name = "EffectSprite3D"; + jsb_EffectSprite3D_class->addProperty = JS_PropertyStub; + jsb_EffectSprite3D_class->delProperty = JS_DeletePropertyStub; + jsb_EffectSprite3D_class->getProperty = JS_PropertyStub; + jsb_EffectSprite3D_class->setProperty = JS_StrictPropertyStub; + jsb_EffectSprite3D_class->enumerate = JS_EnumerateStub; + jsb_EffectSprite3D_class->resolve = JS_ResolveStub; + jsb_EffectSprite3D_class->convert = JS_ConvertStub; + jsb_EffectSprite3D_class->finalize = js_EffectSprite3D_finalize; + jsb_EffectSprite3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setEffect3D", js_cocos2dx_EffectSprite3D_setEffect3D, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addEffect", js_cocos2dx_EffectSprite3D_addEffect, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("createFromObjFileAndTexture", js_cocos2dx_EffectSprite3D_createFromObjFileAndTexture, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("create", js_cocos2dx_EffectSprite3D_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_EffectSprite3D_prototype = JS_InitClass( + cx, global, + JS::RootedObject(cx, jsb_cocos2d_Sprite3D_prototype), + jsb_EffectSprite3D_class, + jsb_EffectSprite3D_constructor, 1, + 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, "EffectSprite3D", 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_EffectSprite3D_class; + p->proto = jsb_EffectSprite3D_prototype; + p->parentProto = jsb_cocos2d_Sprite3D_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +void register_Effect3D_bindings(JSContext *cx, JS::HandleObject global) +{ + JS::RootedObject ccobj(cx); + get_or_create_js_obj(cx, global, "cc", &ccobj); + js_register_cocos2dx_Effect3DOutline(cx, ccobj); + js_register_cocos2dx_EffectSprite3D(cx, ccobj); +} \ No newline at end of file diff --git a/tests/js-tests/project/Classes/js_Effect3D_bindings.h b/tests/js-tests/project/Classes/js_Effect3D_bindings.h new file mode 100644 index 0000000000..b5456d6d3b --- /dev/null +++ b/tests/js-tests/project/Classes/js_Effect3D_bindings.h @@ -0,0 +1,31 @@ +/**************************************************************************** + Copyright (c) 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 NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +#ifndef __js_effect3d_bindings_h__ +#define __js_effect3d_bindings_h__ + +#include "jsapi.h" + +void register_Effect3D_bindings(JSContext *cx, JS::HandleObject global); + +#endif diff --git a/tests/js-tests/project/proj.android/.classpath b/tests/js-tests/project/proj.android/.classpath new file mode 100644 index 0000000000..3cd35c958e --- /dev/null +++ b/tests/js-tests/project/proj.android/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/js-tests/project/proj.android/.project b/tests/js-tests/project/proj.android/.project new file mode 100644 index 0000000000..0649734c25 --- /dev/null +++ b/tests/js-tests/project/proj.android/.project @@ -0,0 +1,49 @@ + + + JSTests + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/tests/js-tests/project/proj.android/AndroidManifest.xml b/tests/js-tests/project/proj.android/AndroidManifest.xml new file mode 100644 index 0000000000..0e3fe1e035 --- /dev/null +++ b/tests/js-tests/project/proj.android/AndroidManifest.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/js-tests/project/proj.android/ant.properties b/tests/js-tests/project/proj.android/ant.properties new file mode 100644 index 0000000000..f8af38bfb4 --- /dev/null +++ b/tests/js-tests/project/proj.android/ant.properties @@ -0,0 +1 @@ +aapt.ignore.assets="!*.pvr.gz:!*.gz:!.svn:!.git:.*:_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~" diff --git a/tests/js-tests/project/proj.android/build-cfg.json b/tests/js-tests/project/proj.android/build-cfg.json new file mode 100644 index 0000000000..4010cc7cdb --- /dev/null +++ b/tests/js-tests/project/proj.android/build-cfg.json @@ -0,0 +1,29 @@ +{ + "copy_resources": [ + { + "from": "../../src", + "to": "src" + }, + { + "from": "../../../cpp-tests/Resources/", + "to": "res/" + }, + { + "from": "../../main.js", + "to": "" + }, + { + "from": "../../project.json", + "to": "" + }, + { + "from": "../../../../cocos/scripting/js-bindings/script", + "to": "script" + } + ], + "ndk_module_path": [ + "../../../..", + "../../../../cocos", + "../../../../external" + ] +} diff --git a/tests/js-tests/project/proj.android/build.xml b/tests/js-tests/project/proj.android/build.xml new file mode 100644 index 0000000000..2f46f6e914 --- /dev/null +++ b/tests/js-tests/project/proj.android/build.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/js-tests/project/proj.android/jni/Android.mk b/tests/js-tests/project/proj.android/jni/Android.mk new file mode 100644 index 0000000000..4ea163a5bb --- /dev/null +++ b/tests/js-tests/project/proj.android/jni/Android.mk @@ -0,0 +1,23 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := js_tests_shared + +LOCAL_MODULE_FILENAME := libjs_tests + +LOCAL_SRC_FILES := main.cpp \ + ../../Classes/AppDelegate.cpp \ + ../../Classes/js_DrawNode3D_bindings.cpp \ + ../../Classes/js_Effect3D_bindings.cpp + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes + +LOCAL_STATIC_LIBRARIES := cocos2d_js_static + + +LOCAL_EXPORT_CFLAGS := -DCOCOS2D_DEBUG=1 + +include $(BUILD_SHARED_LIBRARY) + +$(call import-module,scripting/js-bindings/proj.android) diff --git a/tests/js-tests/project/proj.android/jni/Application.mk b/tests/js-tests/project/proj.android/jni/Application.mk new file mode 100644 index 0000000000..706af60331 --- /dev/null +++ b/tests/js-tests/project/proj.android/jni/Application.mk @@ -0,0 +1,15 @@ +APP_STL := gnustl_static + +# 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 + +ifeq ($(NDK_DEBUG),1) + APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 + APP_OPTIM := debug +else + APP_CPPFLAGS += -DNDEBUG + APP_OPTIM := release +endif diff --git a/tests/js-tests/project/proj.android/jni/main.cpp b/tests/js-tests/project/proj.android/jni/main.cpp new file mode 100644 index 0000000000..baf5ca9810 --- /dev/null +++ b/tests/js-tests/project/proj.android/jni/main.cpp @@ -0,0 +1,17 @@ +#include "AppDelegate.h" +#include "cocos2d.h" +#include "platform/android/jni/JniHelper.h" +#include +#include + +#define LOG_TAG "main" +#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) + +using namespace cocos2d; + +void cocos_android_app_init (JNIEnv* env, jobject thiz) { + LOGD("cocos_android_app_init"); + AppDelegate *pAppDelegate = new AppDelegate(); + JavaVM* vm; + env->GetJavaVM(&vm); +} diff --git a/tests/js-tests/project/proj.android/ndkgdb.sh b/tests/js-tests/project/proj.android/ndkgdb.sh new file mode 100644 index 0000000000..b8b83e024f --- /dev/null +++ b/tests/js-tests/project/proj.android/ndkgdb.sh @@ -0,0 +1,47 @@ +APPNAME="JSTests" +APP_ANDROID_NAME="org.cocos2dx.js_tests" + +if [ -z "${SDK_ROOT+aaa}" ]; then +# ... if SDK_ROOT is not set, use "$HOME/bin/android-sdk" + SDK_ROOT="$HOME/bin/android-sdk" +fi + +if [ -z "${NDK_ROOT+aaa}" ]; then +# ... if NDK_ROOT is not set, use "$HOME/bin/android-ndk" + NDK_ROOT="$HOME/bin/android-ndk" +fi + +if [ -z "${COCOS2DX_ROOT+aaa}" ]; then +# ... if COCOS2DX_ROOT is not set +# ... find current working directory + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +# ... use paths relative to current directory + COCOS2DX_ROOT="$DIR/../../.." + APP_ROOT="$DIR/.." + APP_ANDROID_ROOT="$DIR" +else + APP_ROOT="$COCOS2DX_ROOT/samples/$APPNAME" + APP_ANDROID_ROOT="$COCOS2DX_ROOT/samples/$APPNAME/proj.android" +fi + +echo "NDK_ROOT = $NDK_ROOT" +echo "SDK_ROOT = $SDK_ROOT" +echo "COCOS2DX_ROOT = $COCOS2DX_ROOT" +echo "APP_ROOT = $APP_ROOT" +echo "APP_ANDROID_ROOT = $APP_ANDROID_ROOT" +echo "APP_ANDROID_NAME = $APP_ANDROID_NAME" + +echo +echo "Killing and restarting ${APP_ANDROID_NAME}" +echo + +set -x + +"${SDK_ROOT}"/platform-tools/adb shell am force-stop "${APP_ANDROID_NAME}" + +NDK_MODULE_PATH="${COCOS2DX_ROOT}":"${COCOS2DX_ROOT}"/cocos2dx/platform/third_party/android/prebuilt \ + "${NDK_ROOT}"/ndk-gdb \ + --adb="${SDK_ROOT}"/platform-tools/adb \ + --verbose \ + --start \ + --force diff --git a/tests/js-tests/project/proj.android/proguard-project.txt b/tests/js-tests/project/proj.android/proguard-project.txt new file mode 100644 index 0000000000..f2fe1559a2 --- /dev/null +++ b/tests/js-tests/project/proj.android/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/tests/js-tests/project/proj.android/project.properties b/tests/js-tests/project/proj.android/project.properties new file mode 100644 index 0000000000..4bd7647d63 --- /dev/null +++ b/tests/js-tests/project/proj.android/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "ant.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-10 + +android.library.reference.1=../../../../cocos/platform/android/java +android.library.reference.2=../../../../plugin/plugins/facebook/proj.android/DependProject diff --git a/tests/js-tests/project/proj.android/res/drawable-hdpi/icon.png b/tests/js-tests/project/proj.android/res/drawable-hdpi/icon.png new file mode 100644 index 0000000000..8aa4767c2f Binary files /dev/null and b/tests/js-tests/project/proj.android/res/drawable-hdpi/icon.png differ diff --git a/tests/js-tests/project/proj.android/res/drawable-ldpi/icon.png b/tests/js-tests/project/proj.android/res/drawable-ldpi/icon.png new file mode 100644 index 0000000000..17ce11a085 Binary files /dev/null and b/tests/js-tests/project/proj.android/res/drawable-ldpi/icon.png differ diff --git a/tests/js-tests/project/proj.android/res/drawable-mdpi/icon.png b/tests/js-tests/project/proj.android/res/drawable-mdpi/icon.png new file mode 100644 index 0000000000..3780aac46c Binary files /dev/null and b/tests/js-tests/project/proj.android/res/drawable-mdpi/icon.png differ diff --git a/tests/js-tests/project/proj.android/res/values/strings.xml b/tests/js-tests/project/proj.android/res/values/strings.xml new file mode 100644 index 0000000000..4717131918 --- /dev/null +++ b/tests/js-tests/project/proj.android/res/values/strings.xml @@ -0,0 +1,5 @@ + + + JSTests + 1426774790893461 + diff --git a/tests/js-tests/project/proj.android/src/org/cocos2dx/js_tests/AppActivity.java b/tests/js-tests/project/proj.android/src/org/cocos2dx/js_tests/AppActivity.java new file mode 100644 index 0000000000..a42c8089d7 --- /dev/null +++ b/tests/js-tests/project/proj.android/src/org/cocos2dx/js_tests/AppActivity.java @@ -0,0 +1,80 @@ +/**************************************************************************** +Copyright (c) 2010-2012 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. +****************************************************************************/ +package org.cocos2dx.js_tests; + +import org.cocos2dx.js_tests.R; +import org.cocos2dx.lib.Cocos2dxActivity; +import org.cocos2dx.lib.Cocos2dxGLSurfaceView; +import org.cocos2dx.lib.Cocos2dxJavascriptJavaBridge; + +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.content.Intent; +import android.os.Bundle; + +public class AppActivity extends Cocos2dxActivity { + + private static AppActivity app = null; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + app = this; + } + + @Override + public Cocos2dxGLSurfaceView onCreateView() { + Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this); + // TestCpp should create stencil buffer + glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8); + + return glSurfaceView; + } + + public static void showAlertDialog(final String title, final String message) { + app.runOnUiThread(new Runnable() { + @Override + public void run() { + AlertDialog alertDialog = new AlertDialog.Builder(app).create(); + alertDialog.setTitle(title); + alertDialog.setMessage(message); + alertDialog.setCancelable(true); + alertDialog.setIcon(R.drawable.icon); + alertDialog.setButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + app.runOnGLThread(new Runnable() { + @Override + public void run() { + + Cocos2dxJavascriptJavaBridge.evalString("cc.log(\"Javascript Java bridge!\")"); + } + }); + } + }); + alertDialog.show(); + } + }); + } + +} diff --git a/tests/js-tests/project/proj.ios/AppController.h b/tests/js-tests/project/proj.ios/AppController.h new file mode 100644 index 0000000000..2e8186124e --- /dev/null +++ b/tests/js-tests/project/proj.ios/AppController.h @@ -0,0 +1,35 @@ +/**************************************************************************** + Copyright (c) 2010-2013 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 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. + ****************************************************************************/ + +@class RootViewController; + +@interface AppController : NSObject +{ + UIWindow *window; + RootViewController *viewController; +} + +@end + diff --git a/tests/js-tests/project/proj.ios/AppController.mm b/tests/js-tests/project/proj.ios/AppController.mm new file mode 100644 index 0000000000..127a2d3c20 --- /dev/null +++ b/tests/js-tests/project/proj.ios/AppController.mm @@ -0,0 +1,144 @@ +/**************************************************************************** + Copyright (c) 2010-2013 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 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. + ****************************************************************************/ + +#import +#import "cocos2d.h" +#import "AppController.h" +#import "AppDelegate.h" +#import "RootViewController.h" +#import "platform/ios/CCEAGLView-ios.h" +//#import +@implementation AppController + +#pragma mark - +#pragma mark Application lifecycle + +// cocos2d application instance +static AppDelegate s_sharedApplication; + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + + // 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] + pixelFormat: kEAGLColorFormatRGBA8 + depthFormat: GL_DEPTH24_STENCIL8_OES + preserveBackbuffer: NO + sharegroup: nil + multiSampling: NO + numberOfSamples: 0 ]; + + [eaglView setMultipleTouchEnabled:YES]; + + // Use RootViewController manage CCEAGLView + viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; + viewController.wantsFullScreenLayout = YES; + viewController.view = eaglView; + + // Set RootViewController to window + if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) + { + // warning: addSubView doesn't work on iOS6 + [window addSubview: viewController.view]; + } + else + { + // use this method on ios6 + [window setRootViewController:viewController]; + } + + [window makeKeyAndVisible]; + + [[UIApplication sharedApplication] setStatusBarHidden: YES]; + + // IMPORTANT: Setting the GLView should be done after creating the RootViewController + cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView); + cocos2d::Director::getInstance()->setOpenGLView(glview); + + cocos2d::Application::getInstance()->run(); + return YES; +} +- (void)applicationWillResignActive:(UIApplication *)application { + /* + Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. + */ + cocos2d::Director::getInstance()->pause(); +} +//- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation +//{ +// return [FBSession.activeSession handleOpenURL:url]; +//} +//- (void)applicationDidBecomeActive:(UIApplication *)application { +// /* +// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +// */ +// [FBAppCall handleDidBecomeActive]; +// cocos2d::Director::getInstance()->resume(); +//} + +- (void)applicationDidEnterBackground:(UIApplication *)application { + /* + Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + If your application supports background execution, called instead of applicationWillTerminate: when the user quits. + */ + cocos2d::Application::getInstance()->applicationDidEnterBackground(); +} + +- (void)applicationWillEnterForeground:(UIApplication *)application { + /* + Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. + */ + cocos2d::Application::getInstance()->applicationWillEnterForeground(); +} + +- (void)applicationWillTerminate:(UIApplication *)application { + /* + Called when the application is about to terminate. + See also applicationDidEnterBackground:. + */ +} + + +#pragma mark - +#pragma mark Memory management + +- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { + /* + Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. + */ + cocos2d::Director::getInstance()->purgeCachedData(); +} + + +- (void)dealloc { + [super dealloc]; +} + +@end + diff --git a/tests/js-tests/project/proj.ios/Default-568h@2x.png b/tests/js-tests/project/proj.ios/Default-568h@2x.png new file mode 100644 index 0000000000..66c6d1cead Binary files /dev/null and b/tests/js-tests/project/proj.ios/Default-568h@2x.png differ diff --git a/tests/js-tests/project/proj.ios/Default.png b/tests/js-tests/project/proj.ios/Default.png new file mode 100644 index 0000000000..dcb80725de Binary files /dev/null and b/tests/js-tests/project/proj.ios/Default.png differ diff --git a/tests/js-tests/project/proj.ios/Default@2x.png b/tests/js-tests/project/proj.ios/Default@2x.png new file mode 100644 index 0000000000..84689888a1 Binary files /dev/null and b/tests/js-tests/project/proj.ios/Default@2x.png differ diff --git a/tests/js-tests/project/proj.ios/Icon-114.png b/tests/js-tests/project/proj.ios/Icon-114.png new file mode 100644 index 0000000000..c3807861ad Binary files /dev/null and b/tests/js-tests/project/proj.ios/Icon-114.png differ diff --git a/tests/js-tests/project/proj.ios/Icon-120.png b/tests/js-tests/project/proj.ios/Icon-120.png new file mode 100644 index 0000000000..a5b49ccbb1 Binary files /dev/null and b/tests/js-tests/project/proj.ios/Icon-120.png differ diff --git a/tests/js-tests/project/proj.ios/Icon-144.png b/tests/js-tests/project/proj.ios/Icon-144.png new file mode 100644 index 0000000000..1526615c02 Binary files /dev/null and b/tests/js-tests/project/proj.ios/Icon-144.png differ diff --git a/tests/js-tests/project/proj.ios/Icon-152.png b/tests/js-tests/project/proj.ios/Icon-152.png new file mode 100644 index 0000000000..8aa82506d0 Binary files /dev/null and b/tests/js-tests/project/proj.ios/Icon-152.png differ diff --git a/tests/js-tests/project/proj.ios/Icon-57.png b/tests/js-tests/project/proj.ios/Icon-57.png new file mode 100644 index 0000000000..4fcc6fddff Binary files /dev/null and b/tests/js-tests/project/proj.ios/Icon-57.png differ diff --git a/tests/js-tests/project/proj.ios/Icon-72.png b/tests/js-tests/project/proj.ios/Icon-72.png new file mode 100644 index 0000000000..2c573c8df4 Binary files /dev/null and b/tests/js-tests/project/proj.ios/Icon-72.png differ diff --git a/tests/js-tests/project/proj.ios/Icon-76.png b/tests/js-tests/project/proj.ios/Icon-76.png new file mode 100644 index 0000000000..8a1fa1850c Binary files /dev/null and b/tests/js-tests/project/proj.ios/Icon-76.png differ diff --git a/tests/js-tests/project/proj.ios/Info.plist b/tests/js-tests/project/proj.ios/Info.plist new file mode 100644 index 0000000000..4c9edec354 --- /dev/null +++ b/tests/js-tests/project/proj.ios/Info.plist @@ -0,0 +1,96 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFiles + + Icon-72.png + Icon.png + Icon@2x.png + Icon-57.png + Icon-114.png + Icon-144.png + + CFBundleIcons + + CFBundlePrimaryIcon + + CFBundleIconFiles + + Icon-72.png + Icon.png + Icon@2x.png + Icon-57.png + Icon-114.png + Icon-144.png + + UIPrerenderedIcon + + + + CFBundleIdentifier + org.cocos2d-x.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + UIAppFonts + + res/fonts/A Damn Mess.ttf + res/fonts/Abberancy.ttf + res/fonts/Abduction.ttf + res/fonts/American Typewriter.ttf + res/fonts/Courier New.ttf + res/fonts/Marker Felt.ttf + res/fonts/Paint Boy.ttf + res/fonts/Schwarzwald Regular.ttf + res/fonts/Scissor Cuts.ttf + res/fonts/tahoma.ttf + res/fonts/Thonburi.ttf + res/fonts/ThonburiBold.ttf + + UIPrerenderedIcon + + UIRequiredDeviceCapabilities + + accelerometer + + opengles-1 + + + UIStatusBarHidden + + UISupportedInterfaceOrientations + + UIInterfaceOrientationLandscapeRight + UIInterfaceOrientationLandscapeLeft + + FacebookAppID + 1426774790893461 + FacebookDisplayName + myFc + CFBundleURLTypes + + + CFBundleURLSchemes + + fb1426774790893461 + + + + + diff --git a/tests/js-tests/project/proj.ios/NativeOcClass.h b/tests/js-tests/project/proj.ios/NativeOcClass.h new file mode 100644 index 0000000000..f8664c6d63 --- /dev/null +++ b/tests/js-tests/project/proj.ios/NativeOcClass.h @@ -0,0 +1,33 @@ +/* + * 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. + */ + + +#import + +@interface NativeOcClass : NSObject + ++(float) callNative:(NSNumber *)a andInt:(NSString *)str; ++(void) callNativeWithParam:(NSString *)str; ++(NSString *)callNativeWithReturnString; ++(BOOL)callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content; ++(int)callNativeWithAdd:(NSNumber *)num1 and:(NSNumber *)num2; +@end diff --git a/tests/js-tests/project/proj.ios/NativeOcClass.m b/tests/js-tests/project/proj.ios/NativeOcClass.m new file mode 100644 index 0000000000..8591fee98a --- /dev/null +++ b/tests/js-tests/project/proj.ios/NativeOcClass.m @@ -0,0 +1,67 @@ +/* + * 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. + */ + +#import "NativeOcClass.h" +#if TARGET_OS_IPHONE +#import +#elif TARGET_OS_MAC +#import +#endif +@implementation NativeOcClass ++(float) callNative:(NSNumber *)a andInt:(NSString *)str{ + float b = [a floatValue]+111.3333; + NSLog(@"callNative string is %@ and int value is %f",str,b); + return b; +} ++(void)callNativeWithParam:(NSString *)str{ + NSLog(@"callNativeWithParam: str is %@ ",str); +} ++(NSString *)callNativeWithReturnString{ + return @"yes is a return string form objective-c"; +} ++(BOOL)callNativeWithReturnBool{ + return true; +} ++(int)callNativeWithAdd:(NSNumber *)num1 and:(NSNumber *)num2{ + return [num1 intValue]+[num2 intValue]; +} +#if TARGET_OS_IPHONE ++(BOOL)callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content{ + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:content delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil]; + [alertView show]; + return true; +} +#elif TARGET_OS_MAC + ++(BOOL)callNativeUIWithTitle:(NSString *) title andContent:(NSString *)content{ + NSAlert *alert = [[NSAlert alloc] init]; + [alert addButtonWithTitle:@"OK"]; + [alert addButtonWithTitle:@"Cancel"]; + [alert setMessageText:title]; + [alert setInformativeText:content]; + [alert setAlertStyle:NSWarningAlertStyle]; + [alert runModal]; + return true; +} + +#endif +@end diff --git a/tests/js-tests/project/proj.ios/Prefix.pch b/tests/js-tests/project/proj.ios/Prefix.pch new file mode 100644 index 0000000000..b056d8694a --- /dev/null +++ b/tests/js-tests/project/proj.ios/Prefix.pch @@ -0,0 +1,8 @@ +// +// Prefix header for all source files of the 'testjs' target in the 'testjs' project +// + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/tests/js-tests/project/proj.ios/RootViewController.h b/tests/js-tests/project/proj.ios/RootViewController.h new file mode 100644 index 0000000000..11dfc4bf88 --- /dev/null +++ b/tests/js-tests/project/proj.ios/RootViewController.h @@ -0,0 +1,33 @@ +/**************************************************************************** + Copyright (c) 2010-2011 cocos2d-x.org + Copyright (c) 2010 Ricardo Quesada + + 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. + ****************************************************************************/ + +#import + + +@interface RootViewController : UIViewController { + +} +- (BOOL)prefersStatusBarHidden; +@end diff --git a/tests/js-tests/project/proj.ios/RootViewController.mm b/tests/js-tests/project/proj.ios/RootViewController.mm new file mode 100644 index 0000000000..8438d7a420 --- /dev/null +++ b/tests/js-tests/project/proj.ios/RootViewController.mm @@ -0,0 +1,79 @@ +// +// testjsAppController.h +// testjs +// +// Created by Rolando Abarca on 3/19/12. +// Copyright __MyCompanyName__ 2012. All rights reserved. +// + +#import "RootViewController.h" + + +@implementation RootViewController + +/* + // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { + if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { + // Custom initialization + } + return self; +} +*/ + +/* +// Implement loadView to create a view hierarchy programmatically, without using a nib. +- (void)loadView { +} +*/ + +/* +// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. +- (void)viewDidLoad { + [super viewDidLoad]; +} + +*/ +// Override to allow orientations other than the default portrait orientation. +// This method is deprecated on ios6 +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + return UIInterfaceOrientationIsLandscape( interfaceOrientation ); +} + +// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead +- (NSUInteger) supportedInterfaceOrientations{ +#ifdef __IPHONE_6_0 + return UIInterfaceOrientationMaskAllButUpsideDown; +#endif +} + +- (BOOL) shouldAutorotate { + return YES; +} + +//fix not hide status on ios7 +- (BOOL)prefersStatusBarHidden +{ + return YES; +} + +- (void)didReceiveMemoryWarning { + // Releases the view if it doesn't have a superview. + [super didReceiveMemoryWarning]; + + // Release any cached data, images, etc that aren't in use. +} + +- (void)viewDidUnload { + [super viewDidUnload]; + // Release any retained subviews of the main view. + // e.g. self.myOutlet = nil; +} + + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/tests/js-tests/project/proj.ios/main.m b/tests/js-tests/project/proj.ios/main.m new file mode 100644 index 0000000000..e3dedca28b --- /dev/null +++ b/tests/js-tests/project/proj.ios/main.m @@ -0,0 +1,17 @@ +// +// main.m +// testjs +// +// Created by Rolando Abarca on 3/19/12. +// Copyright __MyCompanyName__ 2012. All rights reserved. +// + +#import + +int main(int argc, char *argv[]) { + + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + int retVal = UIApplicationMain(argc, argv, nil, @"AppController"); + [pool release]; + return retVal; +} diff --git a/tests/js-tests/project/proj.linux/main.cpp b/tests/js-tests/project/proj.linux/main.cpp new file mode 100644 index 0000000000..e236a953b3 --- /dev/null +++ b/tests/js-tests/project/proj.linux/main.cpp @@ -0,0 +1,10 @@ +#include "../Classes/AppDelegate.h" + +USING_NS_CC; + +int main(int argc, char **argv) +{ + // create the application instance + AppDelegate app; + return Application::getInstance()->run(); +} diff --git a/tests/js-tests/project/proj.mac/Icon.icns b/tests/js-tests/project/proj.mac/Icon.icns new file mode 100644 index 0000000000..3d09e8fb4f Binary files /dev/null and b/tests/js-tests/project/proj.mac/Icon.icns differ diff --git a/tests/js-tests/project/proj.mac/Test_Info.plist b/tests/js-tests/project/proj.mac/Test_Info.plist new file mode 100644 index 0000000000..dfab7c096d --- /dev/null +++ b/tests/js-tests/project/proj.mac/Test_Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + Icon + CFBundleIdentifier + org.cocos2d-x.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSMinimumSystemVersion + ${MACOSX_DEPLOYMENT_TARGET} + NSHumanReadableCopyright + Copyright © 2012. All rights reserved. + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/tests/js-tests/project/proj.mac/Test_Prefix.pch b/tests/js-tests/project/proj.mac/Test_Prefix.pch new file mode 100644 index 0000000000..46c36a7e99 --- /dev/null +++ b/tests/js-tests/project/proj.mac/Test_Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'Paralaxer' target in the 'Paralaxer' project +// + +#ifdef __OBJC__ + #import +#endif diff --git a/tests/js-tests/project/proj.mac/en.lproj/InfoPlist.strings b/tests/js-tests/project/proj.mac/en.lproj/InfoPlist.strings new file mode 100644 index 0000000000..477b28ff8f --- /dev/null +++ b/tests/js-tests/project/proj.mac/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/tests/js-tests/project/proj.mac/en.lproj/MainMenu.xib b/tests/js-tests/project/proj.mac/en.lproj/MainMenu.xib new file mode 100644 index 0000000000..3dacdedbd0 --- /dev/null +++ b/tests/js-tests/project/proj.mac/en.lproj/MainMenu.xib @@ -0,0 +1,812 @@ + + + + 1060 + 10K549 + 1938 + 1038.36 + 461.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 1938 + + + YES + NSMenuItem + NSCustomObject + NSMenu + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + + + PluginDependencyRecalculationVersion + + + + YES + + NSApplication + + + FirstResponder + + + NSApplication + + + AMainMenu + + YES + + + TestCpp + + 1048576 + 2147483647 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + submenuAction: + + TestCpp + + YES + + + About TestCpp + + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Preferences… + , + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Services + + 1048576 + 2147483647 + + + submenuAction: + + Services + + YES + + _NSServicesMenu + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Hide TestCpp + h + 1048576 + 2147483647 + + + + + + Hide Others + h + 1572864 + 2147483647 + + + + + + Show All + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Quit TestCpp + q + 1048576 + 2147483647 + + + + + _NSAppleMenu + + + + + View + + 1048576 + 2147483647 + + + submenuAction: + + View + + YES + + + Toggle Fullscreen + f + 1048576 + 2147483647 + + + + + + + + + Window + + 1048576 + 2147483647 + + + submenuAction: + + Window + + YES + + + Minimize + m + 1048576 + 2147483647 + + + + + + Zoom + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Bring All to Front + + 1048576 + 2147483647 + + + + + _NSWindowsMenu + + + + + Help + + 2147483647 + + + submenuAction: + + Help + + YES + + + TestCpp Help + ? + 1048576 + 2147483647 + + + + + _NSHelpMenu + + + + _NSMainMenu + + + AppController + + + NSFontManager + + + + + YES + + + terminate: + + + + 449 + + + + orderFrontStandardAboutPanel: + + + + 142 + + + + delegate + + + + 495 + + + + performMiniaturize: + + + + 37 + + + + arrangeInFront: + + + + 39 + + + + performZoom: + + + + 240 + + + + hide: + + + + 367 + + + + hideOtherApplications: + + + + 368 + + + + unhideAllApplications: + + + + 370 + + + + showHelp: + + + + 493 + + + + toggleFullScreen: + + + + 537 + + + + + YES + + 0 + + YES + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 29 + + + YES + + + + + + + + + 19 + + + YES + + + + + + 56 + + + YES + + + + + + 57 + + + YES + + + + + + + + + + + + + + + + 58 + + + + + 134 + + + + + 150 + + + + + 136 + + + + + 144 + + + + + 129 + + + + + 143 + + + + + 236 + + + + + 131 + + + YES + + + + + + 149 + + + + + 145 + + + + + 130 + + + + + 24 + + + YES + + + + + + + + + 92 + + + + + 5 + + + + + 239 + + + + + 23 + + + + + 295 + + + YES + + + + + + 296 + + + YES + + + + + + 420 + + + + + 490 + + + YES + + + + + + 491 + + + YES + + + + + + 492 + + + + + 494 + + + + + 536 + + + + + + + YES + + YES + -1.IBPluginDependency + -2.IBPluginDependency + -3.IBPluginDependency + 129.IBPluginDependency + 130.IBPluginDependency + 131.IBPluginDependency + 134.IBPluginDependency + 136.IBPluginDependency + 143.IBPluginDependency + 144.IBPluginDependency + 145.IBPluginDependency + 149.IBPluginDependency + 150.IBPluginDependency + 19.IBPluginDependency + 23.IBPluginDependency + 236.IBPluginDependency + 239.IBPluginDependency + 24.IBPluginDependency + 29.IBPluginDependency + 295.IBPluginDependency + 296.IBPluginDependency + 420.IBPluginDependency + 490.IBPluginDependency + 491.IBPluginDependency + 492.IBPluginDependency + 494.IBPluginDependency + 5.IBPluginDependency + 536.IBPluginDependency + 56.IBPluginDependency + 57.IBPluginDependency + 58.IBPluginDependency + 92.IBPluginDependency + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + YES + + + + + + YES + + + + + 541 + + + + YES + + AppController + NSObject + + YES + + YES + exitFullScreen: + toggleFullScreen: + + + YES + id + id + + + + YES + + YES + exitFullScreen: + toggleFullScreen: + + + YES + + exitFullScreen: + id + + + toggleFullScreen: + id + + + + + YES + + YES + glView + window + + + YES + EAGLView + NSWindow + + + + YES + + YES + glView + window + + + YES + + glView + EAGLView + + + window + NSWindow + + + + + IBProjectSource + ./Classes/AppController.h + + + + EAGLView + NSOpenGLView + + IBProjectSource + ./Classes/EAGLView.h + + + + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES + 3 + + YES + + YES + NSMenuCheckmark + NSMenuMixedState + + + YES + {9, 8} + {7, 2} + + + + diff --git a/tests/js-tests/project/proj.mac/main.cpp b/tests/js-tests/project/proj.mac/main.cpp new file mode 100644 index 0000000000..4b6a1e9021 --- /dev/null +++ b/tests/js-tests/project/proj.mac/main.cpp @@ -0,0 +1,35 @@ +/**************************************************************************** + Copyright (c) 2010 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 "AppDelegate.h" +#include "cocos2d.h" + +USING_NS_CC; + +int main(int argc, char *argv[]) +{ + AppDelegate app; + return Application::getInstance()->run(); +} + diff --git a/tests/js-tests/project/proj.win32/build-cfg.json b/tests/js-tests/project/proj.win32/build-cfg.json new file mode 100644 index 0000000000..d1965344bc --- /dev/null +++ b/tests/js-tests/project/proj.win32/build-cfg.json @@ -0,0 +1,24 @@ +{ + "copy_resources": [ + { + "from": "../../src", + "to": "src" + }, + { + "from": "../../../cpp-tests/Resources", + "to": "res" + }, + { + "from": "../../main.js", + "to": "" + }, + { + "from": "../../project.json", + "to": "" + }, + { + "from": "../../../../cocos/scripting/js-bindings/script", + "to": "script" + } + ] +} diff --git a/tests/js-tests/project/proj.win32/js-tests.rc b/tests/js-tests/project/proj.win32/js-tests.rc new file mode 100644 index 0000000000..3d664e8370 --- /dev/null +++ b/tests/js-tests/project/proj.win32/js-tests.rc @@ -0,0 +1,86 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +#undef APSTUDIO_HIDDEN_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON "res\\js-tests.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "\0" + VALUE "FileDescription", "js-tests Module\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "js-tests\0" + VALUE "LegalCopyright", "Copyright \0" + VALUE "OriginalFilename", "js-tests.exe\0" + VALUE "ProductName", "js-tests Module\0" + VALUE "ProductVersion", "1, 0, 0, 1\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 0x04B0 + END +END + +///////////////////////////////////////////////////////////////////////////// +#endif // !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) diff --git a/tests/js-tests/project/proj.win32/js-tests.vcxproj b/tests/js-tests/project/proj.win32/js-tests.vcxproj new file mode 100644 index 0000000000..be43805d5f --- /dev/null +++ b/tests/js-tests/project/proj.win32/js-tests.vcxproj @@ -0,0 +1,212 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {D0F06A44-A245-4D13-A498-0120C203B539} + js-tests + + + + Application + Unicode + v120 + v120_xp + + + Application + Unicode + v120 + v120_xp + + + + + + + + + + + + + + + + + <_ProjectFileVersion>12.0.21005.1 + $(SolutionDir)$(Configuration).win32\js-tests\ + $(Configuration).win32\ + false + $(SolutionDir)$(Configuration).win32\js-tests\ + $(Configuration).win32\ + false + AllRules.ruleset + + + AllRules.ruleset + + + + + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) + + + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) + + + + _DEBUG;%(PreprocessorDefinitions) + false + Win32 + true + $(IntDir)js-tests.tlb + js-tests.h + + + js-tests_i.c + js-tests_p.c + + + Disabled + $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;$(ProjectDir)..\Classes;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)cocos\scripting\js-bindings\manual;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;STRICT;_DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + false + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + EditAndContinue + 4267;4251;4244;%(DisableSpecificWarnings) + true + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(IntDir);%(AdditionalIncludeDirectories) + + + if not exist "$(OutDir)" mkdir "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$(OutDir)" + + + libcurl_imp.lib;mozjs-33.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) + $(OutDir);$(SolutionDir)$(Configuration).win32;%(AdditionalLibraryDirectories) + true + Windows + MachineX86 + + + if not exist "$(OutDir)" mkdir "$(OutDir)" + +mkdir "$(OutDir)\script" +mkdir "$(OutDir)\src" +mkdir "$(OutDir)\res" +xcopy "$(OutDir)..\*.dll" "$(OutDir)" /D /Y +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\js-bindings\script\*" "$(OutDir)\script" /e /Y +xcopy "$(ProjectDir)..\..\src" "$(OutDir)\src\" /e /Y +xcopy "$(ProjectDir)..\..\..\cpp-tests\Resources" "$(OutDir)\res\" /e /Y +copy "$(ProjectDir)..\..\main.js" "$(OutDir)" +copy "$(ProjectDir)..\..\project.json" "$(OutDir)" + + + Copy js and resource files. + + + + + NDEBUG;%(PreprocessorDefinitions) + false + Win32 + true + $(IntDir)js-tests.tlb + js-tests.h + + + js-tests_i.c + js-tests_p.c + + + $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;$(ProjectDir)..\Classes;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)cocos\scripting\js-bindings\manual;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + MultiThreadedDLL + + + Level3 + + + 4267;4251;4244;%(DisableSpecificWarnings) + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(IntDir);%(AdditionalIncludeDirectories) + + + if not exist "$(OutDir)" mkdir "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$(OutDir)" + + + libcurl_imp.lib;mozjs-33.lib;ws2_32.lib;sqlite3.lib;websockets.lib;%(AdditionalDependencies) + $(OutDir);$(SolutionDir)$(Configuration).win32;%(AdditionalLibraryDirectories) + Windows + MachineX86 + true + + + if not exist "$(OutDir)" mkdir "$(OutDir)" + +mkdir "$(OutDir)\script" +mkdir "$(OutDir)\src" +mkdir "$(OutDir)\res" +xcopy "$(OutDir)..\*.dll" "$(OutDir)" /D /Y +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\js-bindings\script\*" "$(OutDir)\script" /e /Y +xcopy "$(ProjectDir)..\..\src" "$(OutDir)\src\" /e /Y +xcopy "$(ProjectDir)..\..\..\cpp-tests\Resources" "$(OutDir)\res\" /e /Y +copy "$(ProjectDir)..\..\main.js" "$(OutDir)" +copy "$(ProjectDir)..\..\project.json" "$(OutDir)" + Copy js and resource files. + + + + + + + + + + + + + + + + + + + + + + + + {39379840-825a-45a0-b363-c09ffef864bd} + + + + + + \ No newline at end of file diff --git a/tests/js-tests/project/proj.win32/js-tests.vcxproj.filters b/tests/js-tests/project/proj.win32/js-tests.vcxproj.filters new file mode 100644 index 0000000000..b66e775a2e --- /dev/null +++ b/tests/js-tests/project/proj.win32/js-tests.vcxproj.filters @@ -0,0 +1,55 @@ + + + + + Classes + + + win32 + + + Classes + + + Classes + + + + + Classes + + + win32 + + + win32 + + + Classes + + + Classes + + + + + {73cd069e-e032-4051-8d30-65b08ab4f954} + + + {abaf0468-14d3-43ce-8d1a-8a4a34dba59b} + + + {bbe7342c-1f30-4512-b00a-841aa2d4ca9f} + + + + + resource + + + + + resource + + + \ No newline at end of file diff --git a/tests/js-tests/project/proj.win32/main.cpp b/tests/js-tests/project/proj.win32/main.cpp new file mode 100644 index 0000000000..f5ce0656ed --- /dev/null +++ b/tests/js-tests/project/proj.win32/main.cpp @@ -0,0 +1,34 @@ +#include "main.h" +#include "AppDelegate.h" + +USING_NS_CC; + +// uncomment below line, open debug console +// #define USE_WIN32_CONSOLE + +int APIENTRY _tWinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPTSTR lpCmdLine, + int nCmdShow) +{ + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); + +#ifdef USE_WIN32_CONSOLE + AllocConsole(); + freopen("CONIN$", "r", stdin); + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); +#endif + + // create the application instance + AppDelegate app; + + int ret = Application::getInstance()->run(); + +#ifdef USE_WIN32_CONSOLE + FreeConsole(); +#endif + + return ret; +} diff --git a/tests/js-tests/project/proj.win32/main.h b/tests/js-tests/project/proj.win32/main.h new file mode 100644 index 0000000000..e29aeedb3a --- /dev/null +++ b/tests/js-tests/project/proj.win32/main.h @@ -0,0 +1,12 @@ +#ifndef __MAIN_H__ +#define __MAIN_H__ + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +// Windows Header Files: +#include + +// C RunTime Header Files +#include "CCStdC.h" + +#endif // __WINMAIN_H__ diff --git a/tests/js-tests/project/proj.win32/res/js-tests.ico b/tests/js-tests/project/proj.win32/res/js-tests.ico new file mode 100644 index 0000000000..feaf932a74 Binary files /dev/null and b/tests/js-tests/project/proj.win32/res/js-tests.ico differ diff --git a/tests/js-tests/project/proj.win32/resource.h b/tests/js-tests/project/proj.win32/resource.h new file mode 100644 index 0000000000..3436133bc7 --- /dev/null +++ b/tests/js-tests/project/proj.win32/resource.h @@ -0,0 +1,20 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by js-tests.RC +// + +#define IDS_PROJNAME 100 +#define IDR_TESTJS 100 + +#define ID_FILE_NEW_WINDOW 32771 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 201 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 32775 +#endif +#endif diff --git a/tests/js-tests/project/proj.win8.1-universal/App.Shared/App.xaml b/tests/js-tests/project/proj.win8.1-universal/App.Shared/App.xaml new file mode 100644 index 0000000000..2da0ff79d0 --- /dev/null +++ b/tests/js-tests/project/proj.win8.1-universal/App.Shared/App.xaml @@ -0,0 +1,13 @@ + + + + + cpp_tests + + + diff --git a/tests/js-tests/project/proj.win8.1-universal/App.Shared/App.xaml.cpp b/tests/js-tests/project/proj.win8.1-universal/App.Shared/App.xaml.cpp new file mode 100644 index 0000000000..f4365b88c5 --- /dev/null +++ b/tests/js-tests/project/proj.win8.1-universal/App.Shared/App.xaml.cpp @@ -0,0 +1,21 @@ +#include "App.xaml.h" +#include "OpenGLESPage.xaml.h" + +using namespace cocos2d; + +App::App() +{ + InitializeComponent(); +} + +void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) +{ + if (mPage == nullptr) + { + mPage = ref new OpenGLESPage(&mOpenGLES); + } + + // Place the page in the current window and ensure that it is active. + Windows::UI::Xaml::Window::Current->Content = mPage; + Windows::UI::Xaml::Window::Current->Activate(); +} diff --git a/tests/js-tests/project/proj.win8.1-universal/App.Shared/App.xaml.h b/tests/js-tests/project/proj.win8.1-universal/App.Shared/App.xaml.h new file mode 100644 index 0000000000..1309c610d7 --- /dev/null +++ b/tests/js-tests/project/proj.win8.1-universal/App.Shared/App.xaml.h @@ -0,0 +1,19 @@ +#pragma once + +#include "app.g.h" +#include "OpenGLES.h" +#include "openglespage.xaml.h" + +namespace cocos2d +{ + ref class App sealed + { + public: + App(); + virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) override; + + private: + OpenGLESPage^ mPage; + OpenGLES mOpenGLES; + }; +} diff --git a/tests/js-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems b/tests/js-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems new file mode 100644 index 0000000000..4a353710a9 --- /dev/null +++ b/tests/js-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems @@ -0,0 +1,64 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + e956c24b-f04e-47bf-bf00-746681ae1301 + {AE6763F6-1549-441E-AFB5-377BE1C776DC} + js-tests + + + + %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) + + + + + Designer + + + + + $(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\OpenGLESPage.xaml + + + + + + $(MSBuildThisFileDirectory)App.xaml + + + + + $(MSBuildThisFileDirectory)..\..\..\..\..\cocos\platform\win8.1-universal\OpenGLESPage.xaml + + + + + + $(MSBuildThisFileDirectory)App.xaml + + + Create + + + + + + + + <_CustomResource Include="$(MSBuildThisFileDirectory)..\..\Resources\**\*"> + Assets\Resources\%(RecursiveDir)%(FileName)%(Extension) + true + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/js-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems.filters b/tests/js-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems.filters new file mode 100644 index 0000000000..841a3ae6ee --- /dev/null +++ b/tests/js-tests/project/proj.win8.1-universal/App.Shared/js-tests.Shared.vcxitems.filters @@ -0,0 +1,46 @@ + + + + + + + + + Classes + + + Classes + + + Classes + + + + + + + + + + + {38ad799c-8c3c-44a2-8e41-516c8f62f556} + + + + + Classes + + + Classes + + + Classes + + + + + + + + + \ No newline at end of file diff --git a/tests/js-tests/project/proj.win8.1-universal/App.Shared/pch.cpp b/tests/js-tests/project/proj.win8.1-universal/App.Shared/pch.cpp new file mode 100644 index 0000000000..bcb5590be1 --- /dev/null +++ b/tests/js-tests/project/proj.win8.1-universal/App.Shared/pch.cpp @@ -0,0 +1 @@ +#include "pch.h" diff --git a/tests/js-tests/project/proj.win8.1-universal/App.Shared/pch.h b/tests/js-tests/project/proj.win8.1-universal/App.Shared/pch.h new file mode 100644 index 0000000000..087ce3bf18 --- /dev/null +++ b/tests/js-tests/project/proj.win8.1-universal/App.Shared/pch.h @@ -0,0 +1,12 @@ +// +// pch.h +// Header for standard system include files. +// + +#pragma once + +#include "mozilla\Char16.h" +#include "cocos2d.h" +#include "cocos-ext.h" + + diff --git a/tests/js-tests/project/proj.win8.1-universal/App.Windows/Assets/Logo.scale-100.png b/tests/js-tests/project/proj.win8.1-universal/App.Windows/Assets/Logo.scale-100.png new file mode 100644 index 0000000000..e26771cb33 Binary files /dev/null and b/tests/js-tests/project/proj.win8.1-universal/App.Windows/Assets/Logo.scale-100.png differ diff --git a/tests/js-tests/project/proj.win8.1-universal/App.Windows/Assets/SmallLogo.scale-100.png b/tests/js-tests/project/proj.win8.1-universal/App.Windows/Assets/SmallLogo.scale-100.png new file mode 100644 index 0000000000..1eb0d9d528 Binary files /dev/null and b/tests/js-tests/project/proj.win8.1-universal/App.Windows/Assets/SmallLogo.scale-100.png differ diff --git a/tests/js-tests/project/proj.win8.1-universal/App.Windows/Assets/SplashScreen.scale-100.png b/tests/js-tests/project/proj.win8.1-universal/App.Windows/Assets/SplashScreen.scale-100.png new file mode 100644 index 0000000000..d8ded7198a Binary files /dev/null and b/tests/js-tests/project/proj.win8.1-universal/App.Windows/Assets/SplashScreen.scale-100.png differ diff --git a/tests/js-tests/project/proj.win8.1-universal/App.Windows/Assets/StoreLogo.scale-100.png b/tests/js-tests/project/proj.win8.1-universal/App.Windows/Assets/StoreLogo.scale-100.png new file mode 100644 index 0000000000..dcb672712c Binary files /dev/null and b/tests/js-tests/project/proj.win8.1-universal/App.Windows/Assets/StoreLogo.scale-100.png differ diff --git a/tests/js-tests/project/proj.win8.1-universal/App.Windows/Package.appxmanifest b/tests/js-tests/project/proj.win8.1-universal/App.Windows/Package.appxmanifest new file mode 100644 index 0000000000..1eb9e09ad5 --- /dev/null +++ b/tests/js-tests/project/proj.win8.1-universal/App.Windows/Package.appxmanifest @@ -0,0 +1,30 @@ + + + + + js-tests.Windows + msopentech + Assets\StoreLogo.png + + + 6.3.0 + 6.3.0 + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/js-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj b/tests/js-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj new file mode 100644 index 0000000000..14c9ea25f5 --- /dev/null +++ b/tests/js-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj @@ -0,0 +1,227 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + {70914FC8-7709-4CD6-B86B-C63FDE5478DB} + cocos2d + en-US + 12.0 + true + Windows Store + 8.1 + + + + Application + true + v120 + + + Application + true + v120 + + + Application + true + v120 + + + Application + false + false + v120 + + + Application + false + false + v120 + + + Application + false + false + v120 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + js-tests.Windows_TemporaryKey.pfx + True + x86 + FB58178D2A50D64A72EC25130D072580B999A12E + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + + + + + + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + + + + + + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + + + + + + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + + + + + + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + + + + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + + + echo "Copying Windows 8.1 Universal App CPP template files" +xcopy "$(EngineRoot)external\win8.1-universal\OpenGLESPage.xaml" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq +xcopy "$(EngineRoot)external\win8.1-universal\OpenGLESPage.xaml.cpp" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq +xcopy "$(EngineRoot)external\win8.1-universal\OpenGLESPage.xaml.h" "$(EngineRoot)templates\js-template-default\frameworks\runtime-src\proj.win8.1-universal\App.Shared\*" /eiycq + + + + + + Designer + + + + + + + + + + + + {bcf5546d-66a0-4998-afd6-c5514f618930} + + + {9335005f-678e-4e8e-9b84-50037216aec8} + + + {f3550fe0-c795-44f6-8feb-093eb68143ae} + + + {3b26a12d-3a44-47ea-82d2-282660fc844d} + + + + + + \ No newline at end of file diff --git a/tests/js-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj.filters b/tests/js-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj.filters new file mode 100644 index 0000000000..0391f8dd5a --- /dev/null +++ b/tests/js-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows.vcxproj.filters @@ -0,0 +1,29 @@ + + + + + {1a9fa652-867e-41d2-8588-962f108d2d8f} + bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png + + + + + + + + + + + Assets + + + Assets + + + Assets + + + Assets + + + \ No newline at end of file diff --git a/tests/js-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows_TemporaryKey.pfx b/tests/js-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows_TemporaryKey.pfx new file mode 100644 index 0000000000..a5b8824cbb Binary files /dev/null and b/tests/js-tests/project/proj.win8.1-universal/App.Windows/js-tests.Windows_TemporaryKey.pfx differ diff --git a/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Assets/Logo.scale-240.png b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Assets/Logo.scale-240.png new file mode 100644 index 0000000000..76921ca997 Binary files /dev/null and b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Assets/Logo.scale-240.png differ diff --git a/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Assets/SmallLogo.scale-240.png b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Assets/SmallLogo.scale-240.png new file mode 100644 index 0000000000..316630124f Binary files /dev/null and b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Assets/SmallLogo.scale-240.png differ diff --git a/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Assets/SplashScreen.scale-240.png b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Assets/SplashScreen.scale-240.png new file mode 100644 index 0000000000..b0b6bc08e5 Binary files /dev/null and b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Assets/SplashScreen.scale-240.png differ diff --git a/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Assets/Square71x71Logo.scale-240.png b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Assets/Square71x71Logo.scale-240.png new file mode 100644 index 0000000000..cfa54bee03 Binary files /dev/null and b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Assets/Square71x71Logo.scale-240.png differ diff --git a/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Assets/StoreLogo.scale-240.png b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Assets/StoreLogo.scale-240.png new file mode 100644 index 0000000000..47e084b593 Binary files /dev/null and b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Assets/StoreLogo.scale-240.png differ diff --git a/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Assets/WideLogo.scale-240.png b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Assets/WideLogo.scale-240.png new file mode 100644 index 0000000000..6249d29db0 Binary files /dev/null and b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Assets/WideLogo.scale-240.png differ diff --git a/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Package.appxmanifest b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Package.appxmanifest new file mode 100644 index 0000000000..0568af1b21 --- /dev/null +++ b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/Package.appxmanifest @@ -0,0 +1,33 @@ + + + + + + js-tests.WindowsPhone + dalestam + Assets\StoreLogo.png + + + 6.3.1 + 6.3.1 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj new file mode 100644 index 0000000000..b9b5a08fcb --- /dev/null +++ b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj @@ -0,0 +1,151 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Release + ARM + + + Release + Win32 + + + + {94874B5B-398F-448A-A366-35A35DC1DB9C} + cocos2d + en-US + 12.0 + true + Windows Phone + 8.1 + + + + Application + true + v120_wp81 + + + Application + true + v120_wp81 + + + Application + false + false + v120_wp81 + + + Application + false + false + v120_wp81 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + arm + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + + + + + /bigobj /Zm200 %(AdditionalOptions) + 4800;%(DisableSpecificWarnings) + pch.h + $(ProjectDir)..\..\Classes;$(EngineRoot)cocos\platform\win8.1-universal;%(AdditionalIncludeDirectories) + false + + + + + Designer + + + + + + + + + + + + + {ca082ec4-17ce-430b-8207-d1e947a5d1e9} + + + {22f3b9df-1209-4574-8331-003966f562bf} + + + {cc1da216-a80d-4be4-b309-acb6af313aff} + + + {22f798d8-bfff-4754-996f-a5395343d5ec} + + + + + + \ No newline at end of file diff --git a/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj.filters b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj.filters new file mode 100644 index 0000000000..eb71f325ca --- /dev/null +++ b/tests/js-tests/project/proj.win8.1-universal/App.WindowsPhone/js-tests.WindowsPhone.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {c8beb60d-689b-4aaa-9749-99bd3e2dcf75} + bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + + + + \ No newline at end of file diff --git a/tests/js-tests/project/proj.win8.1-universal/resources.props b/tests/js-tests/project/proj.win8.1-universal/resources.props new file mode 100644 index 0000000000..ece2b8ab05 --- /dev/null +++ b/tests/js-tests/project/proj.win8.1-universal/resources.props @@ -0,0 +1,63 @@ + + + + + + + $(EngineRoot)cocos\scripting\js-bindings\manual;$(EngineRoot)cocos\scripting\js-bindings\auto;$(EngineRoot)external\spidermonkey\include\$(COCOS2D_PLATFORM);$(EngineRoot)cocos\base;%(AdditionalIncludeDirectories); + + + mozjs-33.lib;%(AdditionalDependencies) + $(EngineRoot)external\spidermonkey\prebuilt\$(COCOS2D_PLATFORM)\$(Platform);%(AdditionalLibraryDirectories); + + + + + $(EngineRoot)external\spidermonkey\prebuilt\$(COCOS2D_PLATFORM)\$(Platform)\ + + + + + true + + + + + <_CustomResource Include="..\..\..\..\cpp-tests\Resources\**\*"> + Assets\Resources\res\%(RecursiveDir)%(FileName)%(Extension) + true + + + + <_CustomResource Include="..\..\..\src\**\*"> + Assets\Resources\src\%(RecursiveDir)%(FileName)%(Extension) + true + + + + <_CustomResource Include="..\..\..\..\..\cocos\scripting\js-bindings\script\**\*"> + Assets\Resources\script\%(RecursiveDir)%(FileName)%(Extension) + true + + + + <_CustomResource Include="..\..\..\main.js"> + Assets\Resources\%(RecursiveDir)%(FileName)%(Extension) + true + + + + <_CustomResource Include="..\..\..\project.json"> + Assets\Resources\%(RecursiveDir)%(FileName)%(Extension) + true + + + + + + + + + + + diff --git a/tests/js-tests/src/ActionManagerTest/ActionManagerTest.js b/tests/js-tests/src/ActionManagerTest/ActionManagerTest.js new file mode 100644 index 0000000000..7bb29f3a1c --- /dev/null +++ b/tests/js-tests/src/ActionManagerTest/ActionManagerTest.js @@ -0,0 +1,428 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 TAG_NODE = 5560; +var TAG_GROSSINI = 5561; +var TAG_SEQUENCE = 5562; + +var ActionMgrTestIdx = -1; +var NOT_CRASHED_CONST = "NOT_CRASHED"; + + +//------------------------------------------------------------------ +// +// ActionManagerTest +// +//------------------------------------------------------------------ +var ActionManagerTest = BaseTestLayer.extend({ + _atlas:null, + _title:"", + + title:function () { + return "No title"; + }, + + subtitle:function () { + return ""; + }, + + onBackCallback:function (sender) { + var s = new ActionManagerTestScene(); + s.addChild(previousActionMgrTest()); + director.runScene(s); + }, + onRestartCallback:function (sender) { + var s = new ActionManagerTestScene(); + s.addChild(restartActionMgrTest()); + director.runScene(s); + }, + onNextCallback:function (sender) { + var s = new ActionManagerTestScene(); + s.addChild(nextActionMgrTest()); + director.runScene(s); + }, + // automation + numberOfPendingTests:function() { + return ( (arrayOfActionMgrTest.length-1) - ActionMgrTestIdx ); + }, + + getTestNumber:function() { + return ActionMgrTestIdx; + } +}); + +//------------------------------------------------------------------ +// +// Test1 +// +//------------------------------------------------------------------ +var CrashTest = ActionManagerTest.extend({ + title:function () { + return "Test 1. Should not crash"; + }, + onEnter:function () { + //----start0----onEnter + this._super(); + + var child = new cc.Sprite(s_pathGrossini); + child.x = 200; + child.y = 200; + this.addChild(child, 1); + + //Sum of all action's duration is 1.5 second. + child.runAction(cc.rotateBy(1.5, 90)); + child.runAction(cc.sequence( + cc.delayTime(1.4), + cc.fadeOut(1.1)) + ); + + //After 1.5 second, self will be removed. + //this.runAction(cc.sequence( + // cc.delayTime(1.4), + // cc.callFunc(this.onRemoveThis, this)) + //); + //----end0---- + }, + + onRemoveThis:function () { + //----start0----onRemoveThis + this.parent.removeChild(this); + this.onNextCallback(this); + //----end0---- + }, + + // + // Automation + // + getExpectedResult:function() { + return NOT_CRASHED_CONST; + }, + getCurrentResult:function() { + return NOT_CRASHED_CONST; + } +}); + +//------------------------------------------------------------------ +// +// Test2 +// +//------------------------------------------------------------------ +var LogicTest = ActionManagerTest.extend({ + title:function () { + return "Logic test"; + }, + onEnter:function () { + //----start1----onEnter + this._super(); + + var grossini = new cc.Sprite(s_pathGrossini); + this.addChild(grossini, 0, 2); + grossini.x = 200; + grossini.y = 200; + + grossini.runAction(cc.sequence( + cc.moveBy(1, cc.p(150, 0)), + cc.callFunc(this.onBugMe, this)) + ); + + + // + // only for automation + // + if ( autoTestEnabled ) { + this._grossini = grossini; + } + //----end1---- + }, + onBugMe:function (node) { + //----start1----onBugMe + node.stopAllActions(); //After this stop next action not working, if remove this stop everything is working + node.runAction(cc.scaleTo(2, 2)); + //----end1---- + }, + + // + // Automation + // + testDuration: 4.0, + getExpectedResult:function() { + var ret = [ {"scaleX":2, "scaleY":2} ]; + return JSON.stringify(ret); + }, + getCurrentResult:function() { + var ret = [ {"scaleX":this._grossini.scaleX, "scaleY":this._grossini.scaleY} ]; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// PauseTest +// +//------------------------------------------------------------------ +var PauseTest = ActionManagerTest.extend({ + title:function () { + return "Pause Test"; + }, + onEnter:function () { + //----start2----onEnter + // + // This test MUST be done in 'onEnter' and not on 'init' + // otherwise the paused action will be resumed at 'onEnter' time + // + this._super(); + + var s = director.getWinSize(); + var l = new cc.LabelTTF("After 3 seconds grossini should move", "Thonburi", 16); + this.addChild(l); + l.x = s.width / 2; + l.y = 245; + + // + // Also, this test MUST be done, after [super onEnter] + // + var grossini = new cc.Sprite(s_pathGrossini); + this.addChild(grossini, 0, TAG_GROSSINI); + grossini.x = 200; + grossini.y = 200; + + + var action = cc.moveBy(1, cc.p(150, 0)); + + director.getActionManager().addAction(action, grossini, true); + + this.schedule(this.onUnpause, 3); + + // + // only for automation + // + if ( autoTestEnabled ) { + this.scheduleOnce(this.checkControl1, 2.0); + this.scheduleOnce(this.checkControl2, 4.5); + this._grossini = grossini; + } + //----end2---- + }, + + onUnpause:function (dt) { + //----start2----onUnpause + this.unschedule(this.onUnpause); + var node = this.getChildByTag(TAG_GROSSINI); + director.getActionManager().resumeTarget(node); + //----end2---- + }, + + // + // Automation + // + testDuration:5.5, + checkControl1:function(dt) { + this.control1 = cc.p(this._grossini.x, this._grossini.y); + }, + checkControl2:function(dt) { + this.control2 = cc.p(this._grossini.x, this._grossini.y); + }, + getExpectedResult:function() { + var ret = [ {"x":200, "y":200}, {"x":350, "y":200} ]; + return JSON.stringify(ret); + }, + getCurrentResult:function() { + var ret = [ {"x":this.control1.x, "y":this.control1.y}, {"x":this.control2.x, "y":this.control2.y} ]; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// RemoveTest +// +//------------------------------------------------------------------ +var RemoveTest = ActionManagerTest.extend({ + title:function () { + return "Remove Test"; + }, + onEnter:function () { + //----start3----onEnter + this._super(); + + var s = director.getWinSize(); + var l = new cc.LabelTTF("Should not crash", "Thonburi", 16); + this.addChild(l); + l.x = s.width / 2; + l.y = 245; + + var move = cc.moveBy(2, cc.p(200, 0)); + var callback = cc.callFunc(this.stopAction, this); + var sequence = cc.sequence(move, callback); + sequence.tag = TAG_SEQUENCE; + + var child = new cc.Sprite(s_pathGrossini); + child.x = 200; + child.y = 200; + + this.addChild(child, 1, TAG_GROSSINI); + child.runAction(sequence); + //----end3---- + }, + + stopAction:function () { + //----start3----onEnter + var sprite = this.getChildByTag(TAG_GROSSINI); + sprite.stopActionByTag(TAG_SEQUENCE); + //----end3---- + }, + + // + // Automation + // + testDuration:3.5, + getExpectedResult:function() { + return NOT_CRASHED_CONST; + }, + getCurrentResult:function() { + return NOT_CRASHED_CONST; + } +}); + +//------------------------------------------------------------------ +// +// ResumeTest +// +//------------------------------------------------------------------ +var ResumeTest = ActionManagerTest.extend({ + title:function () { + return "Resume Test"; + }, + onEnter:function () { + //----start4----onEnter + this._super(); + + var s = director.getWinSize(); + var l = new cc.LabelTTF("Grossini only rotate/scale in 3 seconds", "Thonburi", 16); + this.addChild(l); + l.x = s.width / 2; + l.y = 245; + + var grossini = new cc.Sprite(s_pathGrossini); + this._grossini = grossini; + this.addChild(grossini, 0, TAG_GROSSINI); + grossini.x = s.width / 2; + grossini.y = s.height / 2; + + grossini.runAction(cc.scaleBy(2, 2)); + + director.getActionManager().pauseTarget(grossini); + grossini.runAction(cc.rotateBy(2, 360)); + + this.schedule(this.resumeGrossini, 3.0); + //----end4---- + + }, + resumeGrossini:function (time) { + //----start4----resumeGrossini + this.unschedule(this.resumeGrossini); + + var grossini = this.getChildByTag(TAG_GROSSINI); + director.getActionManager().resumeTarget(grossini); + //----end4---- + }, + + // + // Automation + // + testDuration:6.0, + setupAutomation:function() { + this.scheduleOnce(this.checkControl1, 1.0); + this.scheduleOnce(this.checkControl2, 5.5); + }, + checkControl1:function(dt) { + this.control1ScaleX = this._grossini.scaleX; + this.control1ScaleY = this._grossini.scaleY; + this.control1Rotation = this._grossini.rotation; + }, + checkControl2:function(dt) { + this.control2ScaleX = this._grossini.scaleX; + this.control2ScaleY = this._grossini.scaleY; + this.control2Rotation = this._grossini.rotation; + }, + getExpectedResult:function() { + var ret = [ {"Rot":0 }, {"sX":1, "sY":1}, {"Rot":360 }, {"sX":2, "sY":2} ]; + return JSON.stringify(ret); + }, + getCurrentResult:function() { + var ret = [ {"Rot": this.control1Rotation }, {"sX": this.control1ScaleX, "sY": this.control1ScaleY}, {"Rot": this.control2Rotation }, {"sX": this.control2ScaleX, "sY": this.control2ScaleY} ]; + return JSON.stringify(ret); + } +}); + +var ActionManagerTestScene = TestScene.extend({ + runThisTest:function (num) { + ActionMgrTestIdx = (num || 0) - 1; + this.addChild(nextActionMgrTest()); + director.runScene(this); + } +}); + + +//- +// +// Flow control +// +var arrayOfActionMgrTest = [ + CrashTest, + LogicTest, + PauseTest, + RemoveTest, + ResumeTest +]; + +var nextActionMgrTest = function (num) { + + ActionMgrTestIdx = num ? num - 1 : ActionMgrTestIdx; + + ActionMgrTestIdx++; + ActionMgrTestIdx = ActionMgrTestIdx % arrayOfActionMgrTest.length; + + if(window.sideIndexBar){ + ActionMgrTestIdx = window.sideIndexBar.changeTest(ActionMgrTestIdx, 0); + } + + return new arrayOfActionMgrTest[ActionMgrTestIdx](); +}; +var previousActionMgrTest = function () { + ActionMgrTestIdx--; + if (ActionMgrTestIdx < 0) + ActionMgrTestIdx += arrayOfActionMgrTest.length; + + if(window.sideIndexBar){ + ActionMgrTestIdx = window.sideIndexBar.changeTest(ActionMgrTestIdx, 0); + } + + return new arrayOfActionMgrTest[ActionMgrTestIdx](); +}; +var restartActionMgrTest = function () { + return new arrayOfActionMgrTest[ActionMgrTestIdx](); +}; diff --git a/tests/js-tests/src/ActionsTest/ActionsTest.js b/tests/js-tests/src/ActionsTest/ActionsTest.js new file mode 100644 index 0000000000..8fae9eecaa --- /dev/null +++ b/tests/js-tests/src/ActionsTest/ActionsTest.js @@ -0,0 +1,2750 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 actionsTestIdx = -1; + +var SPRITE_GROSSINI_TAG = 1; +var SPRITE_TAMARA_TAG = 2; +var SPRITE_KATHIA_TAG = 3; + +// the class inherit from TestScene +// every Scene each test used must inherit from TestScene, +// make sure the test have the menu item for back to main menu +var ActionsTestScene = TestScene.extend({ + runThisTest:function (num) { + actionsTestIdx = (num || num == 0) ? (num - 1) : -1; + this.addChild(nextActionsTest()); + director.runScene(this); + } +}); + +var ActionsDemo = BaseTestLayer.extend({ + _grossini:null, + _tamara:null, + _kathia:null, + _code:null, + + ctor:function () { + this._super(cc.color(0,0,0,255), cc.color(98,99,117,255) ); + + this._grossini = new cc.Sprite(s_pathGrossini); + this._tamara = new cc.Sprite(s_pathSister1); + this._kathia = new cc.Sprite(s_pathSister2); + this.addChild(this._grossini, SPRITE_GROSSINI_TAG); + this.addChild(this._tamara, SPRITE_TAMARA_TAG); + this.addChild(this._kathia, SPRITE_KATHIA_TAG); + var s = director.getWinSize(); + this._grossini.x = s.width / 2; + this._grossini.y = s.height / 3; + this._tamara.x = s.width / 2; + this._tamara.y = 2 * s.height / 3; + this._kathia.x = s.width / 2; + this._kathia.y = s.height / 2; + }, + + centerSprites:function (numberOfSprites) { + var winSize = director.getWinSize(); + + if (numberOfSprites === 0) { + this._tamara.visible = false; + this._kathia.visible = false; + this._grossini.visible = false; + } else if (numberOfSprites == 1) { + this._tamara.visible = false; + this._kathia.visible = false; + this._grossini.x = winSize.width / 2; + this._grossini.y = winSize.height / 2; + } + else if (numberOfSprites == 2) { + this._kathia.x = winSize.width / 3; + this._kathia.y = winSize.height / 2; + this._tamara.x = 2 * winSize.width / 3; + this._tamara.y = winSize.height / 2; + this._grossini.visible = false; + } + else if (numberOfSprites == 3) { + this._grossini.x = winSize.width / 2; + this._grossini.y = winSize.height / 2; + this._tamara.x = winSize.width / 4; + this._tamara.y = winSize.height / 2; + this._kathia.x = 3 * winSize.width / 4; + this._kathia.y = winSize.height / 2; + } + }, + alignSpritesLeft:function (numberOfSprites) { + //----start47----onEnter + var s = director.getWinSize(); + + if (numberOfSprites == 1) { + this._tamara.visible = false; + this._kathia.visible = false; + this._grossini.x = 60; + this._grossini.y = s.height / 2; + } + else if (numberOfSprites == 2) { + this._kathia.x = 60; + this._kathia.y = s.height / 3; + this._tamara.x = 60; + this._tamara.y = 2 * s.height / 3; + this._grossini.visible = false; + } + else if (numberOfSprites == 3) { + this._grossini.x = 60; + this._grossini.y = s.height / 2; + this._tamara.x = 60; + this._tamara.y = 2 * s.height / 3; + this._kathia.x = 60; + this._kathia.y = s.height / 3; + } + //----end47---- + }, + title:function () { + return "ActionsTest"; + }, + subtitle:function () { + return ""; + }, + onBackCallback:function (sender) { + var s = new ActionsTestScene(); + s.addChild(previousActionsTest()); + director.runScene(s); + }, + onRestartCallback:function (sender) { + var s = new ActionsTestScene(); + s.addChild(restartActionsTest()); + director.runScene(s); + }, + onNextCallback:function (sender) { + var s = new ActionsTestScene(); + s.addChild(nextActionsTest()); + director.runScene(s); + }, + numberOfPendingTests:function() { + return ( (arrayOfActionsTest.length-1) - actionsTestIdx ); + }, + + getTestNumber:function() { + return actionsTestIdx; + } +}); + +//------------------------------------------------------------------ +// +// ActionManual +// +//------------------------------------------------------------------ +var ActionManual = ActionsDemo.extend({ + _code:"sprite.x = 10; sprite.y = 20;\n" + + "sprite.rotation = 90;\n" + + "sprite.scale = 2;", + + onEnter:function () { + //----start0----onEnter + this._super(); + + this._tamara.attr({ + x: 100, + y: 70, + opacity: 128, + scaleX: 2.5, + scaleY: -1.0 + }); + + this._grossini.attr({ + x: winSize.width / 2, + y: winSize.height / 2, + rotation: 120, + color: cc.color(255, 0, 0) + }); + + this._kathia.x = winSize.width - 100; + this._kathia.y = winSize.height / 2; + this._kathia.color = cc.color(0, 0, 255); + //----end0---- + }, + + title:function () { + return "Sprite properties"; + }, + subtitle:function () { + return "Manual Transformation"; + }, + + // + // Automation + // + testDuration:0.1, + getExpectedResult:function() { + var ret = [2.5,{"x":100,"y":70},128,120,{"x":winSize.width/2,"y":winSize.height/2},{"r":255,"g":0,"b":0},{"x":winSize.width - 100,"y":winSize.height / 2},{"r":0,"g":0,"b":255}]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = []; + ret.push( this._tamara.scaleX ); + ret.push( cc.p(this._tamara.x, this._tamara.y) ); + ret.push( this._tamara.opacity ); + + ret.push( this._grossini.rotation ); + ret.push( cc.p(this._grossini.x, this._grossini.y) ); + ret.push( this._grossini.color ); + + ret.push( cc.p(this._kathia.x, this._kathia.y) ); + ret.push( this._kathia.color ); + + return JSON.stringify(ret); + } +}); + + +//------------------------------------------------------------------ +// +// ActionMove +// +//------------------------------------------------------------------ +var ActionMove = ActionsDemo.extend({ + + _code:"a =cc.moveBy( time, cc.p(x,y) );\n" + + "a = cc.moveTo( time, cc.p(x,y) );", + + onEnter:function () { + //----start1----onEnter + this._super(); + + this.centerSprites(3); + var s = director.getWinSize(); + + var actionTo = cc.moveTo(2, cc.p(s.width - 40, s.height - 40)); + + var actionBy = cc.moveBy(1, cc.p(80, 80)); + var actionByBack = actionBy.reverse(); + + this._tamara.runAction(actionTo); + this._grossini.runAction(cc.sequence(actionBy, actionByBack)); + this._kathia.runAction(cc.moveTo(1, cc.p(40, 40))); + //----end1---- + }, + title:function () { + return "cc.moveTo / cc.moveBy"; + }, + + // + // Automation + // + testDuration:2.1, + getExpectedResult:function() { + var ret = [{"x":winSize.width-40,"y":winSize.height-40},{"x":winSize.width/2,"y":winSize.height/2},{"x":40,"y":40}]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = []; + ret.push( cc.p(this._tamara.x, this._tamara.y) ); + ret.push( cc.p(this._grossini.x, this._grossini.y) ); + ret.push( cc.p(this._kathia.x, this._kathia.y) ); + + return JSON.stringify(ret); + } + +}); + +//------------------------------------------------------------------ +// +// ActionScale +// +//------------------------------------------------------------------ +var ActionScale = ActionsDemo.extend({ + + _code:"a = cc.scaleBy( time, scale );\n" + + "a = cc.scaleTo( time, scaleX, scaleY );", + + onEnter:function () { + //----start2----onEnter + this._super(); + + this.centerSprites(3); + + var actionTo = cc.scaleTo(2, 0.5); + var actionBy = cc.scaleBy(2, 2); + var actionBy2 = cc.scaleBy(2, 0.25, 4.5); + + this._tamara.runAction(actionTo); + this._kathia.runAction(cc.sequence(actionBy2, cc.delayTime(0.25), actionBy2.reverse())); + this._grossini.runAction(cc.sequence(actionBy, cc.delayTime(0.25), actionBy.reverse())); + + //----end2---- + }, + title:function () { + return "cc.scaleTo / cc.scaleBy"; + }, + + // + // Automation + // + testDuration:2.1, + getExpectedResult:function() { + var ret = [0.5,2,0.25,4.5]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = []; + ret.push( this._tamara.scale ); + ret.push( this._grossini.scale ); + ret.push( this._kathia.scaleX ); + ret.push( this._kathia.scaleY ); + + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// ActionRotate +// +//------------------------------------------------------------------ +var ActionRotate = ActionsDemo.extend({ + + _code:"a = cc.rotateBy( time, degrees );\n" + + "a = cc.rotateTo( time, degrees );", + + onEnter:function () { + //----start3----onEnter + this._super(); + this.centerSprites(3); + var actionTo = cc.rotateTo(2, 45); + var actionTo2 = cc.rotateTo(2, -45); + var actionTo0 = cc.rotateTo(2, 0); + this._tamara.runAction(cc.sequence(actionTo, cc.delayTime(0.25), actionTo0)); + + var actionBy = cc.rotateBy(2, 360); + var actionByBack = actionBy.reverse(); + this._grossini.runAction(cc.sequence(actionBy, cc.delayTime(0.25), actionByBack)); + + this._kathia.runAction(cc.sequence(actionTo2, cc.delayTime(0.25), actionTo0.clone())); + + //----end3---- + }, + title:function () { + return "cc.rotateTo / cc.rotateBy"; + }, + // + // Automation + // + testDuration:2.1, + getExpectedResult:function() { + var ret = [45,360,-45]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = []; + ret.push( this._tamara.rotation ); + ret.push( this._grossini.rotation ); + ret.push( this._kathia.rotation ); + + return JSON.stringify(ret); + } + +}); + +//------------------------------------------------------------------ +// +// ActionRotateXY +// +//------------------------------------------------------------------ +var ActionRotateXY = ActionsDemo.extend({ + onEnter:function () { + //----start4----onEnter + this._super(); + this.centerSprites(3); + var actionTo = cc.rotateTo(2, 37.2, -37.2); + var actionToBack = cc.rotateTo(2, 0, 0); + var actionBy = cc.rotateBy(2, 0, -90); + var actionBy2 = cc.rotateBy(2, 45.0, 45.0); + + var delay = cc.delayTime(0.25); + + this._tamara.runAction(cc.sequence(actionTo, delay, actionToBack)); + this._grossini.runAction(cc.sequence(actionBy, delay.clone(), actionBy.reverse())); + + this._kathia.runAction(cc.sequence(actionBy2, delay.clone(), actionBy2.reverse())); + + if (!cc.sys.isNative && !("opengl" in cc.sys.capabilities)) { + var label = new cc.LabelTTF("Not support Actions on HTML5-canvas", "Times New Roman", 30); + label.x = winSize.width / 2; + label.y = winSize.height / 2 + 50; + this.addChild(label, 100); + } + //----end4---- + }, + title:function () { + return "cc.RotateBy(x,y) / cc.RotateTo(x,y)"; + }, + // + // Automation + // + testDuration:2.1, + getExpectedResult:function() { + var ret = ["37.20","-37.20",0,-90,45,45]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = []; + ret.push( this._tamara.rotationX.toFixed(2) ); + ret.push( this._tamara.rotationY.toFixed(2) ); + + ret.push( this._grossini.rotationX ); + ret.push( this._grossini.rotationY ); + + ret.push( this._kathia.rotationX ); + ret.push( this._kathia.rotationY ); + + return JSON.stringify(ret); + } + +}); +//------------------------------------------------------------------ +// +// ActionSkew +// +//------------------------------------------------------------------ +var ActionSkew = ActionsDemo.extend({ + + _code:"a = cc.skewBy( time, skew );\n" + + "a = cc.skewTo( time, skewX, skewY );", + + onEnter:function () { + //----start5----onEnter + this._super(); + this.centerSprites(3); + var actionTo = cc.skewTo(2, 37.2, -37.2); + var actionToBack = cc.skewTo(2, 0, 0); + var actionBy = cc.skewBy(2, 0, -90); + var actionBy2 = cc.skewBy(2, 45.0, 45.0); + + var delay = cc.delayTime(0.25); + + this._tamara.runAction(cc.sequence(actionTo, delay, actionToBack)); + this._grossini.runAction(cc.sequence(actionBy, delay.clone(), actionBy.reverse())); + + this._kathia.runAction(cc.sequence(actionBy2, delay.clone(), actionBy2.reverse())); + //----end5---- + }, + title:function () { + return "cc.skewTo / cc.skewBy"; + }, + // + // Automation + // + testDuration:2.1, + getExpectedResult:function() { + var ret = ["37.20","-37.20",0,0,45,45]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = []; + ret.push( this._tamara.skewX.toFixed(2) ); + ret.push( this._tamara.skewY.toFixed(2) ); + + ret.push( this._grossini.skewX ); + ret.push( this._grossini.skewY ); + + ret.push( this._kathia.skewX ); + ret.push( this._kathia.skewY ); + + return JSON.stringify(ret); + } +}); + +var ActionSkewRotateScale = ActionsDemo.extend({ + onEnter:function () { + //----start6----onEnter + this._super(); + + this.centerSprites(0); + + var boxW = 100, boxH = 100; + var box = new cc.LayerColor(cc.color(255, 255, 0, 255)); + box.anchorX = 0; + box.anchorY = 0; + box.x = (winSize.width - boxW) / 2; + box.y = (winSize.height - boxH) / 2; + box.width = boxW; + box.height = boxH; + + var markrside = 10.0; + var uL = new cc.LayerColor(cc.color(255, 0, 0, 255)); + box.addChild(uL); + uL.width = markrside; + uL.height = markrside; + uL.x = 0; + uL.y = boxH - markrside; + uL.anchorX = 0; + uL.anchorY = 0; + + var uR = new cc.LayerColor(cc.color(0, 0, 255, 255)); + box.addChild(uR); + uR.width = markrside; + uR.height = markrside; + uR.x = boxW - markrside; + uR.y = boxH - markrside; + uR.anchorX = 0; + uR.anchorY = 0; + + + this.addChild(box); + var actionTo = cc.skewTo(2, 0, 2); + var rotateTo = cc.rotateTo(2, 61.0); + var actionScaleTo = cc.scaleTo(2, -0.44, 0.47); + + var actionScaleToBack = cc.scaleTo(2, 1.0, 1.0); + var rotateToBack = cc.rotateTo(2, 0); + var actionToBack = cc.skewTo(2, 0, 0); + + var delay = cc.delayTime(0.25); + + box.runAction(cc.sequence(actionTo, delay, actionToBack)); + box.runAction(cc.sequence(rotateTo, delay.clone(), rotateToBack)); + box.runAction(cc.sequence(actionScaleTo, delay.clone(), actionScaleToBack)); + + this.box = box; + //----end6---- + }, + title:function () { + return "Skew + Rotate + Scale"; + }, + // + // Automation + // + testDuration:2.1, + getExpectedResult:function() { + var ret = [0,2,61,"-0.44","0.47"]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = []; + ret.push( this.box.skewX ); + ret.push( this.box.skewY ); + ret.push( this.box.rotation ); + ret.push( this.box.scaleX.toFixed(2) ); + ret.push( this.box.scaleY.toFixed(2) ); + + return JSON.stringify(ret); + } + +}); + +//------------------------------------------------------------------ +// +// ActionJump +// +//------------------------------------------------------------------ +var ActionJump = ActionsDemo.extend({ + _code:"a = cc.jumpBy( time, point, height, #_of_jumps );\n" + + "a = cc.jumpTo( time, point, height, #_of_jumps );", + + onEnter:function () { + //----start7----onEnter + this._super(); + this.centerSprites(3); + + var actionTo = cc.jumpTo(2, cc.p(300, 300), 50, 4); + var actionBy = cc.jumpBy(2, cc.p(300, 0), 50, 4); + var actionUp = cc.jumpBy(2, cc.p(0, 0), 80, 4); + var actionByBack = actionBy.reverse(); + + var delay = cc.delayTime(0.25); + + this._tamara.runAction(actionTo); + this._grossini.runAction(cc.sequence(actionBy, delay, actionByBack)); + + var action = cc.sequence(actionUp, delay.clone()).repeatForever(); + this._kathia.runAction(action); + //----end7---- + }, + title:function () { + return "cc.jumpTo / cc.jumpBy"; + }, + subtitle:function () { + return "Actions will stop for 0.25s after 2 seconds"; + }, + + // + // Automation + // + testDuration:2.1, + getExpectedResult:function() { + var ret = [{"x":300,"y":300}, + {"x":winSize.width/2+300,"y":winSize.height/2}, + {"x":3*winSize.width/4,"y":winSize.height/2}]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = []; + ret.push( cc.p(this._tamara.x, this._tamara.y) ); + ret.push( cc.p(this._grossini.x, this._grossini.y) ); + ret.push( cc.p(this._kathia.x, this._kathia.y) ); + + return JSON.stringify(ret); + } + +}); +//------------------------------------------------------------------ +// +// ActionBezier +// +//------------------------------------------------------------------ +var ActionBezier = ActionsDemo.extend({ + onEnter:function () { + //----start8----onEnter + + this._super(); + var s = director.getWinSize(); + + // + // startPosition can be any coordinate, but since the movement + // is relative to the Bezier curve, make it (0,0) + // + + this.centerSprites(3); + + // sprite 1 + + var delay = cc.delayTime(0.25); + + // 3 and only 3 control points should be used for Bezier actions. + var controlPoints = [ cc.p(0, 374), + cc.p(300, -374), + cc.p(300, 100) ]; + + var bezierForward = cc.bezierBy(2, controlPoints); + var rep = cc.sequence(bezierForward, delay, bezierForward.reverse(), delay.clone()).repeatForever(); + + // sprite 2 + this._tamara.x = 80; + this._tamara.y = 160; + + // 3 and only 3 control points should be used for Bezier actions. + var controlPoints2 = [ cc.p(100, s.height / 2), + cc.p(200, -s.height / 2), + cc.p(240, 160) ]; + var bezierTo1 = cc.bezierTo(2, controlPoints2); + + // // sprite 3 + var controlPoints3 = controlPoints2.slice(); + this._kathia.x = 400; + this._kathia.y = 160; + var bezierTo2 = cc.bezierTo(2, controlPoints3); + + this._grossini.runAction(rep); + this._tamara.runAction(bezierTo1); + this._kathia.runAction(bezierTo2); + //----end8---- + }, + title:function () { + return "cc.bezierBy / cc.bezierTo"; + }, + // + // Automation + // + testDuration:2.1, + setupAutomation:function() { + this.scheduleOnce(this.checkControl1, 0.66667); + this.scheduleOnce(this.checkControl2, 1.33333); + }, + checkControl1:function(dt) { + this.control1 = cc.p(this._grossini.x, this._grossini.y); + }, + verifyControl1:function(dt) { + var x = Math.abs( this.control1.x - 77 - winSize.width/2 ); + var y = Math.abs( this.control1.y - 87 - winSize.height/2 ); + // -/+ 5 pixels of error + return ( x < 5 && y < 5); + }, + checkControl2:function(dt) { + this.control2 = cc.p(this._grossini.x, this._grossini.y); + }, + verifyControl2:function(dt) { + var x = Math.abs( this.control2.x - 222 - winSize.width/2 ); + var y = Math.abs( this.control2.y + 53 - winSize.height/2 ); + // -/+ 5 pixels of error + return ( x < 5 && y < 5); + }, + + getExpectedResult:function() { + var ret = [ true, + true, + {"x":winSize.width/2+300,"y":winSize.height/2+100}]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = []; + ret.push( this.verifyControl1() ); + ret.push( this.verifyControl2() ); + ret.push( cc.p(this._grossini.x, this._grossini.y) ); + + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// ActionBezierToCopy +// +//------------------------------------------------------------------ +var ActionBezierToCopy = ActionsDemo.extend({ + onEnter:function () { + //----start9----onEnter + this._super(); + + // + // startPosition can be any coordinate, but since the movement + // is relative to the Bezier curve, make it (0,0) + // + + this.centerSprites(2); + + // sprite 1 + this._tamara.x = 80; + this._tamara.y = 160; + + // 3 and only 3 control points should be used for Bezier actions. + var controlPoints2 = [ cc.p(100, winSize.height / 2), + cc.p(200, -winSize.height / 2), + cc.p(240, 160) ]; + var bezierTo1 = cc.bezierTo(2, controlPoints2); + + // sprite 2 + this._kathia.x = 80; + this._kathia.y = 160; + var bezierTo2 = bezierTo1.clone(); + + this._tamara.runAction(bezierTo1); + this._kathia.runAction(bezierTo2); + //----end9---- + }, + title:function () { + return "cc.bezierTo copy test"; + }, + subtitle:function() { + return "Both sprites should move across the same path"; + } +}); +//------------------------------------------------------------------ +// +// Issue1008 +// +//------------------------------------------------------------------ +var Issue1008 = ActionsDemo.extend({ + onEnter:function () { + + //----start10----onEnter + this._super(); + + this.centerSprites(1); + + // sprite 1 + + this._grossini.x = 428; + this._grossini.y = 279; + + // 3 and only 3 control points should be used for Bezier actions. + var controlPoints1 = [ cc.p(428, 279), cc.p(100, 100), cc.p(100, 100)]; + var controlPoints2 = [ cc.p(100, 100), cc.p(428, 279), cc.p(428, 279)]; + + var bz1 = cc.bezierTo(1.5, controlPoints1); + var bz2 = cc.bezierTo(1.5, controlPoints2); + var trace = cc.callFunc(this.onTrace, this); + var delay = cc.delayTime(0.25); + + var rep = cc.sequence(bz1, bz2, trace,delay).repeatForever(); + this._grossini.runAction(rep); + + //----end10---- + + //this._grossini.runAction(cc.sequence(bz1, bz2, trace,delay)); + + }, + onTrace:function (sender) { + var pos = cc.p(sender.x, sender.y); + cc.log("Position x: " + pos.x + ' y:' + pos.y); + if (Math.round(pos.x) != 428 || Math.round(pos.y) != 279) + this.log("Error: Issue 1008 is still open"); + + this.tracePos = pos; + }, + title:function () { + return "Issue 1008"; + }, + subtitle:function () { + return "cc.bezierTo + Repeat. See console"; + }, + // + // Automation + // + testDuration:3.1, + getExpectedResult:function() { + var ret = {"x":428,"y":279}; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + return JSON.stringify(this.tracePos); + } +}); +//------------------------------------------------------------------ +// +// ActionBlink +// +//------------------------------------------------------------------ +var ActionBlink = ActionsDemo.extend({ + _code:"a = cc.blink( time, #_of_blinks );", + + onEnter:function () { + //----start13----onEnter + this._super(); + this.centerSprites(2); + + var action1 = cc.blink(2, 10); + var action2 = cc.blink(2, 5); + + this._tamara.runAction(action1); + this._kathia.runAction(action2); + //----end13---- + }, + title:function () { + return "cc.blink"; + }, + // + // Automation + // + testDuration:2.1, + setupAutomation:function() { + this.scheduleOnce(this.checkControl1,0.1); + }, + checkControl1:function(dt){ + this.control1 = this._kathia.visible; + }, + getExpectedResult:function() { + var ret = [false,true,true]; + return JSON.stringify(ret); + }, + getCurrentResult:function() { + var ret = []; + ret.push( this.control1 ); + ret.push( this._tamara.visible); + ret.push( this._kathia.visible); + return JSON.stringify(ret); + } +}); +//------------------------------------------------------------------ +// +// ActionFade +// +//------------------------------------------------------------------ +var ActionFade = ActionsDemo.extend({ + _code:"a = cc.fadeIn( time );\n" + + "a = cc.fadeOut( time );", + + onEnter:function () { + //----start14----onEnter + this._super(); + this.centerSprites(2); + var delay = cc.delayTime(0.25); + this._tamara.opacity = 0; + var action1 = cc.fadeIn(1.0); + var action1Back = action1.reverse(); + + var action2 = cc.fadeOut(1.0); + var action2Back = action2.reverse(); + + this._tamara.runAction(cc.sequence(action1, delay, action1Back)); + this._kathia.runAction(cc.sequence(action2, delay.clone(), action2Back)); + //----end14---- + + }, + title:function () { + return "cc.fadeIn / cc.fadeOut"; + }, + // + // Automation + // + testDuration:1.1, + getExpectedResult:function() { + var ret = [255,0]; + return JSON.stringify(ret); + }, + getCurrentResult:function() { + var ret = []; + ret.push( this._tamara.opacity ); + ret.push( this._kathia.opacity); + return JSON.stringify(ret); + } + +}); +//------------------------------------------------------------------ +// +// ActionTint +// +//------------------------------------------------------------------ +var ActionTint = ActionsDemo.extend({ + + _code:"a = cc.tintBy( time, red, green, blue );\n" + + "a = cc.tintTo( time, red, green, blue );", + + onEnter:function () { + + //----start15----onEnter + this._super(); + this.centerSprites(2); + + var action1 = cc.tintTo(2, 255, 0, 255); + var action2 = cc.tintBy(2, -127, -255, -127); + var action2Back = action2.reverse(); + + this._tamara.runAction(action1); + this._kathia.runAction(cc.sequence(action2, cc.delayTime(0.25), action2Back)); + //----end15---- + + }, + title:function () { + return "cc.tintTo / cc.tintBy"; + }, + // + // Automation + // + testDuration:2.1, + getExpectedResult:function() { + var ret = [{"r":255,"g":0,"b":255},{"r":128,"g":0,"b":128}]; + return JSON.stringify(ret); + }, + getCurrentResult:function() { + var ret = []; + ret.push( this._tamara.color ); + ret.push( this._kathia.color ); + return JSON.stringify(ret); + } + +}); + +//------------------------------------------------------------------ +// +// ActionAnimate +// +//------------------------------------------------------------------ +var ActionAnimate = ActionsDemo.extend({ + onEnter:function () { + + //----start44----onEnter + this._super(); + this.centerSprites(3); + + // + // Manual animation + // + var animation = new cc.Animation(); + for (var i = 1; i < 15; i++) { + var frameName = "res/Images/grossini_dance_" + ((i < 10) ? ("0" + i) : i) + ".png"; + animation.addSpriteFrameWithFile(frameName); + } + animation.setDelayPerUnit(2.8 / 14); + animation.setRestoreOriginalFrame(true); + + var action = cc.animate(animation); + this._grossini.runAction(cc.sequence(action, action.reverse())); + + // + // File animation + // + // With 2 loops and reverse + var animCache = cc.animationCache; + + animCache.addAnimations(s_animations2Plist); + var animation2 = animCache.getAnimation("dance_1"); + + var action2 = cc.animate(animation2); + this._tamara.runAction(cc.sequence(action2, action2.reverse())); + + // + // File animation + // + // with 4 loops + var animation3 = animation2.clone(); + animation3.setLoops(4); + + var action3 = cc.animate(animation3); + this._kathia.runAction(action3); + //----end44---- + }, + + title:function () { + return "Animation"; + }, + + subtitle:function () { + return "Center: Manual animation. Border: using file format animation"; + } +}); +//------------------------------------------------------------------ +// +// ActionSequence +// +//------------------------------------------------------------------ +var ActionSequence = ActionsDemo.extend({ + + _code:"a = cc.sequence( a1, a2, a3,..., aN);", + + onEnter:function () { + //----start16----onEnter + this._super(); + this.alignSpritesLeft(1); + + var action = cc.sequence( + cc.moveBy(1.5, cc.p(240, 0)), + cc.rotateBy(1.5, 540) + ); + + this._grossini.runAction(action); + //----end16---- + }, + title:function () { + return "cc.sequence: Move + Rotate"; + }, + // + // Automation + // + testDuration:3.1, + getExpectedResult:function() { + var ret = [{"x":60+240,"y":winSize.height/2},540]; + return JSON.stringify(ret); + }, + getCurrentResult:function() { + var ret = []; + ret.push( cc.p(this._grossini.x, this._grossini.y) ); + ret.push( this._grossini.rotation ); + return JSON.stringify(ret); + } +}); +//------------------------------------------------------------------ +// +// ActionSequence2 +// +//------------------------------------------------------------------ +var ActionSequence2 = ActionsDemo.extend({ + onEnter:function () { + + //----start17----onEnter + this._super(); + this.centerSprites(1); + this._grossini.visible = false; + var action = cc.sequence( + cc.place(cc.p(200, 200)), + cc.show(), + cc.moveBy(1, cc.p(100, 0)), + cc.callFunc(this.onCallback1, this), + cc.callFunc(this.onCallback2.bind(this)), + cc.callFunc(this.onCallback3, this)); + this._grossini.runAction(action); + + this.called1 = this.called2 = this.called3 = false; + //----end17---- + }, + onCallback1:function () { + var s = director.getWinSize(); + var label = new cc.LabelTTF("callback 1 called", "Marker Felt", 16); + label.x = s.width / 4 * 1; + label.y = s.height / 2; + + this.addChild(label); + this.called1 = true; + }, + onCallback2:function () { + var s = director.getWinSize(); + var label = new cc.LabelTTF("callback 2 called", "Marker Felt", 16); + label.x = s.width / 4 * 2; + label.y = s.height / 2; + + this.addChild(label); + this.called2 = true; + }, + onCallback3:function () { + var s = director.getWinSize(); + var label = new cc.LabelTTF("callback 3 called", "Marker Felt", 16); + label.x = s.width / 4 * 3; + label.y = s.height / 2; + + this.addChild(label); + this.called3 = true; + }, + title:function () { + return "Sequence of InstantActions"; + }, + // + // Automation + // + testDuration:1.1, + getExpectedResult:function() { + var ret = [true,true,true,true,{"x":300,"y":200}]; + return JSON.stringify(ret); + }, + getCurrentResult:function() { + var ret = []; + ret.push( this.called1 ); + ret.push( this.called2 ); + ret.push( this.called3 ); + ret.push( this._grossini.visible ); + ret.push( cc.p(this._grossini.x, this._grossini.y) ); + return JSON.stringify(ret); + } +}); +//------------------------------------------------------------------ +// +// ActionCallFunc1 +// +//------------------------------------------------------------------ +var ActionCallFunc1 = ActionsDemo.extend({ + _code:"a = cc.callFunc( this.callback );\n" + + "a = cc.callFunc( this.callback, this, optional_arg );", + + onEnter:function () { + //----start25----onEnter + this._super(); + this.centerSprites(3); + + // Testing different ways to pass "this" + var action = cc.sequence( + cc.moveBy(2, cc.p(200, 0)), + cc.callFunc(this.onCallback1.bind(this)) // 'this' is bound to the callback function using "bind" + ); + + var action2 = cc.sequence( + cc.scaleBy(2, 2), + cc.fadeOut(2), + cc.callFunc(this.onCallback2, this) // 'this' is passed as 2nd argument. + ); + + var action3 = cc.sequence( + cc.rotateBy(3, 360), + cc.fadeOut(2), + cc.callFunc(this.onCallback3, this, "Hi!") // If you want to pass a optional value, like "Hi!", then you should pass 'this' too + ); + + this._grossini.runAction(action); + this._tamara.runAction(action2); + this._kathia.runAction(action3); + //----end25---- + + }, + onCallback1:function (nodeExecutingAction, value) { + var s = director.getWinSize(); + var label = new cc.LabelTTF("callback 1 called", "Marker Felt", 16); + label.x = s.width / 4 * 1; + label.y = s.height / 2; + this.addChild(label); + this.control1 = true; + }, + onCallback2:function (nodeExecutingAction, value) { + var s = director.getWinSize(); + var label = new cc.LabelTTF("callback 2 called", "Marker Felt", 16); + label.x = s.width / 4 * 2; + label.y = s.height / 2; + + this.addChild(label); + this.control2 = true; + }, + onCallback3:function (nodeExecutingAction, value) { + var s = director.getWinSize(); + var label = new cc.LabelTTF("callback 3 called:" + value, "Marker Felt", 16); + label.x = s.width / 4 * 3; + label.y = s.height / 2; + this.addChild(label); + this.control3 = true; + }, + title:function () { + return "Callbacks: CallFunc and friends"; + }, + // + // Automation + // + testDuration:5.05, + setupAutomation:function() { + this.control1 = this.control2 = this.control3 = false; + }, + getExpectedResult:function() { + var ret = [true,true,true]; + return JSON.stringify(ret); + }, + getCurrentResult:function() { + var ret = []; + ret.push( this.control1 ); + ret.push( this.control2 ); + ret.push( this.control3 ); + return JSON.stringify(ret); + } +}); +//------------------------------------------------------------------ +// +// ActionCallFunc2 +// +//------------------------------------------------------------------ +var ActionCallFunc2 = ActionsDemo.extend({ + onEnter:function () { + //----start26----onEnter + this._super(); + this.centerSprites(1); + + var action = cc.sequence(cc.moveBy(2.0, cc.p(200, 0)), + cc.callFunc(this.removeFromParentAndCleanup, this._grossini, true)); + + this._grossini.runAction(action); + //----end26---- + }, + + removeFromParentAndCleanup:function (nodeExecutingAction, data) { + nodeExecutingAction.removeFromParent(data); + }, + + title:function () { + return "cc.CallFunc + auto remove"; + }, + subtitle:function () { + return "cc.CallFunc + removeFromParentAndCleanup. Grossini dissapears in 2s"; + }, + // + // Automation + // + testDuration:2.1, + setupAutomation:function() { + }, + getExpectedResult:function() { + var ret = [null]; + return JSON.stringify(ret); + }, + getCurrentResult:function() { + var ret = []; + ret.push( this.getChildByTag(SPRITE_GROSSINI_TAG) ); + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// ActionCallFunc3 +// +//------------------------------------------------------------------ +var ActionCallFunc3 = ActionsDemo.extend({ + onEnter:function () { + //----start27----onEnter + this._super(); + this.centerSprites(1); + + var action = cc.callFunc(function (nodeExecutingAction, value) { + this.control1 = "Value is: " + value; + this.log("Object:" + nodeExecutingAction + ". " + this.control1); + }, this, "Hello world"); + + this.runAction(action); + //----end27---- + }, + + title:function () { + return "cc.CallFunc + parameters"; + }, + subtitle:function () { + return "cc.CallFunc + parameters. Take a look at the console"; + }, + // + // Automation + // + testDuration:0.1, + setupAutomation:function() { + }, + getExpectedResult:function() { + var ret = ["Value is: Hello world"]; + return JSON.stringify(ret); + }, + getCurrentResult:function() { + var ret = []; + ret.push( this.control1 ); + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// ActionSpawn +// +//------------------------------------------------------------------ +var ActionSpawn = ActionsDemo.extend({ + + _code:"a = cc.spawn( a1, a2, ..., aN );", + + onEnter:function () { + + //----start18----onEnter + this._super(); + this.alignSpritesLeft(1); + + var action = cc.spawn( + cc.jumpBy(2, cc.p(300, 0), 50, 4), + cc.rotateBy(2, 720)); + + this._grossini.runAction(action); + //----end18---- + + }, + title:function () { + return "cc.spawn: Jump + Rotate"; + }, + // + // Automation + // + testDuration:2.1, + getExpectedResult:function() { + var ret = [{"x":300+60,"y":winSize.height/2},720]; + return JSON.stringify(ret); + }, + getCurrentResult:function() { + var ret = []; + ret.push( cc.p(this._grossini.x, this._grossini.y) ); + ret.push( this._grossini.rotation ); + return JSON.stringify(ret); + } +}); +//------------------------------------------------------------------ +// +// ActionRepeatForever +// +//------------------------------------------------------------------ +var ActionRepeatForever = ActionsDemo.extend({ + _code:"a = action.repeatForever();", + + onEnter:function () { + //----start22----onEnter + this._super(); + this.centerSprites(1); + var action = cc.sequence( + cc.delayTime(1), + cc.callFunc(this.repeatForever)); // not passing 'this' since it is not used by the callback func + + this._grossini.runAction(action); + //----end22---- + + }, + repeatForever:function (sender) { + var repeat = cc.rotateBy(1, 360).repeatForever(); + sender.runAction(repeat); + }, + title:function () { + return "cc.CallFunc + cc.RepeatForever"; + }, + // + // Automation + // + testDuration:3.5, + getExpectedResult:function() { + var ret = [true]; + return JSON.stringify(ret); + }, + getCurrentResult:function() { + var ret = []; + var r = this._grossini.rotation; + var expected = 900; + var error = 15; + ret.push( r < expected+error && r > expected-error ); + return JSON.stringify(ret); + } + +}); +//------------------------------------------------------------------ +// +// ActionRotateToRepeat +// +//------------------------------------------------------------------ +var ActionRotateToRepeat = ActionsDemo.extend({ + _code:"a = action_to_repeat.repeat(#_of_times);", + + onEnter:function () { + //----start23----onEnter + this._super(); + this.centerSprites(2); + + var act1 = cc.rotateTo(0.5, 90); + var act2 = cc.rotateTo(0.5, 0); + var seq = cc.sequence(act1, act2); + var seq2 = seq.clone(); + + this._tamara.runAction(seq.repeatForever()); + this._kathia.runAction(seq2.repeat(4)); + //----end23---- + + }, + title:function () { + return "Repeat/RepeatForever + RotateTo"; + }, + // + // Automation + // + testDuration:4.5, + getExpectedResult:function() { + var ret = [0,true]; + return JSON.stringify(ret); + }, + getCurrentResult:function() { + var ret = []; + ret.push( this._kathia.rotation ); + var r = this._tamara.rotation; + var expected = 90; + var error = 15; + ret.push( r < expected+error && r > expected-error ); + return JSON.stringify(ret); + } + +}); +//------------------------------------------------------------------ +// +// ActionRotateJerk +// +//------------------------------------------------------------------ +var ActionRotateJerk = ActionsDemo.extend({ + onEnter:function () { + //----start24----onEnter + this._super(); + this.centerSprites(2); + var seq = cc.sequence( + cc.rotateTo(0.5, -20), + cc.rotateTo(0.5, 20)); + + var rep1 = seq.repeat(10); + var rep2 = seq.clone().repeatForever(); + this._tamara.runAction(rep1); + this._kathia.runAction(rep2); + //----end24---- + }, + title:function () { + return "RepeatForever / Repeat + Rotate"; + } +}); +//------------------------------------------------------------------ +// +// ActionReverse +// +//------------------------------------------------------------------ +var ActionReverse = ActionsDemo.extend({ + + _code:"a = action.reverse();", + + onEnter:function () { + + //----start19----onEnter + this._super(); + this.alignSpritesLeft(1); + + var jump = cc.jumpBy(2, cc.p(300, 0), 50, 4); + var delay = cc.delayTime(0.25); + var action = cc.sequence(jump, delay, jump.reverse()); + + this._grossini.runAction(action); + //----end19---- + }, + title:function () { + return "Reverse Jump action"; + }, + + // + // Automation + // + testDuration:4.4, + setupAutomation:function() { + this.scheduleOnce(this.checkControl1,2.1); + }, + checkControl1:function(dt) { + this.control1 = cc.p(this._grossini.x, this._grossini.y); + }, + getExpectedResult:function() { + var ret = [{"x":360,"y":winSize.height/2},{"x":60,"y":winSize.height/2}]; + return JSON.stringify(ret); + }, + getCurrentResult:function() { + var ret = []; + ret.push( this.control1 ); + ret.push( cc.p(this._grossini.x, this._grossini.y) ); + return JSON.stringify(ret); + } + +}); +//------------------------------------------------------------------ +// +// ActionDelayTime +// +//------------------------------------------------------------------ +var ActionDelayTime = ActionsDemo.extend({ + + _code:"a = cc.delayTime( time );", + + onEnter:function () { + //----start20----onEnter + this._super(); + this.alignSpritesLeft(1); + + var move = cc.moveBy(1, cc.p(150, 0)); + var action = cc.sequence(move, cc.delayTime(2), move.clone()); + + this._grossini.runAction(action); + //----end20---- + }, + title:function () { + return "DelayTime: m + delay + m"; + }, + // + // Automation + // + testDuration:2.9, + getExpectedResult:function() { + var ret = [{"x":210,"y":winSize.height/2}]; + return JSON.stringify(ret); + }, + getCurrentResult:function() { + var ret = []; + ret.push( cc.p(this._grossini.x, this._grossini.y) ); + return JSON.stringify(ret); + } +}); +//------------------------------------------------------------------ +// +// ActionReverseSequence +// +//------------------------------------------------------------------ +var ActionReverseSequence = ActionsDemo.extend({ + onEnter:function () { + + //----start28----onEnter + this._super(); + this.alignSpritesLeft(1); + + var move1 = cc.moveBy(1, cc.p(250, 0)); + var move2 = cc.moveBy(1, cc.p(0, 50)); + var seq = cc.sequence(move1, move2, move1.reverse()); + var action = cc.sequence(seq, seq.reverse()); + + this._grossini.runAction(action); + //----end28---- + + }, + subtitle:function () { + return "Reverse a sequence"; + } +}); +//------------------------------------------------------------------ +// +// ActionReverseSequence2 +// +//------------------------------------------------------------------ +var ActionReverseSequence2 = ActionsDemo.extend({ + onEnter:function () { + + //----start29----onEnter + this._super(); + this.alignSpritesLeft(2); + + + // Test: + // Sequence should work both with IntervalAction and InstantActions + var move1 = cc.moveBy(3, cc.p(250, 0)); + var move2 = cc.moveBy(3, cc.p(0, 50)); + var tog1 = cc.toggleVisibility(); + var tog2 = cc.toggleVisibility(); + var seq = cc.sequence(move1, tog1, move2, tog2, move1.reverse()); + + var action = cc.sequence(seq, seq.reverse()).repeat(3); + + + // Test: + // Also test that the reverse of Hide is Show, and vice-versa + this._kathia.runAction(action); + + var move_tamara = cc.moveBy(1, cc.p(100, 0)); + var move_tamara2 = cc.moveBy(1, cc.p(50, 0)); + var hide = cc.hide(); + var seq_tamara = cc.sequence(move_tamara, hide, move_tamara2); + var seq_back = seq_tamara.reverse(); + this._tamara.runAction(cc.sequence(seq_tamara, seq_back)); + //----end29---- + }, + subtitle:function () { + return "Reverse sequence 2"; + } +}); +//------------------------------------------------------------------ +// +// ActionRepeat +// +//------------------------------------------------------------------ +var ActionRepeat = ActionsDemo.extend({ + onEnter:function () { + //----start21----onEnter + this._super(); + this.alignSpritesLeft(2); + + + var a1 = cc.moveBy(1, cc.p(150, 0)); + + var action1 = cc.sequence(cc.place(cc.p(60, 60)), a1).repeat(3); + var action2 = cc.sequence( a1.clone(), a1.reverse(), cc.delayTime(0.25)).repeatForever(); + + this._kathia.runAction(action1); + this._tamara.runAction(action2); + //----end21---- + }, + title:function () { + return "Repeat / RepeatForever actions"; + }, + // + // Automation + // + testDuration:4.30, + getExpectedResult:function() { + var ret = [{"x":210,"y":60},{"x":60,"y":2*winSize.height/3}]; + return JSON.stringify(ret); + }, + getCurrentResult:function() { + var ret = []; + ret.push( cc.p(this._kathia.x, this._kathia.y) ); + ret.push( cc.p(this._tamara.x, this._tamara.y) ); + return JSON.stringify(ret); + } + +}); +//------------------------------------------------------------------ +// +// ActionOrbit +// +//------------------------------------------------------------------ +var ActionOrbit = ActionsDemo.extend({ + onEnter:function () { + this._super(); + this.centerSprites(3); + + var orbit1 = cc.orbitCamera(2, 1, 0, 0, 180, 0, 0); + var action1 = cc.sequence( + orbit1, + orbit1.reverse()); + + var orbit2 = cc.orbitCamera(2, 1, 0, 0, 180, -45, 0); + var action2 = cc.sequence( + orbit2, + orbit2.reverse()); + + var orbit3 = cc.orbitCamera(2, 1, 0, 0, 180, 90, 0); + var action3 = cc.sequence( + orbit3, + orbit3.reverse()); + + this._kathia.runAction(action1.repeatForever()); + this._tamara.runAction(action2.repeatForever()); + this._grossini.runAction(action3.repeatForever()); + + var move = cc.moveBy(3, cc.p(100, -100)); + var move_back = move.reverse(); + var seq = cc.sequence(move, move_back); + + var rfe = seq.repeatForever(); + + this._kathia.runAction(rfe); + this._tamara.runAction((rfe.clone())); + this._grossini.runAction((rfe.clone())); + + }, + subtitle:function () { + return "OrbitCamera action"; + } +}); +//------------------------------------------------------------------ +// +// ActionFollow +// +//------------------------------------------------------------------ +var ActionFollow = ActionsDemo.extend({ + onEnter:function () { + + //----start30----onEnter + this._super(); + this.centerSprites(1); + var s = director.getWinSize(); + + this._grossini.x = -(s.width / 2); + this._grossini.y = s.height / 2; + var move = cc.moveBy(2, cc.p(s.width * 3, 0)); + var move_back = move.reverse(); + var seq = cc.sequence(move, move_back); + + var rep = seq.repeatForever(); + + this._grossini.runAction(rep); + + this.runAction(cc.follow(this._grossini, cc.rect(0, 0, s.width * 2 - 100, s.height))); + //----end30---- + }, + subtitle:function () { + return "Follow action"; + } +}); + +//------------------------------------------------------------------ +// +// ActionCardinalSpline +// +//------------------------------------------------------------------ +var ActionCardinalSpline = ActionsDemo.extend({ + _array:null, + _drawNode1: null, + _drawNode2: null, + + _code:" a = cc.cadinalSplineBy( time, array_of_points, tension );\n" + + " a = cc.cadinalSplineTo( time, array_of_points, tension );", + + ctor:function () { + this._super(); + this._array = []; + + //add draw node + var winSize = cc.director.getWinSize(); + this._drawNode1 = new cc.DrawNode(); + this.addChild(this._drawNode1); + this._drawNode1.x = 50; + this._drawNode1.y = 50; + this._drawNode1.setDrawColor(cc.color(255,255,255,255)); + + this._drawNode2 = new cc.DrawNode(); + this.addChild(this._drawNode2); + this._drawNode2.x = winSize.width * 0.5; + this._drawNode2.y = 50; + this._drawNode2.setDrawColor(cc.color(255,255,255,255)); + }, + + onEnter:function () { + + //----start11----onEnter + this._super(); + var winSize = cc.director.getWinSize(); + this.centerSprites(2); + + var delay = cc.delayTime(0.25); + + var array = [ + cc.p(0, 0), + cc.p(winSize.width / 2 - 30, 0), + cc.p(winSize.width / 2 - 30, winSize.height - 80), + cc.p(0, winSize.height - 80), + cc.p(0, 0) + ]; + + // + // sprite 1 (By) + // + // Spline with no tension (tension==0) + // + var action1 = cc.cardinalSplineBy(2, array, 0); + var reverse1 = action1.reverse(); + var seq = cc.sequence(action1, delay, reverse1, delay.clone() ); + + this._tamara.x = 50; + this._tamara.y = 50; + this._tamara.runAction(seq); + + // + // sprite 2 (By) + // + // Spline with high tension (tension==1) + // + var action2 = cc.cardinalSplineBy(2, array, 1); + var reverse2 = action2.reverse(); + var seq2 = cc.sequence(action2, delay.clone(), reverse2, delay.clone()); + + this._kathia.x = winSize.width / 2; + this._kathia.y = 50; + this._kathia.runAction(seq2); + + this._drawNode1.drawCardinalSpline(array, 0, 100, 1); + this._drawNode2.drawCardinalSpline(array, 1, 100, 1); + //----end11---- + }, + + subtitle:function () { + return "Cardinal Spline paths. Testing different tensions for one array"; + }, + title:function () { + return "CardinalSplineBy / CardinalSplineAt"; + }, + // + // Automation + // + testDuration:2.1, + setupAutomation:function() { + this.scheduleOnce(this.checkControl1, 0.5); + this.scheduleOnce(this.checkControl2, 1.0); + this.scheduleOnce(this.checkControl3, 1.5); + }, + checkControl1:function(dt) { + this.control1 = cc.p(this._tamara.x, this._tamara.y); + }, + verifyControl1:function(dt) { + var x = Math.abs( 50 + winSize.width/2 - 30 - this.control1.x); + var y = Math.abs( 50 - this.control1.y); + // -/+ 5 pixels of error + return ( x < 5 && y < 5); + }, + checkControl2:function(dt) { + this.control2 = cc.p(this._tamara.x, this._tamara.y); + }, + verifyControl2:function(dt) { + var x = Math.abs( 50 + winSize.width/2 - 30 - this.control2.x ); + var y = Math.abs( 50 + winSize.height - 80 - this.control2.y ); + // -/+ 5 pixels of error + return ( x < 5 && y < 5); + }, + checkControl3:function(dt) { + this.control3 = cc.p(this._tamara.x, this._tamara.y); + }, + verifyControl3:function(dt) { + var x = Math.abs( 50 - this.control3.x ); + var y = Math.abs( 50 + winSize.height - 80 - this.control3.y ); + // -/+ 5 pixels of error + return ( x < 5 && y < 5); + }, + + getExpectedResult:function() { + var ret = [ true, + true, + true, + {"x":50,"y":50}]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = []; + ret.push( this.verifyControl1() ); + ret.push( this.verifyControl2() ); + ret.push( this.verifyControl3() ); + ret.push( cc.p(this._tamara.x, this._tamara.y) ); + + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// ActionCatmullRom +// +//------------------------------------------------------------------ +var ActionCatmullRom = ActionsDemo.extend({ + _drawNode1: null, + _drawNode2: null, + + _code:"a = cc.catmullRomBy( time, array_of_points );\n" + + " a = cc.catmullRomTo( time, array_of_points );", + + ctor:function () { + this._super(); + + this._drawNode1 = new cc.DrawNode(); + this._drawNode1.x = 50; + this._drawNode1.y = 50; + this._drawNode1.setDrawColor(cc.color(255,255,255,255)); + this.addChild(this._drawNode1); + + this._drawNode2 = new cc.DrawNode(); + this._drawNode2.setDrawColor(cc.color(255,255,255,255)); + this.addChild(this._drawNode2); + }, + + onEnter:function () { + + //----start12----onEnter + this._super(); + + this.centerSprites(2); + + var delay = cc.delayTime(0.25); + + // + // sprite 1 (By) + // + // startPosition can be any coordinate, but since the movement + // is relative to the Catmull Rom curve, it is better to start with (0,0). + // + this._tamara.x = 50; + this._tamara.y = 50; + + var array = [ + cc.p(0, 0), + cc.p(80, 80), + cc.p(winSize.width - 80, 80), + cc.p(winSize.width - 80, winSize.height - 80), + cc.p(80, winSize.height - 80), + cc.p(80, 80), + cc.p(winSize.width / 2, winSize.height / 2) + ]; + + var action1 = cc.catmullRomBy(3, array); + var reverse1 = action1.reverse(); + var seq1 = cc.sequence(action1, delay, reverse1); + + this._tamara.runAction(seq1); + + // + // sprite 2 (To) + // + // The startPosition is not important here, because it uses a "To" action. + // The initial position will be the 1st point of the Catmull Rom path + // + var array2 = [ + cc.p(winSize.width / 2, 30), + cc.p(winSize.width - 80, 30), + cc.p(winSize.width - 80, winSize.height - 80), + cc.p(winSize.width / 2, winSize.height - 80), + cc.p(winSize.width / 2, 30) ]; + + var action2 = cc.catmullRomTo(3, array2); + var reverse2 = action2.reverse(); + + var seq2 = cc.sequence(action2, delay.clone(), reverse2); + + this._kathia.runAction(seq2); + + this._drawNode1.drawCatmullRom(array,50, 1); + this._drawNode2.drawCatmullRom(array2,50, 1); + //----end12---- + }, + subtitle:function () { + return "Catmull Rom spline paths. Testing reverse too"; + }, + title:function () { + return "CatmullRomBy / CatmullRomTo"; + }, + // + // Automation + // + testDuration:3.1, + setupAutomation:function() { + this.scheduleOnce(this.checkControl1, 3 / 4 * 0); + this.scheduleOnce(this.checkControl2, 3 / 4 * 1); + this.scheduleOnce(this.checkControl3, 3 / 4 * 2); + }, + checkControl1:function(dt) { + this.control1 = cc.p(this._kathia.x, this._kathia.y); + }, + verifyControl1:function(dt) { + var x = Math.abs( winSize.width/2 - this.control1.x); + var y = Math.abs( 30 - this.control1.y); + // -/+ 5 pixels of error + return ( x < 5 && y < 5); + }, + checkControl2:function(dt) { + this.control2 = cc.p(this._kathia.x, this._kathia.y); + }, + verifyControl2:function(dt) { + var x = Math.abs( winSize.width - 80 - this.control2.x ); + var y = Math.abs( 30 - this.control2.y ); + // -/+ 5 pixels of error + return ( x < 5 && y < 5); + }, + checkControl3:function(dt) { + this.control3 = cc.p(this._kathia.x, this._kathia.y); + }, + verifyControl3:function(dt) { + var x = Math.abs( winSize.width - 80 - this.control3.x ); + var y = Math.abs( winSize.height - 80 - this.control3.y ); + // -/+ 5 pixels of error + return ( x < 5 && y < 5); + }, + + getExpectedResult:function() { + var ret = [ true, + true, + true, + {"x":winSize.width/2,"y":30}]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = []; + ret.push( this.verifyControl1() ); + ret.push( this.verifyControl2() ); + ret.push( this.verifyControl3() ); + ret.push( cc.p(this._kathia.x, this._kathia.y) ); + + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// ActionTargeted +// +//------------------------------------------------------------------ +var ActionTargeted = ActionsDemo.extend({ + _code:"a = cc.targetedAction( target, action );", + + onEnter:function () { + //----start31----onEnter + this._super(); + this.centerSprites(2); + + var jump1 = cc.jumpBy(2, cc.p(0, 0), 100, 3); + var jump2 = jump1.clone(); + var rot1 = cc.rotateBy(1, 360); + var rot2 = rot1.clone(); + + var t1 = cc.targetedAction(this._kathia, jump2); + var t2 = cc.targetedAction(this._kathia, rot2); + + var seq = cc.sequence(jump1, t1, rot1, t2); + + var always = seq.repeatForever(); + + this._tamara.runAction(always); + //----end31---- + }, + title:function () { + return "Action that runs on another target. Useful for sequences"; + }, + subtitle:function () { + return "ActionTargeted"; + } +}); + +//------------------------------------------------------------------ +// +// ActionTargetedCopy +// +//------------------------------------------------------------------ +var ActionTargetedCopy = ActionsDemo.extend({ + onEnter:function () { + //----start32----onEnter + this._super(); + this.centerSprites(2); + + var jump1 = cc.jumpBy(2, cc.p(0, 0), 100, 3); + var jump2 = jump1.clone(); + + var t1 = cc.targetedAction(this._kathia, jump2); + var t_copy = t1.clone(); + + var seq = cc.sequence(jump1, t_copy); + + this._tamara.runAction(seq); + //----end32---- + }, + title:function () { + return "Action that runs on another target. Useful for sequences"; + }, + subtitle:function () { + return "Testing copy on TargetedAction"; + } +}); + +//------------------------------------------------------------------ +// +// ActionStackableMove +// +//------------------------------------------------------------------ +var ActionStackableMove = ActionsDemo.extend({ + onEnter:function () { + //----start33----onEnter + this._super(); + this.centerSprites(1); + + this._grossini.x = 40; + this._grossini.y = winSize.height / 2; + + // shake + var move = cc.moveBy(0.2, cc.p(0,50)); + var move_back = move.reverse(); + var delay = cc.delayTime(0.25); + var move_seq = cc.sequence( move, move_back ); + var move_rep = move_seq.repeatForever(); + this._grossini.runAction( move_rep ); + + // move + var action = cc.moveBy(2, cc.p(winSize.width - 80, 0)); + var back = action.reverse(); + var seq = cc.sequence(action, back); + var repeat = seq.repeatForever(); + this._grossini.runAction(repeat); + //----end33---- + + }, + title:function () { + return "Stackable actions: MoveBy + MoveBy"; + }, + subtitle:function () { + return "Grossini shall move up and down while moving horizontally"; + }, + // + // Automation + // + testDuration:0.2, + getExpectedResult:function() { + var ret = [true, true]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = []; + var x = this._grossini.x, y = this._grossini.y; + var error = 10; + var expected_x = 40 + 0.2 * (winSize.width-80) / 2; + var expected_y =winSize.height/2 + 50; + var ret_x = x < expected_x+error && x > expected_x-error; + var ret_y = y < expected_y+error && y > expected_y-error; + ret.push( ret_x ); + ret.push( ret_y ); + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// ActionStackableJump +// +//------------------------------------------------------------------ +var ActionStackableJump = ActionsDemo.extend({ + onEnter:function () { + + //----start34----onEnter + this._super(); + this.centerSprites(1); + + this._grossini.x = 40; + this._grossini.y = winSize.height / 2; + + // shake + var move = cc.moveBy(0.05, cc.p(8, 8)); + var move_back = move.reverse(); + var move_seq = cc.sequence(move, move_back); + var move_rep = move_seq.repeatForever(); + this._grossini.runAction(move_rep); + + // jump + var action = cc.jumpBy(2, cc.p(winSize.width - 80, 0), 90, 5); + var back = action.reverse(); + var seq = cc.sequence(action, back); + var repeat = seq.repeatForever(); + this._grossini.runAction(repeat); + //----end34---- + + }, + title:function () { + return "Stackable actions: MoveBy + JumpBy"; + }, + subtitle:function () { + return "Grossini shall shake while he is jumping"; + } +}); + +//------------------------------------------------------------------ +// +// ActionStackableBezier +// +//------------------------------------------------------------------ +var ActionStackableBezier = ActionsDemo.extend({ + onEnter:function () { + //----start35----onEnter + this._super(); + this.centerSprites(1); + + this._grossini.x = 40; + this._grossini.y = winSize.height / 2; + + // shake + var move = cc.moveBy(0.05, cc.p(8, 8)); + var move_back = move.reverse(); + var move_seq = cc.sequence(move, move_back); + var move_rep = move_seq.repeatForever(); + this._grossini.runAction(move_rep); + + // Bezier + var controlPoints = [ cc.p(0, winSize.height / 2), + cc.p(winSize.width - 80, -winSize.height / 2), + cc.p(winSize.width - 80, 100) ]; + + var bezierForward = cc.bezierBy(3, controlPoints); + var repeat = cc.sequence(bezierForward, bezierForward.reverse()).repeatForever(); + this._grossini.runAction(repeat); + //----end35---- + + }, + title:function () { + return "Stackable actions: MoveBy + BezierBy"; + }, + subtitle:function () { + return "Grossini shall shake while he moves along a bezier path"; + } +}); + +//------------------------------------------------------------------ +// +// ActionStackableCatmullRom +// +//------------------------------------------------------------------ +var ActionStackableCatmullRom = ActionsDemo.extend({ + onEnter:function () { + //----start36----onEnter + this._super(); + this.centerSprites(1); + + this._grossini.x = 40; + this._grossini.y = 40; + + // shake + var move = cc.moveBy(0.05, cc.p(8, 8)); + var move_back = move.reverse(); + var move_seq = cc.sequence(move, move_back); + var move_rep = move_seq.repeatForever(); + this._grossini.runAction(move_rep); + + // CatmullRom + var array = [ + cc.p(0, 0), + cc.p(80, 80), + cc.p(winSize.width - 80, 80), + cc.p(winSize.width - 80, winSize.height - 80), + cc.p(80, winSize.height - 80), + cc.p(80, 80), + cc.p(winSize.width / 2, winSize.height / 2) + ]; + + var action1 = cc.catmullRomBy(6, array); + var reverse1 = action1.reverse(); + var seq1 = cc.sequence(action1, reverse1); + var repeat = seq1.repeatForever(); + this._grossini.runAction(repeat); + //----end36---- + }, + title:function () { + return "Stackable actions: MoveBy + CatmullRomBy"; + }, + subtitle:function () { + return "Grossini shall shake while he moves along a CatmullRom path"; + } +}); + +//------------------------------------------------------------------ +// +// ActionStackableCardinalSpline +// +//------------------------------------------------------------------ +var ActionStackableCardinalSpline = ActionsDemo.extend({ + onEnter:function () { + //----start37----onEnter + this._super(); + this.centerSprites(1); + + this._grossini.x = 40; + this._grossini.y = 40; + + // shake + var move = cc.moveBy(0.05, cc.p(8, 8)); + var move_back = move.reverse(); + var move_seq = cc.sequence(move, move_back); + var move_rep = move_seq.repeatForever(); + this._grossini.runAction(move_rep); + + // CardinalSpline + var array = [ + cc.p(0, 0), + cc.p(80, 80), + cc.p(winSize.width - 80, 80), + cc.p(winSize.width - 80, winSize.height - 80), + cc.p(80, winSize.height - 80), + cc.p(80, 80), + cc.p(winSize.width / 2, winSize.height / 2) + ]; + + var action1 = cc.cardinalSplineBy(6, array, 0.9); + var reverse1 = action1.reverse(); + var seq1 = cc.sequence(action1, reverse1); + var repeat = seq1.repeatForever(); + this._grossini.runAction(repeat); + //----end37---- + }, + title:function () { + return "Stackable actions: MoveBy + CardinalSplineBy"; + }, + subtitle:function () { + return "Grossini shall shake while he moves along a CardinalSpline path"; + } +}); + +//------------------------------------------------------------------ +// +// PauseResumeActions +// +//------------------------------------------------------------------ +var PauseResumeActions = ActionsDemo.extend({ + _pausedTargets:[], + onEnter:function () { + //----start38----onEnter + this._super(); + this.centerSprites(2); + + this._tamara.runAction(cc.rotateBy(3, 360).repeatForever()); + this._grossini.runAction(cc.rotateBy(3, -360).repeatForever()); + this._kathia.runAction(cc.rotateBy(3, 360).repeatForever()); + + this.schedule(this.pause, 3, false, 0); + this.schedule(this.resume, 5, false, 0); + //----end38---- + }, + + pause:function () { + cc.log("Pausing"); + this._pausedTargets = director.getActionManager().pauseAllRunningActions(); + }, + resume:function () { + cc.log("Resuming"); + director.getActionManager().resumeTargets(this._pausedTargets); + }, + + title:function () { + return "PauseResumeActions"; + }, + subtitle:function () { + return "All actions pause at 3s and resume at 5s"; + } +}); + +//------------------------------------------------------------------ +// +// Issue1305 +// +//------------------------------------------------------------------ +var Issue1305 = ActionsDemo.extend({ + _spriteTemp:null, + onEnter:function () { + //----start39----onEnter + this._super(); + this.centerSprites(0); + + this._spriteTmp = new cc.Sprite(s_pathGrossini); + /* c++ can't support block, so we use CCCallFuncN instead. + [spriteTmp_ runAction:[CCCallBlockN actionWithBlock:^(CCNode* node) { + NSLog(@"This message SHALL ONLY appear when the sprite is added to the scene, NOT BEFORE"); + }] ]; + */ + + this._spriteTmp.runAction(cc.callFunc(this.onLog, this)); + this.scheduleOnce(this.onAddSprite, 2); + //----end39---- + }, + onExit:function () { + this._super(); + }, + onLog:function (pSender) { + cc.log("This message SHALL ONLY appear when the sprite is added to the scene, NOT BEFORE"); + }, + onAddSprite:function (dt) { + this._spriteTmp.x = 250; + this._spriteTmp.y = 250; + this.addChild(this._spriteTmp); + }, + title:function () { + return "Issue 1305"; + }, + subtitle:function () { + return "In two seconds you should see a message on the console. NOT BEFORE."; + } +}); + +//------------------------------------------------------------------ +// +// Issue1305_2 +// +//------------------------------------------------------------------ +var Issue1305_2 = ActionsDemo.extend({ + onEnter:function () { + //----start40----onEnter + this._super(); + this.centerSprites(0); + + var spr = new cc.Sprite(s_pathGrossini); + spr.x = 200; + spr.y = 200; + this.addChild(spr); + + var act1 = cc.moveBy(2, cc.p(0, 100)); + + var act2 = cc.callFunc(this.onLog1); + var act3 = cc.moveBy(2, cc.p(0, -100)); + var act4 = cc.callFunc(this.onLog2, this); + var act5 = cc.moveBy(2, cc.p(100, -100)); + var act6 = cc.callFunc(this.onLog3.bind(this)); + var act7 = cc.moveBy(2, cc.p(-100, 0)); + var act8 = cc.callFunc(this.onLog4, this); + + var actF = cc.sequence(act1, act2, act3, act4, act5, act6, act7, act8); + + // [spr runAction:actF]; + director.getActionManager().addAction(actF, spr, false); + //----end40---- + }, + onLog1:function () { + cc.log("1st block"); + }, + onLog2:function () { + cc.log("2nd block"); + }, + onLog3:function () { + cc.log("3rd block"); + }, + onLog4:function () { + cc.log("4th block"); + }, + title:function () { + return "Issue 1305 #2"; + }, + subtitle:function () { + return "See console. You should only see one message for each block"; + } +}); + +//------------------------------------------------------------------ +// +// Issue1288 +// +//------------------------------------------------------------------ +var Issue1288 = ActionsDemo.extend({ + onEnter:function () { + //----start41----onEnter + this._super(); + this.centerSprites(0); + + var spr = new cc.Sprite(s_pathGrossini); + spr.x = 100; + spr.y = 100; + this.addChild(spr); + + var act1 = cc.moveBy(0.5, cc.p(100, 0)); + var act2 = act1.reverse(); + var act3 = cc.sequence(act1, act2); + var act4 = act3.repeat(2); + + spr.runAction(act4); + //----end41---- + }, + title:function () { + return "Issue 1288"; + }, + subtitle:function () { + return "Sprite should end at the position where it started."; + } +}); + +//------------------------------------------------------------------ +// +// Issue1288_2 +// +//------------------------------------------------------------------ +var Issue1288_2 = ActionsDemo.extend({ + onEnter:function () { + //----start42----onEnter + this._super(); + this.centerSprites(0); + + var spr = new cc.Sprite(s_pathGrossini); + spr.x = 100; + spr.y = 100; + this.addChild(spr); + + var act1 = cc.moveBy(0.5, cc.p(100, 0)); + spr.runAction(act1.repeat(1)); + //----end42---- + }, + title:function () { + return "Issue 1288 #2"; + }, + subtitle:function () { + return "Sprite should move 100 pixels, and stay there"; + } +}); + +//------------------------------------------------------------------ +// +// Issue1327 +// +//------------------------------------------------------------------ +var Issue1327 = ActionsDemo.extend({ + onEnter:function () { + //----start43----onEnter + this._super(); + this.centerSprites(0); + + var spr = new cc.Sprite(s_pathGrossini); + spr.x = 100; + spr.y = 100; + this.addChild(spr); + + var act1 = cc.callFunc(this.onLogSprRotation); + var act2 = cc.rotateBy(0.25, 45); + var act3 = cc.callFunc(this.onLogSprRotation, this); + var act4 = cc.rotateBy(0.25, 45); + var act5 = cc.callFunc(this.onLogSprRotation.bind(this)); + var act6 = cc.rotateBy(0.25, 45); + var act7 = cc.callFunc(this.onLogSprRotation); + var act8 = cc.rotateBy(0.25, 45); + var act9 = cc.callFunc(this.onLogSprRotation); + + var actF = cc.sequence(act1, act2, act3, act4, act5, act6, act7, act8, act9); + spr.runAction(actF); + //----end43---- + }, + onLogSprRotation:function (pSender) { + cc.log(pSender.rotation); + }, + title:function () { + return "Issue 1327"; + }, + subtitle:function () { + return "See console: You should see: 0, 45, 90, 135, 180"; + } +}); + +//------------------------------------------------------------------ +// +// Issue1438 +// +//------------------------------------------------------------------ +var Issue1438 = ActionsDemo.extend({ + onEnter:function () { + //----start45----onEnter + this._super(); + this.centerSprites(2); + + // + // manual animation + // + var animation = new cc.Animation(); + + // Add 60 frames + for (var j = 0; j < 4; j++) { + for (var i = 1; i < 15; i++) { + var frameName = "res/Images/grossini_dance_" + ((i < 10) ? ("0" + i) : i) + ".png"; + animation.addSpriteFrameWithFile(frameName); + } + } + // And display 60 frames per second + animation.setDelayPerUnit(1 / 60); + animation.setRestoreOriginalFrame(true); + + var action = cc.animate(animation); + this._kathia.runAction(action); + + // + // File animation + // + var animCache = cc.animationCache; + animCache.addAnimations(s_animations2Plist); + var animation2 = animCache.getAnimation("dance_1"); + animation2.setDelayPerUnit(1 / 60); + + var action2 = cc.animate(animation2); + this._tamara.runAction(cc.sequence(action2, action2.reverse())); + //----end45---- + }, + + title:function () { + return "Animation"; + }, + + subtitle:function () { + return "Issue 1438. Set FPS to 30 to test this bug."; + } +}); + +//------------------------------------------------------------------ +// +// Issue1438 +// +//------------------------------------------------------------------ +var Issue1446 = ActionsDemo.extend({ + title:function () { + return "Sequence + Speed in 'reverse mode'"; + }, + + subtitle:function () { + return "Issue #1446. 'Hello World' should be visible for only 0.1 seconds"; + }, + + onEnter:function () { + //----start46----onEnter + this._super(); + this.centerSprites(0); + var label = this.label = new cc.LabelTTF("Hello World", "Arial", 64); + + label.x = winSize.width / 2; + label.y = winSize.height / 2; + label.opacity = 0; + + this.addChild(label); + + this.backwardsFade = cc.speed(cc.sequence( + cc.delayTime(2), + cc.fadeTo(1, 255), + cc.delayTime(2)), 1); + label.runAction(this.backwardsFade); + + // Comment out to see that 1.0 in the update function is called which is expected + // Leave it uncommented to see that 0.0 is never called when going in reverse + this.scheduleOnce(this.stepForwardGoBackward, 0.1); + //----end46---- + }, + + stepForwardGoBackward:function () { + var action = this.backwardsFade.getInnerAction(); + action.step(2.5); + // Try with -10.0f and you can see the opacity not fully faded out. Try with lower values to see it 'almost' fade out + this.backwardsFade.setSpeed(-10); + } +}); + +var SequenceRepeatTest = ActionsDemo.extend({ + onEnter:function () { + //----start47----onEnter + this._super(); + this.centerSprites(2); + + this._kathia.runAction(cc.repeat(cc.sequence(cc.blink(2, 3), cc.delayTime(2)), 3)); + + var move = cc.moveBy(1, cc.p(50, 0)); + var move_back = move.reverse(); + var move_seq = cc.sequence(move, cc.delayTime(1), move_back, cc.delayTime(1)); + this._tamara.runAction(move_seq.repeat(3)); + //----end47---- + }, + + title:function () { + return "Sequence.repeat()"; + }, + + subtitle:function () { + return "Tests sequence.repeat function."; + } +}); + +//- +// +// Flow control +// +var arrayOfActionsTest = [ + ActionManual, + ActionMove, + ActionScale, + ActionRotate, + ActionRotateXY, + ActionSkew, + ActionSkewRotateScale, + ActionJump, + ActionBezier, + ActionBezierToCopy, + Issue1008, + ActionCardinalSpline, + ActionCatmullRom, + ActionBlink, + ActionFade, + ActionTint, + ActionSequence, + ActionSequence2, + ActionSpawn, + ActionReverse, + ActionDelayTime, + ActionRepeat, + ActionRepeatForever, + ActionRotateToRepeat, + ActionRotateJerk, + ActionCallFunc1, + ActionCallFunc2, + ActionCallFunc3, + ActionReverseSequence, + ActionReverseSequence2, + + ActionFollow, + ActionTargeted, + ActionTargetedCopy, + + ActionStackableMove, + ActionStackableJump, + ActionStackableBezier, + ActionStackableCatmullRom, + ActionStackableCardinalSpline, + + PauseResumeActions, + Issue1305, + Issue1305_2, + Issue1288, + Issue1288_2, + Issue1327, + ActionAnimate, + Issue1438, + Issue1446, + SequenceRepeatTest +]; + +if("opengl" in cc.sys.capabilities){ + arrayOfActionsTest.push(ActionOrbit); +} + +var nextActionsTest = function () { + actionsTestIdx++; + actionsTestIdx = actionsTestIdx % arrayOfActionsTest.length; + + if(window.sideIndexBar){ + actionsTestIdx = window.sideIndexBar.changeTest(actionsTestIdx, 1); + } + + return new arrayOfActionsTest[actionsTestIdx](); +}; +var previousActionsTest = function () { + actionsTestIdx--; + if (actionsTestIdx < 0) + actionsTestIdx += arrayOfActionsTest.length; + + if(window.sideIndexBar){ + actionsTestIdx = window.sideIndexBar.changeTest(actionsTestIdx, 1); + } + + return new arrayOfActionsTest[actionsTestIdx](); +}; +var restartActionsTest = function () { + return new arrayOfActionsTest[actionsTestIdx](); +}; diff --git a/tests/js-tests/src/BakeLayerTest/BakeLayerTest.js b/tests/js-tests/src/BakeLayerTest/BakeLayerTest.js new file mode 100644 index 0000000000..12b6af4993 --- /dev/null +++ b/tests/js-tests/src/BakeLayerTest/BakeLayerTest.js @@ -0,0 +1,239 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 _bakeLayerTestIdx = -1; + +//------------------------------------------------------------------ +// +// ActionManagerTest +// +//------------------------------------------------------------------ +var BakeLayerBaseTest = BaseTestLayer.extend({ + _atlas:null, + _title:"", + + title:function () { + return "No title"; + }, + + subtitle:function () { + return ""; + }, + + onBackCallback:function (sender) { + var s = new BakeLayerTestScene(); + s.addChild(previousBakeLayerTest()); + director.runScene(s); + }, + onRestartCallback:function (sender) { + var s = new BakeLayerTestScene(); + s.addChild(restartBakeLayerTest()); + director.runScene(s); + }, + onNextCallback:function (sender) { + var s = new BakeLayerTestScene(); + s.addChild(nextBakeLayerTest()); + director.runScene(s); + }, + // automation + numberOfPendingTests:function() { + return ( (arrayOfBakeLayerTest.length-1) - _bakeLayerTestIdx ); + }, + + getTestNumber:function() { + return _bakeLayerTestIdx; + } +}); + +var BakeLayerTest1 = BakeLayerBaseTest.extend({ + _bakeLayer: null, + + title:function () { + return "Test 1. Bake Layer (Canvas only)"; + }, + + ctor: function(){ + this._super(); + + var winSize = cc.winSize; + var bakeItem = new cc.MenuItemFont("bake", this.onBake, this); + var unbakeItem = new cc.MenuItemFont("unbake", this.onUnbake, this); + var runActionItem = new cc.MenuItemFont("run action", this.onRunAction, this); + var menu = new cc.Menu(bakeItem, unbakeItem, runActionItem); + + menu.alignItemsVertically(); + menu.x = winSize.width - 70; + menu.y = winSize.height - 120; + this.addChild(menu, 10); + + var rootLayer = new cc.Layer(); + rootLayer.setPosition(20,20); + this.addChild(rootLayer); + + var bakeLayer = new cc.Layer(); + bakeLayer.bake(); + bakeLayer.setRotation(30); + rootLayer.addChild(bakeLayer); + + for(var i = 0; i < 9; i++){ + var sprite1 = new cc.Sprite(s_pathGrossini); + if (i % 2 === 0) { + sprite1.setPosition(90 + i * 80, winSize.height / 2 - 50); + } else { + sprite1.setPosition(90 + i * 80, winSize.height / 2 + 50); + } + if(i === 4) + this._actionSprite = sprite1; + sprite1.rotation = 360 * Math.random(); + 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(){ + this._bakeLayer.bake(); + }, + + onUnbake: function(){ + this._bakeLayer.unbake(); + }, + + onRunAction: function(){ + this._actionSprite.runAction(cc.rotateBy(1, 180)); + } +}); + +var BakeLayerColorTest = BakeLayerBaseTest.extend({ + _bakeLayer: null, + _actionSprite: null, + + title:function () { + return "Test 2. Bake Layer Gradient (Canvas only)"; + }, + + ctor: function(){ + this._super(); + + var winSize = cc.winSize; + var bakeItem = new cc.MenuItemFont("bake", this.onBake, this); + var unbakeItem = new cc.MenuItemFont("unbake", this.onUnbake, this); + var runActionItem = new cc.MenuItemFont("run action", this.onRunAction, this); + var menu = new cc.Menu(bakeItem, unbakeItem, runActionItem); + + menu.alignItemsVertically(); + menu.x = winSize.width - 70; + menu.y = winSize.height - 120; + this.addChild(menu, 10); + + var rootLayer = new cc.Layer(); + rootLayer.setPosition(20,20); + this.addChild(rootLayer); + + //var bakeLayer = cc.LayerColor.create(cc.color(128,0, 128, 128), 700, 300); //test for LayerColor + //bakeLayer.setPosition(60, 80); + + var bakeLayer = new cc.LayerGradient(cc.color(128,0, 128, 255), cc.color(0, 0, 128, 255)); + bakeLayer.setPosition(60, 80); + bakeLayer.setContentSize(700, 300); + bakeLayer.setRotation(30); + + //bakeLayer.setPosition(winSize.width /2, winSize.height /2); //test for ignoreAnchorPointForPosition + //bakeLayer.ignoreAnchorPointForPosition(false); + rootLayer.addChild(bakeLayer); + + for(var i = 0; i < 9; i++){ + var sprite1 = new cc.Sprite(s_pathGrossini); + if (i % 2 === 0) { + sprite1.setPosition(20 + i * 80, 100); + } else { + sprite1.setPosition(20 + i * 80, 200); + } + if(i === 4) + this._actionSprite = sprite1; + sprite1.rotation = 180 * Math.random(); + bakeLayer.addChild(sprite1); + } + + 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(){ + this._bakeLayer.bake(); + }, + + onUnbake: function(){ + this._bakeLayer.unbake(); + }, + + onRunAction: function(){ + this._actionSprite.runAction(cc.rotateBy(2, 180)); + } +}); + +var BakeLayerTestScene = TestScene.extend({ + runThisTest:function (num) { + _bakeLayerTestIdx = (num || 0) - 1; + this.addChild(nextBakeLayerTest()); + director.runScene(this); + } +}); + +//- +// +// Flow control +// +var arrayOfBakeLayerTest = [ + BakeLayerTest1, + BakeLayerColorTest +]; + +var nextBakeLayerTest = function (num) { + _bakeLayerTestIdx = num ? num - 1 : _bakeLayerTestIdx; + _bakeLayerTestIdx++; + _bakeLayerTestIdx = _bakeLayerTestIdx % arrayOfBakeLayerTest.length; + + if(window.sideIndexBar){ + _bakeLayerTestIdx = window.sideIndexBar.changeTest(_bakeLayerTestIdx, 0); + } + return new arrayOfBakeLayerTest[_bakeLayerTestIdx](); +}; + +var previousBakeLayerTest = function () { + _bakeLayerTestIdx--; + if (_bakeLayerTestIdx < 0) + _bakeLayerTestIdx += arrayOfBakeLayerTest.length; + + if(window.sideIndexBar){ + _bakeLayerTestIdx = window.sideIndexBar.changeTest(_bakeLayerTestIdx, 0); + } + return new arrayOfBakeLayerTest[_bakeLayerTestIdx](); +}; +var restartBakeLayerTest = function () { + return new arrayOfBakeLayerTest[_bakeLayerTestIdx](); +}; \ No newline at end of file diff --git a/tests/js-tests/src/BaseTestLayer/BaseTestLayer.js b/tests/js-tests/src/BaseTestLayer/BaseTestLayer.js new file mode 100644 index 0000000000..d06dd54850 --- /dev/null +++ b/tests/js-tests/src/BaseTestLayer/BaseTestLayer.js @@ -0,0 +1,294 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + 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. + ****************************************************************************/ + +var BASE_TEST_MENUITEM_PREV_TAG = 1; +var BASE_TEST_MENUITEM_RESET_TAG = 2; +var BASE_TEST_MENUITEM_NEXT_TAG = 3; + +var BASE_TEST_MENU_TAG = 10; +var BASE_TEST_TITLE_TAG = 11; +var BASE_TEST_SUBTITLE_TAG = 12; + + +var autoTestEnabled = autoTestEnabled || false; +var autoTestCurrentTestName = autoTestCurrentTestName || "N/A"; + +var BaseTestLayerProps = { + + ctor:function(colorA, colorB ) { + + cc.sys.garbageCollect(); + + // default gradient colors + var a = cc.color(98,99,117,255); + var b = cc.color(0,0,0,255); + + if( arguments.length >= 1 ) + a = colorA; + if( arguments.length == 2 ) + b = colorB; + + // for automation, no gradient. helps for grabbing the screen if needed + if( autoTestEnabled ) { + a = cc.color(0,0,0,255); + b = cc.color(0,0,0,255); + } + + this._super( a, b ); + + // Update winsize in case it was resized + winSize = director.getWinSize(); + + if( autoTestEnabled ) { + this.totalNumberOfTests = this.numberOfPendingTests(); + this.scheduleOnce( this.endTest, this.testDuration ); + + this.setupAutomation(); + } + }, + + setupAutomation:function() { + // override me + // Will be called only if automation is activated + }, + + getTitle:function() { + var t = ""; + + // some tests use "this.title()" and others use "this._title"; + if( 'title' in this ) + t = this.title(); + else if('_title' in this || this._title) + t = this._title; + return t; + }, + getSubtitle:function() { + var st = ""; + // some tests use "this.subtitle()" and others use "this._subtitle"; + if(this.subtitle) + st = this.subtitle(); + else if(this._subtitle) + st = this._subtitle; + + return st; + }, + log:function(str) { + if( !autoTestEnabled ) + cc.log(str); + }, + // + // Menu + // + onEnter:function () { + this._super(); + + var t = this.getTitle(); + var label = new cc.LabelTTF(t, "Arial", 28); + this.addChild(label, 100, BASE_TEST_TITLE_TAG); + label.x = winSize.width / 2; + label.y = winSize.height - 50; + + var st = this.getSubtitle(); + if (st) { + var l = new cc.LabelTTF(st.toString(), "Thonburi", 16); + this.addChild(l, 101, BASE_TEST_SUBTITLE_TAG); + l.x = winSize.width / 2; + l.y = winSize.height - 80; + } + + var item1 = new cc.MenuItemImage(s_pathB1, s_pathB2, this.onBackCallback, this); + var item2 = new cc.MenuItemImage(s_pathR1, s_pathR2, this.onRestartCallback, this); + var item3 = new cc.MenuItemImage(s_pathF1, s_pathF2, this.onNextCallback, this); + + item1.tag = BASE_TEST_MENUITEM_PREV_TAG; + item2.tag = BASE_TEST_MENUITEM_RESET_TAG; + item3.tag = BASE_TEST_MENUITEM_NEXT_TAG; + + var menu = new cc.Menu(item1, item2, item3); + + menu.x = 0; + menu.y = 0; + var width = item2.width, height = item2.height; + item1.x = winSize.width/2 - width*2; + item1.y = height/2 ; + item2.x = winSize.width/2; + item2.y = height/2 ; + item3.x = winSize.width/2 + width*2; + item3.y = height/2 ; + + this.addChild(menu, 102, BASE_TEST_MENU_TAG); + }, + onRestartCallback:function (sender) { + // override me + }, + onNextCallback:function (sender) { + // override me + }, + onBackCallback:function (sender) { + // override me + }, + //------------------------------------------ + // + // Automation Test code + // + //------------------------------------------ + + // How many seconds should this test run + testDuration:0.25, + + // Automated test + getExpectedResult:function() { + // Override me + throw "Not Implemented"; + }, + + // Automated test + getCurrentResult:function() { + // Override me + throw "Not Implemented"; + }, + + compareResults:function(current, expected) { + return (current == expected); + }, + + tearDown:function(dt) { + + // Override to have a different behavior + var current = this.getCurrentResult(); + var expected = this.getExpectedResult(); + + var ret = this.compareResults(current, expected); + if( ! ret ) + this.errorDescription = "Expected value: '" + expected + "'. Current value'" + current + "'."; + + return ret; + }, + + endTest:function(dt) { + + this.errorDescription = ""; + var title = this.getTitle(); + + try { + if( this.tearDown(dt) ) { + // Test OK + cc.log( autoTestCurrentTestName + " - " + this.getTestNumber() + ": Test '" + title + "':' OK"); + } else { + // Test failed + cc.log( autoTestCurrentTestName + " - " +this.getTestNumber() + ": Test '" + title + "': Error: " + this.errorDescription ); + } + } catch(err) { + cc.log( autoTestCurrentTestName + " - " +this.getTestNumber() + ": Test '" + title + "':'" + err); + } + + this.runNextTest(); + }, + + numberOfPendingTests:function() { + // override me. Should return true if the last test was executed + throw "Override me: numberOfPendingTests"; + }, + + getTestNumber:function() { + throw "Override me: getTestNumber"; + }, + + runNextTest:function() { + if( this.numberOfPendingTests() <= 0 ) { + var scene = new cc.Scene(); + var layer = new TestController(); + scene.addChild(layer); + director.runScene(scene); + } else + try { + this.onNextCallback(this); + } catch (err) { + cc.log( autoTestCurrentTestName + " - " +this.getTestNumber() + ": Test '" + this.getTitle() + "':'" + err); + this.runNextTest(); + } + }, + + + containsPixel: function(arr, pix, approx, range) { + + range = range || 50.0; + approx = approx || false; + + var abs = function(a,b) { + return ((a-b) > 0) ? (a-b) : (b-a); + }; + + var pixelEqual = function(pix1, pix2) { + if(approx && abs(pix1, pix2) < range) return true; + else if(!approx && pix1 == pix2) return true; + return false; + }; + + + for(var i=0; i < arr.length; i += 4) { + if(pixelEqual(arr[i], pix[0]) && pixelEqual(arr[i + 1], pix[1]) && + pixelEqual(arr[i + 2], pix[2]) && pixelEqual(arr[i + 3], pix[3])) { + return true; + } + } + return false; + }, + + readPixels:function(x,y,w,h) { + if( 'opengl' in cc.sys.capabilities) { + var size = 4 * w * h; + var array = new Uint8Array(size); + gl.readPixels(x, y, w, h, gl.RGBA, gl.UNSIGNED_BYTE, array); + return array; + } else { + // implement a canvas-html5 readpixels + return cc._renderContext.getImageData(x, winSize.height-y-h, w, h).data; + } + }, + + // + // Useful for comparing results + // From: http://stackoverflow.com/a/1359808 + // + sortObject:function(o) { + var sorted = {}, + key, a = []; + + for (key in o) { + if (o.hasOwnProperty(key)) { + a.push(key); + } + } + + a.sort(); + + for (key = 0; key < a.length; key++) { + sorted[a[key]] = o[a[key]]; + } + return sorted; + } +}; + +var BaseTestLayer = cc.LayerGradient.extend(BaseTestLayerProps); diff --git a/tests/js-tests/src/BillBoardTest/BillBoardTest.js b/tests/js-tests/src/BillBoardTest/BillBoardTest.js new file mode 100644 index 0000000000..d81c74f1bc --- /dev/null +++ b/tests/js-tests/src/BillBoardTest/BillBoardTest.js @@ -0,0 +1,359 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 BillBoardTestIdx = -1; + +var BillBoardTestDemo = cc.Layer.extend({ + _title:"", + _subtitle:"", + + ctor:function () { + this._super(); + }, + + // + // Menu + // + onEnter:function () { + this._super(); + + var label = new cc.LabelTTF(this._title, "Arial", 28); + this.addChild(label, 100, BASE_TEST_TITLE_TAG); + label.x = winSize.width / 2; + label.y = winSize.height - 50; + + var label2 = new cc.LabelTTF(this._subtitle, "Thonburi", 16); + this.addChild(label2, 101, BASE_TEST_SUBTITLE_TAG); + label2.x = winSize.width / 2; + label2.y = winSize.height - 80; + + var item1 = new cc.MenuItemImage(s_pathB1, s_pathB2, this.onBackCallback, this); + var item2 = new cc.MenuItemImage(s_pathR1, s_pathR2, this.onRestartCallback, this); + var item3 = new cc.MenuItemImage(s_pathF1, s_pathF2, this.onNextCallback, this); + + item1.tag = BASE_TEST_MENUITEM_PREV_TAG; + item2.tag = BASE_TEST_MENUITEM_RESET_TAG; + item3.tag = BASE_TEST_MENUITEM_NEXT_TAG; + + var menu = new cc.Menu(item1, item2, item3); + + menu.x = 0; + menu.y = 0; + var width = item2.width, height = item2.height; + item1.x = winSize.width/2 - width*2; + item1.y = height/2 ; + item2.x = winSize.width/2; + item2.y = height/2 ; + item3.x = winSize.width/2 + width*2; + item3.y = height/2 ; + + this.addChild(menu, 102, BASE_TEST_MENU_TAG); + }, + + onRestartCallback:function (sender) { + var s = new BillBoardTestScene(); + s.addChild(restartBillBoardTest()); + director.runScene(s); + }, + + onNextCallback:function (sender) { + var s = new BillBoardTestScene(); + s.addChild(nextBillBoardTest()); + director.runScene(s); + }, + + onBackCallback:function (sender) { + var s = new BillBoardTestScene(); + s.addChild(previousBillBoardTest()); + director.runScene(s); + }, +}); + +var BillBoardTestScene = cc.Scene.extend({ + ctor:function () { + this._super(); + + var label = new cc.LabelTTF("Main Menu", "Arial", 20); + var menuItem = new cc.MenuItemLabel(label, this.onMainMenuCallback, this); + + var menu = new cc.Menu(menuItem); + menu.x = 0; + menu.y = 0; + menuItem.x = winSize.width - 50; + menuItem.y = 25; + this.addChild(menu); + }, + onMainMenuCallback:function () { + var scene = new cc.Scene(); + var layer = new TestController(); + scene.addChild(layer); + director.runScene(scene); + }, + runThisTest:function (num) { + BillBoardTestIdx = (num || num == 0) ? (num - 1) : -1; + var layer = nextBillBoardTest(); + this.addChild(layer); + + director.runScene(this); + } +}); + +var BillBoardRotationTest = BillBoardTestDemo.extend({ + _title:"Rotation Test", + _subtitle:"All the sprites should still facing camera", + + ctor:function(){ + this._super(); + + var root = new jsb.Sprite3D(); + root.setNormalizedPosition(cc.p(0.5, 0.25)); + this.addChild(root); + + var model = new jsb.Sprite3D("Sprite3DTest/orc.c3b"); + model.setScale(5); + model.setRotation3D(cc.math.vec3(0, 180, 0)); + root.addChild(model); + + var bill = new jsb.BillBoard(); + bill.setPosition(0, 120); + root.addChild(bill); + + var sp = new cc.Sprite("Images/SpookyPeas.png"); + bill.addChild(sp); + + var label = new cc.LabelTTF("+100"); + label.setPosition(0, 30); + bill.addChild(label); + + root.runAction(cc.rotateBy(10, cc.math.vec3(0, 360, 0)).repeatForever()); + + var jump = cc.jumpBy(1, cc.p(0, 0), 30, 1); + var scale = cc.scaleBy(2, 2, 2, 0.1); + var rot = cc.rotateBy(2, cc.math.vec3(-90, 0, 0)); + model.runAction(cc.sequence(cc.spawn(cc.sequence(jump, scale), rot), cc.spawn(scale.reverse(), rot.reverse())).repeatForever()); + } +}); + +var BillBoardTest = BillBoardTestDemo.extend({ + _title:"BillBoard Test", + _subtitle:"", + _camera:null, + _layerBillBorad:null, + _billboards:[], + + ctor:function(){ + this._super(); + + //Create touch listener + cc.eventManager.addListener({ + event:cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesMoved:this.onTouchesMoved.bind(this) + }, this); + + var layer3D = new cc.Layer(); + this.addChild(layer3D, 0); + this._layerBillBorad = layer3D; + + var s = cc.winSize; + if(!this._camera){ + this._camera = cc.Camera.createPerspective(60, s.width/s.height, 1, 500); + this._camera.setCameraFlag(cc.CameraFlag.USER1); + this._layerBillBorad.addChild(this._camera); + } + + //Create rotating billboards + var imgs = ["Images/Icon.png", "Images/r2.png"]; + for(var i = 0; i < 4; ++i){ + var layer = new cc.Layer(); + var billboard = new jsb.BillBoard(imgs[Math.floor(Math.random() + 0.5)]); + billboard.setScale(0.5); + billboard.setPosition3D(cc.math.vec3(0, 0, (Math.random() * 2 - 1) * 150)); + billboard.setOpacity(Math.random() * 128 + 128); + this._billboards.push(billboard); + layer.addChild(billboard); + this._layerBillBorad.addChild(layer); + layer.runAction(cc.rotateBy(Math.random() * 10, cc.math.vec3(0, 45, 0)).repeatForever()); + } + + { + var billboard1 = new jsb.BillBoard("Images/Icon.png"); + billboard1.setScale(0.2); + billboard1.setPosition3D(cc.math.vec3(0, 30, 0)); + + var billboard2 = new jsb.BillBoard("Images/r2.png"); + billboard2.setPosition3D(cc.math.vec3(0, 0, 100)); + billboard1.addChild(billboard2); + this._billboards.push(billboard1); + this._billboards.push(billboard2); + + var sprite3d = new jsb.Sprite3D("Sprite3DTest/orc.c3b"); + sprite3d.setScale(2); + sprite3d.addChild(billboard1); + sprite3d.runAction(cc.rotateBy(10, cc.math.vec3(0, 360, 0)).repeatForever()); + this._layerBillBorad.addChild(sprite3d); + } + + this.addNewBillBoradWithCoords(cc.math.vec3(20, 5, 0)); + this.addNewBillBoradWithCoords(cc.math.vec3(60, 5, 0)); + this.addNewBillBoradWithCoords(cc.math.vec3(100, 5, 0)); + this.addNewBillBoradWithCoords(cc.math.vec3(140, 5, 0)); + this.addNewBillBoradWithCoords(cc.math.vec3(180, 5, 0)); + + this.addNewAniBillBoradWithCoords(cc.math.vec3(-20, 0, 0)); + this.addNewAniBillBoradWithCoords(cc.math.vec3(-60, 0, 0)); + this.addNewAniBillBoradWithCoords(cc.math.vec3(-100, 0, 0)); + this.addNewAniBillBoradWithCoords(cc.math.vec3(-140, 0, 0)); + this.addNewAniBillBoradWithCoords(cc.math.vec3(-180, 0, 0)); + + this._camera.setPosition3D(cc.math.vec3(0, 100, 230)); + this._camera.lookAt(cc.math.vec3(0, 0, 0), cc.math.vec3(0, 1, 0)); + + this._layerBillBorad.setCameraMask(2); + + var label1 = new cc.LabelTTF("rotate+", "Arial", 16); + var item1 = new cc.MenuItemLabel(label1, function(){ + var rotation3D = this._camera.getRotation3D(); + rotation3D.y += 10; + this._camera.setRotation3D(rotation3D); + }, this); + var label2 = new cc.LabelTTF("rotate-", "Arial", 16); + var item2 = new cc.MenuItemLabel(label2, function(){ + var rotation3D = this._camera.getRotation3D(); + rotation3D.y -= 10; + this._camera.setRotation3D(rotation3D); + }, this); + var label3 = new cc.LabelTTF("Point Oriented", "Arial", 16); + var item3 = new cc.MenuItemLabel(label3, this.menuCallback_orientedPoint, this); + var label4 = new cc.LabelTTF("Plane Oriented", "Arial", 16); + var item4 = new cc.MenuItemLabel(label4, this.menuCallback_orientedPlane, this); + + item1.setPosition(cc.p(s.width-80, s.height-160)); + item2.setPosition(cc.p(s.width-80, s.height-190)); + item3.setPosition(cc.p(s.width-80, s.height-100)); + item4.setPosition(cc.p(s.width-80, s.height-130)); + + var menu = new cc.Menu(item1, item2, item3, item4); + this.addChild(menu); + menu.setPosition(0, 0); + }, + + addNewBillBoradWithCoords:function(position){ + var imgs = ["Images/Icon.png", "Images/r2.png"]; + for(var i = 0; i < 10; ++i){ + var billboard = new jsb.BillBoard(imgs[Math.floor(Math.random() + 0.5)]); + billboard.setScale(0.5); + billboard.setPosition3D(cc.math.vec3(position.x, position.y, -150+30*i)); + billboard.setOpacity(Math.random() * 128 + 128); + this._layerBillBorad.addChild(billboard); + this._billboards.push(billboard); + } + }, + + addNewAniBillBoradWithCoords:function(position){ + for(var i = 0; i < 10; ++i){ + var billboardAni = new jsb.BillBoard("Images/grossini.png"); + billboardAni.setScale(0.5); + billboardAni.setPosition3D(cc.math.vec3(position.x, position.y, -150+30*i)); + this._layerBillBorad.addChild(billboardAni); + + var animation = new cc.Animation(); + for(var j = 1; j < 15; ++j){ + if(j < 10) + animation.addSpriteFrameWithFile("Images/grossini_dance_0"+j+".png"); + else + animation.addSpriteFrameWithFile("Images/grossini_dance_"+j+".png"); + } + // should last 2.8 seconds. And there are 14 frames. + animation.setDelayPerUnit(2.8/14.0); + animation.setRestoreOriginalFrame(true); + + var action = new cc.Animate(animation); + billboardAni.runAction(action.repeatForever()); + billboardAni.setOpacity(Math.random() * 128 + 128); + this._billboards.push(billboardAni); + } + }, + + menuCallback_orientedPoint:function(sender){ + for(var i = 0; i < this._billboards.length; ++i){ + this._billboards[i].setMode(jsb.BillBoard.Mode.VIEW_POINT_ORIENTED); + } + }, + + menuCallback_orientedPlane:function(sender){ + for(var i = 0; i < this._billboards.length; ++i){ + this._billboards[i].setMode(jsb.BillBoard.Mode.VIEW_PLANE_ORIENTED); + } + }, + + onTouchesMoved:function(touches, event){ + if(touches.length == 1){ + var touch = touches[0]; + var location = touch.getLocation(); + var previousLocation = touch.getPreviousLocation(); + var newPos = cc.p(previousLocation.x - location.x, previousLocation.y - location.y); + + var m = this._camera.getNodeToWorldTransform3D(); + var cameraDir = cc.math.vec3(-m[8], -m[9], -m[10]); + cameraDir.normalize(); + cameraDir.y = 0; + + var cameraRightDir = cc.math.vec3(m[0], m[1], m[2]); + cameraRightDir.normalize(); + cameraRightDir.y = 0; + + var cameraPos = this._camera.getPosition3D(); + cameraPos.x += cameraDir.x * newPos.y * 0.5 + cameraRightDir.x * newPos.x * 0.5; + cameraPos.y += cameraDir.y * newPos.y * 0.5 + cameraRightDir.y * newPos.x * 0.5; + cameraPos.z += cameraDir.z * newPos.y * 0.5 + cameraRightDir.z * newPos.x * 0.5; + this._camera.setPosition3D(cameraPos); + } + } +}); + +// +// Flow control +// +var arrayOfBillBoardTest = [ + BillBoardRotationTest, + BillBoardTest +]; + +var nextBillBoardTest = function () { + BillBoardTestIdx++; + BillBoardTestIdx = BillBoardTestIdx % arrayOfBillBoardTest.length; + + return new arrayOfBillBoardTest[BillBoardTestIdx ](); +}; +var previousBillBoardTest = function () { + BillBoardTestIdx--; + if (BillBoardTestIdx < 0) + BillBoardTestIdx += arrayOfBillBoardTest.length; + + return new arrayOfBillBoardTest[BillBoardTestIdx ](); +}; +var restartBillBoardTest = function () { + return new arrayOfBillBoardTest[BillBoardTestIdx ](); +}; diff --git a/tests/js-tests/src/Box2dTest/Box2dTest.js b/tests/js-tests/src/Box2dTest/Box2dTest.js new file mode 100644 index 0000000000..0757b412d5 --- /dev/null +++ b/tests/js-tests/src/Box2dTest/Box2dTest.js @@ -0,0 +1,197 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 TAG_SPRITE_MANAGER = 1; +var PTM_RATIO = 32; + +var Box2DTestLayer = cc.Layer.extend({ + world:null, + //GLESDebugDraw *m_debugDraw; + + ctor:function () { + + if(window.sideIndexBar){ + window.sideIndexBar.changeTest(0, 2); + } + //----start0----ctor + this._super(); + + cc.eventManager.addListener(cc.EventListener.create({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded: function(touches, event){ + //Add a new body/atlas sprite at the touched location + var touch = touches[0]; + var location = touch.getLocation(); + event.getCurrentTarget().addNewSpriteWithCoords(location); + } + }), this); + + var b2Vec2 = Box2D.Common.Math.b2Vec2 + , b2BodyDef = Box2D.Dynamics.b2BodyDef + , b2Body = Box2D.Dynamics.b2Body + , b2FixtureDef = Box2D.Dynamics.b2FixtureDef + , b2World = Box2D.Dynamics.b2World + , b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape; + + var screenSize = cc.director.getWinSize(); + //UXLog(L"Screen width %0.2f screen height %0.2f",screenSize.width,screenSize.height); + + // Construct a world object, which will hold and simulate the rigid bodies. + this.world = new b2World(new b2Vec2(0, -10), true); + this.world.SetContinuousPhysics(true); + + // Define the ground body. + //var groundBodyDef = new b2BodyDef(); // TODO + //groundBodyDef.position.Set(screenSize.width / 2 / PTM_RATIO, screenSize.height / 2 / PTM_RATIO); // bottom-left corner + + // Call the body factory which allocates memory for the ground body + // from a pool and creates the ground box shape (also from a pool). + // The body is also added to the world. + //var groundBody = this.world.CreateBody(groundBodyDef); + + var fixDef = new b2FixtureDef; + fixDef.density = 1.0; + fixDef.friction = 0.5; + fixDef.restitution = 0.2; + + var bodyDef = new b2BodyDef; + + //create ground + bodyDef.type = b2Body.b2_staticBody; + fixDef.shape = new b2PolygonShape; + fixDef.shape.SetAsBox(20, 2); + // upper + bodyDef.position.Set(10, screenSize.height / PTM_RATIO + 1.8); + this.world.CreateBody(bodyDef).CreateFixture(fixDef); + // bottom + bodyDef.position.Set(10, -1.8); + this.world.CreateBody(bodyDef).CreateFixture(fixDef); + + fixDef.shape.SetAsBox(2, 14); + // left + bodyDef.position.Set(-1.8, 13); + this.world.CreateBody(bodyDef).CreateFixture(fixDef); + // right + bodyDef.position.Set(26.8, 13); + this.world.CreateBody(bodyDef).CreateFixture(fixDef); + + //Set up sprite + + var mgr = new cc.SpriteBatchNode(s_pathBlock, 150); + this.addChild(mgr, 0, TAG_SPRITE_MANAGER); + + this.addNewSpriteWithCoords(cc.p(screenSize.width / 2, screenSize.height / 2)); + + var label = new cc.LabelTTF("Tap screen", "Marker Felt", 32); + this.addChild(label, 0); + label.color = cc.color(0, 0, 255); + label.x = screenSize.width / 2; + label.y = screenSize.height - 50; + + this.scheduleUpdate(); + //----end0---- + }, + + addNewSpriteWithCoords:function (p) { + //----start0----addNewSpriteWithCoords + //UXLog(L"Add sprite %0.2f x %02.f",p.x,p.y); + var batch = this.getChildByTag(TAG_SPRITE_MANAGER); + + //We have a 64x64 sprite sheet with 4 different 32x32 images. The following code is + //just randomly picking one of the images + var idx = (Math.random() > .5 ? 0 : 1); + var idy = (Math.random() > .5 ? 0 : 1); + var sprite = new cc.Sprite(batch.texture, cc.rect(32 * idx, 32 * idy, 32, 32)); + batch.addChild(sprite); + + sprite.x = p.x; + sprite.y = p.y; + + // Define the dynamic body. + //Set up a 1m squared box in the physics world + var b2BodyDef = Box2D.Dynamics.b2BodyDef + , b2Body = Box2D.Dynamics.b2Body + , b2FixtureDef = Box2D.Dynamics.b2FixtureDef + , b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape; + + var bodyDef = new b2BodyDef(); + bodyDef.type = b2Body.b2_dynamicBody; + bodyDef.position.Set(p.x / PTM_RATIO, p.y / PTM_RATIO); + bodyDef.userData = sprite; + var body = this.world.CreateBody(bodyDef); + + // Define another box shape for our dynamic body. + var dynamicBox = new b2PolygonShape(); + dynamicBox.SetAsBox(0.5, 0.5);//These are mid points for our 1m box + + // Define the dynamic body fixture. + var fixtureDef = new b2FixtureDef(); + fixtureDef.shape = dynamicBox; + fixtureDef.density = 1.0; + fixtureDef.friction = 0.3; + body.CreateFixture(fixtureDef); + //----end0---- + }, + update:function (dt) { + //----start0----update + //It is recommended that a fixed time step is used with Box2D for stability + //of the simulation, however, we are using a variable time step here. + //You need to make an informed choice, the following URL is useful + //http://gafferongames.com/game-physics/fix-your-timestep/ + + var velocityIterations = 8; + var positionIterations = 1; + + // Instruct the world to perform a single step of simulation. It is + // generally best to keep the time step and iterations fixed. + this.world.Step(dt, velocityIterations, positionIterations); + + //Iterate over the bodies in the physics world + for (var b = this.world.GetBodyList(); b; b = b.GetNext()) { + if (b.GetUserData() != null) { + //Synchronize the AtlasSprites position and rotation with the corresponding body + var myActor = b.GetUserData(); + myActor.x = b.GetPosition().x * PTM_RATIO; + myActor.y = b.GetPosition().y * PTM_RATIO; + myActor.rotation = -1 * cc.radiansToDegrees(b.GetAngle()); + } + } + //----end0---- + } + //CREATE_NODE(Box2DTestLayer); +}); + +var Box2DTestScene = TestScene.extend({ + runThisTest:function () { + var layer = new Box2DTestLayer(); + this.addChild(layer); + + cc.director.runScene(this); + } +}); + +var arrayOfBox2DTest = [ + Box2DTestLayer +]; diff --git a/tests/js-tests/src/Camera3DTest/Camera3DTest.js b/tests/js-tests/src/Camera3DTest/Camera3DTest.js new file mode 100644 index 0000000000..c3bbeb37b5 --- /dev/null +++ b/tests/js-tests/src/Camera3DTest/Camera3DTest.js @@ -0,0 +1,1278 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 CameraType = { + Free : 0, + FirstPerson : 1, + ThirdPerson : 2, +}; + +var OperateCamType = { + MoveCamera : 0, + RotateCamera : 1 +}; + +var Camera3DTestIdx = -1; + +var Camera3DTestDemo = cc.Layer.extend({ + _title:"", + _subtitle:"", + + ctor:function () { + this._super(); + }, + + // + // Menu + // + onEnter:function () { + this._super(); + + var label = new cc.LabelTTF(this._title, "Arial", 28); + this.addChild(label, 100, BASE_TEST_TITLE_TAG); + label.x = winSize.width / 2; + label.y = winSize.height - 50; + + var label2 = new cc.LabelTTF(this._subtitle, "Thonburi", 16); + this.addChild(label2, 101, BASE_TEST_SUBTITLE_TAG); + label2.x = winSize.width / 2; + label2.y = winSize.height - 80; + + var item1 = new cc.MenuItemImage(s_pathB1, s_pathB2, this.onBackCallback, this); + var item2 = new cc.MenuItemImage(s_pathR1, s_pathR2, this.onRestartCallback, this); + var item3 = new cc.MenuItemImage(s_pathF1, s_pathF2, this.onNextCallback, this); + + item1.tag = BASE_TEST_MENUITEM_PREV_TAG; + item2.tag = BASE_TEST_MENUITEM_RESET_TAG; + item3.tag = BASE_TEST_MENUITEM_NEXT_TAG; + + var menu = new cc.Menu(item1, item2, item3); + + menu.x = 0; + menu.y = 0; + var width = item2.width, height = item2.height; + item1.x = winSize.width/2 - width*2; + item1.y = height/2 ; + item2.x = winSize.width/2; + item2.y = height/2 ; + item3.x = winSize.width/2 + width*2; + item3.y = height/2 ; + + this.addChild(menu, 102, BASE_TEST_MENU_TAG); + }, + + onRestartCallback:function (sender) { + var s = new Camera3DTestScene(); + s.addChild(restartCamera3DTest()); + director.runScene(s); + }, + + onNextCallback:function (sender) { + var s = new Camera3DTestScene(); + s.addChild(nextCamera3DTest()); + director.runScene(s); + }, + + onBackCallback:function (sender) { + var s = new Camera3DTestScene(); + s.addChild(previousCamera3DTest()); + director.runScene(s); + }, +}); + +var Camera3DTestScene = cc.Scene.extend({ + ctor:function () { + this._super(); + + var label = new cc.LabelTTF("Main Menu", "Arial", 20); + var menuItem = new cc.MenuItemLabel(label, this.onMainMenuCallback, this); + + var menu = new cc.Menu(menuItem); + menu.x = 0; + menu.y = 0; + menuItem.x = winSize.width - 50; + menuItem.y = 25; + this.addChild(menu); + }, + onMainMenuCallback:function () { + var scene = new cc.Scene(); + var layer = new TestController(); + scene.addChild(layer); + director.runScene(scene); + }, + runThisTest:function (num) { + Camera3DTestIdx = (num || num == 0) ? (num - 1) : -1; + var layer = nextCamera3DTest(); + this.addChild(layer); + + director.runScene(this); + } +}); + +var CameraRotationTest = Camera3DTestDemo.extend({ + _title:"Camera Rotation Test", + _subtitle:"Slide to rotate", + _camControlNode:null, + _camNode:null, + + ctor:function(){ + this._super(); + + var s = cc.winSize; + this._camControlNode = new cc.Node(); + this._camControlNode.setNormalizedPosition(cc.p(0.5, 0.5)); + this.addChild(this._camControlNode); + + this._camNode = new cc.Node(); + this._camNode.setVertexZ(cc.Camera.getDefaultCamera().getPosition3D().z); + this._camControlNode.addChild(this._camNode); + + var sp3d = new jsb.Sprite3D(); + sp3d.setPosition(s.width/2, s.height/2); + this.addChild(sp3d); + + var lship = new cc.LabelTTF("Ship"); + lship.setPosition(0, 20); + sp3d.addChild(lship); + + //Billboards + //Yellow is at the back + var bill1 = new jsb.BillBoard("Images/Icon.png"); + bill1.setPosition3D(cc.math.vec3(50, 10, -10)); + bill1.setColor(cc.color.YELLOW); + bill1.setScale(0.6); + sp3d.addChild(bill1); + + var l1 = new cc.LabelTTF("Billboard1"); + l1.setPosition(cc.p(0, -10)); + l1.setColor(cc.color.WHITE); + l1.setScale(3); + bill1.addChild(l1); + + var p1 = new cc.ParticleSystem("Particles/SmallSun.plist"); + p1.setPosition(30, 80); + bill1.addChild(p1); + + var bill2 = new jsb.BillBoard("Images/Icon.png"); + bill2.setPosition3D(cc.math.vec3(-50, -10, 10)); + bill2.setScale(0.6); + sp3d.addChild(bill2); + + var l2 = new cc.LabelTTF("Billboard2"); + l2.setPosition(0, -10); + l2.setColor(cc.color.WHITE); + l2.setScale(3); + bill2.addChild(l2); + + var p2 = new cc.ParticleSystem("Particles/SmallSun.plist"); + p2.setPosition(30,80); + bill2.addChild(p2); + + //3D models + var model = new jsb.Sprite3D("Sprite3DTest/boss1.obj"); + model.setScale(4); + model.setTexture("Sprite3DTest/boss.png"); + model.setPosition3D(cc.math.vec3(s.width/2, s.height/2, 0)); + this.addChild(model); + + var self = this; + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + onTouchBegan: function(touch, event){return true;}, + onTouchMoved: function(touch, event){ + var dx = touch.getDelta().x; + var rot = self._camControlNode.getRotation3D(); + rot.y += dx; + self._camControlNode.setRotation3D(rot); + + var matrix = self._camNode.getNodeToWorldTransform3D(); + var worldPos = cc.math.vec3(matrix[12], matrix[13], matrix[14]); + + cc.Camera.getDefaultCamera().setPosition3D(worldPos); + cc.Camera.getDefaultCamera().lookAt(self._camControlNode.getPosition3D()); + } + }, this); + } +}); + +var Camera3DTest = (function(){ + var State = { + State_None : 0, + State_Idle : 0x01, + State_Move : 0x02, + State_Rotate : 0x04, + State_Speak : 0x08, + State_MeleeAttack : 0x10, + State_RemoteAttack : 0x20, + State_Attack : 0x40 + }; + + return Camera3DTestDemo.extend({ + _title:"Testing Camera", + _subtitle:"", + _layer3D:null, + _sprite3D:null, + _targetPos:null, + _camera:null, + _cameraType:-1, + _curState:0, + _bZoomOut:false, + _bZoomIn:false, + _bRotateLeft:false, + _bRotateRight:false, + _ZoomOutlabel:null, + _ZoomInlabel:null, + _RotateLeftlabel:null, + _RotateRightlabel:null, + + ctor:function(){ + this._super(); + }, + + onEnter:function(){ + this._super(); + + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + // onTouchesBegan: this.onTouchesBegan, + onTouchesMoved: this.onTouchesMoved.bind(this), + onTouchesEnded: this.onTouchesEnded.bind(this) + }, this); + + var layer3D = new cc.Layer(); + this.addChild(layer3D, 0); + this._layer3D = layer3D; + this._curState = State.State_None; + this.addNewSpriteWithCoords(cc.math.vec3(0, 0, 0), "Sprite3DTest/girl.c3b", true, 0.2, true); + + var s = cc.winSize; + var containerForLabel1 = new cc.Node(); + this._ZoomOutlabel = new cc.LabelTTF("zoom out", "Arial", 20); + this._ZoomOutlabel.setPosition(s.width-50, cc.visibleRect.top.y-30); + containerForLabel1.addChild(this._ZoomOutlabel); + this.addChild(containerForLabel1, 10); + + cc.eventManager.addListener({ + event:cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches: true, + onTouchBegan:this.onTouchZoomOut.bind(this), + onTouchEnded:this.onTouchZoomOutEnd.bind(this) + }, this._ZoomOutlabel); + + var containerForLabel2 = new cc.Node(); + this._ZoomInlabel = new cc.LabelTTF("zoom in", "Arial", 20); + this._ZoomInlabel.setPosition(s.width-50, cc.visibleRect.top.y - 100); + containerForLabel2.addChild(this._ZoomInlabel); + this.addChild(containerForLabel2, 10); + + cc.eventManager.addListener({ + event:cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches:true, + onTouchBegan:this.onTouchZoomIn.bind(this), + onTouchEnded:this.onTouchZoomInEnd.bind(this) + }, this._ZoomInlabel); + + var containerForLabel3 = new cc.Node(); + this._RotateLeftlabel = new cc.LabelTTF("rotate left", "Arial", 20); + this._RotateLeftlabel.setPosition(s.width-50, cc.visibleRect.top.y - 170); + containerForLabel3.addChild(this._RotateLeftlabel); + this.addChild(containerForLabel3); + + cc.eventManager.addListener({ + event:cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches:true, + onTouchBegan:this.onTouchRotateLeft.bind(this), + onTouchEnded:this.onTouchRotateLeftEnd.bind(this) + }, this._RotateLeftlabel); + + var containerForLabel4 = new cc.Node(); + this._RotateRightlabel = new cc.LabelTTF("rotate right", "Arial", 20); + this._RotateRightlabel.setPosition(s.width-50, cc.visibleRect.top.y - 240); + containerForLabel4.addChild(this._RotateRightlabel); + this.addChild(containerForLabel4, 10); + + cc.eventManager.addListener({ + event:cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches:true, + onTouchBegan:this.onTouchRotateRight.bind(this), + onTouchEnded:this.onTouchRotateRightEnd.bind(this) + }, this._RotateRightlabel); + + var label1 = new cc.LabelTTF("free", "Arial", 20); + var item1 = new cc.MenuItemLabel(label1, this.switchViewCallback, this); + item1.type = CameraType.Free; + item1.setPosition(cc.visibleRect.left.x+100, cc.visibleRect.top.y-50); + + var label2 = new cc.LabelTTF("third person", "Arial", 20); + var item2 = new cc.MenuItemLabel(label2, this.switchViewCallback, this); + item2.type = CameraType.ThirdPerson; + item2.setPosition(cc.visibleRect.left.x+100, cc.visibleRect.top.y-100); + + var label3 = new cc.LabelTTF("first person", "Arial", 20); + var item3 = new cc.MenuItemLabel(label3, this.switchViewCallback, this); + item3.type = CameraType.FirstPerson; + item3.setPosition(cc.visibleRect.left.x+100, cc.visibleRect.top.y-150); + + var menu = new cc.Menu(item1, item2, item3); + menu.setPosition(cc.p(0, 0)); + this.addChild(menu); + + this.schedule(this.updateCamera, 0); + + if(this._camera == null){ + this._camera = cc.Camera.createPerspective(60, s.width/s.height, 1, 1000); + this._camera.setCameraFlag(cc.CameraFlag.USER1); + layer3D.addChild(this._camera); + } + this.switchViewCallback(item2);//third person + + var line = new cc.DrawNode3D(); + //draw x + for(var i = -20; i < 20; ++i) + line.drawLine(cc.math.vec3(-100, 0, 5*i), cc.math.vec3(100, 0, 5*i), cc.color(255, 0, 0, 1)); + + //draw z + for(var j = -20; j < 20; ++j) + line.drawLine(cc.math.vec3(5*j, 0, -100), cc.math.vec3(5*j, 0, 100), cc.color(0, 0, 255, 1)); + + //draw y + line.drawLine(cc.math.vec3(0, -50, 0), cc.math.vec3(0, 0, 0), cc.color(0, 128, 0, 1)); + line.drawLine(cc.math.vec3(0, 0, 0), cc.math.vec3(0, 50, 0), cc.color(0, 255, 0, 1)); + layer3D.addChild(line); + layer3D.setCameraMask(2); + }, + + addNewSpriteWithCoords:function(postion, file, playAnimation, scale, bindCamera){ + var sprite = new jsb.Sprite3D(file); + this._layer3D.addChild(sprite); + var globalZOrder = sprite.getGlobalZOrder(); + sprite.setPosition3D(postion); + sprite.setGlobalZOrder(globalZOrder); + if(playAnimation){ + var animation = jsb.Animation3D.create(file, "Take 001"); + if(animation){ + var animate = jsb.Animate3D.create(animation); + sprite.runAction(cc.repeatForever(animate)); + } + } + if(bindCamera) + this._sprite3D = sprite; + + sprite.setScale(scale); + }, + + updateState:function(dt){ + if(!this._targetPos) + return; + var curPos = this._sprite3D.getPosition3D(); + var m = this._sprite3D.getNodeToWorldTransform3D(); + var curFaceDir = cc.math.vec3(m[8], m[9], m[10]); + curFaceDir.normalize(); + var newFaceDir = cc.math.vec3(this._targetPos.x - curPos.x, this._targetPos.y - curPos.y, this._targetPos.z - curPos.z); + newFaceDir.y = 0; + newFaceDir.normalize(); + var cosAngle = Math.abs(cc.math.vec3Dot(curFaceDir, newFaceDir) - 1); + + var dx = curPos.x - this._targetPos.x, + dy = curPos.y - this._targetPos.y, + dz = curPos.z - this._targetPos.z; + var dist = dx * dx + dy * dy + dz * dz; + + if(dist <= 4){ + if(cosAngle <= 0.01) + this._curState = State.State_Idle; + else + this._curState = State.State_Rotate; + }else{ + if(cosAngle > 0.01) + this._curState = State.State_Rotate | State.State_Move; + else + this._curState = State.State_Move; + } + }, + + move3D:function(dt){ + if(!this._targetPos) + return; + var curPos = this._sprite3D.getPosition3D(); + var newFaceDir = cc.math.vec3(this._targetPos.x - curPos.x, this._targetPos.y - curPos.y, this._targetPos.z - curPos.z); + newFaceDir.y = 0; + newFaceDir.normalize(); + var offset = cc.math.vec3(newFaceDir.x * 25 * dt, newFaceDir.y * 25 * dt, newFaceDir.z * 25 * dt); + curPos.x += offset.x; + curPos.y += offset.y; + curPos.z += offset.z; + this._sprite3D.setPosition3D(curPos); + if(this._cameraType == CameraType.ThirdPerson){ + var cameraPos = this._camera.getPosition3D(); + cameraPos.x += offset.x; + cameraPos.z += offset.z; + this._camera.setPosition3D(cameraPos); + } + }, + + updateCamera:function(dt){ + if(this._cameraType == CameraType.ThirdPerson){ + this.updateState(dt) + + if(this.isState(State.State_Move)){ + this.move3D(dt); + if(this.isState(State.State_Rotate)){ + var curPos = this._sprite3D.getPosition3D(); + var newFaceDir = cc.math.vec3(this._targetPos.x - curPos.x, this._targetPos.y - curPos.y, this._targetPos.z - curPos.z); + newFaceDir.y = 0; + newFaceDir.normalize(); + + var m = this._sprite3D.getNodeToWorldTransform3D(); + var up = cc.math.vec3(m[4], m[5], m[6]); + up.normalize(); + + var right = cc.math.vec3Cross(cc.math.vec3(-newFaceDir.x, -newFaceDir.y, -newFaceDir.z), up); + right.normalize(); + + var mat = [right.x, right.y, right.z, 0, + up.x, up.y, up.z, 0, + newFaceDir.x, newFaceDir.y, newFaceDir.z, 0, + 0, 0, 0, 1]; + + this._sprite3D.setAdditionalTransform(mat); + } + } + } + + if(this._bZoomOut == true){ + if(this._cameraType == CameraType.ThirdPerson){ + var cameraPos = this._camera.getPosition3D(); + var spritePos = this._sprite3D.getPosition3D(); + var lookDir = cc.math.vec3(cameraPos.x - spritePos.x, cameraPos.y - spritePos.y, cameraPos.z - spritePos.z); + if(cc.math.vec3Length(lookDir) <= 300){ + lookDir.normalize(); + cameraPos.x += lookDir.x; + cameraPos.y += lookDir.y; + cameraPos.z += lookDir.z; + this._camera.setPosition3D(cameraPos); + } + }else if(this._cameraType == CameraType.Free){ + var cameraPos = this._camera.getPosition3D(); + if(cc.math.vec3Length(cameraPos) <= 300){ + var n = cc.math.vec3Normalize(cameraPos); + cameraPos.x += n.x; + cameraPos.y += n.y; + cameraPos.z += n.z; + this._camera.setPosition3D(cameraPos); + } + } + } + + if(this._bZoomIn == true){ + if(this._cameraType == CameraType.ThirdPerson){ + var cameraPos = this._camera.getPosition3D(); + var spritePos = this._sprite3D.getPosition3D(); + var lookDir = cc.math.vec3(cameraPos.x - spritePos.x, cameraPos.y - spritePos.y, cameraPos.z - spritePos.z); + if(cc.math.vec3Length(lookDir) >= 50){ + lookDir.normalize(); + cameraPos.x -= lookDir.x; + cameraPos.y -= lookDir.y; + cameraPos.z -= lookDir.z; + this._camera.setPosition3D(cameraPos); + } + }else if(this._cameraType == CameraType.Free){ + var cameraPos = this._camera.getPosition3D(); + if(cc.math.vec3Length(cameraPos) >= 50){ + var n = cc.math.vec3Normalize(cameraPos); + cameraPos.x -= n.x; + cameraPos.y -= n.y; + cameraPos.z -= n.z; + this._camera.setPosition3D(cameraPos); + } + } + } + + if(this._bRotateLeft == true){ + if(this._cameraType == CameraType.Free || this._cameraType == CameraType.FirstPerson){ + var rotation3D = this._camera.getRotation3D(); + rotation3D.y += 1; + this._camera.setRotation3D(rotation3D); + } + } + if(this._bRotateRight == true){ + if(this._cameraType == CameraType.Free || this._cameraType == CameraType.FirstPerson){ + var rotation3D = this._camera.getRotation3D(); + rotation3D.y -= 1; + this._camera.setRotation3D(rotation3D); + } + } + }, + + isState:function(bit){ + return (this._curState & bit) == bit; + }, + + switchViewCallback:function(sender){ + if(this._cameraType == sender.type) + return; + this._cameraType = sender.type; + + if(this._cameraType == CameraType.Free){ var p = this._sprite3D.getPosition3D(); + this._camera.setPosition3D(cc.math.vec3(p.x, p.y+130, p.z+130)); + + this._RotateRightlabel.setColor(cc.color.WHITE); + this._RotateLeftlabel.setColor(cc.color.WHITE); + this._ZoomInlabel.setColor(cc.color.WHITE); + this._ZoomOutlabel.setColor(cc.color.WHITE); + + }else if(this._cameraType == CameraType.FirstPerson){ + var m = this._sprite3D.getWorldToNodeTransform3D(); + var newFaceDir = cc.math.vec3(-m[8], -m[9], -m[10]); + var p = this._sprite3D.getPosition3D(); + this._camera.setPosition3D(cc.math.vec3(p.x, p.y + 35, p.z)); + this._camera.lookAt(cc.math.vec3(p.x + newFaceDir.x*50, p.y + newFaceDir.y*50, p.z+newFaceDir.z*50)); + + this._RotateRightlabel.setColor(cc.color.WHITE); + this._RotateLeftlabel.setColor(cc.color.WHITE); + this._ZoomInlabel.setColor(cc.color.GRAY); + this._ZoomOutlabel.setColor(cc.color.GRAY); + + }else{ + var p = this._sprite3D.getPosition3D(); + this._camera.setPosition3D(cc.math.vec3(p.x, p.y+130, p.z+130)); + this._camera.lookAt(p); + + this._RotateRightlabel.setColor(cc.color.GRAY); + this._RotateLeftlabel.setColor(cc.color.GRAY); + this._ZoomInlabel.setColor(cc.color.WHITE); + this._ZoomOutlabel.setColor(cc.color.WHITE); + } + }, + + onTouchesMoved:function(touches, event){ + if(touches.length == 1){ + var touch = touches[0]; + var location = touch.getLocation(); + var previousLocation = touch.getPreviousLocation(); + var newPos = cc.math.vec3(previousLocation.x - location.x, previousLocation.y - location.y, previousLocation.z - location.z); + if(this._cameraType == CameraType.Free || this._cameraType == CameraType.FirstPerson){ + var m = this._camera.getNodeToWorldTransform3D(); + var cameraDir = cc.math.vec3(-m[8], -m[9], -m[10]); + cameraDir.normalize(); + cameraDir.y = 0; + var cameraRightDir = cc.math.vec3(m[0], m[1], m[2]); + cameraRightDir.normalize(); + cameraRightDir.y = 0; + + var cameraPos = this._camera.getPosition3D(); + cameraPos.x += cameraDir.x*newPos.y*0.1 + cameraRightDir.x*newPos.x*0.1; + cameraPos.y += cameraDir.y*newPos.y*0.1 + cameraRightDir.y*newPos.x*0.1; + cameraPos.z += cameraDir.z*newPos.y*0.1 + cameraRightDir.z*newPos.x*0.1; + this._camera.setPosition3D(cameraPos); + if(this._sprite3D && this._cameraType == CameraType.FirstPerson){ + this._sprite3D.setPosition3D(cc.math.vec3(this._camera.x, 0, this._camera.getVertexZ())); + this._targetPos = this._sprite3D.getPosition3D(); + } + } + } + }, + + onTouchesEnded:function(touches, event){ + for(var i in touches){ + var touch = touches[i]; + var location = touch.getLocationInView(); + if(this._sprite3D && this._cameraType == CameraType.ThirdPerson && this._bZoomOut == false && this._bZoomIn == false && this._bRotateLeft == false && this._bRotateRight == false){ + var nearP = cc.math.vec3(location.x, location.y, -1); + var farP = cc.math.vec3(location.x, location.y, 1); + + nearP = this._camera.unproject(nearP); + farP = this._camera.unproject(farP); + + var dir = cc.math.vec3(farP.x-nearP.x, farP.y-nearP.y, farP.z-nearP.z); + var ndd = dir.y; // (0, 1, 0) * dir + var ndo = nearP.y; // (0, 1, 0) * nearP + var dist = - ndo / ndd; + var p = cc.math.vec3(nearP.x+dist*dir.x, nearP.y+dist*dir.y, nearP.z+dist*dir.z); + + if(p.x > 100) + p.x = 100; + if(p.x < -100) + p.x = -100; + if(p.z > 100) + p.z = 100 + if(p.z < -100) + p.z = -100; + + this._targetPos = p; + } + } + }, + + onTouchZoomOut:function(touch, event){ + var target = event.getCurrentTarget(); + var locationInNode = target.convertToNodeSpace(touch.getLocation()); + var s = target.getContentSize(); + var rect = cc.rect(0, 0, s.width, s.height); + if(cc.rectContainsPoint(rect, locationInNode)){ + this._bZoomOut = true; + return true; + } + return false; + }, + + onTouchZoomOutEnd:function(touch, event){ + this._bZoomOut = false; + }, + + onTouchZoomIn:function(touch, event){ + var target = event.getCurrentTarget(); + var locationInNode = target.convertToNodeSpace(touch.getLocation()); + var s = target.getContentSize(); + var rect = cc.rect(0, 0, s.width, s.height); + if(cc.rectContainsPoint(rect, locationInNode)){ + this._bZoomIn = true; + return true; + } + return false; + }, + + onTouchZoomInEnd:function(touch, event){ + this._bZoomIn = false; + }, + + onTouchRotateLeft:function(touch, event){ + var target = event.getCurrentTarget(); + var locationInNode = target.convertToNodeSpace(touch.getLocation()); + var s = target.getContentSize(); + var rect = cc.rect(0, 0, s.width, s.height); + if(cc.rectContainsPoint(rect, locationInNode)){ + this._bRotateLeft = true; + return true; + } + return false; + }, + + onTouchRotateLeftEnd:function(touch, event){ + this._bRotateLeft = false; + }, + + onTouchRotateRight:function(touch, event){ + var target = event.getCurrentTarget(); + var locationInNode = target.convertToNodeSpace(touch.getLocation()); + var s = target.getContentSize(); + var rect = cc.rect(0, 0, s.width, s.height); + if(cc.rectContainsPoint(rect, locationInNode)){ + this._bRotateRight = true; + return true; + } + return false; + }, + + onTouchRotateRightEnd:function(touch, event){ + this._bRotateRight = false; + } + }); +})(); + +var CameraCullingDemo = Camera3DTestDemo.extend({ + _title:"Camera Frustum Clipping", + _subtitle:"", + _objects:[], + _layer3D:null, + _labelSprite3DCount:null, + _drawAABB:null, + _drawFrustum:null, + _row:3, + _cameraType:CameraType.FirstPerson, + _cameraFirst:null, + _cameraThird:null, + _moveAction:null, + + ctor:function(){ + this._super(); + + this.scheduleUpdate(); + + var layer3D = new cc.Layer(); + this.addChild(layer3D, 0); + this._layer3D = layer3D; + + // swich camera + cc.MenuItemFont.setFontName("Arial"); + cc.MenuItemFont.setFontSize(20); + + var menuItem1 = new cc.MenuItemFont("Switch Camera", this.switchViewCallback, this); + menuItem1.setColor(cc.color(0, 200, 20)); + var menu = new cc.Menu(menuItem1); + menu.setPosition(cc.p(0, 0)); + menuItem1.setPosition(cc.visibleRect.left.x + 80, cc.visibleRect.top.y - 70); + this.addChild(menu); + + // + - + cc.MenuItemFont.setFontSize(40); + var decrease = new cc.MenuItemFont(" - ", this.delSpriteCallback, this); + decrease.setColor(cc.color(0, 200, 20)); + var increase = new cc.MenuItemFont(" + ", this.addSpriteCallback, this); + increase.setColor(cc.color(0, 200, 20)); + + menu = new cc.Menu(decrease, increase); + menu.alignItemsHorizontally(); + menu.setPosition(cc.winSize.width - 60, cc.visibleRect.top.y - 70); + this.addChild(menu, 1); + + this._labelSprite3DCount = new cc.LabelTTF("0 sprites", "Marker Felt", 30); + this._labelSprite3DCount.setColor(cc.color(0, 200, 20)); + this._labelSprite3DCount.setPosition(cc.p(cc.winSize.width / 2, cc.visibleRect.top.y - 70)); + this.addChild(this._labelSprite3DCount); + + // aabb drawNode3D + this._drawAABB = new cc.DrawNode3D(); + this._drawAABB.setCameraMask(cc.CameraFlag.USER1); + this.addChild(this._drawAABB); + + // frustum drawNode3D + this._drawFrustum = new cc.DrawNode3D(); + this._drawFrustum.setCameraMask(cc.CameraFlag.USER1); + this.addChild(this._drawFrustum); + + // set camera + this.switchViewCallback(); + + // add sprite + this.addSpriteCallback(); + }, + + onExit:function(){ + this._super(); + this._moveAction.release(); + }, + + switchViewCallback:function(sender){ + if(!this._cameraFirst){ + var camera = cc.Camera.createPerspective(30, cc.winSize.width/cc.winSize.height, 10, 200); + camera.setCameraFlag(cc.CameraFlag.USER8); + camera.setPosition3D(cc.math.vec3(-100, 0, 0)); + camera.lookAt(cc.math.vec3(1000, 0, 0)); + this._moveAction = cc.moveBy(4, cc.p(200, 0)); + this._moveAction.retain(); + var seq = cc.sequence(this._moveAction, cc.callFunc(this.reachEndCallBack, this)); + seq.setTag(100); + camera.runAction(seq); + this.addChild(camera); + this._cameraFirst = camera; + } + + if(!this._cameraThird){ + var camera = cc.Camera.createPerspective(60, cc.winSize.width/ cc.winSize.height, 1, 1000); + camera.setCameraFlag(cc.CameraFlag.USER8); + camera.setPosition3D(cc.math.vec3(0, 130, 130)); + camera.lookAt(cc.math.vec3(0, 0, 0)); + this.addChild(camera); + this._cameraThird = camera; + } + + if(this._cameraType == CameraType.FirstPerson){ + this._cameraType = CameraType.ThirdPerson; + this._cameraThird.setCameraFlag(cc.CameraFlag.USER1); + this._cameraFirst.setCameraFlag(cc.CameraFlag.USER8); + }else if(this._cameraType == CameraType.ThirdPerson){ + this._cameraType = CameraType.FirstPerson; + this._cameraThird.setCameraFlag(cc.CameraFlag.USER8); + this._cameraFirst.setCameraFlag(cc.CameraFlag.USER1); + this._drawFrustum.clear(); + } + }, + + reachEndCallBack:function(){ + this._cameraFirst.stopActionByTag(100); + var inverse = this._moveAction.reverse(); + inverse.retain(); + this._moveAction.release(); + this._moveAction = inverse; + var rot = cc.rotateBy(1, cc.math.vec3(0, 180, 0)); + var seq = cc.sequence(rot, this._moveAction, cc.callFunc(this.reachEndCallBack, this)); + seq.setTag(100); + this._cameraFirst.runAction(seq); + }, + + delSpriteCallback:function(sender){ + if(this._row == 0) + return; + + this._layer3D.removeAllChildren(); + this._objects.length = 0; + + this._row--; + for(var x = -this._row; x < this._row; ++x){ + for(var z = -this._row; z < this._row; ++z){ + var sprite = new jsb.Sprite3D("Sprite3DTest/orc.c3b"); + sprite.setPosition3D(cc.math.vec3(x * 30, 0, z * 30)); + sprite.setRotation3D(cc.math.vec3(0, 180, 0)); + this._objects.push(sprite); + this._layer3D.addChild(sprite); + } + } + + //set layer mask + this._layer3D.setCameraMask(cc.CameraFlag.USER1); + + //update sprite number + this._labelSprite3DCount.setString(this._layer3D.getChildrenCount() + " sprites"); + }, + + addSpriteCallback:function(sender){ + this._layer3D.removeAllChildren(); + this._objects.length = 0; + this._drawAABB.clear(); + + this._row++; + for(var x = -this._row; x < this._row; ++x){ + for(var z = -this._row; z < this._row; ++z){ + var sprite = new jsb.Sprite3D("Sprite3DTest/orc.c3b"); + sprite.setPosition3D(cc.math.vec3(x * 30, 0, z * 30)); + sprite.setRotation3D(cc.math.vec3(0, 180, 0)); + this._objects.push(sprite); + this._layer3D.addChild(sprite); + } + } + + //set layer mask + this._layer3D.setCameraMask(cc.CameraFlag.USER1); + + //update sprite number + this._labelSprite3DCount.setString(this._layer3D.getChildrenCount() + " sprites"); + }, + + update:function(dt){ + this._drawAABB.clear(); + + if(this._cameraType == CameraType.ThirdPerson) + this.drawCameraFrustum(); + + var children = this._layer3D.getChildren(); + + for(var i in children){ + var aabb = children[i].getAABB(); + if(this._cameraFirst.isVisibleInFrustum(aabb)){ + var corners = cc.math.aabbGetCorners(aabb); + this._drawAABB.drawCube(corners, cc.color(0, 255, 0)); + } + } + }, + + drawCameraFrustum:function(){ + this._drawFrustum.clear(); + var size = cc.winSize; + var color = cc.color(255, 255, 0); + + // top-left + var src = cc.math.vec3(0, 0, 0); + var tl_0 = this._cameraFirst.unproject(src); + src = cc.math.vec3(0, 0, 1); + var tl_1 = this._cameraFirst.unproject(src); + + // top-right + src = cc.math.vec3(size.width, 0, 0); + var tr_0 = this._cameraFirst.unproject(src); + src = cc.math.vec3(size.width, 0, 1); + var tr_1 = this._cameraFirst.unproject(src); + + // bottom-left + src = cc.math.vec3(0, size.height, 0); + var bl_0 = this._cameraFirst.unproject(src); + src = cc.math.vec3(0, size.height, 1); + var bl_1 = this._cameraFirst.unproject(src); + + // bottom-right + src = cc.math.vec3(size.width, size.height, 0); + var br_0 = this._cameraFirst.unproject(src); + src = cc.math.vec3(size.width, size.height, 1); + var br_1 = this._cameraFirst.unproject(src); + + this._drawFrustum.drawLine(tl_0, tl_1, color); + this._drawFrustum.drawLine(tr_0, tr_1, color); + this._drawFrustum.drawLine(bl_0, bl_1, color); + this._drawFrustum.drawLine(br_0, br_1, color); + + this._drawFrustum.drawLine(tl_0, tr_0, color); + this._drawFrustum.drawLine(tr_0, br_0, color); + this._drawFrustum.drawLine(br_0, bl_0, color); + this._drawFrustum.drawLine(bl_0, tl_0, color); + + this._drawFrustum.drawLine(tl_1, tr_1, color); + this._drawFrustum.drawLine(tr_1, br_1, color); + this._drawFrustum.drawLine(br_1, bl_1, color); + this._drawFrustum.drawLine(bl_1, tl_1, color); + } +}); + +var CameraArcBallDemo = Camera3DTestDemo.extend({ + _title:"Camera ArcBall Moving", + _subtitle:"", + _rotationQuat: null, + _layer3D:null, + _camera:null, + _sprite3D1:null, + _sprite3D2:null, + _drawGrid:null, + _operate:OperateCamType.RotateCamera, + _target:0, + _center:cc.math.vec3(0, 0, 0), + _distanceZ:50, + _radius:1, + + ctor:function(){ + this._super(); + this._rotationQuat = cc.math.quaternion(0, 0, 0, 1); + cc.eventManager.addListener({ + event:cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesMoved:this.onTouchesMoved.bind(this) + }, this); + + cc.MenuItemFont.setFontName("Arial"); + cc.MenuItemFont.setFontSize(20); + + var item1 = new cc.MenuItemFont("Switch Operation", this.switchOperateCallback, this); + item1.setColor(cc.color(0, 200, 20)); + var item2 = new cc.MenuItemFont("Switch Target", this.switchTargetCallback, this); + item2.setColor(cc.color(0, 200, 20)); + var menu = new cc.Menu(item1, item2); + menu.setPosition(cc.p(0, 0)); + item1.setPosition(cc.visibleRect.left.x + 80, cc.visibleRect.top.y - 70); + item2.setPosition(cc.visibleRect.left.x + 80, cc.visibleRect.top.y - 100); + this.addChild(menu, 1); + + var layer3D = new cc.Layer(); + this.addChild(layer3D); + this._layer3D = layer3D; + + this._camera = cc.Camera.createPerspective(60, cc.winSize.width/cc.winSize.height, 1, 1000); + this._camera.setCameraFlag(cc.CameraFlag.USER1); + this._camera.setPosition3D(cc.math.vec3(0, 10, 50)); + this._camera.lookAt(cc.math.vec3(0, 0, 0), cc.math.vec3(0, 1, 0)); + layer3D.addChild(this._camera); + + this._sprite3D1 = new jsb.Sprite3D("Sprite3DTest/orc.c3b"); + this._sprite3D1.setScale(0.5); + this._sprite3D1.setRotation3D(cc.math.vec3(0, 180, 0)); + this._sprite3D1.setPosition3D(cc.math.vec3(0, 0, 0)); + layer3D.addChild(this._sprite3D1); + + this._sprite3D2 = new jsb.Sprite3D("Sprite3DTest/boss.c3b"); + this._sprite3D2.setScale(0.6); + this._sprite3D2.setRotation3D(cc.math.vec3(-90, 0, 0)); + this._sprite3D2.setPosition3D(cc.math.vec3(20, 0, 0)); + layer3D.addChild(this._sprite3D2); + + this._drawGrid = new cc.DrawNode3D(); + //draw x + for(var i = -20; i < 20; ++i) + this._drawGrid.drawLine(cc.math.vec3(-100, 0, 5*i), cc.math.vec3(100, 0, 5*i), cc.color(0, 0, 255)); + + //draw z + for(var j = -20; j < 20; ++j) + this._drawGrid.drawLine(cc.math.vec3(5*j, 0, -100), cc.math.vec3(5*j, 0, 100), cc.color(0, 255, 0)); + + //draw y + this._drawGrid.drawLine(cc.math.vec3(0, 0, 0), cc.math.vec3(0, 50, 0), cc.color(0, 255, 0)); + + layer3D.addChild(this._drawGrid); + layer3D.setCameraMask(2); + this.updateCameraTransform(); + }, + + updateCameraTransform:function(){ + var trans = cc.math.mat4CreateTranslation(cc.math.vec3(0, 10, this._distanceZ)); + var rot = cc.math.mat4CreateRotation(this._rotationQuat); + var center = cc.math.mat4CreateTranslation(this._center); + + var result = cc.math.mat4Multiply(cc.math.mat4Multiply(center, rot), trans); + this._camera.setNodeToParentTransform(result); + }, + + switchOperateCallback:function(sender){ + if(this._operate === OperateCamType.MoveCamera) + this._operate = OperateCamType.RotateCamera; + else if(this._operate === OperateCamType.RotateCamera) + this._operate = OperateCamType.MoveCamera; + }, + + switchTargetCallback:function(sender){ + if(this._target === 0 ){ + this._target = 1; + this._center = this._sprite3D2.getPosition3D(); + this.updateCameraTransform(); + }else if(this._target === 1){ + this._target = 0; + this._center = this._sprite3D1.getPosition3D(); + this.updateCameraTransform(); + } + }, + + onTouchesMoved:function(touches, event){ + if(touches.length > 0){ + if(this._operate === OperateCamType.RotateCamera){ //arc ball rotate + var visibleSize = cc.director.getVisibleSize(); + var prelocation = touches[0].getPreviousLocationInView(); + var location = touches[0].getLocationInView(); + location.x = 2 * location.x / visibleSize.width - 1; + location.y = 2 * (visibleSize.height - location.y) / visibleSize.height - 1; + prelocation.x = 2 * prelocation.x / visibleSize.width - 1; + prelocation.y = 2 * (visibleSize.height - prelocation.y) / visibleSize.height - 1; + + var quat = this.calculateArcBall(prelocation.x, prelocation.y, location.x, location.y); //calculate rotation cc.math.quaternion parameters + this._rotationQuat = cc.math.quatMultiply(quat, this._rotationQuat); + + this.updateCameraTransform(); + }else if(this._operate === OperateCamType.MoveCamera){ //camera zoom + var newPos = cc.pSub(touches[0].getPreviousLocation(), touches[0].getLocation()); + this._distanceZ -= newPos.y * 0.1; + + this.updateCameraTransform(); + } + } + }, + + calculateArcBall:function(p1x, p1y, p2x, p2y){ + var axis, angle; + + var rotation_matrix = cc.math.mat4CreateRotation(this._rotationQuat); + + var uv = cc.math.mat4MultiplyVec3(rotation_matrix, cc.math.vec3(0, 1, 0)); //rotation y + var sv = cc.math.mat4MultiplyVec3(rotation_matrix, cc.math.vec3(1, 0, 0)); //rotation x + var lv = cc.math.mat4MultiplyVec3(rotation_matrix, cc.math.vec3(0, 0, -1));//rotation z + + var z = this.projectToSphere(this._radius, p1x, p1y); + var p1 = cc.math.vec3Sub(cc.math.vec3Add(cc.math.vec3(sv.x * p1x, sv.y * p1x, sv.z * p1x), cc.math.vec3(uv.x * p1y, uv.y * p1y, uv.z *p1y)), cc.math.vec3(lv.x * z, lv.y * z, lv.z * z)); //start point screen transform to 3d + z = this.projectToSphere(this._radius, p2x, p2y); + var p2 = cc.math.vec3Sub(cc.math.vec3Add(cc.math.vec3(sv.x * p2x, sv.y * p2x, sv.z * p2x), cc.math.vec3(uv.x * p2y, uv.y * p2y, uv.z *p2y)), cc.math.vec3(lv.x * z, lv.y * z, lv.z * z)); //end point screen transform to 3d + + axis = cc.math.vec3Cross(p2, p1); //calculate rotation axis + axis.normalize(); + + var t = cc.math.vec3Length(cc.math.vec3Sub(p2, p1)) / (2 * this._radius); + //clamp -1 to 1 + if(t > 1) t = 1; + if(t < -1) t = -1; + angle = Math.asin(t); //rotation angle*/ + + return cc.math.quaternion(axis, angle) + }, + + /* project an x,y pair onto a sphere of radius r or a + hyperbolic sheet if we are away from the center of the sphere. */ + projectToSphere:function(r, x, y){ + var d = Math.sqrt(x*x + y*y); + var t, z; + if(d < r * 0.70710678118654752440)//inside sphere + z = Math.sqrt(r*r - d*d) + else{ + t = r / 1.41421356237309504880; + z = t*t / d; + } + return z; + } +}); + +var FogTestDemo = Camera3DTestDemo.extend({ + _title:"Fog Test Demo", + _subtitle:"", + _sprite3D1:null, + _sprite3D2:null, + _camera:null, + _state:null, + + ctor:function(){ + this._super(); + cc.director.setClearColor(cc.color(128, 128, 128)); + + cc.eventManager.addListener({ + event:cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesMoved:this.onTouchesMoved.bind(this) + }, this); + + // swich fog type + var label1 = new cc.LabelTTF("Linear", "Arial", 20); + var item1 = new cc.MenuItemLabel(label1, this.switchTypeCallback, this); + item1.setUserData(0); + var label2 = new cc.LabelTTF("Exp", "Arial", 20); + var item2 = new cc.MenuItemLabel(label2, this.switchTypeCallback, this); + item2.setUserData(1); + var label3 = new cc.LabelTTF("Exp2", "Arial", 20); + var item3 = new cc.MenuItemLabel(label3, this.switchTypeCallback, this); + item3.setUserData(2); + var menu = new cc.Menu(item1, item2, item3); + menu.setPosition(cc.p(0, 0)); + + item1.setPosition(cc.visibleRect.left.x + 60, cc.visibleRect.top.y - 50); + item2.setPosition(cc.visibleRect.left.x + 60, cc.visibleRect.top.y - 100); + item3.setPosition(cc.visibleRect.left.x + 60, cc.visibleRect.top.y - 150); + this.addChild(menu, 0); + + var layer3D = new cc.Layer(); + this.addChild(layer3D, 0); + + var shader = new cc.GLProgram("Sprite3DTest/fog.vert", "Sprite3DTest/fog.frag"); + var state = cc.GLProgramState.create(shader); + this._state = state; + + this._sprite3D1 = new jsb.Sprite3D("Sprite3DTest/teapot.c3b"); + this._sprite3D2 = new jsb.Sprite3D("Sprite3DTest/teapot.c3b"); + + this._sprite3D1.setGLProgramState(state); + this._sprite3D2.setGLProgramState(state); + + //pass mesh's attribute to shader + var offset = 0; + var attributeCount = this._sprite3D1.getMesh().getMeshVertexAttribCount(); + for(var i = 0; i < attributeCount; ++i){ + var meshattribute = this._sprite3D1.getMesh().getMeshVertexAttribute(i); + state.setVertexAttribPointer(cc.attributeNames[meshattribute.vertexAttrib], + meshattribute.size, + meshattribute.type, + gl.FALSE, + this._sprite3D1.getMesh().getVertexSizeInBytes(), + offset); + offset += meshattribute.attribSizeBytes; + } + + var offset1 = 0; + var attributeCount = this._sprite3D2.getMesh().getMeshVertexAttribCount(); + for(var i = 0; i < attributeCount; ++i){ + var meshattribute = this._sprite3D2.getMesh().getMeshVertexAttribute(i); + state.setVertexAttribPointer(cc.attributeNames[meshattribute.vertexAttrib], + meshattribute.size, + meshattribute.type, + gl.FALSE, + this._sprite3D2.getMesh().getVertexSizeInBytes(), + offset1); + offset1 += meshattribute.attribSizeBytes; + } + + state.setUniformVec4("u_fogColor", cc.math.vec4(0.5, 0.5, 0.5, 1.0)); + state.setUniformFloat("u_fogStart", 10); + state.setUniformFloat("u_fogEnd", 60); + state.setUniformInt("u_fogEquation", 0); + + layer3D.addChild(this._sprite3D1); + this._sprite3D1.setPosition3D(cc.math.vec3(0, 0, 0)); + this._sprite3D1.setScale(2); + this._sprite3D1.setRotation3D(cc.math.vec3(-90, 180, 0)); + + layer3D.addChild(this._sprite3D2); + this._sprite3D2.setPosition3D(cc.math.vec3(0, 0, -20)); + this._sprite3D2.setScale(2); + this._sprite3D2.setRotation3D(cc.math.vec3(-90, 180, 0)); + + this._camera = cc.Camera.createPerspective(60, cc.winSize.width/cc.winSize.height, 1, 1000); + this._camera.setCameraFlag(cc.CameraFlag.USER1); + this._camera.setPosition3D(cc.math.vec3(0, 30, 40)); + this._camera.lookAt(cc.math.vec3(0, 0, 0), cc.math.vec3(0, 1, 0)); + layer3D.addChild(this._camera); + layer3D.setCameraMask(2); + }, + + onExit:function(){ + this._super(); + cc.director.setClearColor(cc.color(0, 0, 0)); + }, + + switchTypeCallback:function(sender){ + var type = sender.getUserData(); + if(type === 0){ + this._state.setUniformVec4("u_fogColor", cc.math.vec4(0.5, 0.5, 0.5, 1.0)); + this._state.setUniformFloat("u_fogStart", 10); + this._state.setUniformFloat("u_fogEnd", 60); + this._state.setUniformInt("u_fogEquation", 0); + + this._sprite3D1.setGLProgramState(this._state); + this._sprite3D2.setGLProgramState(this._state); + }else if(type === 1){ + this._state.setUniformVec4("u_fogColor", cc.math.vec4(0.5, 0.5, 0.5, 1.0)); + this._state.setUniformFloat("u_fogDensity", 0.03); + this._state.setUniformInt("u_fogEquation", 1); + + this._sprite3D1.setGLProgramState(this._state); + this._sprite3D2.setGLProgramState(this._state); + }else if(type === 2){ + this._state.setUniformVec4("u_fogColor", cc.math.vec4(0.5, 0.5, 0.5, 1.0)); + this._state.setUniformFloat("u_fogDensity", 0.03); + this._state.setUniformInt("u_fogEquation", 2); + + this._sprite3D1.setGLProgramState(this._state); + this._sprite3D2.setGLProgramState(this._state); + } + }, + + onTouchesMoved:function(touches, event){ + if(touches.length === 1){ + var prelocation = touches[0].getPreviousLocationInView(); + var location = touches[0].getLocationInView(); + var newPos = cc.math.vec3Sub(prelocation, location); + + var m = this._camera.getNodeToWorldTransform3D(); + var cameraDir = cc.math.vec3(-m[8], -m[9], -m[10]); + cameraDir.normalize(); + cameraDir.y = 0; + var cameraRightDir = cc.math.vec3(m[0], m[1], m[2]); + cameraRightDir.normalize(); + cameraRightDir.y = 0; + + var cameraPos = this._camera.getPosition3D(); + cameraPos.x += cameraDir.x*newPos.y*0.1 + cameraRightDir.x*newPos.x*0.1; + cameraPos.y += cameraDir.y*newPos.y*0.1 + cameraRightDir.y*newPos.x*0.1; + cameraPos.z += cameraDir.z*newPos.y*0.1 + cameraRightDir.z*newPos.x*0.1; + this._camera.setPosition3D(cameraPos); + } + } +}); + +// +// Flow control +// +var arrayOfCamera3DTest = [ + CameraRotationTest, + Camera3DTest, + CameraCullingDemo, + CameraArcBallDemo +]; + +if(cc.sys.os !== cc.sys.OS_WP8 || cc.sys.os !== cc.sys.OS_WINRT){ + arrayOfCamera3DTest.push(FogTestDemo); +} + +var nextCamera3DTest = function () { + Camera3DTestIdx++; + Camera3DTestIdx = Camera3DTestIdx % arrayOfCamera3DTest.length; + + return new arrayOfCamera3DTest[Camera3DTestIdx ](); +}; +var previousCamera3DTest = function () { + Camera3DTestIdx--; + if (Camera3DTestIdx < 0) + Camera3DTestIdx += arrayOfCamera3DTest.length; + + return new arrayOfCamera3DTest[Camera3DTestIdx ](); +}; +var restartCamera3DTest = function () { + return new arrayOfCamera3DTest[Camera3DTestIdx ](); +}; diff --git a/tests/js-tests/src/ChipmunkTest/ChipmunkTest.js b/tests/js-tests/src/ChipmunkTest/ChipmunkTest.js new file mode 100644 index 0000000000..1988649904 --- /dev/null +++ b/tests/js-tests/src/ChipmunkTest/ChipmunkTest.js @@ -0,0 +1,2107 @@ + /** + * 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. + * + * + * Chipmunk Demo code: + * Original Demo code written in C by Scott Lembcke + * Ported to JavaScript by Joseph Gentle + * Additions to the demo code by Ricardo Quesada + */ + +// +// JavaScript + chipmunk tests +// + +var chipmunkTestSceneIdx = -1; + + +//------------------------------------------------------------------ +// +// ChipmunkBaseLayer +// +//------------------------------------------------------------------ +var ChipmunkBaseLayer = BaseTestLayer.extend( { + ctor : function() { + // + // VERY IMPORTANT + // + // Only subclasses of a native classes MUST call cc.associateWithNative + // Failure to do so, it will crash. + // + this._super( cc.color(0,0,0,255), cc.color(98*0.5,99*0.5,117*0.5,255) ); + + this._title = "No title"; + this._subtitle = "No Subtitle"; + + // Menu to toggle debug physics on / off + var item = new cc.MenuItemFont("Physics On/Off", this.onToggleDebug, this); + item.fontSize = 24; + var menu = new cc.Menu( item ); + this.addChild( menu ); + menu.x = winSize.width-100; + menu.y = winSize.height-90; + + // Create the initial space + this.space = new cp.Space(); + + this.setupDebugNode(); + }, + + setupDebugNode : function() + { + // debug only + this._debugNode = new cc.PhysicsDebugNode(this.space ); + this._debugNode.visible = false ; + this.addChild( this._debugNode ); + }, + + onToggleDebug : function(sender) { + var state = this._debugNode.visible; + this._debugNode.visible = !state ; + }, + + onEnter : function() { + BaseTestLayer.prototype.onEnter.call(this); + //cc.base(this, 'onEnter'); + + cc.sys.dumpRoot(); + cc.sys.garbageCollect(); + }, + + onCleanup : function() { + // Not compulsory, but recommended: cleanup the scene + this.unscheduleUpdate(); + }, + + onRestartCallback : function (sender) { + this.onCleanup(); + var s = new ChipmunkTestScene(); + s.addChild(restartChipmunkTest()); + director.runScene(s); + }, + + onNextCallback : function (sender) { + this.onCleanup(); + var s = new ChipmunkTestScene(); + s.addChild(nextChipmunkTest()); + director.runScene(s); + }, + + onBackCallback : function (sender) { + this.onCleanup(); + var s = new ChipmunkTestScene(); + s.addChild(previousChipmunkTest()); + director.runScene(s); + }, + + numberOfPendingTests : function() { + return ( (arrayOfChipmunkTest.length-1) - chipmunkTestSceneIdx ); + }, + + getTestNumber : function() { + return chipmunkTestSceneIdx; + } +}); + +//------------------------------------------------------------------ +// +// Chipmunk + Sprite +// +//------------------------------------------------------------------ +var ChipmunkSprite = ChipmunkBaseLayer.extend( { + + ctor: function() { + this._super(); + //cc.base(this); + + this.addSprite = function( pos ) { + var sprite = this.createPhysicsSprite( pos ); + this.addChild( sprite ); + }; + + this._title = 'Chipmunk Sprite Test'; + this._subtitle = 'Chipmunk + cocos2d sprites tests. Tap screen.'; + + this.initPhysics(); + }, + + title : function(){ + return 'Chipmunk Sprite Test'; + }, + + initPhysics : function() { + var space = this.space ; + var staticBody = 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 shape = walls[i]; + shape.setElasticity(1); + shape.setFriction(1); + space.addStaticShape( shape ); + } + + // Gravity + space.gravity = cp.v(0, -100); + }, + + createPhysicsSprite : function( pos ) { + 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(s_pathGrossini); + sprite.setBody( body ); + return sprite; + }, + + onEnter : function () { + ChipmunkBaseLayer.prototype.onEnter.call(this); + //cc.base(this, 'onEnter'); + + this.scheduleUpdate(); + for(var i=0; i<10; i++) { + var variancex = cc.randomMinus1To1() * 5; + var variancey = cc.randomMinus1To1() * 5; + this.addSprite( cp.v(winSize.width/2 + variancex, winSize.height/2 + variancey) ); + } + + if( 'touches' in cc.sys.capabilities ){ + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded: function(touches, event){ + var l = touches.length, target = event.getCurrentTarget(); + for( var i=0; i < l; i++) { + target.addSprite( touches[i].getLocation() ); + } + } + }, this); + } else if( 'mouse' in cc.sys.capabilities ) + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseDown: function(event){ + event.getCurrentTarget().addSprite(event.getLocation()); + } + }, this); + }, + + update : function( delta ) { + this.space.step( delta ); + } +}); + +//------------------------------------------------------------------ +// +// Chipmunk + Sprite + Batch +// +//------------------------------------------------------------------ +var ChipmunkSpriteBatchTest = ChipmunkSprite.extend( { + ctor : function () { + this._super(); + // cc.base(this); + + // batch node + this.batch = new cc.SpriteBatchNode(s_pathGrossini, 50 ); + this.addChild( this.batch ); + + this.addSprite = function( pos ) { + var sprite = this.createPhysicsSprite( pos ); + this.batch.addChild( sprite ); + }; + + this._title = 'Chipmunk SpriteBatch Test'; + this._subtitle = 'Chipmunk + cocos2d sprite batch tests. Tap screen.'; + }, + + title : function(){ + return 'Chipmunk SpriteBatch Test'; + } +}); + + //------------------------------------------------------------------ + // + // 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 +// Using Object Oriented API. +// Base your samples on the "Object Oriented" API. +// +//------------------------------------------------------------------ +var ChipmunkCollisionTest = ChipmunkBaseLayer.extend( { + + ctor : function () { + this._super(); + // cc.base(this); + + this._title = 'Chipmunk Collision test'; + this._subtitle = 'Using Object Oriented API. ** Use this API **'; + }, + + // 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, collision_type ) { + 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 ); + shape.setCollisionType( collision_type ); + this.space.addShape( shape ); + + var sprite = new cc.PhysicsSprite(file); + sprite.setBody( body ); + return sprite; + }, + + onEnter : function () { + ChipmunkBaseLayer.prototype.onEnter.call(this); + // cc.base(this, 'onEnter'); + + this.initPhysics(); + this.scheduleUpdate(); + + var sprite1 = this.createPhysicsSprite( cc.p(winSize.width/2, winSize.height-20), s_pathGrossini, 1); + var sprite2 = this.createPhysicsSprite( cc.p(winSize.width/2, 50), s_pathSister1, 2); + + this.addChild( sprite1 ); + this.addChild( sprite2 ); + + this.space.addCollisionHandler( 1, 2, + this.collisionBegin.bind(this), + this.collisionPre.bind(this), + this.collisionPost.bind(this), + this.collisionSeparate.bind(this) + ); + }, + + onExit : function() { + this.space.removeCollisionHandler( 1, 2 ); + ChipmunkBaseLayer.prototype.onExit.call(this); + }, + + update : function( delta ) { + this.space.step( delta ); + }, + + collisionBegin : function ( arbiter, space ) { + + if( ! this.messageDisplayed ) { + var label = new cc.LabelBMFont("Collision Detected", s_bitmapFontTest5_fnt); + this.addChild( label ); + label.x = winSize.width/2; + label.y = winSize.height/2 ; + this.messageDisplayed = true; + } + cc.log('collision begin'); + var shapes = arbiter.getShapes(); + var collTypeA = shapes[0].collision_type; + 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; + }, + + collisionPost : function ( arbiter, space ) { + cc.log('collision post'); + }, + + collisionSeparate : function ( arbiter, space ) { + cc.log('collision separate'); + }, + + title : function(){ + return 'Chipmunk Collision test'; + } +}); + + +//------------------------------------------------------------------ +// +// Chipmunk Collision Test +// Using "C" API. +// XXX DO NOT USE THE "C" API. +// XXX IT WAS ADDED FOR TESTING PURPOSES ONLY +// +//------------------------------------------------------------------ +var ChipmunkCollisionTestB = ChipmunkBaseLayer.extend( { + + ctor: function () { + this._super(); + // cc.base(this); + + this.messageDisplayed = false; + + this._title = 'Chipmunk Collision Test'; + this._subtitle = 'using "C"-like API. ** DO NOT USE THIS API **'; + }, + + // init physics + initPhysics : function() { + this.space = cp.spaceNew(); + + // update Physics Debug Node with new space + this._debugNode.setSpace(this.space); + + var staticBody = cp.spaceGetStaticBody( this.space ); + + // Walls using "C" API. DO NO USE THIS API + var walls = [cp.segmentShapeNew( staticBody, cp.v(0,0), cp.v(winSize.width,0), 0 ), // bottom + cp.segmentShapeNew( staticBody, cp.v(0,winSize.height), cp.v(winSize.width,winSize.height), 0), // top + cp.segmentShapeNew( staticBody, cp.v(0,0), cp.v(0,winSize.height), 0), // left + cp.segmentShapeNew( staticBody, cp.v(winSize.width,0), cp.v(winSize.width,winSize.height), 0) // right + ]; + + for( var i=0; i < walls.length; i++ ) { + // 'properties' using "C" API. DO NO USE THIS API + var wall = walls[i]; + cp.shapeSetElasticity(wall, 1); + cp.shapeSetFriction(wall, 1); + cp.spaceAddStaticShape( this.space, wall ); + } + + // Gravity + cp.spaceSetGravity( this.space, cp.v(0, -30) ); + }, + + createPhysicsSprite : function( pos, file, collision_type ) { + // using "C" API. DO NO USE THIS API + var body = cp.bodyNew(1, cp.momentForBox(1, 48, 108) ); + cp.bodySetPos( body, pos ); + cp.spaceAddBody( this.space, body ); + var shape = cp.boxShapeNew( body, 48, 108); + cp.shapeSetElasticity( shape, 0.5 ); + cp.shapeSetFriction( shape, 0.5 ); + cp.shapeSetCollisionType( shape, collision_type ); + cp.spaceAddShape( this.space, shape ); + + var sprite = new cc.PhysicsSprite(file); + sprite.setBody( body ); + return sprite; + }, + + onEnter : function () { + ChipmunkBaseLayer.prototype.onEnter.call(this); + // cc.base(this, 'onEnter'); + + this.initPhysics(); + this.scheduleUpdate(); + + var sprite1 = this.createPhysicsSprite( cc.p(winSize.width/2, winSize.height-20), s_pathGrossini, 1); + var sprite2 = this.createPhysicsSprite( cc.p(winSize.width/2, 50), s_pathSister1, 2); + + this.addChild( sprite1 ); + this.addChild( sprite2 ); + + cp.spaceAddCollisionHandler( this.space, 1, 2, + this.collisionBegin.bind(this), + this.collisionPre.bind(this), + this.collisionPost.bind(this), + this.collisionSeparate.bind(this) ); + }, + + onExit : function() { + cp.spaceRemoveCollisionHandler( this.space, 1, 2 ); + cp.spaceFree( this.space ); + ChipmunkBaseLayer.prototype.onExit.call(this); + }, + + update : function( delta ) { + cp.spaceStep( this.space, delta ); + }, + + collisionBegin : function ( arbiter, space ) { + + if( ! this.messageDisplayed ) { + var label = new cc.LabelBMFont("Collision Detected", s_bitmapFontTest5_fnt); + this.addChild( label ); + label.x = winSize.width/2; + label.y = winSize.height/2 ; + this.messageDisplayed = true; + } + cc.log('collision begin'); + var bodies = cp.arbiterGetBodies( arbiter ); + var shapes = cp.arbiterGetShapes( arbiter ); + var collTypeA = cp.shapeGetCollisionType( shapes[0] ); + var collTypeB = cp.shapeGetCollisionType( shapes[1] ); + cc.log( 'Collision Type A:' + collTypeA ); + cc.log( 'Collision Type B:' + collTypeB ); + 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 Memory Leak Test +// +//------------------------------------------------------------------ +var ChipmunkCollisionMemoryLeakTest = ChipmunkBaseLayer.extend({ + + ctor : function() { + this._super(); + // cc.base(this); + + this._title = 'Chipmunk Memory Leak Test'; + this._subtitle = 'Testing possible memory leak on the collision handler. No visual feedback'; + }, + + collisionBegin : function ( arbiter, space ) { + return true; + }, + + collisionPre : function ( arbiter, space ) { + return true; + }, + + collisionPost : function ( arbiter, space ) { + cc.log('collision post'); + }, + + collisionSeparate : function ( arbiter, space ) { + cc.log('collision separate'); + }, + + onEnter : function() { + ChipmunkBaseLayer.prototype.onEnter.call(this); + // cc.base(this, 'onEnter'); + + for( var i=1 ; i < 100 ; i++ ) + this.space.addCollisionHandler( i, i+1, + this.collisionBegin.bind(this), + this.collisionPre.bind(this), + this.collisionPost.bind(this), + this.collisionSeparate.bind(this) + ); + + }, + + onExit : function() { + ChipmunkBaseLayer.prototype.onExit.call(this); + + for( var i=1 ; i < 100 ; i++ ) + this.space.removeCollisionHandler( i, i+1 ); + }, + + title : function(){ + return 'Chipmunk Memory Leak Test'; + } +}); + +//------------------------------------------------------------------ +// +// Test Anchor Point with PhysicsSprite +// +//------------------------------------------------------------------ +var ChipmunkSpriteAnchorPoint = ChipmunkBaseLayer.extend({ + + ctor : function() { + this._super(); + // cc.base(this); + + this._title = 'AnchorPoint in PhysicsSprite'; + this._subtitle = 'Tests AnchorPoint in PhysicsSprite. See animated sprites'; + }, + + onEnter : function() { + ChipmunkBaseLayer.prototype.onEnter.call(this); + // cc.base(this, 'onEnter'); + + this._debugNode.visible = true ; + + this.space.gravity = v(0, 0); + + var sprite1 = this.createPhysicsSprite( cp.v(winSize.width/4*1, winSize.height/2) ); + var sprite2 = this.createPhysicsSprite( cp.v(winSize.width/4*2, winSize.height/2) ); + var sprite3 = this.createPhysicsSprite( cp.v(winSize.width/4*3, winSize.height/2) ); + + sprite1.anchorX = 0; + sprite1.anchorY = 0; + sprite2.anchorX = 0.5; + sprite2.anchorY = 0.5; + sprite3.anchorX = 1; + sprite3.anchorY = 1; + + // scale sprite + var scaledown = cc.scaleBy(0.5, 0.5); + var scaleup = scaledown.reverse(); + var seq = cc.sequence( scaledown, scaleup); + var repeat = seq.repeatForever(); + + sprite1.runAction( repeat ); + sprite2.runAction( repeat.clone() ); + sprite3.runAction( repeat.clone() ); + + this.addChild(sprite1); + this.addChild(sprite2); + this.addChild(sprite3); + + this.scheduleUpdate(); + }, + + title : function(){ + return 'AnchorPoint in PhysicsSprite'; + }, + + createPhysicsSprite : function(pos) { + + // create body + var body = new cp.Body(1, cp.momentForBox(1, 48, 108) ); + body.setPos( pos ); + this.space.addBody( body ); + + // create shape + var shape = new cp.BoxShape( body, 48, 108); + shape.setElasticity( 0.5 ); + shape.setFriction( 0.5 ); + this.space.addShape( shape ); + + // create sprite + var sprite = new cc.PhysicsSprite(s_pathGrossini); + + // associate sprite with body + sprite.setBody( body ); + + return sprite; + }, + + update : function(dt) { + var steps = 1; + dt /= steps; + for (var i = 0; i < steps; i++){ + this.space.step(dt); + } + } +}); + + +//------------------------------------------------------------------ +// +// ChipmunkReleaseTest +// +//------------------------------------------------------------------ +var ChipmunkReleaseTest = ChipmunkBaseLayer.extend({ + + ctor : function () { + this._super(); + // cc.base(this); + + this._title = 'Chipmunk Release Test'; + this._subtitle = 'Space finalizer should be called'; + }, + + collisionBegin : function ( arbiter, space ) { + return true; + }, + + collisionPre : function ( arbiter, space ) { + return true; + }, + + collisionPost : function ( arbiter, space ) { + cc.log('collision post'); + }, + + collisionSeparate : function ( arbiter, space ) { + cc.log('collision separate'); + }, + + onEnter : function() { + ChipmunkBaseLayer.prototype.onEnter.call(this); + // cc.base(this, 'onEnter'); + + cc.log("OnEnter"); + cc.sys.dumpRoot(); + cc.sys.garbageCollect(); + + this.space.addCollisionHandler( 10,11, + this.collisionBegin.bind(this), + this.collisionPre.bind(this), + this.collisionPost.bind(this), + this.collisionSeparate.bind(this) + ); + + }, + + onExit : function() { + + cc.log("OnExit"); + + // not calling this on purpose + // this.space.removeCollisionHandler( 10, 11 ); + + this.space = null; + + cc.sys.dumpRoot(); + cc.sys.garbageCollect(); + + // cc.base(this, 'onExit'); + ChipmunkBaseLayer.prototype.onExit.call(this); + } +}); + +// +// Base class for Chipmunk Demo +// +// Chipmunk Demos from Chipmunk-JS project +// https://github.com/josephg/chipmunk-js +// + +var v = cp.v; +var ctx; +var GRABABLE_MASK_BIT = 1<<31; +var NOT_GRABABLE_MASK = ~GRABABLE_MASK_BIT; + +var ChipmunkDemo = ChipmunkBaseLayer.extend( { + ctor : function () { + this._super(); + //cc.base(this); + + this.remainder = 0; + + // debug only + this._debugNode.visible = true ; + + this.scheduleUpdate(); + }, + + update : function(dt) { + this.space.step(dt); + }, + + addFloor : function() { + var space = this.space; + var floor = space.addShape(new cp.SegmentShape(space.staticBody, v(0, 0), v(640, 0), 0)); + floor.setElasticity(1); + floor.setFriction(1); + floor.setLayers(NOT_GRABABLE_MASK); + }, + + addWalls : function() { + var space = this.space; + var wall1 = space.addShape(new cp.SegmentShape(space.staticBody, v(0, 0), v(0, 480), 0)); + wall1.setElasticity(1); + wall1.setFriction(1); + wall1.setLayers(NOT_GRABABLE_MASK); + + var wall2 = space.addShape(new cp.SegmentShape(space.staticBody, v(640, 0), v(640, 480), 0)); + wall2.setElasticity(1); + wall2.setFriction(1); + wall2.setLayers(NOT_GRABABLE_MASK); + } +}); + +//------------------------------------------------------------------ +// +// Chipmunk Demo: Pyramid Stack +// +//------------------------------------------------------------------ +var PyramidStack = ChipmunkDemo.extend( { + + ctor : function () { + this._super(); + // cc.base(this); + this._subtitle = 'Chipmunk Demo'; + this._title = 'Pyramid Stack'; + + var space = this.space; + //space.iterations = 30; + space.gravity = v(0, -100); + space.sleepTimeThreshold = 0.5; + space.collisionSlop = 0.5; + + var body, staticBody = space.staticBody; + var shape; + + this.addFloor(); + this.addWalls(); + + // Add lots of boxes. + for(var i=0; i<14; i++){ + for(var j=0; j<=i; j++){ + body = space.addBody(new cp.Body(1, cp.momentForBox(1, 30, 30))); + body.setPos(v(j*32 - i*16 + 320, 540 - i*32)); + + shape = space.addShape(new cp.BoxShape(body, 30, 30)); + shape.setElasticity(0); + shape.setFriction(0.8); + } + } + + // Add a ball to make things more interesting + var radius = 15; + body = space.addBody(new cp.Body(10, cp.momentForCircle(10, 0, radius, v(0,0)))); + body.setPos(v(320, radius+5)); + + shape = space.addShape(new cp.CircleShape(body, radius, v(0,0))); + shape.setElasticity(0); + shape.setFriction(0.9); + }, + + title : function(){ + return 'Pyramid Stack'; + } +}); + +//------------------------------------------------------------------ +// +// Chipmunk Demo: Pyramid Topple +// +//------------------------------------------------------------------ +var PyramidTopple = ChipmunkDemo.extend( { + + ctor : function() { + this._super(); + // cc.base(this); + this._subtitle = 'Chipmunk Demo'; + this._title = 'Pyramid Topple'; + + var WIDTH = 4; + var HEIGHT = 30; + + var space = this.space; + + var add_domino = function(pos, flipped) + { + var mass = 1; + var moment = cp.momentForBox(mass, WIDTH, HEIGHT); + + var body = space.addBody(new cp.Body(mass, moment)); + body.setPos(pos); + + var shape = (flipped ? new cp.BoxShape(body, HEIGHT, WIDTH) : new cp.BoxShape(body, WIDTH, HEIGHT)); + space.addShape(shape); + shape.setElasticity(0); + shape.setFriction(0.6); + }; + + space.iterations = 30; + space.gravity = v(0, -300); + space.sleepTimeThreshold = 0.5; + space.collisionSlop = 0.5; + + this.addFloor(); + + // Add the dominoes. + var n = 12; + for(var i=0; i= 0; y -= 120) { + shape = space.addShape(new cp.SegmentShape(staticBody, v(0,y), v(640,y), 0)); + shape.setElasticity(1); + shape.setFriction(1); + shape.layers = NOT_GRABABLE_MASK; + } + + for(var x = 0; x <= 640; x += 160) { + shape = space.addShape(new cp.SegmentShape(staticBody, v(x,0), v(x,480), 0)); + shape.setElasticity(1); + shape.setFriction(1); + shape.layers = NOT_GRABABLE_MASK; + } + + var body1, body2; + + var posA = v( 50, 60); + var posB = v(110, 60); + + var POS_A = function() { return cp.v.add(boxOffset, posA); }; + var POS_B = function() { return cp.v.add(boxOffset, posB); }; + //#define POS_A vadd(boxOffset, posA) + //#define POS_B vadd(boxOffset, posB) + + this.labels = labels = []; + var label = function(text) { + labels.push({text:text, pos:boxOffset}); + }; + + // Pin Joints - Link shapes with a solid bar or pin. + // Keeps the anchor points the same distance apart from when the joint was created. + boxOffset = v(0, 0); + label('Pin Joint'); + body1 = addBall(posA); + body2 = addBall(posB); + body2.setAngle(Math.PI); + 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. + boxOffset = v(160, 0); + label('Slide Joint'); + body1 = addBall(posA); + body2 = addBall(posB); + body2.setAngle(Math.PI); + 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); + label('Pivot Joint'); + body1 = addBall(posA); + body2 = addBall(posB); + 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) + 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); + 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); + label('Damped Spring'); + body1 = addBall(posA); + body2 = addBall(posB); + body2.setAngle(Math.PI); + 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); + label('Damped Rotary Spring'); + body1 = addBar(posA); + body2 = addBar(posB); + // 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())); + 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); + label('Rotary Limit Joint'); + body1 = addLever(posA); + body2 = addLever(posB); + // 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())); + // Hold their rotation within 90 degrees of each other. + 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); + label('Ratchet Joint'); + body1 = addLever(posA); + body2 = addLever(posB); + // 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())); + // Ratchet every 90 degrees + 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); + label('Gear Joint'); + body1 = addBar(posA); + body2 = addBar(posB); + // 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())); + // Force one to sping 2x as fast as the other + 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); + label('Simple Motor'); + body1 = addBar(posA); + body2 = addBar(posB); + // 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())); + // Make them spin at 1/2 revolution per second in relation to each other. + 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); + var wheel1 = addWheel(posA); + var wheel2 = addWheel(posB); + var chassis = addChassis(v(80, 100)); + + space.addConstraint(new cp.GrooveJoint(chassis, wheel1, v(-30, -10), v(-30, -40), v(0,0))); + space.addConstraint(new cp.GrooveJoint(chassis, wheel2, v( 30, -10), v( 30, -40), v(0,0))); + + space.addConstraint(new cp.DampedSpring(chassis, wheel1, v(-30, 0), v(0,0), 50, 20, 10)); + space.addConstraint(new cp.DampedSpring(chassis, wheel2, v( 30, 0), v(0,0), 50, 20, 10)); + }, + + title : function(){ + return 'Joints'; + } +}); + +//------------------------------------------------------------------ +// +// Chipmunk Demo: Balls +// +//------------------------------------------------------------------ +var Balls = ChipmunkDemo.extend({ + ctor: function() { + this._super(); + // cc.base(this); + this._subtitle = 'Chipmunk Demo'; + this._title = 'Balls'; + + var space = this.space; + space.iterations = 60; + space.gravity = v(0, -500); + space.sleepTimeThreshold = 0.5; + space.collisionSlop = 0.5; + space.sleepTimeThreshold = 0.5; + + this.addFloor(); + this.addWalls(); + + var width = 50; + var height = 60; + var mass = width * height * 1/1000; + var rock = space.addBody(new cp.Body(mass, cp.momentForBox(mass, width, height))); + rock.setPos(v(500, 100)); + rock.setAngle(1); + shape = space.addShape(new cp.BoxShape(rock, width, height)); + shape.setFriction(0.3); + shape.setElasticity(0.3); + + for (var i = 1; i <= 10; i++) { + var radius = 20; + mass = 3; + var body = space.addBody(new cp.Body(mass, cp.momentForCircle(mass, 0, radius, v(0, 0)))); + body.setPos(v(200 + i, (2 * radius + 5) * i)); + var circle = space.addShape(new cp.CircleShape(body, radius, v(0, 0))); + circle.setElasticity(0.8); + circle.setFriction(1); + } + /* + * atom.canvas.onmousedown = function(e) { + radius = 10; + mass = 3; + body = space.addBody(new cp.Body(mass, cp.momentForCircle(mass, 0, radius, v(0, 0)))); + body.setPos(v(e.clientX, e.clientY)); + circle = space.addShape(new cp.CircleShape(body, radius, v(0, 0))); + circle.setElasticity(0.5); + return circle.setFriction(1); + }; + */ + + // this.ctx.strokeStyle = "black"; + + var ramp = space.addShape(new cp.SegmentShape(space.staticBody, v(100, 100), v(300, 200), 10)); + ramp.setElasticity(1); + ramp.setFriction(1); + ramp.setLayers(NOT_GRABABLE_MASK); + }, + + title : function(){ + return 'Balls'; + } +}); + + +//------------------------------------------------------------------ +// +// Buoyancy +// +//------------------------------------------------------------------ + +var FLUID_DENSITY = 0.00014; +var FLUID_DRAG = 2.0; + +var Buoyancy = ChipmunkDemo.extend( { + ctor: function() { + this._super(); + // cc.base(this); + this._subtitle = 'Chipmunk Demo'; + this._title = 'Buoyancy'; + + var space = this.space; + space.iterations = 30; + space.gravity = cp.v(0,-500); + // cpSpaceSetDamping(space, 0.5); + space.sleepTimeThreshold = 0.5; + space.collisionSlop = 0.5; + + var staticBody = space.staticBody; + + // Create segments around the edge of the screen. + var shape = space.addShape( new cp.SegmentShape(staticBody, cp.v(0,0), cp.v(0,480), 0.0)); + shape.setElasticity(1.0); + shape.setFriction(1.0); + shape.setLayers(NOT_GRABABLE_MASK); + + shape = space.addShape( new cp.SegmentShape(staticBody, cp.v(640,0), cp.v(640,480), 0.0)); + shape.setElasticity(1.0); + shape.setFriction(1.0); + shape.setLayers(NOT_GRABABLE_MASK); + + shape = space.addShape( new cp.SegmentShape(staticBody, cp.v(0,0), cp.v(640,0), 0.0)); + shape.setElasticity(1.0); + shape.setFriction(1.0); + shape.setLayers(NOT_GRABABLE_MASK); + + shape = space.addShape( new cp.SegmentShape(staticBody, cp.v(0,480), cp.v(640,480), 0.0)); + shape.setElasticity(1.0); + shape.setFriction(1.0); + shape.setLayers(NOT_GRABABLE_MASK); + + // { + // Add the edges of the bucket + var bb = new cp.BB(20, 40, 420, 240); + var radius = 5.0; + + shape = space.addShape( new cp.SegmentShape(staticBody, cp.v(bb.l, bb.b), cp.v(bb.l, bb.t), radius)); + shape.setElasticity(1.0); + shape.setFriction(1.0); + shape.setLayers(NOT_GRABABLE_MASK); + + shape = space.addShape( new cp.SegmentShape(staticBody, cp.v(bb.r, bb.b), cp.v(bb.r, bb.t), radius)); + shape.setElasticity(1.0); + shape.setFriction(1.0); + shape.setLayers(NOT_GRABABLE_MASK); + + shape = space.addShape( new cp.SegmentShape(staticBody, cp.v(bb.l, bb.b), cp.v(bb.r, bb.b), radius)); + shape.setElasticity(1.0); + shape.setFriction(1.0); + shape.setLayers(NOT_GRABABLE_MASK); + + // Add the sensor for the water. + shape = space.addShape( new cp.BoxShape2(staticBody, bb) ); + shape.setSensor(true); + shape.setCollisionType(1); + // } + + + // { + var width = 200.0; + var height = 50.0; + var mass = 0.3*FLUID_DENSITY*width*height; + var moment = cp.momentForBox(mass, width, height); + + body = space.addBody( new cp.Body(mass, moment)); + body.setPos( cp.v(270, 140)); + body.setVel( cp.v(0, -100)); + body.setAngVel( 1 ); + + shape = space.addShape( new cp.BoxShape(body, width, height)); + shape.setFriction(0.8); + // } + + // { + width = 40.0; + height = width*2; + mass = 0.3*FLUID_DENSITY*width*height; + moment = cp.momentForBox(mass, width, height); + + body = space.addBody( new cp.Body(mass, moment)); + body.setPos(cp.v(120, 190)); + body.setVel(cp.v(0, -100)); + body.setAngVel(1); + + shape = space.addShape(new cp.BoxShape(body, width, height)); + shape.setFriction(0.8); + // } + }, + + update: function(dt) { + var steps = 3; + dt /= steps; + for (var i = 0; i < 3; i++){ + this.space.step(dt); + } + }, + + onEnter: function() { + this._super(); + this.space.addCollisionHandler( 1, 0, null, this.waterPreSolve, null, null); + }, + + onExit: function() { + this.space.removeCollisionHandler(1, 0); + this._super(); + }, + + title: function() { + return 'Buoyancy'; + }, + + waterPreSolve : function(arb, space, ptr) { + var shapes = arb.getShapes(); + var water = shapes[0]; + var poly = shapes[1]; + + var body = poly.getBody(); + + // Get the top of the water sensor bounding box to use as the water level. + var level = water.getBB().t; + + // Clip the polygon against the water level + var count = poly.getNumVerts(); + + var clipped = []; + + var j=count-1; + for(var i=0; i>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= 1) { + this.setMenuItemEnabled(true); + } + } +}); + +//------------------------------------------------------------------ +// +// TestDirectLoading +// +//------------------------------------------------------------------ +var TestDirectLoading = ArmatureTestLayer.extend({ + onEnter:function () { + this._super(); + // remove sigle resource + ccs.armatureDataManager.removeArmatureFileInfo(s_bear_json); + // load resource directly + ccs.armatureDataManager.addArmatureFileInfo(s_bear_json); + + var armature = new ccs.Armature("bear"); + armature.getAnimation().playWithIndex(0); + armature.anchorX = 0.5; + armature.anchorY = 0.5; + armature.x = winSize.width / 2; + armature.y = winSize.height / 2; + armature.runAction(cc.sequence(cc.tintTo(5, 200,100,0), cc.tintTo(5, 255,255,255))); + this.addChild(armature); + }, + title:function () { + return "Test Direct Loading"; + } +}); + +//------------------------------------------------------------------ +// +// TestCSWithSkeleton +// +//------------------------------------------------------------------ +var TestCSWithSkeleton = ArmatureTestLayer.extend({ + onEnter:function () { + this._super(); + ccs.armatureDataManager.addArmatureFileInfo(s_Cowboy_json); + + var armature = new ccs.Armature("Cowboy"); + armature.getAnimation().playWithIndex(0); + armature.scale = 0.2; + armature.anchorX = 0.5; + armature.anchorY = 0.5; + armature.x = winSize.width / 2; + armature.y = winSize.height / 2; + this.addChild(armature); + }, + title:function () { + return "Test Export From CocoStudio With Skeleton Effect"; + } +}); + +//------------------------------------------------------------------ +// +// TestDragonBones20 +// +//------------------------------------------------------------------ +var TestDragonBones20 = ArmatureTestLayer.extend({ + onEnter:function () { + this._super(); + ccs.armatureDataManager.addArmatureFileInfo(s_Dragon_png, s_Dragon_plist, s_Dragon_xml); + var armature = new ccs.Armature("Dragon"); + armature.getAnimation().playWithIndex(0); + armature.getAnimation().setSpeedScale(0.4); + armature.scale = 0.6; + armature.anchorX = 0.5; + armature.anchorY = 0.5; + armature.x = winSize.width / 2; + armature.y = winSize.height / 2; + this.addChild(armature); + }, + title:function () { + return "Test Export From DragonBones version 2.0"; + } +}); + +//------------------------------------------------------------------ +// +// TestPerformance +// +//------------------------------------------------------------------ +var ArmaturePerformanceTag = 20000; +var TestPerformance = ArmatureTestLayer.extend({ + armatureCount: 0, + onEnter: function () { + this._super(); + ccs.armatureDataManager.addArmatureFileInfo(s_knight_png, s_knight_plist, s_knight_xml); + cc.MenuItemFont.setFontSize(65); + var decrease = new cc.MenuItemFont(" - ", this.onDecrease, this); + decrease.color = cc.color(0, 200, 20); + var increase = new cc.MenuItemFont(" + ", this.onIncrease, this); + increase.color = cc.color(0, 200, 20); + + var menu = new cc.Menu(decrease, increase); + menu.alignItemsHorizontally(); + menu.x = cc.visibleRect.width / 2; + menu.y = cc.visibleRect.height - 100; + this.addChild(menu, 10000); + + }, + title: function () { + return "Test Performance"; + }, + subtitle: function () { + return "Current CCArmature Count :"; + }, + onIncrease: function (sender) { + this.addArmature(20); + }, + onDecrease: function (sender) { + if (this.armatureCount == 0) + return; + + for (var i = 0; i < 20; i++) { + this.removeArmatureFromParent(ArmaturePerformanceTag + this.armatureCount); + this.armatureCount--; + this.refreshTitile(); + } + }, + addArmature: function (number) { + for (var i = 0; i < number; i++) { + this.armatureCount++; + var armature = new ccs.Armature("Knight_f/Knight"); + armature.getAnimation().playWithIndex(0); + armature.x = 50 + this.armatureCount * 2; + armature.y = 150; + armature.scale = 0.6; + this.addArmatureToParent(armature); + } + this.refreshTitile(); + }, + addArmatureToParent: function (armature) { + this.addChild(armature, 0, ArmaturePerformanceTag + this.armatureCount); + }, + removeArmatureFromParent: function (tag) { + this.removeChildByTag(tag); + }, + refreshTitile: function () { + var subTile = this.getChildByTag(BASE_TEST_SUBTITLE_TAG); + subTile.setString(this.subtitle() + this.armatureCount); + } +}); + +//------------------------------------------------------------------ +// +// TestPerformanceBatchNode +// +//------------------------------------------------------------------ +var TestPerformanceBatchNode = TestPerformance.extend({ + batchNode: null, + onEnter: function () { + this._super(); + this.batchNode = new ccs.BatchNode(); + this.addChild(this.batchNode); + }, + title: function () { + return "Test Performance of using CCBatchNode"; + }, + addArmatureToParent: function (armature) { + this.batchNode.addChild(armature, 0, ArmaturePerformanceTag + this.armatureCount); + }, + removeArmatureFromParent: function (tag) { + this.batchNode.removeChildByTag(tag); + } +}); + +//------------------------------------------------------------------ +// +// TestChangeZorder +// +//------------------------------------------------------------------ +var TestChangeZorder = ArmatureTestLayer.extend({ + currentTag:0, + onEnter:function () { + this._super(); + var armature = null; + var armatureDataManager = ccs.armatureDataManager; + armatureDataManager.addArmatureFileInfo(s_knight_png, s_knight_plist, s_knight_xml); + armature = new ccs.Armature("Knight_f/Knight"); + armature.getAnimation().playWithIndex(0); + armature.x = winSize.width / 2; + armature.y = winSize.height / 2 - 100; + armature.scale = 0.6; + this.addChild(armature, 0, 0); + + armatureDataManager.addArmatureFileInfo(s_Cowboy_json); + armature = new ccs.Armature("Cowboy"); + armature.getAnimation().playWithIndex(0); + armature.scale = 0.24; + armature.x = winSize.width / 2; + armature.y = winSize.height / 2 - 100; + this.addChild(armature, 1, 1); + + armatureDataManager.addArmatureFileInfo(s_Dragon_png, s_Dragon_plist, s_Dragon_xml); + armature = new ccs.Armature("Dragon"); + armature.getAnimation().playWithIndex(0); + armature.x = winSize.width / 2; + armature.y = winSize.height / 2 - 100; + armature.scale = 0.6; + this.addChild(armature, 2, 2); + + this.schedule(this.changeZorder, 1); + }, + title:function () { + return "Test Change ZOrder Of Different CCArmature"; + }, + changeZorder:function (dt) { + var node = this.getChildByTag(this.currentTag); + node.zIndex = Math.random() * 3; + this.currentTag++; + this.currentTag = this.currentTag % 3; + } + +}); + +//------------------------------------------------------------------ +// +// TestAnimationEvent +// +//------------------------------------------------------------------ +var TestAnimationEvent = ArmatureTestLayer.extend({ + _armature:null, + _direction:1, + onEnter:function () { + this._super(); + + ccs.armatureDataManager.addArmatureFileInfo(s_Cowboy_json); + this._armature = new ccs.Armature("Cowboy"); + this._armature.getAnimation().play("Fire"); + this._armature.scaleX = -0.25; + this._armature.scaleY = 0.25; + this._armature.x = winSize.width / 2 - 150; + this._armature.y = winSize.height / 2; + var self = this; + this._armature.getAnimation().setMovementEventCallFunc(function(armature, movementType, movementID) { + self.animationEvent(armature, movementType, movementID); + }); + this.addChild(this._armature); + + this._direction = 1; + + }, + title:function () { + return "Test Armature Animation Event"; + }, + animationEvent:function (armature, movementType, movementID) { + if (movementType == ccs.MovementEventType.loopComplete) { + if (movementID == "Fire") { + var moveBy = cc.moveBy(2, cc.p(300 * this._direction, 0)); + this._armature.stopAllActions(); + this._armature.runAction(cc.sequence(moveBy, cc.callFunc(this.callback, this))); + this._armature.getAnimation().play("Walk"); + + this._direction *= -1; + } + } + }, + callback:function () { + this._armature.runAction(cc.scaleTo(0.3, 0.25 * this._direction * -1, 0.25)); + this._armature.getAnimation().play("Fire", 10); + } +}); + +//------------------------------------------------------------------ +// +// TestAnimationEvent +// +//------------------------------------------------------------------ + +var FRAME_EVENT_ACTION_TAG = 10000; +var TestFrameEvent = ArmatureTestLayer.extend({ + _nodeGrid: null, + onEnter: function () { + this._super(); + ccs.armatureDataManager.addArmatureFileInfo(s_HeroAnimation_json); + var armature = new ccs.Armature("HeroAnimation"); + armature.getAnimation().play("attack"); + armature.getAnimation().setSpeedScale(0.5); + var center = cc.visibleRect.center; + armature.x = center.x - 50; + armature.y = center.y - 100; + + this._nodeGrid = new cc.NodeGrid(); + this._nodeGrid.addChild(armature); + this.addChild(this._nodeGrid); + /* + * Set armature's frame event callback function + * To disconnect this event, just setFrameEventCallFunc(NULL, NULL); + */ + var self = this; + armature.getAnimation().setFrameEventCallFunc(function(bone, evt, originFrameIndex, currentFrameIndex) { + self.onFrameEvent(bone, evt, originFrameIndex, currentFrameIndex); + }); + + this.schedule(this.checkAction); + }, + title: function () { + return "Test Frame Event"; + }, + onFrameEvent: function (bone, evt, originFrameIndex, currentFrameIndex) { + cc.log("(" + bone.getName() + ") emit a frame event (" + evt + ") at frame index (" + currentFrameIndex + ")."); + if (!this.getActionByTag(FRAME_EVENT_ACTION_TAG) || this.getActionByTag(FRAME_EVENT_ACTION_TAG).isDone()) { + if ("opengl" in cc.sys.capabilities) { + this.stopAllActions(); + var action = cc.shatteredTiles3D(0.2, cc.size(16, 12), 5, false); + action.tag = FRAME_EVENT_ACTION_TAG; + this._nodeGrid.runAction(action); + } + } + }, + checkAction: function (dt) { + if ("opengl" in cc.sys.capabilities) { + if (this._nodeGrid.getNumberOfRunningActions() == 0 && this._nodeGrid.grid != null) + this._nodeGrid.grid = null; + } + } +}); + +//------------------------------------------------------------------ +// +// TestParticleDisplay +// +//------------------------------------------------------------------ +var TestParticleDisplay = ArmatureTestLayer.extend({ + animationID:0, + armature:null, + ctor:function(){ + this._super(); + + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded: function (touches, event) { + var target = event.getCurrentTarget(); + ++target.animationID; + target.animationID = target.animationID % target.armature.getAnimation().getMovementCount(); + target.armature.getAnimation().playWithIndex(target.animationID,10); + return false; + } + }, this); + }, + onEnter:function () { + this._super(); + + this.animationID = 0; + + ccs.armatureDataManager.addArmatureFileInfo(s_robot_png, s_robot_plist, s_robot_xml); + this.armature = new ccs.Armature("robot"); + this.armature.getAnimation().playWithIndex(4); + var center = cc.visibleRect.center; + this.armature.x = center.x; + this.armature.y = center.y; + this.armature.scale = 0.48; + this.armature.getAnimation().setSpeedScale(0.5); + this.addChild(this.armature); + + var p1 = new cc.ParticleSystem("res/Particles/SmallSun.plist"); + p1.setTotalParticles(30); + var p2 = new cc.ParticleSystem("res/Particles/SmallSun.plist"); + p2.setTotalParticles(30); + var bone = new ccs.Bone("p1"); + bone.addDisplay(p1, 0); + bone.changeDisplayWithIndex(0, true); + bone.setIgnoreMovementBoneData(true); + bone.zIndex = 100; + bone.scale = 1.2; + this.armature.addBone(bone, "bady-a3"); + + bone = new ccs.Bone("p2"); + bone.addDisplay(p2, 0); + bone.changeDisplayWithIndex(0, true); + bone.setIgnoreMovementBoneData(true); + bone.zIndex = 100; + bone.scale = 1.2; + this.armature.addBone(bone, "bady-a30"); + }, + title:function () { + return "Test Particle Display"; + }, + subtitle:function () { + return "Touch to change animation"; + } +}); + +//------------------------------------------------------------------ +// +// TestUseMutiplePicture +// +//------------------------------------------------------------------ +var TestUseMutiplePicture = ArmatureTestLayer.extend({ + displayIndex:0, + armature:null, + ctor:function(){ + this._super(); + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded: this.onTouchesEnded.bind(this) + }, this); + }, + onEnter:function () { + this._super(); + this.displayIndex = 0; + var armatureDataManager = ccs.armatureDataManager; + armatureDataManager.addArmatureFileInfo(s_knight_png, s_knight_plist, s_knight_xml); + armatureDataManager.addArmatureFileInfo(s_weapon_png, s_weapon_plist, s_weapon_xml); + + this.armature = new ccs.Armature("Knight_f/Knight"); + this.armature.getAnimation().playWithIndex(0); + this.armature.x = winSize.width / 2; + this.armature.y = winSize.height / 2; + this.armature.scale = 1.2; + this.addChild(this.armature); + + var weapon = ["weapon_f-sword.png", "weapon_f-sword2.png", "weapon_f-sword3.png", "weapon_f-sword4.png", "weapon_f-sword5.png", "weapon_f-knife.png", "weapon_f-hammer.png"]; + + //add skin + for (var i = 0; i < 7; i++) { + var skin = ccs.Skin.createWithSpriteFrameName(weapon[i]); + this.armature.getBone("weapon").addDisplay(skin, i); + } + + //add label + var label = new cc.LabelTTF("This is a weapon!", "Arial", 18); + label.anchorX = 0.2; + label.anchorY = 0.5; + this.armature.getBone("weapon").addDisplay(label, 7); + }, + title:function () { + return "Test One CCArmature Use Different Picture"; + }, + subtitle:function () { + return "Tap Screen"; + }, + onTouchesEnded:function (touch, event) { + ++this.displayIndex; + this.displayIndex = (this.displayIndex) % 8; + this.armature.getBone("weapon").changeDisplayWithIndex(this.displayIndex, true); + return false; + } +}); + +//------------------------------------------------------------------ +// +// TestColliderDetector +// +//------------------------------------------------------------------ +var TestColliderDetector = ArmatureTestLayer.extend({ + armature1:null, + armature2:null, + bullet:null, + space:null, + enemyTag: 1, + bulletTag: 2, + + onEnter:function () { + this._super(); + ccs.ENABLE_PHYSICS_CHIPMUNK_DETECT = true; + ccs.armatureDataManager.addArmatureFileInfo(s_Cowboy_json); + + this.armature1 = new ccs.Armature("Cowboy"); + this.armature1.getAnimation().play("FireWithoutBullet"); + this.armature1.getAnimation().setSpeedScale(0.2); + this.armature1.scaleX = -0.2; + this.armature1.scaleY = 0.2; + this.armature1.x = 170; + this.armature1.y = winSize.height / 2; + + /* + * Set armature's frame event callback function + * To disconnect this event, just setFrameEventCallFunc(nul, null); + */ + this.armature1.getAnimation().setFrameEventCallFunc(this.onFrameEvent,this); + + this.addChild(this.armature1); + + this.armature2 = new ccs.Armature("Cowboy"); + this.armature2.getAnimation().play("Walk"); + this.armature2.scaleX = -0.2; + this.armature2.scaleY = 0.2; + this.armature2.x = winSize.width - 160; + this.armature2.y = winSize.height / 2; + this.addChild(this.armature2); + + this.bullet = new cc.PhysicsSprite("#25.png"); + this.addChild(this.bullet); + + this.initWorld(); + this.scheduleUpdate(); + }, + initWorld:function(){ + this.space = new cp.Space(); + this.space.gravity = cp.v(0, 0); + + // Physics debug layer + var debugLayer = new cc.PhysicsDebugNode(this.space); + this.addChild(debugLayer, 9999); + + //init bullet body + var width = this.bullet.width, height = this.bullet.height; + var verts = [ + -width/2,-height/2, + -width/2,height/2, + width/2,height/2, + width/2,-height/2 + ]; + var body = new cp.Body(1, cp.momentForPoly(1,verts, cp.vzero)); + this.space.addBody(body); + var shape = new cp.PolyShape(body,verts, cp.vzero); + shape.collision_type = this.bulletTag; + this.space.addShape(shape); + this.bullet.setBody(body); + this.bullet.x = -100; + this.bullet.y = -100; + + //init armature body + body = new cp.Body(Infinity, Infinity); + this.space.addBody(body); + this.armature2.setBody(body); + var filter = new ccs.ColliderFilter(this.enemyTag); + this.armature2.setColliderFilter(filter); + //init collision handler + this.space.addCollisionHandler(this.enemyTag, this.bulletTag, this.beginHit.bind(this), null, null, this.endHit.bind(this)); + }, + onFrameEvent: function (bone, evt, originFrameIndex, currentFrameIndex) { + cc.log("(" + bone.getName() + ") emit a frame event (" + evt + ") at frame index (" + currentFrameIndex + ")."); + /* + * originFrameIndex is the frame index editted in Action Editor + * currentFrameIndex is the current index animation played to + * frame event may be delay emit, so originFrameIndex may be different from currentFrameIndex. + */ + var p = this.armature1.getBone("Layer126").getDisplayRenderNode().convertToWorldSpaceAR(cc.p(0, 0)); + this.bullet.x = p.x + 60; + this.bullet.y = p.y; + this.bullet.stopAllActions(); + this.bullet.runAction(cc.moveBy(1.5, cc.p(800, 0))); + }, + beginHit:function(arbiter, space){ + var shapes = arbiter.getShapes(); + var shapeA = shapes[0]; + var shapeB = shapes[1]; + var bone; + if(shapeA.collision_type==this.enemyTag) + bone = shapeA.data; + if(shapeB.collision_type==this.enemyTag) + bone = shapeB.data; + if(bone) + bone.getArmature().visible = false; + }, + + endHit:function(arbiter, space){ + var shapes = arbiter.getShapes(); + var shapeA = shapes[0]; + var shapeB = shapes[1]; + var bone; + if(shapeA.collision_type==this.enemyTag) + bone = shapeA.data; + if(shapeB.collision_type==this.enemyTag) + bone = shapeB.data; + if(bone) + bone.getArmature().visible = true; + }, + update:function(dt){ + this.space.step(dt); + }, + title:function () { + return "Test Collider Detector"; + }, + onExit:function(){ + this._super(); + var shapeList = this.armature2.getShapeList(); + for(var i = 0 ;i maxx ? vertex.x : maxx; + maxy = vertex.y > maxy ? vertex.y : maxy; + } + } + var temp = cc.rect(minx, miny, maxx - minx, maxy - miny); + + if (cc.rectContainsRect(temp, rect)) { + this.armature2.visible = false; + } + } + } + }, + draw: function () { + this.armature2.drawContour(); + }, + title: function () { + return "Test calculated vertex"; + }, + onExit:function(){ + this._super(); + ccs.ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX = false; + } +}); + +//------------------------------------------------------------------ +// +// TestBoundingBox +// +//------------------------------------------------------------------ +var TestBoundingBox = ArmatureTestLayer.extend({ + armature: null, + drawNode: null, + onEnter:function () { + var _this = this; + _this._super(); + + _this.drawNode = new cc.DrawNode(); + _this.drawNode.setDrawColor(cc.color(100,100,100,255)); + _this.addChild(_this.drawNode); + + ccs.armatureDataManager.addArmatureFileInfo(s_Cowboy_json); + + _this.armature = new ccs.Armature("Cowboy"); + _this.armature.getAnimation().playWithIndex(0); + _this.armature.x = winSize.width / 2; + _this.armature.y = winSize.height / 2; + _this.armature.scale = 0.2; + _this.addChild(_this.armature); + + _this.scheduleUpdate(); + }, + + title:function () { + return "Test BoundingBox"; + }, + update: function () { + var rect = this.armature.getBoundingBox(); + this.drawNode.clear(); + this.drawNode.drawRect(cc.p(rect.x, rect.y), cc.p(cc.rectGetMaxX(rect), cc.rectGetMaxY(rect))); + } +}); + +//------------------------------------------------------------------ +// +// TestAnchorPoint +// +//------------------------------------------------------------------ +var TestAnchorPoint = ArmatureTestLayer.extend({ + onEnter:function () { + this._super(); + ccs.armatureDataManager.addArmatureFileInfo(s_Cowboy_json); + for (var i = 0; i < 5; i++) { + var armature = new ccs.Armature("Cowboy"); + armature.getAnimation().playWithIndex(0); + armature.x = winSize.width / 2; + armature.y = winSize.height / 2; + armature.scale = 0.2; + this.addChild(armature, 0, i); + } + + this.getChildByTag(0).anchorX = 0; + this.getChildByTag(0).anchorY = 0; + this.getChildByTag(1).anchorX = 0; + this.getChildByTag(1).anchorY = 1; + this.getChildByTag(2).anchorX = 1; + this.getChildByTag(2).anchorY = 0; + this.getChildByTag(3).anchorX = 1; + this.getChildByTag(3).anchorY = 1; + this.getChildByTag(4).anchorX = 0.5; + this.getChildByTag(4).anchorY = 0.5; + }, + title:function () { + return "Test Set AnchorPoint"; + } +}); + +//------------------------------------------------------------------ +// +// TestArmatureNesting +// +//------------------------------------------------------------------ +var TestArmatureNesting = ArmatureTestLayer.extend({ + armature:null, + weaponIndex:0, + ctor:function(){ + this._super(); + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded: this.onTouchesEnded.bind(this) + }, this); + }, + onEnter:function () { + this._super(); + ccs.armatureDataManager.addArmatureFileInfo(s_cyborg_png, s_cyborg_plist, s_cyborg_xml); + this.armature = new ccs.Armature("cyborg"); + this.armature.getAnimation().playWithIndex(1); + this.armature.x = winSize.width / 2; + this.armature.y = winSize.height / 2; + this.armature.scale = 1.2; + this.armature.getAnimation().setSpeedScale(0.4); + this.addChild(this.armature); + this.weaponIndex = 0; + }, + title:function () { + return "Test CCArmature Nesting"; + }, + onTouchesEnded:function (touch, event) { + ++this.weaponIndex; + this.weaponIndex = this.weaponIndex % 4; + this.armature.getBone("armInside").getChildArmature().getAnimation().playWithIndex(this.weaponIndex); + this.armature.getBone("armOutside").getChildArmature().getAnimation().playWithIndex(this.weaponIndex); + } +}); + +//------------------------------------------------------------------ +// +// TestArmatureNesting2 +// +//------------------------------------------------------------------ +var Hero = ccs.Armature.extend({ + _mount: null, + _layer: null, + ctor: function () { + this._super(); + this._mount = null; + this._layer = null; + }, + + changeMount: function (armature) { + if (armature == null) { + this.retain(); + + this.playWithIndex(0); + //Remove hero from display list + this._mount.getBone("hero").removeDisplay(0); + this._mount.stopAllActions(); + + //Set position to current position + this.x = this._mount.x; + this.y = this._mount.y; + //Add to layer + this._layer.addChild(this); + this._mount = armature; + } + else { + this._mount = armature; + this.retain(); + //Remove from layer + this.removeFromParent(false); + + //Get the hero bone + var bone = armature.getBone("hero"); + //Add hero as a display to this bone + bone.addDisplay(this, 0); + //Change this bone's display + bone.changeDisplayWithIndex(0, true); + bone.setIgnoreMovementBoneData(true); + + this.x = 0; + + this.y = 0; + //Change animation + this.playWithIndex(1); + this.scale = 1; + } + + }, + + playWithIndex: function (index) { + this.getAnimation().playWithIndex(index); + if (this._mount) { + this._mount.getAnimation().playWithIndex(index); + } + }, + setLayer:function(layer){ + this._layer = layer; + }, + getLayer:function(){ + return this._layer; + }, + setMount:function(mount){ + this._mount = mount; + }, + getMount:function(){ + return this._mount; + } +}); + + +Hero.create = function(name){ + var hero = new Hero(); + if (hero && hero.init(name)) { + return hero; + } + return null; +}; + +var TestArmatureNesting2 = ArmatureTestLayer.extend({ + _hero: null, + _horse: null, + _horse2: null, + _bear: null, + _touchedMenu: false, + ctor:function(){ + this._super(); + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded: this.onTouchesEnded.bind(this) + }, this); + }, + onEnter: function () { + this._super(); + + this._touchedMenu = false; + var label = new cc.LabelTTF("Change Mount", "Arial", 20); + var menuItem = new cc.MenuItemLabel(label, this.changeMountCallback, this); + var menu = new cc.Menu(menuItem); + menu.x = 0; + menu.y = 0; + menuItem.x = cc.visibleRect.right.x - 67; + menuItem.y = cc.visibleRect.bottom.y + 50; + this.addChild(menu, 2); + + //Create a hero + var hero = Hero.create("hero"); + hero.setLayer(this); + hero.playWithIndex(0); + hero.x = cc.visibleRect.left.x + 20; + hero.y = cc.visibleRect.left.y; + this.addChild(hero); + this._hero = hero; + + //Create 3 mount + this._horse = this.createMount("horse", cc.visibleRect.center); + this._horse2 = this.createMount("horse", cc.p(120, 200)); + this._horse2.opacity = 200; + this._bear = this.createMount("bear", cc.p(300, 70)); + }, + title: function () { + return "Test CCArmature Nesting 2"; + }, + subtitle: function () { + return "Move to a mount and press the ChangeMount Button."; + }, + onTouchesEnded: function (touches, event) { + var point = touches[0].getLocation(); + var armature = this._hero.getMount() == null ? this._hero : this._hero.getMount(); + //Set armature direction + if (point.x < armature.x) { + armature.scaleX = -1; + } + else { + armature.scaleX = 1; + } + + var move = cc.moveTo(2, point); + armature.stopAllActions(); + armature.runAction(move); + return false; + }, + + changeMountCallback: function (sender) { + this._hero.stopAllActions(); + if (this._hero.getMount()) { + this._hero.changeMount(null); + } + else { + var heroPos = cc.p(this._hero.x, this._hero.y); + var horsePos = cc.p(this._horse.x, this._horse.y); + var horse2Pos = cc.p(this._horse2.x, this._horse2.y); + var bearPos = cc.p(this._bear.x, this._bear.y); + + if (cc.pDistance(heroPos, horsePos) < 20) { + this._hero.changeMount(this._horse); + } + else if (cc.pDistance(heroPos, horse2Pos) < 20) { + this._hero.changeMount(this._horse2); + } + else if (cc.pDistance(heroPos, bearPos) < 30) { + this._hero.changeMount(this._bear); + } + } + }, + createMount: function (name, position) { + var armature = new ccs.Armature(name); + armature.getAnimation().playWithIndex(0); + armature.x = position.x; + armature.y = position.y; + this.addChild(armature); + return armature; + } +}); + +//------------------------------------------------------------------ +// +// TestPlaySeveralMovement +// +//------------------------------------------------------------------ +var TestPlaySeveralMovement = ArmatureTestLayer.extend({ + onEnter:function () { + this._super(); + ccs.armatureDataManager.addArmatureFileInfo(s_Cowboy_json); + var armature = new ccs.Armature("Cowboy"); + armature.getAnimation().playWithNames(["Walk", "FireMax", "Fire"],10,true); + armature.scale = 0.2; + armature.x = winSize.width / 2; + armature.y = winSize.height / 2; + this.addChild(armature); + }, + title:function () { + return "Test play several movement"; + }, + subtitle:function () { + return "Movement is played one by one"; + } +}); + +//------------------------------------------------------------------ +// +// TestChangeAnimationInternal +// +//------------------------------------------------------------------ +var TestChangeAnimationInternal = ArmatureTestLayer.extend({ + ctor:function(){ + this._super(); + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded: this.onTouchesEnded.bind(this) + }, this); + }, + onEnter:function () { + this._super(); + + ccs.armatureDataManager.addArmatureFileInfo(s_Cowboy_json); + var armature = new ccs.Armature("Cowboy"); + armature.getAnimation().playWithIndex(0); + armature.scale = 0.2; + armature.x = winSize.width / 2; + armature.y = winSize.height / 2; + this.addChild(armature); + }, + title:function () { + return "Test change animation internal"; + }, + subtitle:function () { + return "Touch to change animation internal"; + }, + onTouchesEnded: function (touch, event) { + if (cc.director.getAnimationInterval() == 1 / 30) { + cc.director.setAnimationInterval(1 / 60); + } + else { + cc.director.setAnimationInterval(1 / 30); + } + return false; + }, + onExit: function () { + this._super(); + cc.director.setAnimationInterval(1 / 60); + } +}); + +//------------------------------------------------------------------ +// +// TestChangeAnimationInternal +// +//------------------------------------------------------------------ +var TestEasing = ArmatureTestLayer.extend({ + animationID: 0, + armature: null, + ctor:function(){ + this._super(); + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded: this.onTouchesEnded.bind(this) + }, this); + }, + onEnter: function () { + this._super(); + + ccs.armatureDataManager.addArmatureFileInfo(s_testEasing_json); + var armature = new ccs.Armature("testEasing"); + armature.getAnimation().playWithIndex(0); + armature.scale = 0.8; + armature.x = winSize.width / 2; + armature.y = winSize.height / 2; + this.addChild(armature); + this.armature = armature; + this.updateSubTitle(); + }, + title: function () { + return "Test easing effect"; + }, + subtitle: function () { + return "Current easing :"; + }, + onTouchesEnded: function (touch, event) { + this.animationID++; + this.animationID = this.animationID % this.armature.getAnimation().getMovementCount(); + this.armature.getAnimation().playWithIndex(this.animationID); + + this.updateSubTitle(); + return false; + }, + updateSubTitle: function () { + var str = this.subtitle() + this.armature.getAnimation().getCurrentMovementID(); + var label = this.getChildByTag(BASE_TEST_SUBTITLE_TAG); + label.setString(str); + } +}); + +var runArmatureTestScene = function(){ + var pScene = new ArmatureTestScene(); + if (pScene) { + pScene.runThisTest(); + } +}; \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/CocoStudioTest.js b/tests/js-tests/src/CocoStudioTest/CocoStudioTest.js new file mode 100644 index 0000000000..b8e18bba3e --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/CocoStudioTest.js @@ -0,0 +1,139 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 LINE_SPACE = 40; +var ITEM_TAG_BASIC = 1000; + +var cocoStudioTestItemNames = [ + { + itemTitle:"CocoStudioArmatureTest", + testScene:function () { + runArmatureTestScene(); + } + }, + { + itemTitle:"CocoStudioGUITest", + testScene:function () { + runGuiTestMain(); + } + }, + { + itemTitle:"CocoStudioSceneTest", + testScene:function () { + runSceneEditorTest(); + } + }, + { + itemTitle:"ParserTest", + testScene:function(){ + runParserTest(); + } + } +]; + +if(!cc.sys.isNative){ + cocoStudioTestItemNames.push({ + itemTitle: "CocoStudioComponentsTest", + testScene: function () { + runComponentsTestLayer(); + } + }); + cocoStudioTestItemNames.push({ + itemTitle:"CustomWidget", + testScene:function(){ + runCustomGUITest(); + } + }); +} + +var CocoStudioMainLayer = cc.Layer.extend({ + onEnter:function () { + this._super(); + + var winSize = cc.director.getWinSize(); + + var pMenu = new cc.Menu(); + pMenu.x = 0; + pMenu.y = 0; + cc.MenuItemFont.setFontName("Arial"); + cc.MenuItemFont.setFontSize(24); + for (var i = 0; i < cocoStudioTestItemNames.length; ++i) { + var selItem = cocoStudioTestItemNames[i]; + var pItem = new cc.MenuItemFont(selItem.itemTitle, + this.menuCallback, this); + pItem.x = winSize.width / 2; + pItem.y = winSize.height - (i + 1) * LINE_SPACE; + pMenu.addChild(pItem, ITEM_TAG_BASIC + i); + } + this.addChild(pMenu); + }, + + menuCallback:function (sender) { + var nIndex = sender.zIndex - ITEM_TAG_BASIC; + cocoStudioTestItemNames[nIndex].testScene(); + } +}); + +var cocoStudioOldApiFlag = 0; +var CocoStudioTestScene = TestScene.extend({ + + onEnter: function(){ + TestScene.prototype.onEnter.call(this); + + var winSize = cc.director.getWinSize(); + + var pMenu = new cc.Menu(); + pMenu.x = 0; + pMenu.y = 0; + cc.MenuItemFont.setFontName("Arial"); + cc.MenuItemFont.setFontSize(24); + var str = "new api"; + if(cocoStudioOldApiFlag){ + str = "old api"; + } + var pItem = new cc.MenuItemFont(str, + function(){ + if(cocoStudioOldApiFlag){ + cocoStudioOldApiFlag = 0; + pItem.setString("new api"); + }else{ + cocoStudioOldApiFlag = 1; + pItem.setString("old api"); + } + }, this); + pItem.x = 50; + pItem.y = winSize.height - 20; + pMenu.addChild(pItem); + + this.addChild(pMenu); + }, + + runThisTest:function () { + var pLayer = new CocoStudioMainLayer(); + this.addChild(pLayer); + cc.director.runScene(this); + } +}); diff --git a/tests/js-tests/src/CocoStudioTest/ComponentsTest/ComponentsTestScene.js b/tests/js-tests/src/CocoStudioTest/ComponentsTest/ComponentsTestScene.js new file mode 100644 index 0000000000..5d13cf29bb --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/ComponentsTest/ComponentsTestScene.js @@ -0,0 +1,77 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 ComponentsTestLayer = cc.LayerColor.extend({ + init: function () { + if (cc.LayerColor.prototype.init.call(this, cc.color(255, 255, 255, 255))) { + var root = this.createGameScene(); + this.addChild(root, 0, 1); + root.getChildByTag(1).addComponent(new ccs.ComAudio()); + root.getChildByTag(1).addComponent(PlayerController.create()); + root.addComponent(new ccs.ComAudio()); + root.addComponent(new ccs.ComAttribute()); + root.addComponent(SceneController.create()); + return true; + } + return false; + }, + + createGameScene: function () { + var root = new cc.Node(); + var winSize = cc.director.getWinSize(); + var player = new cc.Sprite("res/components/Player.png", cc.rect(0, 0, 27, 40)); + player.x = 30; + player.y = winSize.height / 2; + root.addChild(player, 1, 1); + + var itemBack = new cc.MenuItemFont("Back", this.toExtensionsMainLayer, this); + itemBack.color = cc.color(0, 0, 0); + itemBack.x = cc.visibleRect.bottomRight.x - 50; + itemBack.y = cc.visibleRect.bottomRight.y + 25; + var menuBack = new cc.Menu(itemBack); + menuBack.x = 0; + menuBack.y = 0; + this.addChild(menuBack); + return root; + }, + + toExtensionsMainLayer: function (sender) { + cc.audioEngine.stopMusic("res/Sound/background-music-aac.wav"); + var scene = new CocoStudioTestScene(); + scene.runThisTest(); + } +}); +ComponentsTestLayer.scene = function(){ + var scene = new cc.Scene(); + var layer = new ComponentsTestLayer(); + layer.init(); + scene.addChild(layer); + return scene; +}; +var runComponentsTestLayer = function () { + var scene = ComponentsTestLayer.scene(); + cc.director.runScene(scene); +}; \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/ComponentsTest/EnemyController.js b/tests/js-tests/src/CocoStudioTest/ComponentsTest/EnemyController.js new file mode 100644 index 0000000000..fa186339af --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/ComponentsTest/EnemyController.js @@ -0,0 +1,83 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 EnemyController = ccs.ComController.extend({ + ctor: function () { + this._super(); + this._name = "EnemyController"; + }, + init: function () { + return true; + }, + + onEnter: function () { + // Determine where to spawn the target along the Y axis + var winSize = cc.director.getWinSize(); + var minY = this.getOwner().height / 2; + var rangeY = winSize.height - this.getOwner().height; + var actualY = (Math.random() * rangeY ) + minY; + + // Create the target slightly off-screen along the right edge, + // and along a random position along the Y axis as calculated + this.getOwner().x = winSize.width + (this.getOwner().width / 2); + this.getOwner().y = actualY; + + + // Determine speed of the target + var minDuration = 2.0; + var maxDuration = 4.0; + var rangeDuration = maxDuration - minDuration; + var actualDuration = ( Math.random() % rangeDuration ) + minDuration; + + // Create the actions + var actionMove = cc.moveTo(actualDuration, cc.p(0 - this.getOwner().width / 2, actualY)); + var actionMoveDone = cc.callFunc(function () { + var comController = this.getOwner().parent.getComponent("SceneController"); + comController.spriteMoveFinished(this.getOwner()); + }, this); + this.getOwner().runAction(cc.sequence(actionMove, actionMoveDone)); + }, + + onExit: function () { + }, + + update: function (dt) { + + }, + + die: function () { + var com = this.getOwner().parent.getComponent("SceneController"); + var targets = com.getTargets(); + cc.arrayRemoveObject(targets, this.getOwner()); + this.getOwner().removeFromParent(true); + com.increaseKillCount(); + } +}); +EnemyController.create = function () { + var controller = new EnemyController(); + controller.init(); + return controller; +}; diff --git a/tests/js-tests/src/CocoStudioTest/ComponentsTest/GameOverScene.js b/tests/js-tests/src/CocoStudioTest/ComponentsTest/GameOverScene.js new file mode 100644 index 0000000000..573bde95bb --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/ComponentsTest/GameOverScene.js @@ -0,0 +1,74 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 GameOverLayer = cc.LayerColor.extend({ + _label: null, + init: function () { + if (this._super(cc.color(255, 255, 255, 255))) { + var winSize = cc.director.getWinSize(); + this._label = new cc.LabelTTF("", "Artial", 32); + this._label.retain(); + this._label.color = cc.color(0, 0, 0); + this._label.x = winSize.width / 2; + this._label.y = winSize.height / 2; + this.addChild(this._label); + this.runAction(cc.sequence(cc.delayTime(3), cc.callFunc(this.gameOverDone, this))); + var itemBack = new cc.MenuItemFont("Back", this.toExtensionsMainLayer, this); + itemBack.color = cc.color(0, 0, 0); + itemBack.x = cc.visibleRect.bottomRight.x - 50; + itemBack.y = cc.visibleRect.bottomRight.y + 25; + var menuBack = new cc.Menu(itemBack); + menuBack.x = 0; + menuBack.y = 0; + this.addChild(menuBack); + return true; + } + return false; + }, + gameOverDone: function () { + cc.director.runScene(ComponentsTestLayer.scene()); + }, + getLabel: function () { + return this._label; + } +}); +var GameOverScene = cc.Scene.extend({ + _layer: null, + init: function () { + this._super(); + this._layer = new GameOverLayer(); + this._layer.init(); + this.addChild(this._layer); + }, + getLayer: function () { + return this._layer; + } +}); +GameOverScene.create = function () { + var scene = new GameOverScene(); + scene.init(); + return scene; +}; diff --git a/tests/js-tests/src/CocoStudioTest/ComponentsTest/PlayerController.js b/tests/js-tests/src/CocoStudioTest/ComponentsTest/PlayerController.js new file mode 100644 index 0000000000..03dc538619 --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/ComponentsTest/PlayerController.js @@ -0,0 +1,66 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 PlayerController = ccs.ComController.extend({ + ctor: function () { + this._super(); + this._name = "PlayerController"; + + this._listener1 = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded: this.onTouchesEnded.bind(this) + }); + + cc.eventManager.addListener(this._listener1, 1); + }, + + update: function (dt) { + + }, + + onTouchesEnded: function (touch, event) { + var location = touch[0].getLocation(); + + var projectile = new cc.Sprite("res/components/Projectile.png", cc.rect(0, 0, 20, 20)); + this.getOwner().parent.addChild(projectile, 1, 4); + + var com = ProjectileController.create(); + projectile.addComponent(com); + com.move(location.x, location.y); + + this.getOwner().getComponent("Audio").playEffect("res/Sound/pew-pew-lei.wav"); + }, + onExit:function(){ + cc.eventManager.removeListener(this._listener1); + this._super(); + } +}); + +PlayerController.create = function () { + var controller = new PlayerController(); + controller.init(); + return controller; +}; \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/ComponentsTest/ProjectileController.js b/tests/js-tests/src/CocoStudioTest/ComponentsTest/ProjectileController.js new file mode 100644 index 0000000000..a4813fc0ea --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/ComponentsTest/ProjectileController.js @@ -0,0 +1,122 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 ProjectileController = ccs.ComController.extend({ + ctor: function () { + this._super(); + this._name = "ProjectileController"; + }, + init: function () { + return true; + }, + + onEnter: function () { + var winSize = cc.director.getWinSize(); + this.getOwner().x = 30; + this.getOwner().y = winSize.height / 2; + this.getOwner().tag = 3; + var com = this.getOwner().parent.getComponent("SceneController"); + com.getProjectiles().push(this.getOwner()); + }, + + onExit: function () { + }, + + update: function (dt) { + var com = this.getOwner().parent.getComponent("SceneController"); + var targets = com.getTargets(); + + var projectile = this.getOwner(); + var projectileRect = cc.rect(projectile.x - (projectile.width / 2), projectile.y - (projectile.height / 2), projectile.width, projectile.height); + + var targetsToDelete = []; + var target = null; + var targetSize = null; + for (var i = 0; i < targets.length; i++) { + target = targets[i]; + var targetRect = cc.rect(target.x - (target.width / 2), target.y - (target.height / 2), target.width, target.height); + if (cc.rectIntersectsRect(projectileRect, targetRect)) { + targetsToDelete.push(target); + } + } + + for (var i = 0; i < targetsToDelete.length; i++) { + var target = targetsToDelete[i]; + target.getComponent("EnemyController").die(); + } + + var isDied = targetsToDelete.length; + + if (isDied) { + this.die(); + } + }, + + move: function (x, y) { + var winSize = cc.director.getWinSize(); + + var offX = x - this.getOwner().x; + var offY = y - this.getOwner().y; + + if (offX <= 0) return; + + // Determine where we wish to shoot the projectile to + var realX = winSize.width + (this.getOwner().width / 2); + var ratio = offY / offX; + var realY = (realX * ratio) + this.getOwner().y; + var realDest = cc.p(realX, realY); + + // Determine the length of how far we're shooting + var offRealX = realX - this.getOwner().x; + var offRealY = realY - this.getOwner().y; + var length = Math.sqrt((offRealX * offRealX) + (offRealY * offRealY)); + var velocity = 480 / 1; // 480pixels/1sec + var realMoveDuration = length / velocity; + + // Move projectile to actual endpoint + this.getOwner().runAction(cc.sequence( + cc.moveTo(realMoveDuration, realDest), + cc.callFunc(function () { + var sceneController = this.getOwner().parent.getComponent("SceneController"); + sceneController.spriteMoveFinished(this.getOwner()); + }, this))); + + }, + + die: function () { + var com = this.getOwner().parent.getComponent("SceneController"); + var projectiles = com.getProjectiles(); + cc.arrayRemoveObject(projectiles, this.getOwner()); + this.getOwner().removeFromParent(true); + } + +}); + +ProjectileController.create = function () { + var controller = new ProjectileController(); + controller.init(); + return controller; +}; \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/ComponentsTest/SceneController.js b/tests/js-tests/src/CocoStudioTest/ComponentsTest/SceneController.js new file mode 100644 index 0000000000..e244174e99 --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/ComponentsTest/SceneController.js @@ -0,0 +1,107 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 SceneController = ccs.ComController.extend({ + _targets: null, + _projectiles: null, + _addTargetTime: 0, + _elapsedTime: 0, + ctor: function () { + this._super(); + this._name = "SceneController"; + this._targets = []; + this._projectiles = []; + }, + init: function () { + return true; + }, + + onEnter: function () { + this._addTargetTime = 1; + this._targets = []; + this._projectiles = []; + this.getOwner().getComponent("Audio").playBackgroundMusic("res/Sound/background-music-aac.wav", true); + this.getOwner().getComponent("CCComAttribute").setInt("KillCount", 0); + }, + + onExit: function () { + + }, + + update: function (dt) { + this._elapsedTime += dt; + if (this._elapsedTime > this._addTargetTime) { + this.addTarget(); + this._elapsedTime = 0.0; + } + }, + + addTarget: function () { + var target = new cc.Sprite("res/components/Target.png", cc.rect(0, 0, 27, 40)); + this.getOwner().addChild(target, 1, 2); + target.addComponent(EnemyController.create()); + target.tag = 2; + this._targets.push(target); + }, + + spriteMoveFinished: function (sender) { + var sprite = sender; + this.getOwner().removeChild(sprite, true); + if (sprite.tag == 2) { + cc.arrayRemoveObject(this._targets, sprite); + var gameOverScene = GameOverScene.create(); + gameOverScene.getLayer().getLabel().setString("You Lose!"); + cc.director.runScene(gameOverScene); + } + else if (sprite.tag == 3) { + cc.arrayRemoveObject(this._projectiles, sprite); + } + + }, + + increaseKillCount: function () { + var comAttribute = this.getOwner().getComponent("CCComAttribute"); + var projectilesDestroyed = comAttribute.getInt("KillCount"); + comAttribute.setInt("KillCount", ++projectilesDestroyed); + if (projectilesDestroyed >= 5) { + var gameOverScene = GameOverScene.create(); + gameOverScene.getLayer().getLabel().setString("You Win!"); + cc.director.runScene(gameOverScene); + } + }, + getProjectiles: function () { + return this._projectiles; + }, + getTargets: function () { + return this._targets; + } +}); + +SceneController.create = function () { + var controller = new SceneController(); + controller.init(); + return controller; +}; \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/CustomTest/CustomGUIScene.js b/tests/js-tests/src/CocoStudioTest/CustomTest/CustomGUIScene.js new file mode 100644 index 0000000000..5b8ea55864 --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/CustomTest/CustomGUIScene.js @@ -0,0 +1,107 @@ +/**************************************************************************** + 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 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 g_guisTests = [ + { + title: "custom gui image Test", + test: function(){ + var pScene = new CustomImageScene(); + pScene.runThisTest(); + } + },{ + title: "custom gui particle widget Test", + test: function(){ + var pScene = new CustomParticleWidgetScene(); + pScene.runThisTest(); + } + } +]; + +var CustomGUITestMainLayer = cc.Layer.extend({ + onEnter: function(){ + cc.Layer.prototype.onEnter.call(this); + + var winSize = cc.director.getWinSize(); + + var pMenu = new cc.Menu(); + pMenu.x = 0; + pMenu.y = 0; + cc.MenuItemFont.setFontName("fonts/arial.ttf"); + cc.MenuItemFont.setFontSize(24); + + for (var i = 0; i < g_guisTests.length; ++i) { + var selItem = g_guisTests[i]; + var pItem = new cc.MenuItemFont(selItem.title, + selItem.test, this); + pItem.x = winSize.width / 2; + pItem.y = winSize.height - (i + 1) * LINE_SPACE; + pMenu.addChild(pItem, ITEM_TAG_BASIC + i); + } + this.addChild(pMenu); + + }, + onTouchesBegan: function(touches, event){ + var touch = touches[0]; + + this._beginPos = touch.getLocation(); + }, + touchEvent: function(){ + + } + +}); + +var CustomGUITestScene = cc.Scene.extend({ + onEnter: function(){ + cc.Scene.prototype.onEnter.call(this); + + var label = new cc.LabelTTF("Back", "fonts/arial.ttf", 20); + //#endif + var pMenuItem = new cc.MenuItemLabel(label, this.BackCallback, this); + + var pMenu = new cc.Menu(pMenuItem); + + pMenu.setPosition( cc.p(0, 0) ); + pMenuItem.setPosition(cc.pAdd(cc.visibleRect.bottomRight,cc.p(-50,25))); + + this.addChild(pMenu, 1); + + }, + runThisTest: function(){ + var pLayer = new CustomGUITestMainLayer(); + this.addChild(pLayer); + + cc.director.runScene(this); + }, + BackCallback: function(pSender){ + var pScene = new CocoStudioTestScene(); + pScene.runThisTest(); + + } +}); + +var runCustomGUITest = function(){ + var scene = new CustomGUITestScene(); + scene.runThisTest(); +}; \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageScene/CustomImageScene.js b/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageScene/CustomImageScene.js new file mode 100644 index 0000000000..57042f3e62 --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageScene/CustomImageScene.js @@ -0,0 +1,67 @@ +/**************************************************************************** + 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 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 CustomImageLayer = cc.Layer.extend({ + + onEnter: function(){ + cc.Layer.prototype.onEnter.call(this); + + var guiReader = ccs.uiReader; + guiReader.registerTypeAndCallBack("CustomImageView", + CustomImageView, + customImageViewReader, + customImageViewReader.setProperties); + + var layout = guiReader.widgetFromJsonFile("res/cocosui/CustomImageViewTest/NewProject_2_1.ExportJson"); + this.addChild(layout); + } +}); + +var CustomImageScene = cc.Scene.extend({ + + onEnter: function(){ + cc.Scene.prototype.onEnter.call(this); + + var label = new cc.LabelTTF("Back", "fonts/arial.ttf", 20); + //#endif + var pMenuItem = new cc.MenuItemLabel(label, this.BackCallback, this); + + var pMenu = new cc.Menu(pMenuItem); + + pMenu.setPosition( cc.p(0, 0) ); + pMenuItem.setPosition( cc.p( 750, 25) ); + + this.addChild(pMenu, 1); + }, + runThisTest: function(){ + var pLayer = new CustomImageLayer(); + this.addChild(pLayer); + + cc.director.runScene(this); + }, + BackCallback: function(pSender){ + var pScene = new CustomGUITestScene(); + pScene.runThisTest(); + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageView/CustomImageView.js b/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageView/CustomImageView.js new file mode 100644 index 0000000000..ca09265f98 --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageView/CustomImageView.js @@ -0,0 +1,66 @@ +/**************************************************************************** + 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 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 CustomImageView = ccui.ImageView.extend({ + + _label: null, + + init: function(){ + if (ccui.ImageView.prototype.init.call(this)) + { + return true; + } + return false; + }, + + _initRenderer: function(){ + ccui.ImageView.prototype._initRenderer.call(this); + + this._label = new cc.LabelTTF(); + cc.ProtectedNode.prototype.addChild.call(this, this._label, this.getLocalZOrder() + 1, -1); + }, + + createInstance: function(){ + return CustomImageView; + }, + + setText: function(text){ + this._label.setString(text); + }, + + getText: function(){ + return this._label.getString(); + } +}); + +CustomImageView.create = function(){ + var custom = new CustomImageView(); + + if (custom && custom.init()) + { + return custom; + } + return null; + +}; \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageView/CustomImageViewReader.js b/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageView/CustomImageViewReader.js new file mode 100644 index 0000000000..b2aec77aee --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageView/CustomImageViewReader.js @@ -0,0 +1,42 @@ +/**************************************************************************** + 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 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 customImageViewReader = { + + _instanceCustomImageViewReader: null, + + setProperties: function(classType, widget, customOptions){ + var custom = widget; + + var StringTest = customOptions["StringTest"]; + if (StringTest) { + custom.setText(StringTest); + } + + }, + + setPropsFromJsonDictionary: function(){ + ccs.imageViewReader.setPropsFromJsonDictionary.apply(this, arguments); + } +}; \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageView/CustomParticWidgetReader.js b/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageView/CustomParticWidgetReader.js new file mode 100644 index 0000000000..f947e2f5ec --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageView/CustomParticWidgetReader.js @@ -0,0 +1,43 @@ +/**************************************************************************** + 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 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 customParticleWidgetReader = { + + setProperties: function(classType, widget, customOptions){ + var guiReader = ccs.uiReader; + + var custom = widget; + + var isExistPlistFile = customOptions["PlistFile"]; + if (isExistPlistFile) + { + var PlistFile = customOptions["PlistFile"]; + var PlistFilePath = guiReader.getFilePath(); + PlistFilePath += PlistFile; + custom.setParticlePlist(PlistFilePath); + + } + + } +}; \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageView/CustomParticleWidget.js b/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageView/CustomParticleWidget.js new file mode 100644 index 0000000000..e3d3901ea0 --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageView/CustomParticleWidget.js @@ -0,0 +1,104 @@ +/**************************************************************************** + 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 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 CustomParticleWidget = ccui.Widget.extend({ + + _emitter: null, + + _emitterPlist: null, + + _emitterPostion: null, + + init: function(){ + if (ccui.Widget.prototype.init.call(this)) + { + return true; + } + return false; + }, + + _initRenderer: function(){ + ccui.Widget.prototype._initRenderer.call(this); + }, + + removeAllChildren: function(){ + ccui.Widget.prototype.removeAllChildren.call(this); + }, + + createInstance: function(){ + return CustomParticleWidget.create(); + }, + setParticlePlist: function(plist){ + if (!this._emitter) + { + this._emitter = new cc.ParticleSystem(plist); + + } + else + { + this._emitter.removeFromParent(); + this._emitter = new cc.ParticleSystem(plist); + } + //Warning!!! don't forget to set the position + this.addProtectedChild(this._emitter , this.getLocalZOrder() + 1, -1); + this.setParticlePosition(cc.p(0, 0)); + + this._emitterPlist = plist; + + }, + getParticlePlist: function(){ + return this._emitterPlist; + }, + setParticlePosition: function(pos){ + this._emitter.setPosition(pos); + + this._emitterPostion = pos; + + }, + getParticlePosition: function(){ + return this._emitterPostion; + }, + playParticle: function(){ + if (this._emitter) + { + this._emitter.resetSystem(); + } + }, + stopParticle: function(){ + if (this._emitter) + { + this._emitter.stopSystem(); + } + } +}); + +CustomParticleWidget.create = function(){ + var custom = new CustomParticleWidget(); + + if (custom && custom.init()) + { + return custom; + } + return null; +}; \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageView/CustomReader.js b/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageView/CustomReader.js new file mode 100644 index 0000000000..333fb4f90f --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageView/CustomReader.js @@ -0,0 +1,43 @@ +/**************************************************************************** + 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 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.customReader = { + + _instanceCustomReader: null, + + setProperties: function(classType, widget, customOptions){ + if (classType.compare("CustomImageView") == 0) + { + var customImageView = widget; + + var isExistText = customOptions["text"]; + if (isExistText) + { + var text = customOptions["text"]; + customImageView.setText(text); + } + } + + } +}; \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.js b/tests/js-tests/src/CocoStudioTest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.js new file mode 100644 index 0000000000..772f2c1c2e --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/CustomTest/CustomParticleWidgetTest/CustomParticleWidgetTest.js @@ -0,0 +1,74 @@ +/**************************************************************************** + 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 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 CustomParticleWidgetLayer = cc.Layer.extend({ + + onEnter: function(){ + cc.Layer.prototype.onEnter.call(this); + + var guiReader = ccs.uiReader; + guiReader.registerTypeAndCallBack("CustomParticleWidget", + CustomParticleWidget, + customParticleWidgetReader, + customParticleWidgetReader.setProperties); + + var custom = CustomParticleWidget.create(); + custom.setPosition(cc.p(370, 210)); + custom.setParticlePlist("res/Particles/BoilingFoam.plist"); + + this.addChild(custom, 10, -1); + } +}); + + +var CustomParticleWidgetScene = cc.Scene.extend({ + + onEnter: function(){ + cc.Scene.prototype.onEnter.call(this); + + var label = new cc.LabelTTF("Back", "fonts/arial.ttf", 20); + //#endif + var pMenuItem = new cc.MenuItemLabel(label, this.BackCallback, this); + + var pMenu = new cc.Menu(pMenuItem); + + pMenu.setPosition( cc.p(0, 0) ); + pMenuItem.setPosition( cc.p( 750, 25) ); + + this.addChild(pMenu, 1); + + }, + + runThisTest: function(){ + var pLayer = new CustomParticleWidgetLayer(); + this.addChild(pLayer); + + cc.director.runScene(this); + }, + + BackCallback: function(pSender){ + var pScene = new CustomGUITestScene(); + pScene.runThisTest(); + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/GUITest/UIBaseLayer.js b/tests/js-tests/src/CocoStudioTest/GUITest/UIBaseLayer.js new file mode 100644 index 0000000000..3937657cde --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/GUITest/UIBaseLayer.js @@ -0,0 +1,70 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 UIBaseLayer = cc.Layer.extend({ + _mainNode:null, + _topDisplayText:null, + ctor: function () { + this._super(); + var winSize = cc.director.getWinSize(); + + //add main node + var mainNode = new cc.Node(); + var scale = winSize.height / 320; + mainNode.attr({anchorX: 0, anchorY: 0, scale: scale, x: (winSize.width - 480 * scale) / 2, y: (winSize.height - 320 * scale) / 2}); + this.addChild(mainNode); + + var topDisplayText = new ccui.Text(); + topDisplayText.attr({ + string: "", + font: "20px Arial", + x: 240, + y: 320-50 + }); + mainNode.addChild(topDisplayText,100); + + this._mainNode = mainNode; + this._topDisplayText = topDisplayText; + }, + + _parseUIFile: function(file){ + if(cocoStudioOldApiFlag == 0){ + cc.log("ccs.load : %s", file); + var json = ccs.load(file); + return json.node; + }else{ + //ccs.uiReader.widgetFromJsonFile only supports 1.x file. + cc.log("ccs.uiReader.widgetFromJsonFile : %s", file); + return ccs.uiReader.widgetFromJsonFile(file) + } + }, + + backEvent: function (sender, type) { + if (type == ccui.Widget.TOUCH_ENDED) { + runGuiTestMain(); + } + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/GUITest/UIButtonTest/UIButtonTest.js b/tests/js-tests/src/CocoStudioTest/GUITest/UIButtonTest/UIButtonTest.js new file mode 100644 index 0000000000..cfff52221a --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/GUITest/UIButtonTest/UIButtonTest.js @@ -0,0 +1,68 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 UIButtonEditorTest = UIBaseLayer.extend({ + ctor: function () { + this._super(); + var root = this._parseUIFile("res/cocosui/CCS/Button/Button_1.json"); + this._mainNode.addChild(root); + + var back_label = ccui.helper.seekWidgetByName(root, "back"); + back_label.addTouchEventListener(this.backEvent,this); + + var button = ccui.helper.seekWidgetByName(root, "Button_123"); + button.addTouchEventListener(this.touchEvent,this); + + var title_button = ccui.helper.seekWidgetByName(root, "Button_126"); + title_button.addTouchEventListener(this.touchEvent,this); + + var scale9_button = ccui.helper.seekWidgetByName(root, "Button_129"); + scale9_button.addTouchEventListener(this.touchEvent,this); + }, + + touchEvent: function (sender, type) { + switch (type) { + case ccui.Widget.TOUCH_BEGAN: + this._topDisplayText.setString("Touch Down"); + break; + + case ccui.Widget.TOUCH_MOVED: + this._topDisplayText.setString("Touch Move"); + break; + + case ccui.Widget.TOUCH_ENDED: + this._topDisplayText.setString("Touch Up"); + break; + + case ccui.Widget.TOUCH_CANCELED: + this._topDisplayText.setString("Touch Cancelled"); + break; + + default: + break; + } + } +}); diff --git a/tests/js-tests/src/CocoStudioTest/GUITest/UICheckBoxTest/UICheckBoxTest.js b/tests/js-tests/src/CocoStudioTest/GUITest/UICheckBoxTest/UICheckBoxTest.js new file mode 100644 index 0000000000..d5f89573a4 --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/GUITest/UICheckBoxTest/UICheckBoxTest.js @@ -0,0 +1,113 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 CEHCK_BOX_INDEX = 0; + +var UICheckBoxEditorTest = UIBaseLayer.extend({ + ctor: function () { + this._super(); + var left_button = new ccui.Button(); + left_button.loadTextures("res/Images/b1.png", "res/Images/b2.png", ""); + left_button.x = 240-50; + left_button.y = 50; + left_button.anchorX = 0.5; + left_button.anchorY = 0.5; + left_button.addTouchEventListener(this.previousCallback, this); + this._mainNode.addChild(left_button, 999); + + var right_button = new ccui.Button(); + right_button.loadTextures("res/Images/f1.png", "res/Images/f2.png", ""); + right_button.x = 240+50; + right_button.y = 50; + right_button.anchorX = 0.5; + right_button.anchorY = 0.5; + right_button.addTouchEventListener(this.nextCallback, this); + this._mainNode.addChild(right_button, 999); + }, + previousCallback: function (render, type) { + if (type == ccui.Widget.TOUCH_ENDED) { + CEHCK_BOX_INDEX--; + if (CEHCK_BOX_INDEX < 0)CEHCK_BOX_INDEX = CEHCK_BOX_SCENE.length-1; + if (CEHCK_BOX_INDEX >= CEHCK_BOX_SCENE.length)CEHCK_BOX_INDEX = 0; + this.runNextScene(); + } + }, + nextCallback: function (render, type) { + if (type == ccui.Widget.TOUCH_ENDED) { + CEHCK_BOX_INDEX++; + if (CEHCK_BOX_INDEX < 0)CEHCK_BOX_INDEX = CEHCK_BOX_SCENE.length-1; + if (CEHCK_BOX_INDEX >= CEHCK_BOX_SCENE.length)CEHCK_BOX_INDEX = 0; + this.runNextScene(); + } + }, + runNextScene: function () { + var scene = new cc.Scene(); + scene.addChild(new CEHCK_BOX_SCENE[CEHCK_BOX_INDEX]()); + cc.director.runScene(scene); + }, + + selectedStateEvent: function (sender, type) { + switch (type) { + case ccui.CheckBox.EVENT_SELECTED: + this._topDisplayText.setString("Selected"); + break; + case ccui.CheckBox.EVENT_UNSELECTED: + this._topDisplayText.setString("Unselected"); + break; + + default: + break; + } + } +}); + +var UICheckBoxOldTest = UICheckBoxEditorTest.extend({ + ctor: function () { + this._super(); + var root = this._parseUIFile("res/cocosui/CCS/CheckBox/checkbox_1.json"); + this._mainNode.addChild(root); + + var back_label =ccui.helper.seekWidgetByName(root, "back"); + back_label.addTouchEventListener(this.backEvent,this); + + var checkbox = ccui.helper.seekWidgetByName(root, "CheckBox_540"); + checkbox.addEventListener(this.selectedStateEvent,this); + } +}); + +var UICheckBoxNewTest = UICheckBoxEditorTest.extend({ + ctor: function () { + this._super(); + var root = ccs.load("res/cocosui/CCS/CheckBox/MainScene.json"); + this._mainNode.addChild(root.node); + var checkbox = ccui.helper.seekWidgetByName(root.node, "CheckBox_1"); + checkbox.addEventListener(this.selectedStateEvent,this); + } +}); + +var CEHCK_BOX_SCENE = [ + UICheckBoxOldTest, + UICheckBoxNewTest +]; diff --git a/tests/js-tests/src/CocoStudioTest/GUITest/UIImageViewTest/UIImageViewTest.js b/tests/js-tests/src/CocoStudioTest/GUITest/UIImageViewTest/UIImageViewTest.js new file mode 100644 index 0000000000..f92f400761 --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/GUITest/UIImageViewTest/UIImageViewTest.js @@ -0,0 +1,36 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 UIImageViewEditorTest = UIBaseLayer.extend({ + ctor: function () { + this._super(); + var root = this._parseUIFile("res/cocosui/CCS/ImageView/ImageView_1.json"); + this._mainNode.addChild(root); + + var back_label =ccui.helper.seekWidgetByName(root, "back"); + back_label.addTouchEventListener(this.backEvent,this); + } +}); diff --git a/tests/js-tests/src/CocoStudioTest/GUITest/UILayoutTest/UILayoutTest.js b/tests/js-tests/src/CocoStudioTest/GUITest/UILayoutTest/UILayoutTest.js new file mode 100644 index 0000000000..6284598fca --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/GUITest/UILayoutTest/UILayoutTest.js @@ -0,0 +1,88 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 LAYOUT_RES = [ + "res/cocosui/CCS/Layout/Layout/layout_1.json", + "res/cocosui/CCS/Layout/Color/color_1.json", + "res/cocosui/CCS/Layout/Gradient_Color/gradient_color_1.json", + "res/cocosui/CCS/Layout/BackgroundImage/backgroundimage_1.json", + "res/cocosui/CCS/Layout/Scale9/scale9.json", + "res/cocosui/CCS/Layout/Linear_Vertical/linear_vertical.json", + "res/cocosui/CCS/Layout/Linear_Horizontal/linear_horizontal.json", + "res/cocosui/CCS/Layout/Relative_Align_Parent/relative_align_parent.json", + "res/cocosui/CCS/Layout/Relative_Align_Location/relative_align_location.json" +]; +var LAYOUT_INDEX = 0; +var UILayoutEditorTest = UIBaseLayer.extend({ + ctor: function () { + this._super(); + var root = this._parseUIFile(LAYOUT_RES[LAYOUT_INDEX]); + this._mainNode.addChild(root); + + var back_label = ccui.helper.seekWidgetByName(root, "back"); + back_label.addTouchEventListener(this.backEvent, this); + + var left_button = new ccui.Button(); + left_button.loadTextures("res/Images/b1.png", "res/Images/b2.png", ""); + left_button.x = 240-50; + left_button.y = 50; + left_button.anchorX = 0.5; + left_button.anchorY = 0.5; + left_button.zOrder = 999; + left_button.addTouchEventListener(this.previousCallback, this); + this._mainNode.addChild(left_button); + + var right_button = new ccui.Button(); + right_button.loadTextures("res/Images/f1.png", "res/Images/f2.png", ""); + right_button.x = 240+50; + right_button.y = 50; + right_button.zOrder = 999; + right_button.anchorX = 0.5; + right_button.anchorY = 0.5; + right_button.addTouchEventListener(this.nextCallback, this); + this._mainNode.addChild(right_button); + }, + previousCallback: function (render, type) { + if (type == ccui.Widget.TOUCH_ENDED) { + LAYOUT_INDEX--; + if (LAYOUT_INDEX < 0)LAYOUT_INDEX = LAYOUT_RES.length-1; + if (LAYOUT_INDEX >= LAYOUT_RES.length)LAYOUT_INDEX = 0; + this.runNextScene(); + } + }, + nextCallback: function (render, type) { + if (type == ccui.Widget.TOUCH_ENDED) { + LAYOUT_INDEX++; + if (LAYOUT_INDEX < 0)LAYOUT_INDEX = LAYOUT_RES.length-1; + if (LAYOUT_INDEX >= LAYOUT_RES.length)LAYOUT_INDEX = 0; + this.runNextScene(); + } + }, + runNextScene: function () { + var scene = new cc.Scene(); + scene.addChild(new UILayoutEditorTest()); + cc.director.runScene(scene); + } +}); diff --git a/tests/js-tests/src/CocoStudioTest/GUITest/UIListViewTest/UIListViewTest.js b/tests/js-tests/src/CocoStudioTest/GUITest/UIListViewTest/UIListViewTest.js new file mode 100644 index 0000000000..54201c6dcb --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/GUITest/UIListViewTest/UIListViewTest.js @@ -0,0 +1,97 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 LISTVIEW_RES = [ + "res/cocosui/CCS/ListView/Vertical/vertical_1.json", + "res/cocosui/CCS/ListView/Horizontal/horizontal_1.json" +]; +var LISTVIEW_INDEX = 0; +var UIListViewEditorTest = UIBaseLayer.extend({ + ctor: function () { + this._super(); + var root = this._parseUIFile(LISTVIEW_RES[LISTVIEW_INDEX]); + this._mainNode.addChild(root); + + var back_label = ccui.helper.seekWidgetByName(root, "back"); + back_label.addTouchEventListener(this.backEvent, this); + + var listView = ccui.helper.seekWidgetByName(root, "ListView_1214"); + listView.addEventListener(this.selectedItemEvent,this); + + var left_button = new ccui.Button(); + left_button.loadTextures("res/Images/b1.png", "res/Images/b2.png", ""); + left_button.x = 240-50; + left_button.y = 50; + left_button.anchorX = 0.5; + left_button.anchorY = 0.5; + left_button.zOrder = 999; + left_button.addTouchEventListener(this.previousCallback, this); + this._mainNode.addChild(left_button); + + var right_button = new ccui.Button(); + right_button.loadTextures("res/Images/f1.png", "res/Images/f2.png", ""); + right_button.x = 240+50; + right_button.y = 50; + right_button.zOrder = 999; + right_button.anchorX = 0.5; + right_button.anchorY = 0.5; + right_button.addTouchEventListener(this.nextCallback, this); + this._mainNode.addChild(right_button); + }, + selectedItemEvent: function (sender, type) { + switch (type) { + case ccui.ListView.EVENT_SELECTED_ITEM: + var listViewEx = sender; + cc.log("select child index = " + listViewEx.getCurSelectedIndex()); + break; + + default: + break; + } + }, + previousCallback: function (render, type) { + if (type == ccui.Widget.TOUCH_ENDED) { + LISTVIEW_INDEX--; + if (LISTVIEW_INDEX < 0)LISTVIEW_INDEX = LISTVIEW_RES.length-1; + if (LISTVIEW_INDEX >= LISTVIEW_RES.length)LISTVIEW_INDEX = 0; + this.runNextScene(); + } + }, + nextCallback: function (render, type) { + if (type == ccui.Widget.TOUCH_ENDED) { + LISTVIEW_INDEX++; + if (LISTVIEW_INDEX < 0)LISTVIEW_INDEX = LISTVIEW_RES.length-1; + if (LISTVIEW_INDEX >= LISTVIEW_RES.length)LISTVIEW_INDEX = 0; + this.runNextScene(); + } + }, + runNextScene: function () { + var scene = new cc.Scene(); + scene.addChild(new UIListViewEditorTest()); + cc.director.runScene(scene); + } +}); + + diff --git a/tests/js-tests/src/CocoStudioTest/GUITest/UILoadingBarTest/UILoadingBarTest.js b/tests/js-tests/src/CocoStudioTest/GUITest/UILoadingBarTest/UILoadingBarTest.js new file mode 100644 index 0000000000..677f71301b --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/GUITest/UILoadingBarTest/UILoadingBarTest.js @@ -0,0 +1,55 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 UILoadingBarEditorTest = UIBaseLayer.extend({ + _count: 0, + _loadingBar_left_to_right:null, + _loadingBar_right_to_left:null, + ctor: function () { + this._super(); + var root = this._parseUIFile("res/cocosui/CCS/LoadingBar/loadingbar_1.json"); + this._mainNode.addChild(root); + + var back_label =ccui.helper.seekWidgetByName(root, "back"); + back_label.addTouchEventListener(this.backEvent,this); + + this._loadingBar_left_to_right = ccui.helper.seekWidgetByName(root, "LoadingBar_856"); + this._loadingBar_left_to_right.setPercent(0); + + this._loadingBar_right_to_left = ccui.helper.seekWidgetByName(root, "LoadingBar_857"); + this._loadingBar_right_to_left.setPercent(0); + + this.scheduleUpdate(); + }, + update: function (dt) { + this._count++; + if (this._count > 100) { + this._count = 0; + } + this._loadingBar_left_to_right.setPercent(this._count); + this._loadingBar_right_to_left.setPercent(this._count); + } +}); diff --git a/tests/js-tests/src/CocoStudioTest/GUITest/UINodeContainerTest/UINodeContainerTest.js b/tests/js-tests/src/CocoStudioTest/GUITest/UINodeContainerTest/UINodeContainerTest.js new file mode 100644 index 0000000000..f2f047cb0c --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/GUITest/UINodeContainerTest/UINodeContainerTest.js @@ -0,0 +1,41 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 UIWidgetAddNodeEditorTest = UIBaseLayer.extend({ + ctor: function () { + this._super(); + var root = this._parseUIFile("res/cocosui/CCS/WidgetAddNode/widget_add_node.json"); + this._mainNode.addChild(root); + + var back_label =ccui.helper.seekWidgetByName(root, "back"); + back_label.addTouchEventListener(this.backEvent,this); + + var sprite = new cc.Sprite("res/cocosui/ccicon.png"); + sprite.x = 240; + sprite.y = 160; + root.addNode(sprite,9999); + } +}); diff --git a/tests/js-tests/src/CocoStudioTest/GUITest/UIPageViewTest/UIPageViewTest.js b/tests/js-tests/src/CocoStudioTest/GUITest/UIPageViewTest/UIPageViewTest.js new file mode 100644 index 0000000000..f50749bfe0 --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/GUITest/UIPageViewTest/UIPageViewTest.js @@ -0,0 +1,50 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 UIPageViewEditorTest = UIBaseLayer.extend({ + ctor: function () { + this._super(); + var root = this._parseUIFile("res/cocosui/CCS/PageView/pageview_1.json"); + this._mainNode.addChild(root); + + var back_label =ccui.helper.seekWidgetByName(root, "back"); + back_label.addTouchEventListener(this.backEvent,this); + + var pageView =ccui.helper.seekWidgetByName(root, "PageView_1269"); + pageView.addEventListener(this.pageViewEvent, this); + }, + + pageViewEvent: function (sender, type) { + switch (type) { + case ccui.PageView.EVENT_TURNING: + var pageView = sender; + this._topDisplayText.setString("page = " + (pageView.getCurPageIndex() + 1)); + break; + default: + break; + } + } +}); diff --git a/tests/js-tests/src/CocoStudioTest/GUITest/UIRichTextTest/UIRichTextTest.js b/tests/js-tests/src/CocoStudioTest/GUITest/UIRichTextTest/UIRichTextTest.js new file mode 100644 index 0000000000..16c0ce2324 --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/GUITest/UIRichTextTest/UIRichTextTest.js @@ -0,0 +1,92 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 UIRichTextTest = UISceneEditor.extend({ + _richText:null, + init: function () { + if (this._super()) { + //init text + this._topDisplayLabel.setString(""); + this._bottomDisplayLabel.setString("RichText"); + + var widgetSize = this._widget.getContentSize(); + var button = new ccui.Button(); + button.setTouchEnabled(true); + button.loadTextures("res/cocosui/animationbuttonnormal.png", "res/cocosui/animationbuttonpressed.png", ""); + button.setTitleText("switch"); + button.setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 + button.getContentSize().height * 2.5)); + button.addTouchEventListener(this.touchEvent,this); + this._mainNode.addChild(button); + + + // RichText + var richText = new ccui.RichText(); + richText.ignoreContentAdaptWithSize(false); + richText.setContentSize(cc.size(120, 100)); + + var re1 = new ccui.RichElementText(1, cc.color.WHITE, 255, "This color is white. ", "Helvetica", 10); + var re2 = new ccui.RichElementText(2, cc.color.YELLOW, 255, "And this is yellow. ", "Helvetica", 10); + var re3 = new ccui.RichElementText(3, cc.color.BLUE, 255, "This one is blue. ", "Helvetica", 10); + var re4 = new ccui.RichElementText(4, cc.color.GREEN, 255, "And green. ", "Helvetica", 10); + var re5 = new ccui.RichElementText(5, cc.color.RED, 255, "Last one is red ", "Helvetica", 10); + + var reimg = new ccui.RichElementImage(6, cc.color.WHITE, 255, "res/cocosui/sliderballnormal.png"); + + ccs.armatureDataManager.addArmatureFileInfo("res/cocosui/100/100.ExportJson"); + var pAr = new ccs.Armature("100"); + pAr.getAnimation().play("Animation1"); + + var recustom = new ccui.RichElementCustomNode(1, cc.color.WHITE, 255, pAr); + var re6 = new ccui.RichElementText(7, cc.color.ORANGE, 255, "Have fun!! ", "Helvetica", 10); + richText.pushBackElement(re1); + richText.insertElement(re2, 1); + richText.pushBackElement(re3); + richText.pushBackElement(re4); + richText.pushBackElement(re5); + richText.insertElement(reimg, 2); + richText.pushBackElement(recustom); + richText.pushBackElement(re6); + + richText.setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2)); + + this._mainNode.addChild(richText); + this._richText = richText; + return true; + } + return false; + }, + touchEvent: function (sender, type) { + if (type == ccui.Widget.TOUCH_ENDED) { + if (this._richText.isIgnoreContentAdaptWithSize()) { + this._richText.ignoreContentAdaptWithSize(false); + this._richText.setContentSize(cc.size(120, 100)); + } + else { + this._richText.ignoreContentAdaptWithSize(true); + } + } + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/GUITest/UISceneTest.js b/tests/js-tests/src/CocoStudioTest/GUITest/UISceneTest.js new file mode 100644 index 0000000000..d1e25af47e --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/GUITest/UISceneTest.js @@ -0,0 +1,177 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 s_GuiTestEditorArray = [ + { + title: "Button", + layer: function () { + return new UIButtonEditorTest(); + } + }, + { + title: "CheckBox", + layer: function () { + return new CEHCK_BOX_SCENE[0](); + } + }, + { + title: "ImageView", + layer: function () { + return new UIImageViewEditorTest(); + } + }, + { + title: "Text", + layer: function () { + return new UITextEditorTest(); + } + }, + { + title: "TextAtlas", + layer: function () { + return new UITextAtlasEditorTest(); + } + }, + { + title: "TextBMFont", + layer: function () { + return new UITextBMFontEditorTest(); + } + }, + { + title: "LoadingBar", + layer: function () { + return new UILoadingBarEditorTest(); + } + }, + { + title: "Slider", + layer: function () { + return new UISliderEditorTest(); + } + }, + { + title: "TextField", + layer: function () { + return new UITextFieldEditorTest(); + } + }, + { + title: "AddNode", + layer: function () { + return new UIWidgetAddNodeEditorTest(); + } + }, + { + title: "Layout", + layer: function () { + return new UILayoutEditorTest(); + } + }, + { + title: "ListView", + layer: function () { + return new UIListViewEditorTest(); + } + }, + { + title: "PageView", + layer: function () { + return new UIPageViewEditorTest(); + } + }, + { + title: "ScrollView", + layer: function () { + return new UIScrollViewEditorTest(); + } + } +]; + +var GuiTestMainLayer = cc.Layer.extend({ + ctor: function () { + this._super(); + var winSize = cc.winSize; + var x = 0; + var y = winSize.height - 10; + for (var i = 0; i < s_GuiTestEditorArray.length; i++) { + var guiTest = s_GuiTestEditorArray[i]; + var text = new ccui.Text(); + if (i % 2 == 0) { + x = winSize.width / 2 - 100; + y -= 30; + } else { + x = winSize.width / 2 + 100; + } + text.attr({ + string: guiTest.title, + font: "20px Arial", + x: x, + y: y, + tag: i + }); + text.setTouchEnabled(true); + text.setTouchScaleChangeEnabled(true); + text.addTouchEventListener(this.touchEvent, this); + this.addChild(text); + } + + var backText = new ccui.Text(); + backText.attr({ + string: "Back", + font: "20px Arial", + x: winSize.width-50, + y: 50, + tag: 10000 + }); + backText.setTouchEnabled(true); + backText.setTouchScaleChangeEnabled(true); + backText.addTouchEventListener(this.backEvent, this); + this.addChild(backText); + }, + touchEvent:function(sender,type){ + if(type==ccui.Widget.TOUCH_ENDED){ + var tag = sender.tag; + var scene = new cc.Scene(); + var guiTest = s_GuiTestEditorArray[tag]; + scene.addChild(guiTest.layer()); + cc.director.runScene(scene); + } + }, + backEvent:function(sender,type){ + if(type==ccui.Widget.TOUCH_ENDED){ + var scene = new CocoStudioTestScene(); + scene.runThisTest(); + } + } +}); + +var runGuiTestMain = function(){ + var scene = new cc.Scene(); + var main = new GuiTestMainLayer(); + scene.addChild(main); + cc.director.runScene(scene); +} \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/GUITest/UIScrollViewTest/UIScrollViewTest.js b/tests/js-tests/src/CocoStudioTest/GUITest/UIScrollViewTest/UIScrollViewTest.js new file mode 100644 index 0000000000..6bf63a4bfc --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/GUITest/UIScrollViewTest/UIScrollViewTest.js @@ -0,0 +1,84 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 SCROLLVIEW_RES = [ + "res/cocosui/CCS/ScrollView/Vertical/vertical_1.json", + "res/cocosui/CCS/ScrollView/Horizontal/horizontal_1.json", + "res/cocosui/CCS/ScrollView/Both/both_1.json" +]; +var SCROLLVIEW_INDEX = 0; +var UIScrollViewEditorTest = UIBaseLayer.extend({ + ctor: function () { + this._super(); + var root = this._parseUIFile(SCROLLVIEW_RES[SCROLLVIEW_INDEX]); + this._mainNode.addChild(root); + + var back_label = ccui.helper.seekWidgetByName(root, "back"); + back_label.addTouchEventListener(this.backEvent, this); + + var left_button = new ccui.Button(); + left_button.loadTextures("res/Images/b1.png", "res/Images/b2.png", ""); + left_button.x = 240-50; + left_button.y = 50; + left_button.anchorX = 0.5; + left_button.anchorY = 0.5; + left_button.zOrder = 999; + left_button.addTouchEventListener(this.previousCallback, this); + this._mainNode.addChild(left_button); + + var right_button = new ccui.Button(); + right_button.loadTextures("res/Images/f1.png", "res/Images/f2.png", ""); + right_button.x = 240+50; + right_button.y = 50; + right_button.zOrder = 999; + right_button.anchorX = 0.5; + right_button.anchorY = 0.5; + right_button.addTouchEventListener(this.nextCallback, this); + this._mainNode.addChild(right_button); + }, + + previousCallback: function (render, type) { + if (type == ccui.Widget.TOUCH_ENDED) { + SCROLLVIEW_INDEX--; + if (SCROLLVIEW_INDEX < 0)SCROLLVIEW_INDEX = SCROLLVIEW_RES.length-1; + if (SCROLLVIEW_INDEX >= SCROLLVIEW_RES.length)SCROLLVIEW_INDEX = 0; + this.runNextScene(); + } + }, + nextCallback: function (render, type) { + if (type == ccui.Widget.TOUCH_ENDED) { + SCROLLVIEW_INDEX++; + if (SCROLLVIEW_INDEX < 0)SCROLLVIEW_INDEX = SCROLLVIEW_RES.length-1; + if (SCROLLVIEW_INDEX >= SCROLLVIEW_RES.length)SCROLLVIEW_INDEX = 0; + this.runNextScene(); + } + }, + runNextScene: function () { + var scene = new cc.Scene(); + scene.addChild(new UIScrollViewEditorTest()); + cc.director.runScene(scene); + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/GUITest/UISliderTest/UISliderTest.js b/tests/js-tests/src/CocoStudioTest/GUITest/UISliderTest/UISliderTest.js new file mode 100644 index 0000000000..727e9cddc3 --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/GUITest/UISliderTest/UISliderTest.js @@ -0,0 +1,54 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 UISliderEditorTest = UIBaseLayer.extend({ + ctor: function () { + this._super(); + var root = this._parseUIFile("res/cocosui/CCS/Slider/slider_1.json"); + this._mainNode.addChild(root); + + var back_label =ccui.helper.seekWidgetByName(root, "back"); + back_label.addTouchEventListener(this.backEvent,this); + + var slider = ccui.helper.seekWidgetByName(root, "Slider_738"); + slider.addEventListener(this.sliderEvent,this); + + var scale9_slider = ccui.helper.seekWidgetByName(root, "Slider_740"); + scale9_slider.addEventListener(this.sliderEvent,this); + }, + + sliderEvent: function (sender, type) { + switch (type) { + case ccui.Slider.EVENT_PERCENT_CHANGED: + var slider = sender; + var percent = slider.getPercent(); + this._topDisplayText.setString("Percent " + percent.toFixed(0)); + break; + default: + break; + } + } +}); diff --git a/tests/js-tests/src/CocoStudioTest/GUITest/UITextAtlasTest/UITextAtlasTest.js b/tests/js-tests/src/CocoStudioTest/GUITest/UITextAtlasTest/UITextAtlasTest.js new file mode 100644 index 0000000000..d7aed9254c --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/GUITest/UITextAtlasTest/UITextAtlasTest.js @@ -0,0 +1,38 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 UITextAtlasEditorTest = UIBaseLayer.extend({ + ctor: function () { + this._super(); + var root = this._parseUIFile("res/cocosui/CCS/LabelAtlas/labelatlas_1.json"); + + this._mainNode.addChild(root); + + var back_label =ccui.helper.seekWidgetByName(root, "back"); + back_label.addTouchEventListener(this.backEvent,this); + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/GUITest/UITextBMFontTest/UITextBMFontTest.js b/tests/js-tests/src/CocoStudioTest/GUITest/UITextBMFontTest/UITextBMFontTest.js new file mode 100644 index 0000000000..1b23e535e6 --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/GUITest/UITextBMFontTest/UITextBMFontTest.js @@ -0,0 +1,37 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 UITextBMFontEditorTest = UIBaseLayer.extend({ + ctor: function () { + this._super(); + var root = this._parseUIFile("res/cocosui/CCS/LabelBMFont/labelbmfont_1.json"); + this._mainNode.addChild(root); + + var back_label =ccui.helper.seekWidgetByName(root, "back"); + back_label.addTouchEventListener(this.backEvent,this); + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/GUITest/UITextFieldTest/UITextFieldTest.js b/tests/js-tests/src/CocoStudioTest/GUITest/UITextFieldTest/UITextFieldTest.js new file mode 100644 index 0000000000..e8fa7a86a1 --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/GUITest/UITextFieldTest/UITextFieldTest.js @@ -0,0 +1,63 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 UITextFieldEditorTest = UIBaseLayer.extend({ + ctor: function () { + this._super(); + var root = this._parseUIFile("res/cocosui/CCS/TextField/textfield_1.json"); + this._mainNode.addChild(root); + + var back_label =ccui.helper.seekWidgetByName(root, "back"); + back_label.addTouchEventListener(this.backEvent,this); + + var textField_normal = ccui.helper.seekWidgetByName(root, "TextField_1109"); + textField_normal.addEventListener(this.textFieldEvent,this); + + var textField_max_character = ccui.helper.seekWidgetByName(root, "TextField_1110"); + textField_max_character.addEventListener(this.textFieldEvent,this); + + var textField_password = ccui.helper.seekWidgetByName(root, "TextField_1107"); + textField_password.addEventListener(this.textFieldEvent,this); + }, + textFieldEvent: function (sender, type) { + switch (type) { + case ccui.TextField. EVENT_ATTACH_WITH_IME: + this._topDisplayText.setString("attach with IME"); + break; + case ccui.TextField. EVENT_DETACH_WITH_IME: + this._topDisplayText.setString("detach with IME"); + break; + case ccui.TextField. EVENT_INSERT_TEXT: + this._topDisplayText.setString("insert words"); + break; + case ccui.TextField. EVENT_DELETE_BACKWARD: + this._topDisplayText.setString("delete word"); + break; + default: + break; + } + } +}); diff --git a/tests/js-tests/src/CocoStudioTest/GUITest/UITextTest/UITextTest.js b/tests/js-tests/src/CocoStudioTest/GUITest/UITextTest/UITextTest.js new file mode 100644 index 0000000000..ecadf762f1 --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/GUITest/UITextTest/UITextTest.js @@ -0,0 +1,37 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 UITextEditorTest = UIBaseLayer.extend({ + ctor: function () { + this._super(); + var root = this._parseUIFile("res/cocosui/CCS/Label/label_1.json"); + this._mainNode.addChild(root); + + var back_label =ccui.helper.seekWidgetByName(root, "back"); + back_label.addTouchEventListener(this.backEvent,this); + } +}); diff --git a/tests/js-tests/src/CocoStudioTest/ParserTest/ParserTest.js b/tests/js-tests/src/CocoStudioTest/ParserTest/ParserTest.js new file mode 100644 index 0000000000..5fbd215ebc --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/ParserTest/ParserTest.js @@ -0,0 +1,151 @@ +/**************************************************************************** + 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 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 g_parsersTests = [ + { + title: "cocostudio 1.3", + test: function(){ + new CocostudioParserJsonScene("res/cocosui/CCS/ccs1_3/CCSV1_3_1.ExportJson").runThisTest(); + } + },{ + title: "cocostudio 1.4", + test: function(){ + new CocostudioParserJsonScene("res/cocosui/CCS/ccs1_4/CCS1_4_1.ExportJson").runThisTest(); + } + },{ + title: "cocostudio 1.5", + test: function(){ + new CocostudioParserJsonScene("res/cocosui/CCS/ccs1_5/CCS1_5_1.ExportJson").runThisTest(); + } + },{ + title: "cocostudio 2.1", + test: function(){ + new CocostudioParserJsonScene("res/cocosui/CCS/2.1/MainScene.json").runThisTest(); + } + } +]; + +var runParserTest = function () { + var pScene = new CocostudioParserJsonScene(); + if (pScene) { + pScene.runThisTest(); + } +}; + +var CocostudioParserJsonLayer = cc.Layer.extend({ + + _jsonFile: null, + + ctor: function(jsonFile){ + this._super(); + this._jsonFile = jsonFile; + }, + + onEnter: function(){ + this._super(); + cc.Layer.prototype.onEnter.call(this); + + var layout; + if(cocoStudioOldApiFlag == 0){ + cc.log("ccs.load : %s", this._jsonFile); + var json = ccs.load(this._jsonFile); + layout = json.node; + }else{ + //ccs.uiReader.widgetFromJsonFile only supports 1.x file + cc.log("ccs.uiReader.widgetFromJsonFile : %s", this._jsonFile); + var guiReader = ccs.uiReader; + layout = guiReader.widgetFromJsonFile(this._jsonFile); + } + if(layout){ + if(layout.getScale() == 1) + layout.setScale(0.7); + + this.addChild(layout); + } + } +}); + +var CocostudioParserJsonScene = cc.Scene.extend({ + + _jsonFile: null, + + ctor: function(jsonFile){ + this._super(); + if(jsonFile){ + this._jsonFile = jsonFile; + } + }, + + onEnter: function(){ + cc.Scene.prototype.onEnter.call(this); + + var label = new cc.LabelTTF("Back", "fonts/arial.ttf", 20); + //#endif + var pMenuItem = new cc.MenuItemLabel(label, this.BackCallback, this); + + var pMenu = new cc.Menu(pMenuItem); + + pMenu.setPosition( cc.p(0, 0) ); + pMenuItem.setPosition( cc.pAdd(cc.visibleRect.bottomRight,cc.p(-50,25)) ); + + this.addChild(pMenu, 1); + + }, + runThisTest: function(){ + if(this._jsonFile){ + var pLayer = new CocostudioParserJsonLayer(this._jsonFile); + this.addChild(pLayer); + }else{ + var winSize = cc.director.getWinSize(); + + var pMenu = new cc.Menu(); + pMenu.x = 0; + pMenu.y = 0; + cc.MenuItemFont.setFontName("fonts/arial.ttf"); + cc.MenuItemFont.setFontSize(24); + + for (var i = 0; i < g_parsersTests.length; ++i) { + var selItem = g_parsersTests[i]; + var pItem = new cc.MenuItemFont(selItem.title, + selItem.test, this); + pItem.x = winSize.width / 2; + pItem.y = winSize.height - (i + 1) * LINE_SPACE; + pMenu.addChild(pItem, ITEM_TAG_BASIC + i); + } + this.addChild(pMenu); + } + + cc.director.runScene(this); + }, + BackCallback: function(){ + cc.audioEngine.stopMusic(); + cc.audioEngine.stopAllEffects(); + if(this._jsonFile){ + new CocostudioParserJsonScene().runThisTest(); + }else{ + new CocoStudioTestScene().runThisTest(); + } + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/SceneTest/SceneEditorTest.js b/tests/js-tests/src/CocoStudioTest/SceneTest/SceneEditorTest.js new file mode 100644 index 0000000000..7a4238df2b --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/SceneTest/SceneEditorTest.js @@ -0,0 +1,547 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 sceneTestIdx = -1; + +var SceneEditorScene = TestScene.extend({ + onEnter: function () { + this._super(); + }, + runThisTest: function () { + sceneTestIdx = -1; + this.addChild(nextSceneEditorTest()); + director.runScene(this); + }, + onMainMenuCallback: function () { + var scene = new CocoStudioTestScene(); + scene.runThisTest(); + }, + onExit: function () { + this._super(); + } +}); +var sceneEditorArr = [ + function () { + return new LoadSceneEdtiorFileTest(); + }, + function () { + return new SpriteComponentTest(); + }, + function () { + return new ArmatureComponentTest(); + }, + function () { + return new UIComponentTest(); + }, + function () { + return new TmxMapComponentTest(); + }, + function () { + return new ParticleComponentTest(); + }, + function () { + return new EffectComponentTest(); + }, + function () { + return new BackgroundComponentTest(); + }, + function () { + return new AttributeComponentTest(); + }, + function () { + return new TriggerTest(); + } +]; + +var nextSceneEditorTest = function () { + sceneTestIdx++; + sceneTestIdx = sceneTestIdx % sceneEditorArr.length; + return sceneEditorArr[sceneTestIdx](); +}; + +var backSceneEditorTest = function () { + sceneTestIdx--; + if (sceneTestIdx < 0) + sceneTestIdx += sceneEditorArr.length; + + return sceneEditorArr[sceneTestIdx](); +}; + +var restartSceneEditorTest = function () { + return sceneEditorArr[sceneTestIdx](); +}; +var SceneEditorTestLayer = BaseTestLayer.extend({ + ctor: function () { + if (arguments.length === 0) { + this._super(cc.color(0, 0, 0, 255), cc.color(98, 99, 117, 255)); + } else { + this._super.apply(this, arguments); + } + }, + + onRestartCallback: function (sender) { + var s = new SceneEditorScene(); + s.addChild(restartSceneEditorTest()); + director.runScene(s); + }, + + onNextCallback: function (sender) { + var s = new SceneEditorScene(); + s.addChild(nextSceneEditorTest()); + director.runScene(s); + }, + + onBackCallback: function (sender) { + var s = new SceneEditorScene(); + s.addChild(backSceneEditorTest()); + director.runScene(s); + }, + onExit: function () { + ccs.armatureDataManager.clear(); + ccs.sceneReader.clear(); + ccs.actionManager.clear(); + ccs.uiReader.clear(); + this._super(); + }, + initSize:function(node){ + var winSize = cc.director.getWinSize(); + var scale = winSize.height / 320; + node.scale = scale; + node.x = (winSize.width - 480 * scale) / 2; + node.y = (winSize.height - 320 * scale) / 2; + } +}); + +var runSceneEditorTest = function () { + var pScene = new SceneEditorScene(); + if (pScene) { + pScene.runThisTest(); + } +}; + +//------------------------------------------------------------------ +// +// LoadSceneEdtiorFileTest +// +//------------------------------------------------------------------ +var LoadSceneEdtiorFileTest = SceneEditorTestLayer.extend({ + onEnter: function () { + this._super(); + var node, + file = "res/scenetest/LoadSceneEdtiorFileTest/FishJoy2.json"; + if(cocoStudioOldApiFlag == 0){ + cc.log("ccs.load : %s", file); + var json = ccs.load(file); + node = json.node; + }else{ + //ccs.sceneReader only supports 1.x file + cc.log("ccs.sceneReader.createNodeWithSceneFile : %s", file); + node = ccs.sceneReader.createNodeWithSceneFile(file); + } + this.addChild(node); + ccs.actionManager.playActionByName("startMenu_1.json", "Animation1"); + this.initSize(node); + }, + onExit: function() { + ccs.actionManager.releaseActions(); + this._super(); + }, + title: function () { + return "loadSceneEdtiorFile Test"; + } +}); + +//------------------------------------------------------------------ +// +// SpriteComponentTest +// +//------------------------------------------------------------------ +var SpriteComponentTest = SceneEditorTestLayer.extend({ + onEnter: function () { + this._super(); + var node, + file = "res/scenetest/SpriteComponentTest/SpriteComponentTest.json"; + if(cocoStudioOldApiFlag == 0){ + cc.log("ccs.load : %s", file); + var json = ccs.load(file); + node = json.node; + }else{ + //ccs.sceneReader only supports 1.x file + cc.log("ccs.sceneReader.createNodeWithSceneFile : %s", file); + node = ccs.sceneReader.createNodeWithSceneFile(file); + } + this.addChild(node); + + var action1 = cc.blink(2, 10); + var action2 = cc.blink(2, 5); + var sister1 = node.getChildByTag(10003).getComponent("CCSprite").getNode(); + sister1.runAction(action1); + + var sister2 = node.getChildByTag(10004).getComponent("CCSprite").getNode(); + sister2.runAction(action2); + + this.initSize(node); + }, + title: function () { + return "Sprite Component Test"; + } +}); + +//------------------------------------------------------------------ +// +// ArmatureComponentTest +// +//------------------------------------------------------------------ +var ArmatureComponentTest = SceneEditorTestLayer.extend({ + onEnter: function () { + this._super(); + var node, + file = "res/scenetest/ArmatureComponentTest/ArmatureComponentTest.json"; + if(cocoStudioOldApiFlag == 0){ + cc.log("ccs.load : %s", file); + var json = ccs.load(file); + node = json.node;ccs.load(file); + }else{ + //ccs.sceneReader only supports 1.x file + cc.log("ccs.sceneReader.createNodeWithSceneFile : %s", file); + node = ccs.sceneReader.createNodeWithSceneFile(file); + } + this.addChild(node); + + var blowFish = node.getChildByTag(10007).getComponent("CCArmature").getNode(); + blowFish.runAction(cc.moveBy(10, cc.p(-1000, 0))); + + var butterFlyFish = node.getChildByTag(10008).getComponent("CCArmature").getNode(); + butterFlyFish.runAction(cc.moveBy(10, cc.p(-1000, 0))); + + this.initSize(node); + }, + title: function () { + return "Armature Component Test"; + } +}); + +//------------------------------------------------------------------ +// +// UIComponentTest +// +//------------------------------------------------------------------ +var UIComponentTest = SceneEditorTestLayer.extend({ + _node: null, + onEnter: function () { + this._super(); + var node, + file = "res/scenetest/UIComponentTest/UIComponentTest.json"; + if(cocoStudioOldApiFlag == 0){ + cc.log("ccs.load : %s", file); + var json = ccs.load(file); + node = json.node; + }else{ + //ccs.sceneReader only supports 1.x file + cc.log("ccs.sceneReader.createNodeWithSceneFile : %s", file); + node = ccs.sceneReader.createNodeWithSceneFile(file); + } + this._node = node; + this.addChild(this._node); + var widget = this._node.getChildByTag(10025).getComponent("GUIComponent").getNode(); + var button = widget.getChildByName("Button_156"); + button.addTouchEventListener(this.touchEvent, this); + + this.initSize(this._node); + }, + touchEvent: function (sender, type) { + switch (type) { + case ccui.Widget.TOUCH_BEGAN: + var blowFish = this._node.getChildByTag(10010).getComponent("CCArmature").getNode(); + blowFish.runAction(cc.moveBy(10, cc.p(-1000, 0))); + + var butterFlyFish = this._node.getChildByTag(10011).getComponent("CCArmature").getNode(); + butterFlyFish.runAction(cc.moveBy(10, cc.p(-1000.0, 0))); + break; + default: + break; + } + }, + title: function () { + return "UI Component Test"; + } +}); + +//------------------------------------------------------------------ +// +// TmxMapComponentTest +// +//------------------------------------------------------------------ +var TmxMapComponentTest = SceneEditorTestLayer.extend({ + onEnter: function () { + this._super(); + var node, + file = "res/scenetest/TmxMapComponentTest/TmxMapComponentTest.json"; + if(cocoStudioOldApiFlag == 0){ + cc.log("ccs.load : %s", file); + var json = ccs.load(file); + node = json.node; + }else{ + //ccs.sceneReader only supports 1.x file + cc.log("ccs.sceneReader.createNodeWithSceneFile : %s", file); + node = ccs.sceneReader.createNodeWithSceneFile(file); + } + this.addChild(node); + var tmxMap = node.getChildByTag(10015).getComponent("CCTMXTiledMap").getNode(); + var actionTo = cc.skewTo(2, 0, 2); + var rotateTo = cc.rotateTo(2, 61); + var actionScaleTo = cc.scaleTo(2, -0.44, 0.47); + + var actionScaleToBack = cc.scaleTo(2, 1, 1); + var rotateToBack = cc.rotateTo(2, 0); + var actionToBack = cc.skewTo(2, 0, 0); + + tmxMap.runAction(cc.sequence(actionTo, actionToBack)); + tmxMap.runAction(cc.sequence(rotateTo, rotateToBack)); + tmxMap.runAction(cc.sequence(actionScaleTo, actionScaleToBack)); + + this.initSize(node); + }, + title: function () { + return "TmxMap Component Test"; + } +}); + + +//------------------------------------------------------------------ +// +// ParticleComponentTest +// +//------------------------------------------------------------------ +var ParticleComponentTest = SceneEditorTestLayer.extend({ + onEnter: function () { + this._super(); + var node, + file = "res/scenetest/ParticleComponentTest/ParticleComponentTest.json"; + if(cocoStudioOldApiFlag == 0){ + cc.log("ccs.load : %s", file); + var json = ccs.load(file); + node = json.node; + }else{ + //ccs.sceneReader only supports 1.x file + cc.log("ccs.sceneReader.createNodeWithSceneFile : %s", file); + node = ccs.sceneReader.createNodeWithSceneFile(file); + } + this.addChild(node); + + var particle = node.getChildByTag(10020).getComponent("CCParticleSystemQuad").getNode(); + var jump = cc.jumpBy(5, cc.p(-500, 0), 50, 4); + var action = cc.sequence(jump, jump.reverse()); + particle.runAction(action); + + this.initSize(node); + }, + title: function () { + return "Particle Component Test"; + } +}); + +//------------------------------------------------------------------ +// +// EffectComponentTest +// +//------------------------------------------------------------------ +var EffectComponentTest = SceneEditorTestLayer.extend({ + _node: null, + onEnter: function () { + this._super(); + var node, + file = "res/scenetest/EffectComponentTest/EffectComponentTest.json"; + if(cocoStudioOldApiFlag == 0){ + cc.log("ccs.load : %s", file); + var json = ccs.load(file); + node = json.node; + }else{ + //ccs.sceneReader only supports 1.x file + cc.log("ccs.sceneReader.createNodeWithSceneFile : %s", file); + node = ccs.sceneReader.createNodeWithSceneFile(file); + } + this._node = node; + this.addChild(this._node); + + var armature = this._node.getChildByTag(10015).getComponent("CCArmature").getNode(); + armature.getAnimation().setMovementEventCallFunc(this.animationEvent, this); + + this.initSize(this._node); + }, + title: function () { + return "Effect Component Test"; + }, + animationEvent: function (armature, movementType, movementID) { + if (movementType == ccs.MovementEventType.loopComplete) { + if (movementID == "Fire") { + var audio = this._node.getChildByTag(10015).getComponent("CCComAudio"); + audio.playEffect(); + } + } + } +}); + +//------------------------------------------------------------------ +// +// BackgroundComponentTest +// +//------------------------------------------------------------------ +var BackgroundComponentTest = SceneEditorTestLayer.extend({ + onEnter: function () { + this._super(); + var node, + file = "res/scenetest/BackgroundComponentTest/BackgroundComponentTest.json"; + if(cocoStudioOldApiFlag == 0){ + cc.log("ccs.load : %s", file); + var json = ccs.load(file); + node = json.node; + }else{ + //ccs.sceneReader only supports 1.x file + cc.log("ccs.sceneReader.createNodeWithSceneFile : %s", file); + node = ccs.sceneReader.createNodeWithSceneFile(file); + } + this.addChild(node); + ccs.actionManager.playActionByName("startMenu_1.json", "Animation1"); + + var audio = node.getComponent("CCBackgroundAudio"); + audio.playBackgroundMusic(); + + this.initSize(node); + }, + onExit: function() { + ccs.actionManager.releaseActions(); + this._super(); + }, + title: function () { + return "Background Component Test"; + } +}); + +//------------------------------------------------------------------ +// +// AttributeComponentTest +// +//------------------------------------------------------------------ +var AttributeComponentTest = SceneEditorTestLayer.extend({ + onEnter: function () { + this._super(); + var node, + file = "res/scenetest/AttributeComponentTest/AttributeComponentTest.json"; + if(cocoStudioOldApiFlag == 0){ + cc.log("ccs.load : %s", file); + var json = ccs.load(file); + node = json.node; + }else{ + //ccs.sceneReader only supports 1.x file + cc.log("ccs.sceneReader.createNodeWithSceneFile : %s", file); + node = ccs.sceneReader.createNodeWithSceneFile(file); + } + this.addChild(node); + + var comAttribute = node.getChildByTag(10015).getComponent("CCComAttribute"); + cc.log("name:" + comAttribute.getString("name")); + cc.log("maxHP:" + comAttribute.getFloat("maxHP")); + cc.log("maxMP:" + comAttribute.getFloat("maxMP")); + + this.initSize(node); + }, + title: function () { + return "Attribute Component Test"; + }, + subtitle:function(){ + return "See console"; + } +}); + +//------------------------------------------------------------------ +// +// TriggerTest +// +//------------------------------------------------------------------ +var TriggerTest = SceneEditorTestLayer.extend({ + _blowFishNode: null, + _flyFishNode: null, + onEnter: function () { + this._super(); + var node, + file = "res/scenetest/TriggerTest/TriggerTest.json"; + if(cocoStudioOldApiFlag == 0){ + cc.log("ccs.load : %s", file); + var json = ccs.load(file); + node = json.node; + }else{ + //ccs.sceneReader only supports 1.x file + cc.log("ccs.sceneReader.createNodeWithSceneFile : %s", file); + node = ccs.sceneReader.createNodeWithSceneFile(file); + } + this.addChild(node); + ccs.actionManager.playActionByName("startMenu_1.json", "Animation1"); + + this.schedule(this.gameLogic); + ccs.sendEvent(TRIGGER_EVENT_ENTERSCENE); + + var listener1 = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches: true, + onTouchBegan: this.onTouchBegan.bind(this), + onTouchMoved: this.onTouchMoved.bind(this), + onTouchEnded: this.onTouchEnded.bind(this) + }); + cc.eventManager.addListener(listener1, this); + this.initSize(node); + }, + onExit: function () { + ccs.actionManager.releaseActions(); + ccs.sendEvent(TRIGGER_EVENT_LEAVESCENE); + this.unschedule(this.gameLogic, this); + this._super(); + }, + + onTouchBegan: function (touch, event) { + ccs.sendEvent(TRIGGER_EVENT_TOUCHBEGAN); + return true; + }, + + onTouchMoved: function (touch, event) { + ccs.sendEvent(TRIGGER_EVENT_TOUCHMOVED); + }, + + onTouchEnded: function (touch, event) { + ccs.sendEvent(TRIGGER_EVENT_TOUCHENDED); + }, + + onTouchCancelled: function (touch, event) { + ccs.sendEvent(TRIGGER_EVENT_TOUCHCANCELLED); + }, + + gameLogic: function () { + ccs.sendEvent(TRIGGER_EVENT_UPDATESCENE); + }, + title: function () { + return "Trigger Test"; + } +}); diff --git a/tests/js-tests/src/CocoStudioTest/SceneTest/TriggerCode/Acts.js b/tests/js-tests/src/CocoStudioTest/SceneTest/TriggerCode/Acts.js new file mode 100644 index 0000000000..c25e015603 --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/SceneTest/TriggerCode/Acts.js @@ -0,0 +1,642 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 PlayMusic = ccs.BaseTriggerAction.extend({ + _tag: -1, + _comName: "", + _type: -1, + ctor: function () { + this._tag = -1; + this._comName = ""; + this._type = -1; + }, + + init: function () { + return true; + }, + + done: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + if (!node) + return; + var audio = node.getComponent(this._comName); + if (!audio) + return; + if (this._type == 0) { + audio.playBackgroundMusic(); + } + else if (this._type == 1) { + audio.playEffect(); + } + }, + + serialize: function (jsonVal) { + var dataitems = jsonVal["dataitems"] || []; + for (var i = 0; i < dataitems.length; i++) { + var subDict = dataitems[i]; + var key = subDict["key"]; + if (key == "Tag") { + this._tag = subDict["value"]; + continue; + } + if (key == "componentName") { + this._comName = subDict["value"]; + continue; + } + if (key == "type") { + this._type = subDict["value"]; + } + } + }, + + removeAll: function () { + } +}); + +var TMoveTo = ccs.BaseTriggerAction.extend({ + _tag: -1, + _duration: 0, + _pos: cc.p(0, 0), + ctor: function () { + this._tag = -1; + this._duration = 0; + this._pos = cc.p(0, 0); + }, + + init: function () { + return true; + }, + + done: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + if (!node) + return; + var actionTo = cc.moveTo(this._duration, cc.p(this._pos.x, this._pos.y)); + node.runAction(actionTo); + }, + + serialize: function (jsonVal) { + var dataitems = jsonVal["dataitems"] || []; + for (var i = 0; i < dataitems.length; i++) { + var subDict = dataitems[i]; + + var key = subDict["key"]; + if (key == "Tag") { + this._tag = subDict["value"]; + continue; + } + if (key == "Duration") { + this._duration = subDict["value"]; + continue; + } + if (key == "x") { + this._pos.x = subDict["value"]; + continue; + } + if (key == "y") { + this._pos.y = subDict["value"]; + } + } + }, + + removeAll: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + node.actionManager.removeAllActions(); + } +}); + +var TMoveBy = ccs.BaseTriggerAction.extend({ + _tag: -1, + _duration: 0, + _pos: cc.p(0, 0), + _reverse: false, + ctor: function () { + this._tag = -1; + this._duration = 0; + this._pos = cc.p(0, 0); + this._reverse = false; + }, + + init: function () { + return true; + }, + + done: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + if (!node) + return; + var moveBy = cc.moveBy(this._duration, cc.p(this._pos.x, this._pos.y)); + if (this._reverse) { + var actionByBack = moveBy.reverse(); + node.runAction(cc.sequence(moveBy, actionByBack)); + } else { + node.runAction(moveBy); + } + }, + + serialize: function (jsonVal) { + var dataitems = jsonVal["dataitems"] || []; + for (var i = 0; i < dataitems.length; i++) { + var subDict = dataitems[i]; + + var key = subDict["key"]; + if (key == "Tag") { + this._tag = subDict["value"]; + continue; + } + if (key == "Duration") { + this._duration = subDict["value"]; + continue; + } + if (key == "x") { + this._pos.x = subDict["value"]; + continue; + } + if (key == "y") { + this._pos.y = subDict["value"]; + continue; + } + if (key == "IsReverse") { + this._reverse = subDict["value"] || false; + } + } + }, + + removeAll: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + node.actionManager.removeAllActions(); + } +}); + +var TRotateTo = ccs.BaseTriggerAction.extend({ + _tag: -1, + _duration: 0, + _deltaAngle: 0, + ctor: function () { + this._tag = -1; + this._duration = 0; + this._deltaAngle = 0; + }, + + init: function () { + return true; + }, + + done: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + if (!node) + return; + var actionTo = cc.rotateTo(this._duration, this._deltaAngle); + node.runAction(actionTo); + }, + + serialize: function (jsonVal) { + var dataitems = jsonVal["dataitems"] || []; + for (var i = 0; i < dataitems.length; i++) { + var subDict = dataitems[i]; + + var key = subDict["key"]; + if (key == "Tag") { + this._tag = subDict["value"]; + continue; + } + if (key == "Duration") { + this._duration = subDict["value"]; + continue; + } + if (key == "DeltaAngle") { + this._deltaAngle = subDict["value"]; + } + } + }, + + removeAll: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + node.actionManager.removeAllActions(); + } +}); + +var TRotateBy = ccs.BaseTriggerAction.extend({ + _tag: -1, + _duration: 0, + _deltaAngle: 0, + _reverse: false, + ctor:function(){ + this._tag = -1; + this._duration = 0; + this._deltaAngle = 0; + this._reverse = false; + }, + + init: function () { + return true; + }, + + done: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + if (!node) + return; + var actionBy = cc.rotateBy(this._duration, this._deltaAngle); + if (this._reverse == true) { + var actionByBack = actionBy.reverse(); + node.runAction(cc.sequence(actionBy, actionByBack)); + } + else { + node.runAction(actionBy); + } + }, + + serialize: function (jsonVal) { + var dataitems = jsonVal["dataitems"] || []; + for (var i = 0; i < dataitems.length; i++) { + var subDict = dataitems[i]; + + var key = subDict["key"]; + if (key == "Tag") { + this._tag = subDict["value"]; + continue; + } + if (key == "Duration") { + this._duration = subDict["value"]; + continue; + } + if (key == "DeltaAngle") { + this._deltaAngle = subDict["value"]; + continue; + } + if (key == "IsReverse") { + this._reverse = subDict["value"]; + } + } + }, + + removeAll: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + node.actionManager.removeAllActions(); + } +}); + +var TScaleTo = ccs.BaseTriggerAction.extend({ + _tag: -1, + _duration: 0, + _scaleX: 0, + _scaleY: 0, + ctor: function () { + this._tag = -1; + this._duration = 0; + this._scaleX = 0; + this._scaleY = 0; + }, + + init: function () { + return true; + }, + + done: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + if (!node) + return; + var actionTo = cc.scaleTo(this._duration, this._scaleX, this._scaleY); + node.runAction(actionTo); + }, + + serialize: function (jsonVal) { + var dataitems = jsonVal["dataitems"] || []; + for (var i = 0; i < dataitems.length; i++) { + var subDict = dataitems[i]; + + var key = subDict["key"]; + if (key == "Tag") { + this._tag = subDict["value"]; + continue; + } + if (key == "Duration") { + this._duration = subDict["value"]; + continue; + } + if (key == "ScaleX") { + this._scaleX = subDict["value"]; + continue; + } + if (key == "ScaleY") { + this._scaleY = subDict["value"]; + } + } + }, + + removeAll: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + node.actionManager.removeAllActions(); + } +}); + +var TScaleBy = ccs.BaseTriggerAction.extend({ + _tag: -1, + _duration: 0, + _scaleX: 0, + _scaleY: 0, + _reverse: false, + ctor: function () { + this._tag = -1; + this._duration = 0; + this._scaleX = 0; + this._scaleY = 0; + this._reverse = false; + }, + + init: function () { + return true; + }, + + done: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + if (!node) + return; + var actionBy = cc.scaleBy(this._duration, this._scaleX, this._scaleY); + if (this._reverse == true) { + var actionByBack = actionBy.reverse(); + node.runAction(cc.sequence(actionBy, actionByBack)); + } + else { + node.runAction(actionBy); + } + }, + + serialize: function (jsonVal) { + var dataitems = jsonVal["dataitems"] || []; + for (var i = 0; i < dataitems.length; i++) { + var subDict = dataitems[i]; + + var key = subDict["key"]; + if (key == "Tag") { + this._tag = subDict["value"]; + continue; + } + if (key == "Duration") { + this._duration = subDict["value"]; + continue; + } + if (key == "ScaleX") { + this._scaleX = subDict["value"]; + continue; + } + if (key == "ScaleY") { + this._scaleY = subDict["value"]; + } + } + }, + + removeAll: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + node.actionManager.removeAllActions(); + } +}); + +var TSkewTo = ccs.BaseTriggerAction.extend({ + _tag: -1, + _duration: 0, + _skewX: 0, + _skewY: 0, + ctor: function () { + this._tag = -1; + this._duration = 0; + this._skewX = 0; + this._skewY = 0; + }, + + init: function () { + return true; + }, + + done: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + if (!node) + return; + var actionTo = cc.skewTo(this._duration, this._skewX, this._skewY); + node.runAction(actionTo); + }, + + serialize: function (jsonVal) { + var dataitems = jsonVal["dataitems"] || []; + for (var i = 0; i < dataitems.length; i++) { + var subDict = dataitems[i]; + + var key = subDict["key"]; + if (key == "Tag") { + this._tag = subDict["value"]; + continue; + } + if (key == "Duration") { + this._duration = subDict["value"]; + continue; + } + if (key == "SkewX") { + this._skewX = subDict["value"]; + continue; + } + if (key == "SkewY") { + this._skewY = subDict["value"]; + } + } + }, + + removeAll: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + node.actionManager.removeAllActions(); + } +}); + +var TSkewBy = ccs.BaseTriggerAction.extend({ + _tag: -1, + _duration: 0, + _skewX: 0, + _skewY: 0, + _reverse: false, + ctor: function () { + this._tag = -1; + this._duration = 0; + this._skewX = 0; + this._skewY = 0; + this._reverse = false; + }, + + init: function () { + return true; + }, + + done: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + if (!node) + return; + var actionBy = cc.skewBy(this._duration, this._skewX, this._skewY); + if (this._reverse == true) { + var actionByBack = actionBy.reverse(); + node.runAction(cc.sequence(actionBy, actionByBack)); + } + else { + node.runAction(actionBy); + } + }, + + serialize: function (jsonVal) { + var dataitems = jsonVal["dataitems"] || []; + for (var i = 0; i < dataitems.length; i++) { + var subDict = dataitems[i]; + + var key = subDict["key"]; + if (key == "Tag") { + this._tag = subDict["value"]; + continue; + } + if (key == "Duration") { + this._duration = subDict["value"]; + continue; + } + if (key == "SkewX") { + this._skewX = subDict["value"]; + continue; + } + if (key == "SkewY") { + this._skewY = subDict["value"]; + } + } + }, + + removeAll: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + node.actionManager.removeAllActions(); + } +}); + +var TriggerState = ccs.BaseTriggerAction.extend({ + _id: -1, + _state: 0, + ctor: function () { + this._id = -1; + this._state = 0; + }, + + init: function () { + return true; + }, + + done: function () { + var obj = ccs.triggerManager.getTriggerObj(this._id); + if (obj) { + if (this._state == 0) { + obj.setEnable(false); + } + else if (this._state == 1) { + obj.setEnable(true); + } + else if (this._state == 2) { + ccs.triggerManager.removeTriggerObj(this._id); + } + + } + }, + + serialize: function (jsonVal) { + var dataitems = jsonVal["dataitems"] || []; + for (var i = 0; i < dataitems.length; i++) { + var subDict = dataitems[i]; + + var key = subDict["key"]; + if (key == "ID") { + this._id = subDict["value"]; + continue; + } + if (key == "State") { + this._state = subDict["value"]; + } + } + }, + + removeAll: function () { + } +}); + +var ArmaturePlayAction = ccs.BaseTriggerAction.extend({ + _tag: -1, + _comName: 0, + _aniName: "", + ctor: function () { + this._tag = -1; + this._comName = 0; + this._aniName = ""; + }, + + init: function () { + return true; + }, + + done: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + if (!node) + return; + var render = node.getComponent(this._comName); + if (!render) + return; + var armature = render.getNode(); + if (!armature) + return; + armature.getAnimation().play(this._aniName); + }, + + serialize: function (jsonVal) { + var dataitems = jsonVal["dataitems"] || []; + for (var i = 0; i < dataitems.length; i++) { + var subDict = dataitems[i]; + + var key = subDict["key"]; + if (key == "ID") { + this._id = subDict["value"]; + continue; + } + if (key == "componentName") { + this._comName = subDict["value"]; + continue; + } + if (key == "AnimationName") { + this._aniName = subDict["value"]; + } + } + }, + + removeAll: function () { + } +}); + +ccs.registerTriggerClass("PlayMusic", PlayMusic); +ccs.registerTriggerClass("TMoveTo", TMoveTo); +ccs.registerTriggerClass("TMoveBy", TMoveBy); +ccs.registerTriggerClass("TRotateTo", TRotateTo); +ccs.registerTriggerClass("TRotateBy", TRotateBy); +ccs.registerTriggerClass("TScaleTo", TScaleTo); +ccs.registerTriggerClass("TScaleBy", TScaleBy); +ccs.registerTriggerClass("TSkewTo", TSkewTo); +ccs.registerTriggerClass("TSkewBy", TSkewBy); +ccs.registerTriggerClass("TriggerState", TriggerState); +ccs.registerTriggerClass("ArmaturePlayAction", ArmaturePlayAction); \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/SceneTest/TriggerCode/Cons.js b/tests/js-tests/src/CocoStudioTest/SceneTest/TriggerCode/Cons.js new file mode 100644 index 0000000000..3cc6a1cb6a --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/SceneTest/TriggerCode/Cons.js @@ -0,0 +1,245 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 TimeElapsed = ccs.BaseTriggerCondition.extend({ + _totalTime: 0, + _tmpTime: 0, + _scheduler: null, + _success: false, + ctor: function () { + this._totalTime = 0; + this._tmpTime = 0; + this._scheduler = null; + this._success = false; + this._scheduler = cc.director.getScheduler(); + }, + + init: function () { + this._scheduler.scheduleCallbackForTarget(this, this.update); + return true; + }, + + detect: function () { + return this._success; + }, + + serialize: function (jsonVal) { + var dataitems = jsonVal["dataitems"] || []; + for (var i = 0; i < dataitems.length; i++) { + var subDict = dataitems[i]; + var key = subDict["key"]; + if (key == "TotalTime") { + this._totalTime = subDict["value"]; + } + } + }, + + removeAll: function () { + this._scheduler.unscheduleUpdateForTarget(this); + }, + + update: function (dt) { + this._tmpTime += dt; + if (this._tmpTime > this._totalTime) { + this._tmpTime = 0.0; + this._success = true; + } + } +}); +var ArmatureActionState = ccs.BaseTriggerCondition.extend({ + _tag: -1, + _state: -1, + _success: false, + _aniName: "", + _comName: "", + _armature: null, + ctor: function () { + this._tag = -1; + this._state = -1; + this._success = false; + this._aniName = ""; + this._comName = ""; + this._armature = null; + }, + + init: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + if (!node) return false; + var render = node.getComponent(this._comName); + if (!render) return false; + var armature = render.getNode(); + if (!armature) return false; + this._armature = armature; + ccs.triggerManager.addArmatureMovementCallBack(this._armature, this.animationEvent, this); + return true; + }, + + detect: function () { + return this._success; + }, + + serialize: function (jsonVal) { + var dataitems = jsonVal["dataitems"] || []; + for (var i = 0; i < dataitems.length; i++) { + var subDict = dataitems[i]; + var key = subDict["key"]; + if (key == "TotalTime") { + this._totalTime = subDict["value"]; + continue; + } + if (key == "componentName") { + this._comName = subDict["value"]; + continue; + } + if (key == "AnimationName") { + this._aniName = subDict["value"]; + continue; + } + if (key == "ActionType") { + this._state = subDict["value"]; + } + } + }, + + removeAll: function () { + if (this._armature) { + ccs.triggerManager.removeArmatureMovementCallBack(this._armature, this.animationEvent, this); + } + }, + + animationEvent: function (armature, movementType, movementID) { + if (movementType == this._state && movementID == this._aniName) { + this._success = true; + } + } +}); +var NodeInRect = ccs.BaseTriggerCondition.extend({ + _tag: -1, + _origin: null, + _size: null, + ctor: function () { + this._tag = -1; + this._origin = null; + this._size = null; + this._origin = cc.p(0, 0); + this._size = cc.p(0, 0); + }, + + init: function () { + + return true; + }, + + detect: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + if (node && Math.abs(node.x - this._origin.x) <= this._size.width && Math.abs(node.y - this._origin.y) <= this._size.height) { + return true; + } + return false; + }, + serialize: function (jsonVal) { + var dataitems = jsonVal["dataitems"] || []; + for (var i = 0; i < dataitems.length; i++) { + var subDict = dataitems[i]; + var key = subDict["key"]; + if (key == "Tag") { + this._tag = subDict["value"]; + continue; + } + if (key == "originX") { + this._origin.x = subDict["value"]; + continue; + } + if (key == "originY") { + this._origin.y = subDict["value"]; + continue; + } + if (key == "originX") { + this._origin.x = subDict["value"]; + continue; + } + if (key == "originY") { + this._origin.y = subDict["value"]; + continue; + } + if (key == "sizeWidth") { + this._size.width = subDict["value"]; + continue; + } + if (key == "sizeHeight") { + this._size.height = subDict["value"]; + } + } + }, + + removeAll: function () { + + } +}); + +var NodeVisible = ccs.BaseTriggerCondition.extend({ + _tag: -1, + _visible: false, + cotr: function () { + this._tag = -1; + this._visible = false; + }, + + init: function () { + return true; + }, + + detect: function () { + var node = ccs.sceneReader.getNodeByTag(this._tag); + if (node && node.visible == this._visible) { + return true; + } + return false; + }, + serialize: function (jsonVal) { + var dataitems = jsonVal["dataitems"] || []; + for (var i = 0; i < dataitems.length; i++) { + var subDict = dataitems[i]; + var key = subDict["key"]; + if (key == "Tag") { + this._tag = subDict["value"]; + continue; + } + if (key == "Visible") { + this._visible = subDict["value"]; + } + } + }, + + removeAll: function () { + + } +}); + + +ccs.registerTriggerClass("TimeElapsed", TimeElapsed); +ccs.registerTriggerClass("ArmatureActionState", ArmatureActionState); +ccs.registerTriggerClass("NodeInRect", NodeInRect); +ccs.registerTriggerClass("NodeVisible", NodeVisible); \ No newline at end of file diff --git a/tests/js-tests/src/CocoStudioTest/SceneTest/TriggerCode/EventDef.js b/tests/js-tests/src/CocoStudioTest/SceneTest/TriggerCode/EventDef.js new file mode 100644 index 0000000000..f9bc131a73 --- /dev/null +++ b/tests/js-tests/src/CocoStudioTest/SceneTest/TriggerCode/EventDef.js @@ -0,0 +1,33 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 TRIGGER_EVENT_ENTERSCENE = 0; +var TRIGGER_EVENT_LEAVESCENE = 1; +var TRIGGER_EVENT_INITSCENE = 2; +var TRIGGER_EVENT_UPDATESCENE = 3; +var TRIGGER_EVENT_TOUCHBEGAN = 4; +var TRIGGER_EVENT_TOUCHMOVED = 5; +var TRIGGER_EVENT_TOUCHENDED = 6; +var TRIGGER_EVENT_TOUCHCANCELLED = 7; \ No newline at end of file diff --git a/tests/js-tests/src/CocosDenshionTest/CocosDenshionTest.js b/tests/js-tests/src/CocosDenshionTest/CocosDenshionTest.js new file mode 100644 index 0000000000..b076eca8e1 --- /dev/null +++ b/tests/js-tests/src/CocosDenshionTest/CocosDenshionTest.js @@ -0,0 +1,328 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 audioEngine = cc.audioEngine; + +var MUSIC_FILE = cc.sys.os == cc.sys.OS_WP8 || cc.sys.os == cc.sys.OS_WINRT ? "res/Sound/background-music-aac.wav" : "res/Sound/background.mp3"; +var EFFECT_FILE = cc.sys.os == cc.sys.OS_WP8 || cc.sys.os == cc.sys.OS_WINRT ? "res/Sound/pew-pew-lei.wav" : "res/Sound/effect2.mp3"; + +var _DenshionTests = [ + 'Music Test' +]; +var DenshionTests = [ + { + title:"Play Music", + playFunc:function () { + return new playMusic(); + } + }, + { + title:"Stop Music", + playFunc:function () { + return new stopMusic(); + } + }, + { + title:"Pause Music", + playFunc:function () { + return new pauseMusic(); + } + }, + { + title:"Resume Music", + playFunc:function () { + return new resumeMusic(); + } + }, + { + title:"Rewind Music", + playFunc:function () { + return new rewindMusic(); + } + }, + { + title:"is Music Playing", + playFunc:function () { + return new isMusicPlaying(); + } + }, + { + title:"Increase Music Volume", + playFunc:function () { + return new addMusicVolume(); + } + }, + { + title:"Decrease Music Volume", + playFunc:function () { + return new subMusicVolume(); + } + }, + { + title:"Play Sound Effect", + playFunc:function () { + return new playEffect(); + } + }, + { + title:"Repeat Sound Effect", + playFunc:function () { + return new playEffectRepeatly(); + } + }, + { + title:"Stop Sound Effect", + playFunc:function () { + return new stopEffect(); + } + }, + { + title:"Unload Sound Effect", + playFunc:function () { + return new unloadEffect(); + } + }, + { + title:"Increase Sound Effect Volume", + playFunc:function () { + return new addEffectsVolume(); + } + }, + { + title:"Decrease Sound Effect Volume", + playFunc:function () { + return new subEffectsVolume(); + } + }, + { + title:"Pause Sound Effect", + playFunc:function () { + return new pauseEffect(); + } + }, + { + title:"Resume Sound Effect", + playFunc:function () { + return new resumeEffect(); + } + }, + { + title:"Pause All Sound Effects", + playFunc:function () { + return new pauseAllEffects(); + } + }, + { + title:"Resume All Sound Effects", + playFunc:function () { + return new resumeAllEffects(); + } + }, + { + title:"Stop All Sound Effects", + playFunc:function () { + return new stopAllEffects(); + } + } +]; + +var CocosDenshionTest = cc.LayerGradient.extend({ + _itemMenu:null, + _beginPos:cc.p(0, 0), + _testCount:0, + ctor:function () { + this._super(cc.color(0, 0, 0, 255), cc.color(148, 80, 120, 255)); + + this._itemMenu = new cc.Menu(); + var winSize = director.getWinSize(); + for (var i = 0; i < DenshionTests.length; i++) { + var label = new cc.LabelTTF(DenshionTests[i].title, "Arial", 24); + var menuItem = new cc.MenuItemLabel(label, this.onMenuCallback, this); + this._itemMenu.addChild(menuItem, i + 10000); + menuItem.x = winSize.width / 2; + menuItem.y = winSize.height - (i + 1) * LINE_SPACE; + } + this._testCount = i; + this._itemMenu.width = winSize.width; + this._itemMenu.height = (this._testCount + 1) * LINE_SPACE; + this._itemMenu.x = 0; + this._itemMenu.y = 0; + this.addChild(this._itemMenu); + + if( 'touches' in cc.sys.capabilities ) { + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesMoved: function (touches, event) { + event.getCurrentTarget().moveMenu(touches[0].getDelta()); + } + }, this); + } else if ('mouse' in cc.sys.capabilities ) + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseMove: function(event){ + if(event.getButton() == cc.EventMouse.BUTTON_LEFT) + event.getCurrentTarget().moveMenu(event.getDelta()); + } + }, this); + + // set default volume + audioEngine.setEffectsVolume(0.5); + audioEngine.setMusicVolume(0.5); + }, + onExit:function () { + this._super(); + audioEngine.stopMusic(); + audioEngine.stopAllEffects(); + }, + + onMenuCallback:function (sender) { + var idx = sender.zIndex - 10000; + // create the test scene and run it + var scene = DenshionTests[idx].playFunc(); + }, + + moveMenu:function (delta) { + var newY = this._itemMenu.y + delta.y; + + if (newY < 0) + newY = 0; + + if (newY > ((DenshionTests.length + 1) * LINE_SPACE - winSize.height)) + newY = ((DenshionTests.length + 1) * LINE_SPACE - winSize.height); + + this._itemMenu.y = newY; + } +}); + +var CocosDenshionTestScene = TestScene.extend({ + runThisTest:function () { + + audioEngine = cc.audioEngine; + var layer = new CocosDenshionTest(); + this.addChild(layer); + director.runScene(this); + } +}); + +var soundId = null; + +var playMusic = function () { + cc.log("play background music"); + audioEngine.playMusic(MUSIC_FILE, false); +}; + +var stopMusic = function () { + cc.log("stop background music"); + audioEngine.stopMusic(); +}; + +var pauseMusic = function () { + cc.log("pause background music"); + audioEngine.pauseMusic(); +}; + +var resumeMusic = function () { + cc.log("resume background music"); + audioEngine.resumeMusic(); +}; + +var rewindMusic = function () { + cc.log("rewind background music"); + audioEngine.rewindMusic(); +}; + +// is background music playing +var isMusicPlaying = function () { + if (audioEngine.isMusicPlaying()) { + cc.log("background music is playing"); + } + else { + cc.log("background music is not playing"); + } +}; + +var playEffect = function () { + cc.log("play effect"); + soundId = audioEngine.playEffect(EFFECT_FILE); +}; + +var playEffectRepeatly = function () { + cc.log("play effect repeatly"); + soundId = audioEngine.playEffect(EFFECT_FILE, true); +}; + +var stopEffect = function () { + cc.log("stop effect"); + audioEngine.stopEffect(soundId); +}; + +var unloadEffect = function () { + cc.log("unload effect"); + audioEngine.unloadEffect(EFFECT_FILE); +}; + +var addMusicVolume = function () { + cc.log("add bakcground music volume"); + audioEngine.setMusicVolume(audioEngine.getMusicVolume() + 0.1); +}; + +var subMusicVolume = function () { + cc.log("sub backgroud music volume"); + audioEngine.setMusicVolume(audioEngine.getMusicVolume() - 0.1); +}; + +var addEffectsVolume = function () { + cc.log("add effects volume"); + audioEngine.setEffectsVolume(audioEngine.getEffectsVolume() + 0.1); +}; + +var subEffectsVolume = function () { + cc.log("sub effects volume"); + audioEngine.setEffectsVolume(audioEngine.getEffectsVolume() - 0.1); +}; + +var pauseEffect = function () { + cc.log("pause effect"); + audioEngine.pauseEffect(soundId); +}; + +var resumeEffect = function () { + cc.log("resume effect"); + audioEngine.resumeEffect(soundId); +}; + +var pauseAllEffects = function () { + cc.log("pause all effects"); + audioEngine.pauseAllEffects(); +}; +var resumeAllEffects = function () { + cc.log("resume all effects"); + audioEngine.resumeAllEffects(); +}; +var stopAllEffects = function () { + cc.log("stop all effects"); + audioEngine.stopAllEffects(); +}; \ No newline at end of file diff --git a/tests/js-tests/src/CocosNodeTest/CocosNodeTest.js b/tests/js-tests/src/CocosNodeTest/CocosNodeTest.js new file mode 100644 index 0000000000..5cc47249be --- /dev/null +++ b/tests/js-tests/src/CocosNodeTest/CocosNodeTest.js @@ -0,0 +1,1075 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 TAG_SPRITE1 = 1; +var TAG_SPRITE2 = 2; +var TAG_SPRITE3 = 3; +var TAG_SLIDER = 4; + +var nodeTestSceneIdx = -1; +var MAX_LAYER = 9; + +var TestNodeDemo = BaseTestLayer.extend({ + ctor:function () { + this._super(); + }, + title:function () { + return "No title"; + }, + subtitle:function () { + return ""; + }, + onRestartCallback:function (sender) { + var s = new NodeTestScene(); + s.addChild(restartNodeTest()); + director.runScene(s); + }, + onNextCallback:function (sender) { + var s = new NodeTestScene(); + s.addChild(nextNodeTest()); + director.runScene(s); + }, + onBackCallback:function (sender) { + var s = new NodeTestScene(); + s.addChild(previousNodeTest()); + director.runScene(s); + }, + // automation + numberOfPendingTests:function () { + return ( (arrayOfNodeTest.length - 1) - nodeTestSceneIdx ); + }, + + getTestNumber:function () { + return nodeTestSceneIdx; + } +}); + +var CCNodeTest2 = TestNodeDemo.extend({ + onEnter:function () { + //----start0----onEnter + this._super(); + + var sp1 = new cc.Sprite(s_pathSister1); + var sp2 = new cc.Sprite(s_pathSister2); + var sp3 = new cc.Sprite(s_pathSister1); + var sp4 = new cc.Sprite(s_pathSister2); + + sp1.x = winSize.width / 4; + sp1.y = winSize.height / 2; + sp2.x = winSize.width / 4 * 3; + sp2.y = winSize.height / 2; + this.addChild(sp1); + this.addChild(sp2); + + sp3.scale = 0.25; + sp4.scale = 0.25; + + sp1.addChild(sp3); + sp2.addChild(sp4); + + var a1 = cc.rotateBy(2, 360); + var a2 = cc.scaleBy(2, 2); + var delay = cc.delayTime(0.2); + + var action1 = cc.sequence(a1, a2, delay, a2.reverse()).repeatForever(); + var action2 = cc.sequence(a1.clone(), a2.clone(), delay.clone(), a2.reverse()).repeatForever(); + + sp2.anchorX = 0; + sp2.anchorY = 0; + + sp1.runAction(action1); + sp2.runAction(action2); + //----end0---- + }, + title:function () { + return "anchorPoint and children"; + }, + // + // Automation + // + testDuration:4.1, + pixel1:{"0":255, "1":230, "2":204, "3":255}, + pixel2:{"0":204, "1":153, "2":102, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 4 - 54, winSize.height / 2 - 146, 5, 5); + var ret2 = this.readPixels(winSize.width / 4 * 3 + 93, winSize.height / 2 + 113, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1, true, 5) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2, true, 5) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +var SID_DELAY2 = 1; +var SID_DELAY4 = 2; +var CCNodeTest4 = TestNodeDemo.extend({ + ctor:function () { + //----start1----ctor + this._super(); + var sp1 = new cc.Sprite(s_pathSister1); + var sp2 = new cc.Sprite(s_pathSister2); + sp1.x = 150; + sp1.y = winSize.height / 2; + sp2.x = winSize.width - 150; + sp2.y = winSize.height / 2; + + this.addChild(sp1, 0, 2); + this.addChild(sp2, 0, 3); + + this.schedule(this.delay2, 2.0); + this.schedule(this.delay4, 4.0); + + //Automation param + this.autoParam = sp1; + //----end1---- + }, + delay2:function (dt) { + //----start1----delay2 + var node = this.getChildByTag(2); + var action1 = cc.rotateBy(1, 360); + node.runAction(action1); + //----end1---- + }, + delay4:function (dt) { + //----start1----delay4 + this.unschedule(this.delay4); + this.removeChildByTag(3, false); + //----end1---- + }, + title:function () { + return "tags"; + }, + // + // Automation + // + testDuration:1, + getExpectedResult:function () { + return this.autoParam; + }, + getCurrentResult:function () { + var node = this.getChildByTag(2); + return node; + } +}); + +var CCNodeTest5 = TestNodeDemo.extend({ + ctor:function () { + //----start2----ctor + this._super(); + var sp1 = new cc.Sprite(s_pathSister1); + var sp2 = new cc.Sprite(s_pathSister2); + sp1.x = 150; + sp1.y = winSize.height / 2; + sp2.x = winSize.width - 150; + sp2.y = winSize.height / 2; + + var rot = cc.rotateBy(2, 360); + var rot_back = rot.reverse(); + var forever = cc.sequence(rot, rot_back).repeatForever(); + var forever2 = forever.clone(); + forever.tag = 101; + forever2.tag = 102; + + this.addChild(sp1, 0, TAG_SPRITE1); + this.addChild(sp2, 0, TAG_SPRITE2); + + sp1.runAction(forever); + sp2.runAction(forever2); + + this.schedule(this.onAddAndRemove, 2.0); + //----end2---- + }, + onAddAndRemove:function (dt) { + //----start2----onAddAndRemove + var sp1 = this.getChildByTag(TAG_SPRITE1); + var sp2 = this.getChildByTag(TAG_SPRITE2); + + // hack for JSB. + sp1.retain(); + sp2.retain(); + + this.removeChild(sp1, false); + this.removeChild(sp2, true); + + this.testSP1 = this.getChildByTag(TAG_SPRITE1); + this.testSP2 = this.getChildByTag(TAG_SPRITE2); + + this.addChild(sp1, 0, TAG_SPRITE1); + this.addChild(sp2, 0, TAG_SPRITE2); + + // hack for JSB. + sp1.release(); + sp2.release(); + //----end2---- + }, + title:function () { + return "remove and cleanup"; + }, + // + // Automation + // + testDuration:2.5, + testSP1:null, + testSP2:null, + pixel1:{"0":0, "1":0, "2":0, "3":255}, + pixel2:{"0":51, "1":0, "2":0, "3":255}, + getExpectedResult:function () { + var ret = {"sp1":null, "sp2":null, "pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(134, 164, 5, 5); + var ret2 = this.readPixels(winSize.width - 148, winSize.height / 2 + 51, 5, 5); + var ret = {"sp1":this.testSP1, "sp2":this.testSP2, + "pixel1":this.containsPixel(ret1, this.pixel1, false) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2, true, 3) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +var CCNodeTest6 = TestNodeDemo.extend({ + ctor:function () { + //----start3----ctor + this._super(); + var sp1 = new cc.Sprite(s_pathSister1); + var sp11 = new cc.Sprite(s_pathSister1); + + var sp2 = new cc.Sprite(s_pathSister2); + var sp21 = new cc.Sprite(s_pathSister2); + + sp1.x = 150; + sp1.y = winSize.height / 2; + sp2.x = winSize.width - 150; + sp2.y = winSize.height / 2; + + var rot = cc.rotateBy(2, 360); + var rot_back = rot.reverse(); + var forever1 = cc.sequence(rot, rot_back).repeatForever(); + var forever11 = forever1.clone(); + + var forever2 = forever1.clone(); + var forever21 = forever1.clone(); + + this.addChild(sp1, 0, TAG_SPRITE1); + sp1.addChild(sp11, 11); + this.addChild(sp2, 0, TAG_SPRITE2); + sp2.addChild(sp21, 21); + + sp1.runAction(forever1); + sp11.runAction(forever11); + sp2.runAction(forever2); + sp21.runAction(forever21); + + this.schedule(this.onAddAndRemove, 2.0); + //----end3---- + }, + onAddAndRemove:function (dt) { + //----start3----onAddAndRemove + var sp1 = this.getChildByTag(TAG_SPRITE1); + var sp2 = this.getChildByTag(TAG_SPRITE2); + + // hack for JSB. + sp1.retain(); + sp2.retain(); + + this.removeChild(sp1, false); + this.removeChild(sp2, true); + + //Automation parameters + this.autoParam1 = sp1.getChildByTag(11); + this.autoParam2 = sp2.getChildByTag(21); + + this.addChild(sp1, 0, TAG_SPRITE1); + this.addChild(sp2, 0, TAG_SPRITE2); + + // hack for JSB. + sp1.release(); + sp2.release(); + //----end3---- + + }, + title:function () { + return "remove/cleanup with children"; + }, + // + // Automation + // + testDuration:2.1, + getExpectedResult:function () { + var ret = [null, null]; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret = [this.autoParam1, this.autoParam2]; + return JSON.stringify(ret); + } +}); + +var StressTest1 = TestNodeDemo.extend({ + ctor:function () { + //----start4----ctor + this._super(); + + var sp1 = new cc.Sprite(s_pathSister1); + this.addChild(sp1, 0, TAG_SPRITE1); + this.width = 0 + this.height = 0; + + sp1.x = winSize.width / 2; + sp1.y = winSize.height / 2; + + this.schedule(this.onShouldNotCrash, 1.0); + //----end4---- + }, + onShouldNotCrash:function (dt) { + //----start4----onShouldNotCrash + this.unschedule(this.onShouldNotCrash); + + // if the node has timers, it crashes + var explosion = new cc.ParticleSun(); + explosion.texture = cc.textureCache.addImage(s_fire); + + explosion.x = winSize.width / 2; + explosion.y = winSize.height / 2; + + this.runAction( + cc.sequence( + cc.rotateBy(2, 360), + cc.callFunc(this.onRemoveMe, this) + ) + ); + + this.addChild(explosion); + //----end4---- + }, + onRemoveMe:function (node) { + //----start4----onRemoveMe + if (autoTestEnabled) { + this.testPass = true; + return; + } + this.parent.removeChild(node, true); + this.onNextCallback(this); + //----end4---- + }, + title:function () { + return "stress test #1: no crashes"; + }, + // + // Automation + // + testDuration:3.2, + testPass:false, + getExpectedResult:function () { + var ret = {"pass":true}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret = {"pass":this.testPass}; + return JSON.stringify(ret); + } +}); + +var StressTest2 = TestNodeDemo.extend({ + ctor:function () { + //----start5----ctor + this._super(); + + var sublayer = new cc.Layer(); + + var sp1 = new cc.Sprite(s_pathSister1); + sp1.x = 80; + sp1.y = winSize.height / 2; + + var move = cc.moveBy(3, cc.p(350, 0)); + var move_ease_inout3 = move.clone().easing(cc.easeInOut(2.0)); + var move_ease_inout_back3 = move_ease_inout3.reverse(); + var seq3 = cc.sequence(move_ease_inout3, move_ease_inout_back3); + sp1.runAction(seq3.repeatForever()); + sublayer.addChild(sp1, 1); + + var fire = new cc.ParticleFire(); + fire.texture = cc.textureCache.addImage(s_fire); + fire.x = 80; + fire.y = winSize.height / 2 - 50; + + var copy_seq3 = seq3.clone(); + + fire.runAction(copy_seq3.repeatForever()); + sublayer.addChild(fire, 2); + + this.schedule(this.shouldNotLeak, 6.0); + + this.addChild(sublayer, 0, TAG_SPRITE1); + //----end5---- + }, + shouldNotLeak:function (dt) { + //----start5----shouleNotLeak + this.unschedule(this.shouldNotLeak); + var sublayer = this.getChildByTag(TAG_SPRITE1); + sublayer.removeAllChildren(); + //----end5---- + }, + title:function () { + return "stress test #2: no leaks"; + } +}); + +var NodeToWorld = TestNodeDemo.extend({ + ctor:function () { + //----start6----ctor + // This code tests that nodeToParent works OK: + // - It tests different anchor Points + // - It tests different children anchor points + this._super(); + var back = new cc.Sprite(s_back3); + this.addChild(back, 5); + back.anchorX = 0; + back.anchorY = 0; + + var item = new cc.MenuItemImage(s_playNormal, s_playSelect, this.onClicked); + var menu = new cc.Menu(item); + menu.alignItemsVertically(); + menu.x = back.width / 2; + menu.y = back.height / 2; + back.addChild(menu); + + var rot = cc.rotateBy(3, 360); + var delay = cc.delayTime(0.3); + var fe = cc.sequence(rot, delay).repeatForever(); + item.runAction(fe); + + var move = cc.moveBy(3, cc.p(200, 0)); + var move_back = move.reverse(); + var seq = cc.sequence(move, delay.clone(), move_back); + var fe2 = seq.repeatForever(); + back.runAction(fe2); + + //Automation parameters + this.autoParam = item; + //----end6---- + }, + onClicked:function () { + //----start6----ctor + cc.log("On clicked"); + //----end6---- + }, + title:function () { + return "nodeToParent transform"; + }, + // + // Automation + // + testDuration:3.1, + getExpectedResult:function () { + var ret = {"a":1, "b":"0.00", "c":"-0.00", "d":1, "tx":"378", "ty":"139"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret = this.autoParam.nodeToWorldTransform(); + ret.b = ret.b.toFixed(2); + ret.c = ret.c.toFixed(2); + ret.tx = ret.tx.toFixed(0); + ret.ty = ret.ty.toFixed(0); + return JSON.stringify(ret); + } +}); + +var CameraOrbitTest = TestNodeDemo.extend({ + ctor:function () { + //----start11----ctor + this._super(); + + var p = new cc.Sprite(s_back3); + this.addChild(p, 0); + p.x = winSize.width / 2; + p.y = winSize.height / 2; + p.opacity = 128; + + // LEFT + var sw = p.width, sh = p.height; + var sprite = new cc.Sprite(s_pathGrossini); + sprite.scale = 0.5; + p.addChild(sprite, 0); + sprite.x = sw / 4; + sprite.y = sh / 2; + var orbit = cc.orbitCamera(2, 1, 0, 0, 360, 0, 0); + sprite.runAction(orbit.repeatForever()); + + // CENTER + sprite = new cc.Sprite(s_pathGrossini); + sprite.scale = 1.0; + p.addChild(sprite, 0); + sprite.x = sw / 4 * 2; + sprite.y = sh / 2; + orbit = cc.orbitCamera(2, 1, 0, 0, 360, 45, 0); + sprite.runAction(orbit.repeatForever()); + + // RIGHT + sprite = new cc.Sprite(s_pathGrossini); + sprite.scale = 2.0; + p.addChild(sprite, 0); + sprite.x = sw / 4 * 3; + sprite.y = sh / 2; + orbit = cc.orbitCamera(2, 1, 0, 0, 360, 90, -45); + sprite.runAction(orbit.repeatForever()); + + // PARENT + orbit = cc.orbitCamera(10, 1, 0, 0, 360, 0, 90); + p.runAction(orbit.repeatForever()); + + this.scale = 1; + //----end11---- + }, + onEnter:function () { + //----start11----onEnter + this._super(); + director.setProjection(cc.Director.PROJECTION_3D); + //----end11---- + }, + onExit:function () { + //----start11----onExit + director.setProjection(cc.Director.PROJECTION_2D); + this._super(); + //----end11---- + }, + title:function () { + return "Camera Orbit test"; + } +}); + +var CameraZoomTest = TestNodeDemo.extend({ + _z:0, + ctor:function () { + //----start12----ctor + this._super(); + + // LEFT + var sprite = new cc.Sprite(s_pathGrossini); + this.addChild(sprite, 0); + sprite.x = winSize.width / 4; + sprite.y = winSize.height / 2; + if ("opengl" in cc.sys.capabilities) { + var cam = sprite.getCamera(); + cam.setEye(0, 0, 415 / 2); + cam.setCenter(0, 0, 0); + } + + // CENTER + sprite = new cc.Sprite(s_pathGrossini); + this.addChild(sprite, 0, 40); + sprite.x = winSize.width / 4 * 2; + sprite.y = winSize.height / 2; + //cam = [sprite camera); + //[cam setEyeX:0 eyeY:0 eyeZ:415/2); + + // RIGHT + sprite = new cc.Sprite(s_pathGrossini); + this.addChild(sprite, 0, 20); + sprite.x = winSize.width / 4 * 3; + sprite.y = winSize.height / 2; + //cam = [sprite camera); + //[cam setEyeX:0 eyeY:0 eyeZ:-485); + //[cam setCenterX:0 centerY:0 centerZ:0); + + this._z = 0; + this.scheduleUpdate(); + + //Automation parameters + this.autoParam = sprite; + //----end12---- + }, + update:function (dt) { + //----start12----update + if (!("opengl" in cc.sys.capabilities)) + return; + + this._z += dt * 100; + var sprite = this.getChildByTag(20); + var cam = sprite.getCamera(); + cam.setEye(0, 0, this._z); + if(!cc.sys.isNative) + sprite.setNodeDirty(); + + sprite = this.getChildByTag(40); + cam = sprite.getCamera(); + cam.setEye(0, 0, -this._z); + if(!cc.sys.isNative) + sprite.setNodeDirty(); + //----end12---- + }, + onEnter:function () { + //TODO + //----start12----onEnter + this._super(); + director.setProjection(cc.Director.PROJECTION_3D); + //----end12---- + }, + onExit:function () { + //TODO + //----start12----onExit + director.setProjection(cc.Director.PROJECTION_2D); + this._super(); + //----end12---- + }, + title:function () { + return "Camera Zoom test"; + }, + // + // Automation + // + testDuration:1.1, + pixel:{"0":115, "1":0, "2":115, "3":255}, + getExpectedResult:function () { + var ret1 = {"z":this._z.toFixed(2)}; + var ret2 = {"pixel":"yes"}; + return JSON.stringify([ret1, ret2]); + }, + getCurrentResult:function () { + var ret1 = {"z":this.autoParam.getCamera().getEye().z.toFixed(2)}; + var readPixel = this.readPixels(winSize.width / 4 * 3, winSize.height / 2, 5, 5); + var ret2 = {"pixel":!this.containsPixel(readPixel, this.pixel, false) ? "yes" : "no"}; + return JSON.stringify([ret1, ret2]); + } +}); + +var CameraCenterTest = TestNodeDemo.extend({ + ctor:function () { + //----start10----ctor + this._super(); + + // LEFT-TOP + var sprite = new cc.Sprite(s_texture512); + this.addChild(sprite, 0); + sprite.x = winSize.width / 5; + sprite.y = winSize.height / 5; + sprite.color = cc.color.RED; + sprite.setTextureRect(cc.rect(0, 0, 120, 50)); + var orbit = cc.orbitCamera(10, 1, 0, 0, 360, 0, 0); + sprite.runAction(orbit.repeatForever()); + + // LEFT-BOTTOM + sprite = new cc.Sprite(s_texture512); + this.addChild(sprite, 0, 40); + sprite.x = winSize.width / 5; + sprite.y = winSize.height / 5 * 4; + sprite.color = cc.color.BLUE; + sprite.setTextureRect(cc.rect(0, 0, 120, 50)); + orbit = cc.orbitCamera(10, 1, 0, 0, 360, 0, 0); + sprite.runAction(orbit.repeatForever()); + + // RIGHT-TOP + sprite = new cc.Sprite(s_texture512); + this.addChild(sprite, 0); + sprite.x = winSize.width / 5 * 4; + sprite.y = winSize.height / 5; + sprite.color = cc.color.YELLOW; + sprite.setTextureRect(cc.rect(0, 0, 120, 50)); + orbit = cc.orbitCamera(10, 1, 0, 0, 360, 0, 0); + sprite.runAction(orbit.repeatForever()); + + // RIGHT-BOTTOM + sprite = new cc.Sprite(s_texture512); + this.addChild(sprite, 0, 40); + sprite.x = winSize.width / 5 * 4; + sprite.y = winSize.height / 5 * 4; + sprite.color = cc.color.GREEN; + sprite.setTextureRect(cc.rect(0, 0, 120, 50)); + orbit = cc.orbitCamera(10, 1, 0, 0, 360, 0, 0); + sprite.runAction(orbit.repeatForever()); + + // CENTER + sprite = new cc.Sprite(s_texture512); + this.addChild(sprite, 0, 40); + sprite.x = winSize.width / 2; + sprite.y = winSize.height / 2; + sprite.color = cc.color.WHITE; + sprite.setTextureRect(cc.rect(0, 0, 120, 50)); + orbit = cc.orbitCamera(10, 1, 0, 0, 360, 0, 0); + sprite.runAction(orbit.repeatForever()); + //----end10---- + }, + + onEnter:function(){ + //----start10----onEnter + this._super(); + cc.director.setProjection(cc.Director.PROJECTION_3D); + //----end10---- + }, + + onExit:function(){ + //----start10----onExit + cc.director.setProjection(cc.Director.PROJECTION_2D); + this._super(); + //----end10---- + }, + + title:function () { + return "Camera Center test"; + }, + subtitle:function () { + return "Sprites should rotate at the same speed"; + }, + // + // Automation + // + testDuration:2.6, + pixel1:{"0":255, "1":255, "2":255, "3":255}, + pixel2:{"0":255, "1":255, "2":255, "3":255}, + pixel3:{"0":255, "1":255, "2":255, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 2, winSize.height / 2, 5, 5); + var ret2 = this.readPixels(winSize.width / 2 - 25, winSize.height / 2, 5, 5); + var ret3 = this.readPixels(winSize.width / 2 + 20, winSize.height / 2, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1, false) ? "yes" : "no", + "pixel2":!this.containsPixel(ret2, this.pixel2, false) ? "yes" : "no", + "pixel3":!this.containsPixel(ret3, this.pixel3, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +// +// ConvertToNode +// +var ConvertToNode = TestNodeDemo.extend({ + ctor:function () { + //----start9----ctor + this._super(); + if ('touches' in cc.sys.capabilities){ + cc.eventManager.addListener(cc.EventListener.create({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded:function (touches, event) { + var target = event.getCurrentTarget(); + for (var it = 0; it < touches.length; it++) { + var touch = touches[it]; + var location = touch.getLocation(); + target.processEvent(location); + } + } + }), this); + } else if ('mouse' in cc.sys.capabilities) + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseUp: function(event){ + event.getCurrentTarget().processEvent(event.getLocation()); + } + }, this); + + var rotate = cc.rotateBy(10, 360); + var action = rotate.repeatForever(); + for (var i = 0; i < 3; i++) { + var sprite = new cc.Sprite(s_pathGrossini); + sprite.x = winSize.width / 4 * (i + 1); + sprite.y = winSize.height / 2; + var point = new cc.Sprite(s_pathR1); + point.scale = 0.25; + point.x = sprite.x; + point.y = sprite.y; + this.addChild(point, 10, 100 + i); + + switch (i) { + case 0: + sprite.anchorX = 0; + sprite.anchorY = 0; + break; + case 1: + sprite.anchorX = 0.5; + sprite.anchorY = 0.5; + break; + case 2: + sprite.anchorX = 1; + sprite.anchorY = 1; + break; + } + + point.x = sprite.x; + point.y = sprite.y; + + var copy = action.clone(); + sprite.runAction(copy); + this.addChild(sprite, i); + } + //----end9---- + }, + processEvent:function (location) { + //----start9----processEvent + this.testP1 = []; + this.testP2 = []; + for (var i = 0; i < 3; i++) { + var node = this.getChildByTag(100 + i); + + var p1 = node.convertToNodeSpaceAR(location); + var p2 = node.convertToNodeSpace(location); + + cc.log("AR: x=" + p1.x.toFixed(2) + ", y=" + p1.y.toFixed(2) + " -- Not AR: x=" + p2.x.toFixed(2) + ", y=" + p2.y.toFixed(2)); + + this.testP1.push({"x":p1.x, "y":p1.y}); + this.testP2.push({"x":p2.x, "y":p2.y}); + } + //----end9---- + }, + + title:function () { + return "Convert To Node Space"; + }, + subtitle:function () { + return "testing convertToNodeSpace / AR. Touch and see console"; + }, + // + // Automation + // + testDuration:1, + testP1:[], + expectedP1:[], + testP2:[], + expectedP2:[], + setupAutomation:function () { + this.expectedP1.push({"x":-winSize.width, "y":-winSize.height * 2}); + this.expectedP1.push({"x":-winSize.width * 2, "y":-winSize.height * 2}); + this.expectedP1.push({"x":-winSize.width * 3, "y":-winSize.height * 2}); + + this.expectedP2.push({"x":-winSize.width + 24.5, "y":-winSize.height * 2 + 23.5}); + this.expectedP2.push({"x":-winSize.width * 2 + 24.5, "y":-winSize.height * 2 + 23.5}); + this.expectedP2.push({"x":-winSize.width * 3 + 24.5, "y":-winSize.height * 2 + 23.5}); + }, + getExpectedResult:function () { + return JSON.stringify({"p1":this.expectedP1, "p2":this.expectedP2}); + }, + getCurrentResult:function () { + this.processEvent(cc.p(0, 0)); + var ret = {"p1":this.testP1, "p2":this.testP2}; + return JSON.stringify(ret); + } +}); + +// +// BoundingBox Test +// +var BoundingBoxTest = TestNodeDemo.extend({ + ctor:function () { + //----start8----ctor + this._super(); + var sprite = new cc.Sprite(s_pathGrossini); + this.addChild(sprite); + sprite.x = winSize.width / 2; + sprite.y = winSize.height / 2; + var bb = sprite.getBoundingBox(); + this.log('BoundingBox:'); + //for( var i in bb ) + // cc.log( i + " = " + bb[i] ); + cc.log('origin = [ ' + bb.x + "," + bb.y + "]"); + cc.log('size = [ ' + bb.width + "," + bb.height + "]"); + + this.testBB = bb; + //----end8---- + }, + title:function () { + return "Bounding Box Test"; + }, + subtitle:function () { + return "Testing getBoundingBox(). See console"; + }, + // + // Automation + // + testDuration:0.5, + testBB:null, + getExpectedResult:function () { + var ret = {"x":0 | (winSize.width / 2 - 42.5), "y":0 | (winSize.height / 2 - 60.5), "w":85, "h":121}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret = {"x":0 | this.testBB.x, "y":0 | this.testBB.y, "w":this.testBB.width, "h":this.testBB.height}; + return JSON.stringify(ret); + } +}); + +var SchedulerTest1 = TestNodeDemo.extend({ + ctor:function () { + //----start7----ctor + this._super(); + var layer = new cc.Layer(); + //UXLOG("retain count after init is %d", layer->retainCount()); + // 1 + + this.addChild(layer, 0); + //UXLOG("retain count after addChild is %d", layer->retainCount()); + // 2 + + layer.schedule(this.doSomething); + //UXLOG("retain count after schedule is %d", layer->retainCount()); + // 3 : (object-c viersion), but win32 version is still 2, because CCTimer class don't save target. + + layer.unschedule(this.doSomething); + //UXLOG("retain count after unschedule is %d", layer->retainCount()); + // STILL 3! (win32 is '2') + //----end7---- + }, + + doSomething:function (dt) { + //----start7----doSomething + this.testBool = false; + //----end7---- + }, + + title:function () { + return "cocosnode scheduler test #1"; + }, + // + // Automation + // + testDuration:0.5, + testBool:true, + getExpectedResult:function () { + return true; + }, + getCurrentResult:function () { + return this.testBool; + } +}); + +var NodeOpaqueTest = TestNodeDemo.extend({ + ctor:function () { + //----start13----ctor + this._super(); + var winSize = cc.director.getWinSize(); + var background; + for (var i = 0; i < 50; i++) { + background = new cc.Sprite(s_back1); + background.setBlendFunc(cc.ONE, cc.ONE_MINUS_SRC_ALPHA); + background.x = winSize.width / 2; + background.y = winSize.height / 2; + this.addChild(background); + } + //----end13---- + }, + + title:function () { + return "Node Opaque Test"; + }, + + subtitle:function () { + return "Node rendered with GL_BLEND disabled"; + } +}); + +var NodeNonOpaqueTest = TestNodeDemo.extend({ + ctor:function () { + //----start14----ctor + this._super(); + var winSize = cc.director.getWinSize(); + var background; + for (var i = 0; i < 50; i++) { + background = new cc.Sprite(s_back1); + background.setBlendFunc(cc.ONE, cc.ZERO); + background.x = winSize.width / 2; + background.y = winSize.height / 2; + this.addChild(background); + } + //----end14---- + }, + title:function () { + return "Node Non Opaque Test"; + }, + + subtitle:function () { + return "Node rendered with GL_BLEND enabled"; + } +}); + +// +// MAIN ENTRY POINT +// +var NodeTestScene = TestScene.extend({ + runThisTest:function (num) { + nodeTestSceneIdx = (num || num == 0) ? (num - 1) : -1; + MAX_LAYER = 9; + var layer = nextNodeTest(); + this.addChild(layer); + + director.runScene(this); + } +}); + +// +// Flow control +// +var arrayOfNodeTest = [ + CCNodeTest2, + CCNodeTest4, + CCNodeTest5, + CCNodeTest6, + StressTest1, + StressTest2, + NodeToWorld, + SchedulerTest1, + BoundingBoxTest, + ConvertToNode +]; + +if ('opengl' in cc.sys.capabilities) { + cc.sys.isNative || arrayOfNodeTest.push(CameraCenterTest); + arrayOfNodeTest.push(CameraOrbitTest); + cc.sys.isNative || arrayOfNodeTest.push(CameraZoomTest); + arrayOfNodeTest.push(NodeOpaqueTest); + arrayOfNodeTest.push(NodeNonOpaqueTest); +} + + +var nextNodeTest = function () { + nodeTestSceneIdx++; + nodeTestSceneIdx = nodeTestSceneIdx % arrayOfNodeTest.length; + + if(window.sideIndexBar){ + nodeTestSceneIdx = window.sideIndexBar.changeTest(nodeTestSceneIdx, 24); + } + + return new arrayOfNodeTest[nodeTestSceneIdx](); +}; +var previousNodeTest = function () { + nodeTestSceneIdx--; + if (nodeTestSceneIdx < 0) + nodeTestSceneIdx += arrayOfNodeTest.length; + + if(window.sideIndexBar){ + nodeTestSceneIdx = window.sideIndexBar.changeTest(nodeTestSceneIdx, 24); + } + + return new arrayOfNodeTest[nodeTestSceneIdx](); +}; +var restartNodeTest = function () { + return new arrayOfNodeTest[nodeTestSceneIdx](); +}; + + +new RegExp() \ No newline at end of file diff --git a/tests/js-tests/src/CurrentLanguageTest/CurrentLanguageTest.js b/tests/js-tests/src/CurrentLanguageTest/CurrentLanguageTest.js new file mode 100644 index 0000000000..8d36605cf1 --- /dev/null +++ b/tests/js-tests/src/CurrentLanguageTest/CurrentLanguageTest.js @@ -0,0 +1,85 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 CurrentLanguageTest = cc.Layer.extend({ + ctor:function () { + this._super(); + + var s = cc.director.getWinSize(); + var label = new cc.LabelTTF("Current language Test", "Arial", 28); + this.addChild(label, 0); + label.x = s.width / 2; + label.y = s.height - 50; + + var labelLanguage = new cc.LabelTTF("", "Arial", 20); + labelLanguage.x = s.width / 2; + labelLanguage.y = s.height / 2; + + var currentLanguageType = cc.sys.language; + switch (currentLanguageType) { + case cc.sys.LANGUAGE_ENGLISH: + labelLanguage.setString("current language is English"); + break; + case cc.sys.LANGUAGE_CHINESE: + labelLanguage.setString("current language is Chinese"); + break; + case cc.sys.LANGUAGE_FRENCH: + labelLanguage.setString("current language is French"); + break; + case cc.sys.LANGUAGE_GERMAN: + labelLanguage.setString("current language is German"); + break; + case cc.sys.LANGUAGE_ITALIAN: + labelLanguage.setString("current language is Italian"); + break; + case cc.sys.LANGUAGE_RUSSIAN: + labelLanguage.setString("current language is Russian"); + break; + case cc.sys.LANGUAGE_SPANISH: + labelLanguage.setString("current language is Spanish"); + break; + } + + this.addChild(labelLanguage); + } +}); + +var CurrentLanguageTestScene = TestScene.extend({ + runThisTest:function () { + if(window.sideIndexBar){ + window.sideIndexBar.changeTest(0, 8); + } + + var layer = new CurrentLanguageTest(); + this.addChild(layer); + + cc.director.runScene(this); + } +}); + +var arrayOfCurrentLanguageTest = [ + CurrentLanguageTest +]; \ No newline at end of file diff --git a/tests/js-tests/src/DrawPrimitivesTest/DrawPrimitivesTest.js b/tests/js-tests/src/DrawPrimitivesTest/DrawPrimitivesTest.js new file mode 100644 index 0000000000..dba7b44657 --- /dev/null +++ b/tests/js-tests/src/DrawPrimitivesTest/DrawPrimitivesTest.js @@ -0,0 +1,246 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 drawTestSceneIdx = -1; + +//------------------------------------------------------------------ +// +// DrawTestDemo +// +//------------------------------------------------------------------ +var DrawTestDemo = BaseTestLayer.extend({ + _title:"", + _subtitle:"", + + ctor:function() { + this._super(cc.color(0,0,0,255), cc.color(98,99,117,255)); + }, + + onRestartCallback:function (sender) { + var s = new DrawPrimitivesTestScene(); + s.addChild(restartDrawTest()); + director.runScene(s); + }, + onNextCallback:function (sender) { + var s = new DrawPrimitivesTestScene(); + s.addChild(nextDrawTest()); + director.runScene(s); + }, + onBackCallback:function (sender) { + var s = new DrawPrimitivesTestScene(); + s.addChild(previousDrawTest()); + director.runScene(s); + }, + // automation + numberOfPendingTests:function() { + return ( (arrayOfDrawTest.length-1) - drawTestSceneIdx ); + }, + + getTestNumber:function() { + return drawTestSceneIdx; + } + +}); + +//------------------------------------------------------------------ +// +// Testing cc.DrawNode API 2 +// +//------------------------------------------------------------------ +var DrawNewAPITest2 = DrawTestDemo.extend({ + _title: "cc.DrawNode", + _subtitle: "Testing cc.DrawNode API 2", + ctor: function () { + //----start0----ctor + this._super(); + var draw = new cc.DrawNode(); + this.addChild(draw, 10); + var winSize = cc.director.getWinSize(); + var centerPos = cc.p(winSize.width / 2, winSize.height / 2); + //drawSegment + draw.drawSegment(cc.p(0, 0), cc.p(winSize.width, winSize.height), 1, cc.color(255, 255, 255, 255)); + draw.drawSegment(cc.p(0, winSize.height), cc.p(winSize.width, 0), 5, cc.color(255, 0, 0, 255)); + + //drawDot + draw.drawDot(cc.p(winSize.width / 2, winSize.height / 2), 40, cc.color(0, 0, 255, 128)); + var points = [cc.p(60, 60), cc.p(70, 70), cc.p(60, 70), cc.p(70, 60)]; + for (var i = 0; i < points.length; i++) { + draw.drawDot(points[i], 4, cc.color(0, 255, 255, 255)); + } + //drawCircle + draw.drawCircle(cc.p(winSize.width / 2, winSize.height / 2), 100, 0, 10, false, 6, cc.color(0, 255, 0, 255)); + draw.drawCircle(cc.p(winSize.width / 2, winSize.height / 2), 50, cc.degreesToRadians(90), 50, true, 2, cc.color(0, 255, 255, 255)); + + //draw poly + //not fill + var vertices = [cc.p(0, 0), cc.p(50, 50), cc.p(100, 50), cc.p(100, 100), cc.p(50, 100) ]; + draw.drawPoly(vertices, null, 5, cc.color(255, 255, 0, 255)); + var vertices2 = [cc.p(30, 130), cc.p(30, 230), cc.p(50, 200)]; + draw.drawPoly(vertices2, null, 2, cc.color(255, 0, 255, 255)); + //fill + var vertices3 = [cc.p(60, 130), cc.p(60, 230), cc.p(80, 200)]; + draw.drawPoly(vertices3, cc.color(0, 255, 255, 50), 2, cc.color(255, 0, 255, 255)); + + //draw rect + //not fill + draw.drawRect(cc.p(120, 120), cc.p(200, 200), null, 2, cc.color(255, 0, 255, 255)); + //fill + draw.drawRect(cc.p(120, 220), cc.p(200, 300), cc.color(0, 255, 255, 50), 2, cc.color(128, 128, 0, 255)); + + // draw quad bezier path + draw.drawQuadBezier(cc.p(0, winSize.height), cc.p(centerPos.x, centerPos.y), cc.p(winSize.width, winSize.height), 50, 2, cc.color(255, 0, 255, 255)); + + // draw cubic bezier path + draw.drawCubicBezier(cc.p(winSize.width / 2, winSize.height / 2), cc.p(winSize.width / 2 + 30, winSize.height / 2 + 50), + cc.p(winSize.width / 2 + 60, winSize.height / 2 - 50), cc.p(winSize.width, winSize.height / 2), 100, 2, cc.color(255, 0, 255, 255)); + + //draw cardinal spline + var vertices4 = [ + cc.p(centerPos.x - 130, centerPos.y - 130), + cc.p(centerPos.x - 130, centerPos.y + 130), + cc.p(centerPos.x + 130, centerPos.y + 130), + cc.p(centerPos.x + 130, centerPos.y - 130), + cc.p(centerPos.x - 130, centerPos.y - 130) + ]; + draw.drawCardinalSpline(vertices4, 0.5, 100, 2, cc.color(255, 255, 255, 255)); + //----end0---- + } +}); +DrawNewAPITest2.prototype.title = function(){ + return 'cc.DrawNode 2'; +}; + +//------------------------------------------------------------------ +// +// Draw New API Test +// +//------------------------------------------------------------------ +var DrawNewAPITest = DrawTestDemo.extend({ + _title : "cc.DrawNode", + _subtitle : "Testing cc.DrawNode API", + + ctor:function() { + //----start1----ctor + this._super(); + + var draw = new cc.DrawNode(); + this.addChild(draw, 10); + // + // Circles + // + for( var i=0; i < 10; i++) { + draw.drawDot( cc.p(winSize.width/2, winSize.height/2), 10*(10-i), cc.color( Math.random()*255, Math.random()*255, Math.random()*255, 255) ); + } + + // + // Polygons + // + var points = [ cc.p(winSize.height/4,0), cc.p(winSize.width,winSize.height/5), cc.p(winSize.width/3*2,winSize.height) ]; + draw.drawPoly(points, cc.color(255,0,0,128), 8, cc.color(0,128,128,255) ); + + // star poly (triggers bugs) + var o=80; + var w=20; + var h=50; + var star = [ + cc.p(o+w,o-h), cc.p(o+w*2, o), // lower spike + cc.p(o + w*2 + h, o+w ), cc.p(o + w*2, o+w*2), // right spike + cc.p(o +w, o+w*2+h), cc.p(o,o+w*2), // top spike + cc.p(o -h, o+w), cc.p(o,o) // left spike + ]; + draw.drawPoly(star, cc.color(255,0,0,128), 2, cc.color(0,0,255,255) ); + + // star poly (doesn't trigger bug... order is important un tesselation is supported. + o=180; + w=20; + h=50; + star = [ + cc.p(o,o), cc.p(o+w,o-h), cc.p(o+w*2, o), // lower spike + cc.p(o + w*2 + h, o+w ), cc.p(o + w*2, o+w*2), // right spike + cc.p(o +w, o+w*2+h), cc.p(o,o+w*2), // top spike + cc.p(o -h, o+w) // left spike + ]; + draw.drawPoly(star, cc.color(255,0,0,128), 2, cc.color(0,0,255,255) ); + + // + // Segments + // + draw.drawSegment( cc.p(20,winSize.height), cc.p(20,winSize.height/2), 10, cc.color(0, 255, 0, 255) ); + draw.drawSegment( cc.p(10,winSize.height/2), cc.p(winSize.width/2, winSize.height/2), 40, cc.color(255, 0, 255, 128) ); + //----end1---- + } +}); + +DrawNewAPITest.prototype.title = function(){ + return 'cc.DrawNode 1'; +}; + +// +// +var DrawPrimitivesTestScene = TestScene.extend({ + runThisTest:function (num) { + drawTestSceneIdx = (num || num == 0) ? (num - 1) : -1; + var layer = nextDrawTest(); + this.addChild(layer); + + director.runScene(this); + } +}); + +// +// Flow control +// + +var arrayOfDrawTest = [ + DrawNewAPITest, + DrawNewAPITest2 +]; + +var nextDrawTest = function () { + drawTestSceneIdx++; + drawTestSceneIdx = drawTestSceneIdx % arrayOfDrawTest.length; + + if(window.sideIndexBar){ + drawTestSceneIdx = window.sideIndexBar.changeTest(drawTestSceneIdx, 9); + } + + return new arrayOfDrawTest[drawTestSceneIdx](); +}; +var previousDrawTest = function () { + drawTestSceneIdx--; + if (drawTestSceneIdx < 0) + drawTestSceneIdx += arrayOfDrawTest.length; + + if(window.sideIndexBar){ + drawTestSceneIdx = window.sideIndexBar.changeTest(drawTestSceneIdx, 9); + } + + return new arrayOfDrawTest[drawTestSceneIdx](); +}; +var restartDrawTest = function () { + return new arrayOfDrawTest[drawTestSceneIdx](); +}; + diff --git a/tests/js-tests/src/EaseActionsTest/EaseActionsTest.js b/tests/js-tests/src/EaseActionsTest/EaseActionsTest.js new file mode 100644 index 0000000000..3abf9b7cfa --- /dev/null +++ b/tests/js-tests/src/EaseActionsTest/EaseActionsTest.js @@ -0,0 +1,1223 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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. + ****************************************************************************/ + +TAG_ACTION1_EASE_ACTIONS = 1; +TAG_ACTION2_EASE_ACTIONS = 2; +TAG_SLIDER_EASE_ACTIONS = 1; + +var easeActionsTestIdx = -1; + +// the class inherit from TestScene +// every .Scene each test used must inherit from TestScene, +// make sure the test have the menu item for back to main menu +var EaseActionsTestScene = TestScene.extend({ + runThisTest:function (num) { + easeActionsTestIdx = (num || num == 0) ? (num - 1) : -1; + this.addChild(nextEaseActionsTest()); + director.runScene(this); + } +}); + + +var EaseSpriteDemo = BaseTestLayer.extend({ + _grossini:null, + _tamara:null, + _kathia:null, + _title:null, + + ctor:function () { + this._super(cc.color(0, 0, 0, 255), cc.color(98, 99, 117, 255)); + }, + + title:function () { + return "No title"; + }, + onEnter:function () { + this._super(); + + // Or you can create an sprite using a filename. PNG and BMP files are supported. Probably TIFF too + this._grossini = new cc.Sprite(s_pathGrossini); + this._tamara = new cc.Sprite(s_pathSister1); + this._kathia = new cc.Sprite(s_pathSister2); + + this.addChild(this._grossini, 3); + this.addChild(this._kathia, 2); + this.addChild(this._tamara, 1); + + this._grossini.x = 60; + + this._grossini.y = winSize.height / 5; + this._kathia.x = 60; + this._kathia.y = winSize.height / 2; + this._tamara.x = 60; + this._tamara.y = winSize.height * 4 / 5; + + this.twoSprites = false; + }, + + onRestartCallback:function (sender) { + var s = new EaseActionsTestScene();//cc.Scene.create(); + s.addChild(restartEaseActionsTest()); + director.runScene(s); + }, + onNextCallback:function (sender) { + var s = new EaseActionsTestScene();//cc.Scene.create(); + s.addChild(nextEaseActionsTest()); + director.runScene(s); + }, + onBackCallback:function (sender) { + var s = new EaseActionsTestScene();//cc.Scene.create(); + s.addChild(previousEaseActionsTest()); + director.runScene(s); + }, + positionForTwo:function () { + this.twoSprites = true; + this._grossini.x = 60; + this._grossini.y = winSize.height / 5; + this._tamara.x = 60; + this._tamara.y = winSize.height * 4 / 5; + this._kathia.visible = false; + }, + + // + // Automation + // + numberOfPendingTests:function() { + return ( (arrayOfEaseActionsTest.length-1) - easeActionsTestIdx ); + }, + + getTestNumber:function() { + return easeActionsTestIdx; + }, + + // default values for automation + testDuration:2.05, + getExpectedResult:function() { + var ret; + var w = 60 + winSize.width - 80; + if( this.twoSprites ) + ret = [w, w]; + else + ret = [w, w, w]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret; + if( this.twoSprites) + ret = [ this._grossini.x, this._tamara.x]; + else + ret = [ this._grossini.x, this._tamara.x, this._kathia.x ]; + return JSON.stringify(ret); + } + +}); + +//------------------------------------------------------------------ +// +// SpriteEase +// +//------------------------------------------------------------------ +var SpriteEase = EaseSpriteDemo.extend({ + + onEnter:function () { + //----start0----onEnter + this._super(); + + var move = cc.moveBy(2, cc.p(winSize.width - 80, 0)); + var move_back = move.reverse(); + + //old api + //var move_ease_in = cc.EaseIn.create(move.clone(), 2.0); + + var move_ease_in = move.clone().easing(cc.easeIn(2.0)); + var move_ease_in_back = move_ease_in.reverse(); + + //old api + //var move_ease_out = cc.EaseOut.create(move.clone(), 2.0); + + var move_ease_out = move.clone().easing(cc.easeOut(2.0)); + var move_ease_out_back = move_ease_out.reverse(); + + + var delay = cc.delayTime(0.10); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()); + var seq2 = cc.sequence(move_ease_in, delay.clone(), move_ease_in_back, delay.clone()); + var seq3 = cc.sequence(move_ease_out, delay.clone(), move_ease_out_back, delay.clone()); + + + var a2 = this._grossini.runAction(seq1.repeatForever()); + a2.tag = 1; + + var a1 = this._tamara.runAction(seq2.repeatForever()); + a1.tag = 1; + + var a = this._kathia.runAction(seq3.repeatForever()); + a.tag = 1; + + this.scheduleOnce(this.testStopAction, 4.1); + //----end0---- + }, + title:function () { + return "EaseIn - EaseOut - Stop"; + }, + + testStopAction:function (dt) { + this._tamara.stopActionByTag(1); + this._kathia.stopActionByTag(1); + this._grossini.stopActionByTag(1); + }, + + // + // Automation + // + testDuration:4.2, + getExpectedResult:function() { + var ret = [60,60,60]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = [ this._grossini.x, this._tamara.x, this._kathia.x ]; + return JSON.stringify(ret); + } + +}); + +//------------------------------------------------------------------ +// +// SpriteEaseInOut +// +//------------------------------------------------------------------ +var SpriteEaseInOut = EaseSpriteDemo.extend({ + + onEnter:function () { + //----start1----onEnter + this._super(); + + var move = cc.moveBy(2, cc.p(winSize.width - 80, 0)); + // id move_back = move.reverse(); + + //old api + //var move_ease_inout1 = cc.EaseInOut.create(move.clone(), 2.0); + + var move_ease_inout1 = move.clone().easing(cc.easeInOut(2.0)); + var move_ease_inout_back1 = move_ease_inout1.reverse(); + + //old api + //var move_ease_inout2 = cc.EaseInOut.create(move.clone(), 3.0); + + var move_ease_inout2 = move.clone().easing(cc.easeInOut(3.0)); + var move_ease_inout_back2 = move_ease_inout2.reverse(); + + //old api + //var move_ease_inout3 = cc.EaseInOut.create(move.clone(), 4.0); + + var move_ease_inout3 = move.clone().easing(cc.easeInOut(4.0)); + var move_ease_inout_back3 = move_ease_inout3.reverse(); + + var delay = cc.delayTime(0.1); + + var seq1 = cc.sequence(move_ease_inout1, delay, move_ease_inout_back1, delay.clone()); + var seq2 = cc.sequence(move_ease_inout2, delay.clone(), move_ease_inout_back2, delay.clone()); + var seq3 = cc.sequence(move_ease_inout3, delay.clone(), move_ease_inout_back3, delay.clone()); + + this._tamara.runAction(seq1.repeatForever()); + this._kathia.runAction(seq2.repeatForever()); + this._grossini.runAction(seq3.repeatForever()); + //----end1---- + }, + title:function () { + return "EaseInOut and rates"; + } +}); + +//------------------------------------------------------------------ +// +// SpriteEaseExponential +// +//------------------------------------------------------------------ +var SpriteEaseExponential = EaseSpriteDemo.extend({ + + onEnter:function () { + //----start2----onEnter + this._super(); + + var move = cc.moveBy(2, cc.p(winSize.width - 80, 0)); + var move_back = move.reverse(); + + //old api + //var move_ease_in = cc.EaseExponentialIn.create(move.clone()); + + var move_ease_in = move.clone().easing(cc.easeExponentialIn()); + var move_ease_in_back = move_ease_in.reverse(); + + var move_ease_out = move.clone().easing(cc.easeExponentialOut()); + var move_ease_out_back = move_ease_out.reverse(); + + var delay = cc.delayTime(0.1); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()); + var seq2 = cc.sequence(move_ease_in, delay.clone(), move_ease_in_back, delay.clone()); + var seq3 = cc.sequence(move_ease_out, delay.clone(), move_ease_out_back, delay.clone()); + + + this._grossini.runAction(seq1.repeatForever()); + this._tamara.runAction(seq2.repeatForever()); + this._kathia.runAction(seq3.repeatForever()); + //----end2----- + }, + title:function () { + return "ExpIn - ExpOut actions"; + } +}); + +//------------------------------------------------------------------ +// +// SpriteEaseExponentialInOut +// +//------------------------------------------------------------------ +var SpriteEaseExponentialInOut = EaseSpriteDemo.extend({ + onEnter:function () { + //----start3----onEnter + this._super(); + + var move = cc.moveBy(2, cc.p(winSize.width - 80, 0)); + var move_back = move.reverse(); + + //old api + //var move_ease = cc.EaseExponentialInOut.create(move.clone()); + + var move_ease = move.clone().easing(cc.easeExponentialInOut()); + var move_ease_back = move_ease.reverse(); + + var delay = cc.delayTime(0.1); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()); + var seq2 = cc.sequence(move_ease, delay.clone(), move_ease_back, delay.clone()); + + this.positionForTwo(); + + this._grossini.runAction(seq1.repeatForever()); + this._tamara.runAction(seq2.repeatForever()); + //----end3---- + }, + title:function () { + return "EaseExponentialInOut action"; + } +}); + +//------------------------------------------------------------------ +// +// SpriteEaseSine +// +//------------------------------------------------------------------ +var SpriteEaseSine = EaseSpriteDemo.extend({ + onEnter:function () { + //----start4----onEnter + this._super(); + + var move = cc.moveBy(2, cc.p(winSize.width - 80, 0)); + var move_back = move.reverse(); + + //old api + //var move_ease_in = cc.EaseSineIn.create(move.clone()); + + var move_ease_in = move.clone().easing(cc.easeSineIn()); + var move_ease_in_back = move_ease_in.reverse(); + + //old api + //var move_ease_out = cc.EaseSineOut.create(move.clone()); + + var move_ease_out = move.clone().easing(cc.easeSineOut()); + var move_ease_out_back = move_ease_out.reverse(); + + var delay = cc.delayTime(0.1); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()); + var seq2 = cc.sequence(move_ease_in, delay, move_ease_in_back, delay.clone()); + var seq3 = cc.sequence(move_ease_out, delay, move_ease_out_back, delay.clone()); + + + this._grossini.runAction(seq1.repeatForever()); + this._tamara.runAction(seq2.repeatForever()); + this._kathia.runAction(seq3.repeatForever()); + //----end4---- + }, + title:function () { + return "EaseSineIn - EaseSineOut"; + } +}); + +//------------------------------------------------------------------ +// +// SpriteEaseSineInOut +// +//------------------------------------------------------------------ +var SpriteEaseSineInOut = EaseSpriteDemo.extend({ + onEnter:function () { + //----start5----onEnter + this._super(); + + var move = cc.moveBy(2, cc.p(winSize.width - 80, 0)); + var move_back = move.reverse(); + + //old api + //var move_ease = cc.EaseSineInOut.create(move.clone()); + + var move_ease = move.clone().easing(cc.easeSineInOut()); + var move_ease_back = move_ease.reverse(); + + var delay = cc.delayTime(0.1); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()); + var seq2 = cc.sequence(move_ease, delay.clone(), move_ease_back, delay.clone()); + + this.positionForTwo(); + + this._grossini.runAction(seq1.repeatForever()); + this._tamara.runAction(seq2.repeatForever()); + //----end5---- + }, + title:function () { + return "EaseSineInOut action"; + } +}); + +//------------------------------------------------------------------ +// +// SpriteEaseElastic +// +//------------------------------------------------------------------ +var SpriteEaseElastic = EaseSpriteDemo.extend({ + onEnter:function () { + //----start6----onEnter + this._super(); + + var move = cc.moveBy(2, cc.p(winSize.width - 80, 0)); + var move_back = move.reverse(); + + //old api + //var move_ease_in = cc.EaseElasticIn.create(move.clone()); + + var move_ease_in = move.clone().easing(cc.easeElasticIn()); + var move_ease_in_back = move_ease_in.reverse(); + + //old api + //var move_ease_out = cc.EaseElasticOut.create(move.clone()); + + var move_ease_out = move.clone().easing(cc.easeElasticOut()); + var move_ease_out_back = move_ease_out.reverse(); + + var delay = cc.delayTime(0.1); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()); + var seq2 = cc.sequence(move_ease_in, delay.clone(), move_ease_in_back, delay.clone()); + var seq3 = cc.sequence(move_ease_out, delay.clone(), move_ease_out_back, delay.clone()); + + this._grossini.runAction(seq1.repeatForever()); + this._tamara.runAction(seq2.repeatForever()); + this._kathia.runAction(seq3.repeatForever()); + //----end6---- + }, + title:function () { + return "Elastic In - Out actions"; + } +}); + +//------------------------------------------------------------------ +// +// SpriteEaseElasticInOut +// +//------------------------------------------------------------------ +var SpriteEaseElasticInOut = EaseSpriteDemo.extend({ + onEnter:function () { + //----start7----onEnter + this._super(); + + var move = cc.moveBy(2, cc.p(winSize.width - 80, 0)); + + //old api + //var move_ease_inout1 = cc.EaseElasticInOut.create(move.clone(), 0.3); + + var move_ease_inout1 = move.clone().easing(cc.easeElasticInOut(0.3)); + var move_ease_inout_back1 = move_ease_inout1.reverse(); + + //old api + //var move_ease_inout2 = cc.EaseElasticInOut.create(move.clone(), 0.45); + + var move_ease_inout2 = move.clone().easing(cc.easeElasticInOut(0.45)); + var move_ease_inout_back2 = move_ease_inout2.reverse(); + + //old api + //var move_ease_inout3 = cc.EaseElasticInOut.create(move.clone(), 0.6); + + var move_ease_inout3 = move.clone().easing(cc.easeElasticInOut(0.6)); + var move_ease_inout_back3 = move_ease_inout3.reverse(); + + var delay = cc.delayTime(0.1); + + var seq1 = cc.sequence(move_ease_inout1, delay, move_ease_inout_back1, delay.clone()); + var seq2 = cc.sequence(move_ease_inout2, delay.clone(), move_ease_inout_back2, delay.clone()); + var seq3 = cc.sequence(move_ease_inout3, delay.clone(), move_ease_inout_back3, delay.clone()); + + this._tamara.runAction(seq1.repeatForever()); + this._kathia.runAction(seq2.repeatForever()); + this._grossini.runAction(seq3.repeatForever()); + //----end7---- + }, + title:function () { + return "EaseElasticInOut action"; + } +}); + +//------------------------------------------------------------------ +// +// SpriteEaseBounce +// +//------------------------------------------------------------------ +var SpriteEaseBounce = EaseSpriteDemo.extend({ + onEnter:function () { + //----start8----onEnter + this._super(); + + var move = cc.moveBy(2, cc.p(winSize.width - 80, 0)); + var move_back = move.reverse(); + + //old api + //var move_ease_in = cc.EaseBounceIn.create(move.clone()); + + var move_ease_in = move.clone().easing(cc.easeBounceIn()); + var move_ease_in_back = move_ease_in.reverse(); + + //old api + //var move_ease_out = cc.EaseBounceOut.create(move.clone()); + + var move_ease_out = move.clone().easing(cc.easeBounceOut()); + var move_ease_out_back = move_ease_out.reverse(); + + var delay = cc.delayTime(0.1); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()); + var seq2 = cc.sequence(move_ease_in, delay.clone(), move_ease_in_back, delay.clone()); + var seq3 = cc.sequence(move_ease_out, delay.clone(), move_ease_out_back, delay.clone()); + + this._grossini.runAction(seq1.repeatForever()); + this._tamara.runAction(seq2.repeatForever()); + this._kathia.runAction(seq3.repeatForever()); + //----end8---- + }, + title:function () { + return "Bounce In - Out actions"; + } +}); + +//------------------------------------------------------------------ +// +// SpriteEaseBounceInOut +// +//------------------------------------------------------------------ +var SpriteEaseBounceInOut = EaseSpriteDemo.extend({ + onEnter:function () { + //----start9----onEnter + this._super(); + + var move = cc.moveBy(2, cc.p(winSize.width - 80, 0)); + var move_back = move.reverse(); + + //old api + //var move_ease = cc.EaseBounceInOut.create(move.clone()); + + var move_ease = move.clone().easing(cc.easeBounceInOut()); + var move_ease_back = move_ease.reverse(); + + var delay = cc.delayTime(0.1); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()); + var seq2 = cc.sequence(move_ease, delay.clone(), move_ease_back, delay.clone()); + + this.positionForTwo(); + + this._grossini.runAction(seq1.repeatForever()); + this._tamara.runAction(seq2.repeatForever()); + //----end9---- + }, + title:function () { + return "EaseBounceInOut action"; + } +}); + +//------------------------------------------------------------------ +// +// SpriteEaseBack +// +//------------------------------------------------------------------ +var SpriteEaseBack = EaseSpriteDemo.extend({ + onEnter:function () { + //----start10----onEnter + this._super(); + + var move = cc.moveBy(2, cc.p(winSize.width - 80, 0)); + var move_back = move.reverse(); + + //old api + //var move_ease_in = cc.EaseBackIn.create(move.clone()); + + var move_ease_in = move.clone().easing(cc.easeBackIn()); + var move_ease_in_back = move_ease_in.reverse(); + + //old api + //var move_ease_out = cc.EaseBackOut.create(move.clone()); + + var move_ease_out = move.clone().easing(cc.easeBackOut()); + var move_ease_out_back = move_ease_out.reverse(); + + var delay = cc.delayTime(0.1); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()); + var seq2 = cc.sequence(move_ease_in, delay.clone(), move_ease_in_back, delay.clone()); + var seq3 = cc.sequence(move_ease_out, delay.clone(), move_ease_out_back, delay.clone()); + + this._grossini.runAction(seq1.repeatForever()); + this._tamara.runAction(seq2.repeatForever()); + this._kathia.runAction(seq3.repeatForever()); + //----end10---- + }, + title:function () { + return "Back In - Out actions"; + } +}); + +//------------------------------------------------------------------ +// +// SpriteEaseBackInOut +// +//------------------------------------------------------------------ +var SpriteEaseBackInOut = EaseSpriteDemo.extend({ + onEnter:function () { + //----start11----onEnter + this._super(); + + var move = cc.moveBy(2, cc.p(winSize.width - 80, 0)); + var move_back = move.reverse(); + + //old api + //var move_ease = cc.EaseBackInOut.create(move.clone()); + + var move_ease = move.clone().easing(cc.easeBackInOut()); + var move_ease_back = move_ease.reverse(); + + var delay = cc.delayTime(0.1); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()); + var seq2 = cc.sequence(move_ease, delay.clone(), move_ease_back, delay.clone()); + + this.positionForTwo(); + + this._grossini.runAction(seq1.repeatForever()); + this._tamara.runAction(seq2.repeatForever()); + //----end11---- + }, + title:function () { + return "EaseBackInOut action"; + } +}); + +var SpeedTest = EaseSpriteDemo.extend({ + onEnter:function () { + //----start12----onEnter + this._super(); + + // rotate and jump + var jump1 = cc.jumpBy(4, cc.p(-winSize.width + 80, 0), 100, 4); + var jump2 = jump1.reverse(); + var rot1 = cc.rotateBy(4, 360 * 2); + var rot2 = rot1.reverse(); + + var seq3_1 = cc.sequence(jump2, jump1); + var seq3_2 = cc.sequence(rot1, rot2); + var spawn = cc.spawn(seq3_1, seq3_2); + + var action = spawn.repeatForever().speed(2); + action.tag = TAG_ACTION1_EASE_ACTIONS; + + var action2 = action.clone(); + var action3 = action.clone(); + + action2.tag = TAG_ACTION1_EASE_ACTIONS; + action3.tag = TAG_ACTION1_EASE_ACTIONS; + + this._grossini.runAction(action2); + this._tamara.runAction(action3); + this._kathia.runAction(action); + + this.schedule(this.altertime, 1.0); + //----end12---- + }, + title:function () { + return "Speed action"; + }, + + altertime:function (dt) { + //----start12----altertime + var action1 = this._grossini.getActionByTag(TAG_ACTION1_EASE_ACTIONS); + var action2 = this._tamara.getActionByTag(TAG_ACTION1_EASE_ACTIONS); + var action3 = this._kathia.getActionByTag(TAG_ACTION1_EASE_ACTIONS); + + action1.setSpeed(Math.random() * 2); + action2.setSpeed(Math.random() * 2); + action3.setSpeed(Math.random() * 2); + //----end12---- + }, + // automation + testDuration:0.1, + getExpectedResult:function() { + throw "Not Implemented"; + }, + getCurrentResult:function() { + throw "Not Implemented"; + } +}); + +//------------------------------------------------------------------ +// +// SchedulerTest +// +//------------------------------------------------------------------ +var SchedulerTest = EaseSpriteDemo.extend({ + onEnter:function () { + //----start13----onEnter + this._super(); + + // rotate and jump + var jump1 = cc.jumpBy(4, cc.p(-winSize.width + 80, 0), 100, 4); + var jump2 = jump1.reverse(); + var rot1 = cc.rotateBy(4, 360 * 2); + var rot2 = rot1.reverse(); + + var seq3_1 = cc.sequence(jump2, jump1); + var seq3_2 = cc.sequence(rot1, rot2); + var spawn = cc.spawn(seq3_1, seq3_2); + var action = spawn.repeatForever(); + + var action2 = action.clone(); + var action3 = action.clone(); + + //old api + //this._grossini.runAction(cc.speed(action, 0.5)); + //this._tamara.runAction(cc.speed(action2, 1.5)); + //this._kathia.runAction(cc.speed(action3, 1.0)); + + this._grossini.runAction(action.speed(0.5)); + this._tamara.runAction(action2.speed(1.5)); + this._kathia.runAction(action3.speed(1.0)); + + var emitter = new cc.ParticleFireworks(); + emitter.setTotalParticles(250); + emitter.texture = cc.textureCache.addImage("res/Images/fire.png"); + this.addChild(emitter); + //----end13---- + }, + title:function () { + return "Scheduler scaleTime Test"; + }, + + // automation + testDuration:0.1, + getExpectedResult:function() { + throw "Not Implemented"; + }, + getCurrentResult:function() { + throw "Not Implemented"; + } +}); + +// +// SpriteEaseBezier action +// +var SpriteEaseBezierTest = EaseSpriteDemo.extend({ + + onEnter: function(){ + this._super(); + //----start14----onEnter + + var size = director.getWinSize(); + + // + // startPosition can be any coordinate, but since the movement + // is relative to the Bezier curve, make it (0,0) + // + + this._grossini.setPosition( cc.p(size.width/2, size.height/2)); + this._tamara.setPosition( cc.p(size.width/4, size.height/2)); + this._kathia.setPosition( cc.p(3 * size.width/4, size.height/2)); + + // sprite 1 + var bezier = [ + cc.p(0, size.height / 2), + cc.p(300 / 480 * 800, -size.height / 2), + cc.p(300 / 480 * 800, 100 / 320 * 450) + ]; + var bezierForward = cc.bezierBy(3, bezier); + //var bezierEaseForward = cc.EaseBezierAction.create(bezierForward); + //bezierEaseForward.setBezierParamer(0.5, 0.5, 1.0, 1.0); + var bezierEaseForward = bezierForward.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0)); + + var bezierEaseBack = bezierEaseForward.reverse(); + var bezierEaseTo = cc.sequence(bezierEaseForward, bezierEaseBack).repeatForever(); + + // sprite 2 + this._tamara.setPosition(cc.p(135,225)); + var bezier2 = [ + cc.p(100 / 480 * 800, size.height / 2), + cc.p(200 / 480 * 800, -size.height / 2), + cc.p(200 / 480 * 800, 160 / 320 * 450) + ]; + var bezierTo1 = cc.bezierTo(2, bezier2); + //var bezierEaseTo1 = cc.EaseBezierAction.create(bezierTo1); + //bezierEaseTo1.setBezierParamer(0.5, 0.5, 1.0, 1.0); + var bezierEaseTo1 = bezierTo1.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0)); + + // sprite 3 + this._kathia.setPosition(cc.p(667, 225)); + var bezierTo2 = cc.bezierTo(2, bezier2); + //var bezierEaseTo2 = cc.EaseBezierAction.create(bezierTo2); + //bezierEaseTo2.setBezierParamer(0.0, 0.5, -5.0, 1.0); + var bezierEaseTo2 = bezierTo2.easing(cc.easeBezierAction(0.0, 0.5, -5.0, 1.0)); + + + this._grossini.runAction(bezierEaseTo); + this._tamara.runAction(bezierEaseTo1); + this._kathia.runAction(bezierEaseTo2); + + //----end14---- + }, + title: function(){ + return "SpriteEaseBezier action"; + } +}); + + +// +// SpriteEaseQuadratic +// +var SpriteEaseQuadraticTest = EaseSpriteDemo.extend({ + + onEnter: function(){ + this._super(); + //----start15----onEnter + + var move = cc.moveBy(3, cc.p(winSize.width - 130, 0)); + var move_back = move.reverse(); + + //var move_ease_in = cc.EaseQuadraticActionIn.create(move.clone()); + var move_ease_in = move.clone().easing(cc.easeQuadraticActionIn()); + var move_ease_in_back = move_ease_in.reverse(); + + //var move_ease_out = cc.EaseQuadraticActionOut.create(move.clone()); + var move_ease_out = move.clone().easing(cc.easeQuadraticActionOut()); + var move_ease_out_back = move_ease_out.reverse(); + + var delay = cc.delayTime(0.25); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()); + var seq2 = cc.sequence(move_ease_in, delay.clone(), move_ease_in_back, delay.clone()); + var seq3 = cc.sequence(move_ease_out, delay.clone(), move_ease_out_back, delay.clone()); + + this._grossini.runAction( seq1.repeatForever() ); + this._tamara.runAction( seq2.repeatForever() ); + this._kathia.runAction( seq3.repeatForever() ); + + //----end15---- + }, + title: function(){ + return "SpriteEaseQuadratic action"; + } +}); + +// +// SpriteEaseQuadraticInOut +// +var SpriteEaseQuadraticInOutTest = EaseSpriteDemo.extend({ + + onEnter: function(){ + this._super(); + //----start16----onEnter + + var move = cc.moveBy(3, cc.p(winSize.width - 130, 0)); + var move_back = move.reverse(); + + //var move_ease = cc.EaseQuadraticActionInOut.create(move.clone()); + var move_ease = move.clone().easing(cc.easeQuadraticActionInOut()); + var move_ease_back = move_ease.reverse(); + + var delay = cc.delayTime(0.25); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()).repeatForever(); + var seq2 = cc.sequence(move_ease, delay.clone(), move_ease_back, delay.clone()).repeatForever(); + + this.positionForTwo(); + + this._grossini.runAction( seq1 ); + this._tamara.runAction( seq2 ); + //----end16---- + }, + title: function(){ + return "SpriteEaseQuadraticInOut action"; + } +}); + +// +// SpriteEaseQuartic +// +var SpriteEaseQuarticTest = EaseSpriteDemo.extend({ + + onEnter: function(){ + this._super(); + //----start17----onEnter + + var move = cc.moveBy(3, cc.p(winSize.width - 130, 0)); + var move_back = move.reverse(); + + //var move_ease_in = cc.EaseQuarticActionIn.create(move.clone() ); + var move_ease_in = move.clone().easing(cc.easeQuarticActionIn()); + var move_ease_in_back = move_ease_in.reverse(); + + //var move_ease_out = cc.EaseQuarticActionOut.create(move.clone() ); + var move_ease_out = move.clone().easing(cc.easeQuarticActionOut()); + var move_ease_out_back = move_ease_out.reverse(); + + var delay = cc.delayTime(0.25); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()); + var seq2 = cc.sequence(move_ease_in, delay.clone(), move_ease_in_back, delay.clone()); + var seq3 = cc.sequence(move_ease_out, delay.clone(), move_ease_out_back, delay.clone()); + + this._grossini.runAction( seq1.repeatForever() ); + this._tamara.runAction( seq2.repeatForever() ); + this._kathia.runAction( seq3.repeatForever() ); + //----end17---- + }, + title: function(){ + return "SpriteEaseQuartic action"; + } +}); + +// +// SpriteEaseQuarticInOut +// +var SpriteEaseQuarticInOutTest = EaseSpriteDemo.extend({ + onEnter: function(){ + this._super(); + //----start18----onEnter + + var move = cc.moveBy(3, cc.p(winSize.width - 130, 0)); + var move_back = move.reverse(); + + //var move_ease = cc.EaseQuarticActionInOut.create(move.clone() ); + var move_ease = move.clone().easing(cc.easeQuarticActionInOut()); + var move_ease_back = move_ease.reverse(); + + var delay = cc.delayTime(0.25); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()); + var seq2 = cc.sequence(move_ease, delay.clone(), move_ease_back, delay.clone()); + + this.positionForTwo(); + + this._grossini.runAction( seq1.repeatForever() ); + this._tamara.runAction( seq2.repeatForever() ); + + //----end18---- + }, + title: function(){ + return "SpriteEaseQuarticInOut action"; + } +}); + +// +// SpriteEaseQuintic +// +var SpriteEaseQuinticTest = EaseSpriteDemo.extend({ + onEnter: function(){ + this._super(); + //----start19----onEnter + + var move = cc.moveBy(3, cc.p(winSize.width - 130, 0)); + var move_back = move.reverse(); + + //var move_ease_in = cc.EaseQuinticActionIn.create(move.clone() ); + var move_ease_in = move.clone().easing(cc.easeQuinticActionIn()); + var move_ease_in_back = move_ease_in.reverse(); + + //var move_ease_out = cc.EaseQuinticActionOut.create(move.clone() ); + var move_ease_out = move.clone().easing(cc.easeQuinticActionOut()); + var move_ease_out_back = move_ease_out.reverse(); + + var delay = cc.delayTime(0.25); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()); + var seq2 = cc.sequence(move_ease_in, delay.clone(), move_ease_in_back, delay.clone()); + var seq3 = cc.sequence(move_ease_out, delay.clone(), move_ease_out_back, delay.clone()); + + this._grossini.runAction( seq1.repeatForever() ); + this._tamara.runAction( seq2.repeatForever() ); + this._kathia.runAction( seq3.repeatForever() ); + + + //----end19---- + }, + title: function(){ + return "SpriteEaseQuintic action"; + } +}); + +// +// SpriteEaseQuinticInOut +// +var SpriteEaseQuinticInOutTest = EaseSpriteDemo.extend({ + onEnter: function(){ + this._super(); + //----start20----onEnter + + var move = cc.moveBy(3, cc.p(winSize.width - 130, 0)); + var move_back = move.reverse(); + + //var move_ease = cc.EaseQuinticActionInOut.create(move.clone() ); + var move_ease = move.clone().easing(cc.easeQuinticActionInOut()); + var move_ease_back = move_ease.reverse(); + + var delay = cc.delayTime(0.25); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()); + var seq2 = cc.sequence(move_ease, delay.clone(), move_ease_back, delay.clone()); + + this.positionForTwo(); + + this._grossini.runAction( seq1.repeatForever() ); + this._tamara.runAction( seq2.repeatForever() ); + + //----end20---- + }, + title: function(){ + return "SpriteEaseQuinticInOut action"; + } +}); + +// +// SpriteEaseCircle +// +var SpriteEaseCircleTest = EaseSpriteDemo.extend({ + onEnter: function(){ + this._super(); + //----start21----onEnter + + var move = cc.moveBy(3, cc.p(winSize.width - 130, 0)); + var move_back = move.reverse(); + + //var move_ease_in = cc.EaseCircleActionIn.create(move.clone() ); + var move_ease_in = move.clone().easing(cc.easeCircleActionIn()); + var move_ease_in_back = move_ease_in.reverse(); + + //var move_ease_out = cc.EaseCircleActionOut.create(move.clone() ); + var move_ease_out = move.clone().easing(cc.easeCircleActionOut()); + var move_ease_out_back = move_ease_out.reverse(); + + var delay = cc.delayTime(0.25); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()); + var seq2 = cc.sequence(move_ease_in, delay.clone(), move_ease_in_back, delay.clone()); + var seq3 = cc.sequence(move_ease_out, delay.clone(), move_ease_out_back, delay.clone()); + + this._grossini.runAction( seq1.repeatForever() ); + this._tamara.runAction( seq2.repeatForever() ); + this._kathia.runAction( seq3.repeatForever() ); + + //----end21---- + }, + title: function(){ + return "SpriteEaseCircle action"; + } +}); + +// +// SpriteEaseCircleInOut +// +var SpriteEaseCircleInOutTest = EaseSpriteDemo.extend({ + onEnter: function(){ + this._super(); + //----start22----onEnter + + var move = cc.moveBy(3, cc.p(winSize.width - 130, 0)); + var move_back = move.reverse(); + + //var move_ease = cc.EaseCircleActionInOut.create(move.clone() ); + var move_ease = move.clone().easing(cc.easeCircleActionInOut()); + var move_ease_back = move_ease.reverse(); + + var delay = cc.delayTime(0.25); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()); + var seq2 = cc.sequence(move_ease, delay.clone(), move_ease_back, delay.clone()); + + this.positionForTwo(); + + this._grossini.runAction( seq1.repeatForever() ); + this._tamara.runAction( seq2.repeatForever() ); + + //----end22---- + }, + title: function(){ + return "SpriteEaseCircleInOut action"; + } +}); + +// +// SpriteEaseCubic +// +var SpriteEaseCubicTest = EaseSpriteDemo.extend({ + onEnter: function(){ + this._super(); + //----start23----onEnter + + var move = cc.moveBy(3, cc.p(winSize.width - 130, 0)); + var move_back = move.reverse(); + + //var move_ease_in = cc.EaseCubicActionIn.create(move.clone() ); + var move_ease_in = move.clone().easing(cc.easeCubicActionIn()); + var move_ease_in_back = move_ease_in.reverse(); + + //var move_ease_out = cc.EaseCubicActionOut.create(move.clone() ); + var move_ease_out = move.clone().easing(cc.easeCubicActionOut()); + var move_ease_out_back = move_ease_out.reverse(); + + var delay = cc.delayTime(0.25); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()); + var seq2 = cc.sequence(move_ease_in, delay.clone(), move_ease_in_back, delay.clone()); + var seq3 = cc.sequence(move_ease_out, delay.clone(), move_ease_out_back, delay.clone()); + + this._grossini.runAction( seq1.repeatForever() ); + this._tamara.runAction( seq2.repeatForever() ); + this._kathia.runAction( seq3.repeatForever() ); + + + //----end23---- + }, + title: function(){ + return "SpriteEaseCubic action"; + } +}); + +// +// SpriteEaseCubicInOut +// +var SpriteEaseCubicInOutTest = EaseSpriteDemo.extend({ + onEnter: function(){ + this._super(); + //----start24----onEnter + + var move = cc.moveBy(3, cc.p(winSize.width - 130, 0)); + var move_back = move.reverse(); + + //var move_ease = cc.EaseCubicActionInOut.create(move.clone() ); + var move_ease = move.clone().easing(cc.easeCubicActionInOut()); + var move_ease_back = move_ease.reverse(); + + var delay = cc.delayTime(0.25); + + var seq1 = cc.sequence(move, delay, move_back, delay.clone()); + var seq2 = cc.sequence(move_ease, delay.clone(), move_ease_back, delay.clone()); + + this.positionForTwo(); + + this._grossini.runAction( seq1.repeatForever() ); + this._tamara.runAction( seq2.repeatForever() ); + + + //----end24---- + }, + title: function(){ + return "SpriteEaseCubicInOut action"; + } +}); + +// +// Flow control +// +var arrayOfEaseActionsTest = [ + SpriteEase, + SpriteEaseInOut, + SpriteEaseExponential, + SpriteEaseExponentialInOut, + SpriteEaseSine, + SpriteEaseSineInOut, + SpriteEaseElastic, + SpriteEaseElasticInOut, + SpriteEaseBounce, + SpriteEaseBounceInOut, + SpriteEaseBack, + SpriteEaseBackInOut, + SpeedTest, + SchedulerTest, + SpriteEaseBezierTest, + SpriteEaseQuadraticTest, + SpriteEaseQuadraticInOutTest, + SpriteEaseQuarticTest, + SpriteEaseQuarticInOutTest, + SpriteEaseQuinticTest, + SpriteEaseQuinticInOutTest, + SpriteEaseCircleTest, + SpriteEaseCircleInOutTest, + SpriteEaseCubicTest, + SpriteEaseCubicInOutTest +]; + +var nextEaseActionsTest = function () { + easeActionsTestIdx++; + easeActionsTestIdx = easeActionsTestIdx % arrayOfEaseActionsTest.length; + + if(window.sideIndexBar){ + easeActionsTestIdx = window.sideIndexBar.changeTest(easeActionsTestIdx, 10); + } + + return new arrayOfEaseActionsTest[easeActionsTestIdx](); +}; +var previousEaseActionsTest = function () { + easeActionsTestIdx--; + if (easeActionsTestIdx < 0) + easeActionsTestIdx += arrayOfEaseActionsTest.length; + + if(window.sideIndexBar){ + easeActionsTestIdx = window.sideIndexBar.changeTest(easeActionsTestIdx, 10); + } + + return new arrayOfEaseActionsTest[easeActionsTestIdx](); +}; +var restartEaseActionsTest = function () { + return new arrayOfEaseActionsTest[easeActionsTestIdx](); +}; diff --git a/tests/js-tests/src/EffectsAdvancedTest/EffectsAdvancedTest.js b/tests/js-tests/src/EffectsAdvancedTest/EffectsAdvancedTest.js new file mode 100644 index 0000000000..580096ddc0 --- /dev/null +++ b/tests/js-tests/src/EffectsAdvancedTest/EffectsAdvancedTest.js @@ -0,0 +1,406 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 EffectsAdvancedTest = EffectsAdvancedTest || {}; + +EffectsAdvancedTest.TAG_TEXTLAYER = 1; + +EffectsAdvancedTest.TAG_SPRITE1 = 1; + +EffectsAdvancedTest.TAG_SPRITE2 = 2; + +EffectsAdvancedTest.TAG_BACKGROUND = 1; + +EffectsAdvancedTest.TAG_LABEL = 2; + +EffectsAdvancedTest.IDC_NEXT = 100; + +EffectsAdvancedTest.IDC_BACK = 101; + +EffectsAdvancedTest.IDC_RESTART = 102; + +var sceneIndex = -1; + +var EffectAdvanceTextLayer = cc.Layer.extend({ + _atlas:null, + _title:null, + rootNode: null, + + ctor:function() { + this._super(); + this.init(); + }, + + onEnter:function () { + this._super(); + + // back gradient + this.rootNode = new cc.LayerGradient(cc.color(0, 0, 0, 255), cc.color(98, 99, 117, 255)); + var nodeGrid = new cc.NodeGrid(); + nodeGrid.addChild(this.rootNode); + this.addChild(nodeGrid, 0, EffectsAdvancedTest.TAG_BACKGROUND); + + var bg = new cc.Sprite(s_back3); + //this.addChild(bg, 0, EffectsAdvancedTest.TAG_BACKGROUND); + this.rootNode.addChild(bg); + bg.x = winSize.width / 2; + bg.y = winSize.height / 2; + + var grossini = new cc.Sprite(s_pathSister2); + var grossiniGrid = new cc.NodeGrid(); + grossiniGrid.addChild(grossini); + this.rootNode.addChild(grossiniGrid, 1, EffectsAdvancedTest.TAG_SPRITE1); + grossini.x = winSize.width / 3; + grossini.y = winSize.height / 2; + var sc = cc.scaleBy(2, 5); + var sc_back = sc.reverse(); + grossini.runAction(cc.sequence(sc, sc_back).repeatForever()); + + var tamara = new cc.Sprite(s_pathSister1); + var tamaraGrid = new cc.NodeGrid(); + tamaraGrid.addChild(tamara); + this.rootNode.addChild(tamaraGrid, 1, EffectsAdvancedTest.TAG_SPRITE2); + tamara.x = winSize.width * 2 / 3; + tamara.y = winSize.height / 2; + var sc2 = cc.scaleBy(2, 5); + var sc2_back = sc2.reverse(); + tamara.runAction(cc.sequence(sc2, sc2_back).repeatForever()); + + var label = new cc.LabelTTF(this.title(), "Arial", 28); + label.x = cc.visibleRect.center.x; + label.y = cc.visibleRect.top.y - 80; + this.addChild(label); + label.tag = EffectsAdvancedTest.TAG_LABEL; + + var strSubtitle = this.subtitle(); + if (strSubtitle != "") { + var subtitleLabel = new cc.LabelTTF(strSubtitle, "Arial", 16); + this.addChild(subtitleLabel, 101); + subtitleLabel.x = cc.visibleRect.center.x; + subtitleLabel.y = cc.visibleRect.top.y - 80; + } + + var item1 = new cc.MenuItemImage(s_pathB1, s_pathB2, this.backCallback, this); + var item2 = new cc.MenuItemImage(s_pathR1, s_pathR2, this.restartCallback, this); + var item3 = new cc.MenuItemImage(s_pathF1, s_pathF2, this.nextCallback, this); + + var menu = new cc.Menu(item1, item2, item3); + + menu.x = 0; + menu.y = 0; + var centerx = cc.visibleRect.center.x, bottomy = cc.visibleRect.bottom.y; + item1.x = centerx - item2.width * 2; + item1.y = bottomy + item2.height / 2; + item2.x = centerx; + item2.y = bottomy + item2.height / 2; + item3.x = centerx + item2.width * 2; + item3.y = bottomy + item2.height / 2; + + this.addChild(menu, 1); + }, + + title:function () { + return "No title"; + }, + + subtitle:function () { + return ""; + }, + + restartCallback:function (sender) { + var scene = new EffectAdvanceScene(); + scene.addChild(restartEffectAdvanceAction()); + cc.director.runScene(scene); + }, + + nextCallback:function (sender) { + var scene = new EffectAdvanceScene(); + scene.addChild(nextEffectAdvanceAction()); + cc.director.runScene(scene); + }, + + backCallback:function (sender) { + var scene = new EffectAdvanceScene(); + scene.addChild(backEffectAdvanceAction()); + cc.director.runScene(scene); + } +}); + +var Effect1 = EffectAdvanceTextLayer.extend({ + title:function () { + return "Lens + Waves3d and OrbitCamera"; + }, + + onEnter:function () { + this._super(); + + var target = this.getChildByTag(EffectsAdvancedTest.TAG_BACKGROUND); + + // To reuse a grid the grid size and the grid type must be the same. + // in this case: + // Lens3D is Grid3D and it's size is (15,10) + // Waves3D is Grid3D and it's size is (15,10) + var size = cc.director.getWinSize(); + var lens = cc.lens3D(0.0, cc.size(15, 10), cc.p(size.width / 2, size.height / 2), 240); + var waves = cc.waves3D(10, cc.size(15, 10), 18, 15); + + var reuse = cc.reuseGrid(1); + var delay = cc.delayTime(8); + + var orbit = cc.orbitCamera(5, 1, 2, 0, 180, 0, -90); + var orbit_back = orbit.reverse(); + + target.runAction(cc.sequence(orbit, orbit_back).repeatForever()); + target.runAction(cc.sequence(lens, delay, reuse, waves)); + } +}); + +var Effect2 = EffectAdvanceTextLayer.extend({ + title:function () { + return "ShakyTiles + ShuffleTiles + TurnOffTiles"; + }, + + onEnter:function () { + this._super(); + var target = this.getChildByTag(EffectsAdvancedTest.TAG_BACKGROUND); + + // To reuse a grid the grid size and the grid type must be the same. + // in this case: + // ShakyTiles is TiledGrid3D and it's size is (15,10) + // Shuffletiles is TiledGrid3D and it's size is (15,10) + // TurnOfftiles is TiledGrid3D and it's size is (15,10) + var shaky = cc.shakyTiles3D(5, cc.size(15, 10), 4, false); + var shuffle = cc.shuffleTiles(0, cc.size(15, 10), 3); + var turnoff = cc.turnOffTiles(0, cc.size(15, 10), 3); + var turnon = turnoff.reverse(); + + // reuse 2 times: + // 1 for shuffle + // 2 for turn off + // turnon tiles will use a new grid + var reuse = cc.reuseGrid(2); + var delay = cc.delayTime(1); + + target.runAction(cc.sequence(shaky, delay, reuse, shuffle, delay.clone(), turnoff, turnon)); + } +}); + +var Effect3 = EffectAdvanceTextLayer.extend({ + title:function () { + return "Effects on 2 sprites"; + }, + + onEnter:function () { + this._super(); + + var bg = this.getChildByTag(EffectsAdvancedTest.TAG_BACKGROUND); + var target1 = this.rootNode.getChildByTag(EffectsAdvancedTest.TAG_SPRITE1); + var target2 = this.rootNode.getChildByTag(EffectsAdvancedTest.TAG_SPRITE2); + + var waves = cc.waves(5, cc.size(15, 10), 5, 20, true, false); + var shaky = cc.shaky3D(5, cc.size(15, 10), 4, false); + + target1.runAction(waves.repeatForever()); + target2.runAction(shaky.repeatForever()); + + // moving background. Testing issue #244 + var move = cc.moveBy(3, cc.p(200, 0)); + bg.runAction(cc.sequence(move, move.reverse()).repeatForever()); + } +}); + +var Lens3DTarget = cc.Node.extend({ + _lens3D:null, + + ctor:function() { + this._super(); + this.init(); + }, + + update: function(dt) { + this._lens3D.x = this.x; + this._lens3D.y = this.y; + }, + + onEnter: function() { + cc.log("Lens3DTarget onEnter"); + this.scheduleUpdate(); + }, + + onExit: function() { + cc.log("Lens3DTarget onExit"); + this.unscheduleUpdate(); + } + +}); + +Lens3DTarget.create = function (action) { + var target = new Lens3DTarget(); + target._lens3D = action; + return target; +}; + +var Effect4 = EffectAdvanceTextLayer.extend({ + title:function () { + return "Jumpy Lens3D"; + }, + + onEnter:function () { + this._super(); + + var lens = cc.lens3D(10, cc.size(32, 24), cc.p(100, 180), 150); + var move = cc.jumpBy(5, cc.p(380, 0), 100, 4); + var move_back = move.reverse(); + var seq = cc.sequence(move, move_back); + + /* In cocos2d-iphone, the type of action's target is 'id', so it supports using the instance of 'CCLens3D' as its target. + While in cocos2d-x, the target of action only supports CCNode or its subclass, + so we make an encapsulation for CCLens3D to achieve that. + */ + var director = cc.director; + var target = Lens3DTarget.create(lens); + // Please make sure the target been added to its parent. + this.addChild(target); + + director.getActionManager().addAction(seq, target, false); + this.runAction(cc.sequence(lens, cc.callFunc( + function(sender) { + sender.removeChild(target, true); + } + ))); + } +}); + +var Effect5 = EffectAdvanceTextLayer.extend({ + title:function () { + return "Test Stop-Copy-Restar"; + }, + + onEnter:function () { + this._super(); + + var effect = cc.liquid(2, cc.size(32, 24), 1, 20); + var stopEffect = cc.sequence(effect, cc.delayTime(2), cc.stopGrid()); + + var bg = this.getChildByTag(EffectsAdvancedTest.TAG_BACKGROUND); + bg.runAction(stopEffect); + }, + + onExit:function () { + this._super(); + cc.director.setProjection(cc.Director.PROJECTION_3D); + } +}); + +var Issue631 = EffectAdvanceTextLayer.extend({ + title:function () { + return "Testing Opacity"; + }, + + subtitle:function () { + return "Effect image should be 100% opaque. Testing issue #631"; + }, + + onEnter:function () { + this._super(); + + var effect = cc.sequence(cc.delayTime(2.0), cc.shaky3D(5.0, cc.size(5, 5), 16, false)); + + // cleanup + var bg = this.getChildByTag(EffectsAdvancedTest.TAG_BACKGROUND); + this.removeChild(bg, true); + + // background + var layer = new cc.LayerColor(cc.color(255, 0, 0, 255)); + this.addChild(layer, -10); + var sprite = new cc.Sprite(s_pathGrossini); + sprite.x = 50; + sprite.y = 80; + layer.addChild(sprite, 10); + + // foreground + var layer2 = new cc.LayerColor(cc.color(0, 255, 0, 255)); + var fog = new cc.Sprite(s_pathFog); + + fog.setBlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA); + var nodeGrid = new cc.NodeGrid(); + layer2.addChild(fog, 1); + nodeGrid.addChild(layer2); + this.addChild(nodeGrid, 1); + + nodeGrid.runAction(effect.repeatForever()); + } +}); + +var arrayOfEffectsAdvancedTest = [ + Effect3, + Effect2, + Effect1, + Effect5, + Issue631 +]; + +if (!cc.sys.isNative) + arrayOfEffectsAdvancedTest.push(Effect4); + +var nextEffectAdvanceAction = function () { + sceneIndex++; + sceneIndex = sceneIndex % arrayOfEffectsAdvancedTest.length; + + if(window.sideIndexBar){ + sceneIndex = window.sideIndexBar.changeTest(sceneIndex, 15); + } + + return new arrayOfEffectsAdvancedTest[sceneIndex](); +}; + +var backEffectAdvanceAction = function () { + sceneIndex--; + if (sceneIndex < 0) + sceneIndex += arrayOfEffectsAdvancedTest.length; + + if(window.sideIndexBar){ + sceneIndex = window.sideIndexBar.changeTest(sceneIndex, 15); + } + + return new arrayOfEffectsAdvancedTest[sceneIndex](); +}; + +var restartEffectAdvanceAction = function () { + return new arrayOfEffectsAdvancedTest[sceneIndex](); +}; + +var EffectAdvanceScene = TestScene.extend({ + runThisTest:function () { + sceneIndex = -1; + var pLayer = nextEffectAdvanceAction(); + this.addChild(pLayer); + cc.director.runScene(this); + } +}); + + + diff --git a/tests/js-tests/src/EffectsTest/EffectsTest.js b/tests/js-tests/src/EffectsTest/EffectsTest.js new file mode 100644 index 0000000000..9ffde46d48 --- /dev/null +++ b/tests/js-tests/src/EffectsTest/EffectsTest.js @@ -0,0 +1,484 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + 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. + ****************************************************************************/ + + +var effectsTestSceneIdx = -1; + +// +// Base Layer +// + +var EffecstsBaseLayer = BaseTestLayer.extend({ + + code:function () { + return ""; + }, + + // callbacks + onRestartCallback:function (sender) { + var s = new EffectsTestScene(); + s.addChild(restartEffectsTest()); + director.runScene(s); + }, + onNextCallback:function (sender) { + var s = new EffectsTestScene(); + s.addChild(nextEffectsTest()); + //director.runScene(cc.TransitionZoomFlipX.create(5, s)); + director.runScene(s); + }, + onBackCallback:function (sender) { + var s = new EffectsTestScene(); + s.addChild(previousEffectsTest()); + director.runScene(s); + }, + onEnter:function () { + this._super(); + + var node = new cc.Node(); + var nodeGrid = new cc.NodeGrid(); + nodeGrid.addChild(node); + nodeGrid.runAction( this.getEffect(3) ); + this.addChild( nodeGrid ); + + // back gradient + var gradient = new cc.LayerGradient( cc.color(0,0,0,255), cc.color(98,99,117,255)); + node.addChild( gradient ); + + // back image + var bg = new cc.Sprite(s_back3); + bg.x = winSize.width/2; + bg.y = winSize.height/2; + node.addChild( bg ); + + var sister1 = new cc.Sprite(s_pathSister1); + sister1.x = winSize.width/3; + sister1.y = winSize.height/2; + node.addChild( sister1, 1 ); + + var sister2 = new cc.Sprite(s_pathSister2); + sister2.x = winSize.width*2/3; + sister2.y = winSize.height/2; + node.addChild( sister2, 1 ); + + var sc = cc.scaleBy(2, 5); + var sc_back = sc.reverse(); + var seq = cc.sequence( sc, sc_back ); + var repeat = seq.repeatForever(); + + sister1.runAction( repeat ); + sister2.runAction( repeat.clone() ); + }, + + getEffect:function(duration) { + // override me + return cc.moveBy(2, cc.p(10,10) ); + }, + + // automation + numberOfPendingTests:function() { + return ( (arrayOfEffectsTest.length-1) - effectsTestSceneIdx ); + }, + + getTestNumber:function() { + return effectsTestSceneIdx; + } + +}); + +//------------------------------------------------------------------ +// +// Tests +// +//------------------------------------------------------------------ +var Shaky3DTest = EffecstsBaseLayer.extend({ + title:function () { + return "Shaky 3D"; + }, + code:function () { + return "a = cc.shaky3D(duration, gridSize, range, shakeZ)"; + }, + getEffect:function(duration) { + return cc.shaky3D( duration, cc.size(15,10), 5, false ); + } +}); + +var Waves3DTest = EffecstsBaseLayer.extend({ + title:function () { + return "Waves 3D"; + }, + code:function () { + return "a = cc.waves3D(duration, gridSize, range, shakeZ)"; + }, + getEffect:function(duration) { + return cc.waves3D(duration, cc.size(15,10), 5, 40 ); + } +}); + +var FlipXTest = EffecstsBaseLayer.extend({ + title:function () { + return "FlipX3D"; + }, + code:function () { + return "a = cc.flipX3D(duration )"; + }, + getEffect:function(duration) { + var a = cc.flipX3D(duration); + var delay = cc.delayTime(2); + var r = a.reverse(); + return cc.sequence( a, delay, r ); + } +}); + +var FlipYTest = EffecstsBaseLayer.extend({ + title:function () { + return "FlipY3D"; + }, + code:function () { + return "a = cc.flipY3D(duration )"; + }, + getEffect:function(duration) { + var a = cc.flipY3D(duration ); + var delay = cc.delayTime(2); + var r = a.reverse(); + return cc.sequence( a, delay, r ); + } +}); + +var Lens3DTest = EffecstsBaseLayer.extend({ + title:function () { + return "Lens3D"; + }, + code:function () { + return "a = cc.lens3D(duration, gridSize, position, radius)"; + }, + getEffect:function(duration) { + return cc.lens3D( duration, cc.size(15,10), cc.p(winSize.width/2, winSize.height/2), 240); + } +}); + +var Ripple3DTest = EffecstsBaseLayer.extend({ + title:function () { + return "Ripple3D"; + }, + code:function () { + return "a = cc.ripple3D(duration, gridSize, position, radius, waves, amplitude)"; + }, + getEffect:function(duration) { + return cc.ripple3D( duration, cc.size(32,24), cc.p(winSize.width/2, winSize.height/2), 240, 4, 160); + } +}); + +var LiquidTest = EffecstsBaseLayer.extend({ + title:function () { + return "Liquid"; + }, + code:function () { + return "a = cc.liquid(duration, gridSize, waves, amplitude)"; + }, + getEffect:function(duration) { + return cc.liquid( duration, cc.size(16,12), 4, 20); + } +}); + +var WavesTest = EffecstsBaseLayer.extend({ + title:function () { + return "Waves"; + }, + code:function () { + return "a = cc.waves(duration, gridSize, waves, amplitude, horizontal, vertical)"; + }, + getEffect:function(duration) { + return cc.waves( duration, cc.size(16,12), 4, 20, true, true); + } +}); + +var TwirlTest = EffecstsBaseLayer.extend({ + title:function () { + return "Twirl"; + }, + code:function () { + return "a = cc.twirl(duration, gridSize, position, twirls, amplitude)"; + }, + getEffect:function(duration) { + return cc.twirl( duration, cc.size(12,8), cc.p(winSize.width/2, winSize.height/2), 1, 2.5); + } +}); + +var ShakyTiles3DTest = EffecstsBaseLayer.extend({ + title:function () { + return "ShakyTiles3D"; + }, + code:function () { + return "a = cc.shakyTiles3D(duration, gridSize, range, shakeZ)"; + }, + getEffect:function(duration) { + return cc.shakyTiles3D( duration, cc.size(16,12), 5, false); + } +}); + +var ShatteredTiles3DTest = EffecstsBaseLayer.extend({ + title:function () { + return "ShatteredTiles3D"; + }, + code:function () { + return "a = cc.shatteredTiles3D(duration, gridSize, range, shatterZ)"; + }, + getEffect:function(duration) { + return cc.shatteredTiles3D( duration, cc.size(16,12), 5, false); + } +}); + +var ShuffleTilesTest = EffecstsBaseLayer.extend({ + title:function () { + return "ShuffleTiles"; + }, + code:function () { + return "a = cc.shuffleTiles(duration, gridSize, seed)"; + }, + getEffect:function(duration) { + var action = cc.shuffleTiles( duration, cc.size(16,12), 25); + var delay = cc.delayTime(2); + var back = action.reverse(); + var seq = cc.sequence( action, delay, back); + return seq; + } +}); + +var FadeOutTRTilesTest = EffecstsBaseLayer.extend({ + title:function () { + return "FadeOutTRTilesTest"; + }, + code:function () { + return "a = cc.fadeOutTRTiles(duration, gridSize)"; + }, + getEffect:function(duration) { + var action = cc.fadeOutTRTiles( duration, cc.size(16,12)); + var delay = cc.delayTime(0.5); + var back = action.reverse(); + var seq = cc.sequence( action, delay, back); + return seq; + } +}); + +var FadeOutBLTilesTest = EffecstsBaseLayer.extend({ + title:function () { + return "FadeOutBLTilesTest"; + }, + code:function () { + return "a = cc.fadeOutBLTiles(duration, gridSize)"; + }, + getEffect:function(duration) { + var action = cc.fadeOutBLTiles( duration, cc.size(16,12)); + var delay = cc.delayTime(0.5); + var back = action.reverse(); + var seq = cc.sequence( action, delay, back); + return seq; + } +}); + +var FadeOutUpTilesTest = EffecstsBaseLayer.extend({ + title:function () { + return "FadeOutUpTilesTest"; + }, + code:function () { + return "a = cc.fadeOutUpTiles(duration, gridSize)"; + }, + getEffect:function(duration) { + var action = cc.fadeOutUpTiles( duration, cc.size(16,12)); + var delay = cc.delayTime(0.5); + var back = action.reverse(); + var seq = cc.sequence( action, delay, back); + return seq; + } +}); + +var FadeOutDownTilesTest = EffecstsBaseLayer.extend({ + title:function () { + return "FadeOutDownTilesTest"; + }, + code:function () { + return "a = cc.fadeOutDownTiles(duration, gridSize)"; + }, + getEffect:function(duration) { + var action = cc.fadeOutDownTiles( duration, cc.size(16,12)); + var delay = cc.delayTime(0.5); + var back = action.reverse(); + var seq = cc.sequence( action, delay, back); + return seq; + } +}); + +var TurnOffTilesTest = EffecstsBaseLayer.extend({ + title:function () { + return "TurnOffTiles"; + }, + code:function () { + return "a = cc.turnOffTiles(duration, gridSize, seed)"; + }, + getEffect:function(duration) { + var action = cc.turnOffTiles( duration, cc.size(48,32), 25); + var delay = cc.delayTime(0.5); + var back = action.reverse(); + var seq = cc.sequence( action, delay, back); + return seq; + } +}); + +var WavesTiles3DTest = EffecstsBaseLayer.extend({ + title:function () { + return "WavesTiles3D"; + }, + code:function () { + return "a = cc.wavesTiles3D(duration, gridSize, waves, amplitude)"; + }, + getEffect:function(duration) { + var action = cc.wavesTiles3D( duration, cc.size(16,12), 4, 120); + return action; + } +}); + + +var JumpTiles3DTest = EffecstsBaseLayer.extend({ + title:function () { + return "JumpTiles3D"; + }, + code:function () { + return "a = cc.jumpTiles3D(duration, gridSize, jumps, amplitude)"; + }, + getEffect:function(duration) { + var action = cc.jumpTiles3D(duration, cc.size(16,12), 2, 30); + return action; + } +}); + +var SplitRowsTest = EffecstsBaseLayer.extend({ + title:function () { + return "SplitRows"; + }, + code:function () { + return "a = cc.splitRows(duration, rows)"; + }, + getEffect:function(duration) { + var action = cc.splitRows(duration, 9); + var delay = cc.delayTime(0.5); + var back = action.reverse(); + var seq = cc.sequence( action, delay, back); + return seq; + } +}); + +var SplitColsTest = EffecstsBaseLayer.extend({ + title:function () { + return "SplitCols"; + }, + code:function () { + return "a = cc.splitCols(duration, cols)"; + }, + getEffect:function(duration) { + var action = cc.splitCols(duration, 9); + var delay = cc.delayTime(0.5); + var back = action.reverse(); + var seq = cc.sequence( action, delay, back); + return seq; + } +}); + +var PageTurn3DTest = EffecstsBaseLayer.extend({ + title:function () { + return "PageTurn3D"; + }, + code:function () { + return "a = cc.pageTurn3D(duration, gridSize)"; + }, + getEffect:function(duration) { + var action = cc.pageTurn3D(duration, cc.size(15,10)); + return action; + } +}); + +// +// Order of tests +// +var EffectsTestScene = TestScene.extend({ + runThisTest:function (num) { + effectsTestSceneIdx = (num || num == 0) ? (num - 1) : -1; + var layer = nextEffectsTest(); + this.addChild(layer); + + director.runScene(this); + } +}); + +// +// Flow control +// +var arrayOfEffectsTest = [ + Shaky3DTest, + Waves3DTest, + FlipXTest, + FlipYTest, + Lens3DTest, + Ripple3DTest, + LiquidTest, + WavesTest, + TwirlTest, + ShakyTiles3DTest, + ShatteredTiles3DTest, + ShuffleTilesTest, + FadeOutTRTilesTest, + FadeOutBLTilesTest, + FadeOutUpTilesTest, + FadeOutDownTilesTest, + TurnOffTilesTest, + WavesTiles3DTest, + JumpTiles3DTest, + SplitRowsTest, + SplitColsTest, + PageTurn3DTest +]; + +var nextEffectsTest = function () { + effectsTestSceneIdx++; + effectsTestSceneIdx = effectsTestSceneIdx % arrayOfEffectsTest.length; + + if(window.sideIndexBar){ + effectsTestSceneIdx = window.sideIndexBar.changeTest(effectsTestSceneIdx, 14); + } + + return new arrayOfEffectsTest[effectsTestSceneIdx](); +}; +var previousEffectsTest = function () { + effectsTestSceneIdx--; + if (effectsTestSceneIdx < 0) + effectsTestSceneIdx += arrayOfEffectsTest.length; + + if(window.sideIndexBar){ + effectsTestSceneIdx = window.sideIndexBar.changeTest(effectsTestSceneIdx, 14); + } + + return new arrayOfEffectsTest[effectsTestSceneIdx](); +}; +var restartEffectsTest = function () { + return new arrayOfEffectsTest[effectsTestSceneIdx](); +}; diff --git a/tests/js-tests/src/EventTest/EventTest.js b/tests/js-tests/src/EventTest/EventTest.js new file mode 100644 index 0000000000..e89b13c1c2 --- /dev/null +++ b/tests/js-tests/src/EventTest/EventTest.js @@ -0,0 +1,505 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + 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. + ****************************************************************************/ + +var TEXT_INPUT_FONT_NAME = "Thonburi"; +var TEXT_INPUT_FONT_SIZE = 36; + +var sceneIdx = -1; + +/** + @brief EventTest for retain prev, reset, next, main menu buttons. + */ +var EventTest = cc.Layer.extend({ + ctor:function() { + this._super(); + this.init(); + }, + + restartCallback:function (sender) { + var s = new EventTestScene(); + s.addChild(restartEventsTest()); + director.runScene(s); + }, + nextCallback:function (sender) { + var s = new EventTestScene(); + s.addChild(nextEventsTest()); + director.runScene(s); + }, + backCallback:function (sender) { + var s = new EventTestScene(); + s.addChild(previousEventsTest()); + director.runScene(s); + }, + + title:function () { + return "Event Test"; + }, + + onEnter:function () { + this._super(); + + var s = director.getWinSize(); + + var label = new cc.LabelTTF(this.title(), "Arial", 24); + this.addChild(label); + label.x = s.width / 2; + label.y = s.height - 50; + + var subTitle = this.subtitle(); + if (subTitle && subTitle !== "") { + var l = new cc.LabelTTF(subTitle, "Thonburi", 16); + this.addChild(l, 1); + l.x = s.width / 2; + l.y = s.height - 80; + } + + var item1 = new cc.MenuItemImage(s_pathB1, s_pathB2, this.backCallback, this); + var item2 = new cc.MenuItemImage(s_pathR1, s_pathR2, this.restartCallback, this); + var item3 = new cc.MenuItemImage(s_pathF1, s_pathF2, this.nextCallback, this); + + var menu = new cc.Menu(item1, item2, item3); + menu.x = 0; + menu.y = 0; + item1.x = s.width / 2 - 100; + item1.y = 30; + item2.x = s.width / 2; + item2.y = 30; + item3.x = s.width / 2 + 100; + item3.y = 30; + + this.addChild(menu, 1); + } +}); + +//------------------------------------------------------------------ +// +// OneByOne Touches +// +//------------------------------------------------------------------ +var TouchOneByOneTest = EventTest.extend({ + init:function () { + this._super(); + this.ids = {}; + this.unused_sprites = []; + + if( 'touches' in cc.sys.capabilities ) { + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches: true, + onTouchBegan: this.onTouchBegan, + onTouchMoved: this.onTouchMoved, + onTouchEnded: this.onTouchEnded, + onTouchCancelled: this.onTouchCancelled + }, this); + } else { + cc.log("TOUCH-ONE-BY-ONE test is not supported on desktop"); + } + + for( var i=0; i < 5;i++) { + var sprite = this.sprite = new cc.Sprite(s_pathR2); + this.addChild(sprite,i+10); + sprite.x = 0; + sprite.y = 0; + sprite.scale = 1; + sprite.color = cc.color( Math.random()*200+55, Math.random()*200+55, Math.random()*200+55 ); + this.unused_sprites.push(sprite); + } + }, + subtitle:function () { + return "Touches One by One. Touch the left / right and see console"; + }, + + new_id:function( id, pos) { + var s = this.unused_sprites.pop(); + this.ids[ id ] = s; + s.x = pos.x; + s.y = pos.y; + }, + update_id:function(id, pos) { + var s = this.ids[ id ]; + s.x = pos.x; + s.y = pos.y; + }, + release_id:function(id, pos) { + var s = this.ids[ id ]; + this.ids[ id ] = null; + this.unused_sprites.push( s ); + s.x = 0; + s.y = 0; + }, + + onTouchBegan:function(touch, event) { + var pos = touch.getLocation(); + var id = touch.getID(); + cc.log("onTouchBegan at: " + pos.x + " " + pos.y + " Id:" + id ); + if( pos.x < winSize.width/2) { + event.getCurrentTarget().new_id(id,pos); + return true; + } + return false; + }, + onTouchMoved:function(touch, event) { + var pos = touch.getLocation(); + var id = touch.getID(); + cc.log("onTouchMoved at: " + pos.x + " " + pos.y + " Id:" + id ); + event.getCurrentTarget().update_id(id,pos); + }, + onTouchEnded:function(touch, event) { + var pos = touch.getLocation(); + var id = touch.getID(); + cc.log("onTouchEnded at: " + pos.x + " " + pos.y + " Id:" + id ); + event.getCurrentTarget().release_id(id,pos); + }, + onTouchCancelled:function(touch, event) { + var pos = touch.getLocation(); + var id = touch.getID(); + cc.log("onTouchCancelled at: " + pos.x + " " + pos.y + " Id:" + id ); + event.getCurrentTarget().update_id(id,pos); + } +}); + +//------------------------------------------------------------------ +// +// All At Once Touches +// +//------------------------------------------------------------------ +var TouchAllAtOnce = EventTest.extend({ + init:function () { + this._super(); + + this.ids = {}; + this.unused_sprites = []; + + if( 'touches' in cc.sys.capabilities ) { + // this is the default behavior. No need to set it explicitly. + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesBegan: this.onTouchesBegan, + onTouchesMoved: this.onTouchesMoved, + onTouchesEnded: this.onTouchesEnded, + onTouchesCancelled: this.onTouchesCancelled + }, this); + } else { + cc.log("TOUCHES not supported"); + } + + for( var i=0; i < 5;i++) { + var sprite = this.sprite = new cc.Sprite(s_pathR2); + this.addChild(sprite,i+10); + sprite.x = 0; + sprite.y = 0; + sprite.scale = 1; + sprite.color = cc.color( Math.random()*200+55, Math.random()*200+55, Math.random()*200+55 ); + this.unused_sprites.push(sprite); + } + }, + subtitle:function () { + return "Touches All At Once. Touch and see console"; + }, + + new_id:function( id, pos) { + var s = this.unused_sprites.pop(); + this.ids[ id ] = s; + s.x = pos.x; + s.y = pos.y; + }, + update_id:function(id, pos) { + var s = this.ids[ id ]; + s.x = pos.x; + s.y = pos.y; + }, + release_id:function(id, pos) { + var s = this.ids[ id ]; + this.ids[ id ] = null; + this.unused_sprites.push( s ); + s.x = 0; + s.y = 0; + }, + + onTouchesBegan:function(touches, event) { + var target = event.getCurrentTarget(); + for (var i=0; i < touches.length;i++ ) { + var touch = touches[i]; + var pos = touch.getLocation(); + var id = touch.getID(); + cc.log("Touch #" + i + ". onTouchesBegan at: " + pos.x + " " + pos.y + " Id:" + id); + target.new_id(id,pos); + } + }, + onTouchesMoved:function(touches, event) { + var target = event.getCurrentTarget(); + for (var i=0; i < touches.length;i++ ) { + var touch = touches[i]; + var pos = touch.getLocation(); + var id = touch.getID(); + cc.log("Touch #" + i + ". onTouchesMoved at: " + pos.x + " " + pos.y + " Id:" + id); + target.update_id(id, pos); + } + }, + onTouchesEnded:function(touches, event) { + var target = event.getCurrentTarget(); + for (var i=0; i < touches.length;i++ ) { + var touch = touches[i]; + var pos = touch.getLocation(); + var id = touch.getID(); + cc.log("Touch #" + i + ". onTouchesEnded at: " + pos.x + " " + pos.y + " Id:" + id); + target.release_id(id); + } + }, + onTouchesCancelled:function(touches, event) { + var target = event.getCurrentTarget(); + for (var i=0; i < touches.length;i++ ) { + var touch = touches[i]; + var pos = touch.getLocation(); + var id = touch.getID(); + cc.log("Touch #" + i + ". onTouchesCancelled at: " + pos.x + " " + pos.y + " Id:" + id); + target.release_id(id); + } + } +}); + +//------------------------------------------------------------------ +// +// Accelerometer test +// +//------------------------------------------------------------------ +var AccelerometerTest = EventTest.extend({ + init:function () { + this._super(); + + if( 'accelerometer' in cc.sys.capabilities ) { + // call is called 30 times per second + cc.inputManager.setAccelerometerInterval(1/30); + cc.inputManager.setAccelerometerEnabled(true); + cc.eventManager.addListener({ + event: cc.EventListener.ACCELERATION, + callback: function(accelEvent, event){ + var target = event.getCurrentTarget(); + cc.log('Accel x: '+ accelEvent.x + ' y:' + accelEvent.y + ' z:' + accelEvent.z + ' time:' + accelEvent.timestamp ); + + var w = winSize.width; + var h = winSize.height; + + var x = w * accelEvent.x + w/2; + var y = h * accelEvent.y + h/2; + + // Low pass filter + x = x*0.2 + target.prevX*0.8; + y = y*0.2 + target.prevY*0.8; + + target.prevX = x; + target.prevY = y; + target.sprite.x = x; + target.sprite.y = y ; + } + }, this); + + var sprite = this.sprite = new cc.Sprite(s_pathR2); + this.addChild( sprite ); + sprite.x = winSize.width/2; + sprite.y = winSize.height/2; + + // for low-pass filter + this.prevX = 0; + this.prevY = 0; + } else { + cc.log("ACCELEROMETER not supported"); + } + }, + + onExit: function(){ + this._super(); + if( 'accelerometer' in cc.sys.capabilities ) + cc.inputManager.setAccelerometerEnabled(false); + }, + + subtitle:function () { + return "Accelerometer test. Move device and see console"; + } +}); + +//------------------------------------------------------------------ +// +// Mouse test +// +//------------------------------------------------------------------ +var MouseTest = EventTest.extend({ + init:function () { + this._super(); + var sprite = this.sprite = new cc.Sprite(s_pathR2); + this.addChild(sprite); + sprite.x = 0; + sprite.y = 0; + sprite.scale = 1; + sprite.color = cc.color(Math.random()*200+55, Math.random()*200+55, Math.random()*200+55); + + if( 'mouse' in cc.sys.capabilities ) { + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseDown: function(event){ + var pos = event.getLocation(), target = event.getCurrentTarget(); + if(event.getButton() === cc.EventMouse.BUTTON_RIGHT) + cc.log("onRightMouseDown at: " + pos.x + " " + pos.y ); + else if(event.getButton() === cc.EventMouse.BUTTON_LEFT) + cc.log("onLeftMouseDown at: " + pos.x + " " + pos.y ); + target.sprite.x = pos.x; + target.sprite.y = pos.y; + }, + onMouseMove: function(event){ + var pos = event.getLocation(), target = event.getCurrentTarget(); + cc.log("onMouseMove at: " + pos.x + " " + pos.y ); + target.sprite.x = pos.x; + target.sprite.y = pos.y; + }, + onMouseUp: function(event){ + var pos = event.getLocation(), target = event.getCurrentTarget(); + target.sprite.x = pos.x; + target.sprite.y = pos.y; + cc.log("onMouseUp at: " + pos.x + " " + pos.y ); + } + }, this); + } else { + cc.log("MOUSE Not supported"); + } + }, + subtitle:function () { + return "Mouse test. Move mouse and see console"; + } +}); + +//------------------------------------------------------------------ +// +// Keyboard test +// +//------------------------------------------------------------------ +var KeyboardTest = EventTest.extend({ + init: function () { + this._super(); + var self = this; + var label = new cc.LabelTTF("show key Code"); + var size = cc.director.getWinSize(); + label.setPosition(size.width / 2, size.height / 2); + this.addChild(label); + if ('keyboard' in cc.sys.capabilities) { + cc.eventManager.addListener({ + event: cc.EventListener.KEYBOARD, + onKeyPressed: function (key, event) { + var strTemp = "Key down:" + key; + var keyStr = self.getKeyStr(key); + if (keyStr.length > 0) + { + strTemp += " the key name is:" + keyStr; + } + label.setString(strTemp); + }, + onKeyReleased: function (key, event) { + var strTemp = "Key up:" + key; + var keyStr = self.getKeyStr(key); + if (keyStr.length > 0) + { + strTemp += " the key name is:" + keyStr; + } + label.setString(strTemp); + } + }, this); + } else { + cc.log("KEYBOARD Not supported"); + } + }, + getKeyStr: function (keycode) + { + if (keycode == cc.KEY.none) + { + return ""; + } + + for (var keyTemp in cc.KEY) + { + if (cc.KEY[keyTemp] == keycode) + { + return keyTemp; + } + } + return ""; + }, + subtitle:function () { + return "Keyboard test. Press keyboard and see console"; + }, + + // this callback is only available on JSB + OS X + // Not supported on cocos2d-html5 + onKeyFlagsChanged:function(key) { + cc.log("Key flags changed:" + key); + } +}); + + +var EventTestScene = TestScene.extend({ + runThisTest:function (num) { + sceneIdx = (num || num == 0) ? (num - 1) : -1; + var layer = nextEventsTest(); + // var menu = new EventTest(); + // menu.addKeyboardNotificationLayer( layer ); + + this.addChild(layer); + director.runScene(this); + } +}); + +// +// Flow control +// +var arrayOfEventsTest = [ + TouchOneByOneTest, + TouchAllAtOnce, + AccelerometerTest, + MouseTest, + KeyboardTest +]; + +var nextEventsTest = function () { + sceneIdx++; + sceneIdx = sceneIdx % arrayOfEventsTest.length; + + if(window.sideIndexBar){ + sceneIdx = window.sideIndexBar.changeTest(sceneIdx, 12); + } + + return new arrayOfEventsTest[sceneIdx](); +}; +var previousEventsTest = function () { + sceneIdx--; + if (sceneIdx < 0) + sceneIdx += arrayOfEventsTest.length; + + if(window.sideIndexBar){ + sceneIdx = window.sideIndexBar.changeTest(sceneIdx, 12); + } + + return new arrayOfEventsTest[sceneIdx](); +}; +var restartEventsTest = function () { + return new arrayOfEventsTest[sceneIdx](); +}; + diff --git a/tests/js-tests/src/ExtensionsTest/AssetsManagerTest/AssetsManagerTest.js b/tests/js-tests/src/ExtensionsTest/AssetsManagerTest/AssetsManagerTest.js new file mode 100644 index 0000000000..acd1c664fe --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/AssetsManagerTest/AssetsManagerTest.js @@ -0,0 +1,231 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 sceneManifests = ["Manifests/AMTestScene1/project.manifest", "Manifests/AMTestScene2/project.manifest", "Manifests/AMTestScene3/project.manifest"]; +var storagePaths = ["JSBTests/AssetsManagerTest/scene1/", "JSBTests/AssetsManagerTest/scene2/", "JSBTests/AssetsManagerTest/scene3"]; +var backgroundPaths = ["Images/assetMgrBackground1.jpg", "Images/assetMgrBackground2.png", "Images/assetMgrBackground3.png"]; + +var currentScene = 0; + +var AssetsManagerTestLayer = BaseTestLayer.extend({ + _background : null, + _spritePath : "", + + ctor : function (spritePath) { + this._super(); + this._spritePath = spritePath; + cc.loader.resPath = "res/"; + }, + + getTitle : function() { + return "AssetsManagerTest"; + }, + + onEnter : function() { + this._super(); + this._background = new cc.Sprite(this._spritePath); + this.addChild(this._background, 1); + this._background.x = cc.winSize.width/2; + this._background.y = cc.winSize.height/2; + }, + + onExit : function(){ + cc.loader.resPath = ""; + this._super(); + }, + + onNextCallback : function () { + if (currentScene < 2) + { + currentScene++; + } + else currentScene = 0; + var scene = new AssetsManagerLoaderScene(); + scene.runThisTest(); + }, + + onBackCallback : function () { + if (currentScene > 0) + { + currentScene--; + } + else currentScene = 2; + var scene = new AssetsManagerLoaderScene(); + scene.runThisTest(); + } +}); + + + +var AssetsManagerTestScene = TestScene.extend({ + _background : "", + + ctor : function (background) { + this._super(); + var layer = new AssetsManagerTestLayer(background); + this.addChild(layer); + } +}); + +var __failCount = 0; + +var AssetsManagerLoaderScene = TestScene.extend({ + _am : null, + _progress : null, + _percent : 0, + _percentByFile : 0, + _loadingBar : null, + _fileLoadingBar : null, + + runThisTest : function () { + var manifestPath = sceneManifests[currentScene]; + var storagePath = ((jsb.fileUtils ? jsb.fileUtils.getWritablePath() : "/") + storagePaths[currentScene]); + cc.log("Storage path for this test : " + storagePath); + + var layer = new cc.Layer(); + this.addChild(layer); + + var icon = new cc.Sprite(s_image_icon); + icon.x = cc.winSize.width/2; + icon.y = cc.winSize.height/2; + layer.addChild(icon); + + this._loadingBar = new ccui.LoadingBar("res/cocosui/sliderProgress.png"); + this._loadingBar.x = cc.visibleRect.center.x; + this._loadingBar.y = cc.visibleRect.top.y - 40; + layer.addChild(this._loadingBar); + + this._fileLoadingBar = new ccui.LoadingBar("res/cocosui/sliderProgress.png"); + this._fileLoadingBar.x = cc.visibleRect.center.x; + this._fileLoadingBar.y = cc.visibleRect.top.y - 80; + layer.addChild(this._fileLoadingBar); + + this._am = new jsb.AssetsManager(manifestPath, storagePath); + this._am.retain(); + + if (!this._am.getLocalManifest().isLoaded()) + { + cc.log("Fail to update assets, step skipped."); + var scene = new AssetsManagerTestScene(backgroundPaths[currentScene]); + cc.director.runScene(scene); + } + else + { + var that = this; + var listener = new jsb.EventListenerAssetsManager(this._am, function(event) { + var scene; + switch (event.getEventCode()) + { + case jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST: + cc.log("No local manifest file found, skip assets update."); + scene = new AssetsManagerTestScene(backgroundPaths[currentScene]); + cc.director.runScene(scene); + break; + case jsb.EventAssetsManager.UPDATE_PROGRESSION: + that._percent = event.getPercent(); + that._percentByFile = event.getPercentByFile(); + + var msg = event.getMessage(); + if (msg) { + cc.log(msg); + } + cc.log(that._percent + "%"); + break; + case jsb.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST: + case jsb.EventAssetsManager.ERROR_PARSE_MANIFEST: + cc.log("Fail to download manifest file, update skipped."); + scene = new AssetsManagerTestScene(backgroundPaths[currentScene]); + cc.director.runScene(scene); + break; + case jsb.EventAssetsManager.ALREADY_UP_TO_DATE: + case jsb.EventAssetsManager.UPDATE_FINISHED: + cc.log("Update finished. " + event.getMessage()); + + // Restart the game to update scripts in scene 3 + if (currentScene == 2) { + // Register the manifest's search path + var searchPaths = that._am.getLocalManifest().getSearchPaths(); + // This value will be retrieved and appended to the default search path during game startup, + // please refer to samples/js-tests/main.js for detailed usage. + // !!! Re-add the search paths in main.js is very important, otherwise, new scripts won't take effect. + cc.sys.localStorage.setItem("Scene3SearchPaths", JSON.stringify(searchPaths)); + // Restart the game to make all scripts take effect. + cc.game.restart(); + } + else { + scene = new AssetsManagerTestScene(backgroundPaths[currentScene]); + cc.director.runScene(scene); + } + break; + case jsb.EventAssetsManager.UPDATE_FAILED: + cc.log("Update failed. " + event.getMessage()); + + __failCount ++; + if (__failCount < 5) + { + that._am.downloadFailedAssets(); + } + else + { + cc.log("Reach maximum fail count, exit update process"); + __failCount = 0; + scene = new AssetsManagerTestScene(backgroundPaths[currentScene]); + cc.director.runScene(scene); + } + break; + case jsb.EventAssetsManager.ERROR_UPDATING: + cc.log("Asset update error: " + event.getAssetId() + ", " + event.getMessage()); + break; + case jsb.EventAssetsManager.ERROR_DECOMPRESS: + cc.log(event.getMessage()); + break; + default: + break; + } + }); + + cc.eventManager.addListener(listener, 1); + + this._am.update(); + + cc.director.runScene(this); + } + + this.schedule(this.updateProgress, 0.5); + }, + + updateProgress : function () { + this._loadingBar.setPercent(this._percent); + this._fileLoadingBar.setPercent(this._percentByFile); + }, + + onExit : function () { + this._am.release(); + this._super(); + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/ExtensionsTest/CCPoolTest/CCPoolTest.js b/tests/js-tests/src/ExtensionsTest/CCPoolTest/CCPoolTest.js new file mode 100644 index 0000000000..c3439c7d0c --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/CCPoolTest/CCPoolTest.js @@ -0,0 +1,190 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + Copyright (c) 2013 James Chen + + 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. + ****************************************************************************/ + + +var CCPoolTest = cc.Layer.extend({ + timeList: null, + init: function () { + this.timeList = {}; + var winSize = cc.director.getWinSize(); + + var MARGIN = 40; + var label = new cc.LabelTTF("CCPoolTest", "Arial", 28); + label.setPosition(cc.p(winSize.width / 2, winSize.height - MARGIN)); + this.addChild(label, 0); + + var menuRequest = new cc.Menu(); + menuRequest.setPosition(cc.p(0, 0)); + this.initUI(); + return true; + }, + initUI: function () { + var createLabel = new cc.LabelTTF("click me to create\n 150 sprites directly", "Arial", 23); + var reCreateLabel = new cc.LabelTTF("click me to create\n 150 sprites use pool", "Arial", 23); + reCreateLabel.color = cc.color(255, 255, 255, 255); + createLabel.color = cc.color(255, 255, 255, 255); + var menuItem1 = new cc.MenuItemLabel(createLabel, this.addSpriteByCreate, this); + var menuItem2 = new cc.MenuItemLabel(reCreateLabel, this.addSpriteByPool, this); + var menu = new cc.Menu(menuItem1, menuItem2); + menu.alignItemsHorizontallyWithPadding(150); + this.directLabel = new cc.LabelTTF("create directly cost:", "Arial", 18); + this.poolLabel = new cc.LabelTTF("use pool cost:", "Arial", 18); + this.directLabel.setPosition(cc.pAdd(cc.visibleRect.center, cc.p(-190, -65))); + this.directLabel.anchorY = 0; + this.poolLabel.setPosition(cc.pAdd(cc.visibleRect.center, cc.p(200, -65))); + this.poolLabel.anchorY = 0; + this.addChild(this.directLabel); + this.addChild(this.poolLabel); + this.addChild(menu, 100); + + // Back Menu + var itemBack = new cc.MenuItemFont("Back", this.toExtensionsMainLayer, this); + itemBack.setPosition(cc.p(winSize.width - 50, 25)); + var menuBack = new cc.Menu(itemBack); + menuBack.setPosition(cc.p(0, 0)); + this.addChild(menuBack); + }, + setDirectLabel: function (time) { + if (time == 0) { + time = "<1"; + } + this.directLabel.string = "create directly cost:" + time + "ms"; + }, + setPoolLabel: function (time) { + if (time == 0) { + time = "<1"; + } + this.poolLabel.string = "use pool cost:" + time + "ms"; + + }, + addSpriteByCreate: function () { + this.datalist1 = []; + this.timeStart("directly"); + for (var i = 0; i < 150; i++) { + var sp = MySprite.create(1, 2, 3); + this.datalist1.push(sp); + this.addChild(sp, 100); + sp.x = 50 + 8 * i; + } + this.setDirectLabel(this.timeEnd("directly")); + this.schedule(function () { + for (var i = 0; i < this.datalist1.length; i++) { + this.datalist1[i].removeFromParent(true); + } + this.datalist1 = []; + }, 0, 1, 0.1); + }, + addSpriteByPool: function () { + this.datalist2 = []; + for (var i = 0; i < 150; i++) { + var sp = MySprite.create(1, 2, 3); + this.addChild(sp); + cc.pool.putInPool(sp); + } + this.timeStart("use Pool"); + for (var i = 0; i < 150; i++) { + var sp = MySprite.reCreate(4, 5, 6); + this.datalist2.push(sp); + this.addChild(sp, 100); +// sp.runAction(action); + sp.x = 50 + 8 * i; + } + this.setPoolLabel(this.timeEnd("use Pool")); + this.schedule(function () { + for (var i = 0; i < this.datalist2.length; i++) { + this.datalist2[i].removeFromParent(true); + } + this.datalist2 = []; + cc.pool.drainAllPools(); + }, 0, 1, 0.1); + }, + timeStart: function (name) { + this.timeList[name] = {startTime: Date.now(), EndTime: 0, DeltaTime: 0}; + }, + timeEnd: function (name) { + var obj = this.timeList[name]; + obj.EndTime = Date.now(); + obj.DeltaTime = obj.EndTime - obj.startTime; + return obj.DeltaTime; + }, + toExtensionsMainLayer: function (sender) { + var scene = new ExtensionsTestScene(); + scene.runThisTest(); + } +}); + +CCPoolTest.create = function () { + var retObj = new CCPoolTest(); + if (retObj && retObj.init()) { + return retObj; + } + return null; +}; + + +var runCCPoolTest = function () { + var pScene = cc.Scene.create(); + var pLayer = CCPoolTest.create(); + pScene.addChild(pLayer); + cc.director.runScene(pScene); +}; +var MySprite = cc.Sprite.extend({ + _hp: 0, + _sp: 0, + _mp: 0, + ctor: function (f1, f2, f3) { + this._super(s_grossini); + this.initData(f1, f2, f3); + }, + initData: function (f1, f2, f3) { + this._hp = f1; + this._mp = f2; + this._sp = f3; + }, + unuse: function () { + this._hp = 0; + this._mp = 0; + this._sp = 0; + this.retain();//if in jsb + this.setVisible(false); + this.removeFromParent(true); + }, + reuse: function (f1, f2, f3) { + this.initData(f1, f2, f3); + this.setVisible(true); + } +}); + +MySprite.create = function (f1, f2, f3) { + return new MySprite(f1, f2, f3) +} +MySprite.reCreate = function (f1, f2, f3) { + var pool = cc.pool; + if (pool.hasObject(MySprite)) return pool.getFromPool(MySprite, f1, f2, f3); + return MySprite.create(f1, f2, f3); +} \ No newline at end of file diff --git a/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.js b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.js new file mode 100644 index 0000000000..764e5e06db --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.js @@ -0,0 +1,40 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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. + ****************************************************************************/ + +cc.BuilderReader.registerController("TestAnimationsLayer", { + "onCCControlButtonIdleClicked" : function(sender, controlEvent) { + this.rootNode.animationManager.runAnimationsForSequenceNamedTweenDuration("Idle", 0.3); + }, + "onCCControlButtonWaveClicked" : function(sender, controlEvent) { + this.rootNode.animationManager.runAnimationsForSequenceNamedTweenDuration("Wave", 0.3); + }, + "onCCControlButtonJumpClicked" : function(sender, controlEvent) { + this.rootNode.animationManager.runAnimationsForSequenceNamedTweenDuration("Jump", 0.3); + }, + "onCCControlButtonFunkyClicked" : function(sender, controlEvent) { + this.rootNode.animationManager.runAnimationsForSequenceNamedTweenDuration("Funky", 0.3); + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.js b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.js new file mode 100644 index 0000000000..fc5df69188 --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.js @@ -0,0 +1,44 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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. + ****************************************************************************/ +cc.BuilderReader.registerController("TestButtonsLayer", { + "onCCControlButtonClicked" : function(sender,controlEvent) { + var str = (function(){ + switch(controlEvent) { + case cc.CONTROL_EVENT_TOUCH_DOWN: return "Touch Down."; + case cc.CONTROL_EVENT_TOUCH_DRAG_INSIDE: return "Touch Drag Inside."; + case cc.CONTROL_EVENT_TOUCH_DRAG_OUTSIDE: return "Touch Drag Outside."; + case cc.CONTROL_EVENT_TOUCH_DRAG_ENTER: return "Touch Drag Enter."; + case cc.CONTROL_EVENT_TOUCH_DRAG_EXIT: return "Touch Drag Exit."; + case cc.CONTROL_EVENT_TOUCH_UP_INSIDE: return "Touch Up Inside."; + case cc.CONTROL_EVENT_TOUCH_UP_OUTSIDE: return "Touch Up Outside."; + case cc.CONTROL_EVENT_TOUCH_CANCEL: return "Touch Cancel."; + case cc.CONTROL_EVENT_VALUECHANGED: return "Value Changed."; + } + return ""; + })(); + this["mCCControlEventLabel"].setString(str); + } +}); diff --git a/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.js b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.js new file mode 100644 index 0000000000..2dcbb3b344 --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.js @@ -0,0 +1,39 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 CocosBuilderTestScene = TestScene.extend({ + runThisTest:function(){ + cc.BuilderReader.setResourcePath("res/"); + + var node = cc.BuilderReader.load("res/ccb/HelloCocosBuilder.ccbi", this); + + if(node != null) { + this.addChild(node); + } + + cc.director.runScene(this); + } +}); diff --git a/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.js b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.js new file mode 100644 index 0000000000..66bd4aaceb --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.js @@ -0,0 +1,69 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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. + ****************************************************************************/ + +cc.BuilderReader.registerController("HelloCocosBuilderLayer", { + _openTest : function(ccbFileName) { + cc.BuilderReader.setResourcePath("res/"); + var node = cc.BuilderReader.load(ccbFileName, this); + + this["mTestTitleLabelTTF"].setString(ccbFileName); + var scene = new cc.Scene(); + if(node != null) + scene.addChild(node); + + /* Push the new scene with a fancy transition. */ + cc.director.pushScene(new cc.TransitionFade(0.5, scene, cc.color(0, 0, 0))); + }, + + "onMenuTestClicked" : function() { + this._openTest("res/ccb/ccb/TestMenus.ccbi"); + }, + + "onSpriteTestClicked" : function() { + this._openTest("res/ccb/ccb/TestSprites.ccbi"); + }, + + "onButtonTestClicked" : function() { + this._openTest("res/ccb/ccb/TestButtons.ccbi"); + }, + + "onAnimationsTestClicked" : function() { + this._openTest("res/ccb/ccb/TestAnimations.ccbi"); + }, + + "onParticleSystemTestClicked" : function() { + this._openTest("res/ccb/ccb/TestParticleSystems.ccbi"); + }, + + "onScrollViewTestClicked" : function() { + this._openTest("res/ccb/ccb/TestScrollViews.ccbi"); + }, + + "onTimelineCallbackSoundClicked" : function() { + this._openTest("res/ccb/ccb/TestTimelineCallback.ccbi"); + } +}); + diff --git a/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/LabelTest/LabelTestLayer.js b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/LabelTest/LabelTestLayer.js new file mode 100644 index 0000000000..b640dd6840 --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/LabelTest/LabelTestLayer.js @@ -0,0 +1,26 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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. + ****************************************************************************/ +cc.BuilderReader.registerController("TestLabelsLayer", {}); \ No newline at end of file diff --git a/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.js b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.js new file mode 100644 index 0000000000..e9193fe818 --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.js @@ -0,0 +1,39 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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. + ****************************************************************************/ + +cc.BuilderReader.registerController("TestMenusLayer", { + "onMenuItemAClicked" : function(sender) { + this["mMenuItemStatusLabelBMFont"].setString("Menu Item A clicked."); + }, + + "onMenuItemBClicked" : function(sender) { + this["mMenuItemStatusLabelBMFont"].setString("Menu Item B clicked."); + }, + + "onMenuItemCClicked" : function(sender) { + this["mMenuItemStatusLabelBMFont"].setString("Menu Item C clicked."); + } +}); diff --git a/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/ParticleSystemTest/ParticleSystemTestLayer.js b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/ParticleSystemTest/ParticleSystemTestLayer.js new file mode 100644 index 0000000000..3b2f7328da --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/ParticleSystemTest/ParticleSystemTestLayer.js @@ -0,0 +1,27 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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. + ****************************************************************************/ + +cc.BuilderReader.registerController("TestParticleSystemsLayer", {}); \ No newline at end of file diff --git a/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/ScrollViewTest/ScrollViewTestLayer.js b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/ScrollViewTest/ScrollViewTestLayer.js new file mode 100644 index 0000000000..2f1c48951f --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/ScrollViewTest/ScrollViewTestLayer.js @@ -0,0 +1,27 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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. + ****************************************************************************/ + +cc.BuilderReader.registerController("TestScrollViewsLayer", {}); \ No newline at end of file diff --git a/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/SpriteTest/SpriteTestLayer.js b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/SpriteTest/SpriteTestLayer.js new file mode 100644 index 0000000000..5565869692 --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/SpriteTest/SpriteTestLayer.js @@ -0,0 +1,28 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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. + ****************************************************************************/ + +cc.BuilderReader.registerController("TestSpritesLayer", {}); + diff --git a/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.js b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.js new file mode 100644 index 0000000000..412b8d5263 --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.js @@ -0,0 +1,31 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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. + ****************************************************************************/ + +cc.BuilderReader.registerController("TestHeaderLayer", { + "onBackClicked" : function() { + cc.director.popScene(); + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.js b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.js new file mode 100644 index 0000000000..0049c9169c --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.js @@ -0,0 +1,41 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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. + ****************************************************************************/ + +cc.BuilderReader.registerController("TestTimelineLayer", { + "onCallback1" : function(sender) { + // Rotate the label when the button is pressed + var label = this["helloLabel"]; + label.runAction(cc.rotateBy(1,360)); + label.setString("Callback 1"); + }, + + "onCallback2" : function(sender) { + // Rotate the label when the button is pressed + var label = this["helloLabel"]; + label.runAction(cc.rotateBy(1,-360)); + label.setString("Callback 2"); + } +}); diff --git a/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.js b/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.js new file mode 100644 index 0000000000..cb30419028 --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.js @@ -0,0 +1,284 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 ControlButtonTest_HelloVariableSize = ControlScene.extend({ + init:function () { + if (this._super()) { + var screenSize = cc.director.getWinSize(); + + // Defines an array of title to create buttons dynamically + var stringArray = ["Hello", "Variable", "Size", "!"]; + + var layer = new cc.Node(); + this.addChild(layer, 1); + + var total_width = 0, height = 0; + + // For each title in the array + for (var i = 0; i < stringArray.length; i++) { + var button = this.standardButtonWithTitle(stringArray[i]); + + if (i == 0) { + button.opacity = 50; + //todo setColor not work in canvas + //button.color = cc.color(0, 255, 0); + } + else if (i == 1) { + button.opacity = 200; + //todo setColor not work in canvas + //button.color = cc.color(0, 255, 0); + } + else if (i == 2) { + button.opacity = 100; + //todo setColor not work in canvas + //button.color = cc.color(0, 0, 255); + } + + button.x = total_width + button.width / 2; + button.y = button.height / 2; + layer.addChild(button); + + // Compute the size of the layer + height = button.height; + total_width += button.width; + } + + layer.anchorX = 0.5; + layer.anchorY = 0.5; + layer.width = total_width; + layer.height = height; + layer.x = screenSize.width / 2.0; + layer.y = screenSize.height / 2.0; + + // Add the black background + var background = new cc.Scale9Sprite(s_extensions_buttonBackground); + background.width = total_width + 14; + background.height = height + 14; + background.x = screenSize.width / 2.0; + background.y = screenSize.height / 2.0; + this.addChild(background); + return true; + } + return false; + }, + // Creates and return a button with a default background and title color. + standardButtonWithTitle:function (title) { + // Creates and return a button with a default background and title color. + var backgroundButton = new cc.Scale9Sprite(s_extensions_button); + var backgroundHighlightedButton = new cc.Scale9Sprite(s_extensions_buttonHighlighted); + + var titleButton = new cc.LabelTTF(title, "Marker Felt", 30); + + titleButton.color = cc.color(159, 168, 176); + + var button = new cc.ControlButton(titleButton, backgroundButton); + button.setBackgroundSpriteForState(backgroundHighlightedButton, cc.CONTROL_STATE_HIGHLIGHTED); + button.setTitleColorForState(cc.color.WHITE, cc.CONTROL_STATE_HIGHLIGHTED); + + return button; + } +}); + +ControlButtonTest_HelloVariableSize.create = function (sceneTitle) { + var scene = new cc.Scene(); + var controlLayer = new ControlButtonTest_HelloVariableSize(); + if (controlLayer && controlLayer.init()) { + controlLayer.getSceneTitleLabel().setString(sceneTitle); + scene.addChild(controlLayer); + } + return scene; +}; + +var ControlButtonTest_Event = ControlScene.extend({ + _displayValueLabel:null, + + init:function () { + if (this._super()) { + var screenSize = cc.director.getWinSize(); + + // Add the button + var backgroundButton = new cc.Scale9Sprite(s_extensions_button); + var backgroundHighlightedButton = new cc.Scale9Sprite(s_extensions_buttonHighlighted); + + // Add a label in which the button events will be displayed + this.setDisplayValueLabel(new cc.LabelTTF("No Event", "Marker Felt", 32)); + this._displayValueLabel.anchorX = 0.5; + this._displayValueLabel.anchorY = -1; + this._displayValueLabel.x = screenSize.width / 2.0; + this._displayValueLabel.y = screenSize.height / 2.0; + this.addChild(this._displayValueLabel, 10); + + var titleButton = new cc.LabelTTF("Touch Me!", "Marker Felt", 30); + titleButton.color = cc.color(159, 168, 176); + + var controlButton = new cc.ControlButton(titleButton, backgroundButton); + controlButton.setBackgroundSpriteForState(backgroundHighlightedButton, cc.CONTROL_STATE_HIGHLIGHTED); + controlButton.setTitleColorForState(cc.color.WHITE, cc.CONTROL_STATE_HIGHLIGHTED); + + controlButton.anchorX = 0.5; + controlButton.anchorY = 1; + controlButton.x = screenSize.width / 2.0; + controlButton.y = screenSize.height / 2.0; + this.addChild(controlButton, 1); + + // Add the black background + var background = new cc.Scale9Sprite(s_extensions_buttonBackground); + background.width = 300; + background.height = 170; + background.x = screenSize.width / 2.0; + background.y = screenSize.height / 2.0; + this.addChild(background); + + // Sets up event handlers + controlButton.addTargetWithActionForControlEvents(this, this.touchDownAction, cc.CONTROL_EVENT_TOUCH_DOWN); + controlButton.addTargetWithActionForControlEvents(this, this.touchDragInsideAction, cc.CONTROL_EVENT_TOUCH_DRAG_INSIDE); + controlButton.addTargetWithActionForControlEvents(this, this.touchDragOutsideAction, cc.CONTROL_EVENT_TOUCH_DRAG_OUTSIDE); + controlButton.addTargetWithActionForControlEvents(this, this.touchDragEnterAction, cc.CONTROL_EVENT_TOUCH_DRAG_ENTER); + controlButton.addTargetWithActionForControlEvents(this, this.touchDragExitAction, cc.CONTROL_EVENT_TOUCH_DRAG_EXIT); + controlButton.addTargetWithActionForControlEvents(this, this.touchUpInsideAction, cc.CONTROL_EVENT_TOUCH_UP_INSIDE); + controlButton.addTargetWithActionForControlEvents(this, this.touchUpOutsideAction, cc.CONTROL_EVENT_TOUCH_UP_OUTSIDE); + controlButton.addTargetWithActionForControlEvents(this, this.touchCancelAction, cc.CONTROL_EVENT_TOUCH_CANCEL); + return true; + } + return false; + }, + + getDisplayValueLabel:function () { + return this._displayValueLabel; + }, + setDisplayValueLabel:function (displayValueLabel) { + this._displayValueLabel = displayValueLabel; + }, + + touchDownAction:function (sender, controlEvent) { + this._displayValueLabel.setString("Touch Down"); + }, + touchDragInsideAction:function (sender, controlEvent) { + this._displayValueLabel.setString("Drag Inside"); + }, + touchDragOutsideAction:function (sender, controlEvent) { + this._displayValueLabel.setString("Drag Outside"); + }, + touchDragEnterAction:function (sender, controlEvent) { + this._displayValueLabel.setString("Drag Enter"); + }, + touchDragExitAction:function (sender, controlEvent) { + this._displayValueLabel.setString("Drag Exit"); + }, + touchUpInsideAction:function (sender, controlEvent) { + this._displayValueLabel.setString("Touch Up Inside."); + }, + touchUpOutsideAction:function (sender, controlEvent) { + this._displayValueLabel.setString("Touch Up Outside."); + }, + touchCancelAction:function (sender, controlEvent) { + this._displayValueLabel.setString("Touch Cancel"); + } +}); + +ControlButtonTest_Event.create = function (sceneTitle) { + var scene = new cc.Scene(); + var controlLayer = new ControlButtonTest_Event(); + if (controlLayer && controlLayer.init()) { + controlLayer.getSceneTitleLabel().setString(sceneTitle); + scene.addChild(controlLayer); + } + return scene; +}; + +var ControlButtonTest_Styling = ControlScene.extend({ + init:function () { + if (this._super()) { + var screenSize = cc.director.getWinSize(); + + var layer = new cc.Node(); + this.addChild(layer, 1); + + var space = 10; // px + + var max_w = 0, max_h = 0; + for (var i = 0; i < 3; i++) { + for (var j = 0; j < 3; j++) { + // Add the buttons + var button = this.standardButtonWithTitle((0 | (Math.random() * 30)) + ""); + button.setAdjustBackgroundImage(false); // Tells the button that the background image must not be adjust + // It'll use the prefered size of the background image + button.x = button.width / 2 + (button.width + space) * i; + button.y = button.height / 2 + (button.height + space) * j; + layer.addChild(button); + + max_w = Math.max(button.width * (i + 1) + space * i, max_w); + max_h = Math.max(button.height * (j + 1) + space * j, max_h); + } + } + + layer.anchorX = 0.5; + layer.anchorY = 0.5; + layer.width = max_w; + layer.height = max_h; + layer.x = screenSize.width / 2.0; + layer.y = screenSize.height / 2.0; + + // Add the black background + var backgroundButton = new cc.Scale9Sprite(s_extensions_buttonBackground); + backgroundButton.width = max_w + 14; + backgroundButton.height = max_h + 14; + backgroundButton.x = screenSize.width / 2.0; + backgroundButton.y = screenSize.height / 2.0; + this.addChild(backgroundButton); + return true; + } + return false; + }, + standardButtonWithTitle:function (title) { + /** Creates and return a button with a default background and title color. */ + var backgroundButton = new cc.Scale9Sprite(s_extensions_button); + backgroundButton.setPreferredSize(cc.size(45, 45)); // Set the prefered size + var backgroundHighlightedButton = new cc.Scale9Sprite(s_extensions_buttonHighlighted); + backgroundHighlightedButton.setPreferredSize(cc.size(45, 45)); // Set the prefered size + + var titleButton = new cc.LabelTTF(title, "Marker Felt", 30); + + titleButton.color = cc.color(159, 168, 176); + + var button = new cc.ControlButton(titleButton, backgroundButton); + button.setBackgroundSpriteForState(backgroundHighlightedButton, cc.CONTROL_STATE_HIGHLIGHTED); + button.setTitleColorForState(cc.color.WHITE, cc.CONTROL_STATE_HIGHLIGHTED); + + return button; + } +}); + +ControlButtonTest_Styling.create = function (sceneTitle) { + var scene = new cc.Scene(); + var controlLayer = new ControlButtonTest_Styling(); + if (controlLayer && controlLayer.init()) { + controlLayer.getSceneTitleLabel().setString(sceneTitle); + scene.addChild(controlLayer); + } + return scene; +}; + diff --git a/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlColourPickerTest/CCControlColourPickerTest.js b/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlColourPickerTest/CCControlColourPickerTest.js new file mode 100644 index 0000000000..f5a834050c --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlColourPickerTest/CCControlColourPickerTest.js @@ -0,0 +1,97 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 ControlColourPickerTest = ControlScene.extend({ + _colorLabel:null, + init:function () { + if (this._super()) { + var screenSize = cc.director.getWinSize(); + + var layer = new cc.Node(); + layer.x = screenSize.width / 2; + layer.y = screenSize.height / 2; + this.addChild(layer, 1); + + var layer_width = 0; + + // Create the colour picker + var colourPicker = new cc.ControlColourPicker(); + colourPicker.color = cc.color(37, 46, 252); + colourPicker.x = colourPicker.width / 2; + colourPicker.y = 0; + + // Add it to the layer + layer.addChild(colourPicker); + + // Add the target-action pair + colourPicker.addTargetWithActionForControlEvents(this,this.colourValueChanged, cc.CONTROL_EVENT_VALUECHANGED); + + + layer_width += colourPicker.width; + + // Add the black background for the text + var background = new cc.Scale9Sprite("res/extensions/buttonBackground.png"); + background.width = 150; + background.height = 50; + background.x = layer_width + background.width / 2.0; + background.y = 0; + layer.addChild(background); + + layer_width += background.width; + + this._colorLabel = new cc.LabelTTF("#color", "Marker Felt", 30); + this._colorLabel.retain(); + + this._colorLabel.x = background.x; + this._colorLabel.y = background.y; + layer.addChild(this._colorLabel); + + // Set the layer size + layer.width = layer_width; + layer.height = 0; + layer.anchorX = 0.5; + layer.anchorY = 0.5; + + // Update the color text + this.colourValueChanged(colourPicker, cc.CONTROL_EVENT_VALUECHANGED); + return true; + } + return false; + }, + colourValueChanged:function (sender, controlEvent) { + // Change value of label. + this._colorLabel.setString(cc.colorToHex(sender.color).toUpperCase()); + } +}); +ControlColourPickerTest.create = function (sceneTitle) { + var scene = new cc.Scene(); + var controlLayer = new ControlColourPickerTest(); + if (controlLayer && controlLayer.init()) { + controlLayer.getSceneTitleLabel().setString(sceneTitle); + scene.addChild(controlLayer); + } + return scene; +}; \ No newline at end of file diff --git a/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.js b/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.js new file mode 100644 index 0000000000..a6d842206f --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.js @@ -0,0 +1,96 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 ControlPotentiometerTest = ControlScene.extend({ + _displayValueLabel:null, + init:function () { + if (this._super()) { + var screenSize = cc.director.getWinSize(); + + var layer = new cc.Node(); + layer.x = screenSize.width / 2; + layer.y = screenSize.height / 2; + this.addChild(layer, 1); + + var layer_width = 0; + + // Add the black background for the text + var background = new cc.Scale9Sprite("res/extensions/buttonBackground.png"); + background.width = 80; + background.height = 50; + background.x = layer_width + background.width / 2.0; + background.y = 0; + layer.addChild(background); + + layer_width += background.width; + + this._displayValueLabel = new cc.LabelTTF("", "HelveticaNeue-Bold", 30); + + this._displayValueLabel.x = background.x; + this._displayValueLabel.y = background.y; + layer.addChild(this._displayValueLabel); + + // Add the slider + var potentiometer = new cc.ControlPotentiometer("res/extensions/potentiometerTrack.png" + , "res/extensions/potentiometerProgress.png" + , "res/extensions/potentiometerButton.png"); + potentiometer.x = layer_width + 10 + potentiometer.width / 2; + potentiometer.y = 0; + + // When the value of the slider will change, the given selector will be call + potentiometer.addTargetWithActionForControlEvents(this, this.valueChanged, cc.CONTROL_EVENT_VALUECHANGED); + + layer.addChild(potentiometer); + + layer_width += potentiometer.width; + + // Set the layer size + layer.width = layer_width; + layer.height = 0; + layer.anchorX = 0.5; + layer.anchorY = 0.5; + + // Update the value label + this.valueChanged(potentiometer, cc.CONTROL_EVENT_VALUECHANGED); + + return true; + } + return false; + }, + valueChanged:function (sender, controlEvent) { + // Change value of label. + this._displayValueLabel.setString(sender.getValue().toFixed(2)); + } +}); +ControlPotentiometerTest.create = function (sceneTitle) { + var scene = new cc.Scene(); + var controlLayer = new ControlPotentiometerTest(); + if (controlLayer && controlLayer.init()) { + controlLayer.getSceneTitleLabel().setString(sceneTitle); + scene.addChild(controlLayer); + } + return scene; +}; \ No newline at end of file diff --git a/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlScene.js b/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlScene.js new file mode 100644 index 0000000000..3f6d2db38b --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlScene.js @@ -0,0 +1,115 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 ControlScene = cc.Layer.extend({ + _sceneTitleLabel:null, + + getSceneTitleLabel:function(){return this._sceneTitleLabel;}, + setSceneTitleLabel:function(sceneTitleLabel){this._sceneTitleLabel = sceneTitleLabel;}, + + init:function(){ + if (this._super()) { + // Get the sceensize + var screensize = cc.director.getWinSize(); + + var pBackItem = new cc.MenuItemFont("Back", this.toExtensionsMainLayer, this); + pBackItem.x = screensize.width - 50; + pBackItem.y = 25; + var pBackMenu = new cc.Menu(pBackItem); + pBackMenu.x = 0; + pBackMenu.y = 0; + this.addChild(pBackMenu, 10); + + // Add the generated background + var background = new cc.Sprite(s_extensions_background); + background.x = screensize.width / 2; + background.y = screensize.height / 2; + var bgRect = background.getTextureRect(); + background.scaleX = screensize.width/bgRect.width; + background.scaleY = screensize.height/bgRect.height; + this.addChild(background); + + // Add the ribbon + var ribbon = new cc.Scale9Sprite(s_extensions_ribbon, cc.rect(1, 1, 48, 55)); + ribbon.width = screensize.width; + ribbon.height = 57; + ribbon.x = screensize.width / 2.0; + ribbon.y = screensize.height - ribbon.height / 2.0; + this.addChild(ribbon); + + // Add the title + this.setSceneTitleLabel(new cc.LabelTTF("Title", "Arial", 12)); + this._sceneTitleLabel.x = screensize.width / 2; + this._sceneTitleLabel.y = screensize.height - this._sceneTitleLabel.height / 2 - 5; + this.addChild(this._sceneTitleLabel, 1); + + // Add the menu + var item1 = new cc.MenuItemImage(s_pathB1, s_pathB2, this.previousCallback, this); + var item2 = new cc.MenuItemImage(s_pathR1, s_pathR2, this.restartCallback, this); + var item3 = new cc.MenuItemImage(s_pathF1, s_pathF2, this.nextCallback, this); + + var menu = new cc.Menu(item1, item3, item2); + menu.x = 0; + menu.y = 0; + item1.x = screensize.width / 2 - 100; + item1.y = 37; + item2.x = screensize.width / 2; + item2.y = 35; + item3.x = screensize.width / 2 + 100; + item3.y = 37; + + this.addChild(menu ,1); + + return true; + } + return false; + }, + + toExtensionsMainLayer:function(sender){ + var pScene = new ExtensionsTestScene(); + pScene.runThisTest(); + }, + + previousCallback:function(sender){ + cc.director.runScene(ControlSceneManager.getInstance().previousControlScene()); + }, + restartCallback:function(sender){ + cc.director.runScene(ControlSceneManager.getInstance().currentControlScene()); + }, + nextCallback:function(sender){ + cc.director.runScene(ControlSceneManager.getInstance().nextControlScene()); + } +}); + +ControlScene.create = function(title){ + var scene = new cc.Scene(); + var controlLayer = new ControlScene(); + if(controlLayer && controlLayer.init()){ + controlLayer.getSceneTitleLabel().setString(title); + scene.addChild(controlLayer); + } + return scene; +}; diff --git a/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.js b/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.js new file mode 100644 index 0000000000..c1ae639f71 --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.js @@ -0,0 +1,120 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 controTestItemNames = [ + { + itemTitle:"ControlSliderTest", + testScene:function () { + return ControlSliderTest.create(this.itemTitle); + } + }, + { + itemTitle:"ControlColourPickerTest", + testScene:function () { + return ControlColourPickerTest.create(this.itemTitle); + } + }, + { + itemTitle:"ControlSwitchTest", + testScene:function () { + return ControlSwitchTest.create(this.itemTitle); + } + }, + { + itemTitle:"ControlButtonTest_HelloVariableSize", + testScene:function () { + return ControlButtonTest_HelloVariableSize.create(this.itemTitle); + } + }, + { + itemTitle:"ControlButtonTest_Event", + testScene:function () { + return ControlButtonTest_Event.create(this.itemTitle); + } + }, + { + itemTitle:"ControlButtonTest_Styling", + testScene:function () { + return ControlButtonTest_Styling.create(this.itemTitle); + } + }, + { + itemTitle:"ControlPotentiometerTest", + testScene:function () { + return ControlPotentiometerTest.create(this.itemTitle); + } + }, + { + itemTitle:"ControlStepperTest", + testScene:function () { + return ControlStepperTest.create(this.itemTitle); + } + } +]; + +var ControlSceneManager = cc.Class.extend({ + _currentControlSceneId:0, + + ctor:function () { + this._currentControlSceneId = 0; + }, + + getCurrentControlSceneId:function () { + return this._currentControlSceneId; + }, + setCurrentControlSceneId:function (currentControlSceneId) { + this._currentControlSceneId = currentControlSceneId + }, + + nextControlScene:function () { + this._currentControlSceneId = (this._currentControlSceneId + 1) % controTestItemNames.length; + return this.currentControlScene(); + }, + + previousControlScene:function () { + this._currentControlSceneId = this._currentControlSceneId - 1; + if (this._currentControlSceneId < 0) { + this._currentControlSceneId = controTestItemNames.length - 1; + } + + return this.currentControlScene(); + }, + + currentControlScene:function () { + return controTestItemNames[this._currentControlSceneId].testScene(); + } +}); + +ControlSceneManager.sharedInstance = null; +/** + * Returns the singleton of the control scene manager. + */ +ControlSceneManager.getInstance = function () { + if (ControlSceneManager.sharedInstance == null) { + ControlSceneManager.sharedInstance = new ControlSceneManager(); + } + return ControlSceneManager.sharedInstance; +}; diff --git a/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.js b/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.js new file mode 100644 index 0000000000..90e6d20ec5 --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.js @@ -0,0 +1,93 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 ControlSliderTest = ControlScene.extend({ + _displayValueLabel:null, + init:function () { + if (this._super()) { + var screenSize = cc.director.getWinSize(); + + // Add a label in which the slider value will be displayed + this._displayValueLabel = new cc.LabelTTF("Move the slider thumb!\nThe lower slider is restricted.", "Marker Felt", 32); + this._displayValueLabel.retain(); + this._displayValueLabel.anchorX = 0.5; + this._displayValueLabel.anchorY = -1.0; + this._displayValueLabel.x = screenSize.width / 1.7; + this._displayValueLabel.y = screenSize.height / 2.0; + this.addChild(this._displayValueLabel); + + // Add the slider + var slider = new cc.ControlSlider("res/extensions/sliderTrack.png", "res/extensions/sliderProgress.png", "res/extensions/sliderThumb.png"); + slider.anchorX = 0.5; + slider.anchorY = 1.0; + slider.setMinimumValue(0.0); // Sets the min value of range + slider.setMaximumValue(5.0); // Sets the max value of range + slider.x = screenSize.width / 2.0; + slider.y = screenSize.height / 2.0 + 16; + slider.tag = 1; + + // When the value of the slider will change, the given selector will be call + slider.addTargetWithActionForControlEvents(this, this.valueChanged, cc.CONTROL_EVENT_VALUECHANGED); + + var restrictSlider = new cc.ControlSlider("res/extensions/sliderTrack.png", "res/extensions/sliderProgress.png", "res/extensions/sliderThumb.png"); + restrictSlider.anchorX = 0.5; + restrictSlider.anchorY = 1.0; + restrictSlider.setMinimumValue(0.0); // Sets the min value of range + restrictSlider.setMaximumValue(5.0); // Sets the max value of range + restrictSlider.setMaximumAllowedValue(4.0); + restrictSlider.setMinimumAllowedValue(1.5); + restrictSlider.setValue(3.0); + restrictSlider.x = screenSize.width / 2.0; + restrictSlider.y = screenSize.height / 2.0 - 24; + restrictSlider.tag = 2; + + //same with restricted + restrictSlider.addTargetWithActionForControlEvents(this, this.valueChanged, cc.CONTROL_EVENT_VALUECHANGED); + + this.addChild(slider); + this.addChild(restrictSlider); + return true; + } + return false; + }, + valueChanged:function (sender, controlEvent) { + // Change value of label. + if (sender.tag == 1) + this._displayValueLabel.setString("Upper slider value = " + sender.getValue().toFixed(2)); + if (sender.tag == 2) + this._displayValueLabel.setString("Lower slider value = " + sender.getValue().toFixed(2)); + } +}); + +ControlSliderTest.create = function (sceneTitle) { + var scene = new cc.Scene(); + var controlLayer = new ControlSliderTest(); + if (controlLayer && controlLayer.init()) { + controlLayer.getSceneTitleLabel().setString(sceneTitle); + scene.addChild(controlLayer); + } + return scene; +}; \ No newline at end of file diff --git a/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.js b/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.js new file mode 100644 index 0000000000..5f4e7708f6 --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.js @@ -0,0 +1,95 @@ +/************************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + 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. + + */ + +var ControlStepperTest = ControlScene.extend({ + _displayValueLabel:null, + init:function () { + if (this._super()) { + var screenSize = cc.director.getWinSize(); + + var layer = new cc.Node(); + layer.x = screenSize.width / 2; + layer.y = screenSize.height / 2; + this.addChild(layer, 1); + var layer_width = 0; + + // Add the black background for the text + var background = new cc.Scale9Sprite("res/extensions/buttonBackground.png"); + background.width = 100; + background.height = 50; + background.x = layer_width + background.width / 2.0; + background.y = 0; + layer.addChild(background); + + this._displayValueLabel = new cc.LabelTTF("0", "HelveticaNeue-Bold", 30); + + this._displayValueLabel.x = background.x; + this._displayValueLabel.y = background.y; + layer.addChild(this._displayValueLabel); + + layer_width += background.width; + + var stepper = this.makeControlStepper(); + stepper.x = layer_width + 10 + stepper.width / 2; + stepper.y = 0; + stepper.addTargetWithActionForControlEvents(this, this.valueChanged, cc.CONTROL_EVENT_VALUECHANGED); + layer.addChild(stepper); + + layer_width += stepper.width; + + // Set the layer size + layer.width = layer_width; + layer.height = 0; + layer.anchorX = 0.5; + layer.anchorY = 0.5; + + // Update the value label + this.valueChanged(stepper, cc.CONTROL_EVENT_VALUECHANGED); + return true; + } + return false; + }, + makeControlStepper:function () { + var minusSprite = new cc.Sprite("res/extensions/stepper-minus.png"); + var plusSprite = new cc.Sprite("res/extensions/stepper-plus.png"); + + return new cc.ControlStepper(minusSprite, plusSprite); + }, + + valueChanged:function (sender, controlEvent) { + // Change value of label. + this._displayValueLabel.setString(sender.getValue().toString()); + } +}); + +ControlStepperTest.create = function (sceneTitle) { + var scene = new cc.Scene(); + var controlLayer = new ControlStepperTest(); + if (controlLayer && controlLayer.init()) { + controlLayer.getSceneTitleLabel().setString(sceneTitle); + scene.addChild(controlLayer); + } + return scene; +}; \ No newline at end of file diff --git a/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.js b/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.js new file mode 100644 index 0000000000..c9f76819b0 --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.js @@ -0,0 +1,102 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 ControlSwitchTest = ControlScene.extend({ + init:function () { + if (this._super()) { + var screenSize = cc.director.getWinSize(); + + var layer = new cc.Node(); + layer.x = screenSize.width / 2; + layer.y = screenSize.height / 2; + this.addChild(layer, 1); + + var layer_width = 0; + + // Add the black background for the text + var background = new cc.Scale9Sprite("res/extensions/buttonBackground.png"); + background.width = 80; + background.height = 50; + background.x = layer_width + background.width / 2.0; + background.y = 0; + layer.addChild(background); + + layer_width += background.width; + + this._displayValueLabel = new cc.LabelTTF("#color", "Marker Felt", 30); + this._displayValueLabel.retain(); + + this._displayValueLabel.x = background.x; + this._displayValueLabel.y = background.y; + layer.addChild(this._displayValueLabel); + + // Create the switch + var switchControl = new cc.ControlSwitch + ( + new cc.Sprite("res/extensions/switch-mask.png"), + new cc.Sprite("res/extensions/switch-on.png"), + new cc.Sprite("res/extensions/switch-off.png"), + new cc.Sprite("res/extensions/switch-thumb.png"), + new cc.LabelTTF("On", "Arial-BoldMT", 16), + new cc.LabelTTF("Off", "Arial-BoldMT", 16) + ); + switchControl.x = layer_width + 10 + switchControl.width / 2; + switchControl.y = 0; + layer.addChild(switchControl); + + switchControl.addTargetWithActionForControlEvents(this, this.valueChanged, cc.CONTROL_EVENT_VALUECHANGED); + + // Set the layer size + layer.width = layer_width; + layer.height = 0; + layer.anchorX = 0.5; + layer.anchorY = 0.5; + + // Update the value label + this.valueChanged(switchControl, cc.CONTROL_EVENT_VALUECHANGED); + return true; + } + return false; + }, + valueChanged:function (sender, controlEvent) { + if (sender.isOn()) { + this._displayValueLabel.setString("On"); + } + else { + this._displayValueLabel.setString("Off"); + } + } +}); + +ControlSwitchTest.create = function (sceneTitle) { + var scene = new cc.Scene(); + var controlLayer = new ControlSwitchTest(); + if (controlLayer && controlLayer.init()) { + controlLayer.getSceneTitleLabel().setString(sceneTitle); + scene.addChild(controlLayer); + } + return scene; +}; \ No newline at end of file diff --git a/tests/js-tests/src/ExtensionsTest/EditBoxTest/EditBoxTest.js b/tests/js-tests/src/ExtensionsTest/EditBoxTest/EditBoxTest.js new file mode 100644 index 0000000000..97f87c9b02 --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/EditBoxTest/EditBoxTest.js @@ -0,0 +1,128 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 EditBoxTestLayer = cc.Layer.extend({ + _box1: null, + _box2: null, + _box3: null, + _box4: null, + + ctor: function () { + this._super(); + cc.associateWithNative(this, cc.Layer); + this.init(); + }, + + init: function () { + this._box1 = new cc.EditBox(cc.size(170, 50), new cc.Scale9Sprite("res/extensions/green_edit.png"), new cc.Scale9Sprite("res/extensions/orange_edit.png")); + this._box1.setString("EditBoxs"); + this._box1.x = 220; + this._box1.y = 50; + this._box1.setFontColor(cc.color(251, 250, 0)); + this._box1.setDelegate(this); + this.addChild(this._box1); + + this._box2 = new cc.EditBox(cc.size(130, 40), new cc.Scale9Sprite("res/extensions/green_edit.png")); + this._box2.setString("EditBox Sample"); + this._box2.x = 220; + this._box2.y = 190; + this._box2.setInputFlag(cc.EDITBOX_INPUT_FLAG_PASSWORD); + this._box2.setFontColor(cc.color(255, 250, 0)); + this._box2.setPlaceHolder("please enter password"); + this._box2.setPlaceholderFontColor(cc.color(255, 255, 255)); + this._box2.setDelegate(this); + this.addChild(this._box2); + + this._box3 = new cc.EditBox(cc.size(65, 40), new cc.Scale9Sprite("res/extensions/orange_edit.png")); + this._box3.setString("Image"); + this._box3.x = 220; + this._box3.y = 250; + this._box3.setFontColor(cc.color(15, 250, 245)); + this._box3.setDelegate(this); + this.addChild(this._box3); + + this._box4 = new cc.EditBox(cc.size(180, 40), new cc.Scale9Sprite("res/extensions/yellow_edit.png")); + this._box4.setPlaceholderFontColor(cc.color(255, 0, 0)); + this._box4.setPlaceHolder("Tooltip:"); + this._box4.x = 40; + this._box4.y = -100; + this._box4.setDelegate(this); + this._box4.setFontColor(cc.color(5, 4, 10)); + this._box4.setMaxLength(10); + this._box3.addChild(this._box4); + + var itemBack = new cc.MenuItemFont("Back", this.toExtensionsMainLayer, this); + itemBack.x = winSize.width - 50; + itemBack.y = 25; + var menuBack = new cc.Menu(itemBack); + menuBack.x = 0; + menuBack.y = 0; + this.addChild(menuBack); + + return true; + }, + + toExtensionsMainLayer: function (sender) { + var scene = new ExtensionsTestScene(); + scene.runThisTest(); + }, + + editBoxEditingDidBegin: function (editBox) { + cc.log("editBox " + this._getEditBoxName(editBox) + " DidBegin !"); + }, + + editBoxEditingDidEnd: function (editBox) { + cc.log("editBox " + this._getEditBoxName(editBox) + " DidEnd !"); + }, + + editBoxTextChanged: function (editBox, text) { + cc.log("editBox " + this._getEditBoxName(editBox) + ", TextChanged, text: " + text); + }, + + editBoxReturn: function (editBox) { + cc.log("editBox " + this._getEditBoxName(editBox) + " was returned !"); + }, + + _getEditBoxName :function(editBox){ + if (this._box1 == editBox) { + return "box1"; + } else if (this._box2 == editBox) { + return "box2"; + } else if (this._box3 == editBox) { + return "box3"; + } else if (this._box4 == editBox) { + return "box4"; + } + return "Unknown EditBox"; + } +}); + +var runEditBoxTest = function () { + var pScene = new cc.Scene(); + var pLayer = new EditBoxTestLayer(); + pScene.addChild(pLayer); + cc.director.runScene(pScene); +}; \ No newline at end of file diff --git a/tests/js-tests/src/ExtensionsTest/ExtensionsTest.js b/tests/js-tests/src/ExtensionsTest/ExtensionsTest.js new file mode 100644 index 0000000000..0bdae8491f --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/ExtensionsTest.js @@ -0,0 +1,157 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 LINE_SPACE = 40; +var ITEM_TAG_BASIC = 1000; + +var TEST_NOTIFICATIONCENTER = 0; +var TEST_CCCONTROLBUTTON = 1; +var TEST_COCOSBUILDER = 2; +var TEST_HTTPCLIENT = 3; + +var extensionsTestItemNames = [ + /* { + itemTitle:"NotificationCenterTest", + testScene:function () { + //runNotificationCenterTest(); + cc.log("not implement"); + } + },*/ + { + itemTitle:"CCControlButtonTest", + testScene:function () { + var pManager = ControlSceneManager.getInstance(); + var pScene = pManager.currentControlScene(); + cc.director.runScene(pScene); + } + }, + { + itemTitle:"CocosBuilderTest", + testScene:function () { + var pScene = new CocosBuilderTestScene(); + if (pScene) { + pScene.runThisTest(); + } + } + }, + /* { + itemTitle:"HttpClientTest", + testScene:function () { + //runHttpClientTest(); + cc.log("not implement"); + } + },*/ + { + itemTitle:"TableViewTest", + testScene:function () { + runTableViewTest(); + } + }, + { + itemTitle:"WebSocketTest", + testScene:function () { + runWebSocketTest(); + } + }, + { + itemTitle:"SocketIOTest", + testScene:function () { + runSocketIOTest(); + } + }, + { + itemTitle:"CCPoolTest", + testScene:function () { + runCCPoolTest(); + } + } +]; + +if(!cc.sys.isNative || cc.sys.OS_LINUX !== cc.sys.os){ + extensionsTestItemNames.push({ + itemTitle:"EditBoxTest", + testScene:function () { + runEditBoxTest(); + } + }); +} + +if (cc.sys.isNative && cc.sys.OS_IOS == cc.sys.os) { + extensionsTestItemNames.push({ + itemTitle:"PluginTest", + testScene:function () { + var testScene = pluginXSceneManager.currentPluginXScene(); + cc.director.runScene(testScene); + } + }) +} + +if (cc.sys.isNative && cc.sys.OS_WINDOWS != cc.sys.os) { + extensionsTestItemNames.push({ + itemTitle:"AssetsManagerTest", + testScene:function () { + var testScene = new AssetsManagerLoaderScene(); + if (testScene) { + testScene.runThisTest(); + } + } + }); +} + +var ExtensionsMainLayer = cc.Layer.extend({ + onEnter:function () { + this._super(); + + var winSize = cc.director.getWinSize(); + + var pMenu = new cc.Menu(); + pMenu.x = 0; + pMenu.y = 0; + cc.MenuItemFont.setFontName("Arial"); + cc.MenuItemFont.setFontSize(24); + for (var i = 0; i < extensionsTestItemNames.length; ++i) { + var selItem = extensionsTestItemNames[i]; + var pItem = new cc.MenuItemFont(selItem.itemTitle, this.menuCallback, this); + pItem.x = winSize.width / 2; + pItem.y = winSize.height - (i + 1) * LINE_SPACE; + pMenu.addChild(pItem, ITEM_TAG_BASIC + i); + } + this.addChild(pMenu); + }, + + menuCallback:function (sender) { + var nIndex = sender.zIndex - ITEM_TAG_BASIC; + extensionsTestItemNames[nIndex].testScene(); + } +}); + +var ExtensionsTestScene = TestScene.extend({ + runThisTest:function () { + var pLayer = new ExtensionsMainLayer(); + this.addChild(pLayer); + cc.director.runScene(this); + } +}); diff --git a/tests/js-tests/src/ExtensionsTest/NetworkTest/SocketIOTest.js b/tests/js-tests/src/ExtensionsTest/NetworkTest/SocketIOTest.js new file mode 100644 index 0000000000..57af0589b1 --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/NetworkTest/SocketIOTest.js @@ -0,0 +1,278 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + Created by Chris Hannon 2014 http://www.channon.us + + 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. + ****************************************************************************/ +/** @expose */ +window.io; + +var SocketIO = SocketIO || window.io; + +var SocketIOTestLayer = cc.Layer.extend({ + + _sioClient: null, + _sioEndpoint: null, + _sioClientStatus: null, + + ctor:function () { + this._super(); + this.init(); + }, + + init: function () { + + var winSize = cc.director.getWinSize(); + + var MARGIN = 40; + var SPACE = 35; + + var label = new cc.LabelTTF("SocketIO Test", "Arial", 28); + label.setPosition(cc.p(winSize.width / 2, winSize.height - MARGIN)); + this.addChild(label, 0); + + var menuRequest = new cc.Menu(); + menuRequest.setPosition(cc.p(0, 0)); + this.addChild(menuRequest); + + // Test to create basic client in the default namespace + var labelSIOClient = new cc.LabelTTF("Open SocketIO Client", "Arial", 22); + labelSIOClient.setAnchorPoint(cc.p(0,0)); + var itemSIOClient = new cc.MenuItemLabel(labelSIOClient, this.onMenuSIOClientClicked, this); + itemSIOClient.setPosition(cc.p(labelSIOClient.getContentSize().width / 2 + MARGIN, winSize.height - MARGIN - SPACE)); + menuRequest.addChild(itemSIOClient); + + // Test to create a client at the endpoint '/testpoint' + var labelSIOEndpoint = new cc.LabelTTF("Open SocketIO Endpoint", "Arial", 22); + labelSIOEndpoint.setAnchorPoint(cc.p(0,0)); + var itemSIOEndpoint = new cc.MenuItemLabel(labelSIOEndpoint, this.onMenuSIOEndpointClicked, this); + itemSIOEndpoint.setPosition(cc.p(winSize.width - (labelSIOEndpoint.getContentSize().width / 2 + MARGIN), winSize.height - MARGIN - SPACE)); + menuRequest.addChild(itemSIOEndpoint); + + // Test sending message to default namespace + var labelTestMessage = new cc.LabelTTF("Send Test Message", "Arial", 22); + labelTestMessage.setAnchorPoint(cc.p(0,0)); + var itemTestMessage = new cc.MenuItemLabel(labelTestMessage, this.onMenuTestMessageClicked, this); + itemTestMessage.setPosition(cc.p(labelTestMessage.getContentSize().width / 2 + MARGIN, winSize.height - MARGIN - 2 * SPACE)); + menuRequest.addChild(itemTestMessage); + + // Test sending message to the endpoint '/testpoint' + var labelTestMessageEndpoint = new cc.LabelTTF("Test Endpoint Message", "Arial", 22); + labelTestMessageEndpoint.setAnchorPoint(cc.p(0,0)); + var itemTestMessageEndpoint = new cc.MenuItemLabel(labelTestMessageEndpoint, this.onMenuTestMessageEndpointClicked, this); + itemTestMessageEndpoint.setPosition(cc.p(winSize.width - (labelTestMessageEndpoint.getContentSize().width / 2 + MARGIN), winSize.height - MARGIN - 2 * SPACE)); + menuRequest.addChild(itemTestMessageEndpoint); + + // Test sending event 'echotest' to default namespace + var labelTestEvent = new cc.LabelTTF("Send Test Event", "Arial", 22); + labelTestEvent.setAnchorPoint(cc.p(0,0)); + var itemTestEvent = new cc.MenuItemLabel(labelTestEvent, this.onMenuTestEventClicked, this); + itemTestEvent.setPosition(cc.p(labelTestEvent.getContentSize().width / 2 + MARGIN, winSize.height - MARGIN - 3 * SPACE)); + menuRequest.addChild(itemTestEvent); + + // Test sending event 'echotest' to the endpoint '/testpoint' + var labelTestEventEndpoint = new cc.LabelTTF("Test Endpoint Event", "Arial", 22); + labelTestEventEndpoint.setAnchorPoint(cc.p(0,0)); + var itemTestEventEndpoint = new cc.MenuItemLabel(labelTestEventEndpoint, this.onMenuTestEventEndpointClicked, this); + itemTestEventEndpoint.setPosition(cc.p(winSize.width - (labelTestEventEndpoint.getContentSize().width / 2 + MARGIN), winSize.height - MARGIN - 3 * SPACE)); + menuRequest.addChild(itemTestEventEndpoint); + + // Test disconnecting basic client + var labelTestClientDisconnect = new cc.LabelTTF("Disconnect Socket", "Arial", 22); + labelTestClientDisconnect.setAnchorPoint(cc.p(0,0)); + var itemClientDisconnect = new cc.MenuItemLabel(labelTestClientDisconnect, this.onMenuTestClientDisconnectClicked, this); + itemClientDisconnect.setPosition(cc.p(labelTestClientDisconnect.getContentSize().width / 2 + MARGIN, winSize.height - MARGIN - 4 * SPACE)); + menuRequest.addChild(itemClientDisconnect); + + // Test disconnecting the endpoint '/testpoint' + var labelTestEndpointDisconnect = new cc.LabelTTF("Disconnect Endpoint", "Arial", 22); + labelTestEndpointDisconnect.setAnchorPoint(cc.p(0,0)); + var itemTestEndpointDisconnect = new cc.MenuItemLabel(labelTestEndpointDisconnect, this.onMenuTestEndpointDisconnectClicked, this); + itemTestEndpointDisconnect.setPosition(cc.p(winSize.width - (labelTestEndpointDisconnect.getContentSize().width / 2 + MARGIN), winSize.height - MARGIN - 4 * SPACE)); + menuRequest.addChild(itemTestEndpointDisconnect); + + this._sioClientStatus = new cc.LabelTTF("Not connected...", "Arial", 14); + this._sioClientStatus.setAnchorPoint(cc.p(0, 0)); + this._sioClientStatus.setPosition(cc.p(0,winSize.height * .25)); + this.addChild(this._sioClientStatus); + + // Back Menu + var itemBack = new cc.MenuItemFont("Back", this.toExtensionsMainLayer, this); + itemBack.setPosition(cc.p(winSize.width - 50, 25)); + var menuBack = new cc.Menu(itemBack); + menuBack.setPosition(cc.p(0, 0)); + this.addChild(menuBack); + + return true; + }, + + onExit: function() { + if(this._sioEndpoint) this._sioEndpoint.disconnect(); + if(this._sioClient) this._sioClient.disconnect(); + + this._super(); + }, + + //socket callback for testing + testevent: function(data) { + var msg = this.tag + " says 'testevent' with data: " + data; + this.statusLabel.setString(msg); + cc.log(msg); + }, + + message: function(data) { + var msg = this.tag + " received message: " + data; + this.statusLabel.setString(msg); + cc.log(msg); + }, + + disconnection: function() { + var msg = this.tag + " disconnected!"; + this.statusLabel.setString(msg); + cc.log(msg); + }, + // Menu Callbacks + onMenuSIOClientClicked: function(sender) { + + //create a client by using this static method, url does not need to contain the protocol + var sioclient = SocketIO.connect("ws://tools.itharbors.com:4000", {"force new connection" : true}); + + //if you need to track multiple sockets it is best to store them with tags in your own array for now + sioclient.tag = "Test Client"; + + //attaching the status label to the socketio client + //this is only necessary in javascript due to scope within shared event handlers, + //as 'this' will refer to the socketio client + sioclient.statusLabel = this._sioClientStatus; + + //register event callbacks + //this is an example of a handler declared inline + sioclient.on("connect", function() { + var msg = sioclient.tag + " Connected!"; + this.statusLabel.setString(msg); + cc.log(msg); + sioclient.send(msg); + }); + + //example of a handler that is shared between multiple clients + sioclient.on("message", this.message); + + sioclient.on("echotest", function(data) { + cc.log("echotest 'on' callback fired!"); + var msg = this.tag + " says 'echotest' with data: " + data; + this.statusLabel.setString(msg); + cc.log(msg); + }); + + sioclient.on("testevent", this.testevent); + + sioclient.on("disconnect", this.disconnection); + + this._sioClient = sioclient; + + }, + + onMenuSIOEndpointClicked: function(sender) { + + //repeat the same connection steps for the namespace "testpoint" + var sioendpoint = SocketIO.connect("ws://tools.itharbors.com:4000/testpoint"); + + //a tag to differentiate in shared callbacks + sioendpoint.tag = "Test Endpoint"; + + sioendpoint.statusLabel = this._sioClientStatus; + + sioendpoint.on("connect", function() { + var msg = sioendpoint.tag + " Connected!"; + this.statusLabel.setString(msg); + cc.log(msg); + sioendpoint.send(msg); + }); + + //register event callbacks + sioendpoint.on("echotest", function(data) { + cc.log("echotest 'on' callback fired!"); + var msg = this.tag + " says 'echotest' with data: " + data; + this.statusLabel.setString(msg); + cc.log(msg); + }); + + sioendpoint.on("message", this.message); + + //demonstrating how callbacks can be shared within a delegate + sioendpoint.on("testevent", this.testevent); + + sioendpoint.on("disconnect", this.disconnection); + + this._sioEndpoint = sioendpoint; + + }, + + onMenuTestMessageClicked: function(sender) { + + //check that the socket is != NULL before sending or emitting events + //the client should be NULL either before initialization and connection or after disconnect + if(this._sioClient != null) this._sioClient.send("Hello Socket.IO!"); + + }, + + onMenuTestMessageEndpointClicked: function(sender) { + + if(this._sioEndpoint != null) this._sioEndpoint.send("Hello Socket.IO!"); + + }, + + onMenuTestEventClicked: function(sender) { + + if(this._sioClient != null) this._sioClient.emit("echotest","[{\"name\":\"myname\",\"type\":\"mytype\"}]"); + + }, + + onMenuTestEventEndpointClicked: function(sender) { + + if(this._sioEndpoint != null) this._sioEndpoint.emit("echotest","[{\"name\":\"myname\",\"type\":\"mytype\"}]"); + + }, + + onMenuTestClientDisconnectClicked: function(sender) { + + if(this._sioClient != null) this._sioClient.disconnect(); + + }, + + onMenuTestEndpointDisconnectClicked: function(sender) { + + if(this._sioEndpoint != null) this._sioEndpoint.disconnect(); + + }, + + toExtensionsMainLayer: function (sender) { + var scene = new ExtensionsTestScene(); + scene.runThisTest(); + } +}); + +var runSocketIOTest = function () { + var pScene = new cc.Scene(); + var pLayer = new SocketIOTestLayer(); + pScene.addChild(pLayer); + cc.director.runScene(pScene); +}; \ No newline at end of file diff --git a/tests/js-tests/src/ExtensionsTest/NetworkTest/WebSocketTest.js b/tests/js-tests/src/ExtensionsTest/NetworkTest/WebSocketTest.js new file mode 100644 index 0000000000..4455043a34 --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/NetworkTest/WebSocketTest.js @@ -0,0 +1,264 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + Copyright (c) 2013 James Chen + + 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. + ****************************************************************************/ + +var WebSocket = WebSocket || window.WebSocket || window.MozWebSocket; + +var WebSocketTestLayer = cc.Layer.extend({ + + _wsiSendText: null, + _wsiSendBinary: null, + _wsiError: null, + + _sendTextStatus: null, + _sendBinaryStatus: null, + _errorStatus: null, + + _sendTextTimes: 0, + _sendBinaryTimes: 0, + + init: function () { + + var winSize = cc.director.getWinSize(); + + var MARGIN = 40; + var SPACE = 35; + + var label = new cc.LabelTTF("WebSocket Test", "Arial", 28); + label.x = winSize.width / 2; + label.y = winSize.height - MARGIN; + this.addChild(label, 0); + + var menuRequest = new cc.Menu(); + menuRequest.x = 0; + menuRequest.y = 0; + this.addChild(menuRequest); + + // Send Text + var labelSendText = new cc.LabelTTF("Send Text", "Arial", 22); + var itemSendText = new cc.MenuItemLabel(labelSendText, this.onMenuSendTextClicked, this); + itemSendText.x = winSize.width / 2; + itemSendText.y = winSize.height - MARGIN - SPACE; + menuRequest.addChild(itemSendText); + + // Send Binary + var labelSendBinary = new cc.LabelTTF("Send Binary", "Arial", 22); + var itemSendBinary = new cc.MenuItemLabel(labelSendBinary, this.onMenuSendBinaryClicked, this); + itemSendBinary.x = winSize.width / 2; + itemSendBinary.y = winSize.height - MARGIN - 2 * SPACE; + menuRequest.addChild(itemSendBinary); + + + // Send Text Status Label + this._sendTextStatus = new cc.LabelTTF("Send Text WS is waiting...", "Arial", 14, cc.size(160, 100), cc.TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_TOP); + this._sendTextStatus.anchorX = 0; + this._sendTextStatus.anchorY = 0; + this._sendTextStatus.x = 0; + this._sendTextStatus.y = 25; + this.addChild(this._sendTextStatus); + + // Send Binary Status Label + this._sendBinaryStatus = new cc.LabelTTF("Send Binary WS is waiting...", "Arial", 14, cc.size(160, 100), cc.TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_TOP); + this._sendBinaryStatus.anchorX = 0; + this._sendBinaryStatus.anchorY = 0; + this._sendBinaryStatus.x = 160; + this._sendBinaryStatus.y = 25; + this.addChild(this._sendBinaryStatus); + + // Error Label + this._errorStatus = new cc.LabelTTF("Error WS is waiting...", "Arial", 14, cc.size(160, 100), cc.TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_TOP); + this._errorStatus.anchorX = 0; + this._errorStatus.anchorY = 0; + this._errorStatus.x = 320; + this._errorStatus.y = 25; + this.addChild(this._errorStatus); + + // Back Menu + var itemBack = new cc.MenuItemFont("Back", this.toExtensionsMainLayer, this); + itemBack.x = winSize.width - 50; + itemBack.y = 25; + var menuBack = new cc.Menu(itemBack); + menuBack.x = 0; + menuBack.y = 0; + this.addChild(menuBack); + + var self = this; + + this._wsiSendText = new WebSocket("ws://echo.websocket.org"); + this._wsiSendText.onopen = function(evt) { + self._sendTextStatus.setString("Send Text WS was opened."); + }; + + this._wsiSendText.onmessage = function(evt) { + self._sendTextTimes++; + var textStr = "response text msg: "+evt.data+", "+self._sendTextTimes; + cc.log(textStr); + + self._sendTextStatus.setString(textStr); + }; + + this._wsiSendText.onerror = function(evt) { + cc.log("sendText Error was fired"); + }; + + this._wsiSendText.onclose = function(evt) { + cc.log("_wsiSendText websocket instance closed."); + self._wsiSendText = null; + }; + + + this._wsiSendBinary = new WebSocket("ws://echo.websocket.org"); + this._wsiSendBinary.binaryType = "arraybuffer"; + this._wsiSendBinary.onopen = function(evt) { + self._sendBinaryStatus.setString("Send Binary WS was opened."); + }; + + this._wsiSendBinary.onmessage = function(evt) { + self._sendBinaryTimes++; + var binary = new Uint16Array(evt.data); + var binaryStr = "response bin msg: "; + + var str = ""; + for (var i = 0; i < binary.length; i++) { + if (binary[i] == 0) + { + str += "\'\\0\'"; + } + else + { + var hexChar = "0x" + binary[i].toString("16").toUpperCase(); + str += String.fromCharCode(hexChar); + } + } + + binaryStr += str + ", " + self._sendBinaryTimes; + cc.log(binaryStr); + self._sendBinaryStatus.setString(binaryStr); + }; + + this._wsiSendBinary.onerror = function(evt) { + cc.log("sendBinary Error was fired"); + }; + + this._wsiSendBinary.onclose = function(evt) { + cc.log("_wsiSendBinary websocket instance closed."); + self._wsiSendBinary = null; + }; + + this._wsiError = new WebSocket("ws://invalid.url.com"); + this._wsiError.onopen = function(evt) {}; + this._wsiError.onmessage = function(evt) {}; + this._wsiError.onerror = function(evt) { + cc.log("Error was fired"); + self._errorStatus.setString("an error was fired"); + }; + this._wsiError.onclose = function(evt) { + cc.log("_wsiError websocket instance closed."); + self._wsiError = null; + }; + + return true; + }, + + onExit: function() { + if (this._wsiSendText) + this._wsiSendText.close(); + + if (this._wsiSendBinary) + this._wsiSendBinary.close(); + + if (this._wsiError) + this._wsiError.close(); + this._super(); + }, + + // Menu Callbacks + onMenuSendTextClicked: function(sender) { + + if (this._wsiSendText.readyState == WebSocket.OPEN) + { + this._sendTextStatus.setString("Send Text WS is waiting..."); + this._wsiSendText.send("Hello WebSocket中文, I'm a text message."); + } + else + { + var warningStr = "send text websocket instance wasn't ready..."; + cc.log(warningStr); + this._sendTextStatus.setString(warningStr); + } + }, + + _stringConvertToArray:function (strData) { + if (!strData) + return null; + + var arrData = new Uint16Array(strData.length); + for (var i = 0; i < strData.length; i++) { + arrData[i] = strData.charCodeAt(i); + } + return arrData; + }, + + onMenuSendBinaryClicked: function(sender) + { + + if (this._wsiSendBinary.readyState == WebSocket.OPEN) + { + this._sendBinaryStatus.setString("Send Binary WS is waiting..."); + var buf = "Hello WebSocket中文,\0 I'm\0 a\0 binary\0 message\0."; + var binary = this._stringConvertToArray(buf); + + this._wsiSendBinary.send(binary.buffer); + } + else + { + var warningStr = "send binary websocket instance wasn't ready..."; + cc.log(warningStr); + this._sendBinaryStatus.setString(warningStr); + } + }, + + toExtensionsMainLayer: function (sender) { + var scene = new ExtensionsTestScene(); + scene.runThisTest(); + } +}); + +WebSocketTestLayer.create = function () { + var retObj = new WebSocketTestLayer(); + if (retObj && retObj.init()) { + return retObj; + } + return null; +}; + + +var runWebSocketTest = function () { + var pScene = new cc.Scene(); + var pLayer = WebSocketTestLayer.create(); + pScene.addChild(pLayer); + cc.director.runScene(pScene); +}; \ No newline at end of file diff --git a/tests/js-tests/src/ExtensionsTest/PluginXTest/AnalyticsTest.js b/tests/js-tests/src/ExtensionsTest/PluginXTest/AnalyticsTest.js new file mode 100644 index 0000000000..3165d79c43 --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/PluginXTest/AnalyticsTest.js @@ -0,0 +1,256 @@ +/**************************************************************************** + Copyright (c) 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 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 g_pAnalytics = null; +var s_strAppKey = ""; +// The app key of flurry +var FLURRY_KEY_IOS = "KMGG7CD9WPK2TW4X9VR8"; +var FLURRY_KEY_ANDROID = "SPKFH8KMPGHMMBWRBT5W"; +var UMENG_KEY_IOS = "50d2b18c5270152187000097"; +var UMENG_KEY_ANDROID = ""; // umeng key for android is setted in AndroidManifest.xml + + +if (!plugin) { + var plugin = {}; +} + +plugin.onApplicationDidEnterBackground = function() { + if (g_pAnalytics != null) { + cc.log("plugin.onApplicationDidEnterBackground."); + g_pAnalytics.stopSession(); + } +}; + + +plugin.onApplicationWillEnterForeground = function() { + if (g_pAnalytics != null) { + cc.log("plugin.onApplicationWillEnterForeground."); + g_pAnalytics.startSession(s_strAppKey); + } +}; + +var loadAnalyticsPlugin = function() { + var langType = cc.sys.language;//cc.Application.getInstance().getCurrentLanguage(); + + var umengKey = ""; + var flurryKey = ""; + + if (cc.sys.os == cc.sys.OS_IOS) + { + umengKey = UMENG_KEY_IOS; + flurryKey = FLURRY_KEY_IOS; + } + else if (cc.sys.os == cc.sys.OS_ANDROID) + { + umengKey = UMENG_KEY_ANDROID; + flurryKey = FLURRY_KEY_ANDROID; + } + + var pluginManager = plugin.PluginManager.getInstance(); + if (cc.LANGUAGE_CHINESE == langType) + { + g_pAnalytics = pluginManager.loadPlugin("AnalyticsUmeng"); + s_strAppKey = umengKey; + } + else + { + g_pAnalytics = pluginManager.loadPlugin("AnalyticsFlurry"); + s_strAppKey = flurryKey; + } + + g_pAnalytics.setDebugMode(true); + g_pAnalytics.startSession(s_strAppKey); + g_pAnalytics.setCaptureUncaughtException(true); + + g_pAnalytics.callFuncWithParam("updateOnlineConfig", null); + g_pAnalytics.callFuncWithParam("setReportLocation", new plugin.PluginParam(plugin.PluginParam.ParamType.TypeBool, true)); + g_pAnalytics.callFuncWithParam("logPageView", null); + g_pAnalytics.callFuncWithParam("setVersionName", new plugin.PluginParam(plugin.PluginParam.ParamType.TypeString, "1.1")); + g_pAnalytics.callFuncWithParam("setAge", new plugin.PluginParam(plugin.PluginParam.ParamType.TypeInt, 20)); + g_pAnalytics.callFuncWithParam("setGender", new plugin.PluginParam(plugin.PluginParam.ParamType.TypeInt, 1)); + g_pAnalytics.callFuncWithParam("setUserId", new plugin.PluginParam(plugin.PluginParam.ParamType.TypeString, "123456")); + g_pAnalytics.callFuncWithParam("setUseHttps", new plugin.PluginParam(plugin.PluginParam.ParamType.TypeBool, false)); +}; + + +TAG_LOG_EVENT_ID = 0; +TAG_LOG_EVENT_ID_KV = 1; +TAG_LOG_ONLINE_CONFIG = 2; +TAG_LOG_EVENT_ID_DURATION = 3; +TAG_LOG_EVENT_BEGIN = 4; +TAG_LOG_EVENT_END = 5; +TAG_MAKE_ME_CRASH = 6; + +var s_EventMenuItem = [ + {id: "OnlineConfig", tag: TAG_LOG_ONLINE_CONFIG}, + {id: "LogEvent-eventId", tag: TAG_LOG_EVENT_ID}, + {id: "LogEvent-eventId-kv", tag: TAG_LOG_EVENT_ID_KV}, + {id: "LogEvent-eventId-Duration", tag: TAG_LOG_EVENT_ID_DURATION}, + {id: "LogEvent-Begin", tag: TAG_LOG_EVENT_BEGIN}, + {id: "LogEvent-End", tag: TAG_LOG_EVENT_END}, + {id: "MakeMeCrash", tag: TAG_MAKE_ME_CRASH} +]; + +var AnalyticsTestLayer = PluginXTest.extend({ + + _title:"Plugin-x Test", + _subtitle: cc.LANGUAGE_CHINESE == cc.sys.language ? "umeng" : "flurry",//cc.Application.getInstance().getCurrentLanguage() ? "umeng" : "flurry", + + onEnter: function() { + this._super(); + var size = cc.director.getWinSize(); + + loadAnalyticsPlugin(); + + var pMenu = new cc.Menu(); + pMenu.setPosition( cc.p(0, 0) ); + this.addChild(pMenu, 1); + + var yPos = 0; + for (var i = 0; i < s_EventMenuItem.length; i++) { + var label = new cc.LabelTTF(s_EventMenuItem[i].id, "Arial", 24); + var pMenuItem = new cc.MenuItemLabel(label, this.eventMenuCallback, this); + pMenu.addChild(pMenuItem, 0, s_EventMenuItem[i].tag); + yPos = size.height - 50*i - 100; + pMenuItem.setPosition( cc.p(size.width / 2, yPos)); + } + + var strName = g_pAnalytics.getPluginName(); + var strVer = g_pAnalytics.getPluginVersion(); + var ret = "Plugin : "+strName+", Ver : "+ strVer; + var pLabel = new cc.LabelTTF(ret, "Arial", 24, cc.size(size.width, 0), cc.TEXT_ALIGNMENT_CENTER); + pLabel.setPosition(cc.p(size.width / 2, yPos - 100)); + this.addChild(pLabel); + + var label = new cc.LabelTTF("reload all plugins", "Arial", 24); + var pMenuItem = new cc.MenuItemLabel(label, this.reloadPluginMenuCallback, this); + pMenuItem.setAnchorPoint(cc.p(0.5, 0)); + pMenu.addChild(pMenuItem, 0); + pMenuItem.setPosition( cc.p(size.width / 2, 0)); + }, + + reloadPluginMenuCallback: function(pSender) { + plugin.PluginManager.getInstance().unloadPlugin("AnalyticsFlurry"); + plugin.PluginManager.getInstance().unloadPlugin("AnalyticsUmeng"); + + loadAnalyticsPlugin(); + }, + + eventMenuCallback: function(pSender) { + switch (pSender.getTag()) + { + case TAG_LOG_EVENT_ID: + { + g_pAnalytics.logEvent("click"); + g_pAnalytics.logEvent("music"); + } + break; + case TAG_LOG_EVENT_ID_KV: + { + var paramMap = {}; + paramMap["type"] = "popular"; + paramMap["artist"] = "JJLin"; + g_pAnalytics.logEvent("music", paramMap); + } + break; + case TAG_LOG_ONLINE_CONFIG: + { + cc.log("Online config = " + g_pAnalytics.callStringFuncWithParam("getConfigParams", new plugin.PluginParam(plugin.PluginParam.ParamType.TypeString, "abc"))); + } + break; + case TAG_LOG_EVENT_ID_DURATION: + { + g_pAnalytics.callFuncWithParam("logEventWithDuration", + new plugin.PluginParam(plugin.PluginParam.ParamType.TypeString, "book"), + new plugin.PluginParam(plugin.PluginParam.ParamType.TypeInt, 12000)); + g_pAnalytics.callFuncWithParam("logEventWithDurationLabel", + new plugin.PluginParam(plugin.PluginParam.ParamType.TypeString, "book"), + new plugin.PluginParam(plugin.PluginParam.ParamType.TypeInt, 23000), + new plugin.PluginParam(plugin.PluginParam.ParamType.TypeString, "chapter1")); + var paramMap = {}; + paramMap["type"] = "popular"; + paramMap["artist"] = "JJLin"; + g_pAnalytics.callFuncWithParam("logEventWithDurationParams", + new plugin.PluginParam(plugin.PluginParam.ParamType.TypeString, "music"), + new plugin.PluginParam(plugin.PluginParam.ParamType.TypeInt, 2330000), + new plugin.PluginParam(plugin.PluginParam.ParamType.TypeStringMap, paramMap)); + } + break; + case TAG_LOG_EVENT_BEGIN: + { + g_pAnalytics.logTimedEventBegin("music"); + + var paramMap = {}; + paramMap["type"] = "popular"; + paramMap["artist"] = "JJLin"; + + g_pAnalytics.callFuncWithParam("logTimedEventWithLabelBegin", + new plugin.PluginParam(plugin.PluginParam.ParamType.TypeString, "music"), + new plugin.PluginParam(plugin.PluginParam.ParamType.TypeString, "one")); + g_pAnalytics.callFuncWithParam("logTimedKVEventBegin", + new plugin.PluginParam(plugin.PluginParam.ParamType.TypeString, "music"), + new plugin.PluginParam(plugin.PluginParam.ParamType.TypeString, "flag0"), + new plugin.PluginParam(plugin.PluginParam.ParamType.TypeStringMap, paramMap)); + + g_pAnalytics.callFuncWithParam("logTimedEventBeginWithParams", + new plugin.PluginParam(plugin.PluginParam.ParamType.TypeString, "music-kv"), + new plugin.PluginParam(plugin.PluginParam.ParamType.TypeStringMap, paramMap)); + } + break; + case TAG_LOG_EVENT_END: + { + g_pAnalytics.logTimedEventEnd("music"); + + g_pAnalytics.callFuncWithParam("logTimedEventWithLabelEnd", + new plugin.PluginParam(plugin.PluginParam.ParamType.TypeString, "music"), + new plugin.PluginParam(plugin.PluginParam.ParamType.TypeString, "one")); + g_pAnalytics.callFuncWithParam("logTimedKVEventEnd", + new plugin.PluginParam(plugin.PluginParam.ParamType.TypeString, "music"), + new plugin.PluginParam(plugin.PluginParam.ParamType.TypeString, "flag0")); + + g_pAnalytics.callFuncWithParam("logTimedEventEnd", new plugin.PluginParam(plugin.PluginParam.ParamType.TypeString, "music-kv")); + } + break; + case TAG_MAKE_ME_CRASH: + { + + } + break; + default: + break; + } + }, + + onNextCallback:function (sender) { + var s = new FacebookTest(); + s.addChild(new FacebookLayer); + director.runScene(s); + }, + onBackCallback:function (sender) { + var s = new FacebookTest(); + s.addChild(new FacebookLayer); + director.runScene(s); + } + +}); diff --git a/tests/js-tests/src/ExtensionsTest/PluginXTest/IOSIAPTest.js b/tests/js-tests/src/ExtensionsTest/PluginXTest/IOSIAPTest.js new file mode 100644 index 0000000000..a0f93437b2 --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/PluginXTest/IOSIAPTest.js @@ -0,0 +1,216 @@ +/**************************************************************************** + Copyright (c) 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 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. + ****************************************************************************/ + +TAG_SETSERVERMODE = 0; +TAG_GETPRODUCTLIST = 1; +TAG_PAYMENT = 2; +TAG_TOAST = 3; + +TAG_SETSERVERMODE_RESULT = 4; +TAG_GETPRODUCTLIST_RESULT = 5; +TAG_PAYMENT_RESULT = 6; + +var s_IAPFunctionItem = [ + {name: "setServerMode", tag: TAG_SETSERVERMODE}, + {name: "getProductList", tag: TAG_GETPRODUCTLIST}, + {name: "PayForProduct", tag: TAG_PAYMENT} +]; +var s_IAPResultItem = [ + {name: "false", tag: TAG_SETSERVERMODE_RESULT}, + {name: "[ ]", tag: TAG_GETPRODUCTLIST_RESULT}, + {name: "didn't call payFunction yet", tag: TAG_PAYMENT_RESULT} +]; +var IAPTestLayer = PluginXTest.extend({ + _serverMode: false, + onEnter: function () { + this._super(); + this.initPlugin(); + this.addMenuItem(); + this.initToast(); + }, + initPlugin: function () { + var pluginManager = plugin.PluginManager.getInstance(); + this.PluginIAP = pluginManager.loadPlugin("IOSIAP"); + this.PluginIAP.setListener(this); + }, + addMenuItem: function () { + var payMenu = new cc.Menu(); + for (var i = 0; i < s_IAPFunctionItem.length; i++) { + var text = new cc.LabelTTF(s_IAPFunctionItem[i].name, "Arial", 20); + var item = new cc.MenuItemLabel(text, this.menuCallBack, this); + item.tag = s_IAPFunctionItem[i].tag; + item.x = 200; + item.y = cc.winSize.height - 200 - i * 50; + + var resultLabel = new cc.LabelTTF(s_IAPResultItem[i].name, "Arial", 20); + resultLabel.color = cc.color(125, 125, 125); + resultLabel.anchorX = 0; + resultLabel.tag = s_IAPResultItem[i].tag; + resultLabel.x = 300; + resultLabel.y = cc.winSize.height - 200 - i * 50; + payMenu.addChild(item); + this.addChild(resultLabel); + } + payMenu.x = 0; + payMenu.y = 0; + this.addChild(payMenu); + }, + closeFunction: function (sender) { + var scene = new ExtensionsTestScene(); + scene.runThisTest(); + cc.director.runScene(scene); + }, + initToast: function () { + this.toastLayer = new cc.LayerColor(); + var label = new cc.LabelTTF("loading", "Arial", 16); + this.toastLayer.addChild(label); + this.toastLayer.setTag(TAG_TOAST); + label.x = cc.winSize.width / 2; + label.y = cc.winSize.height / 2; + this.toastLayer.retain(); + this.toastLayer.setColor(cc.color(100, 100, 100, 100)); + }, + addTouch: function (bool) { + if (bool) { + var self = this.toastLayer; + this.listener = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches: true, + onTouchBegan: function (touch, event) { + return true; + }, + onTouchMoved: function (touch, event) { + }, + onTouchEnded: function (touch, event) { + }, + onTouchCancelled: function (touch, event) { + } + }); + cc.eventManager.addListener(this.listener, self); + } else { + cc.eventManager.removeListener(this.listener); + } + }, + toggleToast: function (show) { + if (show) { + if (!this.getChildByTag(TAG_TOAST)) { + this.addChild(this.toastLayer); + this.addTouch(true); + } + } else { + this.toastLayer.removeFromParent(true); + this.addTouch(false); + } + }, + menuCallBack: function (sender) { + this.toggleToast(true); + if (sender.tag === TAG_SETSERVERMODE) { + this.PluginIAP.callFuncWithParam("setServerMode"); + var label = this.getChildByTag(TAG_SETSERVERMODE_RESULT); + this._serverMode = true; + if (label) { + label.setString("true"); + this.toggleToast(false); + } + } else if (sender.tag == TAG_GETPRODUCTLIST) { + //replace these ids to your own productIdentifiers + var pidList = ["001", "002"]; + this.PluginIAP.callFuncWithParam("requestProducts", plugin.PluginParam(plugin.PluginParam.ParamType.TypeString, pidList.toString())); + } else if (sender.tag == TAG_PAYMENT) { + if (!this.product) { + var label = this.getChildByTag(TAG_PAYMENT_RESULT); + if (label) { + label.setString("please call requestProducts first"); + this.toggleToast(false); + return; + } + } + this.PluginIAP.payForProduct(this.product[0]); + } + }, + + onPayResult: function (ret, msg, productInfo) { + this.toggleToast(false); + cc.log("onPayResult ret is " + ret); + var str = ""; + if (ret == plugin.ProtocolIAP.PayResultCode.PaySuccess) { + str = "payment Success pid is " + productInfo.productId; + //if you use server mode get the receive message and post to your server + if (this._serverMode && msg) { + str = "payment verify from server"; + cc.log(str); + this.postServerData(msg); + } + } else if (ret == plugin.ProtocolIAP.PayResultCode.PayFail) { + str = "payment fail"; + } + var label = this.getChildByTag(TAG_PAYMENT_RESULT); + if (label) { + label.setString(str); + } + }, + onRequestProductResult: function (ret, productInfo) { + var msgStr = ""; + if (ret == plugin.ProtocolIAP.RequestProductCode.RequestFail) { + msgStr = "request error"; + this.toggleToast(false); + } else if (ret == plugin.ProtocolIAP.RequestProductCode.RequestSuccess) { + cc.log("request RequestSuccees " + productInfo[0].productName); + this.product = productInfo; + msgStr = "list: ["; + for (var i = 0; i < productInfo.length; i++) { + var product = productInfo[i]; + msgStr += product.productName + " "; + } + msgStr += " ]"; + this.toggleToast(false); + } + var label = this.getChildByTag(TAG_GETPRODUCTLIST_RESULT); + if (label) { + label.setString(msgStr); + } + }, + postServerData: function (data) { + var that = this; + var xhr = cc.loader.getXMLHttpRequest(); + + //replace to your own server address + xhr.open("POST", "http://localhost/"); + that.toggleToast(true); + xhr.onreadystatechange = function () { + if (xhr.readyState == 4 && xhr.status == 200) { + that.toggleToast(false); + var result = JSON.parse(xhr.responseText); + that.PluginIAP.callFuncWithParam("finishTransaction", new plugin.PluginParam(plugin.PluginParam.ParamType.TypeString, result.receipt.in_app[0].product_id)); + } + }; + // you can add your data and post them to your server; + var result = {userid: 100, receipt: data}; + xhr.send(JSON.stringify(result)); + }, + onExit: function () { + this._super(); + this.toastLayer.release(); + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/ExtensionsTest/PluginXTest/PluginXTest.js b/tests/js-tests/src/ExtensionsTest/PluginXTest/PluginXTest.js new file mode 100644 index 0000000000..f724f12f7b --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/PluginXTest/PluginXTest.js @@ -0,0 +1,99 @@ +/**************************************************************************** + Copyright (c) 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 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 PluginXTest = cc.Layer.extend({ + _sceneTitleLabel:null, + + getSceneTitleLabel:function(){return this._sceneTitleLabel;}, + setSceneTitleLabel:function(sceneTitleLabel){this._sceneTitleLabel = sceneTitleLabel;}, + + ctor:function(title){ + this._super() + // Get the sceensize + var screensize = cc.winSize; + + var pBackItem = new cc.MenuItemFont("Back", this.toExtensionsMainLayer, this); + pBackItem.x = screensize.width - 50; + pBackItem.y = 25; + var pBackMenu = new cc.Menu(pBackItem); + pBackMenu.x = 0; + pBackMenu.y = 0; + this.addChild(pBackMenu, 10); + + // Add the generated background + var background = new cc.Sprite(s_extensions_background); + background.x = screensize.width / 2; + background.y = screensize.height / 2; + var bgRect = background.getTextureRect(); + background.scaleX = screensize.width/bgRect.width; + background.scaleY = screensize.height/bgRect.height; + this.addChild(background); + + // Add the ribbon + var ribbon = new cc.Scale9Sprite(s_extensions_ribbon, cc.rect(1, 1, 48, 55)); + ribbon.width = screensize.width; + ribbon.height = 57; + ribbon.x = screensize.width / 2.0; + ribbon.y = screensize.height - ribbon.height / 2.0; + this.addChild(ribbon); + + // Add the title + this.setSceneTitleLabel(new cc.LabelTTF(title || "Title", "Arial", 12)); + this._sceneTitleLabel.x = screensize.width / 2; + this._sceneTitleLabel.y = screensize.height - this._sceneTitleLabel.height / 2 - 5; + this.addChild(this._sceneTitleLabel, 1); + + // Add the menu + var item1 = new cc.MenuItemImage(s_pathB1, s_pathB2, this.previousCallback, this); + var item2 = new cc.MenuItemImage(s_pathR1, s_pathR2, this.restartCallback, this); + var item3 = new cc.MenuItemImage(s_pathF1, s_pathF2, this.nextCallback, this); + + var menu = new cc.Menu(item1, item3, item2); + menu.x = 0; + menu.y = 0; + item1.x = screensize.width / 2 - 100; + item1.y = 37; + item2.x = screensize.width / 2; + item2.y = 35; + item3.x = screensize.width / 2 + 100; + item3.y = 37; + + this.addChild(menu ,1); + }, + + toExtensionsMainLayer:function(sender){ + var pScene = new ExtensionsTestScene(); + pScene.runThisTest(); + }, + + previousCallback:function(sender){ + cc.director.runScene(pluginXSceneManager.previousPluginXScene()); + }, + restartCallback:function(sender){ + cc.director.runScene(pluginXSceneManager.currentPluginXScene()); + }, + nextCallback:function(sender){ + cc.director.runScene(pluginXSceneManager.nextPluginXScene()); + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/ExtensionsTest/PluginXTest/PluginXTestsManager.js b/tests/js-tests/src/ExtensionsTest/PluginXTest/PluginXTestsManager.js new file mode 100644 index 0000000000..51c499a6c0 --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/PluginXTest/PluginXTestsManager.js @@ -0,0 +1,74 @@ +/**************************************************************************** + Copyright (c) 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 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 pluginXTestItemNames = []; + +if (cc.sys.isMobile && cc.sys.os == cc.sys.OS_IOS) { + pluginXTestItemNames.push({ + itemTitle: "Analytics Test", + testLayer: function () { + return new AnalyticsTestLayer(this.itemTitle); + } + }); +} +if (cc.sys.isMobile && cc.sys.os == cc.sys.OS_IOS) { + pluginXTestItemNames.push({ + itemTitle: "iOS IAP Test", + testLayer: function () { + return new IAPTestLayer(this.itemTitle); + } + }); +} + +var pluginXSceneManager = { + _currentPluginXSceneId: 0, + + getCurrentPluginXSceneId: function () { + return this._currentPluginXSceneId; + }, + setCurrentPluginXSceneId: function (currentPluginXSceneId) { + this._currentPluginXSceneId = currentPluginXSceneId + }, + + nextPluginXScene: function () { + this._currentPluginXSceneId = (this._currentPluginXSceneId + 1) % pluginXTestItemNames.length; + return this.currentPluginXScene(); + }, + + previousPluginXScene: function () { + this._currentPluginXSceneId = this._currentPluginXSceneId - 1; + if (this._currentPluginXSceneId < 0) { + this._currentPluginXSceneId = pluginXTestItemNames.length - 1; + } + + return this.currentPluginXScene(); + }, + + currentPluginXScene: function () { + var scene = new cc.Scene(); + var layer = pluginXTestItemNames[this._currentPluginXSceneId].testLayer(); + scene.addChild(layer); + return scene; + } +}; \ No newline at end of file diff --git a/tests/js-tests/src/ExtensionsTest/S9SpriteTest/S9SpriteTest.js b/tests/js-tests/src/ExtensionsTest/S9SpriteTest/S9SpriteTest.js new file mode 100644 index 0000000000..b0efb1d6e6 --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/S9SpriteTest/S9SpriteTest.js @@ -0,0 +1,559 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + Copyright (c) 2013 Surith Thekkiam + + 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. + ****************************************************************************/ + +var sceneIdx = -1; + +var spriteFrameCache = cc.spriteFrameCache; + +//------------------------------------------------------------------ +// +// S9SpriteTestDemo +// +//------------------------------------------------------------------ +var S9SpriteTestDemo = cc.LayerGradient.extend({ + _title:"", + _subtitle:"", + + ctor:function() { + this._super(cc.color(0,0,0,255), cc.color(98,99,117,255)); + cc.spriteFrameCache.addSpriteFrames(s_s9s_blocks9_plist); + cc.log('sprite frames added to sprite frame cache...'); + }, + onEnter:function () { + this._super(); + + var label = new cc.LabelTTF(this._title, "Arial", 28); + this.addChild(label, 1); + label.x = winSize.width / 2; + label.y = winSize.height - 50; + + if (this._subtitle !== "") { + var l = new cc.LabelTTF(this._subtitle, "Thonburi", 16); + this.addChild(l, 1); + l.x = winSize.width / 2; + l.y = winSize.height - 80; + } + + var item1 = new cc.MenuItemImage(s_pathB1, s_pathB2, this.onBackCallback, this); + var item2 = new cc.MenuItemImage(s_pathR1, s_pathR2, this.onRestartCallback, this); + var item3 = new cc.MenuItemImage(s_pathF1, s_pathF2, this.onNextCallback, this); + + var menu = new cc.Menu(item1, item2, item3); + + menu.x = 0; + menu.y = 0; + var width = item2.width, height = item2.height; + item1.x = winSize.width/2 - width*2; + item1.y = height/2; + item2.x = winSize.width/2; + item2.y = height/2; + item3.x = winSize.width/2 + width*2; + item3.y = height/2; + + this.addChild(menu, 1); + }, + + onExit:function () { + this._super(); + }, + + onRestartCallback:function (sender) { + var s = new S9SpriteTestScene(); + s.addChild(restartS9SpriteTest()); + director.runScene(s); + }, + onNextCallback:function (sender) { + var s = new S9SpriteTestScene(); + s.addChild(nextS9SpriteTest()); + director.runScene(s); + }, + onBackCallback:function (sender) { + var s = new S9SpriteTestScene(); + s.addChild(previousS9SpriteTest()); + director.runScene(s); + } +}); + +// S9BatchNodeBasic + +var S9BatchNodeBasic = S9SpriteTestDemo.extend({ + + _title:"Scale9Sprite created empty and updated from SpriteBatchNode", + _subtitle:"updateWithBatchNode(); capInsets=full size", + + ctor:function() { + this._super(); + + var x = winSize.width / 2; + var y = 0 + (winSize.height / 2); + + cc.log("S9BatchNodeBasic ..."); + + var batchNode = new cc.SpriteBatchNode("res/Images/blocks9.png"); + cc.log("batchNode created with : " + "res/Images/blocks9.png"); + + var blocks = new cc.Scale9Sprite(); + cc.log("... created"); + + blocks.updateWithBatchNode(batchNode, cc.rect(0, 0, 96, 96), false, cc.rect(0, 0, 96, 96)); + cc.log("... updateWithBatchNode"); + + blocks.x = x; + blocks.y = y; + cc.log("... setPosition"); + + this.addChild(blocks); + cc.log("this..addChild"); + + cc.log("... S9BatchNodeBasic done."); + } +}); + +// S9FrameNameSpriteSheet + +var S9FrameNameSpriteSheet = S9SpriteTestDemo.extend({ + + _title:"Scale9Sprite from sprite sheet", + _subtitle:"createWithSpriteFrameName(); default cap insets", + + ctor:function() { + this._super(); + + var x = winSize.width / 2; + var y = 0 + (winSize.height / 2); + + cc.log("S9FrameNameSpriteSheet ..."); + + var blocks = new cc.Scale9Sprite('blocks9.png'); + cc.log("... created"); + + blocks.x = x; + blocks.y = y; + cc.log("... setPosition"); + + this.addChild(blocks); + cc.log("this..addChild"); + + cc.log("... S9FrameNameSpriteSheet done."); + } +}); + +// S9FrameNameSpriteSheetRotated + +var S9FrameNameSpriteSheetRotated = S9SpriteTestDemo.extend({ + + _title:"Scale9Sprite from sprite sheet (stored rotated)", + _subtitle:"createWithSpriteFrameName(); default cap insets", + + ctor:function() { + this._super(); + + var x = winSize.width / 2; + var y = 0 + (winSize.height / 2); + + cc.log("S9FrameNameSpriteSheetRotated ..."); + + var blocks = new cc.Scale9Sprite('blocks9r.png'); + cc.log("... created"); + + blocks.x = x; + blocks.y = y; + cc.log("... setPosition"); + + this.addChild(blocks); + cc.log("this..addChild"); + + cc.log("... S9FrameNameSpriteSheetRotated done."); + } +}); + +// S9BatchNodeScaledNoInsets + +var S9BatchNodeScaledNoInsets = S9SpriteTestDemo.extend({ + + _title:"Scale9Sprite created empty and updated from SpriteBatchNode", + _subtitle:"updateWithBatchNode(); capInsets=full size; rendered 4 X width, 2 X height", + + ctor:function() { + this._super(); + + var x = winSize.width / 2; + var y = 0 + (winSize.height / 2); + + cc.log("S9BatchNodeScaledNoInsets ..."); + + // scaled without insets + var batchNode_scaled = new cc.SpriteBatchNode("res/Images/blocks9.png"); + cc.log("batchNode_scaled created with : " + "res/Images/blocks9.png"); + + var blocks_scaled = new cc.Scale9Sprite(); + cc.log("... created"); + blocks_scaled.updateWithBatchNode(batchNode_scaled, cc.rect(0, 0, 96, 96), false, cc.rect(0, 0, 96, 96)); + cc.log("... updateWithBatchNode"); + + blocks_scaled.x = x; + blocks_scaled.y = y; + cc.log("... setPosition"); + + blocks_scaled.width = 96 * 4; + blocks_scaled.height = 96*2; + cc.log("... setContentSize"); + + this.addChild(blocks_scaled); + cc.log("this..addChild"); + + cc.log("... S9BtchNodeScaledNoInsets done."); + } +}); + +// S9FrameNameSpriteSheetScaledNoInsets + +var S9FrameNameSpriteSheetScaledNoInsets = S9SpriteTestDemo.extend({ + + _title:"Scale9Sprite from sprite sheet", + _subtitle:"createWithSpriteFrameName(); default cap insets; rendered 4 X width, 2 X height", + + ctor:function() { + this._super(); + + var x = winSize.width / 2; + var y = 0 + (winSize.height / 2); + + cc.log("S9FrameNameSpriteSheetScaledNoInsets ..."); + + var blocks_scaled = new cc.Scale9Sprite('blocks9.png'); + cc.log("... created"); + + blocks_scaled.x = x; + blocks_scaled.y = y; + cc.log("... setPosition"); + + blocks_scaled.width = 96 * 4; + blocks_scaled.height = 96*2; + cc.log("... setContentSize"); + + this.addChild(blocks_scaled); + cc.log("this..addChild"); + + cc.log("... S9FrameNameSpriteSheetScaledNoInsets done."); + } +}); + +// S9FrameNameSpriteSheetRotatedScaledNoInsets + +var S9FrameNameSpriteSheetRotatedScaledNoInsets = S9SpriteTestDemo.extend({ + + _title:"Scale9Sprite from sprite sheet (stored rotated)", + _subtitle:"createWithSpriteFrameName(); default cap insets; rendered 4 X width, 2 X height", + + ctor:function() { + this._super(); + + var x = winSize.width / 2; + var y = 0 + (winSize.height / 2); + + cc.log("S9FrameNameSpriteSheetRotatedScaledNoInsets ..."); + + var blocks_scaled = new cc.Scale9Sprite('blocks9r.png'); + cc.log("... created"); + + blocks_scaled.x = x; + blocks_scaled.y = y; + cc.log("... setPosition"); + + blocks_scaled.width = 96 * 4; + blocks_scaled.height = 96*2; + cc.log("... setContentSize"); + + this.addChild(blocks_scaled); + cc.log("this..addChild"); + + cc.log("... S9FrameNameSpriteSheetRotatedScaledNoInsets done."); + } +}); + + +// S9BatchNodeScaleWithCapInsets + +var S9BatchNodeScaleWithCapInsets = S9SpriteTestDemo.extend({ + + _title:"Scale9Sprite created empty and updated from SpriteBatchNode", + _subtitle:"updateWithBatchNode(); capInsets=(32, 32, 32, 32)", + + ctor:function() { + this._super(); + + var x = winSize.width / 2; + var y = 0 + (winSize.height / 2); + + cc.log("S9BatchNodeScaleWithCapInsets ..."); + + var batchNode_scaled_with_insets = new cc.SpriteBatchNode("res/Images/blocks9.png"); + cc.log("batchNode_scaled_with_insets created with : " + "res/Images/blocks9.png"); + + var blocks_scaled_with_insets = new cc.Scale9Sprite(); + cc.log("... created"); + + blocks_scaled_with_insets.updateWithBatchNode(batchNode_scaled_with_insets, cc.rect(0, 0, 96, 96), false, cc.rect(32, 32, 32, 32)); + cc.log("... updateWithBatchNode"); + + blocks_scaled_with_insets.width = 96 * 4.5; + blocks_scaled_with_insets.height = 96 * 2.5; + cc.log("... setContentSize"); + + blocks_scaled_with_insets.x = x; + blocks_scaled_with_insets.y = y; + cc.log("... setPosition"); + + this.addChild(blocks_scaled_with_insets); + cc.log("this..addChild"); + + cc.log("... S9BatchNodeScaleWithCapInsets done."); + } +}); + +// S9FrameNameSpriteSheetInsets + +var S9FrameNameSpriteSheetInsets = S9SpriteTestDemo.extend({ + + _title:"Scale9Sprite scaled with insets sprite sheet", + _subtitle:"createWithSpriteFrameName(); cap insets=(32, 32, 32, 32)", + + ctor:function() { + this._super(); + + var x = winSize.width / 2; + var y = 0 + (winSize.height / 2); + + cc.log("S9FrameNameSpriteSheetInsets ..."); + + var blocks_with_insets = new cc.Scale9Sprite('blocks9.png', cc.rect(32, 32, 32, 32)); + cc.log("... created"); + + blocks_with_insets.x = x; + blocks_with_insets.y = y; + cc.log("... setPosition"); + + this.addChild(blocks_with_insets); + cc.log("this..addChild"); + + cc.log("... S9FrameNameSpriteSheetInsets done."); + } +}); + +// S9FrameNameSpriteSheetInsetsScaled + +var S9FrameNameSpriteSheetInsetsScaled = S9SpriteTestDemo.extend({ + + _title:"Scale9Sprite scaled with insets sprite sheet", + _subtitle:"createWithSpriteFrameName(); default cap insets; rendered scaled 4.5 X width, 2.5 X height", + + ctor:function() { + this._super(); + + var x = winSize.width / 2; + var y = 0 + (winSize.height / 2); + + cc.log("S9FrameNameSpriteSheetInsetsScaled ..."); + + var blocks_scaled_with_insets = new cc.Scale9Sprite('blocks9.png', cc.rect(32, 32, 32, 32)); + cc.log("... created"); + + blocks_scaled_with_insets.width = 96 * 4.5; + blocks_scaled_with_insets.height = 96 * 2.5; + cc.log("... setContentSize"); + + blocks_scaled_with_insets.x = x; + blocks_scaled_with_insets.y = y; + cc.log("... setPosition"); + + this.addChild(blocks_scaled_with_insets); + cc.log("this..addChild"); + + cc.log("... S9FrameNameSpriteSheetInsetsScaled done."); + } +}); + +// S9FrameNameSpriteSheetRotatedInsets + +var S9FrameNameSpriteSheetRotatedInsets = S9SpriteTestDemo.extend({ + + _title:"Scale9Sprite scaled with insets sprite sheet (stored rotated)", + _subtitle:"createWithSpriteFrameName(); cap insets=(32, 32, 32, 32)", + + ctor:function() { + this._super(); + + var x = winSize.width / 2; + var y = 0 + (winSize.height / 2); + + cc.log("S9FrameNameSpriteSheetRotatedInsets ..."); + + var blocks_with_insets = new cc.Scale9Sprite('blocks9r.png', cc.rect(32, 32, 32, 32)); + cc.log("... created"); + + blocks_with_insets.x = x; + blocks_with_insets.y = y; + cc.log("... setPosition"); + + this.addChild(blocks_with_insets); + cc.log("this..addChild"); + + cc.log("... S9FrameNameSpriteSheetRotatedInsets done."); + } +}); + +// S9_TexturePacker + +var S9_TexturePacker = S9SpriteTestDemo.extend({ + + _title:"Scale9Sprite from a spritesheet created with TexturePacker", + _subtitle:"createWithSpriteFrameName('button_normal.png');createWithSpriteFrameName('button_actived.png');", + + ctor:function() { + this._super(); + cc.spriteFrameCache.addSpriteFrames(s_s9s_ui_plist); + + var x = winSize.width / 4; + var y = 0 + (winSize.height / 2); + + cc.log("S9_TexturePacker ..."); + + var s = new cc.Scale9Sprite('button_normal.png'); + cc.log("... created"); + + s.x = x; + + s.y = y; + cc.log("... setPosition"); + + s.width = 21 * 16; + + s.height = 13 * 16; + cc.log("... setContentSize"); + + this.addChild(s); + cc.log("this..addChild"); + + x = winSize.width * 3/4; + + var s2 = new cc.Scale9Sprite('button_actived.png'); + cc.log("... created"); + + s2.x = x; + s2.y = y; + cc.log("... setPosition"); + + s2.width = 21 * 16; + s2.height = 13 * 16; + cc.log("... setContentSize"); + + this.addChild(s2); + cc.log("this..addChild"); + + cc.log("... S9_TexturePacker done."); + } +}); + +// S9FrameNameSpriteSheetRotatedInsetsScaled + +var S9FrameNameSpriteSheetRotatedInsetsScaled = S9SpriteTestDemo.extend({ + + _title:"Scale9Sprite scaled with insets sprite sheet (stored rotated)", + _subtitle:"createWithSpriteFrameName(); default cap insets; rendered scaled 4.5 X width, 2.5 X height", + + ctor:function() { + this._super(); + + var x = winSize.width / 2; + var y = 0 + (winSize.height / 2); + + cc.log("S9FrameNameSpriteSheetRotatedInsetsScaled ..."); + + var blocks_scaled_with_insets = new cc.Scale9Sprite('blocks9.png', cc.rect(32, 32, 32, 32)); + cc.log("... created"); + + blocks_scaled_with_insets.width = 96 * 4.5; + blocks_scaled_with_insets.height = 96 * 2.5; + cc.log("... setContentSize"); + + blocks_scaled_with_insets.x = x; + blocks_scaled_with_insets.y = y; + cc.log("... setPosition"); + + this.addChild(blocks_scaled_with_insets); + cc.log("this..addChild"); + + cc.log("... S9FrameNameSpriteSheetRotatedInsetsScaled done."); + } +}); + +var S9SpriteTestScene = TestScene.extend({ + runThisTest:function (num) { + sceneIdx = (num || num == 0) ? (num - 1) : -1; + var layer = nextS9SpriteTest(); + this.addChild(layer); + + director.runScene(this); + } +}); + +// +// Flow control +// + +var arrayOfS9SpriteTest = [ + S9BatchNodeBasic, + S9FrameNameSpriteSheet, + S9FrameNameSpriteSheetRotated, + S9BatchNodeScaledNoInsets, + S9FrameNameSpriteSheetScaledNoInsets, + S9FrameNameSpriteSheetRotatedScaledNoInsets, + S9BatchNodeScaleWithCapInsets, + S9FrameNameSpriteSheetInsets, + S9FrameNameSpriteSheetInsetsScaled, + S9FrameNameSpriteSheetRotatedInsets, + S9FrameNameSpriteSheetRotatedInsetsScaled, + S9_TexturePacker +]; + +var nextS9SpriteTest = function () { + sceneIdx++; + sceneIdx = sceneIdx % arrayOfS9SpriteTest.length; + + return new arrayOfS9SpriteTest[sceneIdx](); +}; +var previousS9SpriteTest = function () { + sceneIdx--; + if (sceneIdx < 0) + sceneIdx += arrayOfS9SpriteTest.length; + + return new arrayOfS9SpriteTest[sceneIdx](); +}; +var restartS9SpriteTest = function () { + return new arrayOfS9SpriteTest[sceneIdx](); +}; diff --git a/tests/js-tests/src/ExtensionsTest/TableViewTest/TableViewTestScene.js b/tests/js-tests/src/ExtensionsTest/TableViewTest/TableViewTestScene.js new file mode 100644 index 0000000000..37fdccf0c2 --- /dev/null +++ b/tests/js-tests/src/ExtensionsTest/TableViewTest/TableViewTestScene.js @@ -0,0 +1,137 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 CustomTableViewCell = cc.TableViewCell.extend({ + draw:function (ctx) { + this._super(ctx); + } +}); + +var TableViewTestLayer = cc.Layer.extend({ + + ctor:function () { + this._super(); + this.init(); + }, + + init:function () { + var winSize = cc.director.getWinSize(); + + var tableView = new cc.TableView(this, cc.size(600, 60)); + tableView.setDirection(cc.SCROLLVIEW_DIRECTION_HORIZONTAL); + tableView.x = 20; + tableView.y = winSize.height / 2 - 150; + tableView.setDelegate(this); + this.addChild(tableView); + tableView.reloadData(); + + tableView = new cc.TableView(this, cc.size(60, 350)); + tableView.setDirection(cc.SCROLLVIEW_DIRECTION_VERTICAL); + tableView.x = winSize.width - 150; + tableView.y = winSize.height / 2 - 150; + tableView.setDelegate(this); + tableView.setVerticalFillOrder(cc.TABLEVIEW_FILL_TOPDOWN); + this.addChild(tableView); + tableView.reloadData(); + + // Back Menu + var itemBack = new cc.MenuItemFont("Back", this.toExtensionsMainLayer, this); + itemBack.x = winSize.width - 50; + itemBack.y = 25; + var menuBack = new cc.Menu(itemBack); + menuBack.x = 0; + menuBack.y = 0; + this.addChild(menuBack); + + return true; + }, + + toExtensionsMainLayer:function (sender) { + var scene = new ExtensionsTestScene(); + scene.runThisTest(); + }, + + scrollViewDidScroll:function (view) { + }, + scrollViewDidZoom:function (view) { + }, + + tableCellTouched:function (table, cell) { + cc.log("cell touched at index: " + cell.getIdx()); + }, + tableCellTouched2:function () { + cc.log("cell touched at index: "); + }, + + tableCellSizeForIndex:function (table, idx) { + if (idx == 2) { + return cc.size(100, 100); + } + return cc.size(60, 60); + }, + + tableCellAtIndex:function (table, idx) { + var strValue = idx.toFixed(0); + var cell = table.dequeueCell(); + var label; + if (!cell) { + cell = new CustomTableViewCell(); + + + + var sprite = new cc.Sprite(s_image_icon); + sprite.anchorX = 0; + sprite.anchorY = 0; + sprite.x = 0; + sprite.y = 0; + cell.addChild(sprite); + + label = new cc.LabelTTF(strValue, "Helvetica", 20.0); + label.x = 0; + label.y = 0; + label.anchorX = 0; + label.anchorY = 0; + label.tag = 123; + cell.addChild(label); + } else { + label = cell.getChildByTag(123); + label.setString(strValue); + } + + return cell; + }, + + numberOfCellsInTableView:function (table) { + return 25; + } +}); + +var runTableViewTest = function () { + var pScene = new cc.Scene(); + var pLayer = new TableViewTestLayer(); + pScene.addChild(pLayer); + cc.director.runScene(pScene); +}; diff --git a/tests/js-tests/src/FacebookTest/FacebookShareTest.js b/tests/js-tests/src/FacebookTest/FacebookShareTest.js new file mode 100644 index 0000000000..453b459c3a --- /dev/null +++ b/tests/js-tests/src/FacebookTest/FacebookShareTest.js @@ -0,0 +1,406 @@ +/**************************************************************************** + Copyright (c) 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 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 buttons = { + "Share link": "onShareLink", + "Share open graph": "onShareOG", + "Share photo": "onSharePhoto", + "Link message": "onLinkMsg", + "Open graph message": "onOGMsg", + "Photo message": "onPhotoMsg", + "App request": "onRequest" +}; + +var appRequestAction = { + "Invites request": "onInviteRequest", + "Target invite request": "onTargetInviteRequest", + "specific lists of friends": "onSpecificListsFriends", + "Sending gift request": "sendingGiftRequest", + "Turn-based games": "onTurnBasedGamesRequest" +}; +var shareLinkAction = { + "share a simple link": "onShareSimpleLink", + "share a Text link": "onShareTextInfoLink", + "share a Picture link": "onSharePictureInfoLink", + "share a media link": "onShareMediaSource" +}; + +var FacebookShareTest = FacebookTest.extend({ + _title: "Facebook SDK Sharing Test", + _subtitle: "", + _agentManager: null, + _showTips: false, + _secondMenu:null, + ctor: function (title) { + this._super(title); + + window.facebook = window.facebook || (window["plugin"] ? window["plugin"]["FacebookAgent"]["getInstance"]() : null); + + var menu = new cc.Menu(); + menu.setPosition(cc.p(0, 0)); + menu.width = winSize.width; + menu.height = winSize.height; + this.addChild(menu, 1); + + var top = 50; + for (var action in buttons) { + var label = new cc.LabelTTF(action, "Arial", 24); + var item = new cc.MenuItemLabel(label, this[buttons[action]], this); + item.setPosition(winSize.width * 1 / 3, winSize.height - top); + menu.addChild(item); + top += 50; + } + + var logo = new cc.Sprite(s_html5_logo); + logo.setPosition(winSize.width * 2 / 3, winSize.height / 2); + this.addChild(logo); + + this._agentManager = window["plugin"].agentManager; + + this.tipsLabel = new cc.LabelTTF("", "Arial", 20); + this.tipsLabel.setDimensions(cc.size(350, 0)); + this.addChild(this.tipsLabel, 100); + this.tipsLabel.setPosition(cc.pAdd(cc.visibleRect.bottomRight, cc.p(-350 / 2 - 20, 150))); + this.tipsLabel.visible = false; + + this._secondMenu = new cc.Menu(); + this._secondMenu.setPosition(cc.p(340, 0)); + this._secondMenu.width = winSize.width / 2; + this._secondMenu.height = winSize.height; + this.addChild(this._secondMenu, 2); + }, + showSecondMenu: function (buttonActions) { + this._secondMenu.removeAllChildren(); + var top = 50; + for (var action in buttonActions) { + var label = new cc.LabelTTF(action, "Arial", 24); + var item = new cc.MenuItemLabel(label, this[buttonActions[action]], this); + item.setPosition(winSize.width * 1 / 3, winSize.height - top); + this._secondMenu.addChild(item); + top += 50; + } + }, + onShareLink: function () { + this.showSecondMenu(shareLinkAction); + }, + + onShareSimpleLink: function (){ + var map = { + "dialog": "shareLink", + "link": "http://www.cocos2d-x.org" + }; + var self = this; + if(facebook.canPresentDialog(map)){ + facebook.dialog(map,function(errorCode,msg){ + self.showDisableTips(JSON.stringify(msg)); + }); + }else{ + map["dialog"] = "feedDialog"; + facebook.dialog(map,function(errorCode,msg){ + self.showDisableTips(JSON.stringify(msg)); + }); + } + }, + onShareTextInfoLink: function (){ + var map = { + "dialog": "shareLink", + "name": "Cocos2d-JS web site", + "caption": "Cocos2d-JS caption", + "description":"Cocos2d-JS description", + "link": "http://www.cocos2d-x.org" + }; + var self = this; + if(facebook.canPresentDialog(map)){ + facebook.dialog(map,function(errorCode,msg){ + self.showDisableTips(JSON.stringify(msg)); + }); + }else{ + map["dialog"] = "feedDialog"; + facebook.dialog(map,function(errorCode,msg){ + self.showDisableTips(JSON.stringify(msg)); + }); + } + }, + onSharePictureInfoLink: function (){ + var map = { + "dialog": "shareLink", + "name": "Cocos2d-JS web site", + "caption": "Cocos2d-JS caption", + "description":"Cocos2d-JS description", + "to": "100008180737293,100006738453912", + "picture": "http://files.cocos2d-x.org/images/orgsite/logo.png", + "link": "http://www.cocos2d-x.org" + }; + var self = this; + if(facebook.canPresentDialog(map)){ + facebook.dialog(map,function(errorCode,msg){ + self.showDisableTips(JSON.stringify(msg)); + }); + }else{ + map["dialog"] = "feedDialog"; + facebook.dialog(map,function(errorCode,msg){ + self.showDisableTips(JSON.stringify(msg)); + }); + } + }, + onShareMediaSource: function () { + var map = { + "dialog": "shareLink", + "name": "Cocos2d-JS web site", + "caption": "Cocos2d-JS caption", + "description":"Cocos2d-JS description", + "link": "http://www.youtube.com/watch?v=uMnHAHpMtDc&feature=youtu.be" + }; + + var self = this; + // only support in feed dialog + facebook.dialog(map,function(errorCode,msg){ + self.showDisableTips(JSON.stringify(msg)); + }); + }, + showDisableTips: function (msg) { + if (!this._showTips) { + this._showTips = true; + if (msg) { + var preMsg = this.tipsLabel.getString(); + this.tipsLabel.setString(msg); + } + var anim = cc.sequence( + cc.fadeIn(0.2), + cc.delayTime(3), + cc.fadeOut(0.2), + cc.callFunc(function () { + this._showTips = false; + this.tipsLabel.visible = false; + if (preMsg) + this.tipsLabel.setString(preMsg); + }, this) + ); + this.tipsLabel.visible = true; + this.tipsLabel.runAction(anim); + } + }, + onShareOG: function () { + var map = { + "dialog": "shareOpenGraph", + "action_type": "cocostestmyfc:share", + "preview_property_name": "cocos_document", + "title": "Cocos2d-JS Game Engine", + "image": "http://files.cocos2d-x.org/images/orgsite/logo.png", + "url": "http://cocos2d-x.org/docs/manual/framework/html5/en", + "description": "cocos document" + }; + var self = this; + if(facebook.canPresentDialog(map)){ + facebook.dialog(map, function (resultcode, msg) { + self.showDisableTips(JSON.stringify(msg)); + }); + }else{ + self.showDisableTips("Can't open dialog for shareOpenGraph"); + } + + + }, + + onSharePhoto: function () { + var self = this; + if (!cc.sys.isNative) { + self.showDisableTips("This share function is not available on web version of Facebook plugin"); + return; + } + var img = self.screenshot("facebookshare.jpg"); + + var delay = cc.delayTime(2); + var share = cc.callFunc(function () { + var map = { + "dialog": "sharePhoto", + "photo": img + }; + + if(facebook.canPresentDialog(map)){ + facebook.dialog(map, function (resultcode, msg) { + self.showDisableTips(JSON.stringify(msg)); + }); + }else{ + self.showDisableTips("Can't open dialog for sharePhoto"); + } + }); + var seq = cc.sequence(delay, share); + this.runAction(seq); + + }, + + onLinkMsg: function () { + var map = { + "dialog": "messageLink", + "description": "Cocos2d-JS is a great game engine", + "title": "Cocos2d-JS", + "link": "http://www.cocos2d-x.org", + "imageUrl": "http://files.cocos2d-x.org/images/orgsite/logo.png" + }; + if(facebook.canPresentDialog(map)){ + var self = this; + facebook.dialog(map, function (resultcode, msg) { + self.showDisableTips(JSON.stringify(msg)); + }); + }else{ + this.showDisableTips("Can't open dialog for messageLink"); + } + }, + + onOGMsg: function () { + if (!cc.sys.isNative) { + this.showDisableTips("This share function is not available on web version of Facebook plugin"); + return; + } + var map = { + "dialog": "messageOpenGraph", + "action_type": "cocostestmyfc:share", + "preview_property_name": "cocos_document", + "title": "Cocos2d-JS Game Engine", + "image": "http://files.cocos2d-x.org/images/orgsite/logo.png", + "url": "http://cocos2d-x.org/docs/manual/framework/html5/en", + "description": "cocos document" + }; + if(facebook.canPresentDialog(map)){ + var self = this; + facebook.dialog(map, function (resultcode, msg) { + self.showDisableTips(JSON.stringify(msg)); + }); + }else{ + this.showDisableTips("Can't open dialog for messageOpenGraph"); + } + }, + + onPhotoMsg: function () { + var self = this; + if (!cc.sys.isNative) { + self.showDisableTips("This share function is not available on web version of Facebook plugin"); + return; + } + var img = this.screenshot("facebookmessage.jpg"); + + var delay = cc.delayTime(2); + var share = cc.callFunc(function () { + var map = { + "dialog": "messagePhoto", + "photo": img + }; + if(facebook.canPresentDialog(map)){ + facebook.dialog(map, function (resultcode, msg) { + self.showDisableTips(JSON.stringify(msg)); + }); + }else{ + self.showDisableTips("Can't open dialog for messagePhoto"); + } + }); + var seq = cc.sequence(delay, share); + this.runAction(seq); + }, + + onRequest: function () { + this.showSecondMenu(appRequestAction); + }, + + onInviteRequest: function () { + var map = { + "message": "Cocos2d-JS is a great game engine", + "title": "Cocos2d-JS title" + }; + var self = this; + facebook.appRequest(map, function (resultcode, msg) { + self.showDisableTips(JSON.stringify(msg)); + }); + }, + onTargetInviteRequest: function () { + var map = { + "message": "Cocos2d-JS is a great game engine", + "title": "Cocos2d-JS title", + "to": "100006738453912, 10204182777160522" + }; + var self = this; + // android only web view support to + facebook.appRequest(map, function (resultcode, msg) { + self.showDisableTips(JSON.stringify(msg)); + }); + }, + onSpecificListsFriends: function () { + var map = { + "message": "Cocos2d-JS is a great game engine", + "title": "Cocos2d-JS title", + "filters": '[{"name":"company", "user_ids":["100006738453912","10204182777160522"]}]' + }; + var self = this; + // android not support filters + facebook.appRequest(map, function (resultcode, msg) { + self.showDisableTips(JSON.stringify(msg)); + }); + }, + sendingGiftRequest: function () { + var map = { + "message": "Cocos2d-JS is a great game engine", + "to": "100006738453912", + "action_type":"send", + "object_id":"649590015121283"// 191181717736427 1426774790893461 + }; + var self = this; + // android not support action_type + facebook.appRequest(map, function (resultcode, msg) { + self.showDisableTips(JSON.stringify(msg)); + }); + }, + onTurnBasedGamesRequest: function () { + var map = { + "message": "Cocos2d-JS is a great game engine", + "title": "Cocos2d-JS title", + "to": "100006738453912", + "action_type":"turn" + }; + var self = this; + // android not support action_type + facebook.appRequest(map, function (resultcode, msg) { + self.showDisableTips(JSON.stringify(msg)); + }); + }, + + screenshot: function (fileName) { + var tex = new cc.RenderTexture(winSize.width, winSize.height, cc.Texture2D.PIXEL_FORMAT_RGBA8888); + tex.setPosition(cc.p(winSize.width / 2, winSize.height / 2)); + tex.begin(); + cc.director.getRunningScene().visit(); + tex.end(); + + var imgPath = jsb.fileUtils.getWritablePath(); + if (imgPath.length == 0) { + return; + } + var result = tex.saveToFile(fileName, cc.IMAGE_FORMAT_JPEG); + if (result) { + imgPath += fileName; + cc.log("save image:" + imgPath); + return imgPath; + } + return ""; + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/FacebookTest/FacebookTest.js b/tests/js-tests/src/FacebookTest/FacebookTest.js new file mode 100644 index 0000000000..85e6b17f72 --- /dev/null +++ b/tests/js-tests/src/FacebookTest/FacebookTest.js @@ -0,0 +1,98 @@ +/**************************************************************************** + Copyright (c) 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 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 FacebookTest = cc.Layer.extend({ + _sceneTitleLabel:null, + _quit: false, + _title: "", + + ctor:function(title){ + this._super() + // Get the sceensize + var screensize = cc.winSize; + + // Add the generated background + var background = new cc.Sprite(s_extensions_background); + background.x = screensize.width / 2; + background.y = screensize.height / 2; + var bgRect = background.getTextureRect(); + background.scaleX = screensize.width/bgRect.width; + background.scaleY = screensize.height/bgRect.height; + this.addChild(background); + + // Add the ribbon + var ribbon = new cc.Scale9Sprite(s_extensions_ribbon, cc.rect(1, 1, 48, 55)); + ribbon.width = screensize.width; + ribbon.height = 57; + ribbon.x = screensize.width / 2.0; + ribbon.y = screensize.height - ribbon.height / 2.0; + this.addChild(ribbon); + + // Add the title + this._sceneTitleLabel = new cc.LabelTTF(this._title, "Arial", 12); + this._sceneTitleLabel.x = screensize.width / 2; + this._sceneTitleLabel.y = screensize.height - this._sceneTitleLabel.height / 2 - 5; + this.addChild(this._sceneTitleLabel, 1); + + // Add the menu + var item1 = new cc.MenuItemImage(s_pathB1, s_pathB2, this.previousCallback, this); + var item2 = new cc.MenuItemImage(s_pathR1, s_pathR2, this.restartCallback, this); + var item3 = new cc.MenuItemImage(s_pathF1, s_pathF2, this.nextCallback, this); + + var menu = new cc.Menu(item1, item3, item2); + menu.x = 0; + menu.y = 0; + item1.x = screensize.width / 2 - 100; + item1.y = 37; + item2.x = screensize.width / 2; + item2.y = 35; + item3.x = screensize.width / 2 + 100; + item3.y = 37; + + this.addChild(menu ,1); + }, + + restartCallback:function (sender) { + if (this._quit) return; + this._quit = true; + (new FacebookTestScene()).runThisTest(__sceneIdx); + }, + + nextCallback:function (sender) { + if (this._quit) return; + this._quit = true; + __sceneIdx++; + __sceneIdx = __sceneIdx % arrayOfFacebookTest.length; + (new FacebookTestScene()).runThisTest(__sceneIdx); + }, + + previousCallback:function (sender) { + if (this._quit) return; + this._quit = true; + __sceneIdx--; + if (__sceneIdx < 0) + __sceneIdx += arrayOfFacebookTest.length; + (new FacebookTestScene()).runThisTest(__sceneIdx); + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/FacebookTest/FacebookTestsManager.js b/tests/js-tests/src/FacebookTest/FacebookTestsManager.js new file mode 100644 index 0000000000..7de1057755 --- /dev/null +++ b/tests/js-tests/src/FacebookTest/FacebookTestsManager.js @@ -0,0 +1,60 @@ +/**************************************************************************** + Copyright (c) 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 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 facebook_is_canvas = false; +var arrayOfFacebookTest = [ + FacebookShareTest, + FacebookUserTest +]; + +var __sceneIdx = -1; + +var nextFacebookTest = function () { + __sceneIdx++; + __sceneIdx = __sceneIdx % arrayOfFacebookTest.length; + return new arrayOfFacebookTest[__sceneIdx](); +}; + +FacebookTestScene = TestScene.extend({ + runThisTest:function (num) { + var self = this; + __sceneIdx = (num || num == 0) ? (num - 1) : -1; + + if(!cc.sys.isNative) { //browser + cc.loader.loadJs('', [ + "../../frameworks/cocos2d-html5/external/pluginx/platform/facebook_sdk.js", + "../../frameworks/cocos2d-html5/external/pluginx/platform/facebook.js" + ], function() { + var layer = nextFacebookTest(); + self.addChild(layer); + director.runScene(self); + }); + } + else { + var layer = nextFacebookTest(); + self.addChild(layer); + director.runScene(self); + } + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/FacebookTest/FacebookUserTest.js b/tests/js-tests/src/FacebookTest/FacebookUserTest.js new file mode 100644 index 0000000000..d31193d22f --- /dev/null +++ b/tests/js-tests/src/FacebookTest/FacebookUserTest.js @@ -0,0 +1,199 @@ +/**************************************************************************** + Copyright (c) 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 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 button_share = { + "login": "loginClick", + "loginWithPermission": "loginWithPermissionClick", + "logout": "logoutClick", + "getUid": "getUidClick", + "getToken": "getTokenClick", + "getPermissions": "getPermissionClick", + "request API": "requestClick", + "activateApp": "activateAppClick", + "logEvent": "LogEventClick", + "logPurchase": "LogPurchaseClick", + "payment": "paymentClick" +}; +var FacebookUserTest = FacebookTest.extend({ + _title: "Facebook SDK User Test", + _subtitle: "", + _agentManager: null, + _isLogin: false, + ctor: function (title) { + this._super(title); + + window.facebook = window.facebook || (window["plugin"] ? window["plugin"]["FacebookAgent"]["getInstance"]() : null); + + var menu = cc.Menu.create(); + for (var action in button_share) { + var label = new cc.LabelTTF(action, "Arial", 22); + var item = new cc.MenuItemLabel(label, this[button_share[action]], this); + menu.addChild(item); + } + menu.alignItemsVerticallyWithPadding(8); + menu.setPosition(cc.pAdd(cc.visibleRect.left, cc.p(+180, 0))); + this.addChild(menu); + + + this.result = new cc.LabelTTF("You can see the result at this label", "Arial", 22); + this.result.setPosition(cc.pAdd(cc.visibleRect.right, cc.p(-this.result.width / 2 - 30, 0))); + this.result.boundingWidth = this.result.width; + this.addChild(this.result, 1); + }, + activateAppClick: function () { + if (cc.sys.isNative|| facebook_is_canvas) { + facebook.activateApp(); + this.result.setString("activateApp is invoked"); + } + else { + this.result.setString("activateApp is only available for Facebook Canvas App"); + } + }, + LogEventClick: function () { + if (cc.sys.isNative || facebook_is_canvas) { + var parameters = {}; + var floatVal = 888.888; + parameters[window["plugin"].FacebookAgent.AppEventParam.SUCCESS] = window["plugin"].FacebookAgent.AppEventParamValue.VALUE_YES; + // facebook.logEvent(plugin.FacebookAgent.AppEvent.COMPLETED_TUTORIAL); + facebook.logEvent(window["plugin"].FacebookAgent.AppEvent.COMPLETED_TUTORIAL, floatVal); + facebook.logEvent(window["plugin"].FacebookAgent.AppEvent.COMPLETED_TUTORIAL, parameters); + facebook.logEvent(window["plugin"].FacebookAgent.AppEvent.COMPLETED_TUTORIAL, floatVal, parameters); + this.result.setString("logEvent is invoked"); + } + else { + this.result.setString("LogEvent is only available for Facebook Canvas App"); + } + }, + loginClick: function (sender) { + var self = this; + + if (facebook.isLoggedIn()) { + self.result.setString("logged in"); + } + else { + facebook.login(function (type, msg) { + self.result.setString("type is " + type + " msg is " + JSON.stringify(msg)); + }); + } + }, + logoutClick: function (sender) { + var self = this; + facebook.logout(function (type, msg) { + self.result.setString(JSON.stringify(msg)); + }); + }, + getUidClick: function (sender) { + var self = this; + + if (facebook.isLoggedIn()) { + self.result.setString(facebook.getUserID()); + } + else { + self.result.setString("User haven't been logged in"); + } + }, + getTokenClick: function (sender) { + var self = this; + + if (facebook.isLoggedIn()) { + self.result.setString(facebook.getAccessToken()); + } + else { + self.result.setString("User haven't been logged in"); + } + }, + + loginWithPermissionClick: function (sender) { + var self = this; + var permissions = ["create_event", "create_note", "manage_pages", "publish_actions"]; + facebook.login(permissions, function (type, msg) { + if (type == window["plugin"].FacebookAgent.CODE_SUCCEED) { + self.result.setString(msg["permissions"]); + } + }); + }, + getPermissionClick: function (sender) { + var self = this; + facebook.api("/me/permissions", window["plugin"].FacebookAgent.HttpMethod.GET, {}, function (type, data) { + if (type == window["plugin"].FacebookAgent.CODE_SUCCEED) { + data = JSON.stringify(data); + self.result.setString(data); + } + else { + self.result.setString(JSON.stringify(data)); + } + }); + }, + requestClick: function (sender) { + var self = this; + facebook.api("/me/photos", window["plugin"].FacebookAgent.HttpMethod.POST, {"url": "http://files.cocos2d-x.org/images/orgsite/logo.png"}, function (type, msg) { + if (type == window["plugin"].FacebookAgent.CODE_SUCCEED) { + self.result.setString("post_id: " + msg["post_id"]); + } + }); + }, + LogPurchaseClick: function (sender) { + if (cc.sys.isNative || facebook_is_canvas) { + var params = {}; + // All supported parameters are listed here + params[window["plugin"].FacebookAgent.AppEventParam.CURRENCY] = "CNY"; + params[window["plugin"].FacebookAgent.AppEventParam.REGISTRATION_METHOD] = "Facebook"; + params[window["plugin"].FacebookAgent.AppEventParam.CONTENT_TYPE] = "game"; + params[window["plugin"].FacebookAgent.AppEventParam.CONTENT_ID] = "201410102342"; + params[window["plugin"].FacebookAgent.AppEventParam.SEARCH_STRING] = "cocos2djs"; + params[window["plugin"].FacebookAgent.AppEventParam.SUCCESS] = window["plugin"].FacebookAgent.AppEventParamValue.VALUE_YES; + params[window["plugin"].FacebookAgent.AppEventParam.MAX_RATING_VALUE] = "10"; + params[window["plugin"].FacebookAgent.AppEventParam.PAYMENT_INFO_AVAILABLE] = window["plugin"].FacebookAgent.AppEventParamValue.VALUE_YES; + params[window["plugin"].FacebookAgent.AppEventParam.NUM_ITEMS] = "99"; + params[window["plugin"].FacebookAgent.AppEventParam.LEVEL] = "10"; + params[window["plugin"].FacebookAgent.AppEventParam.DESCRIPTION] = "Cocos2d-JS"; + facebook.logPurchase(1.23, "CNY", params); + this.result.setString("Purchase logged."); + } + else { + this.result.setString("LogPurchase is only available for Facebook Canvas App"); + } + }, + paymentClick: function () { + if(facebook_is_canvas){ + var info = { + product: 'https://www.cocos2d-x.org/demo/facebooktest/pay/item1.html' + }; + + var self = this; + facebook.canvas.pay(info, function(code, response){ + if (code == window["plugin"].FacebookAgent.CODE_SUCCEED){ + if (response['status'] === 'completed') + self.result.setString("Payment succeeded: " + response['amount'] + response['currency']); + else + self.result.setString("Payment failed: " + JSON.stringify(response['status'])) + } else { + self.result.setString("Request send failed, error #" + code + ": " + JSON.stringify(response)); + } + }); + }else{ + this.result.setString("canvas.pay is only available for Facebook Canvas App"); + } + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/FontTest/FontTest.js b/tests/js-tests/src/FontTest/FontTest.js new file mode 100644 index 0000000000..fe65ef667b --- /dev/null +++ b/tests/js-tests/src/FontTest/FontTest.js @@ -0,0 +1,159 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 TAG_LABEL1 = 550; +var TAG_LABEL2 = 551; +var TAG_LABEL3 = 552; +var TAG_LABEL4 = 553; + +var fontIdx = 0; + +var fontList = [ + + // System Fonts + "Verdana", + "Lucida Sans Unicode", + "Bookman Old Style", + "Symbol", + "Georgia", + "Trebuchet MS", + "Comic Sans MS", + "Arial Black", + "Tahoma", + "Impact", + + // custom TTF + "American Typewriter", + "Marker Felt", + "A Damn Mess", + "Abberancy", + "Abduction", + "Paint Boy", + "Schwarzwald", + "Scissor Cuts" +]; + + +function nextFontTestAction() { + fontIdx++; + fontIdx = fontIdx % fontList.length; + + if(window.sideIndexBar){ + fontIdx = window.sideIndexBar.changeTest(fontIdx, 16); + } + + return fontList[fontIdx]; +} + +function backFontTestAction() { + fontIdx--; + if (fontIdx < 0) { + fontIdx += fontList.length; + } + + if(window.sideIndexBar){ + fontIdx = window.sideIndexBar.changeTest(fontIdx, 16); + } + + return fontList[fontIdx]; +} + +function restartFontTestAction() { + return fontList[fontIdx]; +} +FontTestScene = TestScene.extend({ + + runThisTest:function (num) { + + fontIdx = num || fontIdx; + + var layer = new FontTest(); + this.addChild(layer); + + director.runScene(this); + } +}); + +var FontTest = BaseTestLayer.extend({ + ctor:function () { + this._super(cc.color(0,0,0,255), cc.color(98,99,117,255)); + + this.showFont(restartFontTestAction()); + + }, + showFont:function (pFont) { + this.removeChildByTag(TAG_LABEL1, true); + this.removeChildByTag(TAG_LABEL2, true); + this.removeChildByTag(TAG_LABEL3, true); + this.removeChildByTag(TAG_LABEL4, true); + + var winSize = director.getWinSize(); + + var top = new cc.LabelTTF(pFont, pFont, 24); + var left = new cc.LabelTTF("alignment left", pFont, 32, cc.size(winSize.width, 50), cc.TEXT_ALIGNMENT_LEFT); + var center = new cc.LabelTTF("alignment center", pFont, 32, cc.size(winSize.width, 50), cc.TEXT_ALIGNMENT_CENTER); + var right = new cc.LabelTTF("alignment right", pFont, 32, cc.size(winSize.width, 50), cc.TEXT_ALIGNMENT_RIGHT); + + top.x = winSize.width / 2; + top.y = winSize.height * 3 / 4; + left.x = winSize.width / 2; + left.y = winSize.height / 2; + center.x = winSize.width / 2; + center.y = winSize.height * 3 / 8; + right.x = winSize.width / 2; + right.y = winSize.height / 4; + + this.addChild(left, 0, TAG_LABEL1); + this.addChild(right, 0, TAG_LABEL2); + this.addChild(center, 0, TAG_LABEL3); + this.addChild(top, 0, TAG_LABEL4); + + }, + + onBackCallback:function (sender) { + this.showFont(backFontTestAction()); + }, + onRestartCallback:function (sender) { + this.showFont(restartFontTestAction()); + }, + onNextCallback:function (sender) { + this.showFont(nextFontTestAction()); + }, + subtitle:function () { + return "Font test"; + }, + title:function () { + return "" + fontList[fontIdx]; + }, + + // automation + numberOfPendingTests:function() { + return ( (fontList.length-1) - fontIdx ); + }, + getTestNumber:function() { + return fontIdx; + } + +}); diff --git a/tests/js-tests/src/GUITest/UIButtonTest/UIButtonTest.js b/tests/js-tests/src/GUITest/UIButtonTest/UIButtonTest.js new file mode 100644 index 0000000000..2596a4f6b5 --- /dev/null +++ b/tests/js-tests/src/GUITest/UIButtonTest/UIButtonTest.js @@ -0,0 +1,568 @@ +/**************************************************************************** + 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 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 UIButtonTest = UIScene.extend({ + init: function () { + if (this._super()) { + //init text + this._topDisplayLabel.setString("No Event"); + this._bottomDisplayLabel.setString("Button"); + + var widgetSize = this._widget.getContentSize(); + // Create the button + var button = new ccui.Button(); + button.setTouchEnabled(true); + button.loadTextures("res/cocosui/animationbuttonnormal.png", "res/cocosui/animationbuttonpressed.png", ""); + button.x = widgetSize.width / 2.0; + button.y = widgetSize.height / 2.0; + button.addTouchEventListener(this.touchEvent, this); + this._mainNode.addChild(button); + + return true; + } + return false; + }, + + touchEvent: function (sender, type) { + switch (type) { + case ccui.Widget.TOUCH_BEGAN: + this._topDisplayLabel.setString("Touch Down"); + break; + + case ccui.Widget.TOUCH_MOVED: + this._topDisplayLabel.setString("Touch Move"); + break; + + case ccui.Widget.TOUCH_ENDED: + this._topDisplayLabel.setString("Touch Up"); + break; + + case ccui.Widget.TOUCH_CANCELED: + this._topDisplayLabel.setString("Touch Cancelled"); + break; + + default: + break; + } + } +}); +var UIButtonTest_Scale9 = UIScene.extend({ + init: function () { + if (this._super()) { + //init text + this._topDisplayLabel.setString("No Event"); + this._bottomDisplayLabel.setString("Button scale9 render"); + + // Create the button + var button = new ccui.Button(); + button.setTouchEnabled(true); + button.setScale9Enabled(true); + button.loadTextures("res/cocosui/button.png", "res/cocosui/buttonHighlighted.png", ""); + button.x = this._widget.width / 2.0; + button.y = this._widget.height / 2.0; + button.setContentSize(cc.size(150, 48)); + button.addTouchEventListener(this.touchEvent ,this); + this._mainNode.addChild(button); + + return true; + } + return false; + }, + + touchEvent: function (sender, type) { + switch (type) { + case ccui.Widget.TOUCH_BEGAN: + this._topDisplayLabel.setString("Touch Down"); + break; + case ccui.Widget.TOUCH_MOVED: + this._topDisplayLabel.setString("Touch Move"); + break; + case ccui.Widget.TOUCH_ENDED: + this._topDisplayLabel.setString("Touch Up"); + break; + case ccui.Widget.TOUCH_CANCELED: + this._topDisplayLabel.setString("Touch Cancelled"); + break; + + default: + break; + } + } +}); + +var UIButtonTest_PressedAction = UIScene.extend({ + init: function () { + if (this._super()) { + //init text + this._topDisplayLabel.setString("No Event"); + this._bottomDisplayLabel.setString("Button Pressed Action"); + + var widgetSize = this._widget.getContentSize(); + // Create the button + var button = new ccui.Button(); + button.setTouchEnabled(true); + button.setPressedActionEnabled(true); + button.loadTextures("res/cocosui/animationbuttonnormal.png", "res/cocosui/animationbuttonpressed.png", ""); + button.x = widgetSize.width / 2; + button.y = widgetSize.height / 2; + button.addTouchEventListener(this.touchEvent ,this); + this._mainNode.addChild(button); + return true; + } + return false; + }, + + touchEvent: function (sender, type) { + switch (type) { + case ccui.Widget.TOUCH_BEGAN: + this._topDisplayLabel.setString("Touch Down"); + break; + case ccui.Widget.TOUCH_MOVED: + this._topDisplayLabel.setString("Touch Move"); + break; + case ccui.Widget.TOUCH_ENDED: + this._topDisplayLabel.setString("Touch Up"); + break; + case ccui.Widget.TOUCH_CANCELED: + this._topDisplayLabel.setString("Touch Cancelled"); + break; + default: + break; + } + } +}); + +var UIButtonTest_Title = UIScene.extend({ + init: function () { + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + //init text + this._topDisplayLabel.setString("No Event"); + this._bottomDisplayLabel.setString("Button with title"); + + // Create the text button + var textButton = new ccui.Button(); + textButton.setTouchEnabled(true); + textButton.loadTextures("res/cocosui/backtotopnormal.png", "res/cocosui/backtotoppressed.png", ""); + textButton.setTitleText("Title Button"); + textButton.x = widgetSize.width / 2.0; + textButton.y = widgetSize.height / 2.0; + textButton.addTouchEventListener(this.touchEvent ,this); + this._mainNode.addChild(textButton); + + return true; + } + return false; + }, + + touchEvent: function (sender, type) { + switch (type) { + case ccui.Widget.TOUCH_BEGAN: + this._topDisplayLabel.setString("Touch Down"); + break; + case ccui.Widget.TOUCH_MOVED: + this._topDisplayLabel.setString("Touch Move"); + break; + case ccui.Widget.TOUCH_ENDED: + this._topDisplayLabel.setString("Touch Up"); + break; + case ccui.Widget.TOUCH_CANCELED: + this._topDisplayLabel.setString("Touch Cancelled"); + break; + default: + break; + } + } +}); + +var UIButtonTestRemoveSelf = UIScene.extend({ + init: function () { + if (this._super()) { + //init text + this._topDisplayLabel.setString("No Event"); + this._bottomDisplayLabel.setString("Remove Self in the Button's Callback shouldn't cause crash!"); + this._bottomDisplayLabel.setFontSize(15); + + var widgetSize = this._widget.getContentSize(); + + var layout = new ccui.Layout(); + layout.setContentSize(widgetSize.width * 0.6, widgetSize.height * 0.6); + layout.setBackGroundColor(cc.color.GREEN); + layout.setBackGroundColorType(ccui.Layout.BG_COLOR_SOLID); + layout.setBackGroundColorOpacity(100); + layout.setPosition(widgetSize.width/2, widgetSize.height/2); + layout.setAnchorPoint(0.5, 0.5); + layout.setTag(12); + this._mainNode.addChild(layout); + + // Create the button + var button = new ccui.Button("res/cocosui/animationbuttonnormal.png", + "res/cocosui/animationbuttonpressed.png"); + button.setPosition(layout.width / 2.0, layout.height / 2.0); + button.addTouchEventListener(this.touchEvent, this); + layout.addChild(button); + return true; + } + return false; + }, + + touchEvent: function(sender, type){ + switch (type) { + case ccui.Widget.TOUCH_BEGAN: + this._topDisplayLabel.setString("Touch Down"); + break; + + case ccui.Widget.TOUCH_MOVED: + this._topDisplayLabel.setString("Touch Move"); + break; + + case ccui.Widget.TOUCH_ENDED: + this._topDisplayLabel.setString("Touch Up"); + var layout = this._mainNode.getChildByTag(12); + layout.removeFromParent(true); + break; + + case ccui.Widget.TOUCH_CANCELED: + this._topDisplayLabel.setString("Touch Cancelled"); + break; + + default: + break; + } + } +}); + +var UIButtonTestSwitchScale9 = UIScene.extend({ + init: function(){ + if (this._super()){ + var widgetSize = this._widget.getContentSize(); + + // Add a label in which the button events will be displayed + this._topDisplayLabel.setString("No Event"); + this._bottomDisplayLabel.setString(""); + + // Create the button + var button = new ccui.Button("res/cocosui/animationbuttonnormal.png", + "res/cocosui/animationbuttonpressed.png"); + button.setPosition(widgetSize.width / 2.0, widgetSize.height / 2.0); + button.addTouchEventListener(this.touchEvent, this); + button.setTitleText("Button Title"); + button.ignoreContentAdaptWithSize(false); + + this._mainNode.addChild(button); + return true; + } + return false; + }, + + touchEvent: function(sender, type){ + switch (type) { + case ccui.Widget.TOUCH_BEGAN: + this._topDisplayLabel.setString("Touch Down"); + break; + + case ccui.Widget.TOUCH_MOVED: + this._topDisplayLabel.setString("Touch Move"); + break; + + case ccui.Widget.TOUCH_ENDED: + this._topDisplayLabel.setString("Touch Up"); + sender.setScale9Enabled(!sender.isScale9Enabled()); + sender.setContentSize(200,100); + break; + + case ccui.Widget.TOUCH_CANCELED: + this._topDisplayLabel.setString("Touch Cancelled"); + break; + + default: + break; + } + } +}); + +var UIButtonTestZoomScale = UIScene.extend({ + init: function(){ + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + + // Add a label in which the button events will be displayed + this._topDisplayLabel.setString("Zoom Scale: -0.5"); + this._bottomDisplayLabel.setString(""); + + // Create the button + var button = new ccui.Button("res/cocosui/animationbuttonnormal.png", "res/cocosui/animationbuttonpressed.png"); + button.setPosition(widgetSize.width / 2.0, widgetSize.height / 2.0 ); + button.setPressedActionEnabled(true); + button.addClickEventListener(function () { + cc.log("Button clicked, position = (" + button.x + ", " + button.y + ")"); + }); + button.setName("button"); + this._mainNode.addChild(button); + button.setZoomScale(-0.5); + + var slider = new ccui.Slider(); + slider.loadBarTexture("res/cocosui/sliderTrack.png"); + slider.loadSlidBallTextures("res/cocosui/sliderThumb.png", "res/cocosui/sliderThumb.png", ""); + slider.loadProgressBarTexture("res/cocosui/sliderProgress.png"); + slider.setPosition(widgetSize.width / 2.0 , widgetSize.height / 2.0 - 50); + slider.addEventListener(this.sliderEvent, this); + slider.setPercent(button.getZoomScale() * 100); + this._mainNode.addChild(slider); + return true; + } + return false; + }, + + sliderEvent: function(slider, type){ + if (type == ccui.Slider.EVENT_PERCENT_CHANGED){ + var percent = slider.getPercent(); + var btn = this._mainNode.getChildByName("button"); + var zoomScale = percent * 0.01; + btn.setZoomScale(zoomScale); + this._topDisplayLabel.setString("Zoom Scale: "+ zoomScale.toFixed(2)); + } + } +}); + +var UIButtonTextOnly = UIScene.extend({ + init: function(){ + if (this._super()) { + // Add a label in which the button events will be displayed + this._topDisplayLabel.setString("Text Only Button"); + this._bottomDisplayLabel.setString(""); + + // Create the button + var button = new ccui.Button(); + button.setNormalizedPosition(0.5, 0.5); + + button.setTitleText("PLAY GAME"); + cc.log("content size should be greater than 0: width = %f, height = %f", button.width, button.height); + button.setZoomScale(0.3); + button.setPressedActionEnabled(true); + button.addClickEventListener(function () { + cc.log("clicked!"); + }); + this.addChild(button); + return true; + } + return false; + } +}); + +var UIButtonIgnoreContentSizeTest = UIScene.extend({ + init: function(){ + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + + // Add a label in which the button events will be displayed + this._topDisplayLabel.setString("Button IgnoreContent Size Test"); + this._bottomDisplayLabel.setString(""); + + // Create the button + var button = new ccui.Button("res/cocosui/animationbuttonnormal.png", "res/cocosui/animationbuttonpressed.png"); + button.ignoreContentAdaptWithSize(false); + button.setContentSize(200,100); + button.setNormalizedPosition(0.3, 0.5); + button.setTitleText("PLAY GAME"); + button.setZoomScale(0.3); + button.setPressedActionEnabled(true); + button.addClickEventListener(function () { + cc.log("clicked!"); + button.setScale(1.2); + }); + this.addChild(button); + + // Create the button + var button2 = new ccui.Button("res/cocosui/animationbuttonnormal.png", "res/cocosui/animationbuttonpressed.png"); + button2.ignoreContentAdaptWithSize(false); + button2.setContentSize(200,100); + button2.setNormalizedPosition(0.8, 0.5); + button2.setTitleText("PLAY GAME"); + button2.setZoomScale(0.3); + button2.setPressedActionEnabled(true); + button2.addClickEventListener(function () { + button2.runAction(cc.scaleTo(1.0, 1.2)); + cc.log("clicked!"); + }); + this.addChild(button2); + + return true; + } + return false; + } +}); + +var UIButtonTitleEffectTest = UIScene.extend({ + init: function(){ + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + + // Add a label in which the button events will be displayed + this._topDisplayLabel.setString("Button Title Effect"); + this._bottomDisplayLabel.setString(""); + + // Create the button + var button = new ccui.Button("res/cocosui/animationbuttonnormal.png", "res/cocosui/animationbuttonpressed.png"); + button.setNormalizedPosition(0.3, 0.5); + button.setTitleText("PLAY GAME"); + //button.setTitleFontName("fonts/Marker Felt.ttf"); + button.setZoomScale(0.3); + button.setScale(2.0); + button.setPressedActionEnabled(true); + var title = button.getTitleRenderer(); + button.setTitleColor(cc.color.RED); + title.enableShadow(cc.color.BLACK, cc.size(2,-2)); + this.addChild(button); + + // Create the button + var button2 = new ccui.Button("res/cocosui/animationbuttonnormal.png", "res/cocosui/animationbuttonpressed.png"); + button2.setNormalizedPosition(0.8, 0.5); + button2.setTitleText("PLAY GAME"); + var title2 = button2.getTitleRenderer(); + title2.enableStroke(cc.color.GREEN, 3); + this.addChild(button2); + return true; + } + return false; + } +}); + +var UIButtonFlipTest = UIScene.extend({ + init: function(){ + if (this._super()) { + + // Add a label in which the button events will be displayed + this._topDisplayLabel.setString(""); + this._bottomDisplayLabel.setString(""); + + // Create the button + var button = new ccui.Button("res/cocosui/animationbuttonnormal.png", "res/cocosui/animationbuttonpressed.png"); + button.setNormalizedPosition(0.3, 0.5); + button.setTitleText("PLAY GAME"); + //button.setTitleFontName("fonts/Marker Felt.ttf"); + button.setZoomScale(0.3); + button.setScale(2.0); + button.setFlippedX(true); + button.setPressedActionEnabled(true); + this.addChild(button); + + var titleLabel = new ccui.Text("Button X flipped", "Arial", 20); + titleLabel.setNormalizedPosition(0.3, 0.7); + this.addChild(titleLabel); + + // Create the button + var button2 = new ccui.Button("res/cocosui/animationbuttonnormal.png", "res/cocosui/animationbuttonpressed.png"); + button2.setNormalizedPosition(0.8, 0.5); + button2.setTitleText("PLAY GAME"); + button2.setFlippedY(true); + this.addChild(button2); + + titleLabel = new ccui.Text("Button Y flipped", "Arial", 20); + titleLabel.setNormalizedPosition(0.8, 0.7); + this.addChild(titleLabel); + return true; + } + return false; + } +}); + +var UIButtonNormalDefaultTest = UIScene.extend({ + init: function(){ + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + + // Add a label in which the button events will be displayed + this._topDisplayLabel.setString(""); + this._bottomDisplayLabel.setString(""); + + // Add the alert + var alert = new ccui.Text("Button should scale when clicked","Arial",20); + alert.setColor(cc.color(159, 168, 176)); + alert.setPosition(widgetSize.width / 2.0, + widgetSize.height / 2.0 - alert.height * 1.75); + this._mainNode.addChild(alert); + + // Create the button + var button = new ccui.Button("res/cocosui/animationbuttonnormal.png"); + button.setPosition(widgetSize.width / 2.0 - 80, widgetSize.height / 2.0 + 40); + button.setZoomScale(0.4); + button.setPressedActionEnabled(true); + this._mainNode.addChild(button); + + // Create the button + var buttonScale9 = new ccui.Button("res/cocosui/button.png"); + // open scale9 render + buttonScale9.setScale9Enabled(true); + buttonScale9.setPosition(widgetSize.width / 2.0 + 50, widgetSize.height / 2.0 + 40); + buttonScale9.setContentSize(150, 70); + buttonScale9.setPressedActionEnabled(true); + this._mainNode.addChild(buttonScale9); + return true; + } + return false; + } +}); + +var UIButtonDisableDefaultTest = UIScene.extend({ + init: function(){ + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + + this._topDisplayLabel.setString(""); + this._bottomDisplayLabel.setString(""); + + // Add the alert + var alert = new ccui.Text("Left button will turn normal when clicked","Arial",20); + alert.setColor(cc.color(159, 168, 176)); + alert.setPosition(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert.height * 1.75); + this._mainNode.addChild(alert); + + // Create the button + var button = new ccui.Button("res/cocosui/animationbuttonnormal.png"); + button.setPosition(widgetSize.width / 2.0 - 80, widgetSize.height / 2.0 + 40); + button.setZoomScale(0.4); + button.setPressedActionEnabled(true); + button.setBright(false); + button.addClickEventListener(function () { + button.setBright(true); + }); + this._mainNode.addChild(button); + + // Create the button + var buttonScale9 = new ccui.Button("res/cocosui/button.png"); + // open scale9 render + buttonScale9.setScale9Enabled(true); + buttonScale9.setPosition(widgetSize.width / 2.0 + 50, widgetSize.height / 2.0 + 40); + buttonScale9.setContentSize(150, 70); + buttonScale9.setPressedActionEnabled(true); + buttonScale9.setEnabled(false); + buttonScale9.setBright(false); + this._mainNode.addChild(buttonScale9); + return true; + } + return false; + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/GUITest/UICheckBoxTest/UICheckBoxTest.js b/tests/js-tests/src/GUITest/UICheckBoxTest/UICheckBoxTest.js new file mode 100644 index 0000000000..4ed941f959 --- /dev/null +++ b/tests/js-tests/src/GUITest/UICheckBoxTest/UICheckBoxTest.js @@ -0,0 +1,120 @@ +/**************************************************************************** + 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 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 UICheckBoxTest = UIScene.extend({ + init: function () { + if (this._super()) { + //init text + this._topDisplayLabel.setString("No Event"); + this._bottomDisplayLabel.setString("CheckBox"); + + var widgetSize = this._widget.getContentSize(); + // Create the checkbox + var checkBox = new ccui.CheckBox(); + checkBox.setTouchEnabled(true); + checkBox.loadTextures("res/cocosui/check_box_normal.png", + "res/cocosui/check_box_normal_press.png", + "res/cocosui/check_box_active.png", + "res/cocosui/check_box_normal_disable.png", + "res/cocosui/check_box_active_disable.png"); + checkBox.x = widgetSize.width / 2.0; + checkBox.y = widgetSize.height / 2.0; + checkBox.addEventListener(this.selectedStateEvent, this); + this._mainNode.addChild(checkBox); + + return true; + } + return false; + }, + + selectedStateEvent: function (sender, type) { + switch (type) { + case ccui.CheckBox.EVENT_UNSELECTED: + this._topDisplayLabel.setString("Unselected"); + break; + case ccui.CheckBox.EVENT_SELECTED: + this._topDisplayLabel.setString("Selected"); + break; + + default: + break; + } + } +}); + +//2015-01-14 +var UICheckBoxDefaultBehaviorTest = UIScene.extend({ + + init: function(){ + if(this._super()){ + var widgetSize = this._widget.getContentSize(); + + // Add a label in which the checkbox events will be displayed + this._displayValueLabel = new ccui.Text("No Event", "Marker Felt", 32); + this._displayValueLabel.setAnchorPoint(cc.p(0.5, -1)); + this._displayValueLabel.setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2)); + this._mainNode.addChild(this._displayValueLabel); + this._bottomDisplayLabel.setString(""); + + // Add the alert + var alert = new ccui.Text("Only left two and the last checkbox can be cliked!","Marker Felt",20 ); + alert.setColor(cc.color(159, 168, 176)); + alert.setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 - alert.getContentSize().height * 1.75)); + this._mainNode.addChild(alert); + + // Create the checkbox + var checkBox = new ccui.CheckBox("res/cocosui/check_box_normal.png", "res/cocosui/check_box_active.png"); + checkBox.setPosition(cc.p(widgetSize.width / 2 - 50, widgetSize.height / 2)); + + this._mainNode.addChild(checkBox); + + + // Create the checkbox + var checkBox2 = new ccui.CheckBox("res/cocosui/check_box_normal.png", "res/cocosui/check_box_active.png"); + checkBox2.setPosition(cc.p(widgetSize.width / 2 - 150, widgetSize.height / 2)); + checkBox2.ignoreContentAdaptWithSize(false); + checkBox2.setZoomScale(0.5); + checkBox2.setContentSize(cc.size(80,80)); + checkBox2.setName("bigCheckBox"); + this._mainNode.addChild(checkBox2); + + + // Create the checkbox + var checkBoxDisabled = new ccui.CheckBox("res/cocosui/check_box_normal.png", "res/cocosui/check_box_active.png"); + checkBoxDisabled.setPosition(cc.p(widgetSize.width / 2 + 20, widgetSize.height / 2)); + checkBoxDisabled.setEnabled(false); + checkBoxDisabled.setBright(false); + this._mainNode.addChild(checkBoxDisabled); + + var checkBoxDisabled2 = new ccui.CheckBox("res/cocosui/check_box_normal.png", "res/cocosui/check_box_active.png"); + checkBoxDisabled2.setPosition(cc.p(widgetSize.width / 2 + 70, widgetSize.height / 2)); + checkBoxDisabled2.setBright(false); + checkBoxDisabled2.setSelected(true); + this._mainNode.addChild(checkBoxDisabled2); + return true; + } + } + +}); \ No newline at end of file diff --git a/tests/js-tests/src/GUITest/UIFocusTest/UIFocusTest.js b/tests/js-tests/src/GUITest/UIFocusTest/UIFocusTest.js new file mode 100644 index 0000000000..6facfd3db3 --- /dev/null +++ b/tests/js-tests/src/GUITest/UIFocusTest/UIFocusTest.js @@ -0,0 +1,554 @@ +/**************************************************************************** + 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 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 UIFocusTestBase = UIScene.extend({ + _dpadMenu: null, + _firstFocusedWidget: null, + _eventListener:null, + + init: function(){ + if (this._super()) { + var root = this._mainNode.getChildByTag(81); + var background = root.getChildByName("background_Panel"); + background.removeFromParent(true); + + this._dpadMenu = new cc.Menu(); + + cc.MenuItemFont.setFontSize(20); + var winSize = cc.director.getVisibleSize(); + var leftItem = new cc.MenuItemFont("Left", this.onLeftKeyPressed, this); + leftItem.setPosition(winSize.width - 100, winSize.height/2); + this._dpadMenu.addChild(leftItem); + + var rightItem = new cc.MenuItemFont("Right", this.onRightKeyPressed, this); + rightItem.setPosition(winSize.width - 30, winSize.height/2); + this._dpadMenu.addChild(rightItem); + + var upItem = new cc.MenuItemFont("Up", this.onUpKeyPressed, this); + upItem.setPosition(winSize.width - 60, winSize.height/2 + 50); + this._dpadMenu.addChild(upItem); + + var downItem = new cc.MenuItemFont("Down", this.onDownKeyPressed, this); + downItem.setPosition(winSize.width - 60, winSize.height/2 - 50); + this._dpadMenu.addChild(downItem); + + this._dpadMenu.setPosition(0, 0); + this.addChild(this._dpadMenu); + + //call this method to enable Dpad focus navigation + ccui.Widget.enableDpadNavigation(true); + + this._eventListener = cc.EventListener.create({ + event: cc.EventListener.FOCUS, //TODO Need add focus event in JSB + onFocusChanged: this.onFocusChanged.bind(this) + }); + cc.eventManager.addListener(this._eventListener, 1); + return true; + } + return false; + }, + + onLeftKeyPressed: function(){ + var event = new cc.EventKeyboard(cc.KEY.dpadLeft, false); + cc.eventManager.dispatchEvent(event); + }, + onRightKeyPressed: function(){ + var event = new cc.EventKeyboard(cc.KEY.dpadRight, false); + cc.eventManager.dispatchEvent(event); + }, + onUpKeyPressed: function(){ + var event = new cc.EventKeyboard(cc.KEY.dpadUp, false); + cc.eventManager.dispatchEvent(event); + }, + onDownKeyPressed: function(){ + var event = new cc.EventKeyboard(cc.KEY.dpadDown, false); + cc.eventManager.dispatchEvent(event); + }, + onFocusChanged: function(widgetLostFocus, widgetGetFocus){ + if (widgetGetFocus && widgetGetFocus.isFocusEnabled()) + widgetGetFocus.setColor(cc.color.RED); + + if (widgetLostFocus && widgetLostFocus.isFocusEnabled()) + widgetLostFocus.setColor(cc.color.WHITE); + + if (widgetLostFocus && widgetGetFocus) + cc.log("on focus change, %d widget get focus, %d widget lose focus", widgetGetFocus.getTag(), widgetLostFocus.getTag()); + }, + + onImageViewClicked: function(widget, touchType){ + if (touchType == ccui.Widget.TOUCH_ENDED) { + if (widget.isFocusEnabled()) { + widget.setFocusEnabled(false); + widget.setColor(cc.color.YELLOW); + }else{ + widget.setFocusEnabled(true); + widget.setColor(cc.color.WHITE); + } + } + } +}); + +var UIFocusTestHorizontal = UIFocusTestBase.extend({ + _horizontalLayout: null, + _loopText: null, + + init: function(){ + if (this._super()) { + var winSize = cc.director.getVisibleSize(); + + this._horizontalLayout = new ccui.HBox(); + this._horizontalLayout.setPosition(winSize.height/2 - 20, winSize.height/2 + 40); + this.addChild(this._horizontalLayout); + + this._horizontalLayout.setFocused(true); + this._horizontalLayout.setLoopFocus(true); + this._horizontalLayout.setTag(100); + this._firstFocusedWidget = this._horizontalLayout; + + var count = 3; + for (var i=0; i 100) { + this._count = 0; + } + + this._loadingBar && this._loadingBar.setPercent(this._count); + }, + + previousCallback: function (sender, type) { + this.unscheduleUpdate(); + this._super(sender, type) + }, + + restartCallback: function (sender, type) { + this.unscheduleUpdate(); + this._super(sender, type) + }, + + nextCallback: function (sender, type) { + this.unscheduleUpdate(); + this._super(sender, type) + } +}); + +var UILoadingBarTest_Left = UILoadingBarTest.extend({ + createLoadingBar: function () { + var widgetSize = this._widget.getContentSize(); + var loadingBar = new ccui.LoadingBar(); + loadingBar.setName("LoadingBar"); + loadingBar.loadTexture("res/cocosui/sliderProgress.png"); + loadingBar.setPercent(0); + loadingBar.x = widgetSize.width / 2; + loadingBar.y = widgetSize.height / 2 + loadingBar.height / 4; + this._mainNode.addChild(loadingBar); + this._loadingBar = loadingBar; + } +}); + +var UILoadingBarTest_Right = UILoadingBarTest.extend({ + createLoadingBar: function () { + var widgetSize = this._widget.getContentSize(); + var loadingBar = new ccui.LoadingBar(); + loadingBar.setName("LoadingBar"); + loadingBar.loadTexture("res/cocosui/sliderProgress.png"); + loadingBar.setDirection(ccui.LoadingBar.TYPE_RIGHT); + loadingBar.setPercent(0); + loadingBar.x = widgetSize.width / 2; + loadingBar.y = widgetSize.height / 2 + loadingBar.height / 4; + this._mainNode.addChild(loadingBar); + this._loadingBar = loadingBar; + } +}); + +var UILoadingBarTest_Fix = UILoadingBarTest.extend({ + createLoadingBar: function () { + var widgetSize = this._widget.getContentSize(); + var loadingBar = new ccui.LoadingBar(); + loadingBar.setName("LoadingBar"); + loadingBar.loadTexture("res/cocosui/sliderProgress.png"); + loadingBar.setDirection(ccui.LoadingBar.TYPE_RIGHT); + loadingBar.setPercent(40); + loadingBar.x = widgetSize.width / 2; + loadingBar.y = widgetSize.height / 2 + loadingBar.height / 4; + this._mainNode.addChild(loadingBar); + this._loadingBar = null; + } +}); + +var UILoadingBarTest_Left_Scale9 = UILoadingBarTest.extend({ + createLoadingBar: function () { + var widgetSize = this._widget.getContentSize(); + var loadingBar = new ccui.LoadingBar(); + loadingBar.setName("LoadingBar"); + loadingBar.setScale9Enabled(true); + loadingBar.loadTexture("res/cocosui/slider_bar_active_9patch.png"); + loadingBar.setCapInsets(cc.rect(0, 0, 0, 0)); + loadingBar.setContentSize(cc.size(300, 30)); + loadingBar.setPercent(0); + loadingBar.x = widgetSize.width / 2; + loadingBar.y = widgetSize.height / 2 + loadingBar.height / 4; + this._mainNode.addChild(loadingBar); + this._loadingBar = loadingBar; + } +}); + +var UILoadingBarTest_Right_Scale9 = UILoadingBarTest.extend({ + createLoadingBar: function () { + var widgetSize = this._widget.getContentSize(); + var loadingBar = new ccui.LoadingBar(); + loadingBar.setName("LoadingBar"); + loadingBar.setScale9Enabled(true); + loadingBar.loadTexture("res/cocosui/slider_bar_active_9patch.png"); + loadingBar.setCapInsets(cc.rect(0, 0, 0, 0)); + loadingBar.setContentSize(cc.size(300, 30)); + loadingBar.setDirection(ccui.LoadingBar.TYPE_RIGHT); + loadingBar.setPercent(0); + loadingBar.x = widgetSize.width / 2; + loadingBar.y = widgetSize.height / 2 + loadingBar.height / 4; + this._mainNode.addChild(loadingBar); + this._loadingBar = loadingBar; + } +}); + +var UILoadingBarTest_Fix_Scale9 = UILoadingBarTest.extend({ + createLoadingBar: function () { + var widgetSize = this._widget.getContentSize(); + var loadingBar = new ccui.LoadingBar(); + loadingBar.setName("LoadingBar"); + loadingBar.setScale9Enabled(true); + loadingBar.loadTexture("res/cocosui/slider_bar_active_9patch.png"); + loadingBar.setPercent(40); + loadingBar.setCapInsets(cc.rect(0, 0, 0, 0)); + loadingBar.setContentSize(cc.size(300, 30)); + loadingBar.setDirection(ccui.LoadingBar.TYPE_RIGHT); + loadingBar.x = widgetSize.width / 2; + loadingBar.y = widgetSize.height / 2 + loadingBar.height / 4; + this._mainNode.addChild(loadingBar); + this._loadingBar = null; + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/GUITest/UINodeContainerTest/UINodeContainerTest.js b/tests/js-tests/src/GUITest/UINodeContainerTest/UINodeContainerTest.js new file mode 100644 index 0000000000..2ed9b344c0 --- /dev/null +++ b/tests/js-tests/src/GUITest/UINodeContainerTest/UINodeContainerTest.js @@ -0,0 +1,49 @@ +/**************************************************************************** + 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 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 UIWidgetAddNodeTest = UIScene.extend({ + init: function () { + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + //init text + this._topDisplayLabel.setString(""); + this._bottomDisplayLabel.setString("NodeContainer"); + + // Create the ui node container + var nodeContainer = new ccui.Widget(); + nodeContainer.x = widgetSize.width / 2; + nodeContainer.y = widgetSize.height / 2; + this._mainNode.addChild(nodeContainer); + + var sprite = new cc.Sprite("res/cocosui/ccicon.png"); + sprite.x = 0; + sprite.y = sprite.getBoundingBox().height / 4; + nodeContainer.addNode(sprite); + + return true; + } + return false; + } +}); diff --git a/tests/js-tests/src/GUITest/UIPageViewTest/UIPageViewTest.js b/tests/js-tests/src/GUITest/UIPageViewTest/UIPageViewTest.js new file mode 100644 index 0000000000..af2fd34854 --- /dev/null +++ b/tests/js-tests/src/GUITest/UIPageViewTest/UIPageViewTest.js @@ -0,0 +1,530 @@ +/**************************************************************************** + 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 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 UIPageViewTest = UIScene.extend({ + init: function () { + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + //init text + this._topDisplayLabel.setString("Move by horizontal direction"); + this._topDisplayLabel.x = widgetSize.width / 2.0; + this._topDisplayLabel.y = widgetSize.height / 2.0 + this._topDisplayLabel.height * 1.5; + this._bottomDisplayLabel.setString("PageView"); + this._bottomDisplayLabel.x = widgetSize.width / 2; + this._bottomDisplayLabel.y = widgetSize.height / 2 - this._bottomDisplayLabel.height * 3; + + var background = this._widget.getChildByName("background_Panel"); + + // Create the page view + var pageView = new ccui.PageView(); + pageView.setTouchEnabled(true); + pageView.setContentSize(cc.size(240, 130)); + pageView.x = (widgetSize.width - background.width) / 2 + (background.width - pageView.width) / 2; + pageView.y = (widgetSize.height - background.height) / 2 + (background.height - pageView.height) / 2; + + for (var i = 0; i < 3; ++i) { + var layout = new ccui.Layout(); + layout.setContentSize(cc.size(240, 130)); + var layoutRect = layout.getContentSize(); + + var imageView = new ccui.ImageView(); + imageView.setTouchEnabled(true); + imageView.setScale9Enabled(true); + imageView.loadTexture("res/cocosui/scrollviewbg.png"); + imageView.setContentSize(cc.size(240, 130)); + imageView.x = layoutRect.width / 2; + imageView.y = layoutRect.height / 2; + layout.addChild(imageView); + + var text = new ccui.Text(); + text.string = "page" + (i + 1); + text.font = "30px 'Marker Felt'"; + text.color = cc.color(192, 192, 192); + text.x = layoutRect.width / 2; + text.y = layoutRect.height / 2; + layout.addChild(text); + + pageView.addPage(layout); + } + pageView.addEventListener(this.pageViewEvent, this); + this._mainNode.addChild(pageView); + + return true; + } + return false; + }, + + pageViewEvent: function (sender, type) { + switch (type) { + case ccui.PageView.EVENT_TURNING: + var pageView = sender; + this._topDisplayLabel.setString("page = " + (pageView.getCurPageIndex().valueOf()-0 + 1)); + break; + default: + break; + } + } +}); + +//2015-01-14 +var UIPageViewButtonTest = UIScene.extend({ + init: function(){ + if (this._super()){ + var widgetSize = this._widget.getContentSize(); + + // Add a label in which the dragpanel events will be displayed + this._topDisplayLabel.setString("Move by horizontal direction"); + this._topDisplayLabel.x = widgetSize.width / 2.0; + this._topDisplayLabel.y = widgetSize.height / 2.0 + this._topDisplayLabel.height * 1.5; + + // Add the black background + this._bottomDisplayLabel.setString("PageView with Buttons"); + this._bottomDisplayLabel.setPosition(widgetSize.width / 2.0, widgetSize.height / 2.0 - this._bottomDisplayLabel.height * 3.075); + + var root = this._mainNode.getChildByTag(81); + var background = root.getChildByName("background_Panel"); + + // Create the page view + var pageView = new ccui.PageView(); + pageView.setContentSize(cc.size(240.0, 130.0)); + var backgroundSize = background.getContentSize(); + pageView.setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2.0 + + (backgroundSize.width - pageView.getContentSize().width) / 2.0, + (widgetSize.height - backgroundSize.height) / 2.0 + + (backgroundSize.height - pageView.getContentSize().height) / 2.0)); + + pageView.removeAllPages(); + + var pageCount = 4; + for (var i = 0; i < pageCount; ++i){ + var outerBox = new ccui.HBox(); + outerBox.setContentSize(cc.size(240.0, 130.0)); + + for (var k = 0; k < 2; ++k) { + var innerBox = new ccui.VBox(); + + for (var j = 0; j < 3; j++) { + var btn = new ccui.Button("res/cocosui/animationbuttonnormal.png", "res/cocosui/animationbuttonpressed.png"); + btn.setName("button " + j); + btn.addTouchEventListener( this.onButtonClicked, this); + innerBox.addChild(btn); + } + + var parameter = new ccui.LinearLayoutParameter(); + parameter.setMargin({left: 0, top: 0, right: 100, bottom: 0}); + innerBox.setLayoutParameter(parameter); + + outerBox.addChild(innerBox); + } + pageView.insertPage(outerBox,i); + } + + pageView.removePageAtIndex(0); + pageView.addEventListener(this.pageViewEvent, this); + this._mainNode.addChild(pageView); + + return true; + } + }, + + onButtonClicked: function(sender, type){ + cc.log("button %s clicked", sender.getName()); + }, + + pageViewEvent: function(pageView, type){ + switch (type){ + case ccui.PageView.EVENT_TURNING: + this._topDisplayLabel.setString("page = " + pageView.getCurPageIndex() + 1); + break; + default: + break; + } + } +}); + +//2015-01-14 +var UIPageViewCustomScrollThreshold = UIScene.extend({ + init: function(){ + if (this._super()){ + var widgetSize = this._widget.getContentSize(); + + // Add a label in which the dragpanel events will be displayed + this._topDisplayLabel.setString("Scroll Threshold"); + this._topDisplayLabel.x = widgetSize.width / 2.0; + this._topDisplayLabel.y = widgetSize.height / 2.0 + this._topDisplayLabel.height * 1.5; + + // Add the black background + this._bottomDisplayLabel.setString("PageView"); + this._bottomDisplayLabel.setPosition(cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0 - this._bottomDisplayLabel.height * 3.075)); + + var root = this._mainNode.getChildByTag(81); + var background = root.getChildByName("background_Panel"); + + // Create the page view + var pageView = new ccui.PageView(); + pageView.setContentSize(cc.size(240.0, 100.0)); + var backgroundSize = background.getContentSize(); + pageView.setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2.0 + + (backgroundSize.width - pageView.getContentSize().width) / 2.0, + (widgetSize.height - backgroundSize.height) / 2.0 + + (backgroundSize.height - pageView.getContentSize().height) / 2.0 + 20)); + + var pageCount = 4; + for (var i = 0; i < pageCount; ++i) { + var layout = new ccui.Layout(); + layout.setContentSize(cc.size(240.0, 130.0)); + + var imageView = new ccui.ImageView("res/cocosui/scrollviewbg.png"); + imageView.setScale9Enabled(true); + imageView.setContentSize(cc.size(240, 130)); + imageView.setPosition(cc.p(layout.getContentSize().width / 2.0, layout.getContentSize().height / 2.0)); + layout.addChild(imageView); + + var label = new ccui.Text("page " + (i+1) , "Marker Felt", 30); + label.setColor(cc.color(192, 192, 192)); + label.setPosition(cc.p(layout.getContentSize().width / 2.0, layout.getContentSize().height / 2.0)); + layout.addChild(label); + + pageView.insertPage(layout,i); + } + + this._mainNode.addChild(pageView); + pageView.setName("pageView"); + + var slider = new ccui.Slider(); + slider.loadBarTexture("res/cocosui/sliderTrack.png"); + slider.loadSlidBallTextures("res/cocosui/sliderThumb.png", "res/cocosui/sliderThumb.png", ""); + slider.loadProgressBarTexture("res/cocosui/sliderProgress.png"); + slider.setPosition(cc.p(widgetSize.width / 2.0 , widgetSize.height / 2.0 - 40)); + slider.addEventListener(this.sliderEvent, this); + slider.setPercent(50); + this._mainNode.addChild(slider); + + return true; + } + }, + + sliderEvent: function(slider, type){ + if (type == ccui.Slider.EVENT_PERCENT_CHANGED){ + var percent = slider.getPercent(); + var pageView = this._mainNode.getChildByName("pageView"); + if (percent == 0) + percent = 1; + pageView.setCustomScrollThreshold(percent * 0.01 * pageView.width); + + this._topDisplayLabel.setString("Scroll Threshold: " + pageView.getCustomScrollThreshold().toFixed(2)); + } + } +}); + +//2015-01-14 +var UIPageViewTouchPropagationTest = UIScene.extend({ + init: function(){ + if (this._super()){ + var widgetSize = this._widget.getContentSize(); + + // Add a label in which the dragpanel events will be displayed + this._topDisplayLabel.setString("Move by horizontal direction"); + this._topDisplayLabel.x = widgetSize.width / 2.0; + this._topDisplayLabel.y = widgetSize.height / 2.0 + this._topDisplayLabel.height * 1.5; + + // Add the black background + this._bottomDisplayLabel.setString("PageView Touch Propagation"); + this._bottomDisplayLabel.setPosition(widgetSize.width / 2.0, widgetSize.height / 2.0 - this._bottomDisplayLabel.height * 3.075); + + var root = this._mainNode.getChildByTag(81); + var background = root.getChildByName("background_Panel"); + + // Create the page view + var pageView = new ccui.PageView(); + pageView.setContentSize(cc.size(240.0, 130.0)); + pageView.setAnchorPoint(cc.p(0.5,0.5)); + var backgroundSize = background.getContentSize(); + pageView.setPosition(cc.p(widgetSize.width / 2.0 ,widgetSize.height / 2.0)); + pageView.setBackGroundColor(cc.color.GREEN); + pageView.setBackGroundColorType(ccui.Layout.BG_COLOR_SOLID); + + var pageCount = 4; + for (var i = 0; i < pageCount; ++i) { + var outerBox = new ccui.HBox(); + outerBox.setContentSize(cc.size(240.0, 130.0)); + + for (var k = 0; k < 2; ++k) { + var innerBox = new ccui.VBox(); + + for (var j = 0; j < 3; j++) { + var btn = new ccui.Button("res/cocosui/animationbuttonnormal.png", "res/cocosui/animationbuttonpressed.png"); + btn.setName("button " + j); + btn.addTouchEventListener(this.onButtonClicked, this); + innerBox.addChild(btn); + } + + var parameter = new ccui.LinearLayoutParameter(); + parameter.setMargin({left: 0, top: 0, right: 100, bottom: 0}); + innerBox.setLayoutParameter(parameter); + + outerBox.addChild(innerBox); + } + pageView.insertPage(outerBox, i); + } + + pageView.addEventListener(this.pageViewEvent, this); + pageView.setName("pageView"); + pageView.addTouchEventListener(function(sender, type){ + if (type == ccui.Widget.TOUCH_BEGAN){ + cc.log("page view touch began"); + }else if(type == ccui.Widget.TOUCH_MOVED){ + cc.log("page view touch moved"); + }else if(type == ccui.Widget.TOUCH_ENDED){ + cc.log("page view touch ended"); + }else{ + cc.log("page view touch cancelled"); + } + }); + this._mainNode.addChild(pageView); + + var propagationText = new ccui.Text("Allow Propagation", "Arial", 10); + propagationText.setAnchorPoint(cc.p(0,0.5)); + propagationText.setTextColor(cc.color.RED); + propagationText.setPosition(cc.p(0, pageView.getPosition().y + 50)); + this._mainNode.addChild(propagationText); + + var swallowTouchText = new ccui.Text("Swallow Touches", "Arial", 10); + swallowTouchText.setAnchorPoint(cc.p(0,0.5)); + swallowTouchText.setTextColor(cc.color.RED); + swallowTouchText.setPosition(cc.p(0, pageView.getPosition().y)); + this._mainNode.addChild(swallowTouchText); + + // Create the checkbox + var checkBox1 = new ccui.CheckBox("res/cocosui/check_box_normal.png", + "res/cocosui/check_box_normal_press.png", + "res/cocosui/check_box_active.png", + "res/cocosui/check_box_normal_disable.png", + "res/cocosui/check_box_active_disable.png"); + var propagationPosition = propagationText.getPosition(); + checkBox1.setPosition( + propagationPosition.x + propagationText.getContentSize().width/2, + propagationPosition.y - 20 + ); + + checkBox1.setName("propagation"); + this._mainNode.addChild(checkBox1); + + // Create the checkbox + var checkBox2 = new ccui.CheckBox("res/cocosui/check_box_normal.png", + "res/cocosui/check_box_normal_press.png", + "res/cocosui/check_box_active.png", + "res/cocosui/check_box_normal_disable.png", + "res/cocosui/check_box_active_disable.png"); + var swallowPosition = swallowTouchText.getPosition(); + checkBox2.setPosition( + swallowPosition.x + swallowTouchText.getContentSize().width/2, + swallowPosition.y - 20 + ); + + checkBox2.setName("swallow"); + this._mainNode.addChild(checkBox2); + +// var eventListener = new cc.EventListenerTouchOneByOne(); +// eventListener.onTouchBegan = function(touch, event){ +// cc.log("layout recieves touches"); +// return true; +// }; +// this._eventDispatcher.addEventListenerWithSceneGraphPriority(eventListener, this); + + return true; + } + }, + + onButtonClicked: function(btn, type){ + var ck1 = this._mainNode.getChildByName("propagation"); + var ck2 = this._mainNode.getChildByName("swallow"); + var pageView = this._mainNode.getChildByName("pageView"); + + if (type == ccui.Widget.TOUCH_BEGAN){ + if (ck1.isSelected()){ + btn.setPropagateTouchEvents(true); + pageView.setPropagateTouchEvents(true); + }else{ + btn.setPropagateTouchEvents(false); + pageView.setPropagateTouchEvents(false); + } + + if (ck2.isSelected()){ + btn.setSwallowTouches(true); + pageView.setSwallowTouches(true); + }else{ + btn.setSwallowTouches(false); + pageView.setSwallowTouches(false); + } + } + if (type == ccui.Widget.TOUCH_ENDED) + cc.log("button clicked"); + }, + + pageViewEvent: function(pageView, type){ + switch (type){ + case ccui.PageView.EVENT_TURNING: + this._topDisplayLabel.setString("page = " + (pageView.getCurPageIndex()-0 + 1)); + break; + default: + break; + } + } +}); + +//2015-01-14 +var UIPageViewDynamicAddAndRemoveTest = UIScene.extend({ + init: function(){ + var self = this; + if (this._super()){ + var widgetSize = this._widget.getContentSize(); + + // Add a label in which the dragpanel events will be displayed + this._topDisplayLabel.setString("Click Buttons on the Left"); + this._topDisplayLabel.x = widgetSize.width / 2.0; + this._topDisplayLabel.y = widgetSize.height / 2.0 + this._topDisplayLabel.height * 1.5; + + // Add the black background + this._bottomDisplayLabel.setString("PageView Dynamic Modification"); + this._bottomDisplayLabel.setPosition(widgetSize.width / 2.0, widgetSize.height / 2.0 - this._bottomDisplayLabel.height * 3.075); + + var root = this._mainNode.getChildByTag(81); + var background = root.getChildByName("background_Panel"); + + // Create the page view + var pageView = new ccui.PageView(); + pageView.setContentSize(cc.size(240.0, 130.0)); + pageView.setAnchorPoint(cc.p(0.5,0.5)); + var backgroundSize = background.getContentSize(); + pageView.setPosition(cc.p(widgetSize.width / 2.0 ,widgetSize.height / 2.0)); + pageView.setBackGroundColor(cc.color.GREEN); + pageView.setBackGroundColorType(ccui.Layout.BG_COLOR_SOLID); + + var pageCount = 4; + for (var i = 0; i < pageCount; ++i){ + var outerBox = new ccui.HBox(); + outerBox.setContentSize(cc.size(240.0, 130.0)); + + for (var k = 0; k < 2; ++k){ + var innerBox = new ccui.VBox(); + for (var j = 0; j < 3; j++){ + var btn = new ccui.Button("res/cocosui/animationbuttonnormal.png", + "res/cocosui/animationbuttonpressed.png"); + btn.setName("button " + j); + innerBox.addChild(btn); + } + + var parameter = new ccui.LinearLayoutParameter(); + parameter.setMargin({left: 0, top: 0, right: 100, bottom:0}); + innerBox.setLayoutParameter(parameter); + + outerBox.addChild(innerBox); + } + pageView.insertPage(outerBox,i); + } + + pageView.addEventListener(this.pageViewEvent, this); + pageView.setName("pageView"); + this._mainNode.addChild(pageView); + + //add buttons + var button = new ccui.Button(); +// button.setNormalizedPosition(cc.p(0.12,0.7)); + button.setPosition(20, 220); + button.setTitleText("Add A Page"); + button.setZoomScale(0.3); + button.setPressedActionEnabled(true); + button.setTitleColor(cc.color.RED); + button.addClickEventListener(function(sender){ + var outerBox = new ccui.HBox(); + outerBox.setContentSize(cc.size(240.0, 130.0)); + + for (var k = 0; k < 2; ++k){ + var innerBox = new ccui.VBox(); + for (var j = 0; j < 3; j++){ + var btn = new ccui.Button("res/cocosui/animationbuttonnormal.png", + "res/cocosui/animationbuttonpressed.png"); + btn.setName("button " + j); + innerBox.addChild(btn); + } + + var parameter = new ccui.LinearLayoutParameter(); + parameter.setMargin({left: 0, top: 0, right: 100, bottom: 0}); + innerBox.setLayoutParameter(parameter); + + outerBox.addChild(innerBox); + } + + pageView.addPage(outerBox); + self._topDisplayLabel.setString("page count = " + pageView.getPages().length); + }); + this._mainNode.addChild(button); + + var button2 = new ccui.Button(); +// button2.setNormalizedPosition(cc.p(0.12,0.5)); + button2.setPosition(20, 180); + button2.setTitleText("Remove A Page"); + button2.setZoomScale(0.3); + button2.setPressedActionEnabled(true); + button2.setTitleColor(cc.color.RED); + button2.addClickEventListener(function(sender){ + if (pageView.getPages().length > 0){ + pageView.removePageAtIndex(pageView.getPages().length-1); + }else{ + cc.log("There is no page to remove!"); + } + self._topDisplayLabel.setString("page count = " + pageView.getPages().length); + + }); + this._mainNode.addChild(button2); + + var button3 = new ccui.Button(); +// button3.setNormalizedPosition(cc.p(0.12,0.3)); + button3.setPosition(cc.p(20, 140)); + button3.setTitleText("Remove All Pages"); + button3.setZoomScale(0.3); + button3.setPressedActionEnabled(true); + button3.setTitleColor(cc.color.RED); + button3.addClickEventListener(function(sender){ + pageView.removeAllPages(); + self._topDisplayLabel.setString("page count = " + pageView.getPages().length); + }); + this._mainNode.addChild(button3); + + return true; + } + }, + + pageViewEvent: function(pageView, type){ + switch (type){ + case ccui.PageView.EVENT_TURNING: + this._topDisplayLabel.setString("page = " + (pageView.getCurPageIndex() + 1)); + break; + default: + break; + } + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/GUITest/UIRichTextTest/UIRichTextTest.js b/tests/js-tests/src/GUITest/UIRichTextTest/UIRichTextTest.js new file mode 100644 index 0000000000..68639ec7b9 --- /dev/null +++ b/tests/js-tests/src/GUITest/UIRichTextTest/UIRichTextTest.js @@ -0,0 +1,91 @@ +/**************************************************************************** + 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 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 UIRichTextTest = UIScene.extend({ + _richText:null, + init: function () { + if (this._super()) { + //init text + this._topDisplayLabel.setString(""); + this._bottomDisplayLabel.setString("RichText"); + + var widgetSize = this._widget.getContentSize(); + var button = new ccui.Button(); + button.setTouchEnabled(true); + button.loadTextures("res/cocosui/animationbuttonnormal.png", "res/cocosui/animationbuttonpressed.png", ""); + button.setTitleText("switch"); + button.setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 + button.getContentSize().height * 2.5)); + button.addTouchEventListener(this.touchEvent,this); + this._mainNode.addChild(button); + + // RichText + var richText = new ccui.RichText(); + richText.ignoreContentAdaptWithSize(false); + richText.width = 120; + richText.height = 100; + + var re1 = new ccui.RichElementText(1, cc.color.WHITE, 255, "This color is white. ", "Helvetica", 10); + var re2 = new ccui.RichElementText(2, cc.color.YELLOW, 255, "And this is yellow. ", "Helvetica", 10); + var re3 = new ccui.RichElementText(3, cc.color.BLUE, 255, "This one is blue. ", "Helvetica", 10); + var re4 = new ccui.RichElementText(4, cc.color.GREEN, 255, "And green. ", "Helvetica", 10); + var re5 = new ccui.RichElementText(5, cc.color.RED, 255, "Last one is red ", "Helvetica", 10); + + var reimg = new ccui.RichElementImage(6, cc.color.WHITE, 255, "res/cocosui/sliderballnormal.png"); + + ccs.armatureDataManager.addArmatureFileInfo("res/cocosui/100/100.ExportJson"); + var pAr = new ccs.Armature("100"); + pAr.getAnimation().play("Animation1"); + + var recustom = new ccui.RichElementCustomNode(1, cc.color.WHITE, 255, pAr); + var re6 = new ccui.RichElementText(7, cc.color.ORANGE, 255, "Have fun!! ", "Helvetica", 10); + richText.pushBackElement(re1); + richText.insertElement(re2, 1); + richText.pushBackElement(re3); + richText.pushBackElement(re4); + richText.pushBackElement(re5); + richText.insertElement(reimg, 2); + richText.pushBackElement(recustom); + richText.pushBackElement(re6); + + richText.x = widgetSize.width / 2; + richText.y = widgetSize.height / 2; + + this._mainNode.addChild(richText); + this._richText = richText; + return true; + } + return false; + }, + touchEvent: function (sender, type) { + if (type == ccui.Widget.TOUCH_ENDED) { + if (this._richText.isIgnoreContentAdaptWithSize()) { + this._richText.ignoreContentAdaptWithSize(false); + this._richText.setContentSize(cc.size(120, 100)); + } else { + this._richText.ignoreContentAdaptWithSize(true); + } + } + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/GUITest/UIScene.js b/tests/js-tests/src/GUITest/UIScene.js new file mode 100644 index 0000000000..1dc7f590df --- /dev/null +++ b/tests/js-tests/src/GUITest/UIScene.js @@ -0,0 +1,138 @@ +/**************************************************************************** + 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 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. + ****************************************************************************/ + +UIScene = cc.Scene.extend({ + _widget: null, + _sceneTitle: null, + _topDisplayLabel:null, + _bottomDisplayLabel:null, + _mainNode:null, + ctor: function () { + cc.Scene.prototype.ctor.call(this); + this._widget = null; + }, + init: function () { + if (this._super()) { + var winSize = cc.director.getWinSize(); + + //add main node + var mainNode = new cc.Node(); + var scale = winSize.height / 320; + mainNode.attr({anchorX: 0, anchorY: 0, scale: scale, x: (winSize.width - 480 * scale) / 2, y: (winSize.height - 320 * scale) / 2}); + this.addChild(mainNode); + + var widget; + if(cocoStudioOldApiFlag == 0){ + var json = ccs.load("res/cocosui/UITest/UITest.json"); + widget = json.node; + }else{ + //old api + widget = ccs.uiReader.widgetFromJsonFile("res/cocosui/UITest/UITest.json"); + } + mainNode.addChild(widget,-1); + + this._sceneTitle = widget.getChildByName("UItest"); + + var back_label = widget.getChildByName("back"); + back_label.addTouchEventListener(this.toExtensionsMainLayer, this); + + var left_button = widget.getChildByName("left_Button"); + left_button.addTouchEventListener(this.previousCallback ,this); + + var middle_button = widget.getChildByName("middle_Button"); + middle_button.addTouchEventListener(this.restartCallback ,this); + + var right_button = widget.getChildByName("right_Button"); + right_button.addTouchEventListener(this.nextCallback ,this); + + //add topDisplayLabel + var widgetSize = widget.getContentSize(); + var topDisplayText = new ccui.Text(); + topDisplayText.attr({ + string: "", + fontName: "Marker Felt", + fontSize: 32, + anchorX: 0.5, + anchorY: -1, + x: widgetSize.width / 2.0, + y: widgetSize.height / 2.0 + }); + mainNode.addChild(topDisplayText); + + //add bottomDisplayLabel + var bottomDisplayText = new ccui.Text(); + bottomDisplayText.attr({ + string: "INIT", + fontName: "Marker Felt", + fontSize: 30, + color: cc.color(159, 168, 176), + x: widgetSize.width / 2.0 + }); + bottomDisplayText.y = widgetSize.height / 2.0 - bottomDisplayText.height * 1.75; + mainNode.addChild(bottomDisplayText); + + this._topDisplayLabel = topDisplayText; + this._bottomDisplayLabel = bottomDisplayText; + this._mainNode = mainNode; + this._widget = widget; + return true; + } + return false; + }, + setSceneTitle: function (title) { + this._sceneTitle.setString(title); + }, + toExtensionsMainLayer: function (sender, type) { + if (type == ccui.Widget.TOUCH_ENDED) { + UISceneManager.purge(); + /* + var scene = new cc.Scene(); + var layer = new TestController(); + scene.addChild(layer); + var transition = new cc.TransitionProgressRadialCCW(0.5,scene); + director.runScene(transition); + */ + GUITestScene.prototype.runThisTest(); + } + }, + + previousCallback: function (sender, type) { + if (type == ccui.Widget.TOUCH_ENDED) { + cc.director.runScene(UISceneManager.getInstance().previousUIScene()); + } + }, + + restartCallback: function (sender, type) { + if (type == ccui.Widget.TOUCH_ENDED) { + cc.director.runScene(UISceneManager.getInstance().currentUIScene()); + } + }, + + nextCallback: function (sender, type) { + if (type == ccui.Widget.TOUCH_ENDED) { + cc.director.runScene(UISceneManager.getInstance().nextUIScene()); + } + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/GUITest/UISceneManager.js b/tests/js-tests/src/GUITest/UISceneManager.js new file mode 100644 index 0000000000..61105998dc --- /dev/null +++ b/tests/js-tests/src/GUITest/UISceneManager.js @@ -0,0 +1,654 @@ +/**************************************************************************** + 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 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. + ****************************************************************************/ + +(function(global){ + + var currentTestingArray = null; + + var testingItems = { + "UIButton": [ + { + title: "UIButtonTest", + func: function () { + return new UIButtonTest(); + } + }, + { + title: "UIButtonTest_Scale9", + func: function () { + return new UIButtonTest_Scale9(); + } + }, + { + title: "UIButtonTest_PressedAction", + func: function () { + return new UIButtonTest_PressedAction(); + } + }, + { + title: "UIButtonTest_Title", + func: function () { + return new UIButtonTest_Title(); + } + }, + { + title: "UIButtonTestRemoveSelf", + func: function () { + return new UIButtonTestRemoveSelf(); + } + }, + { + title: "UIButtonTestSwitchScale9", + func: function () { + return new UIButtonTestSwitchScale9(); + } + }, + { + title: "UIButtonTestZoomScale", + func: function () { + return new UIButtonTestZoomScale(); + } + }, + { + title: "UIButtonTextOnly", + func: function () { + return new UIButtonTextOnly(); + } + }, + { + title: "UIButtonIgnoreContentSizeTest", + func: function () { + return new UIButtonIgnoreContentSizeTest(); + } + }, + { + title: "UIButtonTitleEffectTest", + func: function () { + return new UIButtonTitleEffectTest(); + } + }, + { + title: "UIButtonFlipTest", + func: function () { + return new UIButtonFlipTest(); + } + }, + { + title: "UIButtonNormalDefaultTest", + func: function () { + return new UIButtonNormalDefaultTest(); + } + }, + { + title: "UIButtonDisableDefaultTest", + func: function () { + return new UIButtonDisableDefaultTest(); + } + } + ], + "UIFocus": [ + { + title: "UIFocusTestHorizontal", + func: function () { + return new UIFocusTestHorizontal(); + } + }, + { + title: "UIFocusTestVertical", + func: function () { + return new UIFocusTestVertical(); + } + }, + { + title: "UIFocusTestNestedLayout1", + func: function () { + return new UIFocusTestNestedLayout1(); + } + }, + { + title: "UIFocusTestNestedLayout2", + func: function () { + return new UIFocusTestNestedLayout2(); + } + }, + { + title: "UIFocusTestNestedLayout3", + func: function () { + return new UIFocusTestNestedLayout3(); + } + } + /*{ //need test + title: "UIFocusTestListView", + func: function () { + return new UIFocusTestListView(); + } + }*/ + ], + "UICheckBox": [ + { + title: "UICheckBoxTest", + func: function () { + return new UICheckBoxTest(); + } + }, + { + title: "UICheckBoxDefaultBehaviorTest", + func: function(){ + return new UICheckBoxDefaultBehaviorTest(); + } + } + ], + "UISlider": [ + { + title: "UISliderTest", + func: function () { + return new UISliderTest(); + } + }, + { + title: "UISliderTest_Scale9", + func: function () { + return new UISliderTest_Scale9(); + } + }, + { + title: "UISliderNormalDefaultTest", + func: function () { + return new UISliderNormalDefaultTest(); + } + }, + { + title: "UISliderDisabledDefaultTest", + func: function () { + return new UISliderDisabledDefaultTest(); + } + } + ], + "UIImageView": [ + { + title: "UIImageViewTest", + func: function () { + return new UIImageViewTest(); + } + }, + { + title: "UIImageViewTest_Scale9", + func: function () { + return new UIImageViewTest_Scale9(); + } + }, + { + title: "UIImageViewTest_ContentSize", + func: function () { + return new UIImageViewTest_ContentSize(); + } + }, + { + title: "UIImageViewFlipTest", + func: function () { + return new UIImageViewFlipTest(); + } + } + ], + "UILoadingBar": [ + { + title: "UILoadingBarTest_Left", + func: function () { + return new UILoadingBarTest_Left(); + } + }, + { + title: "UILoadingBarTest_Right", + func: function () { + return new UILoadingBarTest_Right(); + } + }, + { + title: "UILoadingBarTest_Fix", + func: function(){ + return new UILoadingBarTest_Fix(); + } + }, + { + title: "UILoadingBarTest_Left_Scale9", + func: function () { + return new UILoadingBarTest_Left_Scale9(); + } + }, + { + title: "UILoadingBarTest_Right_Scale9", + func: function () { + return new UILoadingBarTest_Right_Scale9(); + } + }, + { + title: "UILoadingBarTest_Fix_Scale9", + func: function(){ + return new UILoadingBarTest_Fix_Scale9(); + } + } + ], + "UIText": [ + { + title: "UITextTest", + func: function(){ + return new UITextTest(); + } + }, + { + title: "UITextTest_LineWrap", + func: function(){ + return new UITextTest_LineWrap(); + } + }, + { + title: "UILabelTest_Effect", + func: function(){ + return new UILabelTest_Effect(); + } + }, + { + title: "UITextTest_TTF", + func: function(){ + return new UITextTest_TTF(); + } + }, + { + title: "UITextTest_IgnoreConentSize", + func: function(){ + return new UITextTest_IgnoreConentSize(); + } + }, + { + title: "UILabelAtlasTest", + func: function () { + return new UILabelAtlasTest(); + } + }, + { + title: "UILabelTest", + func: function () { + return new UILabelTest(); + } + }, + { + title: "UILabelTest_LineWrap", + func: function () { + return new UILabelTest_LineWrap(); + } + }, + { + title: "UILabelBMFontTest", + func: function () { + return new UILabelBMFontTest(); + } + }, + { + title: "UILabelTest_TTF", + func: function () { + return new UILabelTest_TTF(); + } + } + ], + "UITextFiled": [ + { + title: "UITextFieldTest", + func: function () { + return new UITextFieldTest(); + } + }, + { + title: "UITextFieldTest_MaxLength", + func: function () { + return new UITextFieldTest_MaxLength(); + } + }, + { + title: "UITextFieldTest_Password", + func: function () { + return new UITextFieldTest_Password(); + } + }, + { + title: "UITextFieldTest_LineWrap", + func: function () { + return new UITextFieldTest_LineWrap(); + } + }, + { + title: "UITextFieldTest_TrueTypeFont", + func: function () { + return new UITextFieldTest_TrueTypeFont(); + } + }, + { + title: "UITextFieldTest_PlaceHolderColor", + func: function () { + return new UITextFieldTest_PlaceHolderColor(); + } + } + ], + "UILayout": [ + { + title: "UILayoutTest", + func: function () { + return new UILayoutTest(); + } + }, + { + title: "UILayoutTest_Color", + func: function () { + return new UILayoutTest_Color(); + } + }, + { + title: "UILayoutTest_Gradient", func: function () { + return new UILayoutTest_Gradient(); + } + }, + { + title: "UILayoutTest_BackGroundImage", + func: function () { + return new UILayoutTest_BackGroundImage(); + } + }, + { + title: "UILayoutTest_BackGroundImage_Scale9", + func: function () { + return new UILayoutTest_BackGroundImage_Scale9(); + } + }, + { + title: "UILayoutTest_Layout_Linear_Vertical", + func: function () { + return new UILayoutTest_Layout_Linear_Vertical(); + } + }, + { + title: "UILayoutTest_Layout_Linear_Horizontal", + func: function () { + return new UILayoutTest_Layout_Linear_Horizontal(); + } + }, + { + title: "UILayoutTest_Layout_Relative", + func: function () { + return new UILayoutTest_Layout_Relative(); + } + }, + { + title: "UILayoutTest_Layout_Relative_Align_Parent", + func: function () { + return new UILayoutTest_Layout_Relative_Align_Parent(); + } + }, + { + title: "UILayoutTest_Layout_Relative_Location", + func: function () { + return new UILayoutTest_Layout_Relative_Location(); + } + }, + { + title: "UILayoutComponent_Berth_Test", + func: function () { + return new UILayoutComponent_Berth_Test(); + } + }, + { + title: "UILayoutComponent_Berth_Stretch_Test", + func: function () { + return new UILayoutComponent_Berth_Stretch_Test(); + } + } + ], + "UIScrollView": [ + { + title: "UIScrollViewTest_Vertical", + func: function () { + return new UIScrollViewTest_Vertical(); + } + }, + { + title: "UIScrollViewTest_Horizontal", + func: function () { + return new UIScrollViewTest_Horizontal(); + } + }, + { + title: "UIScrollViewTest_Both", + func: function () { + return new UIScrollViewTest_Both(); + } + }, + { + title: "UIScrollViewTest_ScrollToPercentBothDirection", + func: function () { + return new UIScrollViewTest_ScrollToPercentBothDirection(); + } + }, + { + title: "UIScrollViewTest_ScrollToPercentBothDirection_Bounce", + func: function () { + return new UIScrollViewTest_ScrollToPercentBothDirection_Bounce(); + } + }, + { + title: "UIScrollViewNestTest", + func: function () { + return new UIScrollViewNestTest(); + } + }, + { + title: "UIScrollViewRotated", + func: function () { + return new UIScrollViewRotated(); + } + } + ], + "UIPageView": [ + { + title: "UIPageViewTest", + func: function () { + return new UIPageViewTest(); + } + }, + { + title: "UIPageViewButtonTest", + func: function () { + return new UIPageViewButtonTest(); + } + }, + { + title: "UIPageViewCustomScrollThreshold", + func: function () { + return new UIPageViewCustomScrollThreshold(); + } + }, + { + title: "UIPageViewTouchPropagationTest", + func: function () { + return new UIPageViewTouchPropagationTest(); + } + }, + { + title: "UIPageViewDynamicAddAndRemoveTest", + func: function () { + return new UIPageViewDynamicAddAndRemoveTest(); + } + } + ], + "UIListView": [ + { + title: "UIListViewTest_Vertical", + func: function () { + return new UIListViewTest_Vertical(); + } + }, + { + title: "UIListViewTest_Horizontal", + func: function () { + return new UIListViewTest_Horizontal(); + } + } + ], + "UIWidget": [ + { + title: "UIWidgetAddNodeTest", + func: function () { + return new UIWidgetAddNodeTest(); + } + } + ], + "UIRichText": [ + { + title: "UIRichTextTest", + func: function () { + return new UIRichTextTest(); + } + } + ] + }; + + global.GUITestScene = cc.Class.extend({ + + runThisTest: function(){ + cc.director.runScene(new listScene); + } + + }); + + var listScene = TestScene.extend({ + + onEnter: function(){ + TestScene.prototype.onEnter.call(this); + + var menu = new cc.Menu(); + menu.x = 0; + menu.y = 0; + var index = 0; + for(var p in testingItems){ + (function(name, list){ + var label = new cc.LabelTTF(name, "Arial", 24); + var menuItem = new cc.MenuItemLabel(label, function(){ + currentTestingArray = list; + var manager = global.UISceneManager.getInstance(); + var scene = manager.currentUIScene(); + cc.director.runScene(scene); + }, this); + menuItem.x = winSize.width / 2; + menuItem.y = (winSize.height - (index++ + 1) * 25); + index++; + menu.addChild(menuItem); + })(p, testingItems[p]); + } + + this._menu = menu; + this.addChild(menu); + + if ('touches' in cc.sys.capabilities) + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesMoved: function (touches, event) { + var target = event.getCurrentTarget(); + var delta = touches[0].getDelta(); + target.moveMenu(delta); + return true; + } + }, this); + else if ('mouse' in cc.sys.capabilities) { + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseMove: function (event) { + if (event.getButton() == cc.EventMouse.BUTTON_LEFT) + event.getCurrentTarget().moveMenu(event.getDelta()); + }, + onMouseScroll: function (event) { + var delta = cc.sys.isNative ? event.getScrollY() * 6 : -event.getScrollY(); + event.getCurrentTarget().moveMenu({y: delta}); + return true; + } + }, this); + } + + this._length = 0; + for(var p in testingItems){ + this._length++; + } + }, + + moveMenu: function(delta){ + var newY = this._menu.y + delta.y; + if (newY < 0 ) + newY = 0; + + if( newY > ((this._length + 1) * 49 - winSize.height)) + newY = ((this._length + 1) * 49 - winSize.height); + + this._menu.y = newY; + } + }); + + global.UISceneManager = { + + _currentUISceneId: 0, + + ctor: function () { + this._currentUISceneId = 0; + }, + + nextUIScene: function () { + this._currentUISceneId++; + if (this._currentUISceneId > currentTestingArray.length - 1) { + this._currentUISceneId = 0; + } + return this.currentUIScene(); + }, + + previousUIScene: function () { + this._currentUISceneId--; + if (this._currentUISceneId < 0) { + this._currentUISceneId = currentTestingArray.length - 1; + } + return this.currentUIScene(); + }, + + currentUIScene: function () { + var test = currentTestingArray[this._currentUISceneId]; + var sence = test.func(); + sence.init(); + sence.setSceneTitle(test.title); + return sence; + } + }; + + global.UISceneManager.getInstance = function () { + return this; + }; + + global.UISceneManager.purge = function (){ + this._currentUISceneId = 0; + }; + +})(window); \ No newline at end of file diff --git a/tests/js-tests/src/GUITest/UIScrollViewTest/UIScrollViewTest.js b/tests/js-tests/src/GUITest/UIScrollViewTest/UIScrollViewTest.js new file mode 100644 index 0000000000..0db6aa93fe --- /dev/null +++ b/tests/js-tests/src/GUITest/UIScrollViewTest/UIScrollViewTest.js @@ -0,0 +1,415 @@ +/**************************************************************************** + 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 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 UIScrollViewTest_Vertical = UIScene.extend({ + init: function () { + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + //init text + this._topDisplayLabel.setString("Move by vertical direction"); + this._topDisplayLabel.x = widgetSize.width / 2.0; + this._topDisplayLabel.y = widgetSize.height / 2.0 + this._topDisplayLabel.height * 1.5; + this._bottomDisplayLabel.setString("ScrollView"); + this._bottomDisplayLabel.x = widgetSize.width / 2; + this._bottomDisplayLabel.y = widgetSize.height / 2 - this._bottomDisplayLabel.height * 3; + + var background = this._widget.getChildByName("background_Panel"); + + // Create the scrollview + var scrollView = new ccui.ScrollView(); + scrollView.setDirection(ccui.ScrollView.DIR_VERTICAL); + scrollView.setTouchEnabled(true); + scrollView.setContentSize(cc.size(280, 150)); + + scrollView.x = (widgetSize.width - background.width) / 2 + (background.width - scrollView.width) / 2; + scrollView.y = (widgetSize.height - background.height) / 2 + (background.height - scrollView.height) / 2; + this._mainNode.addChild(scrollView); + + var imageView = new ccui.ImageView(); + imageView.loadTexture("res/cocosui/ccicon.png"); + + var innerWidth = scrollView.width; + var innerHeight = scrollView.height + imageView.height; + + scrollView.setInnerContainerSize(cc.size(innerWidth, innerHeight)); + + var button = new ccui.Button(); + button.setTouchEnabled(true); + button.loadTextures("res/cocosui/animationbuttonnormal.png", "res/cocosui/animationbuttonpressed.png", ""); + button.x = innerWidth / 2; + button.y = scrollView.getInnerContainerSize().height - button.height / 2; + scrollView.addChild(button); + + var textButton = new ccui.Button(); + textButton.setTouchEnabled(true); + textButton.loadTextures("res/cocosui/backtotopnormal.png", "res/cocosui/backtotoppressed.png", ""); + textButton.setTitleText("Text Button"); + textButton.x = innerWidth / 2; + textButton.y = button.getBottomBoundary() - button.height; + scrollView.addChild(textButton); + + var button_scale9 = new ccui.Button(); + button_scale9.setTouchEnabled(true); + button_scale9.setScale9Enabled(true); + button_scale9.loadTextures("res/cocosui/button.png", "res/cocosui/buttonHighlighted.png", ""); + button_scale9.width = 100; + button_scale9.height = 32; + button_scale9.x = innerWidth / 2; + button_scale9.y = textButton.getBottomBoundary() - textButton.height; + scrollView.addChild(button_scale9); + + imageView.x = innerWidth / 2; + imageView.y = imageView.height / 2; + scrollView.addChild(imageView); + + return true; + } + return false; + } +}); + +var UIScrollViewTest_Horizontal = UIScene.extend({ + init: function () { + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + //init text + this._topDisplayLabel.setString("Move by horizontal direction"); + this._topDisplayLabel.x = widgetSize.width / 2.0; + this._topDisplayLabel.y = widgetSize.height / 2.0 + this._topDisplayLabel.height * 1.5; + this._bottomDisplayLabel.setString("ScrollView"); + this._bottomDisplayLabel.x = widgetSize.width / 2; + this._bottomDisplayLabel.y = widgetSize.height / 2 - this._bottomDisplayLabel.height * 3; + + var background = this._widget.getChildByName("background_Panel"); + + // Create the scrollview + var scrollView = new ccui.ScrollView(); + scrollView.setDirection(ccui.ScrollView.DIR_HORIZONTAL); + scrollView.setTouchEnabled(true); + scrollView.setContentSize(cc.size(280, 150)); + var scrollViewRect = scrollView.getContentSize(); + scrollView.setInnerContainerSize(cc.size(scrollViewRect.width,scrollViewRect.height)); + + scrollView.x = (widgetSize.width - background.width) / 2 + (background.width - scrollViewRect.width) / 2; + scrollView.y = (widgetSize.height - background.height) / 2 + (background.height - scrollViewRect.height) / 2; + this._mainNode.addChild(scrollView); + + var imageView = new ccui.ImageView(); + imageView.loadTexture("res/cocosui/ccicon.png"); + + var innerWidth = scrollViewRect.width + imageView.getContentSize().width; + var innerHeight = scrollViewRect.height; + + scrollView.setInnerContainerSize(cc.size(innerWidth, innerHeight)); + + var button = new ccui.Button(); + button.setTouchEnabled(true); + button.loadTextures("res/cocosui/animationbuttonnormal.png", "res/cocosui/animationbuttonpressed.png", ""); + button.x = button.width / 2; + button.y = scrollView.getInnerContainerSize().height - button.height / 2; + scrollView.addChild(button); + + var textButton = new ccui.Button(); + textButton.setTouchEnabled(true); + textButton.loadTextures("res/cocosui/backtotopnormal.png", "res/cocosui/backtotoppressed.png", ""); + textButton.setTitleText("Text Button"); + textButton.x = button.getRightBoundary() + button.width / 2; + textButton.y = button.getBottomBoundary() - button.height; + scrollView.addChild(textButton); + + var button_scale9 = new ccui.Button(); + button_scale9.setTouchEnabled(true); + button_scale9.setScale9Enabled(true); + button_scale9.loadTextures("res/cocosui/button.png", "res/cocosui/buttonHighlighted.png", ""); + button_scale9.width = 100; + button_scale9.height = 32; + button_scale9.x = textButton.getRightBoundary() + textButton.width / 2; + button_scale9.y = textButton.getBottomBoundary() - textButton.height; + scrollView.addChild(button_scale9); + + imageView.x = innerWidth - imageView.width / 2; + imageView.y = button_scale9.getBottomBoundary() - button_scale9.height / 2; + scrollView.addChild(imageView); + + return true; + } + return false; + } +}); + +var UIScrollViewTest_Both = UIScene.extend({ + init: function () { + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + //init text + this._topDisplayLabel.setString("Move by any direction"); + this._topDisplayLabel.x = widgetSize.width / 2.0; + this._topDisplayLabel.y = widgetSize.height / 2.0 + this._topDisplayLabel.height * 1.5; + this._bottomDisplayLabel.setString("ScrollView both"); + this._bottomDisplayLabel.x = widgetSize.width / 2; + this._bottomDisplayLabel.y = widgetSize.height / 2 - this._bottomDisplayLabel.height * 3; + + var background = this._widget.getChildByName("background_Panel"); + + // Create the scrollview + var scrollView = new ccui.ScrollView(); + scrollView.setDirection(ccui.ScrollView.DIR_BOTH); + scrollView.setTouchEnabled(true); + scrollView.setBounceEnabled(true); + scrollView.setBackGroundImageScale9Enabled(true); + scrollView.setBackGroundImage("res/cocosui/green_edit.png"); + scrollView.setContentSize(cc.size(210, 122)); + var scrollViewSize = scrollView.getContentSize(); + + scrollView.x = (widgetSize.width - background.width) / 2 + (background.width - scrollViewSize.width) / 2; + scrollView.y = (widgetSize.height - background.height) / 2 + (background.height - scrollViewSize.height) / 2; + this._mainNode.addChild(scrollView); + + var imageView = new ccui.ImageView(); + imageView.loadTexture("res/cocosui/b11.png"); + scrollView.addChild(imageView); + + scrollView.setInnerContainerSize(cc.size(imageView.width, imageView.height)); + imageView.x = imageView.width/2; + imageView.y = imageView.height/2; + + return true; + } + return false; + } +}); + +var UIScrollViewTest_ScrollToPercentBothDirection = UIScene.extend({ + init: function () { + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + //init text + this._topDisplayLabel.setString(""); + this._bottomDisplayLabel.setString("ScrollView scroll to percent both directrion"); + this._bottomDisplayLabel.x = widgetSize.width / 2; + this._bottomDisplayLabel.y = widgetSize.height / 2 - this._bottomDisplayLabel.height * 3; + + var background = this._widget.getChildByName("background_Panel"); + + // Create the scrollview + var scrollView = new ccui.ScrollView(); + scrollView.setTouchEnabled(true); + scrollView.setBackGroundColor(cc.color.GREEN); + scrollView.setBackGroundColorType(ccui.Layout.BG_COLOR_SOLID); + scrollView.setDirection(ccui.ScrollView.DIR_BOTH); + scrollView.setInnerContainerSize(cc.size(480, 320)); + scrollView.setContentSize(cc.size(100, 100)); + var scrollViewSize = scrollView.getContentSize(); + + scrollView.x = (widgetSize.width - background.width) / 2 + (background.width - scrollViewSize.width) / 2; + scrollView.y = (widgetSize.height - background.height) / 2 + (background.height - scrollViewSize.height) / 2; + scrollView.scrollToPercentBothDirection(cc.p(50, 50), 1, true); + + this._mainNode.addChild(scrollView); + + var imageView = new ccui.ImageView(); + imageView.loadTexture("res/cocosui/Hello.png"); + imageView.x = 240; + imageView.y = 160; + scrollView.addChild(imageView); + + return true; + } + return false; + } +}); + +var UIScrollViewTest_ScrollToPercentBothDirection_Bounce = UIScene.extend({ + init: function () { + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + //init text + this._topDisplayLabel.setString(""); + this._bottomDisplayLabel.setString("ScrollView scroll to percent both directrion bounce"); + this._bottomDisplayLabel.x = widgetSize.width / 2; + this._bottomDisplayLabel.y = widgetSize.height / 2 - this._bottomDisplayLabel.height * 3; + + var background = this._widget.getChildByName("background_Panel"); + + // Create the scrollview + var scrollView = new ccui.ScrollView(); + scrollView.setTouchEnabled(true); + scrollView.setBounceEnabled(true); + scrollView.setBackGroundColor(cc.color.GREEN); + scrollView.setBackGroundColorType(ccui.Layout.BG_COLOR_SOLID); + scrollView.setDirection(ccui.ScrollView.DIR_BOTH); + scrollView.setInnerContainerSize(cc.size(480, 320)); + scrollView.setContentSize(cc.size(100, 100)); + var scrollViewSize = scrollView.getContentSize(); + + scrollView.x = (widgetSize.width - background.width) / 2 + (background.width - scrollViewSize.width) / 2; + scrollView.y = (widgetSize.height - background.height) / 2 + (background.height - scrollViewSize.height) / 2; + scrollView.scrollToPercentBothDirection(cc.p(50, 50), 1, true); + + this._mainNode.addChild(scrollView); + + var imageView = new ccui.ImageView(); + imageView.loadTexture("res/cocosui/Hello.png"); + imageView.x = 240; + imageView.y = 160; + scrollView.addChild(imageView); + + return true; + } + return false; + } +}); + +//2015-01-14 +var UIScrollViewNestTest = UIScene.extend({ + init: function(){ + if(this._super()){ + var widgetSize = this._widget.getContentSize(); + + // Add a label in which the scrollview alert will be displayed + this._topDisplayLabel.setString("Move by vertical direction"); + + // Add the alert + this._bottomDisplayLabel.setString("ScrollView vertical"); + this._bottomDisplayLabel.setPosition(widgetSize.width / 2.0, widgetSize.height / 2.0 - this._bottomDisplayLabel.height * 3.075); + + var root = this._mainNode.getChildByTag(81); + + var background = root.getChildByName("background_Panel"); + + // Create the scrollview by vertical + var scrollView = new ccui.ScrollView(); + scrollView.setContentSize(cc.size(280.0, 150.0)); + scrollView.setDirection(ccui.ScrollView.DIR_BOTH); + var backgroundSize = background.getContentSize(); + scrollView.setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2.0 + + (backgroundSize.width - scrollView.getContentSize().width) / 2.0, + (widgetSize.height - backgroundSize.height) / 2.0 + + (backgroundSize.height - scrollView.getContentSize().height) / 2.0)); + this._mainNode.addChild(scrollView); + + var imageView = new ccui.ImageView("res/cocosui/ccicon.png"); + + var innerWidth = scrollView.getContentSize().width; + var innerHeight = scrollView.getContentSize().height + imageView.getContentSize().height; + + scrollView.setInnerContainerSize(cc.size(innerWidth, innerHeight)); + + var button = new ccui.Button("res/cocosui/animationbuttonnormal.png", "res/cocosui/animationbuttonpressed.png"); + button.setPosition(cc.p(innerWidth / 2.0, scrollView.getInnerContainerSize().height - button.getContentSize().height / 2.0)); + scrollView.addChild(button); + + var titleButton = new ccui.Button("res/cocosui/backtotopnormal.png", "res/cocosui/backtotoppressed.png"); + titleButton.setTitleText("Title Button"); + titleButton.setPosition(cc.p(innerWidth / 2.0, button.getBottomBoundary() - button.getContentSize().height)); + scrollView.addChild(titleButton); + + var button_scale9 = new ccui.Button("res/cocosui/button.png", "res/cocosui/buttonHighlighted.png"); + button_scale9.setScale9Enabled(true); + button_scale9.setContentSize(cc.size(100.0, button_scale9.getVirtualRendererSize().height)); + button_scale9.setPosition(cc.p(innerWidth / 2.0, titleButton.getBottomBoundary() - titleButton.getContentSize().height)); + scrollView.addChild(button_scale9); + + imageView.setPosition(cc.p(innerWidth / 2.0, imageView.getContentSize().height / 2.0)); + scrollView.addChild(imageView); + + // Create the scrollview by horizontal + var sc = new ccui.ScrollView(); + sc.setBackGroundColor(cc.color.GREEN); + sc.setBackGroundColorType(ccui.Layout.BG_COLOR_SOLID); + sc.setBounceEnabled(true); + sc.setDirection(ccui.ScrollView.DIR_BOTH); + sc.setInnerContainerSize(cc.size(480, 320)); + sc.setContentSize(cc.size(100,100)); + sc.setPropagateTouchEvents(false); + sc.setPosition(cc.p(180,100)); + sc.scrollToPercentBothDirection(cc.p(50, 50), 1, true); + var iv = new ccui.ImageView("res/cocosui/Hello.png"); + iv.setPosition(cc.p(240, 160)); + sc.addChild(iv); + scrollView.addChild(sc); + + return true; + } + } + +}); + +//2015-01-14 +var UIScrollViewRotated = UIScene.extend({ + init: function(){ + if(this._super()){ + var widgetSize = this._widget.getContentSize(); + + // Add a label in which the scrollview alert will be displayed + this._topDisplayLabel.setString("Move by vertical direction"); + + // Add the alert + this._bottomDisplayLabel.setString("ScrollView vertical"); + this._bottomDisplayLabel.setPosition(widgetSize.width / 2.0, widgetSize.height / 2.0 - this._bottomDisplayLabel.height * 3.075); + + var root = this._mainNode.getChildByTag(81); + var background = root.getChildByName("background_Panel"); + + // Create the scrollview by vertical + var scrollView = new ccui.ScrollView(); + scrollView.setContentSize(cc.size(280.0, 150.0)); + scrollView.setDirection(ccui.ScrollView.DIR_BOTH); + var backgroundSize = background.getContentSize(); + scrollView.setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2.0 + + (backgroundSize.width - scrollView.getContentSize().width) / 2.0, + (widgetSize.height - backgroundSize.height) / 2.0 + + (backgroundSize.height - scrollView.getContentSize().height) / 2.0 + 100) ); + scrollView.setRotation(45); + this._mainNode.addChild(scrollView); + + var imageView = new ccui.ImageView("res/cocosui/ccicon.png"); + + var innerWidth = scrollView.getContentSize().width; + var innerHeight = scrollView.getContentSize().height + imageView.getContentSize().height; + scrollView.setInnerContainerSize(cc.size(innerWidth, innerHeight)); + + var button = new ccui.Button("res/cocosui/animationbuttonnormal.png", "res/cocosui/animationbuttonpressed.png"); + button.setPosition(cc.p(innerWidth / 2.0, scrollView.getInnerContainerSize().height - button.getContentSize().height / 2.0)); + scrollView.addChild(button); + + var titleButton = new ccui.Button("res/cocosui/backtotopnormal.png", "res/cocosui/backtotoppressed.png"); + titleButton.setTitleText("Title Button"); + titleButton.setPosition(cc.p(innerWidth / 2.0, button.getBottomBoundary() - button.getContentSize().height)); + scrollView.addChild(titleButton); + + var button_scale9 = new ccui.Button("res/cocosui/button.png", "res/cocosui/buttonHighlighted.png"); + button_scale9.setScale9Enabled(true); + button_scale9.setContentSize(cc.size(100.0, button_scale9.getVirtualRendererSize().height)); + button_scale9.setPosition(cc.p(innerWidth / 2.0, titleButton.getBottomBoundary() - titleButton.getContentSize().height)); + scrollView.addChild(button_scale9); + + imageView.setPosition(cc.p(innerWidth / 2.0, imageView.getContentSize().height / 2.0)); + scrollView.addChild(imageView); + + return true; + } + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/GUITest/UISliderTest/UISliderTest.js b/tests/js-tests/src/GUITest/UISliderTest/UISliderTest.js new file mode 100644 index 0000000000..551c4c9911 --- /dev/null +++ b/tests/js-tests/src/GUITest/UISliderTest/UISliderTest.js @@ -0,0 +1,175 @@ +/**************************************************************************** + 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 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 UISliderTest = UIScene.extend({ + init: function () { + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + //init text + this._topDisplayLabel.setString("Move the slider thumb"); + this._bottomDisplayLabel.setString("Slider"); + + // Create the slider + var slider = new ccui.Slider(); + slider.setTouchEnabled(true); + slider.loadBarTexture("res/cocosui/sliderTrack.png"); + slider.loadSlidBallTextures("res/cocosui/sliderThumb.png", "res/cocosui/sliderThumb.png", ""); + slider.loadProgressBarTexture("res/cocosui/sliderProgress.png"); + slider.x = widgetSize.width / 2.0; + slider.y = widgetSize.height / 2.0; + slider.addEventListener(this.sliderEvent, this); + this._mainNode.addChild(slider); + + return true; + } + return false; + }, + + sliderEvent: function (sender, type) { + switch (type) { + case ccui.Slider.EVENT_PERCENT_CHANGED: + var slider = sender; + var percent = slider.getPercent(); + this._topDisplayLabel.setString("Percent " + percent.toFixed(0)); + break; + default: + break; + } + } +}); + +var UISliderTest_Scale9 = UIScene.extend({ + init: function () { + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + //init text + this._topDisplayLabel.setString("Move the slider thumb"); + this._bottomDisplayLabel.setString("Slider scale9 render"); + + // Create the slider + var slider = new ccui.Slider(); + slider.setTouchEnabled(true); + slider.setScale9Enabled(true); + slider.loadBarTexture("res/cocosui/sliderTrack2.png"); + slider.loadSlidBallTextures("res/cocosui/sliderThumb.png", "res/cocosui/sliderThumb.png", ""); + slider.loadProgressBarTexture("res/cocosui/slider_bar_active_9patch.png"); + slider.setCapInsets(cc.rect(0, 0, 0, 0)); + slider.setContentSize(cc.size(250, 10)); + slider.x = widgetSize.width / 2.0; + slider.y = widgetSize.height / 2.0; + slider.addEventListener(this.sliderEvent, this); + this._mainNode.addChild(slider); + + return true; + } + return false; + }, + + sliderEvent: function (sender, type) { + switch (type) { + case ccui.Slider.EVENT_PERCENT_CHANGED: + var slider = sender; + var percent = slider.getPercent(); + this._topDisplayLabel.setString("Percent " + percent.toFixed(0)); + break; + default: + break; + } + } +}); + +//2015-01-14 +var UISliderNormalDefaultTest = UIScene.extend({ + init: function () { + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + + this._bottomDisplayLabel.setString(""); + + // Add the alert + var alert = new ccui.Text("when pressed, the slider ball should scale","Marker Felt",20); + alert.setColor(cc.color(159, 168, 176)); + alert.setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 - alert.height * 3.75)); + this._mainNode.addChild(alert); + + // Create the slider + var slider = new ccui.Slider(); + slider.loadBarTexture("res/cocosui/sliderTrack.png"); + slider.loadSlidBallTextures("res/cocosui/sliderThumb.png"); + slider.setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 + 50)); + this._mainNode.addChild(slider); + + var sliderScale9 = new ccui.Slider("res/cocosui/sliderTrack2.png", "res/cocosui/sliderThumb.png"); + sliderScale9.setScale9Enabled(true); + sliderScale9.setCapInsets(cc.rect(0, 0, 0, 0)); + sliderScale9.setZoomScale(1); + sliderScale9.setContentSize(cc.size(250, 19)); + sliderScale9.setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 - 20)); + this._mainNode.addChild(sliderScale9); + + + return true; + } + return false; + } +}); + +//2015-01-14 +var UISliderDisabledDefaultTest = UIScene.extend({ + init: function () { + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + + this._bottomDisplayLabel.setString(""); + + // Add the alert + var alert = new ccui.Text("slider ball should be gray.","Marker Felt",20); + alert.setColor(cc.color(159, 168, 176)); + alert.setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 - alert.height * 3.75)); + this._mainNode.addChild(alert); + + // Create the slider + var slider = new ccui.Slider(); + slider.loadBarTexture("res/cocosui/slidbar.png"); + slider.loadSlidBallTextureNormal("res/cocosui/sliderballnormal.png"); + slider.setEnabled(false); + slider.setBright(false); + slider.setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 + 50)); + this._mainNode.addChild(slider); + + var sliderScale9 = new ccui.Slider("res/cocosui/slidbar.png", "res/cocosui/sliderballnormal.png"); + sliderScale9.setScale9Enabled(true); + sliderScale9.setEnabled(false); + sliderScale9.setBright(false); + sliderScale9.setCapInsets(cc.rect(0, 0, 0, 0)); + sliderScale9.setContentSize(cc.size(250, 10)); + sliderScale9.setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 - 20)); + this._mainNode.addChild(sliderScale9); + + return true; + } + return false; + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/GUITest/UITextFieldTest/UITextFieldTest.js b/tests/js-tests/src/GUITest/UITextFieldTest/UITextFieldTest.js new file mode 100644 index 0000000000..bffd3c4adb --- /dev/null +++ b/tests/js-tests/src/GUITest/UITextFieldTest/UITextFieldTest.js @@ -0,0 +1,329 @@ +/**************************************************************************** + 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 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 UITextFieldTest = UIScene.extend({ + init: function () { + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + //init text + this._topDisplayLabel.setString("No Event"); + this._bottomDisplayLabel.setString("TextField"); + + // Create the textfield + var textField = new ccui.TextField("PlaceHolder", "Marker Felt", 30); + textField.x = widgetSize.width / 2.0; + textField.y = widgetSize.height / 2.0; + textField.addEventListener(this.textFieldEvent, this); + this._mainNode.addChild(textField); + + return true; + } + return false; + }, + + textFieldEvent: function (textField, type) { + switch (type) { + case ccui.TextField.EVENT_ATTACH_WITH_IME: + var widgetSize = this._widget.getContentSize(); + textField.runAction(cc.moveTo(0.225, + cc.p(widgetSize.width / 2, widgetSize.height / 2 + textField.height / 2))); + this._topDisplayLabel.setString("attach with IME"); + break; + case ccui.TextField.EVENT_DETACH_WITH_IME: + var widgetSize = this._widget.getContentSize(); + textField.runAction(cc.moveTo(0.175, cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0))); + this._topDisplayLabel.setString("detach with IME"); + break; + case ccui.TextField.EVENT_INSERT_TEXT: + this._topDisplayLabel.setString("insert words"); + break; + case ccui.TextField.EVENT_DELETE_BACKWARD: + this._topDisplayLabel.setString("delete word"); + break; + default: + break; + } + } +}); + +var UITextFieldTest_MaxLength = UIScene.extend({ + init: function () { + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + //init text + this._topDisplayLabel.setString("No Event"); + this._bottomDisplayLabel.setString("TextField max length"); + + // Create the textfield + var textField = new ccui.TextField(); + textField.setMaxLengthEnabled(true); + textField.setMaxLength(3); + textField.setTouchEnabled(true); + textField.fontName = "Marker Felt"; + textField.fontSize = 30; + textField.placeHolder = "input words here"; + textField.x = widgetSize.width / 2.0; + textField.y = widgetSize.height / 2.0; + textField.addEventListener(this.textFieldEvent, this); + this._mainNode.addChild(textField); + + return true; + } + return false; + }, + + textFieldEvent: function (sender, type) { + var textField = sender; + var widgetSize = this._widget.getContentSize(); + switch (type) { + case ccui.TextField.EVENT_ATTACH_WITH_IME: + textField.runAction(cc.moveTo(0.225, + cc.p(widgetSize.width / 2, widgetSize.height / 2 + textField.height / 2))); + this._topDisplayLabel.setString("attach with IME max length:" + textField.getMaxLength()); + break; + case ccui.TextField.EVENT_DETACH_WITH_IME: + textField.runAction(cc.moveTo(0.175, cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0))); + this._topDisplayLabel.setString("detach with IME max length:" + textField.getMaxLength()); + break; + case ccui.TextField.EVENT_INSERT_TEXT: + this._topDisplayLabel.setString("insert with IME max length:" + textField.getMaxLength()); + break; + case ccui.TextField.EVENT_DELETE_BACKWARD: + this._topDisplayLabel.setString("delete with IME max length:" + textField.getMaxLength()); + break; + default: + break; + } + } +}); + +var UITextFieldTest_Password = UIScene.extend({ + init: function () { + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + //init text + this._topDisplayLabel.setString("No Event"); + this._bottomDisplayLabel.setString("TextField max length"); + + // Create the textfield + var textField = new ccui.TextField(); + textField.setPasswordEnabled(true); + textField.setPasswordStyleText("*"); + textField.setTouchEnabled(true); + textField.fontName = "Marker Felt"; + textField.fontSize = 30; + textField.placeHolder = "input password here"; + textField.x = widgetSize.width / 2.0; + textField.y = widgetSize.height / 2.0; + textField.addEventListener(this.textFieldEvent, this); + this._mainNode.addChild(textField); + + return true; + } + return false; + }, + + textFieldEvent: function (textField, type) { + var widgetSize = this._widget.getContentSize(); + switch (type) { + case ccui.TextField.EVENT_ATTACH_WITH_IME: + textField.runAction(cc.moveTo(0.225, + cc.p(widgetSize.width / 2, widgetSize.height / 2 + textField.height / 2))); + this._topDisplayLabel.setString("attach with IME IME password"); + break; + case ccui.TextField.EVENT_DETACH_WITH_IME: + textField.runAction(cc.moveTo(0.175, cc.p(widgetSize.width / 2.0, widgetSize.height / 2.0))); + this._topDisplayLabel.setString("detach with IME password"); + break; + case ccui.TextField.EVENT_INSERT_TEXT: + this._topDisplayLabel.setString("insert with IME password"); + break; + case ccui.TextField.EVENT_DELETE_BACKWARD: + this._topDisplayLabel.setString("delete with IME password"); + break; + default: + break; + } + } +}); + +//2015-01-14 +var UITextFieldTest_LineWrap = UIScene.extend({ + + init: function(){ + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + + // Add a label in which the textfield events will be displayed + this._topDisplayLabel.setString("No Event"); + this._topDisplayLabel.setPosition(widgetSize.width / 2, widgetSize.height / 2 + this._topDisplayLabel.height * 1.5); + this._bottomDisplayLabel.setString(""); + + // Add the alert + var alert = new ccui.Text("TextField line wrap","Marker Felt",30); + alert.setColor(cc.color(159, 168, 176)); + alert.setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 - alert.height * 3.075)); + this._mainNode.addChild(alert); + + // Create the textfield + var textField = new ccui.TextField("input words here", "Marker Felt",30); + textField.ignoreContentAdaptWithSize(false); + //textField.getVirtualRenderer().setLineBreakWithoutSpace(true); + textField.setContentSize(240, 120); + textField.setString("input words here"); + textField.setTextHorizontalAlignment(cc.TEXT_ALIGNMENT_CENTER); + textField.setTextVerticalAlignment(cc.TEXT_ALIGNMENT_CENTER); + textField.setPosition(widgetSize.width / 2, widgetSize.height / 2); + textField.addEventListener(this.textFieldEvent, this); + this._mainNode.addChild(textField); + return true; + } + }, + + textFieldEvent: function(textField, type){ + var widgetSize = this._widget.getContentSize(); + switch (type){ + case ccui.TextField.EVENT_ATTACH_WITH_IME: + textField.runAction(cc.moveTo(0.225, cc.p(widgetSize.width / 2, widgetSize.height / 2 + 30))); + textField.setTextHorizontalAlignment(cc.TEXT_ALIGNMENT_LEFT); + textField.setTextVerticalAlignment(cc.VERTICAL_TEXT_ALIGNMENT_TOP); + this._topDisplayLabel.setString("attach with IME"); + break; + case ccui.TextField.EVENT_DETACH_WITH_IME: + textField.runAction(cc.moveTo(0.175, cc.p(widgetSize.width / 2, widgetSize.height / 2))); + textField.setTextHorizontalAlignment(cc.TEXT_ALIGNMENT_CENTER); + textField.setTextVerticalAlignment(cc.TEXT_ALIGNMENT_CENTER); + this._topDisplayLabel.setString("detach with IME"); + break; + case ccui.TextField.EVENT_INSERT_TEXT: + this._topDisplayLabel.setString("insert words"); + break; + case ccui.TextField.EVENT_DELETE_BACKWARD: + this._topDisplayLabel.setString("delete word"); + break; + default: + break; + } + } +}); + +//2015-01-14 +var UITextFieldTest_TrueTypeFont = UIScene.extend({ + init: function(){ + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + + // Add a label in which the textfield events will be displayed + this._topDisplayLabel.setString("True Type Font Test - No Event"); + this._topDisplayLabel.setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 + this._topDisplayLabel.height * 1.5)); + + // Add the alert + this._bottomDisplayLabel.setString("TextField"); + this._bottomDisplayLabel.setPosition(widgetSize.width / 2, widgetSize.height / 2 - this._bottomDisplayLabel.height * 3.075); + + // Create the textfield + var textField = new ccui.TextField("input words here","Marker Felt",30); + textField.setPosition(widgetSize.width / 2, widgetSize.height / 2); + textField.addEventListener(this.textFieldEvent, this); + this._mainNode.addChild(textField); + return true; + } + }, + + textFieldEvent: function(textField, type){ + var widgetSize = this._widget.getContentSize(); + switch (type){ + case ccui.TextField.EVENT_ATTACH_WITH_IME: + textField.runAction(cc.moveTo(0.225, cc.p(widgetSize.width / 2, widgetSize.height / 2 + textField.height / 2))); + this._topDisplayLabel.setString("attach with IME"); + break; + + case ccui.TextField.EVENT_DETACH_WITH_IME: + textField.runAction(cc.moveTo(0.175, cc.p(widgetSize.width / 2, widgetSize.height / 2))); + this._topDisplayLabel.setString("detach with IME"); + break; + + case ccui.TextField.EVENT_INSERT_TEXT: + this._topDisplayLabel.setString("insert words"); + break; + + case ccui.TextField.EVENT_DELETE_BACKWARD: + this._topDisplayLabel.setString("delete word"); + break; + + default: + break; + } + } +}); + +//2015-01-14 +var UITextFieldTest_PlaceHolderColor = UIScene.extend({ + init: function(){ + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + + // Add a label in which the textfield events will be displayed + this._topDisplayLabel.setString("Set place hold color"); + this._topDisplayLabel.setPosition(widgetSize.width / 2, widgetSize.height / 2 + this._topDisplayLabel.height * 1.5); + + // Add the alert + this._bottomDisplayLabel.setString("TextField"); + this._bottomDisplayLabel.setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 - this._bottomDisplayLabel.height * 3.075)); + + // Create the textfield + var textField = new ccui.TextField("input words here","Arial",30); + textField.setPlaceHolder("input text here"); + textField.setPlaceHolderColor(cc.color.GREEN); + textField.setTextColor(cc.color.RED); + textField.setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2)); + textField.addEventListener(this.textFieldEvent, this); + this._mainNode.addChild(textField); + return true; + } + }, + + textFieldEvent: function(textField, type){ + var widgetSize = this._widget.getContentSize(); + switch (type){ + case ccui.TextField.EVENT_ATTACH_WITH_IME: + textField.runAction(cc.moveTo(0.225, cc.p(widgetSize.width / 2, widgetSize.height / 2 + textField.height / 2))); + this._topDisplayLabel.setString("attach with IME"); + break; + case ccui.TextField.EVENT_DETACH_WITH_IME: + textField.runAction(cc.moveTo(0.175, cc.p(widgetSize.width / 2, widgetSize.height / 2))); + this._topDisplayLabel.setString("detach with IME"); + break; + case ccui.TextField.EVENT_INSERT_TEXT: + this._topDisplayLabel.setString("insert words"); + break; + case ccui.TextField.EVENT_DELETE_BACKWARD: + this._topDisplayLabel.setString("delete word"); + break; + default: + break; + } + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/GUITest/UITextTest/UITextTest.js b/tests/js-tests/src/GUITest/UITextTest/UITextTest.js new file mode 100644 index 0000000000..e6c5f84ec6 --- /dev/null +++ b/tests/js-tests/src/GUITest/UITextTest/UITextTest.js @@ -0,0 +1,182 @@ +/**************************************************************************** + 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 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. + ****************************************************************************/ + +//2015-01-14 +var UITextTest = UIScene.extend({ + init: function(){ + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + + this._bottomDisplayLabel.setString("Text"); + + // Create the text + var text = new ccui.Text("Text", "AmericanTypewriter", 30); + text.setPosition(cc.p(widgetSize.width / 2, widgetSize.height / 2 + text.height / 4)); + this._mainNode.addChild(text); + + return true; + } + } +}); + +//2015-01-14 +var UITextTest_LineWrap = UIScene.extend({ + init: function(){ + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + + this._bottomDisplayLabel.setString("Text line wrap"); + + // Create the line wrap + var text = new ccui.Text("TextArea Widget can line wrap","AmericanTypewriter",32); + text.ignoreContentAdaptWithSize(false); + text.setContentSize(cc.size(280, 150)); + text.setTextHorizontalAlignment(cc.TEXT_ALIGNMENT_CENTER); + text.setTouchScaleChangeEnabled(true); + text.setTouchEnabled(true); + text.addTouchEventListener(function(sender, type){ + if (type == ccui.Widget.TOUCH_ENDED){ + if (text.width == 280){ + text.setContentSize(cc.size(380,100)); + }else { + text.setContentSize(cc.size(280, 150)); + } + } + }); + text.setPosition(widgetSize.width / 2, widgetSize.height / 2 - text.height / 8); + this._mainNode.addChild(text); + + return true; + } + } +}); + +//2015-01-14 +var UILabelTest_Effect = UIScene.extend({ + init: function(){ + if (this._super()) { + var widgetSize = this._widget.getContentSize(); + + this._bottomDisplayLabel.setString(""); + + var alert = new ccui.Text(); + alert.setString("Label Effect"); + alert.setFontName("Marker Felt"); + alert.setFontSize(30); + alert.setColor(cc.color(159, 168, 176)); + alert.setPosition(widgetSize.width / 2, widgetSize.height / 2 - alert.height * 3.05); + this._mainNode.addChild(alert); + + // create the shadow only label + var shadow_label = new ccui.Text(); + + shadow_label.enableShadow(cc.color.GRAY, cc.p(10, -10)); + shadow_label.setString("Shadow"); + shadow_label.setPosition(widgetSize.width / 2, widgetSize.height / 2 + shadow_label.height); + + this._mainNode.addChild(shadow_label); + + // create the stroke only label + var glow_label = new ccui.Text(); + glow_label.setFontName("Marker Felt"); + glow_label.setString("Glow"); + glow_label.enableGlow(cc.color.RED); + glow_label.setPosition(widgetSize.width / 2, widgetSize.height / 2); + this._mainNode.addChild(glow_label); + + // create the label stroke and shadow + var outline_label = new ccui.Text(); + outline_label.enableOutline(cc.color.BLUE, 2); + outline_label.setString("Outline"); + outline_label.setPosition(widgetSize.width / 2, widgetSize.height / 2 - shadow_label.height); + + this._mainNode.addChild(outline_label); + + return true; + } + } +}); + +//2015-01-14 +var UITextTest_TTF = UIScene.extend({ + init: function(){ + if(this._super()){ + var widgetSize = this._widget.getContentSize(); + + this._bottomDisplayLabel.setString("Text set TTF font"); + + // Create the text, and set font with .ttf + var text = new ccui.Text("Text","A Damn Mess",30); + text.setPosition(widgetSize.width / 2, widgetSize.height / 2 + text.height / 4); + this._mainNode.addChild(text); + + return true; + } + } +}); + +//2015-01-14 +var UITextTest_IgnoreConentSize = UIScene.extend({ + + init: function(){ + if(this._super()){ + var widgetSize = this._widget.getContentSize(); + + this._bottomDisplayLabel.setString(""); + + var leftText = new ccui.Text("ignore conent", "Marker Felt",10); + leftText.setPosition(cc.p(widgetSize.width / 2 - 50, + widgetSize.height / 2)); + leftText.ignoreContentAdaptWithSize(false); + leftText.setTextAreaSize(cc.size(60,60)); + leftText.setString("Text line with break\nText line with break\nText line with break\nText line with break\n"); + leftText.setTouchScaleChangeEnabled(true); + leftText.setTouchEnabled(true); + this._mainNode.addChild(leftText); + + var rightText = new ccui.Text("ignore conent", "Marker Felt",10); + rightText.setPosition(cc.p(widgetSize.width / 2 + 50, + widgetSize.height / 2)); + rightText.setString("Text line with break\nText line with break\nText line with break\nText line with break\n"); + //note: setTextAreaSize must be used with ignoreContentAdaptWithSize(false) + rightText.setTextAreaSize(cc.size(100,30)); + rightText.ignoreContentAdaptWithSize(false); + this._mainNode.addChild(rightText); + + var halighButton = new ccui.Button(); + halighButton.setTitleText("Alignment Right"); + halighButton.addClickEventListener(function(){ + leftText.setTextHorizontalAlignment(cc.TEXT_ALIGNMENT_RIGHT); + rightText.setTextHorizontalAlignment(cc.TEXT_ALIGNMENT_RIGHT); + }); + halighButton.setPosition(cc.p(widgetSize.width/2 - 50, + widgetSize.height/2 - 50)); + this._mainNode.addChild(halighButton); + + return true; + } + } + +}); \ No newline at end of file diff --git a/tests/js-tests/src/IntervalTest/IntervalTest.js b/tests/js-tests/src/IntervalTest/IntervalTest.js new file mode 100644 index 0000000000..99a3813c4a --- /dev/null +++ b/tests/js-tests/src/IntervalTest/IntervalTest.js @@ -0,0 +1,156 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 IntervalLayer = cc.LayerGradient.extend({ + + label0:null, + label1:null, + label2:null, + label3:null, + label4:null, + + time0:null, + time1:null, + time2:null, + time3:null, + time4:null, + + ctor:function () { + this._super(cc.color(0,0,0,255), cc.color(98,99,117,255)); + + this.time0 = this.time1 = this.time2 = this.time3 = this.time4 = 0.0; + + var s = director.getWinSize(); + // sun + var sun = new cc.ParticleSun(); + sun.texture = cc.textureCache.addImage(s_fire); + sun.x = s.width - 32; + sun.y = s.height - 32; + + sun.setTotalParticles(130); + sun.setLife(0.6); + this.addChild(sun); + + // timers + this.label0 = new cc.LabelTTF("0", "Arial", 24); + this.label1 = new cc.LabelTTF("0", "Arial", 24); + this.label2 = new cc.LabelTTF("0", "Arial", 24); + this.label3 = new cc.LabelTTF("0", "Arial", 24); + this.label4 = new cc.LabelTTF("0", "Arial", 24); + + this.scheduleUpdate(); + this.schedule(this.step1); + this.schedule(this.step2, 0); + this.schedule(this.step3, 1.0); + this.schedule(this.step4, 2.0); + + this.label0.x = s.width * 1 / 6; + this.label0.y = s.height / 2; + this.label1.x = s.width * 2 / 6; + this.label1.y = s.height / 2; + this.label2.x = s.width * 3 / 6; + this.label2.y = s.height / 2; + this.label3.x = s.width * 4 / 6; + this.label3.y = s.height / 2; + this.label4.x = s.width * 5 / 6; + this.label4.y = s.height / 2; + + this.addChild(this.label0); + this.addChild(this.label1); + this.addChild(this.label2); + this.addChild(this.label3); + this.addChild(this.label4); + + // Sprite + var sprite = new cc.Sprite(s_pathGrossini); + sprite.x = 40; + sprite.y = 50; + + var jump = cc.jumpBy(3, cc.p(s.width - 80, 0), 50, 4); + + this.addChild(sprite); + sprite.runAction(cc.sequence(jump, jump.reverse()).repeatForever()); + + // pause button + var item1 = new cc.MenuItemFont("Pause", this.onPause, this); + var menu = new cc.Menu(item1); + menu.x = s.width / 2; + menu.y = s.height - 50; + + this.addChild(menu); + + }, + + onPause:function (sender) { + if (director.isPaused()) { + director.resume(); + } else { + director.pause(); + } + }, + + onExit:function () { + if (director.isPaused()) { + director.resume(); + } + this._super(); + }, + + step1:function (dt) { + this.time1 += dt; + this.label1.setString(this.time1.toFixed(1)); + }, + step2:function (dt) { + this.time2 += dt; + this.label2.setString(this.time2.toFixed(1)); + }, + step3:function (dt) { + this.time3 += dt; + this.label3.setString(this.time3.toFixed(1)); + }, + step4:function (dt) { + this.time4 += dt; + this.label4.setString(this.time4.toFixed(1)); + }, + update:function (dt) { + this.time0 += dt; + + this.label0.setString(this.time0.toFixed(1)); + } + + //CREATE_NODE(IntervalLayer); +}); + +var IntervalTestScene = TestScene.extend({ + + runThisTest:function () { + var layer = new IntervalLayer(); + this.addChild(layer); + director.runScene(this); + } +}); diff --git a/tests/js-tests/src/LabelTest/LabelTest.js b/tests/js-tests/src/LabelTest/LabelTest.js new file mode 100644 index 0000000000..d873cdc368 --- /dev/null +++ b/tests/js-tests/src/LabelTest/LabelTest.js @@ -0,0 +1,2080 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 TAG_LABEL = 1; +var TAG_LABEL_SPRITE_MANAGER = 1; +var TAG_ANIMATION1 = 1; +var TAG_BITMAP_ATLAS1 = 1; +var TAG_BITMAP_ATLAS2 = 2; +var TAG_BITMAP_ATLAS3 = 3; + +var TAG_LABEL_SPRITE1 = 660; +var TAG_LABEL_SPRITE12 = 661; +var TAG_LABEL_SPRITE13 = 662; +var TAG_LABEL_SPRITE14 = 663; +var TAG_LABEL_SPRITE15 = 664; +var TAG_LABEL_SPRITE16 = 665; +var TAG_LABEL_SPRITE17 = 666; +var TAG_LABEL_SPRITE18 = 667; + +var labelTestIdx = -1; + +var LabelTestScene = TestScene.extend({ + runThisTest:function (num) { + labelTestIdx = (num || num == 0) ? (num - 1) : -1; + this.addChild(nextLabelTest()); + director.runScene(this); + } +}); + +var AtlasDemo = BaseTestLayer.extend({ + + title:function () { + return "No title"; + }, + subtitle:function () { + return ""; + }, + onRestartCallback:function (sender) { + var s = new LabelTestScene(); + s.addChild(restartLabelTest()); + director.runScene(s); + + }, + onNextCallback:function (sender) { + var s = new LabelTestScene(); + s.addChild(nextLabelTest()); + director.runScene(s); + + }, + onBackCallback:function (sender) { + var s = new LabelTestScene(); + s.addChild(previousLabelTest()); + director.runScene(s); + }, + + // automation + numberOfPendingTests:function() { + return ( (arrayOfLabelTest.length-1) - labelTestIdx ); + }, + + getTestNumber:function() { + return labelTestIdx; + } + +}); + +//------------------------------------------------------------------ +// +// LabelAtlasOpacityTest +// +//------------------------------------------------------------------ +var LabelAtlasOpacityTest = AtlasDemo.extend({ + time:null, + ctor:function () { + //----start0----ctor + this._super(); + this.time = 0; + + var label1 = new cc.LabelAtlas("123 Test", s_resprefix + "fonts/tuffy_bold_italic-charmap.plist"); + this.addChild(label1, 0, TAG_LABEL_SPRITE1); + label1.x = 10; + label1.y = 100; + label1.opacity = 200; + + var label2 = new cc.LabelAtlas("0123456789", s_resprefix + "fonts/tuffy_bold_italic-charmap.plist"); + this.addChild(label2, 0, TAG_LABEL_SPRITE12); + label2.x = 10; + label2.y = 200; + label2.opacity = 32; + + this.schedule(this.step); + //----end0---- + }, + step:function (dt) { + //----start0----step + this.time += dt; + + var label1 = this.getChildByTag(TAG_LABEL_SPRITE1); + var string1 = this.time.toFixed(2) + " Test"; + label1.setString(string1); + + var label2 = this.getChildByTag(TAG_LABEL_SPRITE12); + var string2 = parseInt(this.time, 10).toString(); + label2.setString(string2); + //----end0---- + }, + title:function () { + return "LabelAtlas Opacity"; + }, + subtitle:function () { + return "Updating label should be fast"; + }, + + // + // Automation + // + getExpectedResult:function() { + // yellow, red, green, blue, yellow + var ret = [200,32]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = []; + var tags = [TAG_LABEL_SPRITE1, TAG_LABEL_SPRITE12]; + + for( var i in tags ) { + var t = tags[i]; + ret.push( this.getChildByTag(t).opacity ); + } + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// LabelAtlasOpacityColorTest +// +//------------------------------------------------------------------ +var LabelAtlasOpacityColorTest = AtlasDemo.extend({ + time:null, + ctor:function () { + //----start1----ctor + this._super(); + var label1 = new cc.LabelAtlas("123 Test", s_resprefix + "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); + this.addChild(label1, 0, TAG_LABEL_SPRITE1); + label1.x = 10; + label1.y = 100; + label1.opacity = 200; + + var label2 = new cc.LabelAtlas("0123456789", s_resprefix + "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); + this.addChild(label2, 0, TAG_LABEL_SPRITE12); + label2.x = 10; + label2.y = 200; + label2.color = cc.color(255, 0, 0); + + var fade = cc.fadeOut(1.0); + var fade_in = fade.reverse(); + var delay = cc.delayTime(0.25); + var seq = cc.sequence(fade, delay, fade_in, delay.clone()); + var repeat = seq.repeatForever(); + label2.runAction(repeat); + + this.time = 0; + + this.schedule(this.step); + //----end1---- + }, + step:function (dt) { + //----start1----step + this.time += dt; + var string1 = this.time.toFixed(2) + " Test"; + var label1 = this.getChildByTag(TAG_LABEL_SPRITE1); + label1.setString(string1); + + var label2 = this.getChildByTag(TAG_LABEL_SPRITE12); + var string2 = parseInt(this.time, 10).toString(); + label2.setString(string2); + //----end1---- + }, + title:function () { + return "LabelAtlas Opacity Color"; + }, + subtitle:function () { + return "Opacity + Color should work at the same time"; + }, + + // + // Automation + // + testDuration:1, + getExpectedResult:function() { + // yellow, red, green, blue, yellow + var ret = [200,{"r":255,"g":255,"b":255},0,{"r":255,"g":0,"b":0}]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = []; + var tags = [TAG_LABEL_SPRITE1, TAG_LABEL_SPRITE12]; + + for( var i in tags ) { + var t = tags[i]; + ret.push( this.getChildByTag(t).opacity ); + ret.push( this.getChildByTag(t).color ); + } + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// LabelAtlasHD +// +//------------------------------------------------------------------ +var LabelAtlasHD = AtlasDemo.extend({ + ctor:function () { + //----start2----ctor + this._super(); + var s = director.getWinSize(); + + // cc.LabelBMFont + var label1 = new cc.LabelAtlas("TESTING RETINA DISPLAY", s_resprefix + "fonts/larabie-16.plist"); + label1.anchorX = 0.5; + label1.anchorY = 0.5; + + this.addChild(label1); + label1.x = s.width / 2; + label1.y = s.height / 2; + //----end2---- + }, + title:function () { + return "LabelAtlas with Retina Display"; + }, + subtitle:function () { + return "loading larabie-16 / larabie-16-hd"; + }, + + + // + // Automation + // + + pixel: {"0": 255, "1": 255, "2": 255, "3": 255}, + + getExpectedResult:function() { + + // var ret = [{"0":0,"1":0,"2":226,"3":255},{"0":47,"1":0,"2":0,"3":255},{"0":0,"1":47,"2":0,"3":255}]; + var s = director.getWinSize(); + var ret = {"center": "yes"}; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + + var s = director.getWinSize(); + var ret2 = this.readPixels(s.width/2, s.height/2, 100, 100); + + var ret = {"center": this.containsPixel(ret2, this.pixel) ? "yes" : "no"}; + + return JSON.stringify(ret); + } +}); + + +//------------------------------------------------------------------ +// +// BMFontOpacityColorAlignmentTest +// +//------------------------------------------------------------------ +var BMFontOpacityColorAlignmentTest = AtlasDemo.extend({ + time:0, + ctor:function () { + //----start3----ctor + this._super(); + var col = new cc.LayerColor(cc.color(128, 128, 128, 255)); + this.addChild(col, -10); + + var label1 = new cc.LabelBMFont("Test", s_resprefix + "fonts/bitmapFontTest2.fnt"); + + // testing anchors + label1.anchorX = 0; + label1.anchorY = 0; + this.addChild(label1, 0, TAG_BITMAP_ATLAS1); + var fade = cc.fadeOut(1.0); + var fade_in = fade.reverse(); + var seq = cc.sequence(fade, cc.delayTime(0.25), fade_in); + var repeat = seq.repeatForever(); + label1.runAction(repeat); + + // VERY IMPORTANT + // color and opacity work OK because bitmapFontAltas2 loads a BMP image (not a PNG image) + // If you want to use both opacity and color, it is recommended to use NON premultiplied images like BMP images + // Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected + var label2 = new cc.LabelBMFont("Test", s_resprefix + "fonts/bitmapFontTest2.fnt"); + // testing anchors + label2.anchorX = 0.5; + label2.anchorY = 0.5; + label2.color = cc.color.RED ; + this.addChild(label2, 0, TAG_BITMAP_ATLAS2); + label2.runAction(repeat.clone()); + + var label3 = new cc.LabelBMFont("Test", s_resprefix + "fonts/bitmapFontTest2.fnt"); + // testing anchors + label3.anchorX = 1; + label3.anchorY = 1; + this.addChild(label3, 0, TAG_BITMAP_ATLAS3); + + var s = director.getWinSize(); + label1.x = 0; + label1.y = 0; + label2.x = s.width / 2; + label2.y = s.height / 2; + label3.x = s.width; + label3.y = s.height; + + this.schedule(this.step); + //----end3---- + }, + step:function (dt) { + //----start3----step + this.time += dt; + //var string; + var string = this.time.toFixed(2) + "Test j"; + + var label1 = this.getChildByTag(TAG_BITMAP_ATLAS1); + label1.setString(string); + + var label2 = this.getChildByTag(TAG_BITMAP_ATLAS2); + label2.setString(string); + + var label3 = this.getChildByTag(TAG_BITMAP_ATLAS3); + label3.setString(string); + //----end3---- + }, + + title:function () { + return "cc.LabelBMFont"; + }, + subtitle:function () { + return "Testing alignment. Testing opacity + tint"; + }, + + + // + // Automation + // + testDuration:1.1, + getExpectedResult:function() { + // yellow, red, green, blue, yellow + var ret = [0,{"r":255,"g":255,"b":255},0,{"r":255,"g":0,"b":0}]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = []; + var tags = [TAG_BITMAP_ATLAS1, TAG_BITMAP_ATLAS2]; + + for( var i in tags ) { + var t = tags[i]; + ret.push( this.getChildByTag(t).opacity ); + ret.push( this.getChildByTag(t).color ); + } + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// BMFontSubSpriteTest +// +//------------------------------------------------------------------ +var BMFontSubSpriteTest = AtlasDemo.extend({ + time:null, + ctor:function () { + //----start4----ctor + this._super(); + this.time = 0; + + var s = director.getWinSize(); + + var drawNode = new cc.DrawNode(); + this.addChild(drawNode); + drawNode.setDrawColor(cc.color(255,0,0,128)); + drawNode.drawSegment(cc.p(0, s.height / 2), cc.p(s.width, s.height / 2), 2); + drawNode.drawSegment(cc.p(s.width / 2, 0), cc.p(s.width / 2, s.height), 2); + + // Upper Label + var label = new cc.LabelBMFont("Bitmap Font Atlas", s_resprefix + "fonts/bitmapFontTest.fnt"); + this.labelObj = label; + this.addChild(label); + + label.x = s.width / 2; + label.y = s.height / 2; + label.anchorX = 0.5; + label.anchorY = 0.5; + + var BChar = label.getChildByTag(0); + var FChar = label.getChildByTag(7); + var AChar = label.getChildByTag(12); + + if(autoTestEnabled) { + var jump = cc.jumpBy(0.5, cc.p(0,0), 60, 1); + var jump_4ever = cc.sequence(jump, cc.delayTime(0.25)).repeatForever(); + var fade_out = cc.fadeOut(0.5); + var rotate = cc.rotateBy(0.5, 180); + var rot_4ever = cc.sequence(rotate, cc.delayTime(0.25), rotate.clone()).repeatForever(); + + var scale = cc.scaleBy(0.5, 1.5); + } else { + var jump = cc.jumpBy(4, cc.p(0,0), 60, 1); + var jump_4ever = jump.repeatForever(); + var fade_out = cc.fadeOut(1); + var rotate = cc.rotateBy(2, 360); + var rot_4ever = rotate.repeatForever(); + + var scale = cc.scaleBy(2, 1.5); + } + + var scale_back = scale.reverse(); + var scale_seq = cc.sequence(scale, cc.delayTime(0.25), scale_back); + var scale_4ever = scale_seq.repeatForever(); + + var fade_in = cc.fadeIn(1); + var seq = cc.sequence(fade_out, cc.delayTime(0.25), fade_in); + var fade_4ever = seq.repeatForever(); + + BChar.runAction(rot_4ever); + BChar.runAction(scale_4ever); + FChar.runAction(jump_4ever); + AChar.runAction(fade_4ever); + + // Bottom Label + var label2 = new cc.LabelBMFont("00.0", s_resprefix + "fonts/bitmapFontTest.fnt"); + this.addChild(label2, 0, TAG_BITMAP_ATLAS2); + label2.x = s.width / 2.0; + label2.y = 80; + + var lastChar = label2.getChildByTag(3); + lastChar.runAction(rot_4ever.clone()); + + this.schedule(this.step, 0.1); + //----end4---- + }, + step:function (dt) { + //----start4----step + this.time += dt; + var string = this.time.toFixed(1); + string = (string < 10) ? "0" + string : string; + var label1 = this.getChildByTag(TAG_BITMAP_ATLAS2); + label1.setString(string); + //----end4---- + }, + title:function () { + return "cc.LabelBMFont BMFontSubSpriteTest"; + }, + subtitle:function () { + return "Using fonts as cc.Sprite objects. Some characters should rotate."; + }, + + // + // Automation + // + testDuration:0.6, + getExpectedResult:function() { + // yellow, red, green, blue, yellow + var ret = {"rotate": 180, "scale": 1.5, "opacity": 0}; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + + var s = this.labelObj.getChildByTag(0).scale; + var r = this.labelObj.getChildByTag(0).rotation; + var o = this.labelObj.getChildByTag(12).opacity; + var ret = {"rotate": r, "scale": s, "opacity": o}; + + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// BMFontPaddingTest +// +//------------------------------------------------------------------ +var BMFontPaddingTest = AtlasDemo.extend({ + ctor:function () { + //----start5---- + this._super(); + var label = new cc.LabelBMFont("abcdefg", s_resprefix + "fonts/bitmapFontTest4.fnt"); + this.addChild(label); + + var s = director.getWinSize(); + + label.x = s.width / 2; + label.y = s.height / 2; + label.anchorX = 0.5; + label.anchorY = 0.5; + //----end5---- + }, + title:function () { + return "cc.LabelBMFont BMFontPaddingTest"; + }, + subtitle:function () { + return "Testing padding"; + }, + + + // + // Automation + // + pixel: {"0": 255, "1": 255, "2": 255, "3": 255}, + + getExpectedResult:function() { + + // var ret = [{"0":0,"1":0,"2":226,"3":255},{"0":47,"1":0,"2":0,"3":255},{"0":0,"1":47,"2":0,"3":255}]; + var s = director.getWinSize(); + var ret = {"center": "yes"}; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + + var s = director.getWinSize(); + var ret2 = this.readPixels(s.width/2, s.height/2, 100, 100); + var ret = {"center": this.containsPixel(ret2, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// BMFontOffsetTest +// +//------------------------------------------------------------------ +var BMFontOffsetTest = AtlasDemo.extend({ + ctor:function () { + //----start6----ctor + this._super(); + var s = director.getWinSize(); + + var label = null; + label = new cc.LabelBMFont("FaFeFiFoFu", s_resprefix + "fonts/bitmapFontTest5.fnt"); + this.addChild(label); + label.x = s.width / 2; + label.y = s.height / 2 + 50; + label.anchorX = 0.5; + label.anchorY = 0.5; + + label = new cc.LabelBMFont("fafefifofu", s_resprefix + "fonts/bitmapFontTest5.fnt"); + this.addChild(label); + label.x = s.width / 2; + label.y = s.height / 2; + label.anchorX = 0.5; + label.anchorY = 0.5; + + label = new cc.LabelBMFont("aeiou", s_resprefix + "fonts/bitmapFontTest5.fnt"); + this.addChild(label); + label.x = s.width / 2; + label.y = s.height / 2 - 50; + label.anchorX = 0.5; + label.anchorY = 0.5; + //----end6---- + }, + title:function () { + return "cc.LabelBMFont"; + }, + subtitle:function () { + return "Rendering should be OK. Testing offset"; + }, + + // + // Automation + // + + pixel: {"0":150,"1":150,"2":150,"3":255}, + getExpectedResult:function() { + var ret = {"top": "yes", "center": "yes", "bottom": "yes"}; + + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + + var s = director.getWinSize(); + var ret1 = this.readPixels(s.width/2, s.height/2-50, 50, 50); + var ret2 = this.readPixels(s.width/2, s.height/2, 50, 50); + var ret3 = this.readPixels(s.width/2, s.height/2+50, 50, 50); + var ret = {"top": this.containsPixel(ret1, this.pixel, true, 140) ? "yes" : "no", + "center": this.containsPixel(ret2, this.pixel, true, 140) ? "yes" : "no", + "bottom": this.containsPixel(ret3, this.pixel, true, 140) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// BMFontTintTest +// +//------------------------------------------------------------------ +var BMFontTintTest = AtlasDemo.extend({ + ctor:function () { + //----start7----ctor + this._super(); + var s = director.getWinSize(); + + var label = null; + label = new cc.LabelBMFont("Blue", s_resprefix + "fonts/bitmapFontTest5.fnt"); + label.color = cc.color(0, 0, 255); + this.addChild(label); + label.x = s.width / 2; + label.y = s.height / 4; + label.anchorX = 0.5; + label.anchorY = 0.5; + + label = new cc.LabelBMFont("Red", s_resprefix + "fonts/bitmapFontTest5.fnt"); + this.addChild(label); + label.x = s.width / 2; + label.y = 2 * s.height / 4; + label.anchorX = 0.5; + label.anchorY = 0.5; + label.color = cc.color(255, 0, 0); + + label = new cc.LabelBMFont("G", s_resprefix + "fonts/bitmapFontTest5.fnt"); + this.addChild(label); + label.x = s.width / 2; + label.y = 3 * s.height / 4; + label.anchorX = 0.5; + label.anchorY = 0.5; + label.color = cc.color(0, 255, 0); + label.setString("Green"); + //----end7---- + }, + title:function () { + return "cc.LabelBMFont BMFontTintTest"; + }, + subtitle:function () { + return "Testing color"; + }, + + // + // Automation + // + + pixel1: {"0":0,"1":0,"2":255,"3":255}, + pixel2: {"0":255,"1":0,"2":0,"3":255}, + pixel3: {"0":0,"1":255,"2":0,"3":255}, + getExpectedResult:function() { + var ret = {"left": "yes", "center": "yes", "right": "yes"}; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + + var s = director.getWinSize(); + var ret1 = this.readPixels(s.width/2, s.height/4, 50, 50); + var ret2 = this.readPixels(s.width/2, 2 * s.height/4, 50, 50); + var ret3 = this.readPixels(s.width/2, 3 * s.height/4, 50, 50); + var ret = {"left": this.containsPixel(ret1, this.pixel1, true, 100) ? "yes" : "no", + "center": this.containsPixel(ret2, this.pixel2, true, 100) ? "yes" : "no", + "right": this.containsPixel(ret3, this.pixel3, true, 100) ? "yes" : "no"} + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// BMFontSpeedTest +// +//------------------------------------------------------------------ +var BMFontSpeedTest = AtlasDemo.extend({ + ctor:function () { + //----start8----ctor + this._super(); + // Upper Label + for (var i = 0; i < 100; i++) { + var str = "-" + i + "-"; + var label = new cc.LabelBMFont(str, s_resprefix + "fonts/bitmapFontTest.fnt"); + this.addChild(label); + + var s = director.getWinSize(); + + var p = cc.p(Math.random() * s.width, Math.random() * s.height); + label.setPosition(p); + label.anchorX = 0.5; + label.anchorY = 0.5; + } + //----end8---- + }, + title:function () { + return "cc.LabelBMFont"; + }, + subtitle:function () { + return "Creating several cc.LabelBMFont with the same .fnt file should be fast"; + } +}); + +//------------------------------------------------------------------ +// +// BMFontMultiLineTest +// +//------------------------------------------------------------------ +var BMFontMultiLineTest = AtlasDemo.extend({ + ctor:function () { + //----start9----ctor + this._super(); + + // Left + var label1 = new cc.LabelBMFont("Multi line\nLeft", s_resprefix + "fonts/bitmapFontTest3.fnt"); + label1.anchorX = 0; + label1.anchorY = 0; + this.addChild(label1, 0, TAG_BITMAP_ATLAS1); + cc.log("content size:" + label1.width + "," + label1.height); + + + // Center + var label2 = new cc.LabelBMFont("Multi line\nCenter", s_resprefix + "fonts/bitmapFontTest3.fnt"); + label2.anchorX = 0.5; + label2.anchorY = 0.5; + this.addChild(label2, 0, TAG_BITMAP_ATLAS2); + cc.log("content size:" + label2.width + "," + label2.height); + + // right + var label3 = new cc.LabelBMFont("Multi line\nRight\nThree lines Three", s_resprefix + "fonts/bitmapFontTest3.fnt"); + label3.anchorX = 1; + label3.anchorY = 1; + this.addChild(label3, 0, TAG_BITMAP_ATLAS3); + cc.log("content size:" + label3.width + "," + label3.height); + + var s = director.getWinSize(); + label1.x = 0; + label1.y = 0; + label2.x = s.width / 2; + label2.y = s.height / 2; + label3.x = s.width; + label3.y = s.height; + //----end9---- + }, + title:function () { + return "cc.LabelBMFont BMFontMultiLineTest"; + }, + subtitle:function () { + return "Multiline + anchor point"; + }, + + // Automation + + pixel: {"0": 255, "1": 186, "2": 33, "3": 255}, + + getExpectedResult:function() { + + // var ret = [{"0":0,"1":0,"2":226,"3":255},{"0":47,"1":0,"2":0,"3":255},{"0":0,"1":47,"2":0,"3":255}]; + var s = director.getWinSize(); + var ret = {"left": "yes", "center": "yes", "right": "yes"}; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + + var s = director.getWinSize(); + var ret1 = this.readPixels(0, 0, 100, 100); + var ret2 = this.readPixels(s.width/2, s.height/2, 100, 100); + var ret3 = this.readPixels(s.width - 100, s.height - 100, 100, 100); + + + var ret = {"left": this.containsPixel(ret1, this.pixel) ? "yes" : "no", + "center": this.containsPixel(ret2, this.pixel) ? "yes" : "no", + "right": this.containsPixel(ret3, this.pixel) ? "yes" : "no"} + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// BMFontMultiLine2Test +// +//------------------------------------------------------------------ +var BMFontMultiLine2Test = AtlasDemo.extend({ + ctor:function () { + //----start10----ctor + this._super(); + + // Left + var label1 = new cc.LabelBMFont("Multi line\n\nAligned to the left", s_resprefix + "fonts/bitmapFontTest3.fnt"); + label1.anchorX = 0; + label1.anchorY = 0; + label1.textAlign = cc.TEXT_ALIGNMENT_LEFT; + label1.boundingWidth = 400; + this.addChild(label1, 0, TAG_BITMAP_ATLAS1); + cc.log("content size:" + label1.width + "," + label1.height); + + + // Center + var label2 = new cc.LabelBMFont("Error\n\nSome error message", s_resprefix + "fonts/bitmapFontTest3.fnt"); + label2.anchorX = 0.5; + label2.anchorY = 0.5; + label2.textAlign = cc.TEXT_ALIGNMENT_CENTER; + label2.boundingWidth = 290; + this.addChild(label2, 0, TAG_BITMAP_ATLAS2); + cc.log("content size:" + label2.width + "," + label2.height); + + // right + var label3 = new cc.LabelBMFont("Multi line\n\nAligned to the right", s_resprefix + "fonts/bitmapFontTest3.fnt"); + label3.anchorX = 1; + label3.anchorY = 1; + label3.textAlign = cc.TEXT_ALIGNMENT_RIGHT; + label3.boundingWidth = 400; + this.addChild(label3, 0, TAG_BITMAP_ATLAS3); + cc.log("content size:" + label3.width + "," + label3.height); + + var s = director.getWinSize(); + label1.x = 0; + label1.y = 0; + label2.x = s.width / 2; + label2.y = s.height / 2; + label3.x = s.width; + label3.y = s.height; + //----end10---- + }, + title:function () { + return "cc.LabelBMFont BMFontMultiLine2Test"; + }, + subtitle:function () { + return "Multiline with 2 new lines. All characters should appear"; + }, + // Automation + + pixel: {"0": 255, "1": 186, "2": 33, "3": 255}, + + getExpectedResult:function() { + + // var ret = [{"0":0,"1":0,"2":226,"3":255},{"0":47,"1":0,"2":0,"3":255},{"0":0,"1":47,"2":0,"3":255}]; + var s = director.getWinSize(); + var ret = {"left": "yes", "center": "yes", "right": "yes"}; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var s = director.getWinSize(); + var ret1 = this.readPixels(0, 0, 100, 100); + var ret2 = this.readPixels(s.width/2, s.height/2, 100, 100); + var ret3 = this.readPixels(s.width - 100, s.height - 100, 100, 100); + + var ret = {"left": this.containsPixel(ret1, this.pixel) ? "yes" : "no", + "center": this.containsPixel(ret2, this.pixel) ? "yes" : "no", + "right": this.containsPixel(ret3, this.pixel) ? "yes" : "no"} + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// LabelsEmpty +// +//------------------------------------------------------------------ +var LabelsEmpty = AtlasDemo.extend({ + setEmpty:null, + ctor:function () { + //----start25----ctor + this._super(); + + + // cc.LabelBMFont + var label1 = new cc.LabelBMFont("", s_resprefix + "fonts/bitmapFontTest3.fnt"); + this.addChild(label1, 0, TAG_BITMAP_ATLAS1); + label1.x = winSize.width / 2; + label1.y = winSize.height - 100; + + // cc.LabelTTF + var label2 = new cc.LabelTTF("", "Arial", 24); + this.addChild(label2, 0, TAG_BITMAP_ATLAS2); + label2.x = winSize.width / 2; + label2.y = winSize.height / 2; + + // cc.LabelAtlas + var label3 = new cc.LabelAtlas("", s_resprefix + "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); + this.addChild(label3, 0, TAG_BITMAP_ATLAS3); + label3.x = winSize.width / 2; + label3.y = 0 + 100; + + this.schedule(this.onUpdateStrings, 1.0); + + this.setEmpty = false; + //----end25---- + }, + onUpdateStrings:function (dt) { + //----start25----onUpdateStrings + var label1 = this.getChildByTag(TAG_BITMAP_ATLAS1); + var label2 = this.getChildByTag(TAG_BITMAP_ATLAS2); + var label3 = this.getChildByTag(TAG_BITMAP_ATLAS3); + + if (!this.setEmpty) { + label1.setString("not empty"); + label2.setString("not empty"); + label3.setString("hi"); + + this.setEmpty = true; + } + else { + label1.setString(""); + label2.setString(""); + label3.setString(""); + + this.setEmpty = false; + } + //----end25---- + }, + title:function () { + return "Testing empty labels"; + }, + subtitle:function () { + return "3 empty labels: LabelAtlas, LabelTTF and LabelBMFont"; + } +}); + +//------------------------------------------------------------------ +// +// BMFontHDTest +// +//------------------------------------------------------------------ +var BMFontHDTest = AtlasDemo.extend({ + ctor:function () { + //----start16----ctor + this._super(); + var s = director.getWinSize(); + + // cc.LabelBMFont + var label1 = new cc.LabelBMFont("TESTING RETINA DISPLAY", s_resprefix + "fonts/konqa32.fnt"); + this.addChild(label1); + label1.x = s.width / 2; + label1.y = s.height / 2; + //----end16---- + }, + title:function () { + return "Testing Retina Display BMFont"; + }, + subtitle:function () { + return "loading arista16 or arista16-hd"; + }, + + // + // Automation + // + + pixel: {"0": 255, "1": 255, "2": 255, "3": 255}, + + getExpectedResult:function() { + + // var ret = [{"0":0,"1":0,"2":226,"3":255},{"0":47,"1":0,"2":0,"3":255},{"0":0,"1":47,"2":0,"3":255}]; + var s = director.getWinSize(); + var ret = {"center": "yes"}; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + + var s = director.getWinSize(); + var ret2 = this.readPixels(s.width/2, s.height/2, 100, 100); + + var ret = {"center": this.containsPixel(ret2, this.pixel) ? "yes" : "no"}; + + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// BMFontGlyphDesignerTest +// +//------------------------------------------------------------------ +var BMFontGlyphDesignerTest = AtlasDemo.extend({ + ctor:function () { + //----start17----ctor + this._super(); + var s = director.getWinSize(); + + var layer = new cc.LayerColor(cc.color(128, 128, 128, 255)); + this.addChild(layer, -10); + + // cc.LabelBMFont + var label1 = new cc.LabelBMFont("Testing Glyph Designer", s_resprefix + "fonts/futura-48.fnt"); + this.addChild(label1); + label1.x = s.width / 2; + label1.y = s.height / 2; + //----end17---- + }, + title:function () { + return "Testing Glyph Designer"; + }, + subtitle:function () { + return "You should see a font with shawdows and outline"; + }, + + // + // Automation + // + + pixel: {"0": 240, "1": 201, "2": 108, "3": 255}, + + getExpectedResult:function() { + + // var ret = [{"0":0,"1":0,"2":226,"3":255},{"0":47,"1":0,"2":0,"3":255},{"0":0,"1":47,"2":0,"3":255}]; + var s = director.getWinSize(); + var ret = {"center": "yes"}; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + + var s = director.getWinSize(); + var ret2 = this.readPixels(s.width/2, s.height/2, 100, 100); + + var ret = {"center": this.containsPixel(ret2, this.pixel) ? "yes" : "no"}; + + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// LabelTTFTest +// +//------------------------------------------------------------------ + +var LabelTTFStrokeShadowTest = AtlasDemo.extend({ + _labelShadow: null, + _labelStroke: null, + _labelStrokeShadow: null, + + ctor: function () { + //----start26----ctor + this._super(); + this.updateLabels(); + //----end26---- + }, + + updateLabels: function () { + //----start26----updateLabels + var blockSize = cc.size(400, 100); + var s = director.getWinSize(); + + // colors + var redColor = cc.color(255, 0, 0); + var yellowColor = cc.color(255, 255, 0); + var blueColor = cc.color(0, 0, 255); + + // shadow offset + var shadowOffset = cc.p(12, -12); + + // positioning stuff + var posX = s.width / 2 - (blockSize.width / 2); + var posY_5 = s.height / 7; + + // font definition + var fontDefRedShadow = new cc.FontDefinition(); + fontDefRedShadow.fontName = "Arial"; + fontDefRedShadow.fontSize = 32; + fontDefRedShadow.textAlign = cc.TEXT_ALIGNMENT_CENTER; + fontDefRedShadow.verticalAlign = cc.VERTICAL_TEXT_ALIGNMENT_TOP; + fontDefRedShadow.fillStyle = redColor; + fontDefRedShadow.boundingWidth = blockSize.width; + fontDefRedShadow.boundingHeight = blockSize.height; + // shadow + fontDefRedShadow.shadowEnabled = true; + fontDefRedShadow.shadowOffsetX = shadowOffset.x; + fontDefRedShadow.shadowOffsetY = shadowOffset.y; + + // create the label using the definition + this._labelShadow = new cc.LabelTTF("Shadow Only", fontDefRedShadow); + this._labelShadow.anchorX = 0; + this._labelShadow.anchorY = 0; + this._labelShadow.x = posX; + this._labelShadow.y = posY_5; + + // font definition + var fontDefBlueStroke = new cc.FontDefinition(); + fontDefBlueStroke.fontName = "Arial"; + fontDefBlueStroke.fontSize = 32; + fontDefBlueStroke.textAlign = cc.TEXT_ALIGNMENT_CENTER; + fontDefBlueStroke.verticalAlign = cc.VERTICAL_TEXT_ALIGNMENT_TOP; + fontDefBlueStroke.fillStyle = blueColor; + fontDefBlueStroke.boundingWidth = blockSize.width; + fontDefBlueStroke.boundingHeight = blockSize.height; + // stroke + fontDefBlueStroke.strokeEnabled = true; + fontDefBlueStroke.strokeStyle = yellowColor; + + this._labelStroke = new cc.LabelTTF("Stroke Only", fontDefBlueStroke); + this._labelStroke.anchorX = 0; + this._labelStroke.anchorY = 0; + this._labelStroke.x = posX; + this._labelStroke.y = posY_5 * 2; + + // font definition + var fontDefRedStrokeShadow = new cc.FontDefinition(); + fontDefRedStrokeShadow.fontName = "Arial"; + fontDefRedStrokeShadow.fontSize = 32; + fontDefRedStrokeShadow.textAlign = cc.TEXT_ALIGNMENT_CENTER; + fontDefRedStrokeShadow.verticalAlign = cc.VERTICAL_TEXT_ALIGNMENT_TOP; + fontDefRedStrokeShadow.fillStyle = blueColor; + fontDefRedStrokeShadow.boundingWidth = blockSize.width; + fontDefRedStrokeShadow.boundingHeight = blockSize.height; + // stroke + fontDefRedStrokeShadow.strokeEnabled = true; + fontDefRedStrokeShadow.strokeStyle = redColor; + // shadow + fontDefRedStrokeShadow.shadowEnabled = true; + fontDefRedStrokeShadow.shadowOffsetX = -12; + fontDefRedStrokeShadow.shadowOffsetY = 12; //shadowOffset; + + this._labelStrokeShadow = new cc.LabelTTF("Stroke + Shadow\n New Line", fontDefRedStrokeShadow); + this._labelStrokeShadow.anchorX = 0; + this._labelStrokeShadow.anchorY = 0; + this._labelStrokeShadow.x = posX; + this._labelStrokeShadow.y = posY_5 * 3; + + // add all the labels + this.addChild(this._labelShadow); + this.addChild(this._labelStroke); + this.addChild(this._labelStrokeShadow); + //----end26---- + }, + + title: function () { + return "Testing cc.LabelTTF + shadow and stroke"; + }, + + subtitle: function () { + return ""; + } +}); + +var LabelTTFTest = AtlasDemo.extend({ + _label:null, + _horizAlign:null, + _vertAlign:null, + ctor:function () { + //----start19----ctor + this._super(); + var blockSize = cc.size(200, 160); + var s = director.getWinSize(); + + var colorLayer = new cc.LayerColor(cc.color(100, 100, 100, 255), blockSize.width, blockSize.height); + colorLayer.anchorX = 0; + colorLayer.anchorY = 0; + colorLayer.x = (s.width - blockSize.width) / 2; + colorLayer.y = (s.height - blockSize.height) / 2; + + this.addChild(colorLayer); + + cc.MenuItemFont.setFontSize(30); + var menu = new cc.Menu( + new cc.MenuItemFont("Left", this.setAlignmentLeft, this), + new cc.MenuItemFont("Center", this.setAlignmentCenter, this), + new cc.MenuItemFont("Right", this.setAlignmentRight, this)); + menu.alignItemsVerticallyWithPadding(4); + menu.x = 50; + menu.y = s.height / 2 - 20; + this.addChild(menu); + + menu = new cc.Menu( + new cc.MenuItemFont("Top", this.setAlignmentTop, this), + new cc.MenuItemFont("Middle", this.setAlignmentMiddle, this), + new cc.MenuItemFont("Bottom", this.setAlignmentBottom, this)); + menu.alignItemsVerticallyWithPadding(4); + menu.x = s.width - 50; + menu.y = s.height / 2 - 20; + this.addChild(menu); + + this._label = null; + this._horizAlign = cc.TEXT_ALIGNMENT_LEFT; + this._vertAlign = cc.VERTICAL_TEXT_ALIGNMENT_TOP; + + this.updateAlignment(); + //----end19---- + }, + updateAlignment:function () { + //----start19----updateAlignment + var blockSize = cc.size(200, 160); + var s = director.getWinSize(); + + if (this._label) { + this._label.removeFromParent(); + } + + this._label = new cc.LabelTTF(this.getCurrentAlignment(), "Arial", 32, blockSize, this._horizAlign, this._vertAlign); + + this._label.anchorX = 0; + this._label.anchorY = 0; + this._label.x = (s.width - blockSize.width) / 2; + this._label.y = (s.height - blockSize.height) / 2; + + this.addChild(this._label); + //----end19---- + }, + setAlignmentLeft:function (sender) { + this._horizAlign = cc.TEXT_ALIGNMENT_LEFT; + this.updateAlignment(); + }, + setAlignmentCenter:function (sender) { + this._horizAlign = cc.TEXT_ALIGNMENT_CENTER; + this.updateAlignment(); + }, + setAlignmentRight:function (sender) { + this._horizAlign = cc.TEXT_ALIGNMENT_RIGHT; + this.updateAlignment(); + }, + setAlignmentTop:function (sender) { + this._vertAlign = cc.VERTICAL_TEXT_ALIGNMENT_TOP; + this.updateAlignment(); + }, + setAlignmentMiddle:function (sender) { + this._vertAlign = cc.VERTICAL_TEXT_ALIGNMENT_CENTER; + this.updateAlignment(); + }, + setAlignmentBottom:function (sender) { + this._vertAlign = cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM; + this.updateAlignment(); + }, + getCurrentAlignment:function () { + //----start19----getCurrentAlignment + var vertical = null; + var horizontal = null; + switch (this._vertAlign) { + case cc.VERTICAL_TEXT_ALIGNMENT_TOP: + vertical = "Top"; + break; + case cc.VERTICAL_TEXT_ALIGNMENT_CENTER: + vertical = "Middle"; + break; + case cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM: + vertical = "Bottom"; + break; + } + switch (this._horizAlign) { + case cc.TEXT_ALIGNMENT_LEFT: + horizontal = "Left"; + break; + case cc.TEXT_ALIGNMENT_CENTER: + horizontal = "Center"; + break; + case cc.TEXT_ALIGNMENT_RIGHT: + horizontal = "Right"; + break; + } + + return "Alignment " + vertical + " " + horizontal; + //----end19---- + }, + title:function () { + return "Testing cc.LabelTTF"; + }, + subtitle:function () { + return "Select the buttons on the sides to change alignment"; + } +}); + +var LabelTTFMultiline = AtlasDemo.extend({ + ctor:function () { + //----start20----ctor + this._super(); + var s = director.getWinSize(); + + // cc.LabelBMFont + var center = new cc.LabelTTF("word wrap \"testing\" (bla0) bla1 'bla2' [bla3] (bla4) {bla5} {bla6} [bla7] (bla8) [bla9] 'bla0' \"bla1\"", + "Arial", 32, cc.size(s.width / 2, 200), cc.TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_TOP); + center.setDimensions(s.width / 2, 200); + center.x = s.width / 2; + center.y = 150; + + this.addChild(center); + //----end20---- + }, + title:function () { + return "Testing cc.LabelTTF Word Wrap"; + }, + subtitle:function () { + return "Word wrap using cc.LabelTTF"; + }, + + // + // Automation + // + + pixel: {"0": 255, "1": 255, "2": 255, "3": 255}, + + getExpectedResult:function() { + + // var ret = [{"0":0,"1":0,"2":226,"3":255},{"0":47,"1":0,"2":0,"3":255},{"0":0,"1":47,"2":0,"3":255}]; + var s = director.getWinSize(); + var ret = {"center": "yes"}; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + + var s = director.getWinSize(); + var ret2 = this.readPixels(s.width/2, 125, 100, 100); + + var ret = {"center": this.containsPixel(ret2, this.pixel) ? "yes" : "no"}; + + return JSON.stringify(ret); + } +}); + +var LabelTTFChinese = AtlasDemo.extend({ + ctor:function () { + //----start21----ctor + this._super(); + var size = director.getWinSize(); + var fontname = (cc.sys.os === cc.sys.OS_WP8 ) ? "fonts/arialuni.ttf" : (cc.sys.os == cc.sys.OS_WINRT) ? "DengXian" : "Microsoft Yahei"; + var label = new cc.LabelTTF("中国", fontname, 30); + label.x = size.width / 2; + label.y = size.height / 3 * 2; + this.addChild(label); + + // Test UTF8 string from native to jsval. + var label2 = new cc.LabelTTF("string from native:"+label.getString(), fontname, 30); + label2.x = size.width / 2; + label2.y = size.height / 3; + this.addChild(label2); + //----end21---- + }, + title:function () { + return "Testing cc.LabelTTF with Chinese character"; + } +}); + +var BMFontChineseTest = AtlasDemo.extend({ + ctor:function () { + //----start18----ctor + this._super(); + var size = director.getWinSize(); + var label = new cc.LabelBMFont("中国", s_resprefix + "fonts/bitmapFontChinese.fnt"); + label.x = size.width / 2; + label.y = size.height / 2; + this.addChild(label); + //----end18---- + }, + title:function () { + return "Testing cc.LabelBMFont with Chinese character"; + }, + + // + // Automation + // + + pixel: {"0": 255, "1": 0, "2": 142, "3": 255}, + + getExpectedResult:function() { + + // var ret = [{"0":0,"1":0,"2":226,"3":255},{"0":47,"1":0,"2":0,"3":255},{"0":0,"1":47,"2":0,"3":255}]; + var s = director.getWinSize(); + var ret = {"center": "yes"}; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + + var s = director.getWinSize(); + var ret2 = this.readPixels(s.width/2, s.height / 2, 100, 100); + + var ret = {"center": this.containsPixel(ret2, this.pixel) ? "yes" : "no"}; + + return JSON.stringify(ret); + } +}); + +var LongSentencesExample = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."; +var chineseExampleText = "美好的一天美好的一天美好的一天美好的一天美好的一天美好的一天美好的一天美好的一天美好的一天美好的一天美好的一天"; +var chineseMixEnglishText = "美好的一天bdgpy美b好b的d一b天d美好bd的p一g天美好b的d一d天bdgpybdgpybdgpybdg美好的一天bdgpy美好的一天美好的一天"; +var mixAllLanguageText = "美好良い一日を一Buen díabdgpy美b好b的d一b天d美Buen い一日を好b的d一d天Buen py美好的一天bdgpy美好的一天美好的一天"; +var LineBreaksExample = "Lorem ipsum dolor\nsit amet\nconsectetur adipisicing elit\nblah\nblah"; +var MixedExample = "ABC\nLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt\nDEF"; + +var ArrowsMax = 0.95; +var ArrowsMin = 0.7; + +var LeftAlign = 0; +var CenterAlign = 1; +var RightAlign = 2; + +var LongSentences = 0; +var LineBreaks = 1; +var Mixed = 2; +var chineseText = 3; +var chineseMixEnglish = 4; +var mixAllLanguage = 5; + +var alignmentItemPadding = 40; +var menuItemPaddingCenter = 80; + +var BMFontMultiLineAlignmentTest = AtlasDemo.extend({ + labelShouldRetain:null, + arrowsBarShouldRetain:null, + arrowsShouldRetain:null, + lastSentenceItem:null, + lastAlignmentItem:null, + lineBreakFlag:false, + ctor:function () { + //----start11----ctor + this._super(); + + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesBegan: this.onTouchesBegan.bind(this), + onTouchesMoved: this.onTouchesMoved.bind(this), + onTouchesEnded: this.onTouchesEnded.bind(this) + }, this); + if ('touches' in cc.sys.capabilities){ + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesBegan: this.onTouchesBegan.bind(this), + onTouchesMoved: this.onTouchesMoved.bind(this), + onTouchesEnded: this.onTouchesEnded.bind(this) + }, this); + } else if ('mouse' in cc.sys.capabilities) + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseDown: this.onMouseDown.bind(this), + onMouseMove: this.onMouseMove.bind(this), + onMouseUp: this.onMouseUp.bind(this) + }, this); + + // ask director the the window size + var size = director.getWinSize(); + + // create and initialize a Label + this.labelShouldRetain = new cc.LabelBMFont(LongSentencesExample, s_resprefix + "fonts/markerFelt.fnt", size.width / 2, cc.TEXT_ALIGNMENT_CENTER, cc.p(0, 0)); + this.arrowsBarShouldRetain = new cc.Sprite(s_resprefix + "Images/arrowsBar.png"); + this.arrowsShouldRetain = new cc.Sprite(s_resprefix + "Images/arrows.png"); + + cc.MenuItemFont.setFontSize(20); + var longSentences = new cc.MenuItemFont("Long Flowing Sentences", this.onStringChanged, this); + var lineBreaks = new cc.MenuItemFont("Short Sentences With Intentional Line Breaks", this.onStringChanged, this); + var mixed = new cc.MenuItemFont("Long Sentences Mixed With Intentional Line Breaks", this.onStringChanged.bind(this)); // another way to pass 'this' + var changeChineseItem = new cc.MenuItemFont("change chinese", this.onStringChanged, this); + var mixEnglishItem = new cc.MenuItemFont("change chinesemixEnglish", this.onStringChanged, this); + var mixAllLanItem = new cc.MenuItemFont("change mixAllLan", this.onStringChanged, this); + + var stringMenu = new cc.Menu(longSentences, lineBreaks, mixed, changeChineseItem,mixEnglishItem, mixAllLanItem); + stringMenu.alignItemsVertically(); + + var setLineBreakItem = new cc.MenuItemFont("setLineBreakWithoutSpace", this.onLineBreakChanged, this); + var setScale = new cc.MenuItemFont("setScale", this.onScaleChange, this); + var lineBreakMenu = new cc.Menu(setLineBreakItem, setScale); + lineBreakMenu.x = 100; + lineBreakMenu.y = winSize.height / 2; + lineBreakMenu.alignItemsVertically(); + + longSentences.color = cc.color(255, 0, 0); + this.lastSentenceItem = longSentences; + longSentences.tag = LongSentences; + lineBreaks.tag = LineBreaks; + mixed.tag = Mixed; + changeChineseItem.tag = chineseText; + mixEnglishItem.tag = chineseMixEnglish; + mixAllLanItem.tag = mixAllLanguage; + + cc.MenuItemFont.setFontSize(30); + + var left = new cc.MenuItemFont("Left", this.onAlignmentChanged, this); + var center = new cc.MenuItemFont("Center", this.onAlignmentChanged, this); + var right = new cc.MenuItemFont("Right", this.onAlignmentChanged.bind(this)); // another way to pass 'this' + var alignmentMenu = new cc.Menu(left, center, right); + alignmentMenu.alignItemsHorizontallyWithPadding(alignmentItemPadding); + + center.color = cc.color(255, 0, 0); + this.lastAlignmentItem = center; + left.tag = LeftAlign; + center.tag = CenterAlign; + right.tag = RightAlign; + + // position the label on the center of the screen + this.labelShouldRetain.x = size.width / 2; + this.labelShouldRetain.y = size.height / 2; + + this.arrowsBarShouldRetain.visible = false; + + var arrowsWidth = (ArrowsMax - ArrowsMin) * size.width; + this.arrowsBarShouldRetain.scaleX = arrowsWidth / this.arrowsBarShouldRetain.width; + this.arrowsBarShouldRetain.anchorX = 0; + this.arrowsBarShouldRetain.anchorY = 0.5; + this.arrowsBarShouldRetain.x = ArrowsMin * size.width; + this.arrowsBarShouldRetain.y = this.labelShouldRetain.y; + + this.arrowsShouldRetain.x = this.arrowsBarShouldRetain.x; + this.arrowsShouldRetain.y = this.arrowsBarShouldRetain.y; + + stringMenu.x = size.width / 2; + stringMenu.y = size.height - menuItemPaddingCenter; + alignmentMenu.x = size.width / 2; + alignmentMenu.y = menuItemPaddingCenter + 15; + + this.addChild(this.labelShouldRetain); + this.addChild(this.arrowsBarShouldRetain); + this.addChild(this.arrowsShouldRetain); + this.addChild(stringMenu); + this.addChild(alignmentMenu); + this.addChild(lineBreakMenu); + + + //----end11---- + }, + __title: function(){ + return 'The scroll bar'; + }, + title:function () { + return ""; + }, + subtitle:function () { + return ""; + }, + + onScaleChange:function(sener){ + if (this.labelShouldRetain.getScale() > 1) + { + this.labelShouldRetain.setScale(1.0); + } + else + { + this.labelShouldRetain.setScale(2.0); + } + + }, + onLineBreakChanged:function(sender){ + this.lineBreakFlag = !this.lineBreakFlag; + this.labelShouldRetain.setLineBreakWithoutSpace(this.lineBreakFlag); + }, + onStringChanged:function (sender) { + this.lastSentenceItem.color = cc.color(255, 255, 255); + sender.color = cc.color(255, 0, 0); + this.lastSentenceItem = sender; + + switch (sender.tag) { + case LongSentences: + this.labelShouldRetain.setString(LongSentencesExample); + this.labelShouldRetain.setFntFile(s_resprefix + "fonts/markerFelt.fnt"); + break; + case LineBreaks: + this.labelShouldRetain.setString(LineBreaksExample); + this.labelShouldRetain.setFntFile(s_resprefix + "fonts/markerFelt.fnt"); + break; + case Mixed: + this.labelShouldRetain.setString(MixedExample); + this.labelShouldRetain.setFntFile(s_resprefix + "fonts/markerFelt.fnt"); + break; + case chineseText: + this.labelShouldRetain.setFntFile(s_resprefix + "fonts/arial-unicode-26.fnt"); + this.labelShouldRetain.setString(chineseExampleText); + break; + case chineseMixEnglish: + this.labelShouldRetain.setFntFile(s_resprefix + "fonts/arial-unicode-26.fnt"); + this.labelShouldRetain.setString(chineseMixEnglishText); + break; + case mixAllLanguage: + this.labelShouldRetain.setFntFile(s_resprefix + "fonts/arial-unicode-26.fnt"); + this.labelShouldRetain.setString(mixAllLanguageText); + break; + default: + break; + } + + this.snapArrowsToEdge(); + }, + onAlignmentChanged:function (sender) { + var item = sender; + this.lastAlignmentItem.color = cc.color(255, 255, 255); + item.color = cc.color(255, 0, 0); + this.lastAlignmentItem = item; + + switch (item.tag) { + case LeftAlign: + this.labelShouldRetain.textAlign = cc.TEXT_ALIGNMENT_LEFT; + break; + case CenterAlign: + this.labelShouldRetain.textAlign = cc.TEXT_ALIGNMENT_CENTER; + break; + case RightAlign: + this.labelShouldRetain.textAlign = cc.TEXT_ALIGNMENT_RIGHT; + break; + default: + break; + } + + this.snapArrowsToEdge(); + }, + onTouchesBegan:function (touches) { + var touch = touches[0]; + var location = touch.getLocation(); + + if (cc.rectContainsPoint(this.arrowsShouldRetain.getBoundingBox(), location)) { + this.arrowsBarShouldRetain.visible = true; + } + }, + onTouchesEnded:function () { + this.arrowsBarShouldRetain.visible = false; + }, + onTouchesMoved:function (touches) { + var touch = touches[0]; + var location = touch.getLocation(); + + var winSize = director.getWinSize(); + + this.arrowsShouldRetain.x = Math.max(Math.min(location.x, ArrowsMax * winSize.width), ArrowsMin * winSize.width); + + this.labelShouldRetain.boundingWidth = Math.abs(this.arrowsShouldRetain.getPosition().x - this.labelShouldRetain.getPosition().x) * 2; + }, + + onMouseDown:function (event) { + var location = event.getLocation(); + + if (cc.rectContainsPoint(this.arrowsShouldRetain.getBoundingBox(), location)) { + this.arrowsBarShouldRetain.visible = true; + } + }, + onMouseMove:function (event) { + if(!event.getButton || event.getButton() != cc.EventMouse.BUTTON_LEFT) + return; + + var location = event.getLocation(); + var winSize = director.getWinSize(); + + this.arrowsShouldRetain.x = Math.max(Math.min(location.x, ArrowsMax * winSize.width), ArrowsMin * winSize.width); + this.labelShouldRetain.boundingWidth = Math.abs(this.arrowsShouldRetain.x - this.labelShouldRetain.x) * 2; + }, + onMouseUp:function (event) { + //this.snapArrowsToEdge(); + this.arrowsBarShouldRetain.visible = false; + }, + + snapArrowsToEdge:function () { + var winSize = director.getWinSize(); + this.arrowsShouldRetain.x = ArrowsMin * winSize.width; + this.arrowsShouldRetain.y = this.arrowsBarShouldRetain.y; + } +}); + +/// LabelTTFA8Test +var LabelTTFA8Test = AtlasDemo.extend({ + ctor:function () { + //----start22----ctor + this._super(); + var s = director.getWinSize(); + + var layer = new cc.LayerColor(cc.color(128, 128, 128, 255)); + this.addChild(layer, -10); + + // cc.LabelBMFont + var label1 = new cc.LabelTTF("Testing A8 Format", "Arial", 48); + this.addChild(label1); + label1.color = cc.color(255, 0, 0); + label1.x = s.width / 2; + label1.y = s.height / 2; + + var fadeOut = cc.fadeOut(2); + var fadeIn = cc.fadeIn(2); + var seq = cc.sequence(fadeOut, fadeIn); + var forever = seq.repeatForever(); + label1.runAction(forever); + //----end22---- + }, + title:function () { + return "Testing A8 Format"; + }, + subtitle:function () { + return "RED label, fading In and Out in the center of the screen"; + } +}); + +/// BMFontOneAtlas +var BMFontOneAtlas = AtlasDemo.extend({ + ctor:function () { + //----start12----ctor + this._super(); + var s = director.getWinSize(); + + var label1 = new cc.LabelBMFont("This is Helvetica", s_resprefix + "fonts/helvetica-32.fnt", cc.LabelAutomaticWidth, cc.TEXT_ALIGNMENT_LEFT, cc.p(0, 0)); + this.addChild(label1); + label1.x = s.width / 2; + label1.y = s.height * 2 / 3; + + var label2 = new cc.LabelBMFont("And this is Geneva", s_resprefix + "fonts/geneva-32.fnt", cc.LabelAutomaticWidth, cc.TEXT_ALIGNMENT_LEFT, cc.p(0, 128)); + this.addChild(label2); + label2.x = s.width / 2; + label2.y = s.height / 3; + //----end12---- + }, + + title:function () { + return "cc.LabelBMFont with one texture"; + }, + + subtitle:function () { + return "Using 2 .fnt definitions that share the same texture atlas."; + } +}); + +/// BMFontUnicode +var BMFontUnicode = AtlasDemo.extend({ + ctor:function () { + //----start13----ctor + this._super(); + var chinese = "美好的一天"; + var japanese = "良い一日を"; + var spanish = "Buen día"; + + var label1 = new cc.LabelBMFont(spanish, s_resprefix + "fonts/arial-unicode-26.fnt", 200, cc.TEXT_ALIGNMENT_LEFT); + this.addChild(label1); + label1.x = winSize.width / 2; + label1.y = winSize.height / 4; + + var label2 = new cc.LabelBMFont(chinese, s_resprefix + "fonts/arial-unicode-26.fnt"); + this.addChild(label2); + label2.x = winSize.width / 2; + label2.y = winSize.height / 2.2; + + var label3 = new cc.LabelBMFont(japanese, s_resprefix + "fonts/arial-unicode-26.fnt"); + this.addChild(label3); + label3.x = winSize.width / 2; + label3.y = winSize.height / 1.5; + //----end13---- + }, + title:function () { + return "cc.LabelBMFont with Unicode support"; + }, + subtitle:function () { + return "You should see 3 different labels: In Spanish, Chinese and Korean"; + } +}); + +// BMFontInit +var BMFontInit = AtlasDemo.extend({ + ctor:function () { + //----start14----ctor + this._super(); + + var bmFont = new cc.LabelBMFont(); + bmFont.setFntFile(s_resprefix + "fonts/helvetica-32.fnt"); + bmFont.setString("It is working!"); + this.addChild(bmFont); + bmFont.x = winSize.width / 2; + bmFont.y = winSize.height / 2; + //----end14---- + }, + title:function () { + return "cc.LabelBMFont init"; + }, + subtitle:function () { + return "Test for support of init method without parameters."; + } +}); + +// LabelTTFFontInitTest +var LabelTTFFontInitTest = AtlasDemo.extend({ + ctor:function () { + //----start23----ctor + this._super(); + var font = new cc.LabelTTF(); + font.font = "48px 'Courier New'"; + //font.setFontName("Arial"); + font.string = "It is working!"; + this.addChild(font); + font.x = winSize.width / 2; + font.y = winSize.height / 2; + //----end23---- + }, + title:function () { + return "cc.LabelTTF init"; + }, + subtitle:function () { + return "Test for support of init method without parameters."; + } +}); + + +var LabelTTFAlignment = AtlasDemo.extend({ + ctor:function () { + //----start24----ctor + this._super(); + var s = director.getWinSize(); + var ttf0 = new cc.LabelTTF("Alignment 0\nnew line", "Arial", 12, cc.size(256, 32), cc.TEXT_ALIGNMENT_LEFT); + ttf0.x = s.width / 2; + ttf0.y = (s.height / 6) * 2; + ttf0.anchorX = 0.5; + ttf0.anchorY = 0.5; + this.addChild(ttf0); + + var ttf1 = new cc.LabelTTF("Alignment 1\nnew line", "Arial", 12, cc.size(256, 32), cc.TEXT_ALIGNMENT_CENTER); + ttf1.x = s.width / 2; + ttf1.y = (s.height / 6) * 3; + ttf1.anchorX = 0.5; + ttf1.anchorY = 0.5; + this.addChild(ttf1); + + var ttf2 = new cc.LabelTTF("Alignment 2\nnew line", "Arial", 12, cc.size(256, 32), cc.TEXT_ALIGNMENT_RIGHT); + ttf2.x = s.width / 2; + ttf2.y = (s.height / 6) * 4; + ttf2.anchorX = 0.5; + ttf2.anchorY = 0.5; + this.addChild(ttf2); + //----end24---- + }, + title:function () { + return "cc.LabelTTF alignment"; + }, + subtitle:function () { + return "Tests alignment values"; + }, + + // + // Automation + // + getExpectedResult:function() { + // yellow, red, green, blue, yellow + var ret = [{"r":255,"g":255,"b":0},{"r":255,"g":0,"b":0},{"r":0,"g":255,"b":0},{"r":0,"g":0,"b":255},{"r":255,"g":255,"b":0}]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = []; + for( var i=0; i<5; i++) { + var ch = this.label.getChildByTag(i).getDisplayedColor(); + ret.push(ch); + } + + return JSON.stringify(ret); + } + +}); + +var BMFontColorParentChild = AtlasDemo.extend({ + ctor:function () { + //----start15----ctor + this._super(); + + this.label = new cc.LabelBMFont("YRGB", s_resprefix + "fonts/konqa32.fnt"); + this.addChild(this.label); + this.label.x = winSize.width / 2; + this.label.y = winSize.height / 2; + this.label.color = cc.color.YELLOW; + + // R + var letter = this.label.getChildByTag(1); + letter.color = cc.color.RED; + + // G + letter = this.label.getChildByTag(2); + letter.color = cc.color.GREEN; + + // B + letter = this.label.getChildByTag(3); + letter.color = cc.color.BLUE; + + this.scheduleUpdate(); + + this.accum = 0; + //----end15---- + }, + + update:function(dt){ + //----start15----update + this.accum += dt; + + this.label.setString("YRGB " + parseInt(this.accum,10).toString() ); + //----end15---- + }, + + title:function () { + return "cc.LabelBMFont color parent / child"; + }, + subtitle:function () { + return "Yellow Red Green Blue and numbers in Yellow"; + }, + + // + // Automation + // + getExpectedResult:function() { + // yellow, red, green, blue, yellow + var ret = [{"r":255,"g":255,"b":0},{"r":255,"g":0,"b":0},{"r":0,"g":255,"b":0},{"r":0,"g":0,"b":255},{"r":255,"g":255,"b":0}]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = []; + for( var i=0; i<5; i++) { + var ch = this.label.getChildByTag(i).getDisplayedColor(); + ret.push(ch); + } + + return JSON.stringify(ret); + } +}); + +var WrapAlgorithmTest = AtlasDemo.extend({ + ctor: function(){ + this._super(); + var self = this; + + var normalText = [ + "这里是中文测试例", + "测试带有符号,换行", + "测试中带有符号,换行", + "", + "Here is the English test", + "aaaaaaaaaaaaaaaaa", + "test test test aaa, tt", + "test test test aa, tt", + "こは日本語テスト", + "符号のテストに,ついて" + ]; + + normalText.forEach(function(text, i){ + var LabelTTF = new cc.LabelTTF(); + LabelTTF.setString(text); + LabelTTF.setPosition(30 + 150 * (i/4|0), 300 - (i%4) * 60); + LabelTTF.setAnchorPoint(0,1); + LabelTTF.boundingWidth = 120; + LabelTTF.boundingHeight = 0; + LabelTTF.enableStroke(cc.color(0, 0, 0, 1), 3.0); + if (cc.sys.os === cc.sys.OS_WP8) + LabelTTF.setFontName("fonts/arialuni.ttf"); + else if(cc.sys.os === cc.sys.OS_WINRT) + LabelTTF.setFontName("DengXian"); + self.addChild(LabelTTF); + }); + + //Extreme test + var extremeText = [ + "测", + "\n", + "\r\n", + "、", + ",", + "W", + "7" + ]; + + extremeText.forEach(function(text, i){ + var LabelTTF = new cc.LabelTTF(); + LabelTTF.setString(text); + LabelTTF.setPosition(480 + i * 25, 300); + LabelTTF.setAnchorPoint(0,1); + LabelTTF.boundingWidth = 3; + LabelTTF.boundingHeight = 0; + LabelTTF.enableStroke(cc.color(0, 0, 0, 1), 3.0); + if (cc.sys.os === cc.sys.OS_WP8) + LabelTTF.setFontName("fonts/arialuni.ttf"); + else if(cc.sys.os === cc.sys.OS_WINRT) + LabelTTF.setFontName("DengXian"); + self.addChild(LabelTTF); + }); + + //Combinatorial testing + var combinatorialText = [ + "中英混排English", + "中日混排テスト", + "日本語テストEnglish" + ]; + + combinatorialText.forEach(function(text, i){ + var LabelTTF = new cc.LabelTTF(); + LabelTTF.setString(text); + LabelTTF.setPosition(480 + 100 * (i/3|0), 240 - (i%3) * 60); + LabelTTF.setAnchorPoint(0,1); + LabelTTF.boundingWidth = 90; + LabelTTF.boundingHeight = 0; + LabelTTF.enableStroke(cc.color(0, 0, 0, 1), 3.0); + if (cc.sys.os === cc.sys.OS_WP8) + LabelTTF.setFontName("fonts/arialuni.ttf"); + else if(cc.sys.os === cc.sys.OS_WINRT) + LabelTTF.setFontName("DengXian"); + self.addChild(LabelTTF); + }); + + }, + title: function(){ + return "Wrap algorithm test"; + }, + subtitle: function(){ + return "Wrap effect under various circumstances"; + }, + onEnter: function(){ + this._super(); + cc.SPRITE_DEBUG_DRAW = 1; + }, + onExit: function(){ + this._super(); + cc.SPRITE_DEBUG_DRAW = 0; + } +}); + +// +// Flow control +// +var arrayOfLabelTest = [ + LabelAtlasOpacityTest, + LabelAtlasOpacityColorTest, + LabelAtlasHD, + + BMFontOpacityColorAlignmentTest, + BMFontSubSpriteTest, + BMFontPaddingTest, + BMFontOffsetTest, + BMFontTintTest, + BMFontSpeedTest, + BMFontMultiLineTest, + BMFontMultiLine2Test, + BMFontMultiLineAlignmentTest, + BMFontOneAtlas, + BMFontUnicode, + BMFontInit, + BMFontColorParentChild, + BMFontHDTest, + BMFontGlyphDesignerTest, + BMFontChineseTest, + + LabelTTFTest, + LabelTTFMultiline, + LabelTTFChinese, + LabelTTFA8Test, + LabelTTFFontInitTest, + LabelTTFAlignment, + + LabelsEmpty, + LabelTTFStrokeShadowTest +]; + +if (!cc.sys.isNative || cc.sys.isMobile) { + arrayOfLabelTest.push(WrapAlgorithmTest); +} + +var nextLabelTest = function () { + labelTestIdx++; + labelTestIdx = labelTestIdx % arrayOfLabelTest.length; + + if(window.sideIndexBar){ + labelTestIdx = window.sideIndexBar.changeTest(labelTestIdx, 19); + } + + return new arrayOfLabelTest[labelTestIdx](); +}; +var previousLabelTest = function () { + labelTestIdx--; + if (labelTestIdx < 0) + labelTestIdx += arrayOfLabelTest.length; + + if(window.sideIndexBar){ + labelTestIdx = window.sideIndexBar.changeTest(labelTestIdx, 19); + } + + return new arrayOfLabelTest[labelTestIdx](); +}; +var restartLabelTest = function () { + return new arrayOfLabelTest[labelTestIdx](); +}; diff --git a/tests/js-tests/src/LayerTest/LayerTest.js b/tests/js-tests/src/LayerTest/LayerTest.js new file mode 100644 index 0000000000..6d129c6b3c --- /dev/null +++ b/tests/js-tests/src/LayerTest/LayerTest.js @@ -0,0 +1,579 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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. + ****************************************************************************/ +cc.TAG_LAYER = 1; + +var layerTestSceneIdx = -1; +var LAYERTEST2_LAYER1_TAG = 1; +var LAYERTEST2_LAYER2_TAG = 2; + +var LayerTestScene = TestScene.extend({ + runThisTest:function (num) { + layerTestSceneIdx = (num || num == 0) ? (num - 1) : -1; + this.addChild(nextLayerTest()); + director.runScene(this); + } +}); + +//------------------------------------------------------------------ +// +// LayerTest +// +//------------------------------------------------------------------ +var LayerTest = BaseTestLayer.extend({ + _title:null, + + + title:function () { + return "No title"; + }, + subtitle:function () { + return ""; + }, + + onRestartCallback:function (sender) { + var s = new LayerTestScene(); + s.addChild(restartLayerTest()); + director.runScene(s); + + }, + onNextCallback:function (sender) { + var s = new LayerTestScene(); + s.addChild(nextLayerTest()); + director.runScene(s); + + }, + onBackCallback:function (sender) { + var s = new LayerTestScene(); + s.addChild(previousLayerTest()); + director.runScene(s); + + }, + // automation + numberOfPendingTests:function() { + return ( (arrayOfLayerTest.length-1) - layerTestSceneIdx ); + }, + + getTestNumber:function() { + return layerTestSceneIdx; + } + +}); + +//------------------------------------------------------------------ +// +// LayerTest1 +// +//------------------------------------------------------------------ +var LayerTest1 = LayerTest.extend({ + onEnter:function () { + //----start0----onEnter + this._super(); + + if( 'touches' in cc.sys.capabilities ) + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesMoved:function (touches, event) { + event.getCurrentTarget().updateSize(touches[0].getLocation()); + } + }, this); + else if ('mouse' in cc.sys.capabilities ) + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseMove: function(event){ + if(event.getButton() == cc.EventMouse.BUTTON_LEFT) + event.getCurrentTarget().updateSize(event.getLocation()); + } + }, this); + + var s = director.getWinSize(); + var layer = new cc.LayerColor(cc.color(255, 0, 0, 128)); + + layer.ignoreAnchor = false; + layer.anchorX = 0.5; + layer.anchorY = 0.5; + layer.setContentSize(200, 200); + layer.x = s.width / 2; + layer.y = s.height / 2; + this.addChild(layer, 1, cc.TAG_LAYER); + //----end0---- + }, + title:function () { + return "ColorLayer resize (tap & move)"; + }, + + updateSize:function (location) { + //----start0----updateSize + var l = this.getChildByTag(cc.TAG_LAYER); + + l.width = Math.abs(location.x - winSize.width / 2) * 2; + l.height = Math.abs(location.y - winSize.height / 2) * 2; + //----end0---- + }, + + // + // Automation + // + pixel: {"0": 190, "1": 0, "2": 0, "3": 128}, + + getExpectedResult:function() { + + var s = director.getWinSize(); + var ret = {"center": "yes"}; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + + var s = director.getWinSize(); + var ret2 = this.readPixels(s.width/2, s.height/2, 5, 5); + var ret = {"center": this.containsPixel(ret2, this.pixel, true, 100) ? "yes" : "no"}; + + return JSON.stringify(ret); + } +}); + +var IgnoreAnchorpointTest1 = LayerTest.extend({ + onEnter:function () { + //----start3----onEnter + this._super(); + //create layer + var ws = director.getWinSize(); + var layer1 = new cc.LayerColor(cc.color(255, 100, 100, 128), ws.width / 2, ws.height / 2); + layer1.ignoreAnchorPointForPosition(true); + var layer2 = new cc.LayerColor(cc.color(100, 255, 100, 128), ws.width / 4, ws.height / 4); + layer2.ignoreAnchorPointForPosition(true); + layer1.addChild(layer2); + layer1.x = ws.width / 2; + layer1.y = ws.height / 2; + this.addChild(layer1); + //----end3---- + }, + title:function () { + return "ignore Anchorpoint Test #1"; + }, + subtitle:function () { + return "red:true green:true"; + }, + + + // + // Automation + // + + pixel1: {"0": 100, "1": 150, "2": 100, "3": 200}, + pixel2: {"0": 100, "1": 50, "2": 50, "3": 200}, + + getExpectedResult:function() { + + var s = director.getWinSize(); + var ret = {"big": "yes", "small": "yes"}; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + + var s = director.getWinSize(); + var ret2 = this.readPixels(s.width/2 + s.width/5, s.height/2 + s.height/5, 5, 5); + var ret3 = this.readPixels(s.width - 50, s.height - 50, 50, 50); + var ret = {"big": this.containsPixel(ret2, this.pixel1, true, 100) ? "yes" : "no", + "small": this.containsPixel(ret3, this.pixel2, true, 100) ? "yes" : "no"}; + + return JSON.stringify(ret); + } +}); +var IgnoreAnchorpointTest2 = LayerTest.extend({ + onEnter:function () { + //----start4----onEnter + this._super(); + //create layer + var ws = director.getWinSize(); + var layer1 = new cc.LayerColor(cc.color(255, 100, 100, 128), ws.width / 2, ws.height / 2); + layer1.ignoreAnchorPointForPosition(true); + var layer2 = new cc.LayerColor(cc.color(100, 255, 100, 128), ws.width / 4, ws.height / 4); + layer2.ignoreAnchorPointForPosition(false); + layer1.addChild(layer2); + layer1.x = ws.width / 2; + layer1.y = ws.height / 2; + this.addChild(layer1); + //----end4---- + }, + title:function () { + return "ignore Anchorpoint Test #2"; + }, + subtitle:function () { + return "red:true green:false"; + }, + + + // + // Automation + // + + pixel1: {"0": 50, "1": 100, "2": 50, "3": 200}, + pixel2: {"0": 100, "1": 50, "2": 50, "3": 200}, + + getExpectedResult:function() { + + var s = director.getWinSize(); + var ret = {"big": "yes", "small": "yes"}; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + + var s = director.getWinSize(); + var ret2 = this.readPixels(s.width/2 - 50, s.height/2 - 50, 5, 5); + var ret3 = this.readPixels(s.width - 50, s.height - 50, 5, 5); + var ret = {"big": this.containsPixel(ret2, this.pixel1, true, 100) ? "yes" : "no", + "small": this.containsPixel(ret3, this.pixel2, true, 100) ? "yes" : "no"}; + + return JSON.stringify(ret); + } +}); + +var IgnoreAnchorpointTest3 = LayerTest.extend({ + onEnter:function () { + //----start5----onEnter + this._super(); + //create layer + var ws = director.getWinSize(); + var layer1 = new cc.LayerColor(cc.color(255, 100, 100, 128), ws.width / 2, ws.height / 2); + layer1.ignoreAnchorPointForPosition(false); + var layer2 = new cc.LayerColor(cc.color(100, 255, 100, 128), ws.width / 4, ws.height / 4); + layer2.ignoreAnchorPointForPosition(false); + layer1.addChild(layer2); + layer1.x = ws.width / 2; + layer1.y = ws.height / 2; + this.addChild(layer1); + //----end5---- + }, + title:function () { + return "ignore Anchorpoint Test #3"; + }, + subtitle:function () { + return "red:false green:false"; + } +}); + +var IgnoreAnchorpointTest4 = LayerTest.extend({ + onEnter:function () { + //----start6----onEnter + this._super(); + //create layer + var ws = director.getWinSize(); + var layer1 = new cc.LayerColor(cc.color(255, 100, 100, 128), ws.width / 2, ws.height / 2); + layer1.ignoreAnchorPointForPosition(false); + var layer2 = new cc.LayerColor(cc.color(100, 255, 100, 128), ws.width / 4, ws.height / 4); + layer2.ignoreAnchorPointForPosition(true); + layer1.addChild(layer2); + layer1.x = ws.width / 2; + layer1.y = ws.height / 2; + this.addChild(layer1); + //----end6---- + }, + title:function () { + return "ignore Anchorpoint Test #4"; + }, + subtitle:function () { + return "red:false green:true"; + } + +}); + +//------------------------------------------------------------------ +// +// LayerTest2 +// +//------------------------------------------------------------------ +var LayerTest2 = LayerTest.extend({ + + onEnter:function () { + //----start1----onEnter + this._super(); + + var s = director.getWinSize(); + var layer1 = new cc.LayerColor(cc.color(255, 255, 0, 80), 100, 300); + layer1.x = s.width / 3; + layer1.y = s.height / 2; + layer1.ignoreAnchorPointForPosition(false); + this.addChild(layer1, 1, LAYERTEST2_LAYER1_TAG); + + var layer2 = new cc.LayerColor(cc.color(0, 0, 255, 255), 100, 300); + layer2.x = (s.width / 3) * 2; + layer2.y = s.height / 2; + layer2.ignoreAnchorPointForPosition(false); + this.addChild(layer2, 2, LAYERTEST2_LAYER2_TAG); + + var actionTint = cc.tintBy(2, -255, -127, 0); + var actionTintBack = actionTint.reverse(); + + var actionFade = cc.fadeOut(2.0); + var actionFadeBack = actionFade.reverse(); + + if (autoTestEnabled) { + var seq1 = cc.sequence(actionTint, cc.delayTime(0.25), actionTintBack); + var seq2 = cc.sequence(actionFade, cc.delayTime(0.25), actionFadeBack); + } else { + var seq1 = cc.sequence(actionTint, actionTintBack); + var seq2 = cc.sequence(actionFade, actionFadeBack); + } + + layer1.runAction(seq1); + layer2.runAction(seq2); + //----end1---- + }, + title:function () { + return "ColorLayer: fade and tint"; + }, + + // + // Automation + // + + testDuration: 2.1, + tintTest: {"r": 0, "g": 128, "b": 60}, + getExpectedResult:function() { + var ret = {"tint": "yes", "opacity": 0}; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var abs = function (a) { + return (a > 0) ? a : a * -1; + }; + + var inColorRange = function (pix1, pix2) { + // Color on iOS comes as 0,128,128 and on web as 0,128,0 + if (abs(pix1.r - pix2.r) < 50 && abs(pix1.g - pix2.g) < 50 && + abs(pix1.b - pix2.b) < 90) { + return true; + } + return false; + }; + var s = director.getWinSize(); + var tint = this.getChildByTag(LAYERTEST2_LAYER1_TAG).color; + var op = this.getChildByTag(LAYERTEST2_LAYER2_TAG).opacity; + var ret = {"tint": inColorRange(tint, this.tintTest) ? "yes" : "no", + "opacity": op}; + + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// LayerTestBlend +// +//------------------------------------------------------------------ +var LayerTestBlend = LayerTest.extend({ + _blend:true, + + ctor:function () { + //----start2----ctor + this._super(); + var layer1 = new cc.LayerColor(cc.color(255, 255, 255, 80)); + + var sister1 = new cc.Sprite(s_pathSister1); + var sister2 = new cc.Sprite(s_pathSister2); + + this.addChild(sister1); + this.addChild(sister2); + this.addChild(layer1, 100, cc.TAG_LAYER); + + sister1.x = winSize.width/3; + + sister1.y = winSize.height / 2; + sister2.x = winSize.width/3 * 2; + sister2.y = winSize.height / 2; + + if (!cc.sys.isNative && !("opengl" in cc.sys.capabilities)) { + var label = new cc.LabelTTF("Not supported on HTML5-canvas", "Times New Roman", 30); + this.addChild(label); + label.x = winSize.width / 2; + label.y = winSize.height / 2; + } + + this.schedule(this.onNewBlend, 1.0); + this._blend = true; + //----end2---- + }, + onNewBlend:function (dt) { + //----start2----onNewBlend + var layer = this.getChildByTag(cc.TAG_LAYER); + + var src; + var dst; + + if (this._blend) { + src = cc.SRC_ALPHA; + dst = cc.ONE_MINUS_SRC_ALPHA; + } else { + src = cc.ONE_MINUS_DST_COLOR; + dst = cc.ZERO; + } + layer.setBlendFunc( src, dst ); + this._blend = ! this._blend; + //----end2---- + }, + title:function () { + return "ColorLayer: blend"; + } +}); + +//------------------------------------------------------------------ +// +// LayerGradient +// +//------------------------------------------------------------------ +var LayerGradient = LayerTest.extend({ + _isPressed:false, + ctor:function () { + //----start7----onEnter + this._super(); + var layer1 = new cc.LayerGradient(cc.color(255, 0, 0, 255), cc.color(0, 255, 0, 255), cc.p(0.9, 0.9)); + this.addChild(layer1, 0, cc.TAG_LAYER); + + if( 'touches' in cc.sys.capabilities ){ + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesBegan:function(touches, event){ + event.getCurrentTarget().updateGradient(touches[0].getLocation()); + }, + onTouchesMoved:function (touches, event) { + event.getCurrentTarget().updateGradient(touches[0].getLocation()); + } + }, this); + } else if ('mouse' in cc.sys.capabilities ){ + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseDown: function(event){ + event.getCurrentTarget().updateGradient(event.getLocation()); + }, + onMouseMove: function(event){ + if(event.getButton() == cc.EventMouse.BUTTON_LEFT) + event.getCurrentTarget().updateGradient(event.getLocation()); + } + }, this); + } + + var label1 = new cc.LabelTTF("Compressed Interpolation: Enabled", "Marker Felt", 26); + var label2 = new cc.LabelTTF("Compressed Interpolation: Disabled", "Marker Felt", 26); + var item1 = new cc.MenuItemLabel(label1); + var item2 = new cc.MenuItemLabel(label2); + var item = new cc.MenuItemToggle(item1, item2, this.onToggleItem, this); + + var menu = new cc.Menu(item); + this.addChild(menu); + menu.x = winSize.width / 2; + menu.y = 100; + //----end7---- + }, + + updateGradient:function(pos) { + //----start7----updateGradient + var diff = cc.pSub(cc.p(winSize.width / 2, winSize.height / 2), pos); + diff = cc.pNormalize(diff); + + var gradient = this.getChildByTag(1); + gradient.setVector(diff); + //----end7---- + }, + + onToggleItem:function (sender) { + //----start7----onToggleItem + var gradient = this.getChildByTag(cc.TAG_LAYER); + gradient.setCompressedInterpolation(!gradient.isCompressedInterpolation()); + //----end7---- + }, + + title:function () { + return "LayerGradient"; + }, + subtitle:function () { + return "Touch the screen and move your finger"; + }, + + // + // Automation + // + + pixel1: {"0": 255, "1": 0, "2": 0, "3": 255}, + pixel2: {"0": 0, "1": 255, "2": 0, "3": 255}, + + getExpectedResult:function() { + + var s = director.getWinSize(); + var ret = {"bottomleft": "yes", "topright": "yes"}; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + + var s = director.getWinSize(); + var ret2 = this.readPixels(50, 50, 50, 50); + var ret3 = this.readPixels(s.width - 50, s.height - 50, 50, 50); + var ret = {"bottomleft": this.containsPixel(ret2, this.pixel1) ? "yes" : "no", + "topright": this.containsPixel(ret3, this.pixel2) ? "yes" : "no"}; + + return JSON.stringify(ret); + } +}); + +var arrayOfLayerTest = [ + LayerTest1, + LayerTest2, + LayerGradient, + LayerTestBlend, + IgnoreAnchorpointTest1, + IgnoreAnchorpointTest2, + IgnoreAnchorpointTest3, + IgnoreAnchorpointTest4 +]; + +var nextLayerTest = function () { + layerTestSceneIdx++; + layerTestSceneIdx = layerTestSceneIdx % arrayOfLayerTest.length; + + if(window.sideIndexBar){ + layerTestSceneIdx = window.sideIndexBar.changeTest(layerTestSceneIdx, 20); + } + + return new arrayOfLayerTest[layerTestSceneIdx](); +}; +var previousLayerTest = function () { + layerTestSceneIdx--; + if (layerTestSceneIdx < 0) + layerTestSceneIdx += arrayOfLayerTest.length; + + if(window.sideIndexBar){ + layerTestSceneIdx = window.sideIndexBar.changeTest(layerTestSceneIdx, 20); + } + + return new arrayOfLayerTest[layerTestSceneIdx](); +}; +var restartLayerTest = function () { + return new arrayOfLayerTest[layerTestSceneIdx](); +}; diff --git a/tests/js-tests/src/LightTest/LightTest.js b/tests/js-tests/src/LightTest/LightTest.js new file mode 100644 index 0000000000..b4825fdca0 --- /dev/null +++ b/tests/js-tests/src/LightTest/LightTest.js @@ -0,0 +1,321 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 LightTestIdx = -1; + +var LightTestDemo = cc.Layer.extend({ + _title:"", + _subtitle:"", + + ctor:function () { + this._super(); + }, + + // + // Menu + // + onEnter:function () { + this._super(); + + var label = new cc.LabelTTF(this._title, "Arial", 28); + this.addChild(label, 100, BASE_TEST_TITLE_TAG); + label.x = winSize.width / 2; + label.y = winSize.height - 50; + + var label2 = new cc.LabelTTF(this._subtitle, "Thonburi", 16); + this.addChild(label2, 101, BASE_TEST_SUBTITLE_TAG); + label2.x = winSize.width / 2; + label2.y = winSize.height - 80; + + var item1 = new cc.MenuItemImage(s_pathB1, s_pathB2, this.onBackCallback, this); + var item2 = new cc.MenuItemImage(s_pathR1, s_pathR2, this.onRestartCallback, this); + var item3 = new cc.MenuItemImage(s_pathF1, s_pathF2, this.onNextCallback, this); + + item1.tag = BASE_TEST_MENUITEM_PREV_TAG; + item2.tag = BASE_TEST_MENUITEM_RESET_TAG; + item3.tag = BASE_TEST_MENUITEM_NEXT_TAG; + + var menu = new cc.Menu(item1, item2, item3); + + menu.x = 0; + menu.y = 0; + var width = item2.width, height = item2.height; + item1.x = winSize.width/2 - width*2; + item1.y = height/2 ; + item2.x = winSize.width/2; + item2.y = height/2 ; + item3.x = winSize.width/2 + width*2; + item3.y = height/2 ; + + this.addChild(menu, 102, BASE_TEST_MENU_TAG); + }, + + onRestartCallback:function (sender) { + var s = new LightTestScene(); + s.addChild(restartLightTest()); + director.runScene(s); + }, + + onNextCallback:function (sender) { + var s = new LightTestScene(); + s.addChild(nextLightTest()); + director.runScene(s); + }, + + onBackCallback:function (sender) { + var s = new LightTestScene(); + s.addChild(previousLightTest()); + director.runScene(s); + }, +}); + +var LightTestScene = cc.Scene.extend({ + ctor:function () { + this._super(); + + var label = new cc.LabelTTF("Main Menu", "Arial", 20); + var menuItem = new cc.MenuItemLabel(label, this.onMainMenuCallback, this); + + var menu = new cc.Menu(menuItem); + menu.x = 0; + menu.y = 0; + menuItem.x = winSize.width - 50; + menuItem.y = 25; + this.addChild(menu); + }, + onMainMenuCallback:function () { + var scene = new cc.Scene(); + var layer = new TestController(); + scene.addChild(layer); + director.runScene(scene); + }, + runThisTest:function (num) { + LightTestIdx = (num || num == 0) ? (num - 1) : -1; + var layer = nextLightTest(); + this.addChild(layer); + + director.runScene(this); + } +}); + +var LightTest = LightTestDemo.extend({ + _title:"Light Test", + _subtitle:"", + _ambientLight:null, + _directionalLight:null, + _pointLight:null, + _spotLight:null, + _ambientLightLabel:null, + _directionalLightLabel:null, + _pointLightLabel:null, + _spotLightLabel:null, + _angle:0, + + ctor:function(){ + this._super(); + + this.addSprite(); + this.addLights(); + this.scheduleUpdate(); + + var s = cc.winSize; + var camera = cc.Camera.createPerspective(60, s.width/s.height, 1, 1000); + camera.setCameraFlag(cc.CameraFlag.USER1); + camera.setPosition3D(cc.math.vec3(0, 100, 100)); + camera.lookAt(cc.math.vec3(0, 0, 0), cc.math.vec3(0, 1, 0)); + this.addChild(camera); + + this._ambientLightLabel = new cc.LabelTTF("Ambient Light ON", "Arial", 15); + var item1 = new cc.MenuItemLabel(this._ambientLightLabel, this.switchLight, this); + item1.setPosition(cc.p(100, 100 + item1.getContentSize().height * 8)); + item1.setUserData(cc.LightType.AMBIENT); + + this._directionalLightLabel = new cc.LabelTTF("Directional Light OFF", "Arial", 15); + var item2 = new cc.MenuItemLabel(this._directionalLightLabel, this.switchLight, this); + item2.setPosition(cc.p(100, 100 + item2.getContentSize().height * 6)); + item2.setUserData(cc.LightType.DIRECTIONAL); + + this._pointLightLabel = new cc.LabelTTF("Point Light OFF", "Arial", 15); + var item3 = new cc.MenuItemLabel(this._pointLightLabel, this.switchLight, this); + item3.setPosition(cc.p(100, 100 + item3.getContentSize().height * 4)); + item3.setUserData(cc.LightType.POINT); + + this._spotLightLabel = new cc.LabelTTF("Spot Light OFF", "Arial", 15); + var item4 = new cc.MenuItemLabel(this._spotLightLabel, this.switchLight, this); + item4.setPosition(cc.p(100, 100 + item4.getContentSize().height * 2)); + item4.setUserData(cc.LightType.SPOT); + + var menu = new cc.Menu(item1, item2, item3, item4); + this.addChild(menu); + menu.setPosition(cc.p(0, 0)); + + }, + + addSprite:function(){ + var s = cc.winSize; + + var orc = new jsb.Sprite3D("Sprite3DTest/orc.c3b"); + orc.setRotation3D(cc.math.vec3(0, 180, 0)); + orc.setPosition(cc.p(0, 0)); + orc.setScale(2.0); + var axe = new jsb.Sprite3D("Sprite3DTest/axe.c3b"); + orc.getAttachNode("Bip001 R Hand").addChild(axe); + var animation = jsb.Animation3D.create("Sprite3DTest/orc.c3b"); + if(animation){ + var animate = jsb.Animate3D.create(animation); + orc.runAction(cc.repeatForever(animate)); + } + this.addChild(orc); + orc.setCameraMask(2); + + var sphere1 = new jsb.Sprite3D("Sprite3DTest/sphere.c3b"); + sphere1.setPosition(cc.p(30, 0)); + this.addChild(sphere1); + sphere1.setCameraMask(2); + + var sphere2 = new jsb.Sprite3D("Sprite3DTest/sphere.c3b"); + sphere2.setPosition(cc.p(-50, 0)); + sphere2.setScale(0.5); + this.addChild(sphere2); + sphere2.setCameraMask(2); + + var sphere3 = new jsb.Sprite3D("Sprite3DTest/sphere.c3b"); + sphere3.setPosition(cc.p(-30, 0)); + sphere3.setScale(0.5); + this.addChild(sphere3); + sphere3.setCameraMask(2); + }, + + addLights:function(){ + this._ambientLight = jsb.AmbientLight.create(cc.color(200, 200, 200)); + this._ambientLight.setEnabled(true); + this.addChild(this._ambientLight); + this._ambientLight.setCameraMask(2); + + this._directionalLight = jsb.DirectionLight.create(cc.math.vec3(-1, -1, 0), cc.color(200, 200, 200)); + this._directionalLight.setEnabled(false); + this.addChild(this._directionalLight); + this._directionalLight.setCameraMask(2); + + this._pointLight = jsb.PointLight.create(cc.math.vec3(0, 0, 0), cc.color(200, 200, 200), 10000); + this._pointLight.setEnabled(false); + this.addChild(this._pointLight); + this._pointLight.setCameraMask(2); + + this._spotLight = jsb.SpotLight.create(cc.math.vec3(-1, -1, 0), cc.math.vec3(0, 0, 0), cc.color(200, 200, 200), 0, 0.5, 10000); + this._spotLight.setEnabled(false); + this.addChild(this._spotLight); + this._spotLight.setCameraMask(2); + + var seq1 = cc.sequence(cc.tintTo(4, 0, 0, 255), cc.tintTo(4, 0, 255, 0), cc.tintTo(4, 255, 0, 0), cc.tintTo(4, 255, 255, 255)); + this._ambientLight.runAction(seq1.repeatForever()); + + var seq2 = cc.sequence(cc.tintTo(4, 255, 0, 0), cc.tintTo(4, 0, 255, 0), cc.tintTo(4, 0, 0, 255), cc.tintTo(4, 255, 255, 255)); + this._directionalLight.runAction(seq2.repeatForever()); + + var seq3 = cc.sequence(cc.tintTo(4, 255, 0, 0), cc.tintTo(4, 0, 255, 0), cc.tintTo(4, 0, 0, 255), cc.tintTo(4, 255, 255, 255)); + this._pointLight.runAction(seq3.repeatForever()); + + var seq4 = cc.sequence(cc.tintTo(4, 255, 0, 0), cc.tintTo(4, 0, 255, 0), cc.tintTo(4, 0, 0, 255), cc.tintTo(4, 255, 255, 255)); + this._spotLight.runAction(seq4.repeatForever()); + }, + + update:function(dt){ + if(this._directionalLight) + this._directionalLight.setRotation3D(cc.math.vec3(-45, -cc.radiansToDegrees(this._angle), 0)); + + if(this._pointLight) + this._pointLight.setPosition3D(cc.math.vec3(100*Math.cos(this._angle+2*dt), 100, 100*Math.sin(this._angle+2*dt))); + + if(this._spotLight){ + this._spotLight.setPosition3D(cc.math.vec3(100*Math.cos(this._angle+4*dt), 100, 100*Math.sin(this._angle+4*dt))); + this._spotLight.setDirection(cc.math.vec3(-Math.cos(this._angle + 4 * dt), -1, -Math.sin(this._angle + 4*dt))); + } + }, + + switchLight:function(sender){ + var lightType = sender.getUserData(); + switch(lightType){ + case cc.LightType.AMBIENT: + var isAmbientOn = !this._ambientLight.isEnabled(); + this._ambientLight.setEnabled(isAmbientOn); + this._ambientLightLabel.setString("Ambient Light " + (isAmbientOn ? "ON" : "OFF")); + break; + + case cc.LightType.DIRECTIONAL: + var isDirectionalOn = !this._directionalLight.isEnabled(); + this._directionalLight.setEnabled(isDirectionalOn); + this._directionalLightLabel.setString("Directional Light " + (isDirectionalOn ? "ON" : "OFF")); + break; + + case cc.LightType.POINT: + var isPointOn = !this._pointLight.isEnabled(); + this._pointLight.setEnabled(isPointOn); + this._pointLightLabel.setString("Point Light " + (isPointOn ? "ON" : "OFF")); + break; + + case cc.LightType.SPOT: + var isSpotOn = !this._spotLight.isEnabled(); + this._spotLight.setEnabled(isSpotOn); + this._spotLightLabel.setString("Spot Light " + (isSpotOn ? "ON" : "OFF")); + break; + + default: + break; + } + } +}); + +// +// Flow control +// +var arrayOfLightTest = [ + LightTest +]; + +var nextLightTest = function () { + LightTestIdx++; + LightTestIdx = LightTestIdx % arrayOfLightTest.length; + + if(window.sideIndexBar){ + LightTestIdx = window.sideIndexBar.changeTest(LightTestIdx, 36); + } + + return new arrayOfLightTest[LightTestIdx ](); +}; +var previousLightTest = function () { + LightTestIdx--; + if (LightTestIdx < 0) + LightTestIdx += arrayOfLightTest.length; + + if(window.sideIndexBar){ + LightTestIdx = window.sideIndexBar.changeTest(LightTestIdx, 36); + } + + return new arrayOfLightTest[LightTestIdx ](); +}; +var restartLightTest = function () { + return new arrayOfLightTest[LightTestIdx ](); +}; diff --git a/tests/js-tests/src/LoaderTest/LoaderTest.js b/tests/js-tests/src/LoaderTest/LoaderTest.js new file mode 100644 index 0000000000..4893f2a823 --- /dev/null +++ b/tests/js-tests/src/LoaderTest/LoaderTest.js @@ -0,0 +1,94 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + 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. + ****************************************************************************/ + +//------------------------------------------------------------------ +// +// LoaderTestLayer +// +//------------------------------------------------------------------ +var LoaderTestLayer = BaseTestLayer.extend({ + _title:"Loader Test", + _subtitle:"", + + ctor:function() { + var self = this; + self._super(cc.color(0,0,0,255), cc.color(98,99,117,255)); + + var winSize = cc.winSize; + cc.loader.load(s_helloWorld, function(err, results){ + if(err){ + cc.log("Failed to load %s.", s_helloWorld); + return; + } + cc.log(s_helloWorld + "--->"); + cc.log(results[0]); + var bg = new cc.Sprite(s_helloWorld); + self.addChild(bg); + bg.x = winSize.width/2; + bg.y = winSize.height/2; + }); + + cc.loader.load([s_Cowboy_plist, s_Cowboy_png], function(err, results){ + if(err){ + cc.log("Failed to load %s, %s .", s_Cowboy_plist, s_Cowboy_png); + return; + } + + cc.log(s_Cowboy_plist + "--->"); + cc.log(results[0]); + cc.log(s_Cowboy_png + "--->"); + cc.log(results[1]); + cc.spriteFrameCache.addSpriteFrames(s_Cowboy_plist); + var frame = new cc.Sprite("#testAnimationResource/1.png"); + self.addChild(frame); + frame.x = winSize.width/4; + frame.y = winSize.height/4; + }); + + + var str; + if(cc.sys.isNative) { + str = s_lookup_desktop_plist; + } else if(cc.sys.isMobile) { + str = s_lookup_mobile_plist; + } else { + str = s_lookup_html5_plist; + } + + cc.loader.loadAliases(str, function(){ + var sprite = new cc.Sprite("grossini.bmp"); + self.addChild( sprite ); + sprite.x = winSize.width/2; + sprite.y = winSize.height/2; + }); + + } +}); + +var LoaderTestScene = TestScene.extend({ + runThisTest:function () { + this.addChild(new LoaderTestLayer()); + director.runScene(this); + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/MenuTest/MenuTest.js b/tests/js-tests/src/MenuTest/MenuTest.js new file mode 100644 index 0000000000..074a6b4bc4 --- /dev/null +++ b/tests/js-tests/src/MenuTest/MenuTest.js @@ -0,0 +1,533 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 TAG_MENU = 77771; +var TAG_MENU0 = 77770; +var TAG_MENU1 = 77771; + +//------------------------------------------------------------------ +// +// LayerMainMenu +// +//------------------------------------------------------------------ +var MenuLayerMainMenu = cc.Layer.extend({ + _disabledItem:null, + _touchListener: null, + + ctor:function () { + //----start0----ctor + this._super(); + + // Font Item + var spriteNormal = new cc.Sprite(s_menuItem, cc.rect(0,23*2,115,23)); + var spriteSelected = new cc.Sprite(s_menuItem, cc.rect(0,23,115,23)); + var spriteDisabled = new cc.Sprite(s_menuItem, cc.rect(0,0,115,23)); + + var item1 = new cc.MenuItemSprite(spriteNormal, spriteSelected, spriteDisabled, this.onMenuCallback, this); + + // Image Item + var sendScoreSF = new cc.SpriteFrame(s_sendScore, cc.rect(0, 0, 145, 26)); + cc.spriteFrameCache.addSpriteFrame(sendScoreSF, "send_score_sf"); + var item2 = new cc.MenuItemImage("#send_score_sf", s_pressSendScore, this.onMenuCallback2, this); + + // Label Item (LabelAtlas) + var labelAtlas = new cc.LabelAtlas("0123456789", s_fpsImages, 16, 24, '.'); + var item3 = new cc.MenuItemLabel(labelAtlas, this.onMenuCallbackDisabled, this ); + item3.setDisabledColor( cc.color(32,32,64) ); + item3.color = cc.color(200,200,255); + + // Font Item + var item4 = new cc.MenuItemFont("I toggle enable items", function(sender) { + this._disabledItem.enabled = !this._disabledItem.enabled; + }, this); + + item4.fontSize = 20; + item4.fontName = "Arial"; + + // Label Item (LabelBMFont) + var label = new cc.LabelBMFont("configuration", s_bitmapFontTest3_fnt); + var item5 = new cc.MenuItemLabel(label, this.onMenuCallbackConfig, this); + + // Testing issue #500 + item5.scale = 0.8; + + // Events + cc.MenuItemFont.setFontName("Arial"); + + // Bugs Item + var item7 = new cc.MenuItemFont("Bugs", this.onMenuCallbackBugsTest, this); + + // Font Item + var item8 = new cc.MenuItemFont("Quit", this.onQuit, this); + + var item9 = new cc.MenuItemFont("Remove menu item when moving", this.onMenuMovingCallback, this); + + var color_action = cc.tintBy(0.5, 0, -255, -255); + var color_back = color_action.reverse(); + var seq = cc.sequence(color_action, color_back); + item8.runAction(seq.repeatForever()); + + var menu = new cc.Menu( item1, item2, item3, item4, item5, item7, item8, item9); + menu.alignItemsVertically(); + + // elastic effect + var winSize = cc.director.getWinSize(); + + var locChildren = menu.children; + var dstPoint = cc.p(0,0); + for(var i = 0; i < locChildren.length; i++){ + var selChild = locChildren[i]; + if(selChild){ + dstPoint.x = selChild.x; + dstPoint.y = selChild.y; + var offset = 0|(winSize.width/2 + 50); + if( i % 2 == 0) + offset = -offset; + + selChild.x = dstPoint.x + offset; + selChild.y = dstPoint.y; + selChild.runAction(cc.moveBy(2, cc.p(dstPoint.x - offset,0)).easing(cc.easeElasticOut(0.35))); + } + } + this._disabledItem = item3; + this._disabledItem.enabled = false; + this.addChild(menu); + menu.x = winSize.width/2; + menu.y = winSize.height/2; + //----end0---- + }, + + onMenuCallback:function (sender) { + this.parent.switchTo(1); + }, + + onMenuCallbackConfig:function (sender) { + this.parent.switchTo(3); + }, + + onAllowTouches:function (dt) { + cc.eventManager.setPriority(this._touchListener, 1); + this.unscheduleAllCallbacks(); + cc.log("TOUCHES ALLOWED AGAIN"); + }, + + onMenuCallbackDisabled:function (sender) { + // hijack all touch events for 5 seconds + cc.eventManager.setPriority(this._touchListener, -1); + this.schedule(this.onAllowTouches, 5.0); + cc.log("TOUCHES DISABLED FOR 5 SECONDS"); + }, + + onMenuCallback2:function (sender) { + this.parent.switchTo(2); + }, + + onEnter: function() { + this._super(); + this._touchListener = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches: true, + onTouchBegan:function () { + return true; + } + }); + cc.eventManager.addListener(this._touchListener, 1); + }, + + onExit: function() { + this._super(); + cc.eventManager.removeListener(this._touchListener); + }, + + onQuit:function (sender) { + cc.log("Quit called"); + }, + + onMenuCallbackBugsTest:function(sender){ + this.parent.switchTo(4); + }, + + onMenuMovingCallback:function(sender){ + this.parent.switchTo(5); + } +}); + +//------------------------------------------------------------------ +// +// MenuLayer2 +// +//------------------------------------------------------------------ +var MenuLayer2 = cc.Layer.extend({ + _centeredMenu:null, + _alignedH:false, + + ctor:function () { + this._super(); + for (var i = 0; i < 2; i++) { + var item1 = new cc.MenuItemImage(s_playNormal, s_playSelect, this.onMenuCallback, this); + var item2 = new cc.MenuItemImage(s_highNormal, s_highSelect, this.onMenuCallbackOpacity, this); + var item3 = new cc.MenuItemImage(s_aboutNormal, s_aboutSelect, this.onMenuCallbackAlign, this); + + item1.scaleX = 1.5; + item2.scaleX = 0.5; + item3.scaleX = 0.5; + + var menu = new cc.Menu(item1, item2, item3); + var winSize = director.getWinSize(); + + menu.tag = TAG_MENU; + menu.x = winSize.width / 2; + menu.y = winSize.height / 2; + + this.addChild(menu, 0, 100 + i); + + this._centeredMenu = cc.p(menu.x, menu.y); + } + this._alignedH = true; + this.alignMenuH(); + }, + init:function () { + this._super(); + + }, + alignMenuH:function () { + for (var i = 0; i < 2; i++) { + var menu = this.getChildByTag(100 + i); + menu.x = this._centeredMenu.x; + menu.y = this._centeredMenu.y; + if (i === 0) { + menu.alignItemsHorizontally(); + menu.y += 30; + } else { + menu.alignItemsHorizontallyWithPadding(40); + menu.y -= 30; + } + } + }, + alignMenusV:function () { + for (var i = 0; i < 2; i++) { + var menu = this.getChildByTag(100 + i); + menu.x = this._centeredMenu.x; + menu.y = this._centeredMenu.y; + if (i === 0) { + menu.alignItemsVertically(); + menu.x += 100; + } else { + menu.alignItemsVerticallyWithPadding(40); + menu.x -= 100; + } + } + }, + // callbacks + onMenuCallback:function (sender) { + this.parent.switchTo(0); + }, + onMenuCallbackOpacity:function (sender) { + var menu = sender.parent; + var opacity = menu.opacity; + if (opacity == 128) + menu.opacity = 255; + else + menu.opacity = 128; + }, + onMenuCallbackAlign:function (sender) { + this._alignedH = !this._alignedH; + if (this._alignedH) + this.alignMenuH(); + else + this.alignMenusV(); + } +}); + +//------------------------------------------------------------------ +// +// MenuLayer3 +// +//------------------------------------------------------------------ +var MenuLayer3 = cc.Layer.extend({ + _disabledItem:null, + + ctor:function () { + this._super(); + this.init(); + }, + init:function () { + this._super(); + cc.MenuItemFont.setFontName("Marker Felt"); + cc.MenuItemFont.setFontSize(28); + + var label = new cc.LabelBMFont("Enable AtlasItem", s_bitmapFontTest3_fnt); + var item1 = new cc.MenuItemLabel(label, function(sender){ + this._disabledItem.enabled = !this._disabledItem.enabled; + this._disabledItem.stopAllActions(); + }, this); + var item2 = new cc.MenuItemFont("--- Go Back ---", function(sender){ + this.parent.switchTo(0); + }, this); + + var spriteNormal = new cc.Sprite(s_menuItem, cc.rect(0, 23 * 2, 115, 23)); + var spriteSelected = new cc.Sprite(s_menuItem, cc.rect(0, 23, 115, 23)); + var spriteDisabled = new cc.Sprite(s_menuItem, cc.rect(0, 0, 115, 23)); + + var item3 = new cc.MenuItemSprite(spriteNormal, spriteSelected, spriteDisabled, function(sender){ + cc.log("sprite clicked!"); + }, this); + this._disabledItem = item3; + this._disabledItem.enabled = false; + + var menu = new cc.Menu(item1, item2, item3); + menu.x = 0; + menu.y = 0; + + var s = director.getWinSize(); + + item1.x = s.width / 2 - 150; + item1.y = s.height / 2; + item2.x = s.width / 2 - 200; + item2.y = s.height / 2; + item3.x = s.width / 2; + item3.y = s.height / 2 - 100; + + var jump = cc.jumpBy(3, cc.p(400, 0), 50, 4); + item2.runAction(cc.sequence(jump, jump.reverse()).repeatForever()); + var spin1 = cc.rotateBy(3, 360); + var spin2 = spin1.clone(); + var spin3 = spin1.clone(); + + item1.runAction(spin1.repeatForever()); + item2.runAction(spin2.repeatForever()); + item3.runAction(spin3.repeatForever()); + + this.addChild(menu); + menu.x = 0; + menu.y = 0; + } +}); + +var MenuLayer4 = cc.Layer.extend({ + ctor:function () { + this._super(); + this.init(); + }, + init:function () { + //this._super(); + cc.MenuItemFont.setFontName("American Typewriter"); + cc.MenuItemFont.setFontSize(18); + + var title1 = new cc.MenuItemFont("Sound"); + title1.enabled = false; + cc.MenuItemFont.setFontName("Marker Felt"); + cc.MenuItemFont.setFontSize(34); + + // you can create a ToggleItem by passing the items + // and later setting the callback + var item1 = new cc.MenuItemToggle( + new cc.MenuItemFont("On"), + new cc.MenuItemFont("Off")); + item1.setCallback(this.onMenuCallback, this); + + cc.MenuItemFont.setFontName("American Typewriter"); + cc.MenuItemFont.setFontSize(18); + var title2 = new cc.MenuItemFont("Music"); + title2.enabled = false; + cc.MenuItemFont.setFontName("Marker Felt"); + cc.MenuItemFont.setFontSize(34); + + // or you can create a ToggleItem by passing the items + // an the callback at the last arguments. + var item2 = new cc.MenuItemToggle( + new cc.MenuItemFont("Off"), + new cc.MenuItemFont("On"), + this.onMenuCallback.bind(this) + ); + + cc.MenuItemFont.setFontName("American Typewriter"); + cc.MenuItemFont.setFontSize(18); + var title3 = new cc.MenuItemFont("Quality"); + title3.enabled = false; + cc.MenuItemFont.setFontName("Marker Felt"); + cc.MenuItemFont.setFontSize(34); + var item3 = new cc.MenuItemToggle( + new cc.MenuItemFont("High"), + new cc.MenuItemFont("Low"), + this.onMenuCallback, this + ); + + cc.MenuItemFont.setFontName("American Typewriter"); + cc.MenuItemFont.setFontSize(18); + var title4 = new cc.MenuItemFont("Orientation"); + title4.enabled = false; + cc.MenuItemFont.setFontName("Marker Felt"); + cc.MenuItemFont.setFontSize(34); + var item4 = new cc.MenuItemToggle( + new cc.MenuItemFont("Off"), + new cc.MenuItemFont("33%"), + new cc.MenuItemFont("66%"), + new cc.MenuItemFont("100%"), + this.onMenuCallback, this + ); + + // you can change the one of the items by doing this + item4.setSelectedIndex(2); + + cc.MenuItemFont.setFontName("Marker Felt"); + cc.MenuItemFont.setFontSize(34); + + var label = new cc.LabelBMFont("go back", s_bitmapFontTest3_fnt); + var back = new cc.MenuItemLabel(label, this.onBackCallback, this); + + var menu = new cc.Menu( + title1, title2, + item1, item2, + title3, title4, + item3, item4, + back); // 9 items. + + menu.alignItemsInColumns(2, 2, 2, 2, 1); + + this.addChild(menu); + + var winSize = director.getWinSize(); + menu.x = winSize.width / 2; + menu.y = winSize.height / 2; + }, + onMenuCallback:function (sender) { + cc.log("Callback called"); + }, + onBackCallback:function (sender) { + this.parent.switchTo(0); + } +}); + +var MenuBugsTest = cc.Layer.extend({ + ctor:function(){ + this._super(); + + var issue1410 = new cc.MenuItemFont("Issue 1410", this.onIssue1410MenuCallback, this); + var issue1410_2 = new cc.MenuItemFont("Issue 1410 #2", this.onIssue1410v2MenuCallback, this); + var back = new cc.MenuItemFont("Back", this.onBackMenuCallback, this); + + var menu = new cc.Menu(issue1410, issue1410_2, back); + this.addChild(menu); + menu.alignItemsVertically(); + + var s = cc.director.getWinSize(); + menu.x = s.width/2; + menu.y = s.height/2; + }, + + onIssue1410MenuCallback:function(sender){ + var menu = sender.parent; + menu.setEnabled(false); + menu.setEnabled(true); + + cc.log("NO CRASHES"); + }, + + onIssue1410v2MenuCallback:function(sender){ + var menu = sender.parent; + menu.setEnabled(true); + menu.setEnabled(false); + + cc.log("NO CRASHES. AND MENU SHOULD STOP WORKING"); + }, + + onBackMenuCallback:function(sender){ + this.parent.switchTo(0); + } +}); + +var RemoveMenuItemWhenMove = cc.Layer.extend({ + _item:null, + _touchListener: null, + ctor: function(){ + this._super(); + + var s = cc.director.getWinSize(); + + var label = new cc.LabelTTF("click item and move, should not crash", "Arial", 20); + label.x = s.width/2; + label.y = s.height - 30; + this.addChild(label); + + this._item = new cc.MenuItemFont("item 1"); + + var back = new cc.MenuItemFont("go back", this.goBack, this); + + var menu = new cc.Menu(this._item, back); + this.addChild(menu); + menu.alignItemsVertically(); + + menu.x = s.width/2; + menu.y = s.height/2; + }, + + onEnter: function() { + this._super(); + this._touchListener = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches: false, + onTouchBegan:function(touch, event){ + return true; + }, + onTouchMoved: function(touch, event){ + if (this._item){ + this._item.removeFromParent(true); + this._item = null; + } + }.bind(this) + }); + cc.eventManager.addListener(this._touchListener, -129); + }, + + onExit: function() { + this._super(); + cc.eventManager.removeListener(this._touchListener); + }, + + goBack: function(sender){ + this.parent.switchTo(0); + } +}); + +var MenuTestScene = TestScene.extend({ + runThisTest:function () { + var layer1 = new MenuLayerMainMenu(); + var layer2 = new MenuLayer2(); + var layer3 = new MenuLayer3(); + var layer4 = new MenuLayer4(); + var layer5 = new MenuBugsTest(); + var layer6 = new RemoveMenuItemWhenMove(); + + var layer = new cc.LayerMultiplex(layer1, layer2, layer3, layer4, layer5, layer6); + this.addChild(layer, 0); + + director.runScene(this); + } +}); + +var arrayOfMenuTest = [MenuTestScene]; diff --git a/tests/js-tests/src/MotionStreakTest/MotionStreakTest.js b/tests/js-tests/src/MotionStreakTest/MotionStreakTest.js new file mode 100644 index 0000000000..38cc58be7a --- /dev/null +++ b/tests/js-tests/src/MotionStreakTest/MotionStreakTest.js @@ -0,0 +1,269 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + Copyright (c) 2008-2009 Jason Booth + + 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. + ****************************************************************************/ + +var TAG_LABEL = 1; +var TAG_SPRITE1 = 2; +var TAG_SPRITE2 = 3; + +var sceneIdx = -1; + +var MotionStreakTest = cc.Layer.extend({ + _streak:null, + + title:function () { + return "No title"; + }, + subtitle:function () { + return ""; + }, + + onEnter:function () { + this._super(); + + var winSize = cc.director.getWinSize(); + + var label = new cc.LabelTTF(this.title(), "Arial", 32); + this.addChild(label, 0, TAG_LABEL); + label.x = winSize.width / 2; + label.y = winSize.height - 50; + + var subTitle = this.subtitle(); + if (subTitle.length > 0) { + var l = new cc.LabelTTF(subTitle, "Arial", 16); + this.addChild(l, 1); + l.x = winSize.width / 2; + l.y = winSize.height - 80; + } + + var item1 = new cc.MenuItemImage(s_pathB1, s_pathB2, this.backCallback, this); + var item2 = new cc.MenuItemImage(s_pathR1, s_pathR2, this.restartCallback, this); + var item3 = new cc.MenuItemImage(s_pathF1, s_pathF2, this.nextCallback, this); + + var menu = new cc.Menu(item1, item2, item3); + + menu.x = 0; + menu.y = 0; + item1.x = cc.visibleRect.center.x - item2.width * 2; + item1.y = cc.visibleRect.bottom.y + item2.height / 2; + item2.x = cc.visibleRect.center.x; + item2.y = cc.visibleRect.bottom.y + item2.height / 2; + item3.x = cc.visibleRect.center.x + item2.width * 2; + item3.y = cc.visibleRect.bottom.y + item2.height / 2; + + this.addChild(menu, 1); + + var itemMode = new cc.MenuItemToggle(new cc.MenuItemFont("Use High Quality Mode"), + new cc.MenuItemFont("Use Fast Mode"), this.modeCallback, this); + + var menuMode = new cc.Menu(itemMode); + this.addChild(menuMode); + + menuMode.x = winSize.width / 2; + menuMode.y = winSize.height / 4; + }, + + restartCallback:function (sender) { + var scene = new MotionStreakTestScene(); + scene.addChild(restartMotionAction()); + cc.director.runScene(scene); + }, + + nextCallback:function (sender) { + var scene = new MotionStreakTestScene(); + scene.addChild(nextMotionAction()); + cc.director.runScene(scene); + }, + + backCallback:function (sender) { + var scene = new MotionStreakTestScene; + scene.addChild(backMotionAction()); + cc.director.runScene(scene); + }, + + modeCallback:function (sender) { + var fastMode = this._streak.fastMode; + this._streak.fastMode = !fastMode; + } +}); + +var MotionStreakTest1 = MotionStreakTest.extend({ + _root:null, + _target:null, + + onEnter:function () { + this._super(); + + var winSize = cc.director.getWinSize(); + // the root object just rotates around + this._root = new cc.Sprite(s_pathR1); + this.addChild(this._root, 1); + this._root.x = winSize.width / 2; + this._root.y = winSize.height / 2; + + // the target object is offset from root, and the streak is moved to follow it + this._target = new cc.Sprite(s_pathR1); + this._root.addChild(this._target); + this._target.x = winSize.width / 4; + this._target.y = 0; + + // create the streak object and add it to the scene + this._streak = new cc.MotionStreak(2, 3, 32, cc.color.GREEN, s_streak); + this.addChild(this._streak); + // schedule an update on each frame so we can syncronize the streak with the target + this.schedule(this.onUpdate); + + var a1 = cc.rotateBy(2, 360); + + var action1 = a1.repeatForever(); + var motion = cc.moveBy(2, cc.p(100, 0)); + this._root.runAction(cc.sequence(motion, motion.reverse()).repeatForever()); + this._root.runAction(action1); + + var colorAction = cc.sequence( + cc.tintTo(0.2, 255, 0, 0), + cc.tintTo(0.2, 0, 255, 0), + cc.tintTo(0.2, 0, 0, 255), + cc.tintTo(0.2, 0, 255, 255), + cc.tintTo(0.2, 255, 255, 0), + cc.tintTo(0.2, 255, 0, 255), + cc.tintTo(0.2, 255, 255, 255) + ).repeatForever(); + + this._streak.runAction(colorAction); + }, + + onUpdate:function (delta) { + var pos = this._target.convertToWorldSpace(cc.p(this._target.width/2, 0)); + this._streak.x = pos.x; + this._streak.y = pos.y; + }, + + title:function () { + return "MotionStreak test 1"; + } +}); + +var MotionStreakTest2 = MotionStreakTest.extend({ + _root:null, + _target:null, + + onEnter:function () { + this._super(); + + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesMoved:function (touches, event) { + if (touches.length == 0) + return; + + var touch = touches[0]; + var touchLocation = touch.getLocation(); + var streak = event.getCurrentTarget()._streak; + streak.x = touchLocation.x; + streak.y = touchLocation.y; + } + }, this); + var winSize = cc.director.getWinSize(); + // create the streak object and add it to the scene + this._streak = new cc.MotionStreak(3, 3, 64, cc.color.WHITE, s_streak); + this.addChild(this._streak); + this._streak.x = winSize.width / 2; + this._streak.y = winSize.height / 2; + }, + + title:function () { + return "MotionStreak test"; + } +}); + +var Issue1358 = MotionStreakTest.extend({ + _center:null, + _radius:0, + _angle:0, + title:function () { + return "Issue 1358"; + }, + + subtitle:function () { + return "The tail should use the texture"; + }, + + onEnter:function () { + this._super(); + + // ask director the the window size + var size = cc.director.getWinSize(); + this._streak = new cc.MotionStreak(2.0, 1.0, 50.0, cc.color(255, 255, 0), s_image_icon); + this.addChild(this._streak); + + this._center = cc.p(size.width / 2, size.height / 2); + this._radius = size.width / 3; + this._angle = 0.0; + this.schedule(this.update, 0); + }, + + update:function (dt) { + this._angle += 1.0; + this._streak.x = this._center.x + Math.cos(this._angle / 180 * Math.PI) * this._radius; + this._streak.y = this._center.y + Math.sin(this._angle / 180 * Math.PI) * this._radius; + } +}); + +var arrayOfMotionStreakTest = [ + MotionStreakTest1, + MotionStreakTest2, + Issue1358 +]; + +var nextMotionAction = function () { + sceneIdx++; + sceneIdx = sceneIdx % arrayOfMotionStreakTest.length; + return new arrayOfMotionStreakTest[sceneIdx](); +}; + +var backMotionAction = function () { + sceneIdx--; + if (sceneIdx < 0) + sceneIdx += arrayOfMotionStreakTest.length; + return new arrayOfMotionStreakTest[sceneIdx](); +}; + +var restartMotionAction = function () { + return new arrayOfMotionStreakTest[sceneIdx](); +}; + +var MotionStreakTestScene = TestScene.extend({ + runThisTest:function (num) { + sceneIdx = (num || num == 0) ? (num - 1) : -1; + var pLayer = nextMotionAction(); + this.addChild(pLayer); + cc.director.runScene(this); + } +}); + + + diff --git a/tests/js-tests/src/NewEventManagerTest/NewEventManagerTest.js b/tests/js-tests/src/NewEventManagerTest/NewEventManagerTest.js new file mode 100644 index 0000000000..55e57a0aff --- /dev/null +++ b/tests/js-tests/src/NewEventManagerTest/NewEventManagerTest.js @@ -0,0 +1,1301 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 eventDispatcherSceneIdx = -1; + +var EventDispatcherTestDemo = BaseTestLayer.extend({ + ctor:function() { + this._super(cc.color(0,0,0,255), cc.color(160,32,32,255)); + }, + + title:function () { + return "No title"; + }, + + subtitle:function () { + return ""; + }, + + onBackCallback:function (sender) { + var s = new EventDispatcherTestScene(); + s.addChild(previousDispatcherTest()); + director.runScene(s); + }, + + onRestartCallback:function (sender) { + var s = new EventDispatcherTestScene(); + s.addChild(restartDispatcherTest()); + director.runScene(s); + }, + + onNextCallback:function (sender) { + var s = new EventDispatcherTestScene(); + s.addChild(nextDispatcherTest()); + director.runScene(s); + }, + // varmation + numberOfPendingTests:function() { + return ( (arrayOfEventDispatcherTest.length-1) - eventDispatcherSceneIdx ); + }, + + getTestNumber:function() { + return eventDispatcherSceneIdx; + } +}); + +var TouchableSpriteTest = EventDispatcherTestDemo.extend({ + onEnter:function(){ + //----start0----onEnter + this._super(); + + var origin = director.getVisibleOrigin(); + var size = director.getVisibleSize(); + + var containerForSprite1 = new cc.Node(); + var sprite1 = new cc.Sprite("res/Images/CyanSquare.png"); + sprite1.setPosition(origin.x + size.width/2 - 80, origin.y + size.height/2 + 80); + containerForSprite1.addChild(sprite1); + this.addChild(containerForSprite1, 10); + + var sprite2 = new cc.Sprite("res/Images/MagentaSquare.png"); + sprite2.setPosition(origin.x + size.width/2, origin.y + size.height/2); + this.addChild(sprite2, 20); + + var sprite3 = new cc.Sprite("res/Images/YellowSquare.png"); + sprite3.setPosition(0,0); + sprite2.addChild(sprite3, 1); + + // Make sprite1 touchable + var listener1 = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches: true, + onTouchBegan: function (touch, event) { + var target = event.getCurrentTarget(); + + var locationInNode = target.convertToNodeSpace(touch.getLocation()); + var s = target.getContentSize(); + var rect = cc.rect(0, 0, s.width, s.height); + + if (cc.rectContainsPoint(rect, locationInNode)) { + cc.log("sprite began... x = " + locationInNode.x + ", y = " + locationInNode.y); + target.opacity = 180; + return true; + } + return false; + }, + onTouchMoved: function (touch, event) { + var target = event.getCurrentTarget(); + var delta = touch.getDelta(); + target.x += delta.x; + target.y += delta.y; + }, + onTouchEnded: function (touch, event) { + var target = event.getCurrentTarget(); + cc.log("sprite onTouchesEnded.. "); + target.setOpacity(255); + if (target == sprite2) { + containerForSprite1.setLocalZOrder(100); + } else if (target == sprite1) { + containerForSprite1.setLocalZOrder(0); + } + } + }); + + cc.eventManager.addListener(listener1, sprite1); + cc.eventManager.addListener(listener1.clone(), sprite2); + cc.eventManager.addListener(listener1.clone(), sprite3); + var selfPointer = this; + + var removeAllTouchItem = new cc.MenuItemFont("Remove All Touch Listeners", function(senderItem){ + senderItem.setString("Only Next item could be clicked"); + + cc.eventManager.removeListeners(cc.EventListener.TOUCH_ONE_BY_ONE); + + var nextItem = new cc.MenuItemFont("Next", function(sender){ + selfPointer.onNextCallback(); + }); + + nextItem.fontSize = 16; + nextItem.x = cc.visibleRect.right.x -100; + nextItem.y = cc.visibleRect.right.y - 30; + + var menu2 = new cc.Menu(nextItem); + menu2.setPosition(0, 0); + menu2.setAnchorPoint(0, 0); + selfPointer.addChild(menu2); + }); + + removeAllTouchItem.fontSize = 16; + removeAllTouchItem.x = cc.visibleRect.right.x -removeAllTouchItem.width/2-20; + removeAllTouchItem.y = cc.visibleRect.right.y; + + var menu = new cc.Menu(removeAllTouchItem); + menu.setPosition(0, 0); + menu.setAnchorPoint(0, 0); + this.addChild(menu); + //----end0---- + }, + + title:function(){ + return "Touchable Sprite Test"; + }, + + subtitle:function(){ + return "Please drag the blocks"; + } +}); + +TouchableSpriteTest.create = function(){ + var test = new TouchableSpriteTest(); + test.init(); + return test; +}; + +var TouchableSprite = cc.Sprite.extend({ + _listener:null, + _fixedPriority:0, + _removeListenerOnTouchEnded: false, + + ctor: function(priority){ + this._super(); + this._fixedPriority = priority || 0; + }, + + setPriority:function(fixedPriority){ + this._fixedPriority = fixedPriority; + }, + + onEnter:function(){ + this._super(); + + var selfPointer = this; + var listener = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches: true, + onTouchBegan: function (touch, event) { + var locationInNode = selfPointer.convertToNodeSpace(touch.getLocation()); + var s = selfPointer.getContentSize(); + var rect = cc.rect(0, 0, s.width, s.height); + + if (cc.rectContainsPoint(rect, locationInNode)) { + selfPointer.setColor(cc.color.RED); + return true; + } + return false; + }, + onTouchMoved: function (touch, event) { + //this.setPosition(this.getPosition() + touch.getDelta()); + }, + onTouchEnded: function (touch, event) { + selfPointer.setColor(cc.color.WHITE); + if(selfPointer._removeListenerOnTouchEnded) { + cc.eventManager.removeListener(selfPointer._listener); + selfPointer._listener = null; + } + } + }); + + if(this._fixedPriority != 0) + cc.eventManager.addListener(listener, this._fixedPriority); + else + cc.eventManager.addListener(listener, this); + this._listener = listener; + }, + + onExit: function(){ + this._listener && cc.eventManager.removeListener(this._listener); + this._super(); + }, + + removeListenerOnTouchEnded: function(toRemove){ + this._removeListenerOnTouchEnded = toRemove; + }, + + getListener: function() { + return this._listener; + } +}); + +TouchableSprite.create = function(priority){ + var test = new TouchableSprite(priority); + test.init(); + return test; +}; + +var FixedPriorityTest = EventDispatcherTestDemo.extend({ + onEnter:function(){ + //----start1----onEnter + this._super(); + + var origin = director.getVisibleOrigin(); + var size = director.getVisibleSize(); + + var sprite1 = TouchableSprite.create(30); + sprite1.setTexture("res/Images/CyanSquare.png"); + sprite1.x = origin.x + size.width / 2 - 80; + sprite1.y = origin.y + size.height / 2 + 40; + this.addChild(sprite1, 10); + + var sprite2 = TouchableSprite.create(20); + sprite2.setTexture("res/Images/MagentaSquare.png"); + sprite2.x = origin.x + size.width / 2; + sprite2.y = origin.y + size.height / 2; + this.addChild(sprite2, 20); + + var sprite3 = TouchableSprite.create(10); + sprite3.setTexture("res/Images/YellowSquare.png"); + sprite3.x = 0; + sprite3.y = 0; + sprite2.addChild(sprite3, 1); + //----end1---- + }, + + title:function(){ + return "Fixed priority test"; + }, + + subtitle:function(){ + return "Fixed Priority, Blue: 30, Red: 20, Yellow: 10\n The lower value the higher priority will be."; + } +}); + +FixedPriorityTest.create = function(){ + var test = new FixedPriorityTest(); + test.init(); + return test; +}; + +var RemoveListenerWhenDispatching = EventDispatcherTestDemo.extend({ + onEnter:function(){ + //----start2----onEnter + this._super(); + + var origin = director.getVisibleOrigin(); + var size = director.getVisibleSize(); + + var sprite1 = new cc.Sprite("res/Images/CyanSquare.png"); + sprite1.setPosition(origin.x + size.width/2, origin.y + size.height/2); + this.addChild(sprite1, 10); + + // Make sprite1 touchable + var listener1 = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches: true, + onTouchBegan: function (touch, event) { + var locationInNode = sprite1.convertToNodeSpace(touch.getLocation()); + var s = sprite1.getContentSize(); + var rect = cc.rect(0, 0, s.width, s.height); + + if (cc.rectContainsPoint(rect, locationInNode)) { + sprite1.setColor(cc.color.RED); + return true; + } + return false; + }, + onTouchEnded: function (touch, event) { + sprite1.setColor(cc.color.WHITE); + } + }); + this.setUserObject(listener1); + + cc.eventManager.addListener(listener1, sprite1); + + var statusLabel = new cc.LabelTTF("The sprite could be touched!", "", 20); + statusLabel.setPosition(origin.x + size.width/2, origin.y + size.height-90 ); + this.addChild(statusLabel); + + var enable = true; + + // Enable/Disable item + var toggleItem = new cc.MenuItemToggle(new cc.MenuItemFont("Enabled"), new cc.MenuItemFont("Disabled"), + function (sender) { + if (enable) { + cc.eventManager.removeListener(listener1); + statusLabel.setString("The sprite could not be touched!"); + enable = false; + } else { + cc.eventManager.addListener(listener1, sprite1); + statusLabel.setString("The sprite could be touched!"); + enable = true; + } + }); + + toggleItem.setPosition(origin.x + size.width/2, origin.y + 80); + var menu = new cc.Menu(toggleItem); + menu.setPosition(0, 0); + menu.setAnchorPoint(0, 0); + this.addChild(menu, 1); + //----end2---- + }, + + title:function(){ + return "Add and remove listener\n when dispatching event"; + }, + + subtitle:function(){ + return ""; + } +}); + +RemoveListenerWhenDispatching.create = function(){ + var test = new RemoveListenerWhenDispatching(); + test.init(); + return test; +}; + +var CustomEventTest = EventDispatcherTestDemo.extend({ + _listener1: null, + _listener2: null, + _item1Count: 0, + _item2Count: 0, + + onEnter:function(){ + //----start3----onEnter + this._super(); + + var origin = director.getVisibleOrigin(), size = director.getVisibleSize(), selfPointer = this; + + cc.MenuItemFont.setFontSize(20); + + var statusLabel = new cc.LabelTTF("No custom event 1 received!", "", 20); + statusLabel.setPosition(origin.x + size.width / 2, origin.y + size.height - 90); + this.addChild(statusLabel); + + this._listener1 = cc.EventListener.create({ + event: cc.EventListener.CUSTOM, + eventName: "game_custom_event1", + callback: function(event){ + statusLabel.setString("Custom event 1 received, " + event.getUserData() + " times"); + } + }); + cc.eventManager.addListener(this._listener1, 1); + + var sendItem = new cc.MenuItemFont("Send Custom Event 1", function(sender){ + ++selfPointer._item1Count; + var event = new cc.EventCustom("game_custom_event1"); + event.setUserData(selfPointer._item1Count.toString()); + cc.eventManager.dispatchEvent(event); + }); + sendItem.setPosition(origin.x + size.width/2, origin.y + size.height/2); + + var statusLabel2 = new cc.LabelTTF("No custom event 2 received!", "", 20); + statusLabel2.setPosition(origin.x + size.width/2, origin.y + size.height-120); + this.addChild(statusLabel2); + + this._listener2 = cc.EventListener.create({ + event: cc.EventListener.CUSTOM, + eventName: "game_custom_event2", + callback: function(event){ + statusLabel2.setString("Custom event 2 received, " + event.getUserData() + " times"); + } + }); + + cc.eventManager.addListener(this._listener2, 1); + var sendItem2 = new cc.MenuItemFont("Send Custom Event 2", function(sender){ + ++selfPointer._item2Count; + var event = new cc.EventCustom("game_custom_event2"); + event.setUserData(selfPointer._item2Count.toString()); + cc.eventManager.dispatchEvent(event); + }); + sendItem2.setPosition(origin.x + size.width/2, origin.x + size.height/2 - 40); + + var menu = new cc.Menu(sendItem, sendItem2); + menu.setPosition(0, 0); + menu.setAnchorPoint(0, 0); + this.addChild(menu, 1); + //----end3---- + }, + + onExit:function(){ + //----start3----onExit + cc.eventManager.removeListener(this._listener1); + cc.eventManager.removeListener(this._listener2); + this._super(); + //----end3---- + }, + + title:function(){ + return "Send custom event"; + }, + + subtitle:function(){ + return ""; + } +}); + +CustomEventTest.create = function(){ + var test = new CustomEventTest(); + test.init(); + return test; +}; + +var LabelKeyboardEventTest = EventDispatcherTestDemo.extend({ + onEnter:function(){ + //----start4----onEnter + this._super(); + + var origin = director.getVisibleOrigin(); + var size = director.getVisibleSize(); + + var statusLabel = new cc.LabelTTF("No keyboard event received!", "", 20); + statusLabel.setPosition(origin.x + size.width/2, origin.x + size.height/2); + this.addChild(statusLabel); + + var that = this; + cc.eventManager.addListener({ + event: cc.EventListener.KEYBOARD, + onKeyPressed: function(keyCode, event){ + var label = event.getCurrentTarget(); + label.setString("Key " + (cc.sys.isNative ? that.getNativeKeyName(keyCode) : String.fromCharCode(keyCode) ) + "(" + keyCode.toString() + ") was pressed!"); + }, + onKeyReleased: function(keyCode, event){ + var label = event.getCurrentTarget(); + label.setString("Key " + (cc.sys.isNative ? that.getNativeKeyName(keyCode) : String.fromCharCode(keyCode) ) + "(" + keyCode.toString() + ") was released!"); + } + }, statusLabel); + //----end4---- + }, + + getNativeKeyName:function(keyCode) { + var allCode = Object.getOwnPropertyNames(cc.KEY); + var keyName = ""; + for(var x in allCode){ + if(cc.KEY[allCode[x]] == keyCode){ + keyName = allCode[x]; + break; + } + } + return keyName; + }, + + title:function(){ + return "Label Receives Keyboard Event"; + }, + + subtitle:function(){ + return "Please click keyboard\n(Only available on Desktop and Android)"; + } +}); + +LabelKeyboardEventTest.create = function(){ + var test = new LabelKeyboardEventTest(); + test.init(); + return test; +}; + +var SpriteAccelerationEventTest = EventDispatcherTestDemo.extend({ + onEnter:function(){ + //----start5----onEnter + this._super(); + + var origin = director.getVisibleOrigin(); + var size = director.getVisibleSize(); + + cc.inputManager.setAccelerometerEnabled(true); + + var sprite = new cc.Sprite("res/Images/ball.png"); + sprite.setPosition(origin.x + size.width/2, origin.y + size.height/2); + this.addChild(sprite); + + cc.eventManager.addListener({ + event: cc.EventListener.ACCELERATION, + callback: function(acc, event){ + var target = event.getCurrentTarget(); + var ballSize = target.getContentSize(); + var ptNow = target.getPosition(); + + //cc.log("acc: x = " + acc.x + ", y = " + acc.y); + + target.x = SpriteAccelerationEventTest._fix_pos(ptNow.x + acc.x * 9.81, + (cc.visibleRect.left.x + ballSize.width / 2.0), (cc.visibleRect.right.x - ballSize.width / 2.0)); + target.y = SpriteAccelerationEventTest._fix_pos(ptNow.y + acc.y * 9.81, + (cc.visibleRect.bottom.y + ballSize.height / 2.0), (cc.visibleRect.top.y - ballSize.height / 2.0)); + } + }, sprite); + //----end5---- + }, + + onExit:function(){ + //----start5----onEnter + cc.inputManager.setAccelerometerEnabled(false); + this._super(); + //----end---- + }, + + title:function(){ + return "Sprite Receives Acceleration Event"; + }, + + subtitle:function(){ + return "Please move your device\n(Only available on mobile)"; + } +}); + +SpriteAccelerationEventTest._fix_pos = function(pos, min, max){ + var ret = pos; + if(pos < min) + ret = min; + else if(pos > max) + ret = max; + return ret; +}; + +SpriteAccelerationEventTest.create = function(){ + var test = new SpriteAccelerationEventTest(); + test.init(); + return test; +}; + +var RemoveAndRetainNodeTest = EventDispatcherTestDemo.extend({ + _sprite:null, + _spriteSaved:false, + + onEnter:function(){ + //----start6----onEnter + this._super(); + + var origin = director.getVisibleOrigin(); + var size = director.getVisibleSize(); + + this._sprite = new cc.Sprite("res/Images/CyanSquare.png"); + this._sprite.setPosition(origin.x + size.width/2, origin.y + size.height/2); + this.addChild(this._sprite, 10); + + // Make sprite1 touchable + var listener1 = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches: true, + onTouchBegan: function (touch, event) { + var target = event.getCurrentTarget(); + + var locationInNode = target.convertToNodeSpace(touch.getLocation()); + var s = target.getContentSize(); + var rect = cc.rect(0, 0, s.width, s.height); + + if (cc.rectContainsPoint(rect, locationInNode)) { + cc.log("sprite began... x = " + locationInNode.x + ", y = " + locationInNode.y); + target.opacity = 180; + return true; + } + return false; + }, + onTouchMoved: function (touch, event) { + var target = event.getCurrentTarget(); + var delta = touch.getDelta(); + target.x += delta.x; + target.y += delta.y; + }, + onTouchEnded: function (touch, event) { + var target = event.getCurrentTarget(); + cc.log("sprite onTouchesEnded.. "); + target.opacity = 255; + } + }); + cc.eventManager.addListener(listener1, this._sprite); + + this.runAction(cc.sequence(cc.delayTime(5.0), + cc.callFunc(function () { + this._spriteSaved = true; + this._sprite.retain(); + this._sprite.removeFromParent(); + }, this), + cc.delayTime(5.0), + cc.callFunc(function () { + this._spriteSaved = false; + this.addChild(this._sprite); + if(!cc.sys.isNative) + cc.eventManager.addListener(listener1, this._sprite); + this._sprite.release(); + }, this) + )); + //----end6---- + }, + + onExit:function(){ + //----start6----onExit + this._super(); + if (this._spriteSaved) + this._sprite.release(); + //----end6---- + }, + + title:function(){ + return "RemoveAndRetainNodeTest"; + }, + + subtitle:function(){ + return "Sprite should be removed after 5s, add to scene again after 5s"; + } +}); + +RemoveAndRetainNodeTest.create = function(){ + var test = new RemoveAndRetainNodeTest(); + test.init(); + return test; +}; + +var RemoveListenerAfterAddingTest = EventDispatcherTestDemo.extend({ + onEnter:function(){ + //----start7----onEnter + this._super(); + var selfPointer = this; + var item1 = new cc.MenuItemFont("Click Me 1", function(sender){ + var listener = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + onTouchBegan: function (touch, event) { + cc.assert(false, "Should not come here!"); + return true; + } + }); + cc.eventManager.addListener(listener, -1); + cc.eventManager.removeListener(listener); + }); + var vCenter = cc.visibleRect.center; + item1.setPosition(vCenter.x, vCenter.y + 80); + + var addNextButton = function(){ + var next = new cc.MenuItemFont("Please Click Me To Reset!", function(sender){ + selfPointer.onRestartCallback(); + }); + next.setPosition(vCenter.x, vCenter.y - 40); + + var menu = new cc.Menu(next); + menu.setPosition(cc.visibleRect.bottomLeft); + menu.setAnchorPoint(0,0); + selfPointer.addChild(menu); + }; + + var item2 = new cc.MenuItemFont("Click Me 2", function(sender){ + var listener = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + onTouchBegan: function(touch, event){ + cc.assert("Should not come here!"); + return true; + } + }); + cc.eventManager.addListener(listener, -1); + cc.eventManager.removeListeners(cc.EventListener.TOUCH_ONE_BY_ONE); + addNextButton(); + }, this); + item2.setPosition(vCenter.x, vCenter.y + 40); + + var item3 = new cc.MenuItemFont("Click Me 3", function(sender){ + var listener = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + onTouchBegan: function(touch, event){ + cc.assert(false, "Should not come here!"); + return true; + } + }); + cc.eventManager.addListener(listener, -1); + cc.eventManager.removeAllListeners(); + addNextButton(); + }, this); + item3.setPosition(cc.visibleRect.center); + + var menu = new cc.Menu(item1, item2, item3); + menu.setPosition(cc.visibleRect.bottomLeft); + menu.setAnchorPoint(0, 0); + this.addChild(menu); + //----end7---- + }, + + title:function(){ + return "RemoveListenerAfterAddingTest"; + }, + + subtitle:function(){ + return "Should not crash!"; + } +}); + +RemoveListenerAfterAddingTest.create = function(){ + var test = new RemoveListenerAfterAddingTest(); + test.init(); + return test; +}; + +var DirectorEventTest = EventDispatcherTestDemo.extend({ + _count1:0, + _count2:0, + _count3:0, + _count4:0, + _label1:null, + _label2:null, + _label3:null, + _label4:null, + _event1:null, + _event2:null, + _event3:null, + _event4:null, + _time:0, + + onEnter:function(){ + //----start8----onEnter + this._super(); + var s = director.getWinSize(), selfPointer = this; + + this._label1 = new cc.LabelTTF("Update: 0", "Arial", 20); + this._label1.setPosition(80,s.height/2 + 60); + this.addChild(this._label1); + + this._label2 = new cc.LabelTTF("Visit: 0", "Arial", 20); + this._label2.setPosition(80,s.height/2 + 20); + this.addChild(this._label2); + + this._label3 = new cc.LabelTTF("Draw: 0", "Arial", 20); + this._label3.setPosition(80,s.height/2 - 20); + this.addChild(this._label3); + + this._label4 = new cc.LabelTTF("Projection: 0", "Arial", 20); + this._label4.setPosition(80,s.height/2 - 60); + this.addChild(this._label4); + + var dispatcher = cc.eventManager; + + this._event1 = dispatcher.addCustomListener(cc.Director.EVENT_AFTER_UPDATE, this.onEvent1.bind(this)); + this._event2 = dispatcher.addCustomListener(cc.Director.EVENT_AFTER_VISIT, this.onEvent2.bind(this)); + this._event3 = dispatcher.addCustomListener(cc.Director.EVENT_AFTER_DRAW, function(event) { + selfPointer._label3.setString("Draw: " + selfPointer._count3++); + }); + this._event4 = dispatcher.addCustomListener(cc.Director.EVENT_PROJECTION_CHANGED, function(event) { + selfPointer._label4.setString("Projection: " + selfPointer._count4++); + }); + + this._event1.retain(); + this._event2.retain(); + this._event3.retain(); + this._event4.retain(); + + this.scheduleUpdate(); + }, + + onExit:function(){ + //----start8----onExit + this._super(); + + var eventManager = cc.eventManager; + eventManager.removeListener(this._event1); + eventManager.removeListener(this._event2); + eventManager.removeListener(this._event3); + eventManager.removeListener(this._event4); + + this._event1.release(); + this._event2.release(); + this._event3.release(); + this._event4.release(); + //----end8---- + }, + + update:function(dt){ + //----start8----update + this._time += dt; + if(this._time > 0.5) { + cc.director.setProjection(cc.Director.PROJECTION_2D); + this._time = 0; + } + //----end8---- + }, + + onEvent1:function(event){ + //----start8----onExit + this._label1.setString("Update: " + this._count1++); + //----end8---- + }, + + onEvent2:function(event){ + //----start8----onExit + this._label2.setString("Visit: " + this._count2++); + //----end8---- + }, + + title:function(){ + return "Testing Director Events"; + }, + + subtitle:function(){ + return "after visit, after draw, after update, projection changed"; + } +}); + +DirectorEventTest.create = function(){ + var test = new DirectorEventTest(); + test.init(); + return test; +}; + +var GlobalZTouchTest = EventDispatcherTestDemo.extend({ + _sprite:null, + _accum:null, + + ctor: function(){ + this._super(); + + var listener = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches:true, + onTouchBegan: function(touch, event){ + var target = event.getCurrentTarget(); + + var locationInNode = target.convertToNodeSpace(touch.getLocation()); + var s = target.getContentSize(); + var rect = cc.rect(0, 0, s.width, s.height); + + if (cc.rectContainsPoint(rect, locationInNode)) { + cc.log("sprite began... x = %f, y = %f", locationInNode.x, locationInNode.y); + target.setOpacity(180); + return true; + } + return false; + }, + onTouchMoved: function(touch, event){ + var target = event.getCurrentTarget(), delta = touch.getDelta(); + target.x += delta.x; + target.y += delta.y; + }, + onTouchEnded: function(touch, event){ + cc.log("sprite onTouchesEnded.. "); + event.getCurrentTarget().setOpacity(255); + } + }); + + var SPRITE_COUNT = 8, sprite; + for (var i = 0; i < SPRITE_COUNT; i++) { + if(i==4) { + sprite = new cc.Sprite("res/Images/CyanSquare.png"); + this._sprite = sprite; + this._sprite.setGlobalZOrder(-1); + } else + sprite = new cc.Sprite("res/Images/YellowSquare.png"); + + cc.eventManager.addListener(listener.clone(), sprite); + this.addChild(sprite); + + var visibleSize = cc.director.getVisibleSize(); + sprite.x = cc.visibleRect.left.x + visibleSize.width / (SPRITE_COUNT - 1) * i; + sprite.y = cc.visibleRect.center.y; + } + + this.scheduleUpdate(); + }, + + update: function(dt){ + this._accum += dt; + if( this._accum > 2.0) { + var z = this._sprite.getGlobalZOrder(); + this._sprite.setGlobalZOrder(-z); + this._accum = 0; + } + }, + + title: function(){ + return "Global Z Value, Try touch blue sprite"; + }, + + subtitle: function() { + return "Blue Sprite should change go from foreground to background"; + } +}); + +GlobalZTouchTest.create = function(){ + var test = new GlobalZTouchTest(); + test.init(); + return test; +}; + +var StopPropagationTest = EventDispatcherTestDemo.extend({ + ctor:function(){ + //----start9----ctor + this._super(); + + var touchOneByOneListener = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches:true, + onTouchBegan: function(touch, event){ + // Skip if don't touch top half screen. + if (!this._isPointInTopHalfAreaOfScreen(touch.getLocation())) + return false; + + var target = event.getCurrentTarget(); + if(target.getTag() != StopPropagationTest._TAG_BLUE_SPRITE) + cc.log("Yellow blocks shouldn't response event."); + + if (this._isPointInNode(touch.getLocation(), target)) { + target.setOpacity(180); + return true; + } + + // Stop propagation, so yellow blocks will not be able to receive event. + event.stopPropagation(); + return false; + }.bind(this), + onTouchEnded: function(touch, event){ + event.getCurrentTarget().setOpacity(255); + } + }); + + var touchAllAtOnceListener = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesBegan: function(touches, event){ + // Skip if don't touch top half screen. + if (this._isPointInTopHalfAreaOfScreen(touches[0].getLocation())) + return; + + var target = event.getCurrentTarget(); + if(target.getTag() != StopPropagationTest._TAG_BLUE_SPRITE2) + cc.log("Yellow blocks shouldn't response event."); + + if (this._isPointInNode(touches[0].getLocation(), target)) + target.setOpacity(180); + // Stop propagation, so yellow blocks will not be able to receive event. + event.stopPropagation(); + }.bind(this), + onTouchesEnded: function(touches, event){ + // Skip if don't touch top half screen. + if (this._isPointInTopHalfAreaOfScreen(touches[0].getLocation())) + return; + + var target = event.getCurrentTarget(); + if(target.getTag() != StopPropagationTest._TAG_BLUE_SPRITE2) + cc.log("Yellow blocks shouldn't response event."); + + if (this._isPointInNode(touches[0].getLocation(), target)) + target.setOpacity(255); + // Stop propagation, so yellow blocks will not be able to receive event. + event.stopPropagation(); + }.bind(this) + }); + + var keyboardEventListener = cc.EventListener.create({ + event: cc.EventListener.KEYBOARD, + onKeyPressed: function(key, event){ + var target = event.getCurrentTarget(); + if(!(target.getTag() == StopPropagationTest._TAG_BLUE_SPRITE || target.getTag() == StopPropagationTest._TAG_BLUE_SPRITE2)){ + cc.log("Yellow blocks shouldn't response event."); + } + // Stop propagation, so yellow blocks will not be able to receive event. + event.stopPropagation(); + } + }); + + var SPRITE_COUNT = 8, sprite1, sprite2; + + for (var i = 0; i < SPRITE_COUNT; i++) { + if(i==4) { + sprite1 = new cc.Sprite("res/Images/CyanSquare.png"); + sprite1.setTag(StopPropagationTest._TAG_BLUE_SPRITE); + this.addChild(sprite1, 100); + + sprite2 = new cc.Sprite("res/Images/CyanSquare.png"); + sprite2.setTag(StopPropagationTest._TAG_BLUE_SPRITE2); + this.addChild(sprite2, 100); + } else { + sprite1 = new cc.Sprite("res/Images/YellowSquare.png"); + this.addChild(sprite1, 0); + sprite2 = new cc.Sprite("res/Images/YellowSquare.png"); + this.addChild(sprite2, 0); + } + + + cc.eventManager.addListener(touchOneByOneListener.clone(), sprite1); + cc.eventManager.addListener(keyboardEventListener.clone(), sprite1); + + cc.eventManager.addListener(touchAllAtOnceListener.clone(), sprite2); + cc.eventManager.addListener(keyboardEventListener.clone(), sprite2); + + + var visibleSize = cc.director.getVisibleSize(); + sprite1.x = cc.visibleRect.left.x + visibleSize.width / (SPRITE_COUNT - 1) * i; + sprite1.y = cc.visibleRect.center.y + sprite2.getContentSize().height / 2 + 10; + sprite2.x = cc.visibleRect.left.x + visibleSize.width / (SPRITE_COUNT - 1) * i; + sprite2.y = cc.visibleRect.center.y - sprite2.getContentSize().height / 2 - 10; + } + //----end9---- + }, + + _isPointInNode: function (pt, node) { + //----start9----_isPointInNode + var s = node.getContentSize(); + return cc.rectContainsPoint(cc.rect(0, 0, s.width, s.height), node.convertToNodeSpace(pt)); + //----end9---- + }, + + _isPointInTopHalfAreaOfScreen: function(pt){ + //----start9----_isPointInTopHalfAreaOfScreen + var winSize = cc.director.getWinSize(); + return (pt.y >= winSize.height/2); + //----end9---- + }, + + title: function(){ + return "Stop Propagation Test"; + }, + + subtitle: function() { + return "Shouldn't crash and only blue block could be clicked"; + } +}); +StopPropagationTest._TAG_BLUE_SPRITE = 101; +StopPropagationTest._TAG_BLUE_SPRITE2 = 102; + +StopPropagationTest.create = function(){ + var test = new StopPropagationTest(); + test.init(); + return test; +}; + +var Issue4160 = EventDispatcherTestDemo.extend({ + ctor: function(){ + //----start10----ctor + this._super(); + var origin = cc.director.getVisibleOrigin(); + var size = cc.director.getVisibleSize(); + + var sprite1 = TouchableSprite.create(-30); + sprite1.setTexture("res/Images/CyanSquare.png"); + sprite1.x = origin.x + (size.width/2) - 80; + sprite1.y = origin.y + (size.height/2) + 40; + this.addChild(sprite1, 5); + + var sprite2 = TouchableSprite.create(-20); + sprite2.setTexture("res/Images/MagentaSquare.png"); + sprite2.removeListenerOnTouchEnded(true); + sprite2.x = origin.x + (size.width/2); + sprite2.y = origin.y + (size.height/2); + this.addChild(sprite2, 10); + + var sprite3 = TouchableSprite.create(-10); + sprite3.setTexture("res/Images/YellowSquare.png"); + sprite3.x = 0; + sprite3.y = 0; + sprite2.addChild(sprite3, 21); + //----end10---- + }, + + title: function(){ + return "Issue 4160: Out of range exception"; + }, + + subtitle: function() { + return "Touch the red block twice \n should not crash and the red one couldn't be touched"; + } +}); + +Issue4160.create = function(){ + var test = new Issue4160(); + test.init(); + return test; +}; + +var PauseResumeTargetTest = EventDispatcherTestDemo.extend({ + ctor: function () { + //----start11----ctor + this._super(); + + var origin = cc.director.getVisibleOrigin(); + var size = cc.director.getVisibleSize(); + + var sprite1 = TouchableSprite.create(); + sprite1.setTexture("res/Images/CyanSquare.png"); + sprite1.x = origin.x + size.width / 2 - 180; + sprite1.y = origin.y + size.height / 2 + 40; + this.addChild(sprite1, 10); + + var sprite2 = TouchableSprite.create(); + sprite2.setTexture("res/Images/MagentaSquare.png"); + sprite2.x = origin.x + size.width / 2 - 100; + sprite2.y = origin.y + size.height / 2; + this.addChild(sprite2, 1); + + var sprite3 = TouchableSprite.create(100); // Sprite3 uses fixed priority listener + sprite3.setTexture("res/Images/YellowSquare.png"); + sprite3.x = 0; + sprite3.y = 0; + sprite2.addChild(sprite3, -1); + + var _this = this; + var popup = new cc.MenuItemFont("Popup", function(sender){ + sprite3.getListener().setEnabled(false); + cc.eventManager.pauseTarget(_this, true); + var colorLayer = new cc.LayerColor(cc.color(0, 0, 255, 100)); + _this.addChild(colorLayer, 999); //set colorLayer to top + + // Add the button + var backgroundButton = new cc.Scale9Sprite(s_extensions_button); + var backgroundHighlightedButton = new cc.Scale9Sprite(s_extensions_buttonHighlighted); + + var titleButton = new cc.LabelTTF("Close Dialog", "Marker Felt", 26); + titleButton.color = cc.color(159, 168, 176); + + var controlButton = new cc.ControlButton(titleButton, backgroundButton); + controlButton.setBackgroundSpriteForState(backgroundHighlightedButton, cc.CONTROL_STATE_HIGHLIGHTED); + controlButton.setTitleColorForState(cc.color.WHITE, cc.CONTROL_STATE_HIGHLIGHTED); + + controlButton.anchorX = 0.5; + controlButton.anchorY = 1; + controlButton.x = size.width / 2 + 50; + controlButton.y = size.height / 2; + colorLayer.addChild(controlButton, 1); + controlButton.addTargetWithActionForControlEvents(this, function(){ + colorLayer.removeFromParent(); + cc.eventManager.resumeTarget(_this, true); + sprite3.getListener().setEnabled(true); + }, cc.CONTROL_EVENT_TOUCH_UP_INSIDE); + + // Add the black background + var background = new cc.Scale9Sprite(s_extensions_buttonBackground); + background.width = 300; + background.height = 170; + background.x = size.width / 2.0 + 50; + background.y = size.height / 2.0; + colorLayer.addChild(background); + }); + + popup.setAnchorPoint(1,0.5); + popup.setPosition(cc.visibleRect.right); + + var menu = new cc.Menu(popup); + menu.setAnchorPoint(0, 0); + menu.setPosition(0, 0); + + this.addChild(menu); + //----end11---- + }, + + title: function(){ + return "PauseResumeTargetTest"; + }, + + subtitle: function() { + return "Yellow block uses fixed priority"; + } +}); + +PauseResumeTargetTest.create = function(){ + var test = new Issue4160(); + test.init(); + return test; +}; + +var Issue9898 = EventDispatcherTestDemo.extend({ + + title: function(){ + return "Issue9898"; + }, + + subtitle: function(){ + return "Should not crash if dispatch event after remove\n event listener in callback"; + }, + + ctor: function(){ + this._super(); + //----start12----ctor + + var origin = cc.director.getVisibleOrigin(); + var size = cc.director.getVisibleSize(); + + var node = new cc.Node(); + this.addChild(node); + + var _listener = cc.EventListener.create({ + event: cc.EventListener.CUSTOM, + eventName: "Issue9898", + callback: function(event){ + cc.eventManager.removeListener(_listener); + event = new cc.EventCustom("Issue9898"); + cc.eventManager.dispatchEvent(event); + } + }); + cc.eventManager.addListener(_listener, 1); + var menuItem = new cc.MenuItemFont("Dispatch Custom Event1", function(sender){ + var event = new cc.EventCustom("Issue9898"); + cc.eventManager.dispatchEvent(event); + }); + menuItem.setPosition(origin.x + size.width/2, origin.y + size.height/2); + + var menu = new cc.Menu(menuItem); + menu.setPosition(0, 0); + this.addChild(menu); + //----end12---- + } + +}); + +Issue9898.create = function(){ + var test = new Issue9898(); + test.init(); + return test; +}; + +var EventDispatcherTestScene = TestScene.extend({ + runThisTest:function (num) { + eventDispatcherSceneIdx = (num || num == 0) ? (num - 1) : -1; + this.addChild(nextDispatcherTest()); + director.runScene(this); + } +}); + +var arrayOfEventDispatcherTest = [ + TouchableSpriteTest, + FixedPriorityTest, + RemoveListenerWhenDispatching, + CustomEventTest, + LabelKeyboardEventTest, + SpriteAccelerationEventTest, + RemoveAndRetainNodeTest, + RemoveListenerAfterAddingTest, + DirectorEventTest, + //GlobalZTouchTest, + StopPropagationTest, + Issue4160, + PauseResumeTargetTest, + Issue9898 +]; + +var nextDispatcherTest = function () { + eventDispatcherSceneIdx++; + eventDispatcherSceneIdx = eventDispatcherSceneIdx % arrayOfEventDispatcherTest.length; + + if(window.sideIndexBar){ + eventDispatcherSceneIdx = window.sideIndexBar.changeTest(eventDispatcherSceneIdx, 11); + } + + return new arrayOfEventDispatcherTest[eventDispatcherSceneIdx](); +}; +var previousDispatcherTest = function () { + eventDispatcherSceneIdx--; + if (eventDispatcherSceneIdx < 0) + eventDispatcherSceneIdx += arrayOfEventDispatcherTest.length; + + if(window.sideIndexBar){ + eventDispatcherSceneIdx = window.sideIndexBar.changeTest(eventDispatcherSceneIdx, 11); + } + + return new arrayOfEventDispatcherTest[eventDispatcherSceneIdx](); +}; +var restartDispatcherTest = function () { + return new arrayOfEventDispatcherTest[eventDispatcherSceneIdx](); +}; \ No newline at end of file diff --git a/tests/js-tests/src/OpenGLTest/OpenGLTest.js b/tests/js-tests/src/OpenGLTest/OpenGLTest.js new file mode 100644 index 0000000000..bae9d902e8 --- /dev/null +++ b/tests/js-tests/src/OpenGLTest/OpenGLTest.js @@ -0,0 +1,1361 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + 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. + ****************************************************************************/ + +var OpenGLTestIdx = -1; + +// the class inherit from TestScene +// every Scene each test used must inherit from TestScene, +// make sure the test have the menu item for back to main menu +var OpenGLTestScene = TestScene.extend({ + runThisTest:function (num) { + OpenGLTestIdx = (num || num == 0) ? (num - 1) : -1; + this.addChild(nextOpenGLTest()); + director.runScene(this); + } +}); + +cc.GLNode = cc.GLNode || cc.Node.extend({ + ctor:function(){ + this._super(); + this.init(); + }, + init:function(){ + this._renderCmd._needDraw = true; + this._renderCmd.rendering = function(ctx){ + cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW); + cc.kmGLPushMatrix(); + cc.kmGLLoadMatrix(this._stackMatrix); + + this._node.draw(ctx); + + cc.kmGLPopMatrix(); + }; + }, + draw:function(ctx){ + this._super(ctx); + } +}); + +var OpenGLTestLayer = BaseTestLayer.extend({ + _grossini:null, + _tamara:null, + _kathia:null, + _code:null, + + ctor:function() { + this._super(cc.color(0,0,0,255), cc.color(98,99,117,255) ); + }, + + title:function () { + return "OpenGLTest"; + }, + subtitle:function () { + return ""; + }, + onBackCallback:function (sender) { + var s = new OpenGLTestScene(); + s.addChild(previousOpenGLTest()); + director.runScene(s); + }, + onRestartCallback:function (sender) { + var s = new OpenGLTestScene(); + s.addChild(restartOpenGLTest()); + director.runScene(s); + }, + onNextCallback:function (sender) { + var s = new OpenGLTestScene(); + s.addChild(nextOpenGLTest()); + director.runScene(s); + }, + + // automation + numberOfPendingTests:function() { + return ( (arrayOfOpenGLTest.length-1) - OpenGLTestIdx ); + }, + + getTestNumber:function() { + return OpenGLTestIdx; + } +}); + +//------------------------------------------------------------------ +// +// ReadPixelsTest +// +//------------------------------------------------------------------ +var GLReadPixelsTest = OpenGLTestLayer.extend({ + + ctor:function() { + this._super(); + + if( 'opengl' in cc.sys.capabilities ) { + var x = winSize.width; + var y = winSize.height; + + var blue = new cc.LayerColor(cc.color(0, 0, 255, 255)); + var red = new cc.LayerColor(cc.color(255, 0, 0, 255)); + var green = new cc.LayerColor(cc.color(0, 255, 0, 255)); + var white = new cc.LayerColor(cc.color(255, 255, 255, 255)); + + blue.scale = 0.5; + blue.x = -x / 4; + blue.y = -y / 4; + + red.scale = 0.5; + red.x = x / 4; + red.y = -y / 4; + + green.scale = 0.5; + green.x = -x / 4; + green.y = y / 4; + + white.scale = 0.5; + white.x = x / 4; + white.y = y / 4; + + this.addChild(blue,10); + this.addChild(white,11); + this.addChild(green,12); + this.addChild(red,13); + } + }, + + title:function () { + return "gl.ReadPixels()"; + }, + subtitle:function () { + return "Tests ReadPixels. See console"; + }, + + // + // Automation + // + getExpectedResult:function() { + // red, green, blue, white + var ret = [{"0":255,"1":0,"2":0,"3":255},{"0":0,"1":255,"2":0,"3":255},{"0":0,"1":0,"2":255,"3":255},{"0":255,"1":255,"2":255,"3":255}]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var x = winSize.width; + var y = winSize.height; + + var rPixels = new Uint8Array(4); + var gPixels = new Uint8Array(4); + var bPixels = new Uint8Array(4); + var wPixels = new Uint8Array(4); + + // blue + gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, bPixels); + + // red + gl.readPixels(x-1, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, rPixels); + + // green + gl.readPixels(0, y-1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, gPixels); + + // white + gl.readPixels(x-1, y-1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, wPixels); + + var ret = [ rPixels, gPixels, bPixels, wPixels]; + return JSON.stringify(ret); + } + +}); + + +//------------------------------------------------------------------ +// +// GLClearTest +// +//------------------------------------------------------------------ +var GLClearTest = OpenGLTestLayer.extend({ + + ctor:function() { + this._super(); + + if( 'opengl' in cc.sys.capabilities ) { + + var blue = new cc.LayerColor(cc.color(0, 0, 255, 255)); + this.addChild( blue, 1 ); + + var node = new cc.GLNode(); + node.init(); + node.draw = function() { + gl.clear( gl.COLOR_BUFFER_BIT ); + }; + + this.addChild( node, 10 ); + node.x = winSize.width/2; + node.y = winSize.height/2 ; + } + }, + + title:function () { + return "gl.clear(gl.COLOR_BUFFER_BIT)"; + }, + subtitle:function () { + return "Testing gl.clear() with cc.GLNode"; + }, + + // + // Automation + // + getExpectedResult:function() { + // black pixel, not a blue pixel + var ret = {"0":0,"1":0,"2":0,"3":255}; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = this.readPixels(winSize.width/2, winSize.height/2, 1, 1); + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// GLNodeWebGLAPITest +// +//------------------------------------------------------------------ +var GLNodeWebGLAPITest = OpenGLTestLayer.extend({ + + ctor:function() { + this._super(); + + if( 'opengl' in cc.sys.capabilities ) { + + // simple shader example taken from: + // http://learningwebgl.com/blog/?p=134 + var vsh = "\n" + + "attribute vec3 aVertexPosition;\n" + + "attribute vec4 aVertexColor;\n" + + "uniform mat4 uMVMatrix;\n" + + "uniform mat4 uPMatrix;\n" + + "varying vec4 vColor;\n" + + "void main(void) {\n" + + " gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);\n" + + " vColor = aVertexColor;\n" + + "}\n"; + + var fsh = "\n" + + "#ifdef GL_ES\n" + + "precision mediump float;\n" + + "#endif\n" + + "varying vec4 vColor;\n" + + "void main(void) {\n"+ + " gl_FragColor = vColor;\n" + + "}\n"; + + var fshader = this.compileShader(fsh, 'fragment'); + var vshader = this.compileShader(vsh, 'vertex'); + + var shaderProgram = this.shader = gl.createProgram(); + + gl.attachShader(shaderProgram, vshader); + gl.attachShader(shaderProgram, fshader); + gl.linkProgram(shaderProgram); + + if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) { + throw("Could not initialise shaders"); + } + + gl.useProgram(shaderProgram); + + shaderProgram.vertexPositionAttribute = gl.getAttribLocation(shaderProgram, "aVertexPosition"); + gl.enableVertexAttribArray(shaderProgram.vertexPositionAttribute); + + shaderProgram.vertexColorAttribute = gl.getAttribLocation(shaderProgram, "aVertexColor"); + gl.enableVertexAttribArray(shaderProgram.vertexColorAttribute); + + shaderProgram.pMatrixUniform = gl.getUniformLocation(shaderProgram, "uPMatrix"); + shaderProgram.mvMatrixUniform = gl.getUniformLocation(shaderProgram, "uMVMatrix"); + + this.initBuffers(); + + var glnode = new cc.GLNode(); + this.addChild(glnode,10); + this.glnode = glnode; + + glnode.draw = function() { + var pMatrix = [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]; + this.pMatrix = pMatrix = new Float32Array(pMatrix); + + var mvMatrix = [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]; + this.mvMatrix = mvMatrix = new Float32Array(mvMatrix); + + gl.useProgram(this.shader); + gl.uniformMatrix4fv(this.shader.pMatrixUniform, false, this.pMatrix); + gl.uniformMatrix4fv(this.shader.mvMatrixUniform, false, this.mvMatrix); + + gl.enableVertexAttribArray(this.shader.vertexPositionAttribute); + gl.enableVertexAttribArray(this.shader.vertexColorAttribute); + + // Draw fullscreen Square + gl.bindBuffer(gl.ARRAY_BUFFER, this.squareVertexPositionBuffer); + gl.vertexAttribPointer(this.shader.vertexPositionAttribute, this.squareVertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.squareVertexColorBuffer); + gl.vertexAttribPointer(this.shader.vertexColorAttribute, this.squareVertexColorBuffer.itemSize, gl.FLOAT, false, 0, 0); + + this.setMatrixUniforms(); + gl.drawArrays(gl.TRIANGLE_STRIP, 0, this.squareVertexPositionBuffer.numItems); + + // Draw fullscreen Triangle + gl.bindBuffer(gl.ARRAY_BUFFER, this.triangleVertexPositionBuffer); + gl.vertexAttribPointer(this.shader.vertexPositionAttribute, this.triangleVertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.triangleVertexColorBuffer); + gl.vertexAttribPointer(this.shader.vertexColorAttribute, this.triangleVertexColorBuffer.itemSize, gl.FLOAT, false, 0, 0); + + gl.drawArrays(gl.TRIANGLES, 0, this.triangleVertexPositionBuffer.numItems); + + gl.bindBuffer(gl.ARRAY_BUFFER, null); + + }.bind(this); + + } + }, + + setMatrixUniforms:function() { + gl.uniformMatrix4fv(this.shader.pMatrixUniform, false, this.pMatrix); + gl.uniformMatrix4fv(this.shader.mvMatrixUniform, false, this.mvMatrix); + }, + + initBuffers:function() { + var triangleVertexPositionBuffer = this.triangleVertexPositionBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer); + var vertices = [ + 0.0, 1.0, 0.0, + -1.0, -1.0, 0.0, + 1.0, -1.0, 0.0 + ]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + triangleVertexPositionBuffer.itemSize = 3; + triangleVertexPositionBuffer.numItems = 3; + + var triangleVertexColorBuffer = this.triangleVertexColorBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexColorBuffer); + var colors = [ + 1.0, 0.0, 0.0, 1.0, + 1.0, 0.0, 0.0, 1.0, + 1.0, 0.0, 0.0, 1.0 + ]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(colors), gl.STATIC_DRAW); + triangleVertexColorBuffer.itemSize = 4; + triangleVertexColorBuffer.numItems = 3; + + + var squareVertexPositionBuffer = this.squareVertexPositionBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer); + vertices = [ + 1.0, 1.0, 0.0, + -1.0, 1.0, 0.0, + 1.0, -1.0, 0.0, + -1.0, -1.0, 0.0 + ]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + squareVertexPositionBuffer.itemSize = 3; + squareVertexPositionBuffer.numItems = 4; + + var squareVertexColorBuffer = this.squareVertexColorBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexColorBuffer); + colors = [ + 0.0, 0.0, 1.0, 1.0, + 0.0, 0.0, 1.0, 1.0, + 0.0, 0.0, 1.0, 1.0, + 0.0, 0.0, 1.0, 1.0 + ]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(colors), gl.STATIC_DRAW); + squareVertexColorBuffer.itemSize = 4; + squareVertexColorBuffer.numItems = 4; + + gl.bindBuffer(gl.ARRAY_BUFFER, null); + }, + + compileShader:function(source, type) { + var shader; + if( type == 'fragment' ) + shader = gl.createShader(gl.FRAGMENT_SHADER); + else + shader = gl.createShader(gl.VERTEX_SHADER); + gl.shaderSource(shader, source); + gl.compileShader(shader); + if( !gl.getShaderParameter(shader, gl.COMPILE_STATUS) ) { + cc.log( gl.getShaderInfoLog(shader) ); + throw("Could not compile " + type + " shader"); + } + return shader; + }, + + title:function () { + return "GLNode + WebGL API"; + }, + subtitle:function () { + return "blue background with a red triangle in the middle"; + }, + + // + // Automation + // + getExpectedResult:function() { + // blue, red, blue + var ret = [{"0":0,"1":0,"2":255,"3":255},{"0":0,"1":0,"2":255,"3":255},{"0":255,"1":0,"2":0,"3":255}]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret1 = this.readPixels(10, winSize.height-1, 1, 1); + var ret2 = this.readPixels(winSize.width-10, winSize.height-1, 1, 1); + var ret3 = this.readPixels(winSize.width/2, winSize.height/2, 1, 1); + + return JSON.stringify([ret1,ret2,ret3]); + } +}); + +//------------------------------------------------------------------ +// +// GLNodeCCAPITest +// +//------------------------------------------------------------------ +var GLNodeCCAPITest = OpenGLTestLayer.extend({ + + ctor:function() { + this._super(); + + if( 'opengl' in cc.sys.capabilities ) { + + + var glnode = new cc.GLNode(); + this.addChild(glnode,10); + this.glnode = glnode; + + this.shader = cc.shaderCache.getProgram("ShaderPositionColor"); + this.initBuffers(); + + glnode.draw = function() { + + this.shader.use(); + this.shader.setUniformsForBuiltins(); + cc.glEnableVertexAttribs( cc.VERTEX_ATTRIB_FLAG_COLOR | cc.VERTEX_ATTRIB_FLAG_POSITION); + + // Draw fullscreen Square + gl.bindBuffer(gl.ARRAY_BUFFER, this.squareVertexPositionBuffer); + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.squareVertexColorBuffer); + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0); + + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + + // Draw fullscreen Triangle + gl.bindBuffer(gl.ARRAY_BUFFER, this.triangleVertexPositionBuffer); + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.triangleVertexColorBuffer); + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.FLOAT, false, 0, 0); + + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 3); + + gl.bindBuffer(gl.ARRAY_BUFFER, null); + + }.bind(this); + + } + }, + + initBuffers:function() { + // + // Triangle + // + var triangleVertexPositionBuffer = this.triangleVertexPositionBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer); + var vertices = [ + winSize.width/2, winSize.height, + 0, 0, + winSize.width, 0 + ]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + + var triangleVertexColorBuffer = this.triangleVertexColorBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexColorBuffer); + var colors = [ + 1.0, 0.0, 0.0, 1.0, + 1.0, 0.0, 0.0, 1.0, + 1.0, 0.0, 0.0, 1.0 + ]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(colors), gl.STATIC_DRAW); + + // + // Square + // + var squareVertexPositionBuffer = this.squareVertexPositionBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer); + vertices = [ + winSize.width, winSize.height, + 0, winSize.height, + winSize.width, 0, + 0, 0 + ]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + + var squareVertexColorBuffer = this.squareVertexColorBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexColorBuffer); + colors = [ + 0.0, 0.0, 1.0, 1.0, + 0.0, 0.0, 1.0, 1.0, + 0.0, 0.0, 1.0, 1.0, + 0.0, 0.0, 1.0, 1.0 + ]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(colors), gl.STATIC_DRAW); + gl.bindBuffer(gl.ARRAY_BUFFER, null); + }, + title:function () { + return "GLNode + cocos2d API"; + }, + subtitle:function () { + return "blue background with a red triangle in the middle"; + }, + + // + // Automation + // + getExpectedResult:function() { + // blue, red, blue + var ret = [{"0":0,"1":0,"2":255,"3":255},{"0":0,"1":0,"2":255,"3":255},{"0":255,"1":0,"2":0,"3":255}]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret1 = this.readPixels(10, winSize.height-1, 1, 1); + var ret2 = this.readPixels(winSize.width-10, winSize.height-1, 1, 1); + var ret3 = this.readPixels(winSize.width/2, winSize.height/2, 1, 1); + + return JSON.stringify([ret1,ret2,ret3]); + } +}); + +//------------------------------------------------------------------ +// +// ShaderNode +// +//------------------------------------------------------------------ +var ShaderNode = cc.GLNode.extend({ + ctor:function(vertexShader, framentShader) { + this._super(); + this.init(); + + if( 'opengl' in cc.sys.capabilities ) { + this.width = 256; + this.height = 256; + this.anchorX = 0.5; + this.anchorY = 0.5; + + this.shader = cc.GLProgram.create(vertexShader, framentShader); + this.shader.retain(); + this.shader.addAttribute("aVertex", cc.VERTEX_ATTRIB_POSITION); + this.shader.link(); + this.shader.updateUniforms(); + + var program = this.shader.getProgram(); + this.uniformCenter = gl.getUniformLocation( program, "center"); + this.uniformResolution = gl.getUniformLocation( program, "resolution"); + this.initBuffers(); + + this.scheduleUpdate(); + this._time = 0; + } + }, + draw:function() { + this.shader.use(); + this.shader.setUniformsForBuiltins(); + + // + // Uniforms + // + var frameSize = cc.view.getFrameSize(); + this.shader.setUniformLocationF32( this.uniformCenter, frameSize.width/2, frameSize.height/2); + this.shader.setUniformLocationF32( this.uniformResolution, 256, 256); + + cc.glEnableVertexAttribs( cc.VERTEX_ATTRIB_FLAG_POSITION ); + + // Draw fullscreen Square + gl.bindBuffer(gl.ARRAY_BUFFER, this.squareVertexPositionBuffer); + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0); + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + + gl.bindBuffer(gl.ARRAY_BUFFER, null); + }, + + update:function(dt) { + this._time += dt; + }, + initBuffers:function() { + + // + // Square + // + var squareVertexPositionBuffer = this.squareVertexPositionBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer); + vertices = [ + 256, 256, + 0, 256, + 256, 0, + 0, 0 + ]; + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); + gl.bindBuffer(gl.ARRAY_BUFFER, null); + } +}); +//------------------------------------------------------------------ +// +// ShaderHeartTest +// +//------------------------------------------------------------------ +var ShaderHeartTest = OpenGLTestLayer.extend({ + ctor:function() { + this._super(); + + if( 'opengl' in cc.sys.capabilities ) { + var shaderNode = new ShaderNode("res/Shaders/example_Heart.vsh", "res/Shaders/example_Heart.fsh"); + this.addChild(shaderNode,10); + shaderNode.x = winSize.width/2; + shaderNode.y = winSize.height/2; + } + }, + + title:function () { + return "Shader Heart Test"; + }, + subtitle:function () { + return "You should see a heart in the center"; + }, + + // + // Automation + // + getExpectedResult:function() { + // redish pixel + var ret = {"0":255,"1":0,"2":0,"3":255}; + return JSON.stringify(ret); + }, + getCurrentResult:function() { + var ret = this.readPixels(winSize.width/2, winSize.height/2, 1, 1); + ret[0] = ret[0] > 240 ? 255 : 0; + ret[3] = ret[3] > 240 ? 255 : 0; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// ShaderMandelbrotTest +// +//------------------------------------------------------------------ +var ShaderMandelbrotTest = OpenGLTestLayer.extend({ + ctor:function() { + this._super(); + + if( 'opengl' in cc.sys.capabilities ) { + var shaderNode = new ShaderNode("res/Shaders/example_Mandelbrot.vsh", "res/Shaders/example_Mandelbrot.fsh"); + this.addChild(shaderNode,10); + shaderNode.x = winSize.width/2; + shaderNode.y = winSize.height/2; + } + }, + + title:function () { + return "Shader Mandelbrot Test"; + }, + subtitle:function () { + return "Mandelbrot shader with Zoom"; + }, + + // + // Automation + // + getExpectedResult:function() { + throw "Automation Test Not implemented yet"; + }, + getCurrentResult:function() { + throw "Automation Test Not implemented yet"; + } +}); + +//------------------------------------------------------------------ +// +// ShaderMonjoriTest +// +//------------------------------------------------------------------ +var ShaderMonjoriTest = OpenGLTestLayer.extend({ + ctor:function() { + this._super(); + + if( 'opengl' in cc.sys.capabilities ) { + var shaderNode = new ShaderNode("res/Shaders/example_Monjori.vsh", "res/Shaders/example_Monjori.fsh"); + this.addChild(shaderNode,10); + shaderNode.x = winSize.width/2; + shaderNode.y = winSize.height/2; + } + }, + + title:function () { + return "Shader Monjori Test"; + }, + subtitle:function () { + return "Monjori plane deformations"; + }, + + // + // Automation + // + getExpectedResult:function() { + throw "Automation Test Not implemented yet"; + }, + getCurrentResult:function() { + throw "Automation Test Not implemented yet"; + } +}); + +//------------------------------------------------------------------ +// +// ShaderPlasmaTest +// +//------------------------------------------------------------------ +var ShaderPlasmaTest = OpenGLTestLayer.extend({ + ctor:function() { + this._super(); + + if( 'opengl' in cc.sys.capabilities ) { + var shaderNode = new ShaderNode("res/Shaders/example_Plasma.vsh", "res/Shaders/example_Plasma.fsh"); + this.addChild(shaderNode,10); + shaderNode.x = winSize.width/2; + shaderNode.y = winSize.height/2; + } + }, + title:function () { + return "Shader Plasma Test"; + }, + subtitle:function () { + return "You should see a plasma in the center"; + }, + + // + // Automation + // + getExpectedResult:function() { + // redish pixel + return JSON.stringify(true); + }, + getCurrentResult:function() { + var ret = this.readPixels(winSize.width/2, winSize.height/2, 1, 1); + var sum = ret[0] + ret[1] + ret[2]; + return JSON.stringify(sum>300); + } +}); + +//------------------------------------------------------------------ +// +// ShaderFlowerTest +// +//------------------------------------------------------------------ +var ShaderFlowerTest = OpenGLTestLayer.extend({ + + ctor:function() { + this._super(); + + if( 'opengl' in cc.sys.capabilities ) { + + var shaderNode = new ShaderNode("res/Shaders/example_Flower.vsh", "res/Shaders/example_Flower.fsh"); + this.addChild(shaderNode,10); + shaderNode.x = winSize.width/2; + shaderNode.y = winSize.height/2; + } + }, + title:function () { + return "Shader Flower Test"; + }, + subtitle:function () { + return "You should see a moving Flower in the center"; + }, + + // + // Automation + // + getExpectedResult:function() { + // redish pixel + return JSON.stringify(true); + }, + getCurrentResult:function() { + var ret = this.readPixels(winSize.width/2, winSize.height/2, 1, 1); + var sum = ret[0] + ret[1] + ret[2]; + return JSON.stringify(sum<30); + } +}); + +//------------------------------------------------------------------ +// +// ShaderJuliaTest +// +//------------------------------------------------------------------ +var ShaderJuliaTest = OpenGLTestLayer.extend({ + + ctor:function() { + this._super(); + + if( 'opengl' in cc.sys.capabilities ) { + + var shaderNode = new ShaderNode("res/Shaders/example_Julia.vsh", "res/Shaders/example_Julia.fsh"); + this.addChild(shaderNode,10); + shaderNode.x = winSize.width/2; + shaderNode.y = winSize.height/2; + } + }, + title:function () { + return "Shader Julia Test"; + }, + subtitle:function () { + return "You should see Julia effect"; + }, + + // + // Automation + // + getExpectedResult:function() { + // redish pixel + return JSON.stringify(true); + }, + getCurrentResult:function() { + var ret = this.readPixels(winSize.width/2, winSize.height/2, 1, 1); + var sum = ret[0] + ret[1] + ret[2]; + return JSON.stringify(sum>300); + } +}); + +//------------------------------------------------------------------ +// +// ShaderOutline +// +//------------------------------------------------------------------ +//FIX ME: +//The renderers of webgl and opengl is quite different now, so we have to use different shader and different js code +//This is a bug, need to be fixed in the future +var ShaderOutlineEffect = OpenGLTestLayer.extend({ + ctor:function() { + this._super(); + + if( 'opengl' in cc.sys.capabilities ) { + if(cc.sys.isNative){ + this.shader = new cc.GLProgram("res/Shaders/example_Outline_noMVP.vsh", "res/Shaders/example_Outline.fsh"); + this.shader.link(); + this.shader.updateUniforms(); + } + else{ + this.shader = new cc.GLProgram("res/Shaders/example_Outline.vsh", "res/Shaders/example_Outline.fsh"); + this.shader.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION); + this.shader.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS); + this.shader.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR); + + this.shader.link(); + this.shader.updateUniforms(); + this.shader.use(); + this.shader.setUniformLocationWith1f(this.shader.getUniformLocationForName('u_threshold'), 1.75); + this.shader.setUniformLocationWith3f(this.shader.getUniformLocationForName('u_outlineColor'), 0 / 255, 255 / 255, 0 / 255); + } + + this.sprite = new cc.Sprite('res/Images/grossini.png'); + this.sprite.attr({ + x: winSize.width / 2, + y: winSize.height / 2 + }); + this.sprite.runAction(cc.sequence(cc.rotateTo(1.0, 10), cc.rotateTo(1.0, -10)).repeatForever()); + + if(cc.sys.isNative){ + var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this.shader); + glProgram_state.setUniformFloat("u_threshold", 1.75); + glProgram_state.setUniformVec3("u_outlineColor", {x: 0/255, y: 255/255, z: 0/255}); + this.sprite.setGLProgramState(glProgram_state); + }else{ + this.sprite.shaderProgram = this.shader; + } + + this.addChild(this.sprite); + + this.scheduleUpdate(); + } + }, + update:function(dt) { + if( 'opengl' in cc.sys.capabilities ) { + if(cc.sys.isNative){ + this.sprite.getGLProgramState().setUniformFloat("u_radius", Math.abs(this.sprite.getRotation() / 500)); + }else{ + this.shader.use(); + this.shader.setUniformLocationWith1f(this.shader.getUniformLocationForName('u_radius'), Math.abs(this.sprite.getRotation() / 500)); + this.shader.updateUniforms(); + } + } + }, + title:function () { + return "Shader Outline Effect"; + }, + subtitle:function () { + return "Should see rotated image with animated outline effect"; + } + + // + // Automation + // +}); + +//------------------------------------------------------------------ +// +// ShaderRetro +// +//------------------------------------------------------------------ + +// Fix me: +// The implemetation of LabelBMFont is quite defferent between html5 and native +// That is why we use 'if (cc.sys.isNative){...}else{...}' in this test case +// It should be fixed in the future. +var ShaderRetroEffect = OpenGLTestLayer.extend({ + ctor:function() { + this._super(); + + if( 'opengl' in cc.sys.capabilities ) { + var program = new cc.GLProgram("res/Shaders/example_ColorBars.vsh", "res/Shaders/example_ColorBars.fsh"); + program.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION); + program.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS); + program.link(); + program.updateUniforms(); + + var label = new cc.LabelBMFont("RETRO EFFECT","res/fonts/west_england-64.fnt"); + + if(cc.sys.isNative) + label.children[0].shaderProgram = program; + else + label.shaderProgram = program; + + label.x = winSize.width/2; + + label.y = winSize.height/2; + this.addChild(label); + + this.scheduleUpdate(); + + this.label = label; + this.accum = 0; + } + }, + update:function(dt) { + this.accum += dt; + + if(cc.sys.isNative){ + var letters = this.label.children[0]; + for(var i = 0; i< letters.getStringLength(); ++i){ + var sprite = letters.getLetter(i); + sprite.y = Math.sin( this.accum * 2 + i/2.0) * 20; + sprite.scaleY = ( Math.sin( this.accum * 2 + i/2.0 + 0.707) ); + } + }else{ + var children = this.label.children; + + for( var i in children ) { + var sprite = children[i]; + sprite.y = Math.sin( this.accum * 2 + i/2.0) * 20; + + // add fabs() to prevent negative scaling + var scaleY = ( Math.sin( this.accum * 2 + i/2.0 + 0.707) ); + + sprite.scaleY = scaleY; + } + } + }, + title:function () { + return "Shader Retro Effect"; + }, + subtitle:function () { + return "Should see moving colors, and a sin effect on the letters"; + } + + // + // Automation + // +}); +//------------------------------------------------------------------ +// +// GLGetActiveTest +// +//------------------------------------------------------------------ +var GLGetActiveTest = OpenGLTestLayer.extend({ + + ctor:function() { + this._super(); + + if( 'opengl' in cc.sys.capabilities ) { + var sprite = this.sprite = new cc.Sprite("res/Images/grossini.png"); + sprite.x = winSize.width/2; + sprite.y = winSize.height/2; + this.addChild( sprite ); + + // after auto test + this.scheduleOnce( this.onTest, 0.5 ); + } + }, + + onTest:function(dt) { + cc.log( this.getCurrentResult() ); + }, + + title:function () { + return "gl.getActive***"; + }, + subtitle:function () { + return "Tests gl.getActiveUniform / getActiveAttrib. See console"; + }, + + // + // Automation + // + getExpectedResult:function() { + // redish pixel + var ret = [{"size":1,"type":35666,"name":"a_position"},{"size":1,"type":35678,"name":"CC_Texture"},[2,3]]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = []; + var p = this.sprite.shaderProgram.getProgram(); + ret.push( gl.getActiveAttrib( p, 0 ) ); + ret.push( gl.getActiveUniform( p, 0 ) ); + ret.push( gl.getAttachedShaders( p ) ); + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TexImage2DTest +// +//------------------------------------------------------------------ +var TexImage2DTest = OpenGLTestLayer.extend({ + + ctor:function() { + this._super(); + + if( 'opengl' in cc.sys.capabilities ) { + var glnode = new cc.GLNode(); + this.addChild(glnode,10); + this.glnode = glnode; + glnode.x = winSize.width/2; + glnode.y = winSize.height/2; + glnode.width = 128; + glnode.height = 128; + glnode.anchorX = 0.5; + glnode.anchorY = 0.5; + + this.shader = cc.shaderCache.getProgram("ShaderPositionTexture"); + this.initGL(); + + glnode.draw = function() { + this.shader.use(); + this.shader.setUniformsForBuiltins(); + + gl.bindTexture(gl.TEXTURE_2D, this.my_texture); + cc.glEnableVertexAttribs( cc.VERTEX_ATTRIB_FLAG_TEX_COORDS | cc.VERTEX_ATTRIB_FLAG_POSITION); + + // Draw fullscreen Square + gl.bindBuffer(gl.ARRAY_BUFFER, this.squareVertexPositionBuffer); + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0); + + gl.bindBuffer(gl.ARRAY_BUFFER, this.squareVertexTextureBuffer); + gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 0, 0); + + gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); + + gl.bindTexture(gl.TEXTURE_2D, null); + gl.bindBuffer(gl.ARRAY_BUFFER, null); + + }.bind(this); + + } + }, + + initGL:function() { + var texture = this.my_texture = gl.createTexture(); + gl.bindTexture( gl.TEXTURE_2D, texture ); + + var pixels = new Uint8Array(4096); + for( var i=0; i 0 ) + cc.log( gl.getExtension( array[0] ) ); + } + } + }, + + title:function () { + return "GetSupportedExtensionsTest"; + }, + subtitle:function () { + return "See console for the supported GL extensions"; + }, + + // + // Automation + // + getExpectedResult:function() { + var ret = ["[object Array]",null]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + // Extensions varies from machine to machine. Just check for typeof Array + var ext = gl.getSupportedExtensions(); + var type = Object.prototype.toString.call( ext ); + var n = gl.getExtension('do_no_exist'); + return JSON.stringify([type,n]); + } +}); + +//------------------------------------------------------------------ +// +// GLTexParamterTest +// +//------------------------------------------------------------------ +var GLTexParamterTest = OpenGLTestLayer.extend({ + + ctor:function() { + this._super(); + + if( 'opengl' in cc.sys.capabilities ) { + if( ! autoTestEnabled ) { + cc.log( this.getTexValues() ); + } + } + }, + + title:function () { + return "GLTexParamterTest"; + }, + subtitle:function () { + return "tests texParameter()"; + }, + getTexValues:function() { + if(!cc.sys.isNative){ + var texture2d = cc.textureCache.getTextureForKey(s_pathGrossini); + gl.bindTexture(gl.TEXTURE_2D, texture2d.getName()); + } else { + gl.bindTexture(gl.TEXTURE_2D, null); + } + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri( gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE ); + gl.texParameteri( gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE ); + + var mag = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER); + var min = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER); + var w_s = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S); + var w_t = gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S); + + var a = [mag, min, w_s, w_t]; + return a; + }, + + // + // Automation + // + getExpectedResult:function() { + var ret = [9728,9728,33071,33071]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = this.getTexValues(); + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// GLGetUniformTest +// +//------------------------------------------------------------------ +var GLGetUniformTest = OpenGLTestLayer.extend({ + + ctor:function() { + this._super(); + + if( 'opengl' in cc.sys.capabilities ) { + + if( ! autoTestEnabled ) { + cc.log( JSON.stringify( this.runTest() )); + } + + } + }, + + title:function () { + return "GLGetUniformTest"; + }, + subtitle:function () { + return "tests texParameter()"; + }, + runTest:function() { + + var shader = cc.shaderCache.getProgram("ShaderPositionTextureColor"); + var program = shader.getProgram(); + shader.use(); + + var loc = cc.sys.isNative ? gl.getUniformLocation(program, "CC_MVPMatrix") : gl.getUniformLocation(program, "CC_MVMatrix"); + + var pMatrix = [1,2,3,4, 4,3,2,1, 1,2,4,8, 1.1,1.2,1.3,1.4]; + this.pMatrix = new Float32Array(pMatrix); + + gl.uniformMatrix4fv(loc, false, this.pMatrix); + + return gl.getUniform( program, loc ); + }, + + // + // Automation + // + getExpectedResult:function() { + var ret = {"0":1,"1":2,"2":3,"3":4,"4":4,"5":3,"6":2,"7":1,"8":1,"9":2,"10":4,"11":8,"12":1.100000023841858,"13":1.2000000476837158,"14":1.2999999523162842,"15":1.399999976158142}; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = this.runTest(); + return JSON.stringify(ret); + } +}); + +//- +// +// Flow control +// +var arrayOfOpenGLTest = [ + ShaderOutlineEffect, + ShaderRetroEffect, + ShaderMonjoriTest, + ShaderMandelbrotTest, + ShaderHeartTest, + ShaderPlasmaTest, + ShaderFlowerTest, + ShaderJuliaTest, + GLGetActiveTest, + TexImage2DTest, + GetSupportedExtensionsTest, + GLReadPixelsTest, + GLClearTest, + GLNodeWebGLAPITest, + GLNodeCCAPITest, + GLTexParamterTest, + GLGetUniformTest +]; + +var nextOpenGLTest = function () { + OpenGLTestIdx++; + OpenGLTestIdx = OpenGLTestIdx % arrayOfOpenGLTest.length; + + return new arrayOfOpenGLTest[OpenGLTestIdx](); +}; +var previousOpenGLTest = function () { + OpenGLTestIdx--; + if (OpenGLTestIdx < 0) + OpenGLTestIdx += arrayOfOpenGLTest.length; + + return new arrayOfOpenGLTest[OpenGLTestIdx](); +}; +var restartOpenGLTest = function () { + return new arrayOfOpenGLTest[OpenGLTestIdx](); +}; \ No newline at end of file diff --git a/tests/js-tests/src/ParallaxTest/ParallaxTest.js b/tests/js-tests/src/ParallaxTest/ParallaxTest.js new file mode 100644 index 0000000000..1646851caf --- /dev/null +++ b/tests/js-tests/src/ParallaxTest/ParallaxTest.js @@ -0,0 +1,265 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 TAG_NODE = 9960; + +var parallaxTestSceneIdx = -1; + +ParallaxDemo = BaseTestLayer.extend({ + _atlas:null, + ctor:function() { + this._super(cc.color(0,0,0,255), cc.color(160,32,32,255)); + }, + + title:function () { + return "No title"; + }, + + onBackCallback:function (sender) { + var s = new ParallaxTestScene(); + s.addChild(previousParallaxTest()); + director.runScene(s); + }, + + onRestartCallback:function (sender) { + var s = new ParallaxTestScene(); + s.addChild(restartParallaxTest()); + director.runScene(s); + }, + + onNextCallback:function (sender) { + var s = new ParallaxTestScene(); + s.addChild(nextParallaxTest()); + director.runScene(s); + }, + // automation + numberOfPendingTests:function() { + return ( (arrayOfParallaxTest.length-1) - parallaxTestSceneIdx ); + }, + + getTestNumber:function() { + return parallaxTestSceneIdx; + } + +}); + +var Parallax1 = ParallaxDemo.extend({ + _parentNode:null, + _background:null, + _tilemap:null, + _cocosimage:null, + + ctor:function () { + this._super(); + + // Top Layer, a simple image + this._cocosimage = new cc.Sprite(s_power); + // scale the image (optional) + this._cocosimage.scale = 1.5; + // change the transform anchor point to 0,0 (optional) + this._cocosimage.anchorX = 0; + this._cocosimage.anchorY = 0; + + // Middle layer: a Tile map atlas + //var tilemap = cc.TileMapAtlas.create(s_tilesPng, s_levelMapTga, 16, 16); + this._tilemap = new cc.TMXTiledMap(s_resprefix + "TileMaps/orthogonal-test2.tmx"); + + // change the transform anchor to 0,0 (optional) + this._tilemap.anchorX = 0; + this._tilemap.anchorY = 0; + + // Anti Aliased images + //tilemap.texture.setAntiAliasTexParameters(); + + // background layer: another image + this._background = new cc.Sprite(s_back); + // scale the image (optional) + //background.scale = 1.5; + // change the transform anchor point (optional) + this._background.anchorX = 0; + this._background.anchorY = 0; + + // create a void node, a parent node + this._parentNode = new cc.ParallaxNode(); + + // NOW add the 3 layers to the 'void' node + + // background image is moved at a ratio of 0.4x, 0.5y + this._parentNode.addChild(this._background, -1, cc.p(0.4, 0.5), cc.p(0,0)); + + // tiles are moved at a ratio of 2.2x, 1.0y + this._parentNode.addChild(this._tilemap, 1, cc.p(2.2, 1.0), cc.p(0, 0)); + + // top image is moved at a ratio of 3.0x, 2.5y + this._parentNode.addChild(this._cocosimage, 2, cc.p(3.0, 2.5), cc.p(0, 0)); + + // now create some actions that will move the '_parent' node + // and the children of the '_parent' node will move at different + // speed, thus, simulation the 3D environment + var goUp = cc.moveBy(2, cc.p(0, 100)); + var goRight = cc.moveBy(2, cc.p(200, 0)); + var delay = cc.delayTime(2.0); + var goDown = goUp.reverse(); + var goLeft = goRight.reverse(); + var seq = cc.sequence(goUp, goRight, delay, goDown, goLeft); + this._parentNode.runAction(seq.repeatForever()); + + this.addChild(this._parentNode); + }, + + title:function () { + return "Parallax: parent and 3 children"; + }, + + // default values for automation + testDuration:5, + getExpectedResult:function() { + var ret = {}; + ret.pos_parent = cc.p(200,100); + ret.pos_child1 = cc.p(-120, -50); + ret.pos_child2 = cc.p(240, 0); + ret.pos_child3 = cc.p(400, 150); + + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = {}; + ret.pos_parent = cc.p(Math.round(this._parentNode.x), Math.round(this._parentNode.y)); + ret.pos_child1 = cc.p(Math.round(this._background.x), Math.round(this._background.y)); + ret.pos_child2 = cc.p(Math.round(this._tilemap.x), Math.round(this._tilemap.y)); + ret.pos_child3 = cc.p(Math.round(this._cocosimage.x), Math.round(this._cocosimage.y)); + + return JSON.stringify(ret); + } +}); + +var Parallax2 = ParallaxDemo.extend({ + _root:null, + _target:null, + _streak:null, + ctor:function () { + this._super(); + + if( 'touches' in cc.sys.capabilities ){ + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesMoved:function (touches, event) { + var touch = touches[0]; + var node = event.getCurrentTarget().getChildByTag(TAG_NODE); + node.x += touch.getDelta().x; + node.y += touch.getDelta().y; + } + }, this); + } else if ('mouse' in cc.sys.capabilities ){ + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseMove: function(event){ + if(event.getButton() == cc.EventMouse.BUTTON_LEFT){ + var node = event.getCurrentTarget().getChildByTag(TAG_NODE); + node.x += event.getDeltaX(); + node.y += event.getDeltaY(); + } + } + }, this); + } + + + // Top Layer, a simple image + var cocosImage = new cc.Sprite(s_power); + // scale the image (optional) + cocosImage.scale = 1.5; + // change the transform anchor point to 0,0 (optional) + cocosImage.anchorX = 0; + cocosImage.anchorY = 0; + + // Middle layer: a Tile map atlas + //var tilemap = cc.TileMapAtlas.create(s_tilesPng, s_levelMapTga, 16, 16); + var tilemap = new cc.TMXTiledMap(s_resprefix + "TileMaps/orthogonal-test2.tmx"); + + // change the transform anchor to 0,0 (optional) + tilemap.anchorX = 0; + tilemap.anchorY = 0; + + // Anti Aliased images + //tilemap.texture.setAntiAliasTexParameters(); + + // background layer: another image + var background = new cc.Sprite(s_back); + // scale the image (optional) + //background.scale = 1.5; + // change the transform anchor point (optional) + background.anchorX = 0; + background.anchorY = 0; + + // create a void node, a parent node + var voidNode = new cc.ParallaxNode(); + // NOW add the 3 layers to the 'void' node + + // background image is moved at a ratio of 0.4x, 0.5y + voidNode.addChild(background, -1, cc.p(0.4, 0.5), cc.p(0,0)); + + // tiles are moved at a ratio of 1.0, 1.0y + voidNode.addChild(tilemap, 1, cc.p(1.0, 1.0), cc.p(0, 0)); + + // top image is moved at a ratio of 3.0x, 2.5y + voidNode.addChild(cocosImage, 2, cc.p(3.0, 2.5), cc.p(0, 0)); + this.addChild(voidNode, 0, TAG_NODE); + }, + + title:function () { + return "Parallax: drag screen"; + } +}); + +ParallaxTestScene = TestScene.extend({ + runThisTest:function (num) { + parallaxTestSceneIdx = (num || num == 0) ? (num - 1) : -1; + this.addChild(nextParallaxTest()); + director.runScene(this); + } +}); + +var arrayOfParallaxTest = [ + Parallax1, + Parallax2 +]; + +var nextParallaxTest = function () { + parallaxTestSceneIdx++; + parallaxTestSceneIdx = parallaxTestSceneIdx % arrayOfParallaxTest.length; + + return new arrayOfParallaxTest[parallaxTestSceneIdx](); +}; +var previousParallaxTest = function () { + parallaxTestSceneIdx--; + if (parallaxTestSceneIdx < 0) + parallaxTestSceneIdx += arrayOfParallaxTest.length; + + return new arrayOfParallaxTest[parallaxTestSceneIdx](); +}; +var restartParallaxTest = function () { + return new arrayOfParallaxTest[parallaxTestSceneIdx](); +}; diff --git a/tests/js-tests/src/ParticleTest/ParticleTest.js b/tests/js-tests/src/ParticleTest/ParticleTest.js new file mode 100644 index 0000000000..78fa53d8eb --- /dev/null +++ b/tests/js-tests/src/ParticleTest/ParticleTest.js @@ -0,0 +1,1232 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 TAG_LABEL_ATLAS = 1; + +var particleSceneIdx = -1; + +var ParticleTestScene = TestScene.extend({ + runThisTest:function (num) { + particleSceneIdx = (num || num == 0) ? (num - 1) : -1; + + this.addChild(nextParticleAction()); + director.runScene(this); + } +}); + +var particleSceneArr = [ + function () { + return new DemoFlower(); + }, + function () { + return new DemoGalaxy(); + }, + function () { + return new DemoFirework(); + }, + function () { + return new DemoSpiral(); + }, + function () { + return new DemoSun(); + }, + function () { + return new DemoMeteor(); + }, + function () { + return new DemoFire(); + }, + function () { + return new DemoSmoke(); + }, + function () { + return new DemoExplosion(); + }, + function () { + return new DemoSnow(); + }, + function () { + return new DemoRain(); + }, + function () { + return new DemoBigFlower(); + }, + function () { + return new DemoRotFlower(); + }, + function () { + return new DemoModernArt(); + }, + function () { + return new DemoRing(); + }, + function () { + return new DemoParticleFromFile("BoilingFoam"); + }, + function () { + return new DemoParticleFromFile("BurstPipe"); + }, + function () { + return new DemoParticleFromFile("Comet"); + }, + function () { + return new DemoParticleFromFile("debian"); + }, + function () { + return new DemoParticleFromFile("ExplodingRing"); + }, + function () { + return new DemoParticleFromFile("LavaFlow"); + }, + function(){ + return new DemoParticleFromFile("SpinningPeas"); + }, + function () { + return new DemoParticleFromFile("SpookyPeas"); + }, + function () { + return new DemoParticleFromFile("Upsidedown"); + }, + function () { + return new DemoParticleFromFile("Flower"); + }, + function () { + return new DemoParticleFromFile("Spiral"); + }, + function () { + return new DemoParticleFromFile("Galaxy"); + }, + function () { + return new RadiusMode1(); + }, + function () { + return new RadiusMode2(); + }, + function () { + return new Issue704(); + }, + function () { + return new Issue870(); + }, + function () { + return new DemoParticleFromFile("Phoenix"); + }, + function() { + return new ParticleResizeTest(); + } +]; + +if( 'opengl' in cc.sys.capabilities ){ + particleSceneArr.push( function () { + return new ParallaxParticle(); + }); + particleSceneArr.push(function () { + return new ParticleBatchTest(); + }); +} + + +var nextParticleAction = function () { + particleSceneIdx++; + particleSceneIdx = particleSceneIdx % particleSceneArr.length; + return particleSceneArr[particleSceneIdx](); +}; + +var backParticleAction = function () { + particleSceneIdx--; + if (particleSceneIdx < 0) + particleSceneIdx += particleSceneArr.length; + + return particleSceneArr[particleSceneIdx](); +}; + +var restartParticleAction = function () { + return particleSceneArr[particleSceneIdx](); +}; + +var ParticleDemo = BaseTestLayer.extend({ + _emitter:null, + _background:null, + _shapeModeButton:null, + _textureModeButton:null, + _isPressed:false, + + setColor:function () { + }, + + ctor:function () { + this._super(cc.color(0,0,0,255), cc.color(98,99,117,255)); + this._emitter = null; + + if ('touches' in cc.sys.capabilities){ + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesBegan:function (touches, event) { + event.getCurrentTarget()._moveToTouchPoint(touches[0].getLocation()); + }, + onTouchesMoved:function (touches, event) { + event.getCurrentTarget()._moveToTouchPoint(touches[0].getLocation()); + } + }, this); + } else if ('mouse' in cc.sys.capabilities) + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseDown: function(event){ + event.getCurrentTarget()._moveToTouchPoint(event.getLocation()); + }, + onMouseMove: function(event){ + if(event.getButton() == cc.EventMouse.BUTTON_LEFT) + event.getCurrentTarget()._moveToTouchPoint(event.getLocation()); + } + }, this); + + var s = director.getWinSize(); + + var freeBtnNormal = new cc.Sprite(s_MovementMenuItem, cc.rect(0, 23 * 2, 123, 23)); + var freeBtnSelected = new cc.Sprite(s_MovementMenuItem, cc.rect(0, 23, 123, 23)); + var freeBtnDisabled = new cc.Sprite(s_MovementMenuItem, cc.rect(0, 0, 123, 23)); + + var relativeBtnNormal = new cc.Sprite(s_MovementMenuItem, cc.rect(123, 23 * 2, 138, 23)); + var relativeBtnSelected = new cc.Sprite(s_MovementMenuItem, cc.rect(123, 23, 138, 23)); + var relativeBtnDisabled = new cc.Sprite(s_MovementMenuItem, cc.rect(123, 0, 138, 23)); + + var groupBtnNormal = new cc.Sprite(s_MovementMenuItem, cc.rect(261, 23 * 2, 136, 23)); + var groupBtnSelected = new cc.Sprite(s_MovementMenuItem, cc.rect(261, 23, 136, 23)); + var groupBtnDisabled = new cc.Sprite(s_MovementMenuItem, cc.rect(261, 0, 136, 23)); + + var selfPoint = this; + this._freeMovementButton = new cc.MenuItemSprite(freeBtnNormal, freeBtnSelected, freeBtnDisabled, + function () { + selfPoint._emitter.setPositionType(cc.ParticleSystem.TYPE_RELATIVE); + selfPoint._relativeMovementButton.setVisible(true); + selfPoint._freeMovementButton.setVisible(false); + selfPoint._groupMovementButton.setVisible(false); + }); + this._freeMovementButton.x = 10; + this._freeMovementButton.y = 150; + this._freeMovementButton.setAnchorPoint(0, 0); + + this._relativeMovementButton = new cc.MenuItemSprite(relativeBtnNormal, relativeBtnSelected, relativeBtnDisabled, + function () { + selfPoint._emitter.setPositionType(cc.ParticleSystem.TYPE_GROUPED); + selfPoint._relativeMovementButton.setVisible(false); + selfPoint._freeMovementButton.setVisible(false); + selfPoint._groupMovementButton.setVisible(true); + }); + this._relativeMovementButton.setVisible(false); + this._relativeMovementButton.x = 10; + this._relativeMovementButton.y = 150; + this._relativeMovementButton.setAnchorPoint(0, 0); + + this._groupMovementButton = new cc.MenuItemSprite(groupBtnNormal, groupBtnSelected, groupBtnDisabled, + function () { + selfPoint._emitter.setPositionType(cc.ParticleSystem.TYPE_FREE); + selfPoint._relativeMovementButton.setVisible(false); + selfPoint._freeMovementButton.setVisible(true); + selfPoint._groupMovementButton.setVisible(false); + }); + this._groupMovementButton.setVisible(false); + this._groupMovementButton.x = 10; + this._groupMovementButton.y = 150; + this._groupMovementButton.setAnchorPoint(0, 0); + + var spriteNormal = new cc.Sprite(s_shapeModeMenuItem, cc.rect(0, 23 * 2, 115, 23)); + var spriteSelected = new cc.Sprite(s_shapeModeMenuItem, cc.rect(0, 23, 115, 23)); + var spriteDisabled = new cc.Sprite(s_shapeModeMenuItem, cc.rect(0, 0, 115, 23)); + + this._shapeModeButton = new cc.MenuItemSprite(spriteNormal, spriteSelected, spriteDisabled, + function () { + if (selfPoint._emitter.setDrawMode) + selfPoint._emitter.setDrawMode(cc.ParticleSystem.TEXTURE_MODE); + selfPoint._textureModeButton.setVisible(true); + selfPoint._shapeModeButton.setVisible(false); + }); + this._shapeModeButton.setVisible(false); + this._shapeModeButton.x = 10; + this._shapeModeButton.y = 100; + this._shapeModeButton.setAnchorPoint(0, 0); + + var spriteNormal_t = new cc.Sprite(s_textureModeMenuItem, cc.rect(0, 23 * 2, 115, 23)); + var spriteSelected_t = new cc.Sprite(s_textureModeMenuItem, cc.rect(0, 23, 115, 23)); + var spriteDisabled_t = new cc.Sprite(s_textureModeMenuItem, cc.rect(0, 0, 115, 23)); + + this._textureModeButton = new cc.MenuItemSprite(spriteNormal_t, spriteSelected_t, spriteDisabled_t, + function () { + if (selfPoint._emitter.setDrawMode) + selfPoint._emitter.setDrawMode(cc.ParticleSystem.SHAPE_MODE); + selfPoint._textureModeButton.setVisible(false); + selfPoint._shapeModeButton.setVisible(true); + }); + this._textureModeButton.x = 10; + this._textureModeButton.y = 100; + this._textureModeButton.setAnchorPoint(0, 0); + + if ('opengl' in cc.sys.capabilities ) { + // Shape type is not compatible with JSB + this._textureModeButton.enabled = false; + } + + var menu = new cc.Menu( this._shapeModeButton, this._textureModeButton, + this._freeMovementButton, this._relativeMovementButton, this._groupMovementButton); + menu.x = 0; + menu.y = 0; + + this.addChild(menu, 100); + //TODO + var labelAtlas = new cc.LabelAtlas("0123456789", s_fpsImages, 16, 24, '.'); + this.addChild(labelAtlas, 100, TAG_LABEL_ATLAS); + labelAtlas.x = s.width - 66; + labelAtlas.y = 50; + + // moving background + this._background = new cc.Sprite(s_back3); + this.addChild(this._background, 5); + this._background.x = s.width / 2; + this._background.y = s.height - 180; + + var move = cc.moveBy(4, cc.p(300, 0)); + var move_back = move.reverse(); + + var seq = cc.sequence(move, move_back); + this._background.runAction(seq.repeatForever()); + this.scheduleUpdate(); + }, + + onEnter:function () { + this._super(); + + var pLabel = this.getChildByTag(BASE_TEST_TITLE_TAG); + pLabel.setString(this.title()); + }, + title:function () { + return "No title"; + }, + + subtitle:function () { + return "(Tap the Screen)"; + }, + + onRestartCallback:function (sender) { + this._emitter.resetSystem(); + }, + onNextCallback:function (sender) { + var s = new ParticleTestScene(); + s.addChild(nextParticleAction()); + director.runScene(s); + }, + onBackCallback:function (sender) { + var s = new ParticleTestScene(); + s.addChild(backParticleAction()); + director.runScene(s); + }, + toggleCallback:function (sender) { + if (this._emitter.getPositionType() == cc.ParticleSystem.TYPE_GROUPED) + this._emitter.setPositionType(cc.ParticleSystem.TYPE_FREE); + else if (this._emitter.getPositionType() == cc.ParticleSystem.TYPE_FREE) + this._emitter.setPositionType(cc.ParticleSystem.TYPE_RELATIVE); + else if (this._emitter.getPositionType() == cc.ParticleSystem.TYPE_RELATIVE) + this._emitter.setPositionType(cc.ParticleSystem.TYPE_GROUPED); + }, + + _moveToTouchPoint: function (location) { + var pos = cc.p(0, 0); + if (this._background) { + pos = this._background.convertToWorldSpace(cc.p(0, 0)); + } + this._emitter.x = location.x - pos.x; + this._emitter.y = location.y - pos.y; + }, + + update:function (dt) { + if (this._emitter) { + var atlas = this.getChildByTag(TAG_LABEL_ATLAS); + atlas.setString(this._emitter.getParticleCount().toFixed(0)); + } + }, + setEmitterPosition:function () { + var sourcePos = this._emitter.getSourcePosition(); + if (sourcePos.x === 0 && sourcePos.y === 0) + this._emitter.x = 200; + this._emitter.y = 70; + }, + // automation + numberOfPendingTests:function() { + return ( (particleSceneArr.length-1) - particleSceneIdx ); + }, + + getTestNumber:function() { + return particleSceneIdx; + } +}); + +var DemoFirework = ParticleDemo.extend({ + onEnter:function () { + this._super(); + + this._emitter = new cc.ParticleFireworks(); + this._background.addChild(this._emitter, 10); + this._emitter.texture = cc.textureCache.addImage(s_stars1); + if (this._emitter.setShapeType) + this._emitter.setShapeType(cc.ParticleSystem.STAR_SHAPE); + this.setEmitterPosition(); + }, + title:function () { + return "ParticleFireworks"; + } +}); + +var DemoFire = ParticleDemo.extend({ + onEnter:function () { + this._super(); + + this._emitter = new cc.ParticleFire(); + this._background.addChild(this._emitter, 10); + + this._emitter.texture = cc.textureCache.addImage(s_fire);//.pvr"]; + if (this._emitter.setShapeType) + this._emitter.setShapeType(cc.ParticleSystem.BALL_SHAPE); + + this.setEmitterPosition(); + }, + title:function () { + return "ParticleFire"; + } +}); + +var DemoSun = ParticleDemo.extend({ + onEnter:function () { + this._super(); + + this._emitter = new cc.ParticleSun(); + this._background.addChild(this._emitter, 10); + this._emitter.texture = cc.textureCache.addImage(s_fire); + if (this._emitter.setShapeType) + this._emitter.setShapeType(cc.ParticleSystem.BALL_SHAPE); + + this.setEmitterPosition(); + }, + title:function () { + return "ParticleSun"; + } +}); + +var DemoGalaxy = ParticleDemo.extend({ + onEnter:function () { + this._super(); + + this._emitter = new cc.ParticleGalaxy(); + this._background.addChild(this._emitter, 10); + this._emitter.texture = cc.textureCache.addImage(s_fire); + if (this._emitter.setShapeType) + this._emitter.setShapeType(cc.ParticleSystem.BALL_SHAPE); + + this.setEmitterPosition(); + }, + title:function () { + return "ParticleGalaxy"; + } +}); + +var DemoFlower = ParticleDemo.extend({ + _title:"ParticleFlower", + + onEnter:function () { + this._super(); + + this._emitter = new cc.ParticleFlower(); + this._background.addChild(this._emitter, 10); + this._emitter.texture = cc.textureCache.addImage(s_stars1); + + if (this._emitter.setShapeType) + this._emitter.setShapeType(cc.ParticleSystem.STAR_SHAPE); + + this.setEmitterPosition(); + }, + title:function () { + return this._title; + } +}); + +var DemoBigFlower = ParticleDemo.extend({ + onEnter:function () { + this._super(); + + this._emitter = new cc.ParticleSystem(50); + + this._background.addChild(this._emitter, 10); + this._emitter.texture = cc.textureCache.addImage(s_stars1); + this._emitter.shapeType = cc.ParticleSystem.STAR_SHAPE; + + this._emitter.duration = -1; + + // gravity + this._emitter.gravity = cc.p(0, 0); + + // angle + this._emitter.angle = 90; + this._emitter.angleVar = 360; + + // speed of particles + this._emitter.speed = 160; + this._emitter.speedVar = 20; + + // radial + this._emitter.radialAccel = -120; + this._emitter.radialAccelVar = 0; + + // tagential + this._emitter.tangentialAccel = 30; + this._emitter.tangentialAccelVar = 0; + + // emitter position + this._emitter.x = 160; + this._emitter.y = 240; + this._emitter.posVar = cc.p(0, 0); + + // life of particles + this._emitter.life = 4; + this._emitter.lifeVar = 1; + + // spin of particles + this._emitter.startSpin = 0; + this._emitter.startSizeVar = 0; + this._emitter.endSpin = 0; + this._emitter.endSpinVar = 0; + + // color of particles + this._emitter.startColor = cc.color(128, 128, 128, 255); + this._emitter.startColorVar = cc.color(128, 128, 128, 255); + this._emitter.endColor = cc.color(26, 26, 26, 50); + this._emitter.endColorVar = cc.color(26, 26, 26, 50); + + // size, in pixels + this._emitter.startSize = 80.0; + this._emitter.startSizeVar = 40.0; + this._emitter.endSize = cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE; + + // emits per second + this._emitter.emissionRate = this._emitter.totalParticles / this._emitter.life; + + // additive + this._emitter.setBlendAdditive(true); + + this.setEmitterPosition(); + }, + title:function () { + return "ParticleBigFlower"; + } +}); + +var DemoRotFlower = ParticleDemo.extend({ + onEnter:function () { + this._super(); + + this._emitter = new cc.ParticleSystem(("opengl" in cc.sys.capabilities) ? 300 : 150); + + this._background.addChild(this._emitter, 10); + this._emitter.texture = cc.textureCache.addImage(s_stars2); + if (this._emitter.setShapeType) + this._emitter.setShapeType(cc.ParticleSystem.STAR_SHAPE); + + // duration + this._emitter.duration = -1; + + // gravity + this._emitter.gravity = cc.p(0, 0); + + // angle + this._emitter.angle = 90; + this._emitter.angleVar = 360; + + // speed of particles + this._emitter.speed = 160; + this._emitter.speedVar = 20; + + // radial + this._emitter.radialAccel = -120; + this._emitter.radialAccelVar = 0; + + // tangential + this._emitter.tangentialAccel = 30; + this._emitter.tangentialAccelVar = 0; + + // emitter position + this._emitter.x = 160; + this._emitter.y = 240; + this._emitter.posVar = cc.p(0, 0); + + // life of particles + this._emitter.life = 3; + this._emitter.lifeVar = 1; + + // spin of particles + this._emitter.startSpin = 0; + this._emitter.startSpinVar = 0; + this._emitter.endSpin = 0; + this._emitter.endSpinVar = 2000; + + this._emitter.startColor = cc.color(128, 128, 128, 255); + this._emitter.startColorVar = cc.color(128, 128, 128, 255); + this._emitter.endColor = cc.color(26, 26, 26, 50); + this._emitter.endColorVar = cc.color(26, 26, 26, 50); + + // size, in pixels + this._emitter.startSize = 30.0; + this._emitter.startSizeVar = 0; + this._emitter.endSize = cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE; + + // emits per second + this._emitter.emissionRate = this._emitter.totalParticles / this._emitter.life; + + // additive + this._emitter.setBlendAdditive(false); + + this.setEmitterPosition(); + }, + title:function () { + return "ParticleRotFlower"; + } +}); + +var DemoMeteor = ParticleDemo.extend({ + onEnter:function () { + this._super(); + + this._emitter = new cc.ParticleMeteor(); + this._background.addChild(this._emitter, 10); + + this._emitter.texture = cc.textureCache.addImage(s_fire); + this._emitter.shapeType = cc.ParticleSystem.BALL_SHAPE; + + this.setEmitterPosition(); + }, + title:function () { + return "ParticleMeteor"; + } +}); + +var DemoSpiral = ParticleDemo.extend({ + onEnter:function () { + this._super(); + + this._emitter = new cc.ParticleSpiral(); + this._background.addChild(this._emitter, 10); + + this._emitter.texture = cc.textureCache.addImage(s_fire); + this._emitter.shapeType = cc.ParticleSystem.BALL_SHAPE; + + this.setEmitterPosition(); + }, + title:function () { + return "ParticleSpiral"; + } +}); + +var DemoExplosion = ParticleDemo.extend({ + onEnter:function () { + this._super(); + + this._emitter = new cc.ParticleExplosion(); + this._background.addChild(this._emitter, 10); + + this._emitter.texture = cc.textureCache.addImage(s_stars1); + this._emitter.shapeType = cc.ParticleSystem.STAR_SHAPE; + + this._emitter.setAutoRemoveOnFinish(true); + + this.setEmitterPosition(); + }, + onExit: function() { + this._super(); + }, + title:function () { + return "ParticleExplosion"; + } +}); + +var DemoSmoke = ParticleDemo.extend({ + onEnter:function () { + this._super(); + + this._emitter = new cc.ParticleSmoke(); + this._background.addChild(this._emitter, 10); + this._emitter.texture = cc.textureCache.addImage(s_fire); + + this.setEmitterPosition(); + }, + title:function () { + return "ParticleSmoke"; + } +}); + +var DemoSnow = ParticleDemo.extend({ + onEnter:function () { + this._super(); + + this._emitter = new cc.ParticleSnow(); + this._background.addChild(this._emitter, 10); + + this._emitter.life = 3; + this._emitter.lifeVar = 1; + + // gravity + this._emitter.gravity = cc.p(0, -10); + + // speed of particles + this._emitter.speed = 130; + this._emitter.speedVar = 30; + + + var startColor = this._emitter.startColor; + startColor.r = 230; + startColor.g = 230; + startColor.b = 230; + this._emitter.startColor = startColor; + + var startColorVar = this._emitter.startColorVar; + startColorVar.b = 26; + this._emitter.startColorVar = startColorVar; + + this._emitter.emissionRate = this._emitter.totalParticles / this._emitter.life; + + this._emitter.texture = cc.textureCache.addImage(s_snow); + this._emitter.shapeType = cc.ParticleSystem.STAR_SHAPE; + + this.setEmitterPosition(); + }, + title:function () { + return "ParticleSnow"; + } +}); + +var DemoRain = ParticleDemo.extend({ + onEnter:function () { + this._super(); + + this._emitter = new cc.ParticleRain(); + this._background.addChild(this._emitter, 10); + + this._emitter.life = 4; + + this._emitter.texture = cc.textureCache.addImage(s_fire); + this._emitter.shapeType = cc.ParticleSystem.BALL_SHAPE; + + this.setEmitterPosition(); + }, + title:function () { + return "ParticleRain"; + } +}); + +var DemoModernArt = ParticleDemo.extend({ + onEnter:function () { + this._super(); + + this._emitter = new cc.ParticleSystem(("opengl" in cc.sys.capabilities) ? 1000 : 200); + + this._background.addChild(this._emitter, 10); + + var winSize = director.getWinSize(); + + // duration + this._emitter.duration = -1; + + // gravity + this._emitter.gravity = cc.p(0, 0); + + // angle + this._emitter.angle = 0; + this._emitter.angleVar = 360; + + // radial + this._emitter.radialAccel = 70; + this._emitter.radialAccelVar = 10; + + // tangential + this._emitter.tangentialAccel = 80; + this._emitter.tangentialAccelVar = 0; + + // speed of particles + this._emitter.speed = 50; + this._emitter.speedVar = 10; + + // life of particles + this._emitter.life = 2.0; + this._emitter.lifeVar = 0.3; + + // emits per frame + this._emitter.emissionRate = this._emitter.totalParticles / this._emitter.life; + + // color of particles + this._emitter.startColor = cc.color(128, 128, 128, 255); + this._emitter.startColorVar = cc.color(128, 128, 128, 255); + this._emitter.endColor = cc.color(26, 26, 26, 50); + this._emitter.endColorVar = cc.color(26, 26, 26, 50); + + // size, in pixels + this._emitter.startSize = 1.0; + this._emitter.startSizeVar = 1.0; + this._emitter.endSize = 32.0; + this._emitter.endSizeVar = 8.0; + + // texture + this._emitter.texture = cc.textureCache.addImage(s_fire); + this._emitter.shapeType = cc.ParticleSystem.BALL_SHAPE; + + // additive + this._emitter.setBlendAdditive(false); + + this.setEmitterPosition(); + }, + title:function () { + return "Varying size"; + } +}); + +var DemoRing = ParticleDemo.extend({ + onEnter:function () { + this._super(); + + this._emitter = new cc.ParticleFlower(); + + this._background.addChild(this._emitter, 10); + + this._emitter.texture = cc.textureCache.addImage(s_stars1); + this._emitter.shapeType = cc.ParticleSystem.STAR_SHAPE; + + this._emitter.lifeVar = 0; + this._emitter.life = 10; + this._emitter.speed = 100; + this._emitter.speedVar = 0; + this._emitter.emissionRate = 10000; + + this.setEmitterPosition(); + }, + title:function () { + return "Ring Demo"; + } +}); + +var ParallaxParticle = ParticleDemo.extend({ + onEnter:function () { + this._super(); + + this._background.getParent().removeChild(this._background, true); + this._background = null; + + //TODO + var p = new cc.ParallaxNode(); + this.addChild(p, 5); + + var p1 = new cc.Sprite(s_back3); + var p2 = new cc.Sprite(s_back3); + + p.addChild(p1, 1, cc.p(0.5, 1), cc.p(0, 250)); + p.addChild(p2, 2, cc.p(1.5, 1), cc.p(0, 50)); + + this._emitter = new cc.ParticleFlower(); + this._emitter.texture = cc.textureCache.addImage(s_fire); + + p1.addChild(this._emitter, 10); + this._emitter.x = 250; + this._emitter.y = 200; + + var par = new cc.ParticleSun(); + p2.addChild(par, 10); + par.texture = cc.textureCache.addImage(s_fire); + + var move = cc.moveBy(4, cc.p(300, 0)); + var move_back = move.reverse(); + var seq = cc.sequence(move, move_back); + p.runAction(seq.repeatForever()); + }, + title:function () { + return "Parallax + Particles"; + } +}); + +var DemoParticleFromFile = ParticleDemo.extend({ + _title:"", + ctor:function (filename) { + this._super(); + this._title = filename; + }, + onEnter:function () { + this._super(); + this.setColor(cc.color(0, 0, 0)); + this.removeChild(this._background, true); + this._background = null; + + this._emitter = new cc.ParticleSystem(s_resprefix + "Particles/" + this._title + ".plist"); + // test create from a object + // var plistData = jsb.fileUtils.getValueMapFromFile(s_resprefix + "Particles/" + this._title + ".plist"); + // this._emitter = new cc.ParticleSystem(plistData); + + this.addChild(this._emitter, 10); + + if (this._title == "Flower") { + this._emitter.shapeType = cc.ParticleSystem.STAR_SHAPE; + }//else if( this._title == "Upsidedown"){ + // this._emitter.setDrawMode(cc.ParticleSystem.TEXTURE_MODE); + //} + + this.setEmitterPosition(); + }, + + setEmitterPosition:function () { + var sourcePos = this._emitter.getSourcePosition(); + if (sourcePos.x === 0 && sourcePos.y === 0) + this._emitter.x = director.getWinSize().width / 2; + this._emitter.y = director.getWinSize().height / 2 - 50; + }, + + title:function () { + return this._title; + } +}); + +var RadiusMode1 = ParticleDemo.extend({ + onEnter:function () { + this._super(); + + this.setColor(cc.color(0, 0, 0)); + this.removeChild(this._background, true); + this._background = null; + + this._emitter = new cc.ParticleSystem(100); + this.addChild(this._emitter, 10); + this._emitter.texture = cc.textureCache.addImage(s_starsGrayscale); + + // duration + this._emitter.duration = cc.ParticleSystem.DURATION_INFINITY; + + // radius mode + this._emitter.emitterMode = cc.ParticleSystem.MODE_RADIUS; + + // radius mode: start and end radius in pixels + this._emitter.startRadius = 0; + this._emitter.startRadiusVar = 0; + this._emitter.endRadius = 160; + this._emitter.endRadiusVar = 0; + + // radius mode: degrees per second + this._emitter.rotatePerS = 180; + this._emitter.rotatePerSVar = 0; + + + // angle + this._emitter.angle = 90; + this._emitter.angleVar = 0; + + // emitter position + var size = director.getWinSize(); + this._emitter.x = size.width / 2; + this._emitter.y = size.height / 2; + this._emitter.posVar = cc.p(0, 0); + + // life of particles + this._emitter.life = 5; + this._emitter.lifeVar = 0; + + // spin of particles + this._emitter.startSpin = 0; + this._emitter.startSpinVar = 0; + this._emitter.endSpin = 0; + this._emitter.endSpinVar = 0; + + // color of particles + this._emitter.startColor = cc.color(128, 128, 128, 255); + this._emitter.startColorVar = cc.color(128, 128, 128, 255); + this._emitter.endColor = cc.color(26, 26, 26, 50); + this._emitter.endColorVar = cc.color(26, 26, 26, 50); + + // size, in pixels + this._emitter.startSize = 32; + this._emitter.startSizeVar = 0; + this._emitter.endSize = cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE; + + // emits per second + this._emitter.emissionRate = this._emitter.totalParticles / this._emitter.life; + + // additive + this._emitter.setBlendAdditive(false); + }, + title:function () { + return "Radius Mode: Spiral"; + } +}); + +var RadiusMode2 = ParticleDemo.extend({ + onEnter:function () { + this._super(); + + this.color = cc.color(0, 0, 0); + this.removeChild(this._background, true); + this._background = null; + + this._emitter = new cc.ParticleSystem(100); + this.addChild(this._emitter, 10); + this._emitter.texture = cc.textureCache.addImage(s_starsGrayscale); + + // duration + this._emitter.duration = cc.ParticleSystem.DURATION_INFINITY; + + // radius mode + this._emitter.emitterMode = cc.ParticleSystem.MODE_RADIUS; + + // radius mode: start and end radius in pixels + this._emitter.startRadius = 100; + this._emitter.startRadiusVar = 0; + this._emitter.endRadius = cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS; + this._emitter.endRadiusVar = 0; + + // radius mode: degrees per second + this._emitter.rotatePerS = 45; + this._emitter.rotatePerSVar = 0; + + // angle + this._emitter.angle = 90; + this._emitter.angleVar = 0; + + // emitter position + var size = director.getWinSize(); + this._emitter.x = size.width / 2; + this._emitter.y = size.height / 2; + this._emitter.posVar = cc.p(0, 0); + + // life of particles + this._emitter.life = 4; + this._emitter.lifeVar = 0; + + // spin of particles + this._emitter.startSpin = 0; + this._emitter.startSpinVar = 0; + this._emitter.endSpin = 0; + this._emitter.endSpinVar = 0; + + // color of particles + this._emitter.startColor = cc.color(128, 128, 128, 255); + this._emitter.startColorVar = cc.color(128, 128, 128, 255); + this._emitter.endColor = cc.color(26, 26, 26, 50); + this._emitter.endColorVar = cc.color(26, 26, 26, 50); + + // size, in pixels + this._emitter.startSize = 32; + this._emitter.startSizeVar = 0; + this._emitter.endSize = cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE; + + // emits per second + this._emitter.emissionRate = this._emitter.totalParticles / this._emitter.life; + + // additive + this._emitter.setBlendAdditive(false); + }, + title:function () { + return "Radius Mode: Semi Circle"; + } +}); + +var Issue704 = ParticleDemo.extend({ + onEnter:function () { + this._super(); + + this.color = cc.color(0, 0, 0); + this.removeChild(this._background, true); + this._background = null; + + this._emitter = new cc.ParticleSystem(100); + this.addChild(this._emitter, 10); + this._emitter.texture = cc.textureCache.addImage(s_fire); + this._emitter.shapeType = cc.ParticleSystem.BALL_SHAPE; + + // duration + this._emitter.duration = cc.ParticleSystem.DURATION_INFINITY; + + // radius mode + this._emitter.emitterMode = cc.ParticleSystem.MODE_RADIUS; + + // radius mode: start and end radius in pixels + this._emitter.startRadius = 50; + this._emitter.startRadiusVar = 0; + this._emitter.endRadius = cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS; + this._emitter.endRadiusVar = 0; + + // radius mode: degrees per second + this._emitter.rotatePerS = 0; + this._emitter.rotatePerSVar = 0; + + // angle + this._emitter.angle = 90; + this._emitter.angleVar = 0; + + // emitter position + var size = director.getWinSize(); + this._emitter.x = size.width / 2; + this._emitter.y = size.height / 2; + this._emitter.posVar = cc.p(0, 0); + + // life of particles + this._emitter.life = 5; + this._emitter.lifeVar = 0; + + // spin of particles + this._emitter.startSpin = 0; + this._emitter.startSpinVar = 0; + this._emitter.endSpin = 0; + this._emitter.endSpinVar = 0; + + // color of particles + this._emitter.startColor = cc.color(128, 128, 128, 255); + this._emitter.startColorVar = cc.color(128, 128, 128, 255); + this._emitter.endColor = cc.color(26, 26, 26, 50); + this._emitter.endColorVar = cc.color(26, 26, 26, 50); + + // size, in pixels + this._emitter.startSize = 16; + this._emitter.startSizeVar = 0; + this._emitter.endSize = cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE; + + // emits per second + this._emitter.emissionRate = this._emitter.totalParticles / this._emitter.life; + + // additive + this._emitter.setBlendAdditive(false); + + var rot = cc.rotateBy(16, 360); + this._emitter.runAction(rot.repeatForever()); + }, + title:function () { + return "Issue 704. Free + Rot"; + }, + subtitle:function () { + return "Emitted particles should not rotate"; + } +}); + +var Issue870 = ParticleDemo.extend({ + _index:0, + onEnter:function () { + this._super(); + + this.setColor(cc.color(0, 0, 0)); + this.removeChild(this._background, true); + this._background = null; + + var system = new cc.ParticleSystem(s_resprefix + "Particles/SpinningPeas.plist"); + system.setTextureWithRect(cc.textureCache.addImage(s_particles), cc.rect(0, 0, 32, 32)); + this.addChild(system, 10); + this._emitter = system; + this._emitter.drawMode = cc.ParticleSystem.TEXTURE_MODE; + this._emitter.x = director.getWinSize().width / 2; + this._emitter.y = director.getWinSize().height / 2 - 50; + this._index = 0; + this.schedule(this.updateQuads, 2.0); + }, + title:function () { + return "Issue 870. SubRect"; + }, + subtitle:function () { + return "Every 2 seconds the particle should change"; + }, + updateQuads:function (dt) { + this._index = (this._index + 1) % 4; + var rect = cc.rect(this._index * 32, 0, 32, 32); + this._emitter.setTextureWithRect(this._emitter.texture, rect); + } +}); + +var ParticleBatchTest = ParticleDemo.extend({ + _index:0, + onEnter:function () { + this._super(); + + var emitter1 = new cc.ParticleSystem(s_resprefix + 'Particles/LavaFlow.plist'); + emitter1.startColor = cc.color(255, 0, 0, 255); + var emitter2 = new cc.ParticleSystem(s_resprefix + 'Particles/LavaFlow.plist'); + emitter2.startColor = cc.color(0, 255, 0, 255); + var emitter3 = new cc.ParticleSystem(s_resprefix + 'Particles/LavaFlow.plist'); + emitter3.startColor = cc.color(0, 0, 255, 255); + + emitter1.x = winSize.width / 1.25; + + emitter1.y = winSize.height / 1.25; + emitter2.x = winSize.width / 2; + emitter2.y = winSize.height / 2; + emitter3.x = winSize.width / 4; + emitter3.y = winSize.height / 4; + + var batch = new cc.ParticleBatchNode(emitter1.texture); + + batch.addChild(emitter1); + batch.addChild(emitter2); + batch.addChild(emitter3); + + this.addChild(batch, 10); + + // to be able to use "reset" button + this.removeChild(this._background, true); + this._background = null; + this._emitter = emitter1; + }, + title:function () { + return "Particle Batch Test"; + }, + subtitle:function () { + return "You should 3 particles. They are batched"; + } +}); + +var ParticleResizeTest = ParticleDemo.extend({ + _index:0, + onEnter:function () { + this._super(); + + var emitter1 = new cc.ParticleSystem( s_resprefix + 'Particles/LavaFlow.plist'); + emitter1.x = winSize.width/2; + emitter1.y = winSize.height/2; + this.addChild(emitter1); + + this.schedule( this.onResizeParticle50, 2 ); + + // to be able to use "reset" button + this.removeChild(this._background, true); + this._background = null; + this._emitter = emitter1; + }, + onResizeParticle50:function(dt) { + this._emitter.totalParticles = 50; + this.scheduleOnce( this.onResizeParticle400, 1); + }, + onResizeParticle400:function(dt) { + this._emitter.totalParticles = 400; + }, + + title:function () { + return "Particle Resize Test"; + }, + subtitle:function () { + return "In 2 seconds, the emitter should have only 15 particles. Shall not crash."; + } +}); \ No newline at end of file diff --git a/tests/js-tests/src/PathTest/PathTest.js b/tests/js-tests/src/PathTest/PathTest.js new file mode 100644 index 0000000000..06d799d86f --- /dev/null +++ b/tests/js-tests/src/PathTest/PathTest.js @@ -0,0 +1,132 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + 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. + ****************************************************************************/ + +//------------------------------------------------------------------ +// +// PathTestLayer +// +//------------------------------------------------------------------ +var PathTestLayer = BaseTestLayer.extend({ + _title:"cc.path", + _subtitle:"See the console please!", + + ctor:function() { + this._super(cc.color(0,0,0,255), cc.color(98,99,117,255)); + + this._join([ + ["a", "b.png"], + ["a", "b", "c.png"], + ["a", "b"], + ["a", "b", "/"], + ["a", "b/", "/"] + ]); + + this._extname(["a/b.png", "a/b.png?a=1&b=2", "a/b", "a/b?a=1&b=2", ".a/b.png", ".a/b.png?a=1&b=2", ".a/b", ".a/b?a=1&b=2"]); + + this._basename([ + ["a/b.png"], + ["a/b.png?a=1&b=2"], + ["a/b.png", ".png"], + ["a/b.png?a=1&b=2", ".png"], + ["a/b.png", ".txt"] + ]); + + this._dirname(["a/b/c.png", "a/b/c.png?a=1&b=2"]); + + this._changeExtname([ + ["a/b.png", ".plist"], + ["a/b.png?a=1&b=2", ".plist"] + ]); + + this._changeBasename([ + ["a/b/c.plist", "b.plist"], + ["a/b/c.plist?a=1&b=2", "b.plist"], + ["a/b/c.plist", ".png"], + ["a/b/c.plist", "b"], + ["a/b/c.plist", "b", true] + ]); + }, + + _join : function(args){ + cc.log("-----------cc.path.join begin----------") + for(var i = 0, li = args.length; i < li; i++){ + var obj = args[i]; + cc.log("cc.path.join('" + obj.join("','") + "') ---> " + cc.path.join.apply(cc.path, obj)); + } + cc.log("-----------cc.path.join end------------") + }, + + _extname : function(args){ + cc.log("-----------cc.path.extname begin----------") + for(var i = 0, li = args.length; i < li; i++){ + var obj = args[i]; + cc.log("cc.path.extname('" + obj + "') ---> " + cc.path.extname(obj)); + } + cc.log("-----------cc.path.extname end------------") + }, + + _basename : function(args){ + cc.log("-----------cc.path.basename begin----------") + for(var i = 0, li = args.length; i < li; i++){ + var obj = args[i]; + cc.log("cc.path.basename('" + obj.join("','") + "') ---> " + cc.path.basename.apply(cc.path, obj)); + } + cc.log("-----------cc.path.basename end------------") + }, + + _dirname : function(args){ + cc.log("-----------cc.path.dirname begin----------") + for(var i = 0, li = args.length; i < li; i++){ + var obj = args[i]; + cc.log("cc.path.dirname('" + obj + "') ---> " + cc.path.dirname(obj)); + } + cc.log("-----------cc.path.dirname end------------") + }, + + _changeExtname : function(args){ + cc.log("-----------cc.path.changeExtname begin----------") + for(var i = 0, li = args.length; i < li; i++){ + var obj = args[i]; + cc.log("cc.path.changeExtname('" + obj.join("','") + "') ---> " + cc.path.changeExtname.apply(cc.path, obj)); + } + cc.log("-----------cc.path.changeExtname end------------") + }, + + _changeBasename : function(args){ + cc.log("-----------cc.path.changeBasename begin----------") + for(var i = 0, li = args.length; i < li; i++){ + var obj = args[i]; + var str = obj.length == 3 ? "'" + obj[0] + "','" + obj[1] + "'," + obj[2] : "" + obj.join("','") + "'" + cc.log("cc.path.changeBasename(" + str + ") ---> " + cc.path.changeBasename.apply(cc.path, obj)); + } + cc.log("-----------cc.path.changeBasename end------------") + } +}); + +var PathTestScene = TestScene.extend({ + runThisTest:function () { + this.addChild(new PathTestLayer()); + director.runScene(this); + } +}); diff --git a/tests/js-tests/src/PerformanceTest/PerformanceAnimationTest.js b/tests/js-tests/src/PerformanceTest/PerformanceAnimationTest.js new file mode 100644 index 0000000000..068e454517 --- /dev/null +++ b/tests/js-tests/src/PerformanceTest/PerformanceAnimationTest.js @@ -0,0 +1,240 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 s_nAnimationCurCase = 0; +//////////////////////////////////////////////////////// +// +// AnimationLayer +// +//////////////////////////////////////////////////////// +var AnimationMenuLayer = PerformBasicLayer.extend({ + showCurrentTest:function () { + var scene = null; + switch (this._curCase) { + case 0: + scene = AnimationTest.scene(); + break; + } + s_nAnimationCurCase = this._curCase; + + if (scene) { + cc.director.runScene(scene); + } + }, + + onEnter:function () { + this._super(); + + var s = cc.director.getWinSize(); + + // Title + var label = new cc.LabelTTF(this.title(), "Arial", 40); + this.addChild(label, 1); + label.x = s.width / 2; + label.y = s.height - 32; + label.color = cc.color(255, 255, 40); + + // Subtitle + var strSubTitle = this.subtitle(); + if (strSubTitle.length) { + var l = new cc.LabelTTF(strSubTitle, "Thonburi", 16); + this.addChild(l, 1); + l.x = s.width / 2; + l.y = s.height - 80; + } + + }, + title:function () { + return "no title"; + }, + subtitle:function () { + return "no subtitle"; + }, + performTests:function () { + + } +}); + +//////////////////////////////////////////////////////// +// +// AnimationTest +// +//////////////////////////////////////////////////////// +var AnimationTest = AnimationMenuLayer.extend({ + numNodes:null, + lastRenderedCount:null, + moveLayerList:null, + init:function () { + this._super(); + + var size = cc.director.getWinSize(); + + cc.MenuItemFont.setFontSize(65); + var decrease = new cc.MenuItemFont(" - ", this.onDecrease, this); + decrease.color = cc.color(0, 200, 20); + var increase = new cc.MenuItemFont(" + ", this.onIncrease, this); + increase.color = cc.color(0, 200, 20); + + var menu = new cc.Menu(decrease, increase); + menu.alignItemsHorizontally(); + menu.x = size.width / 2; + menu.y = size.height / 2 + 100; + this.addChild(menu, 1); + + var infoLabel = new cc.LabelTTF("0 nodes", "Marker Felt", 24); + infoLabel.color = cc.color(0, 200, 20); + infoLabel.x = size.width / 2; + infoLabel.y = size.height - 90; + this.addChild(infoLabel, 1, TAG_INFO_LAYER); + this.numNodes = 0; + this.moveLayerList = []; + this.createMovieClip(); + //this.scheduleUpdate(); + }, + performTests:function () { + this.init(); + }, + title:function () { + return "Animation Performance Test"; + }, + subtitle:function () { + return ""; + }, + createMovieClip:function () { + var moveLayer = new cc.Node(); + this.addChild(moveLayer); + this.moveLayerList.push(moveLayer); + var size = cc.director.getWinSize(); + for(var i=0; i<10; i++) { + var character = new CharacterView(); + character.init(); + character.x = size.width /2 - i*15 - 200; + character.y = size.height /2 - i*15; + this.numNodes++; + cc.log("create"+this.numNodes); + moveLayer.addChild(character, 0, this.numNodes); + } + var action = cc.moveBy(1, cc.p(20,0)); + moveLayer.runAction(action.repeatForever()); + this.updateNodes(); + }, + onIncrease:function () { + this.createMovieClip(); + }, + onDecrease:function () { + if(this.numNodes > 0) { + var moveLayer = this.moveLayerList[this.moveLayerList.length-1]; + for(var i=0;i<10;i++) { + cc.log("remove"+this.numNodes); + moveLayer.removeChildByTag(this.numNodes, true); + this.numNodes--; + } + moveLayer.removeFromParent(true); + this.moveLayerList.pop(); + } + this.updateNodes(); + }, + updateNodes:function () { + if (this.numNodes != this.lastRenderedCount) { + var infoLabel = this.getChildByTag(TAG_INFO_LAYER); + var str = this.numNodes + " nodes"; + infoLabel.setString(str); + + this.lastRenderedCount = this.numNodes; + } + } +}); + +var CharacterView = cc.Node.extend({ + leftData:null, + leftItem:null, + rightData:null, + rightItem:null, + leftX:null, + + init: function() { + this._super(); + cc.spriteFrameCache.addSpriteFrames("res/animations/crystals.plist"); + var i = 0; + rightData = new Array(10); + for (i = 0; i < 10; i++) { + var right = new cc.Sprite("#crystals/4.png"); + right.x = 50; + right.y = i * 10 - 40; + right.rotation = -90; + right.scale = 1; + this.addChild(right); + + rightData[i] = right; + if (i == 0) { + rightItem = right; + } + } + + for(i=0; i<10; i++){ + var head = new cc.Sprite("#crystals/1.png"); + head.x = i * 5; + head.y = 50; + this.addChild(head); + head.scale = 1.5; + head.rotation = 350; + var rotateToA = cc.rotateBy(0.01, 5); + head.runAction(rotateToA.repeatForever()); + } + + leftData = new Array(10); + for(i=0; i<10; i++){ + var left = new cc.Sprite("#crystals/2.png"); + left.x = 10; + left.y = i * 5 - 20; + left.rotation = 90; + this.addChild(left); + //var moveStep = cc.moveBy(0.01, cc.p(-5,0)); + // left.runAction(moveStep); + leftData[i] = left; + if(i==0){ + leftItem = left; + } + } + + }, + + setDistance: function(){ + leftX = leftItem.x; + } +}); + +AnimationTest.scene = function () { + var scene = new cc.Scene(); + var layer = new AnimationTest(false, 1, s_nAnimationCurCase); + scene.addChild(layer); + return scene; +}; +function runAnimationTest() { + s_nAnimationCurCase = 0; + var scene = AnimationTest.scene(); + cc.director.runScene(scene); +} diff --git a/tests/js-tests/src/PerformanceTest/PerformanceNodeChildrenTest.js b/tests/js-tests/src/PerformanceTest/PerformanceNodeChildrenTest.js new file mode 100644 index 0000000000..3033f2300b --- /dev/null +++ b/tests/js-tests/src/PerformanceTest/PerformanceNodeChildrenTest.js @@ -0,0 +1,524 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 TAG_BASE = 2000; +var MAX_NODES = 1500; +var NODES_INCREASE = 50; +var s_nCurCase = 0; + +//////////////////////////////////////////////////////// +// +// NodeChildrenMenuLayer +// +//////////////////////////////////////////////////////// +var NodeChildrenMenuLayer = PerformBasicLayer.extend({ + _maxCases:4, + showCurrentTest:function () { + var nodes = (this.parent).getQuantityOfNodes(); + var scene = null; + switch (this._curCase) { + case 0: + scene = new IterateSpriteSheetCArray(); + break; + case 1: + scene = new AddSpriteSheet(); + break; + case 2: + scene = new RemoveSpriteSheet(); + break; + case 3: + scene = new ReorderSpriteSheet(); + break; + } + s_nCurCase = this._curCase; + + if (scene) { + scene.initWithQuantityOfNodes(nodes); + cc.director.runScene(scene); + } + } +}); + +//////////////////////////////////////////////////////// +// +// NodeChildrenMainScene +// +//////////////////////////////////////////////////////// +var NodeChildrenMainScene = cc.Scene.extend({ + _lastRenderedCount:null, + _quantityOfNodes:null, + _currentQuantityOfNodes:null, + + ctor:function() { + this._super(); + this.init(); + }, + + initWithQuantityOfNodes:function (nodes) { + //srand(time()); + var s = cc.director.getWinSize(); + + // Title + var label = new cc.LabelTTF(this.title(), "Arial", 40); + this.addChild(label, 1); + label.x = s.width / 2; + label.y = s.height - 32; + label.color = cc.color(255, 255, 40); + + // Subtitle + var strSubTitle = this.subtitle(); + if (strSubTitle.length) { + var l = new cc.LabelTTF(strSubTitle, "Thonburi", 16); + this.addChild(l, 1); + l.x = s.width / 2; + l.y = s.height - 80; + } + + this._lastRenderedCount = 0; + this._currentQuantityOfNodes = 0; + this._quantityOfNodes = nodes; + + cc.MenuItemFont.setFontSize(65); + var that = this; + var decrease = new cc.MenuItemFont(" - ", this.onDecrease, this); + decrease.color = cc.color(0, 200, 20); + var increase = new cc.MenuItemFont(" + ", this.onIncrease, this); + increase.color = cc.color(0, 200, 20); + + var menu = new cc.Menu(decrease, increase); + menu.alignItemsHorizontally(); + menu.x = s.width / 2; + menu.y = s.height / 2 + 15; + this.addChild(menu, 1); + + var infoLabel = new cc.LabelTTF("0 nodes", "Marker Felt", 30); + infoLabel.color = cc.color(0, 200, 20); + infoLabel.x = s.width / 2; + infoLabel.y = s.height / 2 - 15; + this.addChild(infoLabel, 1, TAG_INFO_LAYER); + + var menu = new NodeChildrenMenuLayer(true, 4, s_nCurCase); + this.addChild(menu); + + this.updateQuantityLabel(); + this.updateQuantityOfNodes(); + }, + title:function () { + return "No title"; + }, + subtitle:function () { + return ""; + }, + updateQuantityOfNodes:function () { + + }, + onDecrease:function (sender) { + this._quantityOfNodes -= NODES_INCREASE; + if (this._quantityOfNodes < 0) { + this._quantityOfNodes = 0; + } + + this.updateQuantityLabel(); + this.updateQuantityOfNodes(); + }, + onIncrease:function (sender) { + this._quantityOfNodes += NODES_INCREASE; + if (this._quantityOfNodes > MAX_NODES) { + this._quantityOfNodes = MAX_NODES + } + + this.updateQuantityLabel(); + this.updateQuantityOfNodes(); + }, + updateQuantityLabel:function () { + if (this._quantityOfNodes != this._lastRenderedCount) { + var infoLabel = this.getChildByTag(TAG_INFO_LAYER); + var str = this._quantityOfNodes + " nodes"; + infoLabel.setString(str); + + this._lastRenderedCount = this._quantityOfNodes; + } + }, + getQuantityOfNodes:function () { + return this._quantityOfNodes; + } +}); + +//////////////////////////////////////////////////////// +// +// IterateSpriteSheet +// +//////////////////////////////////////////////////////// +var IterateSpriteSheet = NodeChildrenMainScene.extend({ + _batchNode:null, + _profilingTimer:null, + ctor:function () { + this._super(); + if (cc.ENABLE_PROFILERS) { + this._profilingTimer = new cc.ProfilingTimer(); + } + }, + updateQuantityOfNodes:function () { + var s = cc.director.getWinSize(); + + // increase nodes + if (this._currentQuantityOfNodes < this._quantityOfNodes) { + for (var i = 0; i < (this._quantityOfNodes - this._currentQuantityOfNodes); i++) { + var sprite = new cc.Sprite(this._batchNode.texture, cc.rect(0, 0, 32, 32)); + this._batchNode.addChild(sprite); + sprite.x = Math.random() * s.width; + sprite.y = Math.random() * s.height; + } + } + + // decrease nodes + else if (this._currentQuantityOfNodes > this._quantityOfNodes) { + for (var i = 0; i < (this._currentQuantityOfNodes - this._quantityOfNodes); i++) { + var index = this._currentQuantityOfNodes - i - 1; + this._batchNode.removeChildAtIndex(index, true); + } + } + + this._currentQuantityOfNodes = this._quantityOfNodes; + }, + initWithQuantityOfNodes:function (nodes) { + this._batchNode = new cc.SpriteBatchNode("res/Images/spritesheet1.png"); + this.addChild(this._batchNode); + + this._super(nodes); + + if (cc.ENABLE_PROFILERS) { + this._profilingTimer = cc.Profiler.timerWithName(this.profilerName(), this); + } + this.scheduleUpdate(); + }, + update:function (dt) { + }, + profilerName:function () { + return "none"; + } +}); + +//////////////////////////////////////////////////////// +// +// IterateSpriteSheetFastEnum +// +//////////////////////////////////////////////////////// +var IterateSpriteSheetFastEnum = IterateSpriteSheet.extend({ + update:function (dt) { + // iterate using fast enumeration protocol + var children = this._batchNode.children; + + if (cc.ENABLE_PROFILERS) { + cc.ProfilingBeginTimingBlock(this._profilingTimer); + } + + for (var i = 0; i < children.length; i++) { + var sprite = children[i]; + sprite.visible = false; + } + + if (cc.ENABLE_PROFILERS) { + cc.ProfilingEndTimingBlock(this._profilingTimer); + } + }, + + title:function () { + return "A - Iterate SpriteSheet"; + }, + subtitle:function () { + return "Iterate children using Fast Enum API. See console"; + }, + profilerName:function () { + return "iter fast enum"; + } +}); + +//////////////////////////////////////////////////////// +// +// IterateSpriteSheetCArray +// +//////////////////////////////////////////////////////// +var IterateSpriteSheetCArray = IterateSpriteSheet.extend({ + update:function (dt) { + // iterate using fast enumeration protocol + var children = this._batchNode.children; + + if (cc.ENABLE_PROFILERS) { + cc.ProfilingBeginTimingBlock(this._profilingTimer); + } + for (var i = 0; i < children.length; i++) { + var sprite = children[i]; + sprite.visible = false; + } + + if (cc.ENABLE_PROFILERS) { + cc.ProfilingEndTimingBlock(this._profilingTimer); + } + }, + + title:function () { + return "B - Iterate SpriteSheet"; + }, + subtitle:function () { + return "Iterate children using Array API. See console"; + }, + profilerName:function () { + return "iter c-array"; + } +}); + +//////////////////////////////////////////////////////// +// +// AddRemoveSpriteSheet +// +//////////////////////////////////////////////////////// +var AddRemoveSpriteSheet = NodeChildrenMainScene.extend({ + _batchNode:null, + ctor:function () { + this._super(); + if (cc.ENABLE_PROFILERS) { + this._profilingTimer = new cc.ProfilingTimer(); + } + }, + updateQuantityOfNodes:function () { + var s = cc.director.getWinSize(); + + // increase nodes + if (this._currentQuantityOfNodes < this._quantityOfNodes) { + for (var i = 0; i < (this._quantityOfNodes - this._currentQuantityOfNodes); i++) { + var sprite = new cc.Sprite(this._batchNode.texture, cc.rect(0, 0, 32, 32)); + this._batchNode.addChild(sprite); + sprite.x = Math.random() * s.width; + sprite.y = Math.random() * s.height; + sprite.visible = false; + } + } + // decrease nodes + else if (this._currentQuantityOfNodes > this._quantityOfNodes) { + for (var i = 0; i < (this._currentQuantityOfNodes - this._quantityOfNodes); i++) { + var index = this._currentQuantityOfNodes - i - 1; + this._batchNode.removeChildAtIndex(index, true); + } + } + + this._currentQuantityOfNodes = this._quantityOfNodes; + }, + initWithQuantityOfNodes:function (nodes) { + this._batchNode = new cc.SpriteBatchNode("res/Images/spritesheet1.png"); + this.addChild(this._batchNode); + + this._super(nodes); + + if (cc.ENABLE_PROFILERS) { + this._profilingTimer = cc.Profiler.timerWithName(this.profilerName(), this); + } + + this.scheduleUpdate(); + }, + update:function (dt) { + }, + profilerName:function () { + return "none"; + } +}); + +//////////////////////////////////////////////////////// +// +// AddSpriteSheet +// +//////////////////////////////////////////////////////// +var AddSpriteSheet = AddRemoveSpriteSheet.extend({ + update:function (dt) { + // reset seed + //srandom(0); + + // 15 percent + var totalToAdd = this._currentQuantityOfNodes * 0.15; + + if (totalToAdd > 0) { + var sprites = []; + var zs = []; + + // Don't include the sprite creation time and random as part of the profiling + for (var i = 0; i < totalToAdd; i++) { + var sprite = new cc.Sprite(this._batchNode.texture, cc.rect(0, 0, 32, 32)); + sprites.push(sprite); + zs[i] = (Math.random()*2-1) * 50; + } + + // add them with random Z (very important!) + if (cc.ENABLE_PROFILERS) + cc.ProfilingBeginTimingBlock(this._profilingTimer); + } + + for (var i = 0; i < totalToAdd; i++) { + this._batchNode.addChild(sprites[i], zs[i], TAG_BASE + i); + } + + if (cc.ENABLE_PROFILERS) { + cc.ProfilingEndTimingBlock(this._profilingTimer); + } + + // remove them + for (var i = 0; i < totalToAdd; i++) { + this._batchNode.removeChildByTag(TAG_BASE + i, true); + } + + delete zs; + + }, + title:function () { + return "C - Add to spritesheet"; + }, + subtitle:function () { + return "Adds %10 of total sprites with random z. See console"; + }, + profilerName:function () { + return "add sprites"; + } + }) + ; + +//////////////////////////////////////////////////////// +// +// RemoveSpriteSheet +// +//////////////////////////////////////////////////////// +var RemoveSpriteSheet = AddRemoveSpriteSheet.extend({ + update:function (dt) { + //srandom(0); + + // 15 percent + var totalToAdd = this._currentQuantityOfNodes * 0.15; + + if (totalToAdd > 0) { + var sprites = []; + + // Don't include the sprite creation time as part of the profiling + for (var i = 0; i < totalToAdd; i++) { + var sprite = new cc.Sprite(this._batchNode.texture, cc.rect(0, 0, 32, 32)); + sprites.push(sprite); + } + + // add them with random Z (very important!) + for (var i = 0; i < totalToAdd; i++) { + this._batchNode.addChild(sprites[i], (Math.random()*2-1) * 50, TAG_BASE + i); + } + + // remove them + if (cc.ENABLE_PROFILERS) { + cc.ProfilingBeginTimingBlock(this._profilingTimer); + } + + for (var i = 0; i < totalToAdd; i++) { + this._batchNode.removeChildByTag(TAG_BASE + i, true); + } + + if (cc.ENABLE_PROFILERS) { + cc.ProfilingEndTimingBlock(this._profilingTimer); + } + } + }, + title:function () { + return "D - Del from spritesheet"; + }, + subtitle:function () { + return "Remove %10 of total sprites placed randomly. See console"; + }, + profilerName:function () { + return "remove sprites"; + } +}); + +//////////////////////////////////////////////////////// +// +// ReorderSpriteSheet +// +//////////////////////////////////////////////////////// +var ReorderSpriteSheet = AddRemoveSpriteSheet.extend({ + + update:function (dt) { + //srandom(0); + + // 15 percent + var totalToAdd = this._currentQuantityOfNodes * 0.15; + + if (totalToAdd > 0) { + var sprites = []; + + // Don't include the sprite creation time as part of the profiling + for (var i = 0; i < totalToAdd; i++) { + var sprite = new cc.Sprite(this._batchNode.texture, cc.rect(0, 0, 32, 32)); + sprites.push(sprite); + } + + // add them with random Z (very important!) + for (var i = 0; i < totalToAdd; i++) { + this._batchNode.addChild(sprites[i], (Math.random()*2-1) * 50, TAG_BASE + i); + } + + // [this._batchNode sortAllChildren]; + + // reorder them + if (cc.ENABLE_PROFILERS) { + cc.ProfilingBeginTimingBlock(this._profilingTimer); + } + + for (var i = 0; i < totalToAdd; i++) { + var node = this._batchNode.children[i]; + ; + this._batchNode.reorderChild(node, (Math.random()*2-1) * 50); + } + if (cc.ENABLE_PROFILERS) { + cc.ProfilingEndTimingBlock(this._profilingTimer); + } + } + + + // remove them + for (var i = 0; i < totalToAdd; i++) { + this._batchNode.removeChildByTag(TAG_BASE + i, true); + } + + }, + + title:function () { + return "E - Reorder from spritesheet"; + }, + subtitle:function () { + return "Reorder %10 of total sprites placed randomly. See console"; + }, + profilerName:function () { + return "reorder sprites"; + } +}); + +function runNodeChildrenTest() { + var scene = new IterateSpriteSheetCArray(); + scene.initWithQuantityOfNodes(NODES_INCREASE); + cc.director.runScene(scene); +} diff --git a/tests/js-tests/src/PerformanceTest/PerformanceParticleTest.js b/tests/js-tests/src/PerformanceTest/PerformanceParticleTest.js new file mode 100644 index 0000000000..197c6e1f09 --- /dev/null +++ b/tests/js-tests/src/PerformanceTest/PerformanceParticleTest.js @@ -0,0 +1,526 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 TAG_PARTICLE_SYSTEM = 3; +var TAG_LABEL_ATLAS = 4; +var MAX_PARTICLES = 3000; +var PARTICLE_NODES_INCREASE = 200; +var s_nParCurIdx = 0; +var TAG_PARTICLE_MENU_LAYER = 1000; + +//////////////////////////////////////////////////////// +// +// ParticleMenuLayer +// +//////////////////////////////////////////////////////// +var ParticleMenuLayer = PerformBasicLayer.extend({ + _maxCases:4, + showCurrentTest:function () { + var scene = this.parent; + var subTest = scene.getSubTestNum(); + var parNum = scene.getParticlesNum(); + + var newScene = null; + + switch (this._curCase) { + case 0: + newScene = new ParticlePerformTest1; + break; + case 1: + newScene = new ParticlePerformTest2; + break; + case 2: + newScene = new ParticlePerformTest3; + break; + case 3: + newScene = new ParticlePerformTest4; + break; + } + + s_nParCurIdx = this._curCase; + if (newScene) { + newScene.initWithSubTest(subTest, parNum); + cc.director.runScene(newScene); + } + } +}); + +//////////////////////////////////////////////////////// +// +// ParticleMainScene +// +//////////////////////////////////////////////////////// +var ParticleMainScene = cc.Scene.extend({ + _lastRenderedCount:null, + _quantityParticles:null, + _subtestNumber:null, + ctor:function () { + this._super(); + this.init(); + }, + initWithSubTest:function (asubtest, particles) { + //srandom(0); + + this._subtestNumber = asubtest; + var s = cc.director.getWinSize(); + + this._lastRenderedCount = 0; + this._quantityParticles = particles; + + cc.MenuItemFont.setFontSize(65); + var decrease = new cc.MenuItemFont(" - ", this.onDecrease, this); + decrease.color = cc.color(0, 200, 20); + var increase = new cc.MenuItemFont(" + ", this.onIncrease, this); + increase.color = cc.color(0, 200, 20); + + var menu = new cc.Menu(decrease, increase); + menu.alignItemsHorizontally(); + menu.x = s.width / 2; + menu.y = s.height / 2 + 15; + this.addChild(menu, 1); + + var infoLabel = new cc.LabelTTF("0 nodes", "Marker Felt", 30); + infoLabel.color = cc.color(0, 200, 20); + infoLabel.x = s.width / 2; + infoLabel.y = s.height - 90; + this.addChild(infoLabel, 1, TAG_INFO_LAYER); + + // particles on stage + var labelAtlas = new cc.LabelAtlas("0000", "res/Images/fps_images.png", 16, 24, '.'); + // var labelAtlas = cc.LabelTTF.create("0000", "Marker Felt", 30); + this.addChild(labelAtlas, 0, TAG_LABEL_ATLAS); + labelAtlas.x = s.width - 66; + labelAtlas.y = 50; + + // Next Prev Test + var menu = new ParticleMenuLayer(true, 4, s_nParCurIdx); + this.addChild(menu, 1, TAG_PARTICLE_MENU_LAYER); + + // Sub Tests + cc.MenuItemFont.setFontSize(40); + var subMenu = new cc.Menu(); + for (var i = 1; i <= 3; ++i) { + var str = i.toString(); + var itemFont = new cc.MenuItemFont(str, this.testNCallback, this); + itemFont.tag = i; + subMenu.addChild(itemFont, 10); + + if (i <= 1) { + itemFont.color = cc.color(200, 20, 20); + } + else { + itemFont.color = cc.color(0, 200, 20); + } + } + subMenu.alignItemsHorizontally(); + subMenu.x = s.width / 2; + subMenu.y = 80; + this.addChild(subMenu, 2); + + var label = new cc.LabelTTF(this.title(), "Arial", 40); + this.addChild(label, 1); + label.x = s.width / 2; + label.y = s.height - 32; + label.color = cc.color(255, 255, 40); + + this.updateQuantityLabel(); + this.createParticleSystem(); + + this.schedule(this.step); + }, + title:function () { + return "No title"; + }, + + step:function (dt) { + var atlas = this.getChildByTag(TAG_LABEL_ATLAS); + var emitter = this.getChildByTag(TAG_PARTICLE_SYSTEM); + + var str = emitter.getParticleCount().toString(); + atlas.setString(str); + }, + createParticleSystem:function () { + /* + * Tests: + * 1 Quad Particle System using 32-bit textures (PNG) + * 2: Quad Particle System using 16-bit textures (PNG) + * 3: Quad Particle System using 8-bit textures (PNG) + * 4: Quad Particle System using 4-bit textures (PVRTC) + */ + + this.removeChildByTag(TAG_PARTICLE_SYSTEM, true); + + // remove the "fire.png" from the TextureCache cache. + //var texture = cc.textureCache.addImage("res/Images/fire.png"); + //cc.textureCache.removeTexture(texture); + + var particleSystem = new cc.ParticleSystem(this._quantityParticles); + + switch (this._subtestNumber) { + case 1: + if ("opengl" in cc.sys.capabilities) + cc.Texture2D.defaultPixelFormat = cc.Texture2D.PIXEL_FORMAT_RGBA8888; + particleSystem.texture = cc.textureCache.addImage("res/Images/fire.png"); + break; + case 2: + if ("opengl" in cc.sys.capabilities) + cc.Texture2D.defaultPixelFormat = cc.Texture2D.PIXEL_FORMAT_RGBA4444; + particleSystem.texture = cc.textureCache.addImage("res/Images/fire.png"); + break; + case 3: + if ("opengl" in cc.sys.capabilities) + cc.Texture2D.defaultPixelFormat = cc.Texture2D.PIXEL_FORMAT_A8; + particleSystem.texture = cc.textureCache.addImage("res/Images/fire.png"); + break; + default: + particleSystem = null; + cc.log("Shall not happen!"); + break; + } + this.addChild(particleSystem, 0, TAG_PARTICLE_SYSTEM); + + this.doTest(); + + // restore the default pixel format + if ("opengl" in cc.sys.capabilities) + cc.Texture2D.defaultPixelFormat = cc.Texture2D.PIXEL_FORMAT_RGBA8888; + }, + onDecrease:function (sender) { + this._quantityParticles -= PARTICLE_NODES_INCREASE; + if (this._quantityParticles < 0) + this._quantityParticles = 0; + + this.updateQuantityLabel(); + this.createParticleSystem(); + }, + onIncrease:function (sender) { + this._quantityParticles += PARTICLE_NODES_INCREASE; + if (this._quantityParticles > MAX_PARTICLES) { + this._quantityParticles = MAX_PARTICLES; + } + this.updateQuantityLabel(); + this.createParticleSystem(); + }, + testNCallback:function (sender) { + this._subtestNumber = sender.tag; + var menu = this.getChildByTag(TAG_PARTICLE_MENU_LAYER); + menu.restartCallback(sender); + }, + updateQuantityLabel:function () { + if (this._quantityParticles != this._lastRenderedCount) { + var infoLabel = this.getChildByTag(TAG_INFO_LAYER); + var str = this._quantityParticles + " particles"; + infoLabel.setString(str); + + this._lastRenderedCount = this._quantityParticles; + } + }, + getSubTestNum:function () { + return this._subtestNumber; + }, + getParticlesNum:function () { + return this._quantityParticles; + }, + doTest:function () { + } +}); + +//////////////////////////////////////////////////////// +// +// ParticlePerformTest1 +// +//////////////////////////////////////////////////////// +var ParticlePerformTest1 = ParticleMainScene.extend({ + + title:function () { + return "A " + this._subtestNumber + " size=4"; + }, + doTest:function () { + var s = cc.director.getWinSize(); + var particleSystem = this.getChildByTag(TAG_PARTICLE_SYSTEM); + + // duration + particleSystem.setDuration(-1); + + // gravity + particleSystem.setGravity(cc.p(0, -90)); + + // angle + particleSystem.setAngle(90); + particleSystem.setAngleVar(0); + + // radial + particleSystem.setRadialAccel(0); + particleSystem.setRadialAccelVar(0); + + // speed of particles + particleSystem.setSpeed(180); + particleSystem.setSpeedVar(50); + + // emitter position + particleSystem.x = s.width / 2; + particleSystem.y = 100; + particleSystem.setPosVar(cc.p(s.width / 2, 0)); + + // life of particles + particleSystem.setLife(2.0); + particleSystem.setLifeVar(1); + + // emits per frame + particleSystem.setEmissionRate(particleSystem.getTotalParticles() / particleSystem.getLife()); + + // color of particles + var startColor = cc.color(128, 128, 128, 255); + particleSystem.setStartColor(startColor); + + var startColorVar = cc.color(128, 128, 128, 255); + particleSystem.setStartColorVar(startColorVar); + + var endColor = cc.color(26, 26, 26, 51); + particleSystem.setEndColor(endColor); + + var endColorVar = cc.color(26, 26, 26, 51); + particleSystem.setEndColorVar(endColorVar); + + // size, in pixels + particleSystem.setEndSize(4.0); + particleSystem.setStartSize(4.0); + particleSystem.setEndSizeVar(0); + particleSystem.setStartSizeVar(0); + + // additive + particleSystem.setBlendAdditive(false); + } +}); + +//////////////////////////////////////////////////////// +// +// ParticlePerformTest2 +// +//////////////////////////////////////////////////////// +var ParticlePerformTest2 = ParticleMainScene.extend({ + + title:function () { + return "B " + this._subtestNumber + " size=8"; + }, + doTest:function () { + var s = cc.director.getWinSize(); + var particleSystem = this.getChildByTag(TAG_PARTICLE_SYSTEM); + + // duration + particleSystem.setDuration(-1); + + // gravity + particleSystem.setGravity(cc.p(0, -90)); + + // angle + particleSystem.setAngle(90); + particleSystem.setAngleVar(0); + + // radial + particleSystem.setRadialAccel(0); + particleSystem.setRadialAccelVar(0); + + // speed of particles + particleSystem.setSpeed(180); + particleSystem.setSpeedVar(50); + + // emitter position + particleSystem.x = s.width / 2; + particleSystem.y = 100; + particleSystem.setPosVar(cc.p(s.width / 2, 0)); + + // life of particles + particleSystem.setLife(2.0); + particleSystem.setLifeVar(1); + + // emits per frame + particleSystem.setEmissionRate(particleSystem.getTotalParticles() / particleSystem.getLife()); + + // color of particles + var startColor = cc.color(128, 128, 128, 255); + particleSystem.setStartColor(startColor); + + var startColorVar = cc.color(128, 128, 128, 255); + particleSystem.setStartColorVar(startColorVar); + + var endColor = cc.color(26, 26, 26, 51); + particleSystem.setEndColor(endColor); + + var endColorVar = cc.color(26, 26, 26, 51); + particleSystem.setEndColorVar(endColorVar); + + // size, in pixels + particleSystem.setEndSize(8.0); + particleSystem.setStartSize(8.0); + particleSystem.setEndSizeVar(0); + particleSystem.setStartSizeVar(0); + + // additive + particleSystem.setBlendAdditive(false); + } +}); + +//////////////////////////////////////////////////////// +// +// ParticlePerformTest3 +// +//////////////////////////////////////////////////////// +var ParticlePerformTest3 = ParticleMainScene.extend({ + + title:function () { + return "C " + this._subtestNumber + " size=32"; + }, + doTest:function () { + var s = cc.director.getWinSize(); + var particleSystem = this.getChildByTag(TAG_PARTICLE_SYSTEM); + + // duration + particleSystem.setDuration(-1); + + // gravity + particleSystem.setGravity(cc.p(0, -90)); + + // angle + particleSystem.setAngle(90); + particleSystem.setAngleVar(0); + + // radial + particleSystem.setRadialAccel(0); + particleSystem.setRadialAccelVar(0); + + // speed of particles + particleSystem.setSpeed(180); + particleSystem.setSpeedVar(50); + + // emitter position + particleSystem.x = s.width / 2; + particleSystem.y = 100; + particleSystem.setPosVar(cc.p(s.width / 2, 0)); + + // life of particles + particleSystem.setLife(2.0); + particleSystem.setLifeVar(1); + + // emits per frame + particleSystem.setEmissionRate(particleSystem.getTotalParticles() / particleSystem.getLife()); + + // color of particles + var startColor = cc.color(128, 128, 128, 255); + particleSystem.setStartColor(startColor); + + var startColorVar = cc.color(128, 128, 128, 255); + particleSystem.setStartColorVar(startColorVar); + + var endColor = cc.color(26, 26, 26, 51); + particleSystem.setEndColor(endColor); + + var endColorVar = cc.color(26, 26, 26, 51); + particleSystem.setEndColorVar(endColorVar); + + // size, in pixels + particleSystem.setEndSize(32.0); + particleSystem.setStartSize(32.0); + particleSystem.setEndSizeVar(0); + particleSystem.setStartSizeVar(0); + + // additive + particleSystem.setBlendAdditive(false); + } +}); + +//////////////////////////////////////////////////////// +// +// ParticlePerformTest4 +// +//////////////////////////////////////////////////////// +var ParticlePerformTest4 = ParticleMainScene.extend({ + + title:function () { + return "D " + this._subtestNumber + " size=64"; + }, + doTest:function () { + var s = cc.director.getWinSize(); + var particleSystem = this.getChildByTag(TAG_PARTICLE_SYSTEM); + + // duration + particleSystem.setDuration(-1); + + // gravity + particleSystem.setGravity(cc.p(0, -90)); + + // angle + particleSystem.setAngle(90); + particleSystem.setAngleVar(0); + + // radial + particleSystem.setRadialAccel(0); + particleSystem.setRadialAccelVar(0); + + // speed of particles + particleSystem.setSpeed(180); + particleSystem.setSpeedVar(50); + + // emitter position + particleSystem.x = s.width / 2; + particleSystem.y = 100; + particleSystem.setPosVar(cc.p(s.width / 2, 0)); + + // life of particles + particleSystem.setLife(2.0); + particleSystem.setLifeVar(1); + + // emits per frame + particleSystem.setEmissionRate(particleSystem.getTotalParticles() / particleSystem.getLife()); + + // color of particles + var startColor = cc.color(128, 128, 128, 255); + particleSystem.setStartColor(startColor); + + var startColorVar = cc.color(128, 128, 128, 255); + particleSystem.setStartColorVar(startColorVar); + + var endColor = cc.color(26, 26, 26, 51); + particleSystem.setEndColor(endColor); + + var endColorVar = cc.color(26, 26, 26, 51); + particleSystem.setEndColorVar(endColorVar); + + // size, in pixels + particleSystem.setEndSize(64.0); + particleSystem.setStartSize(64.0); + particleSystem.setEndSizeVar(0); + particleSystem.setStartSizeVar(0); + + // additive + particleSystem.setBlendAdditive(false); + } +}); + +function runParticleTest() { + var scene = new ParticlePerformTest1; + scene.initWithSubTest(1, PARTICLE_NODES_INCREASE); + cc.director.runScene(scene); +} diff --git a/tests/js-tests/src/PerformanceTest/PerformanceSpriteTest.js b/tests/js-tests/src/PerformanceTest/PerformanceSpriteTest.js new file mode 100644 index 0000000000..7b6b0b0f2c --- /dev/null +++ b/tests/js-tests/src/PerformanceTest/PerformanceSpriteTest.js @@ -0,0 +1,606 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 MAX_SPRITES = 10000; +var SPRITES_INCREASE = 500; + +if ( !cc.sys.isNative) { + if(cc.sys.isMobile){ + MAX_SPRITES = 3000; + SPRITES_INCREASE = 50; + } +} + +var TAG_INFO_LAYER = 1; +var TAG_MAIN_LAYER = 2; +var TAG_SPRITE_MENU_LAYER = (MAX_SPRITES + 1000); + +var s_nSpriteCurCase = 0; + +//////////////////////////////////////////////////////// +// +// SubTest +// +//////////////////////////////////////////////////////// +var SubTest = cc.Class.extend({ + _subtestNumber:null, + _batchNode:null, + _parent:null, + removeByTag:function (tag) { + switch (this._subtestNumber) { + case 1: + case 4: + case 7: + this._parent.removeChildByTag(tag + 100, true); + break; + case 2: + case 3: + case 5: + case 6: + case 8: + case 9: + this._batchNode.removeChildAtIndex(tag, true); + break; + default: + break; + } + }, + createSpriteWithTag:function (tag) { +// create + if( "opengl" in cc.sys.capabilities ) + cc.Texture2D.defaultPixelFormat = cc.Texture2D.PIXEL_FORMAT_RGBA8888; + + var sprite = null; + switch (this._subtestNumber) { + case 1: + { + sprite = new cc.Sprite("res/Images/grossinis_sister1.png"); + this._parent.addChild(sprite, 0, tag + 100); + break; + } + case 2: + case 3: + { + sprite = new cc.Sprite(this._batchNode.texture, cc.rect(0, 0, 52, 139)); + this._batchNode.addChild(sprite, 0, tag + 100); + break; + } + case 4: + { + var idx = parseInt(Math.random() * 14) + 1; + idx = idx < 10 ? "0" + idx : idx.toString(); + var str = "res/Images/grossini_dance_" + idx + ".png"; + sprite = new cc.Sprite(str); + this._parent.addChild(sprite, 0, tag + 100); + break; + } + case 5: + case 6: + { + var idx = 0 | (Math.random() * 14); + var x = (idx % 5) * 85; + var y = (0 | (idx / 5)) * 121; + sprite = new cc.Sprite(this._batchNode.texture, cc.rect(x, y, 85, 121)); + this._batchNode.addChild(sprite, 0, tag + 100); + break; + } + + case 7: + { + var y, x; + var r = 0 | (Math.random() * 64); + + y = parseInt(r / 8); + x = parseInt(r % 8); + + var str = "res/Images/sprites_test/sprite-" + x + "-" + y + ".png"; + sprite = new cc.Sprite(str); + this._parent.addChild(sprite, 0, tag + 100); + break; + } + + case 8: + case 9: + { + var y, x; + var r = 0 | (Math.random() * 64); + + y = (0 | (r / 8)) * 32; + x = (r % 8) * 32; + sprite = new cc.Sprite(this._batchNode.texture, cc.rect(x, y, 32, 32)); + this._batchNode.addChild(sprite, 0, tag + 100); + break; + } + + default: + break; + } + + if( "opengl" in cc.sys.capabilities ) + cc.Texture2D.defaultPixelFormat = cc.Texture2D.PIXEL_FORMAT_DEFAULT; + + return sprite; + }, + initWithSubTest:function (subTest, p) { + this._subtestNumber = subTest; + this._parent = p; + this._batchNode = null; + /* + * Tests: + * 1: 1 (32-bit) PNG sprite of 52 x 139 + * 2: 1 (32-bit) PNG Batch Node using 1 sprite of 52 x 139 + * 3: 1 (16-bit) PNG Batch Node using 1 sprite of 52 x 139 + * 4: 1 (4-bit) PVRTC Batch Node using 1 sprite of 52 x 139 + + * 5: 14 (32-bit) PNG sprites of 85 x 121 each + * 6: 14 (32-bit) PNG Batch Node of 85 x 121 each + * 7: 14 (16-bit) PNG Batch Node of 85 x 121 each + * 8: 14 (4-bit) PVRTC Batch Node of 85 x 121 each + + * 9: 64 (32-bit) sprites of 32 x 32 each + *10: 64 (32-bit) PNG Batch Node of 32 x 32 each + *11: 64 (16-bit) PNG Batch Node of 32 x 32 each + *12: 64 (4-bit) PVRTC Batch Node of 32 x 32 each + */ + + // purge textures + // + // [mgr removeAllTextures]; + if ( cc.sys.isNative) { + var mgr = cc.textureCache; + mgr.removeTexture(mgr.addImage("res/Images/grossinis_sister1.png")); + mgr.removeTexture(mgr.addImage("res/Images/grossini_dance_atlas.png")); + mgr.removeTexture(mgr.addImage("res/Images/spritesheet1.png")); + } + + switch (this._subtestNumber) { + case 1: + case 4: + case 7: + break; + /// + case 2: + if( "opengl" in cc.sys.capabilities ) + cc.Texture2D.defaultPixelFormat = cc.Texture2D.PIXEL_FORMAT_RGBA8888; + this._batchNode = new cc.SpriteBatchNode("res/Images/grossinis_sister1.png", 500); + p.addChild(this._batchNode, 0); + break; + case 3: + if( "opengl" in cc.sys.capabilities ) + cc.Texture2D.defaultPixelFormat = cc.Texture2D.PIXEL_FORMAT_RGBA4444; + this._batchNode = new cc.SpriteBatchNode("res/Images/grossinis_sister1.png", 500); + p.addChild(this._batchNode, 0); + break; + + /// + case 5: + if( "opengl" in cc.sys.capabilities ) + cc.Texture2D.defaultPixelFormat = cc.Texture2D.PIXEL_FORMAT_RGBA8888; + this._batchNode = new cc.SpriteBatchNode("res/Images/grossini_dance_atlas.png", 500); + p.addChild(this._batchNode, 0); + break; + case 6: + if( "opengl" in cc.sys.capabilities ) + cc.Texture2D.defaultPixelFormat = cc.Texture2D.PIXEL_FORMAT_RGBA4444; + this._batchNode = new cc.SpriteBatchNode("res/Images/grossini_dance_atlas.png", 500); + p.addChild(this._batchNode, 0); + break; + + /// + case 8: + if( "opengl" in cc.sys.capabilities ) + cc.Texture2D.defaultPixelFormat = cc.Texture2D.PIXEL_FORMAT_RGBA8888; + this._batchNode = new cc.SpriteBatchNode("res/Images/spritesheet1.png", 500); + p.addChild(this._batchNode, 0); + break; + case 9: + if( "opengl" in cc.sys.capabilities ) + cc.Texture2D.defaultPixelFormat = cc.Texture2D.PIXEL_FORMAT_RGBA4444; + this._batchNode = new cc.SpriteBatchNode("res/Images/spritesheet1.png", 500); + p.addChild(this._batchNode, 0); + break; + + default: + break; + } + + if( "opengl" in cc.sys.capabilities ) + cc.Texture2D.defaultPixelFormat = cc.Texture2D.PIXEL_FORMAT_DEFAULT; + } +}); + +//////////////////////////////////////////////////////// +// +// SpriteMenuLayer +// +//////////////////////////////////////////////////////// +var SpriteMenuLayer = PerformBasicLayer.extend({ + _maxCases:7, + showCurrentTest:function () { + var scene = null; + var preScene = this.parent; + var subTest = preScene.getSubTestNum(); + var nodes = preScene.getNodesNum(); + + Math.seedrandom('perftest'); + + switch (this._curCase) { + case 0: + scene = new SpritePerformTest1(); + break; + case 1: + scene = new SpritePerformTest2(); + break; + case 2: + scene = new SpritePerformTest3(); + break; + case 3: + scene = new SpritePerformTest4(); + break; + case 4: + scene = new SpritePerformTest5(); + break; + case 5: + scene = new SpritePerformTest6(); + break; + case 6: + scene = new SpritePerformTest7(); + break; + } + s_nSpriteCurCase = this._curCase; + + if (scene) { + scene.initWithSubTest(subTest, nodes); + cc.director.runScene(scene); + } + } +}); + +//////////////////////////////////////////////////////// +// +// SpriteMainScene +// +//////////////////////////////////////////////////////// +var SpriteMainScene = cc.Scene.extend({ + _lastRenderedCount:null, + _quantityNodes:null, + _subTest:null, + _subtestNumber:1, + ctor:function() { + this._super(); + this.init(); + }, + + title:function () { + return "No title"; + }, + initWithSubTest:function (asubtest, nodes) { + this._subtestNumber = asubtest; + this._subTest = new SubTest(); + this._subTest.initWithSubTest(asubtest, this); + + var s = cc.director.getWinSize(); + + this._lastRenderedCount = 0; + this._quantityNodes = 0; + + // add title label + var label = new cc.LabelTTF(this.title(), "Arial", 40); + this.addChild(label, 1); + label.x = s.width / 2; + label.y = s.height - 32; + label.color = cc.color(255, 255, 40); + + cc.MenuItemFont.setFontSize(65); + var decrease = new cc.MenuItemFont(" - ", this.onDecrease, this); + decrease.color = cc.color(0, 200, 20); + var increase = new cc.MenuItemFont(" + ", this.onIncrease, this); + increase.color = cc.color(0, 200, 20); + + var menu = new cc.Menu(decrease, increase); + menu.alignItemsHorizontally(); + + menu.x = s.width / 2; + + menu.y = s.height - 65; + this.addChild(menu, 1); + + var infoLabel = new cc.LabelTTF("0 nodes", "Marker Felt", 30); + infoLabel.color = cc.color(0, 200, 20); + infoLabel.x = s.width / 2; + infoLabel.y = s.height - 90; + this.addChild(infoLabel, 1, TAG_INFO_LAYER); + + // add menu + var menu = new SpriteMenuLayer(true, 7, s_nSpriteCurCase); + this.addChild(menu, 1, TAG_SPRITE_MENU_LAYER); + + // Sub Tests + cc.MenuItemFont.setFontSize(32); + var subMenu = new cc.Menu(); + for (var i = 1; i <= 9; ++i) { + var text = i.toString(); + var itemFont = new cc.MenuItemFont(text, this.testNCallback, this); + itemFont.tag = i; + subMenu.addChild(itemFont, 10); + + if (i <= 3) + itemFont.color = cc.color(200, 20, 20); + else if (i <= 6) + itemFont.color = cc.color(0, 200, 20); + else + itemFont.color = cc.color(0, 20, 200); + } + + subMenu.alignItemsHorizontally(); + subMenu.x = s.width / 2; + subMenu.y = 80; + this.addChild(subMenu, 2); + + while (this._quantityNodes < nodes) { + this.onIncrease(this); + } + }, + updateNodes:function () { + if (this._quantityNodes != this._lastRenderedCount) { + var infoLabel = this.getChildByTag(TAG_INFO_LAYER); + var str = this._quantityNodes + " nodes"; + infoLabel.setString(str); + + this._lastRenderedCount = this._quantityNodes; + } + }, + testNCallback:function (sender) { + this._subtestNumber = sender.tag; + var menu = this.getChildByTag(TAG_SPRITE_MENU_LAYER); + menu.restartCallback(sender); + }, + onIncrease:function (sender) { + if (this._quantityNodes >= MAX_SPRITES) + return; + + for (var i = 0; i < SPRITES_INCREASE; i++) { + var sprite = this._subTest.createSpriteWithTag(this._quantityNodes); + this.doTest(sprite); + this._quantityNodes++; + } + + this.updateNodes(); + }, + onDecrease:function (sender) { + if (this._quantityNodes <= 0) + return; + + for (var i = 0; i < SPRITES_INCREASE; i++) { + this._quantityNodes--; + this._subTest.removeByTag(this._quantityNodes); + } + + this.updateNodes(); + }, + + doTest:function (sprite) { + + }, + + getSubTestNum:function () { + return this._subtestNumber + }, + getNodesNum:function () { + return this._quantityNodes + } +}); + + +//////////////////////////////////////////////////////// +// +// For test functions +// +//////////////////////////////////////////////////////// +function performanceActions(sprite) { + var size = cc.director.getWinSize(); + sprite.x = parseInt(Math.random() * size.width); + sprite.y = parseInt(Math.random() * size.height); + + var period = 0.5 + (Math.random() * 1000) / 500.0; + var rot = cc.rotateBy(period, 360.0 * Math.random()); + var rot_back = rot.reverse(); + var permanentRotation = cc.sequence(rot, rot_back).repeatForever(); + sprite.runAction(permanentRotation); + + var growDuration = 0.5 + (Math.random() * 1000) / 500.0; + var grow = cc.scaleBy(growDuration, 0.5, 0.5); + var permanentScaleLoop = cc.sequence(grow, grow.reverse()).repeatForever(); + sprite.runAction(permanentScaleLoop); +} + +function performanceActions20(sprite) { + var size = cc.director.getWinSize(); + if (Math.random() < 0.2) { + sprite.x = parseInt(Math.random() * size.width); + sprite.y = parseInt(Math.random() * size.height); + } + else { + sprite.x = -1000; + sprite.y = -1000; + } + + var period = 0.5 + (Math.random() * 1000) / 500.0; + var rot = cc.rotateBy(period, 360.0 * Math.random()); + var rot_back = rot.reverse(); + var permanentRotation = cc.sequence(rot, rot_back).repeatForever(); + sprite.runAction(permanentRotation); + + var growDuration = 0.5 + (Math.random() * 1000) / 500.0; + var grow = cc.scaleBy(growDuration, 0.5, 0.5); + var permanentScaleLoop = cc.sequence(grow, grow.reverse()).repeatForever(); + sprite.runAction(permanentScaleLoop); +} + +function performanceRotationScale(sprite) { + var size = cc.director.getWinSize(); + sprite.x = parseInt(Math.random() * size.width); + sprite.y = parseInt(Math.random() * size.height); + sprite.rotation = Math.random() * 360; + sprite.scale = Math.random() * 2; +} + +function performancePosition(sprite) { + var size = cc.director.getWinSize(); + sprite.x = parseInt(Math.random() * size.width); + sprite.y = parseInt(Math.random() * size.height); +} + +function performanceout20(sprite) { + var size = cc.director.getWinSize(); + + if (Math.random() < 0.2) { + sprite.x = parseInt(Math.random() * size.width); + sprite.y = parseInt(Math.random() * size.height); + } + else { + sprite.x = -1000; + sprite.y = -1000; + } +} + +function performanceOut100(sprite) { + sprite.x = -1000; + sprite.y = -1000; +} + +function performanceScale(sprite) { + var size = cc.director.getWinSize(); + sprite.x = parseInt(Math.random() * size.width); + sprite.y = parseInt(Math.random() * size.height); + sprite.scale = Math.random() * 100 / 50; +} + + +//////////////////////////////////////////////////////// +// +// SpritePerformTest1 +// +//////////////////////////////////////////////////////// +var SpritePerformTest1 = SpriteMainScene.extend({ + doTest:function (sprite) { + performancePosition(sprite); + }, + title:function () { + return "A (" + this._subtestNumber + ") position"; + } +}); + +//////////////////////////////////////////////////////// +// +// SpritePerformTest2 +// +//////////////////////////////////////////////////////// +var SpritePerformTest2 = SpriteMainScene.extend({ + doTest:function (sprite) { + performanceScale(sprite); + }, + title:function () { + return "B (" + this._subtestNumber + ") scale"; + } +}); + +//////////////////////////////////////////////////////// +// +// SpritePerformTest3 +// +//////////////////////////////////////////////////////// +var SpritePerformTest3 = SpriteMainScene.extend({ + doTest:function (sprite) { + performanceRotationScale(sprite); + }, + title:function () { + return "C (" + this._subtestNumber + ") scale + rot"; + } +}); + +//////////////////////////////////////////////////////// +// +// SpritePerformTest4 +// +//////////////////////////////////////////////////////// +var SpritePerformTest4 = SpriteMainScene.extend({ + doTest:function (sprite) { + performanceOut100(sprite); + }, + title:function () { + return "D (" + this._subtestNumber + ") 100% out"; + } +}); + +//////////////////////////////////////////////////////// +// +// SpritePerformTest5 +// +//////////////////////////////////////////////////////// +var SpritePerformTest5 = SpriteMainScene.extend({ + doTest:function (sprite) { + performanceout20(sprite); + }, + title:function () { + return "E (" + this._subtestNumber + ") 80% out"; + } +}); + +//////////////////////////////////////////////////////// +// +// SpritePerformTest6 +// +//////////////////////////////////////////////////////// +var SpritePerformTest6 = SpriteMainScene.extend({ + doTest:function (sprite) { + performanceActions(sprite); + }, + title:function () { + return "F (" + this._subtestNumber + ") actions"; + } +}); + +//////////////////////////////////////////////////////// +// +// SpritePerformTest7 +// +//////////////////////////////////////////////////////// +var SpritePerformTest7 = SpriteMainScene.extend({ + doTest:function (sprite) { + performanceActions20(sprite); + }, + title:function () { + return "G (" + this._subtestNumber + ") actions 80% out"; + } +}); + +function runSpriteTest() { + Math.seedrandom('perftest'); + + var scene = new SpritePerformTest1; + scene.initWithSubTest(1, 50); + cc.director.runScene(scene); +} diff --git a/tests/js-tests/src/PerformanceTest/PerformanceSpriteTest2.js b/tests/js-tests/src/PerformanceTest/PerformanceSpriteTest2.js new file mode 100644 index 0000000000..ec58fb9551 --- /dev/null +++ b/tests/js-tests/src/PerformanceTest/PerformanceSpriteTest2.js @@ -0,0 +1,305 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + 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. + ****************************************************************************/ + +var SECONDS_PER_TEST = 5; +//------------------------------------------------------------------ +// +// Profiler +// +//------------------------------------------------------------------ + +function Profiling(name) { + this.name = name; + this.numberOfCalls = 0; + this.totalTime = 0; + this.minTime = 10000; + this.maxTime = 0; + this.lastUpdate = 0; + + this.beginBlock = function() { + this.lastUpdate = Date.now(); + }; + + this.endBlock = function() { + var now = Date.now(); + var diff = now-this.lastUpdate; + this.totalTime += diff; + this.numberOfCalls++; + this.minTime = Math.min(this.minTime, diff); + this.maxTime = Math.max(this.maxTime, diff); + }; + + this.beginEndBlock = function(diff) { + this.totalTime += diff; + this.numberOfCalls++; + this.minTime = Math.min(this.minTime, diff); + this.maxTime = Math.max(this.maxTime, diff); + }; + + this.reset = function() { + this.totalTime = 0; + this.minTime = 100000; + this.maxTime = 0; + this.lastUpdate = 0; + this.numberOfCalls = 0; + }; + + this.dump = function() { + cc.log('Profiling info for: ' + this.name + '\n' + + 'Number of calls: ' + this.numberOfCalls + '\n' + + 'Average Time: ' + (this.totalTime/this.numberOfCalls)/1000 + '\n' + + 'Min Time: ' + this.minTime/1000 + '\n' + + 'Max Time: ' + this.maxTime/1000 + '\n' + + 'Total Time: ' + this.totalTime/1000 + '\n' + ); + }; +} + + + +var performanceSpriteTestSceneIdx = -1; +//------------------------------------------------------------------ +// +// PerformanceSpriteTestDemo +// +//------------------------------------------------------------------ +var PerformanceTestBase = cc.Layer.extend({ + _title:"", + _subtitle:"", + + ctor:function() { + this._super(); + this.init(); + }, + onEnter:function () { + this._super(); + + var label = new cc.LabelTTF(this._title, "Arial", 28); + this.addChild(label, 1); + label.x = winSize.width / 2; + label.y = winSize.height - 50; + + if (this._subtitle !== "") { + var l = new cc.LabelTTF(this._subtitle, "Thonburi", 16); + this.addChild(l, 1); + l.x = winSize.width / 2; + l.y = winSize.height - 80; + } + + var item1 = new cc.MenuItemImage(s_pathB1, s_pathB2, this.onBackCallback, this); + var item2 = new cc.MenuItemImage(s_pathR1, s_pathR2, this.onRestartCallback, this); + var item3 = new cc.MenuItemImage(s_pathF1, s_pathF2, this.onNextCallback, this); + + var menu = new cc.Menu(item1, item2, item3); + + menu.x = 0; + + menu.y = 0; + var csw = item2.width, csh = item2.height; + item1.x = winSize.width/2 - csw*2; + item1.y = csh/2; + item2.x = winSize.width/2; + item2.y = csh/2; + item3.x = winSize.width/2 + csw*2; + item3.y = csh/2; + + this.addChild(menu, 1); + }, + + onRestartCallback:function (sender) { + var s = new PerformanceSpriteTestScene(); + s.addChild(restartPerformanceSpriteTest()); + director.runScene(s); + }, + onNextCallback:function (sender) { + var s = new PerformanceSpriteTestScene(); + s.addChild(nextPerformanceSpriteTest()); + director.runScene(s); + }, + onBackCallback:function (sender) { + var s = new PerformanceSpriteTestScene(); + s.addChild(previousPerformanceSpriteTest()); + director.runScene(s); + } +}); + +//------------------------------------------------------------------ +// +// PerformanceSpriteTest1 +// +//------------------------------------------------------------------ +var PerformanceSpriteTest1 = PerformanceTestBase.extend({ + _title:"Performance Test 1", + _subtitle:"Let it run until you see the 'done' message. See console for results.", + + ctor:function () { + this._super(); + + this.testFunctions = [this.testA, this.testB]; + this.endFunctions = [this.endA, this.endB]; + this.testSpriteTotals = [100,500,1000,2000,5000,10000]; + this.functionsIdx = 0; + this.spritesTotalsIdx = -1; + + this.runNextTest(); + + this.scheduleUpdate(); + this.schedule( this.endProfiling, SECONDS_PER_TEST); + this.firstTick = true; + }, + + runNextTest:function() { + + // cleanup current function + if( this.spritesTotalsIdx != -1) { + var cleanup = this.endFunctions[ this.functionsIdx ]; + cleanup.bind(this)(); + } + + this.spritesTotalsIdx++; + + // get next function + if( this.spritesTotalsIdx >= this.testSpriteTotals.length ) { + this.spritesTotalsIdx = 0; + this.functionsIdx++; + if( this.functionsIdx >= this.testFunctions.length ) { + cc.log("No more tests"); + return false; + } + } + var func = this.testFunctions[ this.functionsIdx ]; + var t = this.testSpriteTotals[ this.spritesTotalsIdx ]; + func.bind(this)(t); + return true; + }, + + testA:function(num) { + // Draws all sprites on the screen + // Non-batched drawing + + this.profiling = new Profiling("Test A - Total Sprites: " + num); + + // use the same seed for the tests + Math.seedrandom('perftest'); + var parent = new cc.Node(); + this.addChild(parent,0,10); + + for( var i=0; i 1.0) { + var frameRateB = (this._numberOfTouchesB / this._elapsedTime).toFixed(1); + var frameRateM = (this._numberOfTouchesM / this._elapsedTime).toFixed(1); + var frameRateE = (this._numberOfTouchesE / this._elapsedTime).toFixed(1); + var frameRateC = (this._numberOfTouchesC / this._elapsedTime).toFixed(1); + this._elapsedTime = 0; + this._numberOfTouchesB = this._numberOfTouchesM = this._numberOfTouchesE = this._numberOfTouchesC = 0; + + var str = frameRateB + " " + frameRateM + " " + frameRateE + " " + frameRateC; + this._plabel.setString(str); + } + } +}); + +//////////////////////////////////////////////////////// +// +// TouchesPerformTest1 +// +//////////////////////////////////////////////////////// +var TouchesPerformTest1 = TouchesMainScene.extend({ + onEnter:function () { + this._super(); + + var _this = this; + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches: true, + onTouchBegan:function (touch, event) { + _this._numberOfTouchesB++; + return true; + }, + onTouchMoved:function (touch, event) { + _this._numberOfTouchesM++; + }, + onTouchEnded:function (touch, event) { + _this._numberOfTouchesE++; + }, + onTouchCancelled:function (touch, event) { + _this._numberOfTouchesC++; + } + }, this); + }, + title:function () { + return "Targeted touches"; + } +}); + +//////////////////////////////////////////////////////// +// +// TouchesPerformTest2 +// +//////////////////////////////////////////////////////// +var TouchesPerformTest2 = TouchesMainScene.extend({ + onEnter:function () { + this._super(); + var _this = this; + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesBegan:function (touches, event) { + _this._numberOfTouchesB += touches.length; + }, + onTouchesMoved:function (touches, event) { + _this._numberOfTouchesM += touches.length; + }, + onTouchesEnded:function (touches, event) { + _this._numberOfTouchesE += touches.length; + }, + onTouchesCancelled:function (touches, event) { + _this._numberOfTouchesC += touches.length; + } + }, this); + }, + title:function () { + return "Standard touches"; + } +}); + +function runTouchesTest() { + s_nTouchCurCase = 0; + var scene = new cc.Scene(); + var layer = new TouchesPerformTest1(true, 2, s_nTouchCurCase); + scene.addChild(layer); + cc.director.runScene(scene); +} diff --git a/tests/js-tests/src/PerformanceTest/PerformanceVirtualMachineTest.js b/tests/js-tests/src/PerformanceTest/PerformanceVirtualMachineTest.js new file mode 100644 index 0000000000..1385f6f00e --- /dev/null +++ b/tests/js-tests/src/PerformanceTest/PerformanceVirtualMachineTest.js @@ -0,0 +1,550 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 VM_TAG_BASE = 2000; +var VM_MAX_NODES = 1500; +var VM_NODES_INCREASE = 100; +var s_nVMCurCase = 0; + +//////////////////////////////////////////////////////// +// +// VirtualMachineTestMenuLayer +// +// These are some demo test cases about low level JS engine behavior, so in +// some sense this is simliar to PerformanceNodeChildrenTest. This file is +// derived from PerformanceNodeChildrenTest.js actually. +// +// See https://github.com/oupengsoftware/v8/wiki for some of the details (V8) +// under the hood. +// Keyword: hidden class, inline cache, dictionary mode. +// +//////////////////////////////////////////////////////// +var VirtualMachineTestMenuLayer = PerformBasicLayer.extend({ + _maxCases:6, + ctor:function(){ + this._super(); + this._maxCases = (cc._renderType === cc._RENDER_TYPE_CANVAS) ? 6 : 4; + }, + showCurrentTest:function () { + var nodes = (this.parent).getQuantityOfNodes(); + var scene = null; + switch (this._curCase) { + case 0: + scene = new SpritesWithManyPropertiesTestScene1(); + break; + case 1: + scene = new SpritesWithManyPropertiesTestScene2(); + break; + case 2: + scene = new SpritesUndergoneDifferentOperationsTestScene1(); + break; + case 3: + scene = new SpritesUndergoneDifferentOperationsTestScene2(); + break; + case 4: + scene = new ClonedSpritesTestScene1(); + break; + case 5: + scene = new ClonedSpritesTestScene2(); + break; + } + s_nVMCurCase = this._curCase; + + if (scene) { + scene.initWithQuantityOfNodes(nodes); + cc.director.runScene(scene); + } + } +}); + +//////////////////////////////////////////////////////// +// +// VirtualMachineTestMainScene +// +//////////////////////////////////////////////////////// +var VirtualMachineTestMainScene = cc.Scene.extend({ + _lastRenderedCount:null, + _quantityOfNodes:null, + _currentQuantityOfNodes:null, + _batchNode:null, + + ctor:function() { + this._super(); + this.init(); + }, + + initWithQuantityOfNodes:function (nodes) { + this._batchNode = new cc.SpriteBatchNode("res/Images/grossinis_sister1.png"); + this.addChild(this._batchNode); + + //srand(time()); + var s = cc.director.getWinSize(); + + // Title + var label = new cc.LabelTTF(this.title(), "Arial", 40); + this.addChild(label, 1); + label.x = s.width / 2; + label.y = s.height - 32; + label.color = cc.color(255, 255, 40); + + // Subtitle + var strSubTitle = this.subtitle(); + if (strSubTitle.length) { + var l = new cc.LabelTTF(strSubTitle, "Thonburi", 16); + this.addChild(l, 1); + l.x = s.width / 2; + l.y = s.height - 80; + } + + this._lastRenderedCount = 0; + this._currentQuantityOfNodes = 0; + this._quantityOfNodes = nodes; + + cc.MenuItemFont.setFontSize(65); + var that = this; + var decrease = new cc.MenuItemFont(" - ", this.onDecrease, this); + decrease.color = cc.color(0, 200, 20); + var increase = new cc.MenuItemFont(" + ", this.onIncrease, this); + increase.color = cc.color(0, 200, 20); + + var menu = new cc.Menu(decrease, increase); + menu.alignItemsHorizontally(); + menu.x = s.width / 2; + menu.y = s.height / 2 + 15; + this.addChild(menu, 1); + + var infoLabel = new cc.LabelTTF("0 nodes", "Marker Felt", 30); + infoLabel.color = cc.color(0, 200, 20); + infoLabel.x = s.width / 2; + infoLabel.y = s.height / 2 - 15; + this.addChild(infoLabel, 1, TAG_INFO_LAYER); + + var menu = new VirtualMachineTestMenuLayer(true, 3, s_nVMCurCase); + this.addChild(menu); + + this.updateQuantityLabel(); + this.updateQuantityOfNodes(); + this.scheduleUpdate(); + }, + title:function () { + cc.Assert(0); + // override me + }, + subtitle:function () { + cc.Assert(0); + // override me + }, + updateQuantityOfNodes:function () { + cc.Assert(0); + // override me + }, + onDecrease:function (sender) { + this._quantityOfNodes -= VM_NODES_INCREASE; + if (this._quantityOfNodes < 0) { + this._quantityOfNodes = 0; + } + + this.updateQuantityLabel(); + this.updateQuantityOfNodes(); + }, + onIncrease:function (sender) { + this._quantityOfNodes += VM_NODES_INCREASE; + if (this._quantityOfNodes > VM_MAX_NODES) { + this._quantityOfNodes = VM_MAX_NODES + } + + this.updateQuantityLabel(); + this.updateQuantityOfNodes(); + }, + updateQuantityLabel:function () { + if (this._quantityOfNodes != this._lastRenderedCount) { + var infoLabel = this.getChildByTag(TAG_INFO_LAYER); + var str = this._quantityOfNodes + " nodes"; + infoLabel.setString(str); + + this._lastRenderedCount = this._quantityOfNodes; + } + }, + getQuantityOfNodes:function () { + return this._quantityOfNodes; + }, + arrayToUpdate:null, + update:function (dt) { + if (!this.arrayToUpdate) return; + for (var i = 0, imax = this.arrayToUpdate.length; i < imax; ++i) { + var child = this.arrayToUpdate[i]; + if (!(child instanceof SimpleNewtonianSprite) && + child instanceof cc.Class) continue; // old cc.clone-ed + // sprite is not a cc.Class + for (var j = 0; j < 1000; ++j ) { + child._velocityX = child._velocityX + dt * child._accelerationX; + child._velocityY = child._velocityY + dt * child._accelerationY; + child._positionX = child._positionX + dt * child._velocityX; + child._positionY = child._positionY + dt * child._velocityY; + } + } + } +}); + +// Simple sprite extension used for testing the performance of property access. +var SimpleNewtonianSprite = cc.Sprite.extend({ + ctor:function(texture, rect) { + cc.Sprite.prototype.ctor.call(this); + // Since jsb doesn't have ._position, in order not to make these + // showcase more complicated by introducing fuction calls (because + // different JS engines have different inlining strategy), we simply + // introduce ._postionX ._positionY here. These (and update()) really + // just represent *heavy property access operation* anyway (they're + // otherwise dummy). + this._positionX = 0.0; + this._positionY = 0.0; + this._velocityX = 0.0; + this._velocityY = 0.0; + this._accelerationX = 0.0; + this._accelerationY = 0.0; + + if(texture && rect) + this.initWithTexture(texture, rect); + } +}); + +//////////////////////////////////////////////////////// +// +// SpritesWithManyPropertiesTestScene +// +// Some JS engines (notably, V8) assume that objects with many properties are +// dictionary (c.f CCClass.js) and that makes bad performance. Here we +// simulate a character class with many properties of a character, but +// otherwise these properties are dummy (and probably doesn't make much +// sense) in the test of course. +// (TODO: Find a open source real world example, which shouldn't be that hard. +// :) ) +// +//////////////////////////////////////////////////////// +var SpriteWithManyProperties = SimpleNewtonianSprite.extend({ + ctor:function(texture, rect) { + SimpleNewtonianSprite.prototype.ctor.call(this, texture, rect); + this._name = ""; + this._species = ""; + this._id = -1; + this._hp = 100; + this._mp = 100; + this._exp = 100; + this._lv = 1; + this._str = 100; + this._dex = 100; + this._int = 100; + this._luk = 100; + this._gold = 10000000; // I'm rich. + this._weight = 100.0; + this._height = 100.0; + this._items = []; + this._spells = []; + this._dressing = null; + this._weapon = null; + this._mission = null; + this._friends = []; + this._groups = []; + + this._idleTime = 0.0; + this._loginTime = 0.0; + this._isAutoMove = false; + this._autoMoveTarget = false; + this._attackMode = 0; + this._active = true; + this._canBeAttack = true; + this._isLocalPlayer = false; + this._moveType = null; + this._I_AM_TIRED_OF_COMING_UP_WITH_NEW_PROPERTIES = true; + } +}); + +var SpritesWithManyPropertiesTestScene1 = VirtualMachineTestMainScene.extend({ + updateQuantityOfNodes:function () { + var s = cc.director.getWinSize(); + + // increase nodes + if (this._currentQuantityOfNodes < this._quantityOfNodes) { + for (var i = 0; + i < (this._quantityOfNodes - this._currentQuantityOfNodes); + i++) { + var sprite = + new SpriteWithManyProperties(this._batchNode.texture, + cc.rect(0, 0, 52, 139)); + this._batchNode.addChild(sprite); + sprite.x = Math.random() * s.width; + sprite.y = Math.random() * s.height; + } + } + + // decrease nodes + else if (this._currentQuantityOfNodes > this._quantityOfNodes) { + for (var i = 0; + i < (this._currentQuantityOfNodes - this._quantityOfNodes); + i++) { + var index = this._currentQuantityOfNodes - i - 1; + this._batchNode.removeChildAtIndex(index, true); + } + } + + this._currentQuantityOfNodes = this._quantityOfNodes; + }, + title:function () { + return "A1 - Sprites Have Many Properties"; + }, + subtitle:function () { + return "See fps (and source code of this test)."; + } +}); + +var SpritesWithManyPropertiesTestScene2 = + SpritesWithManyPropertiesTestScene1.extend({ + updateQuantityOfNodes:function () { + this._super(); + var arrayToUpdate = this._batchNode.children; + for (var i = 0, imax = arrayToUpdate.length; i < imax; ++i) + arrayToUpdate[i].visible = false; + this.arrayToUpdate = arrayToUpdate; + }, + title:function () { + return "A2 - Sprites Have Many Properties"; + }, + subtitle:function () { + return "No draw(). update() does heavy calculations."; + } +}); + +//////////////////////////////////////////////////////// +// +// SpritesUndergoneDifferentOperationsTestScene +// +// If properties in use are not initilized on each instance, a combinarial +// explosion of hidden classes have to be created for each possible +// permutation of operations. This increases inline cache size and +// constitutes significant performance penalty. +// +//////////////////////////////////////////////////////// + +var SpritesUndergoneDifferentOperationsTestScene1 = VirtualMachineTestMainScene.extend({ + // Adpated from http://codereview.stackexchange.com/a/7025 + possibleOperationSeries:(function permutations(array){ + var fn = function(active, rest, a) { + if (!active.length && !rest.length) { + a.push([]); + return; + } + if (!rest.length) { + if (active.length === 1) { + a.push(active); + return; + } + + var fac = 1; + for (var i = active.length; i > 0; --i) fac = fac * i; + for (var i = 0; i < fac; ++i) { + var choice_num = i; + var choice = []; + for (var j = 1; j < active.length + 1; ++j) { + choice.unshift(choice_num % j); + choice_num = (choice_num - choice_num % j) / j; + } + + var to_choose_from = active.slice(0); + var new_permutation = []; + for (var k = 0; k < active.length; ++k) + new_permutation.push(to_choose_from. + splice(choice[k], 1)[0]); + a.push(new_permutation); + } + } else { + fn(active.concat([rest[0]]), rest.slice(1), a); + fn(active, rest.slice(1), a); + } + return a; + }; + return fn([], array, []); + })([ + function() { this.children; }, // appends ._children + function() { this.tag = cc.NODE_TAG_INVALID; }, // appends .tag + function() { this.setParent(null); }, // appends ._parent + function() { this.zIndex = 0; }, // appends ._zOrder + function() { this.rotation = 0; }, // appends ._rotationX/Y + function() { this.visible = true; }, // appends ._visible + function() { this.onEnter(); } // appends ._running + ]), + updateQuantityOfNodes:function () { + var s = cc.director.getWinSize(); + + // increase nodes + if (this._currentQuantityOfNodes < this._quantityOfNodes) { + for (var i = 0; + i < (this._quantityOfNodes - this._currentQuantityOfNodes); + i++) { + var sprite = + new SimpleNewtonianSprite(this._batchNode.texture, + cc.rect(0, 0, 52, 139)); + var series = this.possibleOperationSeries[i]; + for (var op = 0, opmax = series.length; op < opmax; ++op) + series[op].call(sprite); + + this._batchNode.addChild(sprite); + sprite.x = Math.random() * s.width; + sprite.y = Math.random() * s.height; + } + } + + // decrease nodes + else if (this._currentQuantityOfNodes > this._quantityOfNodes) { + for (var i = 0; + i < (this._currentQuantityOfNodes - this._quantityOfNodes); + i++) { + var index = this._currentQuantityOfNodes - i - 1; + this._batchNode.removeChildAtIndex(index, true); + } + } + + this._currentQuantityOfNodes = this._quantityOfNodes; + }, + title:function () { + return "B1 - Sprites Undergone Different Op. Order"; + }, + subtitle:function () { + return "See fps (and source code of this test)."; + } +}); + +var SpritesUndergoneDifferentOperationsTestScene2 = + SpritesUndergoneDifferentOperationsTestScene1.extend({ + // This looks exactly like the one on ManyPropertiesTestScene2, but + // we can't just do + // 'updateQuantityOfNodes: SpritesWithManyPropertiesTestScene2.prototype.updateQuantityOfNodes' + // here becasue this._super() is different! + updateQuantityOfNodes:function () { + this._super(); + var arrayToUpdate = this._batchNode.children; + for (var i = 0, imax = arrayToUpdate.length; i < imax; ++i) + arrayToUpdate[i].visible = false; + this.arrayToUpdate = arrayToUpdate; + }, + title:function () { + return "B2 - Sprites Undergone Different Op. Order"; + }, + subtitle:function () { + return "No draw(). update() does heavy calculations."; + } +}); + +//////////////////////////////////////////////////////// +// +// ClonedSpritesTestScene +// +// cc.clone has to be written carefully or cloned objects all go to dictionary +// mode. +// +//////////////////////////////////////////////////////// +var ClonedSpritesTestScene1 = VirtualMachineTestMainScene.extend({ + template:null, + updateQuantityOfNodes:function () { + if (!this.template) + this.template = + new SimpleNewtonianSprite(this._batchNode.texture, + cc.rect(0, 0, 52, 139)); + var s = cc.director.getWinSize(); + + // increase nodes + if (this._currentQuantityOfNodes < this._quantityOfNodes) { + for (var i = 0; + i < (this._quantityOfNodes - this._currentQuantityOfNodes); + i++) { + var sprite = cc.clone(this.template); + sprite.setParent(null); // old cc.clone copies null as {}... + + // cc.SpriteBatchNode doesn't support adding non-cc.Sprite child + // and hence incompatible with old cc.clone. We add the sprite + // to the scene directly. + this.addChild(sprite, -1); // zOrder has to be less than 0 or it + // overlaps the menu. + sprite.x = Math.random() * s.width; + sprite.y = Math.random() * s.height; + } + } + + // decrease nodes + else if (this._currentQuantityOfNodes > this._quantityOfNodes) { + var children = this.children; + var lastChildToRemove = children.length; + for (var i = children.length - 1; i >= 0; --i) { + var child = children[i]; + if (child instanceof SimpleNewtonianSprite || + !(child instanceof cc.Class)) { // old cc.clone-ed + // sprite is not a cc.Class + lastChildToRemove = i; + break; + } + } + + for (var i = 0; + i < (this._currentQuantityOfNodes - this._quantityOfNodes); + i++) { + var index = lastChildToRemove - i; + this.removeChild(children[index], true); + } + } + + this._currentQuantityOfNodes = this._quantityOfNodes; + }, + title:function () { + return "C1 - Cloned Sprites"; + }, + subtitle:function () { + return "See fps (and source code of this test)."; + } +}); + +var ClonedSpritesTestScene2 = ClonedSpritesTestScene1.extend({ + updateQuantityOfNodes:function () { + if (!this.template) { + this.template = + new SimpleNewtonianSprite(this._batchNode.texture, + cc.rect(0, 0, 52, 139)); + this.template.visible = false; + } + this._super(); + this.arrayToUpdate = this.children; + }, + title:function () { + return "C2 - Cloned Sprites"; + }, + subtitle:function () { + return "No draw(). update() does heavy calculations."; + } +}); + +function runVirtualMachineTest() { + var scene = new SpritesWithManyPropertiesTestScene1(); + scene.initWithQuantityOfNodes(VM_NODES_INCREASE); + cc.director.runScene(scene); +} diff --git a/tests/js-tests/src/PerformanceTest/seedrandom.js b/tests/js-tests/src/PerformanceTest/seedrandom.js new file mode 100644 index 0000000000..58b4a96158 --- /dev/null +++ b/tests/js-tests/src/PerformanceTest/seedrandom.js @@ -0,0 +1,272 @@ +// seedrandom.js version 2.0. +// Author: David Bau 4/2/2011 +// +// Defines a method Math.seedrandom() that, when called, substitutes +// an explicitly seeded RC4-based algorithm for Math.random(). Also +// supports automatic seeding from local or network sources of entropy. +// +// Usage: +// +// +// +// Math.seedrandom('yipee'); Sets Math.random to a function that is +// initialized using the given explicit seed. +// +// Math.seedrandom(); Sets Math.random to a function that is +// seeded using the current time, dom state, +// and other accumulated local entropy. +// The generated seed string is returned. +// +// Math.seedrandom('yowza', true); +// Seeds using the given explicit seed mixed +// together with accumulated entropy. +// +// +// Seeds using physical random bits downloaded +// from random.org. +// +// Seeds using urandom bits from call.jsonlib.com, +// which is faster than random.org. +// +// Examples: +// +// Math.seedrandom("hello"); // Use "hello" as the seed. +// document.write(Math.random()); // Always 0.5463663768140734 +// document.write(Math.random()); // Always 0.43973793770592234 +// var rng1 = Math.random; // Remember the current prng. +// +// var autoseed = Math.seedrandom(); // New prng with an automatic seed. +// document.write(Math.random()); // Pretty much unpredictable. +// +// Math.random = rng1; // Continue "hello" prng sequence. +// document.write(Math.random()); // Always 0.554769432473455 +// +// Math.seedrandom(autoseed); // Restart at the previous seed. +// document.write(Math.random()); // Repeat the 'unpredictable' value. +// +// Notes: +// +// Each time seedrandom('arg') is called, entropy from the passed seed +// is accumulated in a pool to help generate future seeds for the +// zero-argument form of Math.seedrandom, so entropy can be injected over +// time by calling seedrandom with explicit data repeatedly. +// +// On speed - This javascript implementation of Math.random() is about +// 3-10x slower than the built-in Math.random() because it is not native +// code, but this is typically fast enough anyway. Seeding is more expensive, +// especially if you use auto-seeding. Some details (timings on Chrome 4): +// +// Our Math.random() - avg less than 0.002 milliseconds per call +// seedrandom('explicit') - avg less than 0.5 milliseconds per call +// seedrandom('explicit', true) - avg less than 2 milliseconds per call +// seedrandom() - avg about 38 milliseconds per call +// +// LICENSE (BSD): +// +// Copyright 2010 David Bau, all rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of this module nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/** + * All code is in an anonymous closure to keep the global namespace clean. + * + * @param {number=} overflow + * @param {number=} startdenom + */ +(function (pool, math, width, chunks, significance, overflow, startdenom) { + + +// +// seedrandom() +// This is the seedrandom function described above. +// +math.seedrandom = function seedrandom(seed, use_entropy) { + var key = []; + var arc4; + + // Flatten the seed string or build one from local entropy if needed. + seed = mixkey(flatten( + use_entropy ? [seed, pool] : + arguments.length ? seed : + [Date.now(), pool, window], 3), key); + + // Use the seed to initialize an ARC4 generator. + arc4 = new ARC4(key); + + // Mix the randomness into accumulated entropy. + mixkey(arc4.S, pool); + + // Override Math.random + + // This function returns a random double in [0, 1) that contains + // randomness in every bit of the mantissa of the IEEE 754 value. + + math.random = function random() { // Closure to return a random double: + var n = arc4.g(chunks); // Start with a numerator n < 2 ^ 48 + var d = startdenom; // and denominator d = 2 ^ 48. + var x = 0; // and no 'extra last byte'. + while (n < significance) { // Fill up all significant digits by + n = (n + x) * width; // shifting numerator and + d *= width; // denominator and generating a + x = arc4.g(1); // new least-significant-byte. + } + while (n >= overflow) { // To avoid rounding up, before adding + n /= 2; // last byte, shift everything + d /= 2; // right using integer math until + x >>>= 1; // we have exactly the desired bits. + } + return (n + x) / d; // Form the number within [0, 1). + }; + + // Return the seed that was used + return seed; +}; + +// +// ARC4 +// +// An ARC4 implementation. The constructor takes a key in the form of +// an array of at most (width) integers that should be 0 <= x < (width). +// +// The g(count) method returns a pseudorandom integer that concatenates +// the next (count) outputs from ARC4. Its return value is a number x +// that is in the range 0 <= x < (width ^ count). +// +/** @constructor */ +function ARC4(key) { + var t, u, me = this, keylen = key.length; + var i = 0, j = me.i = me.j = me.m = 0; + me.S = []; + me.c = []; + + // The empty key [] is treated as [0]. + if (!keylen) { key = [keylen++]; } + + // Set up S using the standard key scheduling algorithm. + while (i < width) { me.S[i] = i++; } + for (i = 0; i < width; i++) { + t = me.S[i]; + j = lowbits(j + t + key[i % keylen]); + u = me.S[j]; + me.S[i] = u; + me.S[j] = t; + } + + // The "g" method returns the next (count) outputs as one number. + me.g = function getnext(count) { + var s = me.S; + var i = lowbits(me.i + 1); var t = s[i]; + var j = lowbits(me.j + t); var u = s[j]; + s[i] = u; + s[j] = t; + var r = s[lowbits(t + u)]; + while (--count) { + i = lowbits(i + 1); t = s[i]; + j = lowbits(j + t); u = s[j]; + s[i] = u; + s[j] = t; + r = r * width + s[lowbits(t + u)]; + } + me.i = i; + me.j = j; + return r; + }; + // For robust unpredictability discard an initial batch of values. + // See http://www.rsa.com/rsalabs/node.asp?id=2009 + me.g(width); +} + +// +// flatten() +// Converts an object tree to nested arrays of strings. +// +/** @param {Object=} result + * @param {string=} prop + * @param {string=} typ */ +function flatten(obj, depth, result, prop, typ) { + result = []; + typ = typeof(obj); + if (depth && typ == 'object') { + for (prop in obj) { + if (prop.indexOf('S') < 5) { // Avoid FF3 bug (local/sessionStorage) + try { result.push(flatten(obj[prop], depth - 1)); } catch (e) {} + } + } + } + return (result.length ? result : obj + (typ != 'string' ? '\0' : '')); +} + +// +// mixkey() +// Mixes a string seed into a key that is an array of integers, and +// returns a shortened string seed that is equivalent to the result key. +// +/** @param {number=} smear + * @param {number=} j */ +function mixkey(seed, key, smear, j) { + seed += ''; // Ensure the seed is a string + smear = 0; + for (j = 0; j < seed.length; j++) { + key[lowbits(j)] = + lowbits((smear ^= key[lowbits(j)] * 19) + seed.charCodeAt(j)); + } + seed = ''; + for (j in key) { seed += String.fromCharCode(key[j]); } + return seed; +} + +// +// lowbits() +// A quick "n mod width" for width a power of 2. +// +function lowbits(n) { return n & (width - 1); } + +// +// The following constants are related to IEEE 754 limits. +// +startdenom = math.pow(width, chunks); +significance = math.pow(2, significance); +overflow = significance * 2; + +// +// When seedrandom.js is loaded, we immediately mix a few bits +// from the built-in RNG into the entropy pool. Because we do +// not want to intefere with determinstic PRNG state later, +// seedrandom will not call math.random on its own again after +// initialization. +// +mixkey(math.random(), pool); + +// End anonymous scope, and pass initial values. +})( + [], // pool: entropy pool starts empty + Math, // math: package containing random, pow, and seedrandom + 256, // width: each RC4 output is 0 <= x < 256 + 6, // chunks: at least six RC4 outputs for each double + 52 // significance: there are 52 significant digits in a double +); diff --git a/tests/js-tests/src/Presentation/Presentation.js b/tests/js-tests/src/Presentation/Presentation.js new file mode 100644 index 0000000000..8d82ee231f --- /dev/null +++ b/tests/js-tests/src/Presentation/Presentation.js @@ -0,0 +1,768 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + 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. + ****************************************************************************/ + + +var presentationSceneIdx = -1; +var centerPos = cc.p(0,0); // will be updated later +var images_path = 'res/Presentation/'; + +//------------------------------------------------------------------ +// +// PresentationBaseLayer +// +//------------------------------------------------------------------ +var PresentationBaseLayer = function() { + + // + // VERY IMPORTANT + // + // Only subclasses of a native classes MUST call __associateObjectWithNative + // Failure to do so, it will crash. + // + var parent = BaseTestLayer.call(this, cc.color(0,0,0,255), cc.color(98,99,117,255)); + + this._title = "No title"; + this._subtitle = "No Subtitle"; + this.isMainTitle = false; + +}; +cc.inherits(PresentationBaseLayer, BaseTestLayer ); + +// +// Instance 'base' methods +// XXX: Should be defined after "cc.inherits" +// +PresentationBaseLayer.prototype.onEnter = function() { + + BaseTestLayer.prototype.onEnter.call(this); + + var fontSize = 36; + var tl = this._title.length; + fontSize = (winSize.width / tl) * 1.60; + if( fontSize/winSize.width > 0.09 ) { + fontSize = winSize.width * 0.09; + } + + this.label = new cc.LabelTTF(this._title, "Gill Sans", fontSize); + this.addChild(this.label, 100); + + var isMain = this.isMainTitle; + + if( isMain === true ) { + this.label.x = centerPos.x; + this.label.y = centerPos.y; + } + else { + this.label.x = winSize.width / 2; + this.label.y = winSize.height*11/12 ; + } + + var subStr = this._subtitle; + if (subStr !== "") { + tl = this._subtitle.length; + var subfontSize = (winSize.width / tl) * 1.3; + if( subfontSize > fontSize *0.4 ) { + subfontSize = fontSize *0.4; + } + + this.sublabel = new cc.LabelTTF(subStr, "Thonburi", subfontSize); + this.addChild(this.sublabel, 90); + if( isMain ) { + this.sublabel.x = winSize.width / 2; + this.sublabel.y = winSize.height*3/8; + } + else { + this.sublabel.x = winSize.width / 2; + this.sublabel.y = winSize.height*4/5; + } + } else + this.sublabel = null; + + // Opacity in Menu + var menu = this.getChildByTag(BASE_TEST_MENU_TAG); + var item1 = menu.getChildByTag(BASE_TEST_MENUITEM_PREV_TAG); + var item2 = menu.getChildByTag(BASE_TEST_MENUITEM_RESET_TAG); + var item3 = menu.getChildByTag(BASE_TEST_MENUITEM_NEXT_TAG); + + [item1, item2, item3 ].forEach( function(item) { + item.getNormalImage().opacity = 45; + item.getSelectedImage().opacity = 45; + } ); + + // remove "super" titles + this.removeChildByTag(BASE_TEST_TITLE_TAG); + this.removeChildByTag(BASE_TEST_SUBTITLE_TAG); +}; + +PresentationBaseLayer.prototype.prevTransition = function () { + return cc.TransitionSlideInL; +}; + +PresentationBaseLayer.prototype.nextTransition = function () { + return cc.TransitionSlideInR; +}; + +PresentationBaseLayer.prototype.createBulletList = function () { + var str = ""; + for(var i=0; i 1) { + var locLastLocation = this._lastLocation; + this._target.begin(); + this._brushs = []; + for(var i = 0; i < distance; ++i) { + var diffX = locLastLocation.x - location.x; + var diffY = locLastLocation.y - location.y; + var delta = i / distance; + var sprite = new cc.Sprite(s_fire); + sprite.attr({ + x: location.x + diffX * delta, + y: location.y + diffY * delta, + rotation: Math.random() * 360, + color: cc.color(Math.random() * 255, 255, 255), + scale: Math.random() + 0.25, + opacity: 20 + }); + sprite.retain(); + this._brushs.push(sprite); + } + for (var i = 0; i < distance; i++) { + this._brushs[i].visit(); + } + this._target.end(); + } + this._lastLocation = location; + }, + + subtitle:function () { + return "Testing 'save'"; + } +}); + +var RenderTextureIssue937 = RenderTextureBaseLayer.extend({ + ctor:function () { + this._super(); + var winSize = cc.director.getWinSize(); + /* + * 1 2 + * A: A1 A2 + * + * B: B1 B2 + * + * A1: premulti sprite + * A2: premulti render + * + * B1: non-premulti sprite + * B2: non-premulti render + */ + var background = new cc.LayerColor(cc.color(200, 200, 200, 255)); + this.addChild(background); + + var spr_premulti = new cc.Sprite(s_fire); + spr_premulti.x = 16; + spr_premulti.y = 48; + + var spr_nonpremulti = new cc.Sprite(s_fire); + spr_nonpremulti.x = 16; + spr_nonpremulti.y = 16; + + /* A2 & B2 setup */ + var rend = new cc.RenderTexture(32, 64, cc.Texture2D.PIXEL_FORMAT_RGBA8888); + if (!rend) + return; + // It's possible to modify the RenderTexture blending function by + // [[rend sprite] setBlendFunc:(ccBlendFunc) {GL_ONE, GL_ONE_MINUS_SRC_ALPHA}]; + //rend.getSprite().setBlendFunc(cc._renderContext.ONE, cc._renderContext.ONE_MINUS_SRC_ALPHA); + rend.begin(); + spr_premulti.visit(); + spr_nonpremulti.visit(); + rend.end(); + + /* A1: setup */ + spr_premulti.x = winSize.width / 2 - 16; + spr_premulti.y = winSize.height / 2 + 16; + /* B1: setup */ + spr_nonpremulti.x = winSize.width / 2 - 16; + spr_nonpremulti.y = winSize.height / 2 - 16; + + rend.x = winSize.width / 2 + 16; + rend.y = winSize.height / 2; + //background.visible = false; + this.addChild(spr_nonpremulti); + this.addChild(spr_premulti); + this.addChild(rend); + }, + + title:function () { + return "Testing issue #937"; + }, + + subtitle:function () { + return "All images should be equal.."; + } +}); + +var RenderTextureZbuffer = RenderTextureBaseLayer.extend({ + mgr:null, + sp1:null, + sp2:null, + sp3:null, + sp4:null, + sp5:null, + sp6:null, + sp7:null, + sp8:null, + sp9:null, + + ctor:function () { + this._super(); + + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesBegan: this.onTouchesBegan.bind(this), + onTouchesEnded: this.onTouchesEnded.bind(this), + onTouchesMoved: this.onTouchesMoved.bind(this) + }, this); + + var size = cc.director.getWinSize(); + var label = new cc.LabelTTF("vertexZ = 50", "Marker Felt", 64); + label.x = size.width / 2; + label.y = size.height * 0.25; + this.addChild(label); + + var label2 = new cc.LabelTTF("vertexZ = 0", "Marker Felt", 64); + label2.x = size.width / 2; + label2.y = size.height * 0.5; + this.addChild(label2); + + var label3 = new cc.LabelTTF("vertexZ = -50", "Marker Felt", 64); + label3.x = size.width / 2; + label3.y = size.height * 0.75; + this.addChild(label3); + + label.vertexZ = 50; + label2.vertexZ = 0; + label3.vertexZ = -50; + + cc.spriteFrameCache.addSpriteFrames(s_circle_plist); + this.mgr = new cc.SpriteBatchNode(s_circle_png, 9); + this.addChild(this.mgr); + this.sp1 = new cc.Sprite("#circle.png"); + this.sp2 = new cc.Sprite("#circle.png"); + this.sp3 = new cc.Sprite("#circle.png"); + this.sp4 = new cc.Sprite("#circle.png"); + this.sp5 = new cc.Sprite("#circle.png"); + this.sp6 = new cc.Sprite("#circle.png"); + this.sp7 = new cc.Sprite("#circle.png"); + this.sp8 = new cc.Sprite("#circle.png"); + this.sp9 = new cc.Sprite("#circle.png"); + + this.mgr.addChild(this.sp1, 9); + this.mgr.addChild(this.sp2, 8); + this.mgr.addChild(this.sp3, 7); + this.mgr.addChild(this.sp4, 6); + this.mgr.addChild(this.sp5, 5); + this.mgr.addChild(this.sp6, 4); + this.mgr.addChild(this.sp7, 3); + this.mgr.addChild(this.sp8, 2); + this.mgr.addChild(this.sp9, 1); + + this.sp1.vertexZ = 400; + this.sp2.vertexZ = 300; + this.sp3.vertexZ = 200; + this.sp4.vertexZ = 100; + this.sp5.vertexZ = 0; + this.sp6.vertexZ = -100; + this.sp7.vertexZ = -200; + this.sp8.vertexZ = -300; + this.sp9.vertexZ = -400; + + this.sp9.scale = 2; + this.sp9.color = cc.color.YELLOW; + }, + + onTouchesBegan:function (touches, event) { + if (!touches || touches.length === 0) + return; + + for (var i = 0; i < touches.length; i++) { + var location = touches[i].getLocation(); + + this.sp1.x = location.x; + this.sp1.y = location.y; + this.sp2.x = location.x; + this.sp2.y = location.y; + this.sp3.x = location.x; + this.sp3.y = location.y; + this.sp4.x = location.x; + this.sp4.y = location.y; + this.sp5.x = location.x; + this.sp5.y = location.y; + this.sp6.x = location.x; + this.sp6.y = location.y; + this.sp7.x = location.x; + this.sp7.y = location.y; + this.sp8.x = location.x; + this.sp8.y = location.y; + this.sp9.x = location.x; + this.sp9.y = location.y; + } + }, + + onTouchesMoved:function (touches, event) { + if (!touches || touches.length === 0) + return; + + for (var i = 0; i < touches.length; i++) { + var location = touches[i].getLocation(); + + this.sp1.x = location.x; + this.sp1.y = location.y; + this.sp2.x = location.x; + this.sp2.y = location.y; + this.sp3.x = location.x; + this.sp3.y = location.y; + this.sp4.x = location.x; + this.sp4.y = location.y; + this.sp5.x = location.x; + this.sp5.y = location.y; + this.sp6.x = location.x; + this.sp6.y = location.y; + this.sp7.x = location.x; + this.sp7.y = location.y; + this.sp8.x = location.x; + this.sp8.y = location.y; + this.sp9.x = location.x; + this.sp9.y = location.y; + } + }, + + onTouchesEnded:function (touches, event) { + this.renderScreenShot(); + }, + + title:function () { + return "Testing Z Buffer in Render Texture"; + }, + + subtitle:function () { + return "Touch screen. It should be green"; + }, + + renderScreenShot:function () { + var winSize = cc.director.getWinSize(); + var texture = new cc.RenderTexture(winSize.width, winSize.width); + if (!texture) + return; + + texture.anchorX = 0; + texture.anchorY = 0; + texture.begin(); + this.visit(); + texture.end(); + + var sprite = new cc.Sprite(texture.getSprite().texture); + + sprite.x = winSize.width/2; + sprite.y = winSize.width/2; + sprite.opacity = 182; + sprite.flippedY = 1; + this.addChild(sprite, 999999); + sprite.color = cc.color.GREEN; + + sprite.runAction(cc.sequence(cc.fadeTo(2, 0), cc.hide())); + } +}); + +var RenderTextureTestDepthStencil = RenderTextureBaseLayer.extend({ + ctor:function () { + //Need to re-write test case for new renderer + this._super(); + var gl = cc._renderContext; + + var winSize = cc.director.getWinSize(); + + var sprite = new cc.Sprite(s_fire); + sprite.x = winSize.width * 0.25; + sprite.y = 0; + sprite.scale = 10; + //TODO GL_DEPTH24_STENCIL8 + //var rend = new cc.RenderTexture(winSize.width, winSize.height, cc.TEXTURE_2D_PIXEL_FORMAT_RGBA4444); + var rend = new cc.RenderTexture(winSize.width, winSize.height); + + gl.stencilMask(0xFF); + rend.beginWithClear(0, 0, 0, 0, 0, 0); + + //! mark sprite quad into stencil buffer + gl.enable(gl.STENCIL_TEST); + gl.stencilFunc(gl.ALWAYS, 1, 0xFF); + gl.stencilOp(gl.KEEP, gl.KEEP, gl.REPLACE); + gl.colorMask(0, 0, 0, 1); + sprite.visit(); + + //! move sprite half width and height, and draw only where not marked + sprite.x += sprite.width * sprite.scale / 2; + sprite.y += sprite.height * sprite.scale / 2; + gl.stencilFunc(gl.NOTEQUAL, 1, 0xFF); + gl.colorMask(1, 1, 1, 1); + sprite.visit(); + + rend.end(); + + gl.disable(gl.STENCIL_TEST); + + rend.x = winSize.width * 0.5; + rend.y = winSize.height * 0.5; + + this.addChild(rend); + }, + + title:function () { + return "Testing depthStencil attachment"; + }, + + subtitle:function () { + return "Circle should be missing 1/4 of its region"; + } +}); + +var RenderTextureTargetNode = RenderTextureBaseLayer.extend({ + _sprite1:null, + _sprite2:null, + _time:0, + _winSize:null, + + _renderTexture:null, + + ctor:function () { + this._super(); + /* + * 1 2 + * A: A1 A2 + * + * B: B1 B2 + * + * A1: premulti sprite + * A2: premulti render + * + * B1: non-premulti sprite + * B2: non-premulti render + */ + var background = new cc.LayerColor(cc.color(40, 40, 40, 255)); + this.addChild(background); + + var winSize = cc.director.getWinSize(); + this._winSize = winSize; + + // sprite 1 + var sprite1 = new cc.Sprite(s_fire); + sprite1.x = winSize.width; + sprite1.y = winSize.height; + this._sprite1 = sprite1; + + // sprite 2 + //todo Images/fire_rgba8888.pvr + var sprite2 = new cc.Sprite(s_fire); + sprite2.x = winSize.width; + sprite2.y = winSize.height; + this._sprite2 = sprite2; + + /* Create the render texture */ + //var renderTexture = new cc.RenderTexture(winSize.width, winSize.height, cc.TEXTURE_2D_PIXEL_FORMAT_RGBA4444); + var renderTexture = new cc.RenderTexture(winSize.width, winSize.height); + this._renderTexture = renderTexture; + + renderTexture.x = winSize.width / 2; + renderTexture.y = winSize.height / 2; + // [renderTexture setPosition:cc.p(s.width, s.height)]; + // renderTexture.scale = 2; + + /* add the sprites to the render texture */ + renderTexture.addChild(this._sprite1); + renderTexture.addChild(this._sprite2); + renderTexture.clearColorVal = cc.color(0, 0, 0, 0); + renderTexture.clearFlags = cc._renderContext.COLOR_BUFFER_BIT; + + /* add the render texture to the scene */ + this.addChild(renderTexture); + + renderTexture.setAutoDraw(true); + + this.scheduleUpdate(); + + // Toggle clear on / off + var item = new cc.MenuItemFont("Clear On/Off", this.touched, this); + var menu = new cc.Menu(item); + this.addChild(menu); + + menu.x = winSize.width / 2; + menu.y = winSize.height / 2; + }, + + update:function (dt) { + var r = 80; + var locWinSize = this._winSize; + var locTime = this._time; + this._sprite1.x = Math.cos(locTime * 2) * r + locWinSize.width /2; + this._sprite1.y = Math.sin(locTime * 2) * r + locWinSize.height /2; + this._sprite2.x = Math.sin(locTime * 2) * r + locWinSize.width /2; + this._sprite2.y = Math.cos(locTime * 2) * r + locWinSize.height /2; + + this._time += dt; + }, + + title:function () { + return "Testing Render Target Node"; + }, + + subtitle:function () { + return "Sprites should be equal and move with each frame"; + }, + + touched:function (sender) { + if (this._renderTexture.clearFlags == 0) + this._renderTexture.clearFlags = cc._renderContext.COLOR_BUFFER_BIT; + else { + this._renderTexture.clearFlags = 0; + this._renderTexture.clearColorVal = cc.color(Math.random()*255, Math.random()*255, Math.random()*255, 255); + } + } +}); + +//------------------------------------------------------------------ +// +// Issue1464 +// +//------------------------------------------------------------------ +var Issue1464 = RenderTextureBaseLayer.extend({ + _brush : null, + _target : null, + _lastLocation : null, + _counter :0, + + ctor:function() { + this._super(); + + var sprite = new cc.Sprite(s_grossini); + + // create a render texture + var rend = new cc.RenderTexture( winSize.width/2, winSize.height/2 ); + rend.x = winSize.width/2; + rend.y = winSize.height/2 ; + this.addChild( rend, 1 ); + + sprite.x = winSize.width/4; + + sprite.y = winSize.height/4; + rend.begin(); + sprite.visit(); + rend.end(); + + var fadeout = cc.fadeOut(2); + var fadein = fadeout.reverse(); + var delay = cc.delayTime(0.25); + var seq = cc.sequence(fadeout, delay, fadein, delay.clone()); + var fe = seq.repeatForever(); + rend.getSprite().runAction(fe); + + if (!cc.sys.isNative && !("opengl" in cc.sys.capabilities)) { + var label = new cc.LabelTTF("Not support Actions on HTML5-canvas", "Times New Roman", 30); + label.x = winSize.width / 2; + label.y = winSize.height / 2 + 50; + this.addChild(label, 100); + } + }, + + title:function () { + return "Issue 1464"; + }, + + subtitle:function () { + return "Sprites should fade in / out correctly"; + }, + + // + // Automation + // + testDuration:2.1, + + getExpectedResult:function() { + // blue, red, blue + var ret = {"0":0,"1":0,"2":0,"3":255,"4":0,"5":0,"6":0,"7":255,"8":0,"9":0,"10":0,"11":255,"12":0,"13":0,"14":0,"15":255,"16":0,"17":0,"18":0,"19":255,"20":0,"21":0,"22":0,"23":255,"24":0,"25":0,"26":0,"27":255,"28":0,"29":0,"30":0,"31":255,"32":0,"33":0,"34":0,"35":255,"36":0,"37":0,"38":0,"39":255,"40":0,"41":0,"42":0,"43":255,"44":0,"45":0,"46":0,"47":255,"48":0,"49":0,"50":0,"51":255,"52":0,"53":0,"54":0,"55":255,"56":0,"57":0,"58":0,"59":255,"60":0,"61":0,"62":0,"63":255}; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = this.readPixels(winSize.width/2-2, winSize.height/2-2, 4, 4); + return JSON.stringify(ret); + } +}); + + +var RenderTextureTestScene = TestScene.extend({ + runThisTest:function (num) { + sceneRenderTextureIdx = (num || num == 0) ? (num - 1) : -1; + var layer = nextRenderTextureTest(); + this.addChild(layer); + + director.runScene(this); + } +}); + +// +// Flow control +// +var arrayOfRenderTextureTest = [ + RenderTextureSave, + Issue1464 +]; + +if(('opengl' in cc.sys.capabilities) && (!cc.sys.isNative) ){ + arrayOfRenderTextureTest.push(RenderTextureIssue937); + arrayOfRenderTextureTest.push(RenderTextureZbuffer); + arrayOfRenderTextureTest.push(RenderTextureTestDepthStencil); + arrayOfRenderTextureTest.push(RenderTextureTargetNode); +} + +var nextRenderTextureTest = function () { + sceneRenderTextureIdx++; + sceneRenderTextureIdx = sceneRenderTextureIdx % arrayOfRenderTextureTest.length; + + return new arrayOfRenderTextureTest[sceneRenderTextureIdx](); +}; +var previousRenderTextureTest = function () { + sceneRenderTextureIdx--; + if (sceneRenderTextureIdx < 0) + sceneRenderTextureIdx += arrayOfRenderTextureTest.length; + + return new arrayOfRenderTextureTest[sceneRenderTextureIdx](); +}; +var restartRenderTextureTest = function () { + return new arrayOfRenderTextureTest[sceneRenderTextureIdx](); +}; diff --git a/tests/js-tests/src/RotateWorldTest/RotateWorldTest.js b/tests/js-tests/src/RotateWorldTest/RotateWorldTest.js new file mode 100644 index 0000000000..bca0c01fc0 --- /dev/null +++ b/tests/js-tests/src/RotateWorldTest/RotateWorldTest.js @@ -0,0 +1,164 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 RotateWorldTestScene = TestScene.extend({ + runThisTest:function () { + var layer = new RotateWorldMainLayer(); + this.addChild(layer); + this.runAction(cc.rotateBy(4, -360)); + director.runScene(this); + } +}); + +var SpriteLayer = cc.Layer.extend({ + ctor:function () { + this._super(); + this.init(); + }, + + onEnter:function () { + this._super(); + + var x, y; + + var size = director.getWinSize(); + x = size.width; + y = size.height; + + var sprite = new cc.Sprite(s_pathGrossini); + var spriteSister1 = new cc.Sprite(s_pathSister1); + var spriteSister2 = new cc.Sprite(s_pathSister2); + + sprite.scale = 1.5; + spriteSister1.scale = 1.5; + spriteSister2.scale = 1.5; + + sprite.x = x / 2; + sprite.y = y / 2; + spriteSister1.x = 40; + spriteSister1.y = y / 2; + spriteSister2.x = x - 40; + spriteSister2.y = y / 2; + + var rot = cc.rotateBy(16, -3600); + + this.addChild(sprite); + this.addChild(spriteSister1); + this.addChild(spriteSister2); + + sprite.runAction(rot); + + var jump1 = cc.jumpBy(4, cc.p(-400, 0), 100, 4); + var jump2 = jump1.reverse(); + + var rot1 = cc.rotateBy(4, 360 * 2); + var rot2 = rot1.reverse(); + + spriteSister1.runAction(cc.sequence(jump2, jump1).repeat(5)); + spriteSister2.runAction(cc.sequence(jump1.clone(), jump2.clone()).repeat(5)); + + spriteSister1.runAction(cc.sequence(rot1, rot2).repeat(5)); + spriteSister2.runAction(cc.sequence(rot2.clone(), rot1.clone()).repeat(5)); + } +}); + +var TestLayer = cc.Layer.extend({ + ctor:function () { + this._super(); + this.init(); + }, + + onEnter:function () { + this._super(); + + var x, y; + + var size = director.getWinSize(); + x = size.width; + y = size.height; + + //cc.MutableArray *array = [UIFont familyNames]; + //for( cc.String *s in array ) + // NSLog( s ); + var label = new cc.LabelTTF("cocos2d", "Tahoma", 64); + + label.x = x / 2; + label.y = y / 2; + + this.addChild(label); + } +}); + +var RotateWorldMainLayer = cc.Layer.extend({ + ctor:function () { + this._super(); + this.init(); + }, + + onEnter:function () { + this._super(); + var x, y; + + var size = director.getWinSize(); + x = size.width; + y = size.height; + + var blue = new cc.LayerColor(cc.color(0, 0, 255, 255)); + var red = new cc.LayerColor(cc.color(255, 0, 0, 255)); + var green = new cc.LayerColor(cc.color(0, 255, 0, 255)); + var white = new cc.LayerColor(cc.color(255, 255, 255, 255)); + + blue.scale = 0.5; + blue.x = -x / 4; + blue.y = -y / 4; + blue.addChild(new SpriteLayer()); + + red.scale = 0.5; + red.x = x / 4; + red.y = -y / 4; + + green.scale = 0.5; + green.x = -x / 4; + green.y = y / 4; + green.addChild(new TestLayer()); + + white.scale = 0.5; + white.x = x / 4; + white.y = y / 4; + + this.addChild(blue, -1); + this.addChild(white); + this.addChild(green); + this.addChild(red); + + var rot = cc.rotateBy(8, 720); + + blue.runAction(rot); + red.runAction(rot.clone()); + green.runAction(rot.clone()); + white.runAction(rot.clone()); + } +}); diff --git a/tests/js-tests/src/SceneTest/SceneTest.js b/tests/js-tests/src/SceneTest/SceneTest.js new file mode 100644 index 0000000000..50df170891 --- /dev/null +++ b/tests/js-tests/src/SceneTest/SceneTest.js @@ -0,0 +1,221 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 MID_PUSHSCENE = 100; +var MID_PUSHSCENETRAN = 101; +var MID_QUIT = 102; +var MID_runScene = 103; +var MID_runSceneTRAN = 104; +var MID_GOBACK = 105; + +var SceneTestLayer1 = cc.Layer.extend({ + ctor:function () { + //----start0----Scene1-ctor + this._super(); + this.init(); + + var s = director.getWinSize(); + var item1 = new cc.MenuItemFont("Test pushScene", this.onPushScene, this); + var item2 = new cc.MenuItemFont("Test pushScene w/transition", this.onPushSceneTran, this); + var item3 = new cc.MenuItemFont("Quit", function () { + cc.log("quit!") + }, this); + + var menu = new cc.Menu(item1, item2, item3); + menu.alignItemsVertically(); + this.addChild(menu); + + var sprite = new cc.Sprite(s_pathGrossini); + this.addChild(sprite); + sprite.x = s.width - 40; + sprite.y = s.height / 2; + var rotate = cc.rotateBy(2, 360); + var repeat = rotate.repeatForever(); + sprite.runAction(repeat); + //----end0---- + + //cc.schedule(this.testDealloc); + }, + + + onEnter:function () { + cc.log("SceneTestLayer1#onEnter"); + this._super(); + }, + + onEnterTransitionDidFinish:function () { + cc.log("SceneTestLayer1#onEnterTransitionDidFinish"); + this._super(); + }, + + testDealloc:function (dt) { + //cc.log("SceneTestLayer1:testDealloc"); + }, + + onPushScene:function (sender) { + var scene = new SceneTestScene(); + var layer = new SceneTestLayer2(); + scene.addChild(layer, 0); + director.pushScene(scene); + }, + + onPushSceneTran:function (sender) { + var scene = new SceneTestScene(); + var layer = new SceneTestLayer2(); + scene.addChild(layer, 0); + + director.pushScene(new cc.TransitionSlideInT(1, scene)); + }, + onQuit:function (sender) { + } + + //CREATE_NODE(SceneTestLayer1); +}); + +var SceneTestLayer2 = cc.Layer.extend({ + + timeCounter:0, + + ctor:function () { + //----start0----Scene2-ctor + this._super(); + this.init(); + + this.timeCounter = 0; + + var s = director.getWinSize(); + + var item1 = new cc.MenuItemFont("runScene", this.runScene, this); + var item2 = new cc.MenuItemFont("runScene w/transition", this.runSceneTran, this); + var item3 = new cc.MenuItemFont("Go Back", this.onGoBack, this); + + var menu = new cc.Menu(item1, item2, item3); + menu.alignItemsVertically(); + this.addChild(menu); + + var sprite = new cc.Sprite(s_pathGrossini); + this.addChild(sprite); + + sprite.x = s.width - 40; + sprite.y = s.height / 2; + var rotate = cc.rotateBy(2, 360); + var repeat = rotate.repeatForever(); + sprite.runAction(repeat); + //----end0---- + + //cc.schedule(this.testDealloc); + }, + + testDealloc:function (dt) { + + }, + + onGoBack:function (sender) { + director.popScene(); + }, + + runScene:function (sender) { + var scene = new SceneTestScene(); + var layer = new SceneTestLayer3(); + scene.addChild(layer, 0); + director.runScene(scene); + + }, + + runSceneTran:function (sender) { + var scene = new SceneTestScene(); + var layer = new SceneTestLayer3(); + scene.addChild(layer, 0); + director.runScene(new cc.TransitionSlideInT(2, scene)); + } + + //CREATE_NODE(SceneTestLayer2); +}); + +var SceneTestLayer3 = cc.LayerColor.extend({ + + ctor:function () { + + //----start0----Scene3-ctor + this._super(); + this.init( cc.color(0,128,255,255) ); + + var label = new cc.LabelTTF("Touch to popScene", "Arial", 28); + this.addChild(label); + var s = director.getWinSize(); + label.x = s.width / 2; + label.y = s.height / 2; + + var sprite = new cc.Sprite(s_pathGrossini); + this.addChild(sprite); + + sprite.x = s.width - 40; + + sprite.y = s.height / 2; + var rotate = cc.rotateBy(2, 360); + var repeat = rotate.repeatForever(); + sprite.runAction(repeat); + //----end0---- + }, + + onEnterTransitionDidFinish: function () { + if ('touches' in cc.sys.capabilities){ + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded: function(touches, event){ + director.popScene(); + } + }, this); + } else if ('mouse' in cc.sys.capabilities) + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseUp: function(event){ + director.popScene(); + } + }, this); + }, + + testDealloc:function (dt) { + + } + + //CREATE_NODE(SceneTestLayer3); +}); + +SceneTestScene = TestScene.extend({ + + runThisTest:function () { + var layer = new SceneTestLayer1(); + this.addChild(layer); + + director.runScene(this); + + } +}); + +var arrayOfSceneTest = [ + SceneTestLayer1 +]; diff --git a/tests/js-tests/src/SchedulerTest/SchedulerTest.js b/tests/js-tests/src/SchedulerTest/SchedulerTest.js new file mode 100644 index 0000000000..ac0c3c96f5 --- /dev/null +++ b/tests/js-tests/src/SchedulerTest/SchedulerTest.js @@ -0,0 +1,749 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 TAG_ANIMATION_DANCE = 1; +var schedulerTestSceneIdx = -1; + +/* + Base Layer +*/ +var SchedulerTestLayer = BaseTestLayer.extend({ + + title:function () { + return "No title"; + }, + subtitle:function () { + return ""; + }, + + onBackCallback:function (sender) { + var scene = new SchedulerTestScene(); + var layer = previousSchedulerTest(); + + scene.addChild(layer); + director.runScene(scene); + }, + onNextCallback:function (sender) { + var scene = new SchedulerTestScene(); + var layer = nextSchedulerTest(); + + scene.addChild(layer); + director.runScene(scene); + }, + onRestartCallback:function (sender) { + var scene = new SchedulerTestScene(); + var layer = restartSchedulerTest(); + + scene.addChild(layer); + director.runScene(scene); + }, + // automation + numberOfPendingTests:function() { + return ( (arrayOfSchedulerTest.length-1) - schedulerTestSceneIdx ); + }, + + getTestNumber:function() { + return schedulerTestSceneIdx; + } + +}); + +/* + SchedulerAutoremove +*/ +var SchedulerAutoremove = SchedulerTestLayer.extend({ + _accum:0, + + onEnter:function () { + //----start0----onEnter + this._super(); + + this.schedule(this.onAutoremove, 0.5); + this.schedule(this.onTick, 0.5); + this._accum = 0; + //----end0---- + }, + title:function () { + return "Self-remove an scheduler"; + }, + subtitle:function () { + return "1 scheduler will be autoremoved in 3 seconds. See console"; + }, + + onAutoremove:function (dt) { + //----start0----onAutoremove + this._accum += dt; + cc.log("Time: " + this._accum); + + if (this._accum > 3) { + this.unschedule(this.onAutoremove); + cc.log("scheduler removed"); + } + //----end0---- + }, + onTick:function (dt) { + cc.log("This scheduler should not be removed"); + } +}); + +/* + SchedulerPauseResume +*/ +var SchedulerPauseResume = SchedulerTestLayer.extend({ + onEnter:function () { + //----start1----onEnter + this._super(); + + this.schedule(this.onTick1, 0.5); + this.schedule(this.onTick2, 0.5); + this.schedule(this.onPause, 3); + //----end1---- + }, + title:function () { + return "Pause / Resume"; + }, + subtitle:function () { + return "Scheduler should be paused after 3 seconds. See console"; + }, + + onTick1:function (dt) { + //----start1----onTick1 + cc.log("tick1"); + //----end1---- + }, + onTick2:function (dt) { + //----start1----onTick2 + cc.log("tick2"); + //----end1---- + }, + onPause:function (dt) { + //----start1----onPause + director.getScheduler().pauseTarget(this); + //----end1---- + } +}); + +/* + SchedulerUnscheduleAll +*/ +var SchedulerUnscheduleAll = SchedulerTestLayer.extend({ + onEnter:function () { + //----start2----onEnter + this._super(); + + this.schedule(this.onTick1, 0.5); + this.schedule(this.onTick2, 1.0); + this.schedule(this.onTick3, 1.5); + this.schedule(this.onTick4, 1.5); + this.schedule(this.onUnscheduleAll, 4); + //----end2---- + }, + title:function () { + return "Unschedule All callbacks"; + }, + subtitle:function () { + return "All scheduled callbacks will be unscheduled in 4 seconds. See console"; + }, + + onTick1:function (dt) { + //----start2----onTick1 + cc.log("tick1"); + //----end2---- + }, + onTick2:function (dt) { + //----start2----onTick2 + cc.log("tick2"); + //----end2---- + }, + onTick3:function (dt) { + //----start2----onTick3 + cc.log("tick3"); + //----end2---- + }, + onTick4:function (dt) { + //----start2----onTick4 + cc.log("tick4"); + //----end2---- + }, + onUnscheduleAll:function (dt) { + //----start2----onUnscheduleAll + this.unscheduleAllCallbacks(); + //----end2---- + } +}); + +/* + SchedulerUnscheduleAllHard +*/ +var SchedulerUnscheduleAllHard = SchedulerTestLayer.extend({ + onEnter:function () { + //----start3----onEnter + this._super(); + + this.schedule(this.onTick1, 0.5); + this.schedule(this.onTick2, 1.0); + this.schedule(this.onTick3, 1.5); + this.schedule(this.onTick4, 1.5); + this.schedule(this.onUnscheduleAll, 4); + //----end3---- + }, + title:function () { + return "Unschedule All callbacks #2"; + }, + subtitle:function () { + return "Unschedules all callbacks after 4s. Uses CCScheduler. See console"; + }, + + onTick1:function (dt) { + //----start3----onTick1 + cc.log("tick1"); + //----end3---- + }, + onTick2:function (dt) { + //----start3----onTick2 + cc.log("tick2"); + //----end3---- + }, + onTick3:function (dt) { + //----start3----onTick3 + cc.log("tick3"); + //----end3---- + }, + onTick4:function (dt) { + //----start3----onTick4 + cc.log("tick4"); + //----end3---- + }, + onUnscheduleAll:function (dt) { + //----start3----onUnscheduleAll + director.getScheduler().unscheduleAllCallbacks(); + //----end3---- + } +}); + +/* + SchedulerSchedulesAndRemove +*/ +var SchedulerSchedulesAndRemove = SchedulerTestLayer.extend({ + onEnter:function () { + //----start4----onEnter + this._super(); + + this.schedule(this.onTick1, 0.5); + this.schedule(this.onTick2, 1.0); + this.schedule(this.onScheduleAndUnschedule, 4.0); + //----end4---- + }, + title:function () { + return "Schedule from Schedule"; + }, + subtitle:function () { + return "Will unschedule and schedule callbacks in 4s. See console"; + }, + + onTick1:function (dt) { + //----start4----onTick1 + cc.log("tick1"); + //----end4---- + }, + onTick2:function (dt) { + //----start4----onTick2 + cc.log("tick2"); + //----end4---- + }, + onTick3:function (dt) { + //----start4----onTick3 + cc.log("tick3"); + //----end4---- + }, + onTick4:function (dt) { + //----start4----onTick4 + cc.log("tick4"); + //----end4---- + }, + onScheduleAndUnschedule:function (dt) { + //----start4----onScheduleAndUnschedule + this.unschedule(this.onTick1); + this.unschedule(this.onTick2); + this.unschedule(this.onScheduleAndUnschedule); + + this.schedule(this.onTick3, 1.0); + this.schedule(this.onTick4, 1.0) + //----end4---- + } +}); + +/* + SchedulerUpdate +*/ +var TestNode = cc.Node.extend({ + _pString:"", + + ctor:function (str, priority) { + this._super(); + this.init(); + this._pString = str; + this.scheduleUpdateWithPriority(priority); + }, + update:function(dt) { + cc.log( this._pString ); + } +}); + +var SchedulerUpdate = SchedulerTestLayer.extend({ + onEnter:function () { + //----start5----onEnter + this._super(); + + var str = "---"; + var d = new TestNode(str,50); + this.addChild(d); + + str = "3rd"; + var b = new TestNode(str,0); + this.addChild(b); + + str = "1st"; + var a = new TestNode(str, -10); + this.addChild(a); + + str = "4th"; + var c = new TestNode(str,10); + this.addChild(c); + + str = "5th"; + var e = new TestNode(str,20); + this.addChild(e); + + str = "2nd"; + var f = new TestNode(str,-5); + this.addChild(f); + + this.schedule(this.onRemoveUpdates, 4.0); + //----end5---- + }, + title:function () { + return "Schedule update with priority"; + }, + subtitle:function () { + return "3 scheduled updates. Priority should work. Stops in 4s. See console"; + }, + + onRemoveUpdates:function (dt) { + //----start5----onRemoveUpdates + var children = this.children; + + for (var i = 0; i < children.length; i++) { + var node = children[i]; + if (node) { + node.unscheduleAllCallbacks(); + } + } + //----end5---- + } +}); + +/* + SchedulerUpdateAndCustom +*/ +var SchedulerUpdateAndCustom = SchedulerTestLayer.extend({ + onEnter:function () { + //----start6----onEnter + this._super(); + + this.scheduleUpdate(); + this.schedule(this.onTick); + this.schedule(this.onStopCallbacks, 4); + //----end6---- + }, + title:function () { + return "Schedule Update + custom callback"; + }, + subtitle:function () { + return "Update + custom callback at the same time. Stops in 4s. See console"; + }, + + update:function (dt) { + //----start6----update + cc.log("update called:" + dt); + //----end6---- + }, + onTick:function (dt) { + //----start6----onTick + cc.log("custom callback called:" + dt); + //----end6---- + }, + onStopCallbacks:function (dt) { + //----start6----onStopCallbacks + this.unscheduleAllCallbacks(); + //----end6---- + } +}); + +/* + SchedulerUpdateFromCustom +*/ +var SchedulerUpdateFromCustom = SchedulerTestLayer.extend({ + onEnter:function () { + //----start7----onEnter + this._super(); + + this.schedule(this.onSchedUpdate, 2.0); + //----end7---- + }, + title:function () { + return "Schedule Update in 2 sec"; + }, + subtitle:function () { + return "Update schedules in 2 secs. Stops 2 sec later. See console"; + }, + + update:function (dt) { + //----start7----update + cc.log("update called:" + dt); + //----end7---- + }, + onSchedUpdate:function (dt) { + //----start7----onSchedUpdate + this.unschedule(this.onSchedUpdate); + this.scheduleUpdate(); + this.schedule(this.onStopUpdate, 2.0); + //----end7---- + }, + onStopUpdate:function (dt) { + //----start7----onStopUpdate + this.unscheduleUpdate(); + this.unschedule(this.onStopUpdate); + //----end7---- + } +}); + + +/* + RescheduleCallback +*/ +var RescheduleCallback = SchedulerTestLayer.extend({ + _interval:1.0, + _ticks:0, + + onEnter:function () { + //----start8----onEnter + this._super(); + + this._interval = 1.0; + this._ticks = 0; + this.schedule(this.onSchedUpdate, this._interval); + //----end8---- + }, + title:function () { + return "Reschedule Callback"; + }, + subtitle:function () { + return "Interval is 1 second, then 2, then 3..."; + }, + + onSchedUpdate:function (dt) { + //----start8----onSchedUpdate + this._ticks++; + + cc.log("schedUpdate: " + dt.toFixed(2)); + if (this._ticks > 3) { + this._interval += 1.0; + this.schedule(this.onSchedUpdate, this._interval); + this._ticks = 0; + } + //----end8---- + } +}); + +/* + ScheduleUsingSchedulerTest +*/ +var ScheduleUsingSchedulerTest = SchedulerTestLayer.extend({ + _accum:0, + + onEnter:function () { + //----start9----onEnter + this._super(); + + this._accum = 0; + var scheduler = director.getScheduler(); + + var priority = 0; // priority 0. default. + var paused = false; // not paused, queue it now. + scheduler.scheduleUpdateForTarget(this, priority, paused); + + var interval = 0.25; // every 1/4 of second + var repeat = cc.REPEAT_FOREVER; // how many repeats. cc.REPEAT_FOREVER means forever + var delay = 2; // start after 2 seconds; + paused = false; // not paused. queue it now. + scheduler.scheduleCallbackForTarget(this, this.onSchedUpdate, interval, repeat, delay, paused); + //----end9---- + }, + title:function () { + return "Schedule / Unschedule using Scheduler"; + }, + subtitle:function () { + return "After 5 seconds all callbacks should be removed"; + }, + + // callbacks + update:function(dt) { + //----start9----update + cc.log("update: " + dt); + //----end9---- + }, + onSchedUpdate:function (dt) { + //----start9----onSchedUpdate + cc.log("onSchedUpdate delta: " + dt); + + this._accum += dt; + if( this._accum > 3 ) { + var scheduler = director.getScheduler(); + scheduler.unscheduleAllCallbacksForTarget(this); + } + cc.log("onSchedUpdate accum: " + this._accum); + //----end9---- + } +}); + +// SchedulerTimeScale + +var SchedulerTimeScale = SchedulerTestLayer.extend({ + _newScheduler: null, + _newActionManager: null, + + onEnter: function() { + this._super(); + + this._newScheduler = new cc.Scheduler(); + this._newActionManager = new cc.ActionManager(); + + var s = cc.winSize; + + // rotate and jump + var jump1 = new cc.JumpBy(4, cc.p(-s.width+80,0), 100, 4); + var jump2 = jump1.reverse(); + var rot1 = new cc.RotateBy(4, 360*2); + var rot2 = rot1.reverse(); + + var seq3_1 = new cc.Sequence(jump2, jump1); + var seq3_2 = new cc.Sequence(rot1, rot2); + var spawn = new cc.Spawn(seq3_1, seq3_2); + var action = new cc.Repeat(spawn, 50); + + var action2 = action.clone(); + var action3 = action.clone(); + + var grossini = new cc.Sprite("res/Images/grossini.png"); + var tamara = new cc.Sprite("res/Images/grossinis_sister1.png"); + var kathia = new cc.Sprite("res/Images/grossinis_sister2.png"); + + grossini.setActionManager(this._newActionManager); + grossini.setScheduler(this._newScheduler); + + grossini.setPosition(cc.p(40,80)); + tamara.setPosition(cc.p(40,80)); + kathia.setPosition(cc.p(40,80)); + + this.addChild(grossini); + this.addChild(tamara); + this.addChild(kathia); + + grossini.runAction(new cc.Speed(action, 0.5)); + tamara.runAction(new cc.Speed(action2, 1.5)); + kathia.runAction(new cc.Speed(action3, 1.0)); + + cc.director.getScheduler().scheduleUpdateForTarget(this._newScheduler, 0, false); + + this._newScheduler.scheduleUpdateForTarget(this._newActionManager, 0, false); + + var emitter = new cc.ParticleFireworks(); + emitter.setTexture( cc.textureCache.addImage(s_stars1) ); + this.addChild(emitter); + + var slider = null; + var l = null; + + slider = new ccui.Slider(); + slider.setTouchEnabled(true); + slider.loadBarTexture("res/cocosui/sliderTrack.png"); + slider.loadSlidBallTextures("res/cocosui/sliderThumb.png", "res/cocosui/sliderThumb.png", ""); + slider.loadProgressBarTexture("res/cocosui/sliderProgress.png"); + slider.x = cc.winSize.width / 2.0; + slider.y = cc.winSize.height / 3.0 * 2; + slider.addEventListener(this.sliderEventForGrossini, this); + this.addChild(slider); + slider.setPercent(20); + + l = new cc.LabelTTF("Control time scale only for Grossini", "Thonburi", 16); + this.addChild(l); + l.x = slider.x; + l.y = slider.y + 30; + + slider = new ccui.Slider(); + slider.setTouchEnabled(true); + slider.loadBarTexture("res/cocosui/sliderTrack.png"); + slider.loadSlidBallTextures("res/cocosui/sliderThumb.png", "res/cocosui/sliderThumb.png", ""); + slider.loadProgressBarTexture("res/cocosui/sliderProgress.png"); + slider.x = cc.winSize.width / 2.0; + slider.y = cc.winSize.height / 3.0; + slider.addEventListener(this.sliderEventForGlobal, this); + this.addChild(slider); + slider.setPercent(20); + l = new cc.LabelTTF("Control time scale for all", "Thonburi", 16); + this.addChild(l); + l.x = slider.x; + l.y = slider.y + 30; + }, + + sliderEventForGrossini: function (sender, type) { + switch (type) { + case ccui.Slider.EVENT_PERCENT_CHANGED: + var slider = sender; + var percent = slider.getPercent() / 100.0 * 5; + this._newScheduler.setTimeScale(percent); + break; + default: + break; + } + }, + + sliderEventForGlobal: function (sender, type) { + switch (type) { + case ccui.Slider.EVENT_PERCENT_CHANGED: + var slider = sender; + var percent = slider.getPercent() / 100.0 * 5; + cc.director.getScheduler().setTimeScale(percent); + break; + default: + break; + } + }, + + onExit: function() { + // restore scale + cc.director.getScheduler().unscheduleUpdateForTarget(this._newScheduler); + this._super(); + }, + + title:function () { + return "Scheduler timeScale Test"; + }, + + subtitle:function () { + return "Fast-forward and rewind using scheduler.timeScale"; + } +}); + +var unScheduleAndRepeatTest = SchedulerTestLayer.extend({ + + onEnter: function(){ + this._super(); + cc.log("start schedule 'repeat': run once and repeat 4 times"); + this.schedule(this.repeat, 0.5, 4); + cc.log("start schedule 'forever': repeat forever (stop in 8s)"); + this.schedule(this.forever, 0.5); + this.schedule(function(){ + cc.log("stop the 'forever'"); + this.unschedule(this.forever); + }, 8); + }, + + _times: 5, + + repeat: function(){ + cc.log("Repeat - the remaining number: " + this._times--); + }, + + forever: function(){ + cc.log("Repeat Forever..."); + }, + + title: function(){ + return "Repeat And unschedule Test"; + }, + + subtitle: function(){ + return "Repeat will print 5 times\nForever will stop in 8 seconds."; + } +}); + +/* + main entry +*/ +var SchedulerTestScene = TestScene.extend({ + runThisTest:function (num) { + schedulerTestSceneIdx = (num || num == 0) ? (num - 1) : -1; + var layer = nextSchedulerTest(); + this.addChild(layer); + + director.runScene(this); + } +}); + +// +// Flow control +// + +var arrayOfSchedulerTest = [ + SchedulerTimeScale, + SchedulerAutoremove, + SchedulerPauseResume, + SchedulerUnscheduleAll, + SchedulerUnscheduleAllHard, + SchedulerSchedulesAndRemove, + SchedulerUpdate, + SchedulerUpdateAndCustom, + SchedulerUpdateFromCustom, + RescheduleCallback, + ScheduleUsingSchedulerTest, + unScheduleAndRepeatTest +]; + +var nextSchedulerTest = function () { + schedulerTestSceneIdx++; + schedulerTestSceneIdx = schedulerTestSceneIdx % arrayOfSchedulerTest.length; + + if(window.sideIndexBar){ + schedulerTestSceneIdx = window.sideIndexBar.changeTest(schedulerTestSceneIdx, 34); + } + + return new arrayOfSchedulerTest[schedulerTestSceneIdx](); +}; +var previousSchedulerTest = function () { + schedulerTestSceneIdx--; + if (schedulerTestSceneIdx < 0) + schedulerTestSceneIdx += arrayOfSchedulerTest.length; + + if(window.sideIndexBar){ + schedulerTestSceneIdx = window.sideIndexBar.changeTest(schedulerTestSceneIdx, 34); + } + + return new arrayOfSchedulerTest[schedulerTestSceneIdx](); +}; +var restartSchedulerTest = function () { + return new arrayOfSchedulerTest[schedulerTestSceneIdx](); +}; diff --git a/tests/js-tests/src/SpineTest/SpineTest.js b/tests/js-tests/src/SpineTest/SpineTest.js new file mode 100644 index 0000000000..f88cd68949 --- /dev/null +++ b/tests/js-tests/src/SpineTest/SpineTest.js @@ -0,0 +1,280 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 sp = sp || {}; + +var spineSceneIdx = -1; +var SpineTestScene = TestScene.extend({ + runThisTest:function () { + var layer = SpineTestScene.nextSpineTestLayer(); + this.addChild(layer); + director.runScene(this); + } +}); + +SpineTestScene.nextSpineTestLayer = function() { + spineSceneIdx++; + var layers = SpineTestScene.testLayers; + spineSceneIdx = spineSceneIdx % layers.length; + return new layers[spineSceneIdx](); +}; + +SpineTestScene.backSpineTestLayer = function() { + spineSceneIdx--; + var layers = SpineTestScene.testLayers; + if(spineSceneIdx < 0) + spineSceneIdx = layers.length; + return new layers[spineSceneIdx](); +}; + +SpineTestScene.restartSpineTestLayer = function(){ + return new SpineTestScene.testLayers[spineSceneIdx](); +}; + +var SpineTestLayer = BaseTestLayer.extend({ + onRestartCallback: function(sender){ + var s = new SpineTestScene(); + s.addChild(SpineTestScene.restartSpineTestLayer()); + cc.director.runScene(s); + }, + + onNextCallback: function(sender){ + var s = new SpineTestScene(); + s.addChild(SpineTestScene.nextSpineTestLayer()); + cc.director.runScene(s); + }, + + onBackCallback: function(sender){ + var s = new SpineTestScene(); + s.addChild(SpineTestScene.backSpineTestLayer()); + cc.director.runScene(s); + } +}); + +var SpineTestLayerNormal = SpineTestLayer.extend({ + _spineboy:null, + _debugMode: 0, + _flipped: false, + ctor:function () { + this._super(cc.color(0,0,0,255), cc.color(98,99,117,255)); + + var size = director.getWinSize(); + + ///////////////////////////// + // Make Spine's Animated skeleton Node + // You need 'json + atlas + image' resource files to make it. + // No JS binding for spine-c in this version. So, only file loading is supported. + var spineBoy = new sp.SkeletonAnimation('res/skeletons/spineboy.json', 'res/skeletons/spineboy.atlas'); + spineBoy.setPosition(cc.p(size.width / 2, size.height / 2 - 150)); + spineBoy.setMix('walk', 'jump', 0.2); + spineBoy.setMix('jump', 'run', 0.2); + spineBoy.setAnimation(0, 'walk', true); + //spineBoy.setAnimationListener(this, this.animationStateEvent); + spineBoy.setScale(0.5); + this.addChild(spineBoy, 4); + this._spineboy = spineBoy; + spineBoy.setStartListener(function(trackIndex){ + var entry = spineBoy.getState().getCurrent(trackIndex); + if(entry){ + var animationName = entry.animation ? entry.animation.name : ""; + cc.log("%d start: %s", trackIndex, animationName); + } + }); + spineBoy.setEndListener(function(traceIndex){ + cc.log("%d end.", traceIndex); + }); + spineBoy.setCompleteListener(function(traceIndex, loopCount){ + cc.log("%d complete: %d", traceIndex, loopCount); + }); + spineBoy.setEventListener(function(traceIndex, event){ + cc.log( traceIndex + " event: %s, %d, %f, %s",event.data.name, event.intValue, event.floatValue, event.stringValue); + }); + + var jumpEntry = spineBoy.addAnimation(0, "jump", false, 3); + spineBoy.addAnimation(0, "run", true); + // spineBoy.setTrackStartListener(jumpEntry, function(traceIndex){ + // cc.log("jumped!"); + // }); + + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesBegan: function(touches, event){ + if(spineBoy.getTimeScale() === 1.0) + spineBoy.setTimeScale(0.3); + else + spineBoy.setTimeScale(1); + } + }, this); + + cc.MenuItemFont.setFontSize(20); + var bonesToggle = new cc.MenuItemToggle( + new cc.MenuItemFont("Debug Bones: Off"), + new cc.MenuItemFont("Debug Bones: On")); + bonesToggle.setCallback(this.onDebugBones, this); + bonesToggle.setPosition(160 - size.width / 2, 120 - size.height / 2); + var slotsToggle = new cc.MenuItemToggle( + new cc.MenuItemFont("Debug Slots: Off"), + new cc.MenuItemFont("Debug Slots: On")); + slotsToggle.setCallback(this.onDebugSlots, this); + slotsToggle.setPosition(160 - size.width / 2, 160 - size.height / 2); + var menu = new cc.Menu(); + menu.ignoreAnchorPointForPosition(true); + menu.addChild(bonesToggle); + menu.addChild(slotsToggle); + this.addChild(menu, 5); + }, + + onDebugBones: function(sender){ + this._spineboy.setDebugBonesEnabled(!this._spineboy.getDebugBonesEnabled()); + }, + + onDebugSlots: function(sender){ + this._spineboy.setDebugSlotsEnabled(!this._spineboy.getDebugSlotsEnabled()); + }, + + subtitle:function () { + return "Spine test"; + }, + title:function () { + return "Spine test"; + }, + + animationStateEvent: function(obj, trackIndex, type, event, loopCount) { + var entry = this._spineboy.getCurrent(); + var animationName = (entry && entry.animation) ? entry.animation.name : 0; + switch(type) { + case sp.ANIMATION_EVENT_TYPE.START: + cc.log(trackIndex + " start: " + animationName); + break; + case sp.ANIMATION_EVENT_TYPE.END: + cc.log(trackIndex + " end:" + animationName); + break; + case sp.ANIMATION_EVENT_TYPE.EVENT: + cc.log(trackIndex + " event: " + animationName); + break; + case sp.ANIMATION_EVENT_TYPE.COMPLETE: + cc.log(trackIndex + " complete: " + animationName + "," + loopCount); + if(this._flipped){ + this._flipped = false; + this._spineboy.setScaleX(0.5); + }else{ + this._flipped = true; + this._spineboy.setScaleX(-0.5); + } + break; + default : + break; + } + }, + + // automation + numberOfPendingTests:function() { + return 1; + }, + getTestNumber:function() { + return 0; + } +}); + +var SpineTestLayerFFD = SpineTestLayer.extend({ + ctor: function(){ + this._super(cc.color(0,0,0,255), cc.color(98,99,117,255)); + + var skeletonNode = new sp.SkeletonAnimation("res/skeletons/goblins-ffd.json", "res/skeletons/goblins-ffd.atlas", 1.5); + skeletonNode.setAnimation(0, "walk", true); + skeletonNode.setSkin("goblin"); + + skeletonNode.setScale(0.5); + var winSize = cc.director.getWinSize(); + skeletonNode.setPosition(winSize.width /2, 20); + this.addChild(skeletonNode); + + var listener = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + onTouchBegan : function(touch, event){ + if(!skeletonNode.getDebugBonesEnabled()) + skeletonNode.setDebugBonesEnabled(true); + else if(skeletonNode.getTimeScale() === 1.0) + skeletonNode.setTimeScale(0.3); + else{ + skeletonNode.setTimeScale(1); + skeletonNode.setDebugBonesEnabled(false); + } + return true; + } + }); + cc.eventManager.addListener(listener, this); + }, + + title: function(){ + return "Spine Test"; + }, + + subtitle: function(){ + return "FFD Spine"; + } +}); + +var SpineTestPerformanceLayer = SpineTestLayer.extend({ + ctor: function(){ + this._super(cc.color(0,0,0,255), cc.color(98,99,117,255)); + + var self = this; + var listener = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + onTouchBegan: function(touch, event){ + var pos = self.convertToNodeSpace(touch.getLocation()); + var skeletonNode = new sp.SkeletonAnimation("res/skeletons/goblins-ffd.json", "res/skeletons/goblins-ffd.atlas", 1.5); + skeletonNode.setAnimation(0, "walk", true); + skeletonNode.setSkin("goblin"); + + skeletonNode.setScale(0.2); + skeletonNode.setPosition(pos); + self.addChild(skeletonNode); + return true; + } + }); + cc.eventManager.addListener(listener, this); + }, + title: function(){ + return "Spine Test"; + }, + subtitle: function() { + return "Performance Test for Spine"; + } +}); + +SpineTestScene.testLayers = [ + SpineTestLayerNormal + //SpineTestLayerFFD, //it doesn't support mesh on Web. + //SpineTestPerformanceLayer +]; + +if(cc.sys.isNative){ + SpineTestScene.testLayers.push(SpineTestLayerFFD); + SpineTestScene.testLayers.push(SpineTestPerformanceLayer); +} + diff --git a/tests/js-tests/src/Sprite3DTest/Sprite3DTest.js b/tests/js-tests/src/Sprite3DTest/Sprite3DTest.js new file mode 100644 index 0000000000..f4f2973c8c --- /dev/null +++ b/tests/js-tests/src/Sprite3DTest/Sprite3DTest.js @@ -0,0 +1,1589 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 Sprite3DTestIdx = -1; + +var Sprite3DTestDemo = cc.Layer.extend({ + _title:"", + _subtitle:"", + + ctor:function () { + this._super(); + }, + + // + // Menu + // + onEnter:function () { + this._super(); + + var label = new cc.LabelTTF(this._title, "Arial", 28); + this.addChild(label, 100, BASE_TEST_TITLE_TAG); + label.x = winSize.width / 2; + label.y = winSize.height - 50; + + var label2 = new cc.LabelTTF(this._subtitle, "Thonburi", 16); + this.addChild(label2, 101, BASE_TEST_SUBTITLE_TAG); + label2.x = winSize.width / 2; + label2.y = winSize.height - 80; + + var item1 = new cc.MenuItemImage(s_pathB1, s_pathB2, this.onBackCallback, this); + var item2 = new cc.MenuItemImage(s_pathR1, s_pathR2, this.onRestartCallback, this); + var item3 = new cc.MenuItemImage(s_pathF1, s_pathF2, this.onNextCallback, this); + + item1.tag = BASE_TEST_MENUITEM_PREV_TAG; + item2.tag = BASE_TEST_MENUITEM_RESET_TAG; + item3.tag = BASE_TEST_MENUITEM_NEXT_TAG; + + var menu = new cc.Menu(item1, item2, item3); + + menu.x = 0; + menu.y = 0; + var width = item2.width, height = item2.height; + item1.x = winSize.width/2 - width*2; + item1.y = height/2 ; + item2.x = winSize.width/2; + item2.y = height/2 ; + item3.x = winSize.width/2 + width*2; + item3.y = height/2 ; + + this.addChild(menu, 102, BASE_TEST_MENU_TAG); + }, + + onRestartCallback:function (sender) { + var s = new Sprite3DTestScene(); + s.addChild(restartSprite3DTest()); + director.runScene(s); + }, + + onNextCallback:function (sender) { + var s = new Sprite3DTestScene(); + s.addChild(nextSprite3DTest()); + director.runScene(s); + }, + + onBackCallback:function (sender) { + var s = new Sprite3DTestScene(); + s.addChild(previousSprite3DTest()); + director.runScene(s); + }, +}); + +var Sprite3DTestScene = cc.Scene.extend({ + ctor:function () { + this._super(); + + var label = new cc.LabelTTF("Main Menu", "Arial", 20); + var menuItem = new cc.MenuItemLabel(label, this.onMainMenuCallback, this); + + var menu = new cc.Menu(menuItem); + menu.x = 0; + menu.y = 0; + menuItem.x = winSize.width - 50; + menuItem.y = 25; + this.addChild(menu); + }, + onMainMenuCallback:function () { + var scene = new cc.Scene(); + var layer = new TestController(); + scene.addChild(layer); + director.runScene(scene); + }, + runThisTest:function (num) { + Sprite3DTestIdx = (num || num == 0) ? (num - 1) : -1; + var layer = nextSprite3DTest(); + this.addChild(layer); + + director.runScene(this); + } +}); + + +var Sprite3DBasicTest = Sprite3DTestDemo.extend({ + _title: "Testing Sprite3D", + _subtitle: "Tap screen to add more sprites", + + ctor:function(){ + this._super(); + + var winSize = cc.winSize; + this.addNewSpriteWithCoords(cc.p(winSize.width/2, winSize.height/2)); + + var that = this; + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded: function(touches, event){ + for(var i in touches){ + that.addNewSpriteWithCoords(touches[i].getLocation()); + } + } + }, this); + }, + + addNewSpriteWithCoords:function(position){ + var sprite = new jsb.Sprite3D("Sprite3DTest/boss1.obj"); + sprite.setScale(3.0); + sprite.setTexture("Sprite3DTest/boss.png"); + sprite.x = position.x; + sprite.y = position.y; + + this.addChild(sprite); + + var action; + var random = Math.random(); + if(random < 0.2) + action = cc.scaleBy(3, 2); + else if(random < 0.4) + action = cc.rotateBy(3, 360); + else if(random < 0.6) + action = cc.blink(1, 3); + else if(random < 0.8) + action = cc.tintBy(2, 0, -255, -255); + else + action = cc.fadeOut(2); + + var action_back = action.reverse(); + var seq = cc.sequence(action, action_back); + + sprite.runAction(seq.repeatForever()); + } +}); + +var Sprite3DHitTest = Sprite3DTestDemo.extend({ + _title:"Testing Sprite3D Touch in 2D", + _subtitle:"Tap Sprite3D and Drag", + + ctor:function(){ + this._super(); + + var s = cc.winSize; + + var sprite1 = new jsb.Sprite3D("Sprite3DTest/boss1.obj"); + sprite1.setScale(4.0); + sprite1.setTexture("Sprite3DTest/boss.png"); + sprite1.setPosition(cc.p(s.width/2, s.height/2)); + + this.addChild(sprite1); + sprite1.runAction(cc.rotateBy(3, 360).repeatForever()); + + var sprite2 = new jsb.Sprite3D("Sprite3DTest/boss1.obj") + sprite2.setScale(4.0); + sprite2.setTexture("Sprite3DTest/boss.png"); + sprite2.setPosition(cc.p(s.width/2, s.height/2)); + sprite2.setAnchorPoint(cc.p(0.5, 0.5)); + + this.addChild(sprite2); + sprite2.runAction(cc.rotateBy(3, -360).repeatForever()); + + // Make sprite1 touchable + var listener1 = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches: true, + onTouchBegan: function (touch, event) { + var target = event.getCurrentTarget(); + var rect = target.getBoundingBox(); + if(cc.rectContainsPoint(rect, touch.getLocation())){ + cc.log("sprite3d began... x = " + touch.getLocation().x + ", y = " + touch.getLocation().y); + target.setOpacity(100); + return true; + } + return false; + }, + onTouchMoved: function (touch, event) { + var target = event.getCurrentTarget(); + var oldPos = target.getPosition(); + var delta = touch.getDelta(); + target.setPosition(cc.p(oldPos.x + delta.x, oldPos.y + delta.y)); + }, + onTouchEnded: function (touch, event) { + var target = event.getCurrentTarget(); + cc.log("sprite3d onTouchEnded..."); + target.setOpacity(255); + } + }); + cc.eventManager.addListener(listener1, sprite1); + cc.eventManager.addListener(listener1.clone(), sprite2); + } +}); + +var AsyncLoadSprite3DTest = Sprite3DTestDemo.extend({ + _title:"Testing Sprite3D::createAsync", + _subtitle:"", + _path:["Sprite3DTest/boss.obj", "Sprite3DTest/girl.c3b", "Sprite3DTest/orc.c3b", "Sprite3DTest/ReskinGirl.c3b", "Sprite3DTest/axe.c3b"], + + ctor:function(){ + this._super(); + + var label = new cc.LabelTTF("AsyncLoad Sprite3D", "Arial", 15); + var item = new cc.MenuItemLabel(label, this. menuCallback_asyncLoadSprite, this); + + var s = cc.winSize; + item.setPosition(s.width / 2, s.height / 2); + + var menu = new cc.Menu(item); + menu.setPosition(cc.p(0, 0)); + this.addChild(menu, 10); + + var node = new cc.Node(); + node.setTag(101); + this.addChild(node); + + this.menuCallback_asyncLoadSprite(); + }, + + menuCallback_asyncLoadSprite:function(sender){ + //Note that you must stop the tasks before leaving the scene. + cc.AsyncTaskPool.getInstance().stopTasks(cc.AsyncTaskPool.TaskType.TASK_IO); + + var node = this.getChildByTag(101); + node.removeAllChildren(); // remove all loaded sprites + + //remove cache data + jsb.sprite3DCache.removeAllSprite3DData(); + + for(var i = 0; i < this._path.length; ++i){ + jsb.Sprite3D.createAsync(this._path[i], this.asyncLoad_Callback, this, i); + } + + }, + + asyncLoad_Callback:function(sprite, data){ + var node = this.getChildByTag(101); + var s = cc.winSize; + var width = s.width / this._path.length; + sprite.setPosition(width * (0.5 + data), s.height / 2); + node.addChild(sprite); + } +}); + +var Sprite3DWithSkinTest = Sprite3DTestDemo.extend({ + _title:"Testing Sprite3D", + _subtitle:"Tap screen to add more sprite3D", + + ctor:function(){ + this._super(); + + var size = cc.winSize; + this.addNewSpriteWithCoords(cc.p(size.width/2, size.height/2)); + + var that = this; + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded: function(touches, event){ + for(var i in touches){ + that.addNewSpriteWithCoords(touches[i].getLocation()); + } + } + }, this); + }, + + addNewSpriteWithCoords:function(position){ + var sprite = new jsb.Sprite3D("Sprite3DTest/orc.c3b"); + sprite.setScale(3); + sprite.setRotation3D({x : 0, y : 180, z: 0}); + this.addChild(sprite); + sprite.setPosition(position); + + var animation = jsb.Animation3D.create("Sprite3DTest/orc.c3b"); + if(animation){ + var animate = jsb.Animate3D.create(animation); + var inverse = Math.random() < 0.33 ? true : false; + + var rand2 = Math.random(); + var speed = 1.0; + if(rand2 < 0.33) + speed = animate.getSpeed() + Math.random(); + else if(rand2 < 0.66) + spped = animate.getSpeed() - 0.5 * Math.random(); + + animate.setSpeed(inverse ? -speed : speed); + sprite.runAction(new cc.RepeatForever(animate)); + } + } +}); + +var Animate3DTest = (function(){ + + var State = { + SWIMMING : 0, + SWIMMING_TO_HURT : 1, + HURT : 2, + HURT_TO_SWIMMING : 3 + }; + + return Sprite3DTestDemo.extend({ + _title:"Testing Animate3D", + _subtitle:"Touch to beat the tortoise", + _sprite:null, + _swim:null, + _hurt:null, + _moveAction:null, + _state:0, + _elapseTransTime:0, + + ctor:function(){ + this._super(); + + this.addSprite3D(); + + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded: this.onTouchesEnded.bind(this) + }, this); + + this.scheduleUpdate(); + }, + + onExit:function(){ + this._super(); + this._moveAction.release(); + this._hurt.release(); + this._swim.release(); + }, + + addSprite3D:function(){ + var sprite = new jsb.Sprite3D("Sprite3DTest/tortoise.c3b"); + sprite.setScale(0.1); + var s = cc.winSize; + sprite.setPosition(cc.p(s.width * 4 / 5, s.height / 2)); + this.addChild(sprite); + this._sprite = sprite; + + var animation = jsb.Animation3D.create("Sprite3DTest/tortoise.c3b"); + if(animation){ + var animate = jsb.Animate3D.create(animation, 0, 1.933); + this._swim = new cc.RepeatForever(animate); + sprite.runAction(this._swim); + + this._swim.retain(); + this._hurt = jsb.Animate3D.create(animation, 1.933, 2.8); + this._hurt.retain(); + + this._state = State.SWIMMING; + } + + this._moveAction = cc.moveBy(4.0, cc.p(-s.width / 5 * 3, 0)); + this._moveAction.retain(); + var seq = cc.sequence(this._moveAction, cc.callFunc(this.reachEndCallBack, this)); + seq.setTag(100); + sprite.runAction(seq); + }, + + reachEndCallBack:function(sender){ + var sprite = this._sprite; + sprite.stopActionByTag(100); + var inverse = this._moveAction.reverse(); + inverse.retain(); + this._moveAction.release(); + this._moveAction = inverse; + var rot = cc.rotateBy(1, {x : 0, y : 180, z : 0}); + var seq = cc.sequence(rot, this._moveAction, cc.callFunc(this.reachEndCallBack, this)); + seq.setTag(100); + sprite.runAction(seq); + }, + + renewCallBack:function(){ + this._sprite.runAction(this._swim); + this._state = State.HURT_TO_SWIMMING; + this._elapseTransTime = 0.0; + }, + + onTouchesEnded:function(touches, event){ + for(var i in touches){ + var location = touches[i].getLocation(); + + if(this._sprite){ + var len = cc.pDistance(this._sprite.getPosition(), location); + + if(len < 40){ + //hurt the tortoise + if(this._state == State.SWIMMING){ + this._elapseTransTime = 0; + this._state = State.SWIMMING_TO_HURT; + this._sprite.stopAction(this._hurt); + this._sprite.runAction(this._hurt); + var delay = cc.delayTime(this._hurt.getDuration() - jsb.Animate3D.getTransitionTime()); + var seq = cc.sequence(delay, cc.callFunc(this.renewCallBack, this)); + seq.setTag(101); + this._sprite.runAction(seq); + } + } + } + } + }, + + update:function(dt){ + if(this._state == State.HURT_TO_SWIMMING){ + this._elapseTransTime += dt; + + if(this._elapseTransTime >= jsb.Animate3D.getTransitionTime()){ + this._sprite.stopAction(this._hurt); + this._state = State.SWIMMING; + } + }else if(this._state == State.SWIMMING_TO_HURT){ + this._elapseTransTime += dt; + + if(this._elapseTransTime >= jsb.Animate3D.getTransitionTime()){ + this._sprite.stopAction(this._swim); + this._state = State.HURT; + } + } + } + }); +})(); + + +var AttachmentTest = Sprite3DTestDemo.extend({ + _title:"Testing Sprite3D Attachment", + _subtitle:"touch to switch weapon", + _hasWeapon:false, + _sprite:null, + + ctor:function(){ + this._super(); + + var s = cc.winSize; + this.addNewSpriteWithCoords(cc.p(s.width/2, s.height/2)); + + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded: this.onTouchesEnded.bind(this) + }, this); + }, + + addNewSpriteWithCoords:function(position){ + var sprite = new jsb.Sprite3D("Sprite3DTest/orc.c3b"); + sprite.setScale(5); + sprite.setRotation3D(cc.math.vec3(0, 180, 0)); + this.addChild(sprite); + sprite.setPosition(position); + + //test attach + var sp = new jsb.Sprite3D("Sprite3DTest/axe.c3b"); + sprite.getAttachNode("Bip001 R Hand").addChild(sp); + + var animation = jsb.Animation3D.create("Sprite3DTest/orc.c3b"); + if(animation){ + var animate = jsb.Animate3D.create(animation); + sprite.runAction(cc.repeatForever(animate)); + } + + this._sprite = sprite; + this._hasWeapon = true; + }, + + onTouchesEnded:function(touches, event){ + if(this._hasWeapon){ + this._sprite.removeAllAttachNode(); + }else{ + var sp = new jsb.Sprite3D("Sprite3DTest/axe.c3b"); + this._sprite.getAttachNode("Bip001 R Hand").addChild(sp); + } + this._hasWeapon = !this._hasWeapon; + } +}); + +var Sprite3DReskinTest = (function(){ + var SkinType = { + UPPER_BODY : 0, + PANTS : 1, + SHOES : 2, + HAIR : 3, + FACE : 4, + HAND : 5, + GLASSES : 6, + MAX_TYPE : 7 + }; + + return Sprite3DTestDemo.extend({ + _title:"Testing Sprite3D Reskin", + _subtitle:"", + _sprite:null, + _skins:[["Girl_UpperBody01", "Girl_UpperBody02"], ["Girl_LowerBody01", "Girl_LowerBody02"], ["Girl_Shoes01", "Girl_Shoes02"], ["Girl_Hair01", "Girl_Hair02"], ["Girl_Face01", "Girl_Face02"], ["Girl_Hand01", "Girl_Hand02"], ["", "Girl_Glasses01"]], + _curSkin:["Girl_UpperBody01", "Girl_LowerBody01", "Girl_Shoes01", "Girl_Hair01", "Girl_Face01", "Girl_Hand01", ""], + + ctor:function(){ + this._super(); + + var s = cc.winSize; + this.addNewSpriteWithCoords(cc.p(s.width/2, s.height/2)); + + var label1 = new cc.LabelTTF("Hair", "Arial", 20); + var item1 = new cc.MenuItemLabel(label1, this.menuCallback_reSkin, this ); + item1.setPosition(cc.p(50, item1.getContentSize().height * 4)); + item1.setUserData(SkinType.HAIR); + + var label2 = new cc.LabelTTF("Glasses", "Arial", 20); + var item2 = new cc.MenuItemLabel(label2, this.menuCallback_reSkin, this); + item2.setPosition(cc.p(50, item2.getContentSize().height * 5)); + item2.setUserData(SkinType.GLASSES); + + var label3 = new cc.LabelTTF("Coat", "Arial", 20); + var item3 = new cc.MenuItemLabel(label3, this.menuCallback_reSkin, this); + item3.setPosition(cc.p(50, item3.getContentSize().height * 6)); + item3.setUserData(SkinType.UPPER_BODY); + + var label4 = new cc.LabelTTF("Pants", "Arial", 20); + var item4 = new cc.MenuItemLabel(label4, this.menuCallback_reSkin, this); + item4.setPosition(cc.p(50, item4.getContentSize().height * 7)); + item4.setUserData(SkinType.PANTS); + + var label5 = new cc.LabelTTF("Shoes", "Arial", 20); + var item5 = new cc.MenuItemLabel(label5, this.menuCallback_reSkin, this); + item5.setPosition(cc.p(50, item5.getContentSize().height * 8)); + item5.setUserData(SkinType.SHOES); + + var menu = new cc.Menu(item1, item2, item3, item4, item5); + this.addChild(menu); + menu.setPosition(cc.p(0, 0)); + }, + + addNewSpriteWithCoords:function(position){ + var sprite = new jsb.Sprite3D("Sprite3DTest/ReskinGirl.c3b"); + sprite.setScale(4); + sprite.setRotation3D(cc.math.vec3(0, 0, 0)); + this.addChild(sprite); + sprite.setPosition(cc.p(position.x, position.y - 60)); + var animation = jsb.Animation3D.create("Sprite3DTest/ReskinGirl.c3b"); + if(animation){ + var animate = jsb.Animate3D.create(animation); + sprite.runAction(cc.repeatForever(animate)); + } + this._sprite = sprite; + + this.applyCurSkin(); + }, + + applyCurSkin:function(){ + for(var i = 0; i < this._sprite.getMeshCount(); i++){ + var mesh = this._sprite.getMeshByIndex(i); + var isVisible = false; + for(var j = 0; j < SkinType.MAX_TYPE; j++){ + if(mesh.getName() == this._curSkin[j]){ + isVisible = true; + break; + } + } + mesh.setVisible(isVisible); + } + }, + + menuCallback_reSkin:function(sender){ + var index = sender.getUserData(); + if(index < SkinType.MAX_TYPE){ + var curr = (this._skins[index].indexOf(this._curSkin[index]) + 1) % this._skins[index].length; + this._curSkin[index] = this._skins[index][curr]; + } + this.applyCurSkin(); + } + }); +})(); + +var Sprite3DWithOBBPerformanceTest = Sprite3DTestDemo.extend({ + _title:"OBB Collison Performance Test", + _subtitle:"", + _drawOBB:null, + _drawDebug:null, + _sprite:null, + _moveAction:null, + _obbt:null, + _obb:[], + _labelCubeCount:null, + _targetObbIndex:-1, + + ctor:function(){ + this._super(); + + cc.eventManager.addListener({ + event:cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesBegan:this.onTouchesBegan.bind(this), + onTouchesMoved:this.onTouchesMoved.bind(this) + }, this); + + this.initDrawBox(); + this.addSprite(); + + var s = cc.winSize; + cc.MenuItemFont.setFontName("Arial"); + cc.MenuItemFont.setFontSize(65); + var decrease = new cc.MenuItemFont(" - ", this.delOBBCallback, this); + decrease.setColor(cc.color(0, 200, 20)); + var increase = new cc.MenuItemFont(" + ", this.addOBBCallback, this); + increase.setColor(cc.color(0, 200, 20)); + + var menu = new cc.Menu(decrease, increase); + menu.alignItemsHorizontally(); + menu.setPosition(s.width / 2, s.height - 65); + this.addChild(menu, 1); + + this._labelCubeCount = new cc.LabelTTF("0 cubes", "Arial", 30); + this._labelCubeCount.setColor(cc.color(0, 200, 20)); + this._labelCubeCount.setPosition(cc.p(s.width / 2, s.height - 90)); + this.addChild(this._labelCubeCount); + + this.addOBBCallback(); + this.scheduleUpdate(); + }, + + onExit:function(){ + this._super(); + this._moveAction.release(); + }, + + update:function(){ + if(this._drawDebug !== undefined){ + this._drawDebug.clear(); + + var mat = this._sprite.getNodeToWorldTransform3D(); + this._obbt.xAxis.x = mat[0]; + this._obbt.xAxis.y = mat[1]; + this._obbt.xAxis.z = mat[2]; + this._obbt.xAxis.normalize(); + + this._obbt.yAxis.x = mat[4]; + this._obbt.yAxis.y = mat[5]; + this._obbt.yAxis.z = mat[6]; + this._obbt.yAxis.normalize(); + + this._obbt.zAxis.x = -mat[8]; + this._obbt.zAxis.y = -mat[9]; + this._obbt.zAxis.z = -mat[10]; + this._obbt.zAxis.normalize(); + + this._obbt.center = this._sprite.getPosition3D(); + + var corners = cc.math.obbGetCorners(this._obbt); + this._drawDebug.drawCube(corners, cc.color(0, 0, 255)); + } + + if(this._obb.length > 0){ + this._drawOBB.clear(); + for(var i = 0; i < this._obb.length; ++i){ + corners = cc.math.obbGetCorners(this._obb[i]); + this._drawOBB.drawCube(corners, cc.math.obbIntersectsObb(this._obbt, this._obb[i]) ? cc.color(255, 0, 0) : cc.color(0, 255, 0)); + } + } + }, + + initDrawBox:function(){ + this._drawOBB = new cc.DrawNode3D(); + this.addChild(this._drawOBB); + }, + + addSprite:function(){ + var sprite = new jsb.Sprite3D("Sprite3DTest/tortoise.c3b"); + sprite.setScale(0.1); + var s = cc.winSize; + sprite.setPosition(cc.p(s.width * 4 / 5, s.height / 2)); + this.addChild(sprite); + + this._sprite = sprite; + var animation = jsb.Animation3D.create("Sprite3DTest/tortoise.c3b"); + if(animation){ + var animate = jsb.Animate3D.create(animation); + sprite.runAction(cc.repeatForever(animate)); + } + + this._moveAction = cc.moveBy(4, cc.p(-s.width * 3 / 5, 0)); + this._moveAction.retain(); + var seq = cc.sequence(this._moveAction, cc.callFunc(this.reachEndCallBack, this)); + seq.setTag(100); + sprite.runAction(seq); + + var aabb = sprite.getAABB(); + this._obbt = cc.math.obb(aabb); + + this._drawDebug = new cc.DrawNode3D(); + this.addChild(this._drawDebug); + }, + + reachEndCallBack:function(){ + var sprite = this._sprite; + sprite.stopActionByTag(100); + var inverse = this._moveAction.reverse(); + inverse.retain(); + this._moveAction.release(); + this._moveAction = inverse; + var rot = cc.rotateBy(1, {x : 0, y : 180, z : 0}); + var seq = cc.sequence(rot, this._moveAction, cc.callFunc(this.reachEndCallBack, this)); + seq.setTag(100); + sprite.runAction(seq); + }, + + addOBBCallback:function(sender){ + var s = cc.winSize; + for(var i = 0; i < 10; ++i){ + var randompos = cc.p(Math.random() * s.width, Math.random() * s.height); + var aabb = cc.math.aabb(cc.math.vec3(-10, -10, -10), cc.math.vec3(10, 10, 10)); + var obb = cc.math.obb(aabb); + obb.center = cc.math.vec3(randompos.x, randompos.y, 0); + this._obb.push(obb); + } + this._labelCubeCount.setString(this._obb.length + " cubes"); + }, + + delOBBCallback:function(sender){ + if(this._obb.length >= 10){ + this._obb.splice(0, 10); + this._drawOBB.clear(); + } + this._labelCubeCount.setString(this._obb.length + " cubes"); + }, + + onTouchesBegan:function(touches, event){ + var location = touches[0].getLocationInView(); + var ray = this.calculateRayByLocationInView(location); + for(var j = 0; j < this._obb.length; ++j){ + if(cc.math.rayIntersectsObb(ray, this._obb[j])){ + this._targetObbIndex = j; + return; + } + } + this._targetObbIndex = -1; + }, + + onTouchesMoved:function(touches, event){ + if(this._targetObbIndex >= 0){ + var location = touches[0].getLocation(); + this._obb[this._targetObbIndex].center = cc.math.vec3(location.x, location.y, 0); + } + }, + + calculateRayByLocationInView:function(location){ + var camera = cc.Camera.getDefaultCamera(); + + var src = cc.math.vec3(location.x, location.y, -1); + var nearPoint = camera.unproject(src); + + src = cc.math.vec3(location.x, location.y, 1); + var farPoint = camera.unproject(src); + + var direction = cc.math.vec3(farPoint.x - nearPoint.x, farPoint.y - nearPoint.y, farPoint.z - nearPoint.z); + direction.normalize(); + + return cc.math.ray(nearPoint, direction); + } +}); + +var Sprite3DMirrorTest = Sprite3DTestDemo.extend({ + _title:"Sprite3D Mirror Test", + _subtitle:"", + + ctor:function(){ + this._super(); + + var s = cc.winSize; + this.addNewSpriteWithCoords(cc.p(s.width / 2, s.height / 2)); + }, + + addNewSpriteWithCoords:function(position){ + var fileName = "Sprite3DTest/orc.c3b"; + var sprite = new jsb.Sprite3D("Sprite3DTest/orc.c3b"); + sprite.setScale(5); + sprite.setRotation3D(cc.math.vec3(0, 180, 0)); + this.addChild(sprite); + sprite.setPosition(cc.p(position.x - 80, position.y)); + + //test attach + var sp = new jsb.Sprite3D("Sprite3DTest/axe.c3b"); + sprite.getAttachNode("Bip001 R Hand").addChild(sp); + + var animation = jsb.Animation3D.create(fileName); + if(animation){ + var animate = jsb.Animate3D.create(animation); + sprite.runAction(cc.repeatForever(animate)); + } + + //create mirror Sprite3D + sprite = new jsb.Sprite3D(fileName); + sprite.setScale(5); + sprite.setScaleX(-5); + sprite.setCullFace(gl.FRONT); + sprite.setRotation3D(cc.math.vec3(0, 180, 0)); + this.addChild(sprite); + sprite.setPosition(cc.p(position.x + 80, position.y)); + + //test attach + sp = new jsb.Sprite3D("Sprite3DTest/axe.c3b"); + sprite.getAttachNode("Bip001 R Hand").addChild(sp); + + var animation = jsb.Animation3D.create(fileName); + if(animation){ + var animate = jsb.Animate3D.create(animation); + sprite.runAction(cc.repeatForever(animate)); + } + } + +}); + +var QuaternionTest = Sprite3DTestDemo.extend({ + _title:"Test Rotation With Quaternion", + _subtitle:"", + _sprite:null, + _radius:100, + _accAngle:0, + + ctor:function(){ + this._super(); + + var sprite = new jsb.Sprite3D("Sprite3DTest/tortoise.c3b"); + sprite.setScale(0.1); + var s = cc.winSize; + sprite.setPosition(cc.p(s.width/2 + this._radius * Math.cos(this._accAngle), s.height / 2 + this._radius * Math.sin(this._accAngle))); + this.addChild(sprite); + this._sprite = sprite; + var animation = jsb.Animation3D.create("Sprite3DTest/tortoise.c3b"); + if(animation){ + var animate = jsb.Animate3D.create(animation, 0, 1.933); + sprite.runAction(cc.repeatForever(animate)); + } + + this.scheduleUpdate(); + }, + + update:function(dt){ + this._accAngle += dt * cc.degreesToRadians(90); + if(this._accAngle >= 2 * Math.PI) + this._accAngle -= 2 * Math.PI; + + var s = cc.winSize; + this._sprite.setPosition(cc.p(s.width / 2 + this._radius * Math.cos(this._accAngle), s.height / 2 + this._radius * Math.sin(this._accAngle))); + + var quat = cc.math.quaternion(cc.math.vec3(0, 0, 1), this._accAngle - Math.PI * 0.5); + this._sprite.setRotationQuat(quat); + } +}); + +var Sprite3DEmptyTest = Sprite3DTestDemo.extend({ + _title:"Testing Sprite3D Container", + _subtitle:"Sprite3D can act as containers for 2D objects", + + ctor:function(){ + this._super(); + + var s = new jsb.Sprite3D(); + s.setNormalizedPosition(cc.p(0.5, 0.5)); + var l = new cc.LabelTTF("Test"); + s.addChild(l); + this.addChild(s); + } +}); + +var Sprite3DForceDepthTest = Sprite3DTestDemo.extend({ + _title:"Force Depth Write Error Test", + _subtitle:"Ship should always appear behind orc", + + ctor:function(){ + this._super(); + + var orc = new jsb.Sprite3D("Sprite3DTest/orc.c3b"); + orc.setScale(5); + orc.setNormalizedPosition(cc.p(0.5, 0.3)); + // orc.setPositionZ(40); + orc.setVertexZ(40); + orc.setRotation3D(cc.math.vec3(0, 180, 0)); + orc.setGlobalZOrder(-1); + + this.addChild(orc); + + var ship = new jsb.Sprite3D("Sprite3DTest/boss1.obj"); + ship.setScale(5); + ship.setTexture("Sprite3DTest/boss.png"); + ship.setNormalizedPosition(cc.p(0.5, 0.5)); + ship.setRotation3D(cc.math.vec3(90, 0, 0)); + ship.setForceDepthWrite(true); + + this.addChild(ship); + } +}); + +var UseCaseSprite3D1 = Sprite3DTestDemo.extend({ + _title:"Use Case For 2D + 3D", + _subtitle:"3d transparent sprite + 2d sprite", + _accAngle:0, + + ctor:function(){ + this._super(); + + var s = cc.winSize; + //setup camera + var camera = cc.Camera.createPerspective(40, s.width/s.height, 0.01, 1000); + camera.setCameraFlag(cc.CameraFlag.USER1); + camera.setPosition3D(cc.math.vec3(0, 30, 100)); + camera.lookAt(cc.math.vec3(0, 0, 0)); + this.addChild(camera); + + var sprite = new jsb.Sprite3D("Sprite3DTest/girl.c3b"); + sprite.setScale(0.15); + var animation = jsb.Animation3D.create("Sprite3DTest/girl.c3b"); + if(animation){ + var animate = jsb.Animate3D.create(animation); + sprite.runAction(cc.repeatForever(animate)); + } + + var circleBack = new jsb.Sprite3D(); + var circle = new cc.Sprite("Sprite3DTest/circle.png"); + circleBack.setScale(0.5); + circleBack.addChild(circle); + circle.runAction(cc.rotateBy(3, cc.math.vec3(0, 0, 360)).repeatForever()); + + circleBack.setRotation3D(cc.math.vec3(90, 0, 0)); + + var pos = sprite.getPosition3D(); + circleBack.setPosition3D(cc.math.vec3(pos.x, pos.y, pos.z-1)); + + sprite.setOpacity(250); + sprite.setCameraMask(2); + circleBack.setCameraMask(2); + sprite.setTag(3); + circleBack.setTag(2); + + this.addChild(sprite); + this.addChild(circleBack); + + this.scheduleUpdate(); + this.update(0.1); + }, + + update:function(dt){ + this._accAngle += dt * cc.degreesToRadians(60); + + var radius = 30; + var x = Math.cos(this._accAngle) * radius; + var z = Math.sin(this._accAngle) * radius; + + var sprite = this.getChildByTag(3); + var circle = this.getChildByTag(2); + + sprite.setPositionX(x); + sprite.setVertexZ(z); + circle.setPositionX(x); + circle.setVertexZ(z); + } +}); + +var UseCaseSprite3D2 = Sprite3DTestDemo.extend({ + _title:"Use Case For 2D + 3D", + _subtitle:"ui - 3d - ui, last ui should on the top", + ctor:function(){ + this._super(); + + var s = cc.winSize; + //setup camera + var camera = cc.Camera.createPerspective(40, s.width/s.height, 0.01, 1000); + camera.setCameraFlag(cc.CameraFlag.USER1); + camera.setPosition3D(cc.math.vec3(0, 30, 100)); + camera.lookAt(cc.math.vec3(0, 0, 0)); + this.addChild(camera); + + var layer = new cc.LayerColor(cc.color(0, 0, 100, 255), s.width/2, s.height/2); + layer.setPosition(s.width/4, s.height/4); + layer.setGlobalZOrder(-1); + layer.setTag(101); + this.addChild(layer); + + var sprite = new jsb.Sprite3D("Sprite3DTest/girl.c3b"); + sprite.setScale(0.5); + var animation = jsb.Animation3D.create("Sprite3DTest/girl.c3b"); + if(animation){ + var animate = jsb.Animate3D.create(animation); + sprite.runAction(cc.repeatForever(animate)); + } + sprite.setPosition(s.width/4, s.height/4); + layer.addChild(sprite); + + var label1 = new cc.LabelTTF("Message", "Arial", 15); + var item1 = new cc.MenuItemLabel(label1, this.menuCallback_Message, this); + var label2 = new cc.LabelTTF("Message", "Arial", 15); + var item2 = new cc.MenuItemLabel(label2, this.menuCallback_Message, this); + + item1.setPosition(cc.p(s.width/2 - item1.getContentSize().width/2, s.height/2 - item1.getContentSize().height)); + item2.setPosition(cc.p(s.width/2 - item1.getContentSize().width/2, s.height/2 - item1.getContentSize().height * 2)); + + var menu = new cc.Menu(item1, item2); + menu.setPosition(cc.p(0, 0)); + layer.addChild(menu); + + }, + + menuCallback_Message:function(sender){ + var layer = this.getChildByTag(101); + var message = layer.getChildByTag(102); + if(message) + layer.removeChild(message); + else{ + // create a new message layer on the top + var s = layer.getContentSize(); + var messagelayer = new cc.LayerColor(cc.color(100, 100, 0, 255)); + messagelayer.setContentSize(cc.size(s.width/2, s.height/2)); + messagelayer.setPosition(cc.p(s.width/4, s.height/4)); + var label = new cc.LabelTTF("This Message Layer \n Should Be On Top"); + label.setPosition(cc.p(s.width/4, s.height/4)); + messagelayer.addChild(label); + messagelayer.setTag(102); + layer.addChild(messagelayer); + } + + } +}); + +var Sprite3DEffectTest = Sprite3DTestDemo.extend({ + _title:"Testing Sprite3D", + _subtitle:"Sprite3d with effects", + + ctor:function(){ + this._super(); + + cc.eventManager.addListener({ + event:cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesBegan:this.onTouchesBegan.bind(this) + }, this); + + this.addNewSpriteWithCoords(cc.p(cc.winSize.width/2, cc.winSize.height/2)); + }, + + addNewSpriteWithCoords:function(position){ + var sprite = new cc.EffectSprite3D("Sprite3DTest/boss1.obj", "Sprite3DTest/boss.png"); + var effect = new cc.Effect3DOutline(); + effect.setOutlineColor(cc.math.vec3(1, 0, 0)); + effect.setOutlineWidth(0.01); + sprite.addEffect(effect, -1); + + var effect2 = new cc.Effect3DOutline(); + effect2.setOutlineColor(cc.math.vec3(1, 1, 0)); + effect2.setOutlineWidth(0.02); + sprite.addEffect(effect2, -2); + + sprite.setScale(6); + this.addChild(sprite); + sprite.setPosition(position); + + var action; + var random = Math.random(); + if(random < 0.2) + action = cc.scaleBy(3, 2); + else if(random < 0.4) + action = cc.rotateBy(3, 360); + else if(random < 0.6) + action = cc.blink(1, 3); + else if(random < 0.8) + action = cc.tintBy(2, 0, -255, -255); + else + action = cc.fadeOut(2); + + var action_back = action.reverse(); + var seq = cc.sequence(action, action_back); + + sprite.runAction(seq.repeatForever()); + }, + + onTouchesBegan:function(touches, event){ + for(var i = 0; i < touches.length; ++i){ + var location = touches[i].getLocation(); + this.addNewSpriteWithCoords(location); + } + } +}); + +var Sprite3DWithSkinOutlineTest = Sprite3DTestDemo.extend({ + _title:"Testing Sprite3D for skinned outline", + _subtitle:"Tap screen to add more sprite3D", + + ctor:function(){ + this._super(); + + cc.eventManager.addListener({ + event:cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesBegan:this.onTouchesBegan.bind(this) + }, this); + + this.addNewSpriteWithCoords(cc.p(cc.winSize.width/2, cc.winSize.height/2)); + }, + + addNewSpriteWithCoords:function(p){ + var sprite = new cc.EffectSprite3D("Sprite3DTest/orc.c3b"); + sprite.setScale(3); + sprite.setRotation3D(cc.math.vec3(0, 180, 0)); + this.addChild(sprite); + sprite.setPosition(p); + + var effect = new cc.Effect3DOutline(); + effect.setOutlineColor(cc.math.vec3(1, 0, 0)); + effect.setOutlineWidth(0.01); + sprite.addEffect(effect, -1); + + var effect2 = new cc.Effect3DOutline(); + effect2.setOutlineColor(cc.math.vec3(1, 1, 0)); + effect2.setOutlineWidth(0.02); + sprite.addEffect(effect2, -2); + + var animation = jsb.Animation3D.create("Sprite3DTest/orc.c3b"); + if(animation){ + var animate = jsb.Animate3D.create(animation); + var inverse = Math.random() < 0.33 ? true : false; + + var rand2 = Math.random(); + var speed = 1.0; + if(rand2 < 0.33) + speed = animate.getSpeed() + Math.random(); + else if(rand2 < 0.66) + spped = animate.getSpeed() - 0.5 * Math.random(); + + animate.setSpeed(inverse ? -speed : speed); + sprite.runAction(new cc.RepeatForever(animate)); + } + }, + + onTouchesBegan:function(touches, event){ + for(var i = 0; i < touches.length; ++i){ + var location = touches[i].getLocation(); + this.addNewSpriteWithCoords(location); + } + } +}); + +var Sprite3DLightMapTest = Sprite3DTestDemo.extend({ + _title:"light map test", + _subtitle:"drag the screen to move around", + _camera:null, + + ctor:function(){ + this._super(); + + //the assets are from the OpenVR demo + //get the visible size. + var visibleSize = cc.director.getVisibleSize(); + this._camera = cc.Camera.createPerspective(60, visibleSize.width/visibleSize.height, 0.1, 200); + this._camera.setCameraFlag(cc.CameraFlag.USER1); + this._camera.setPosition3D(cc.math.vec3(0, 25, 15)); + this._camera.setRotation3D(cc.math.vec3(-35, 0, 0)); + + var LightMapScene = new jsb.Sprite3D("Sprite3DTest/LightMapScene.c3b"); + LightMapScene.setScale(0.1); + this.addChild(LightMapScene); + this.addChild(this._camera); + this.setCameraMask(2); + + //add a point light + var light = jsb.PointLight.create(cc.math.vec3(35, 75, -20.5), cc.color(255, 255, 255), 150); + this.addChild(light); + //set the ambient light + var ambient = jsb.AmbientLight.create(cc.color(55, 55, 55)); + this.addChild(ambient); + + //create a listener + cc.eventManager.addListener({ + event:cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesMoved:this.onTouchesMoved.bind(this) + }, this); + }, + + onTouchesMoved:function(touches, event){ + if(touches.length === 1){ + var dt = cc.director.getDeltaTime(); + var touch = touches[0]; + var location = touch.getLocation(); + var previousLocation = touch.getPreviousLocation(); + var newPos = cc.p(previousLocation.x - location.x, previousLocation.y - location.y); + + var m = this._camera.getNodeToWorldTransform3D(); + var cameraDir = cc.math.vec3(-m[8], -m[9], -m[10]); + cameraDir.normalize(); + cameraDir.y = 0; + + var cameraRightDir = cc.math.vec3(m[0], m[1], m[2]); + cameraRightDir.normalize(); + cameraRightDir.y = 0; + + var cameraPos = this._camera.getPosition3D(); + cameraPos.x += cameraDir.x * newPos.y * dt + cameraRightDir.x * newPos.x * dt; + cameraPos.y += cameraDir.y * newPos.y * dt + cameraRightDir.y * newPos.x * dt; + cameraPos.z += cameraDir.z * newPos.y * dt + cameraRightDir.z * newPos.x * dt; + this._camera.setPosition3D(cameraPos); + } + } +}); + +var Sprite3DUVAnimationTest = Sprite3DTestDemo.extend({ + _title:"Testing UV Animation", + _subtitle:"", + _cylinder_texture_offset:0, + _shining_duraion:0, + _state:null, + fade_in:true, + + ctor:function(){ + this._super(); + + var visibleSize = cc.director.getVisibleSize(); + //use custom camera + var camera = cc.Camera.createPerspective(60, visibleSize.width/visibleSize.height, 0.1, 200); + camera.setCameraFlag(cc.CameraFlag.USER1); + this.addChild(camera); + this.setCameraMask(2); + + //create cylinder + var cylinder = new jsb.Sprite3D("Sprite3DTest/cylinder.c3b"); + this.addChild(cylinder); + cylinder.setScale(3); + cylinder.setPosition(visibleSize.width/2, visibleSize.height/2); + cylinder.setRotation3D(cc.math.vec3(-90, 0, 0)); + + //create and set our custom shader + var shader = new cc.GLProgram("Sprite3DTest/cylinder.vert","Sprite3DTest/cylinder.frag"); + this._state = cc.GLProgramState.create(shader); + cylinder.setGLProgramState(this._state); + + this._state.setUniformFloat("offset", this._cylinder_texture_offset); + this._state.setUniformFloat("duration", this._shining_duraion); + + //pass mesh's attribute to shader + var offset = 0; + var attributeCount = cylinder.getMesh().getMeshVertexAttribCount(); + for(var i = 0; i < attributeCount; ++i){ + var meshattribute = cylinder.getMesh().getMeshVertexAttribute(i); + this._state.setVertexAttribPointer(cc.attributeNames[meshattribute.vertexAttrib], + meshattribute.size, + meshattribute.type, + gl.FALSE, + cylinder.getMesh().getVertexSizeInBytes(), + offset); + offset += meshattribute.attribSizeBytes; + } + + //create the second texture for cylinder + var shining_texture = cc.textureCache.addImage("Sprite3DTest/caustics.png"); + shining_texture.setTexParameters(gl.NEAREST, gl.NEAREST, gl.REPEAT, gl.REPEAT); + //pass the texture sampler to our custom shader + this._state.setUniformTexture("caustics", shining_texture); + + this.scheduleUpdate(); + }, + + update:function(dt){ + //callback function to update cylinder's texcoord + this._cylinder_texture_offset += 0.3 * dt; + this._cylinder_texture_offset = this._cylinder_texture_offset > 1 ? 0 : this._cylinder_texture_offset; + + if(this.fade_in){ + this._shining_duraion += 0.5 * dt; + if(this._shining_duraion > 1) + this.fade_in = false; + }else{ + this._shining_duraion -= 0.5 * dt; + if(this._shining_duraion < 0) + this.fade_in = true; + } + + //pass the result to shader + this._state.setUniformFloat("offset", this._cylinder_texture_offset); + this._state.setUniformFloat("duration", this._shining_duraion); + } +}); + +var State = { + State_None : 0, + State_Idle : 0x01, + State_Move : 0x02, + State_Rotate : 0x04, + State_Speak : 0x08, + State_MeleeAttack : 0x10, + State_RemoteAttack : 0x20, + State_Attack : 0x40 +}; + +var Sprite3DFakeShadowTest = Sprite3DTestDemo.extend({ + _title:"fake shadow effect", + _subtitle:"touch the screen to move around", + _camera:null, + _plane:null, + _orc:null, + _targetPos:null, + _curState:0, + + ctor:function(){ + this._super(); + + cc.eventManager.addListener({ + event:cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded:this.onTouchesEnded.bind(this) + }, this); + + var visibleSize = cc.director.getVisibleSize(); + var s = cc.winSize; + + this._orc = new jsb.Sprite3D("Sprite3DTest/orc.c3b"); + this._orc.setScale(0.2); + this._orc.setRotation3D(cc.math.vec3(0, 180, 0)); + this._orc.setPosition3D(cc.math.vec3(0, 0, 0)); + + this._targetPos = this._orc.getPosition3D(); + this.addChild(this._orc); + + //create a plane + this._plane = new jsb.Sprite3D("Sprite3DTest/plane.c3t"); + this._plane.setRotation3D(cc.math.vec3(90, 0, 0)); + this.addChild(this._plane); + + //use a custom shader + var shader = new cc.GLProgram("Sprite3DTest/simple_shadow.vert", "Sprite3DTest/simple_shadow.frag"); + var state = cc.GLProgramState.create(shader); + this._plane.setGLProgramState(state); + + //pass mesh's attribute to shader + var offset = 0; + var attributeCount = this._plane.getMesh().getMeshVertexAttribCount(); + for(var i = 0; i < attributeCount; ++i){ + var meshattribute = this._plane.getMesh().getMeshVertexAttribute(i); + state.setVertexAttribPointer(cc.attributeNames[meshattribute.vertexAttrib], + meshattribute.size, + meshattribute.type, + gl.FALSE, + this._plane.getMesh().getVertexSizeInBytes(), + offset); + offset += meshattribute.attribSizeBytes; + } + state.setUniformMat4("u_model_matrix", this._plane.getNodeToWorldTransform3D()); + + //create shadow texture + var shadowTexture = cc.textureCache.addImage("Sprite3DTest/shadowCircle.png"); + shadowTexture.setTexParameters(gl.LINEAR, gl.LINEAR, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE); + state.setUniformTexture("u_shadowTexture", shadowTexture); + state.setUniformVec3("u_target_pos", this._targetPos); + + this._camera = cc.Camera.createPerspective(60, s.width/s.height, 1, 1000); + this._camera.setCameraFlag(cc.CameraFlag.USER1); + this._camera.setPosition3D(cc.math.vec3(0, 20, 25)); + this._camera.lookAt(cc.math.vec3(0, 0, 0)); + this.addChild(this._camera); + this.setCameraMask(2); + + this.scheduleUpdate(); + }, + + update:function(dt){ + this.updateState(dt) + + if(this.isState(State.State_Move)){ + this.move3D(dt); + if(this.isState(State.State_Rotate)){ + var curPos = this._orc.getPosition3D(); + var newFaceDir = cc.math.vec3(this._targetPos.x - curPos.x, this._targetPos.y - curPos.y, this._targetPos.z - curPos.z); + newFaceDir.y = 0; + newFaceDir.normalize(); + + var m = this._orc.getNodeToWorldTransform3D(); + var up = cc.math.vec3(m[4], m[5], m[6]); + up.normalize(); + + var right = cc.math.vec3Cross(cc.math.vec3(-newFaceDir.x, -newFaceDir.y, -newFaceDir.z), up); + right.normalize(); + + var mat = [right.x, right.y, right.z, 0, + up.x, up.y, up.z, 0, + newFaceDir.x, newFaceDir.y, newFaceDir.z, 0, + 0, 0, 0, 1]; + + this._orc.setAdditionalTransform(mat); + } + } + }, + + updateState:function(dt){ + if(!this._targetPos) + return; + var curPos = this._orc.getPosition3D(); + var m = this._orc.getNodeToWorldTransform3D(); + var curFaceDir = cc.math.vec3(m[8], m[9], m[10]); + curFaceDir.normalize(); + var newFaceDir = cc.math.vec3(this._targetPos.x - curPos.x, this._targetPos.y - curPos.y, this._targetPos.z - curPos.z); + newFaceDir.y = 0; + newFaceDir.normalize(); + var cosAngle = Math.abs(cc.math.vec3Dot(curFaceDir, newFaceDir) - 1); + + var dx = curPos.x - this._targetPos.x, + dy = curPos.y - this._targetPos.y, + dz = curPos.z - this._targetPos.z; + var dist = dx * dx + dy * dy + dz * dz; + + if(dist <= 4){ + if(cosAngle <= 0.01) + this._curState = State.State_Idle; + else + this._curState = State.State_Rotate; + }else{ + if(cosAngle > 0.01) + this._curState = State.State_Rotate | State.State_Move; + else + this._curState = State.State_Move; + } + }, + + isState:function(bit){ + return (this._curState & bit) == bit; + }, + + move3D:function(dt){ + if(!this._targetPos) + return; + var curPos = this._orc.getPosition3D(); + var newFaceDir = cc.math.vec3(this._targetPos.x - curPos.x, this._targetPos.y - curPos.y, this._targetPos.z - curPos.z); + newFaceDir.y = 0; + newFaceDir.normalize(); + var offset = cc.math.vec3(newFaceDir.x * 25 * dt, newFaceDir.y * 25 * dt, newFaceDir.z * 25 * dt); + curPos.x += offset.x; + curPos.y += offset.y; + curPos.z += offset.z; + this._orc.setPosition3D(curPos); + //pass the newest orc position + this._plane.getGLProgramState().setUniformVec3("u_target_pos",curPos); + }, + + onTouchesEnded:function(touches, event){ + var touch = touches[0]; + var location = touch.getLocationInView(); + if(this._camera !== null){ + var nearP = cc.math.vec3(location.x, location.y, -1); + var farP = cc.math.vec3(location.x, location.y, 1); + + nearP = this._camera.unproject(nearP); + farP = this._camera.unproject(farP); + + var dir = cc.math.vec3(farP.x-nearP.x, farP.y-nearP.y, farP.z-nearP.z); + var ndd = dir.y; // (0, 1, 0) * dir + var ndo = nearP.y; // (0, 1, 0) * nearP + var dist = - ndo / ndd; + var p = cc.math.vec3(nearP.x+dist*dir.x, nearP.y+dist*dir.y, nearP.z+dist*dir.z); + + if(p.x > 100) + p.x = 100; + if(p.x < -100) + p.x = -100; + if(p.z > 100) + p.z = 100 + if(p.z < -100) + p.z = -100; + + this._targetPos = p; + } + } +}); + +var Sprite3DBasicToonShaderTest = Sprite3DTestDemo.extend({ + _title:"basic toon shader test", + _subtitle:"", + + ctor:function(){ + this._super(); + + var camera = cc.Camera.createPerspective(60, cc.winSize.width/cc.winSize.height, 1, 1000); + camera.setCameraFlag(cc.CameraFlag.USER1); + this.addChild(camera); + this.setCameraMask(2); + + //create a teapot + var teapot = new jsb.Sprite3D("Sprite3DTest/teapot.c3b"); + //create and set out custom shader + var shader = new cc.GLProgram("Sprite3DTest/toon.vert", "Sprite3DTest/toon.frag"); + var state = cc.GLProgramState.create(shader); + teapot.setGLProgramState(state); + teapot.setPosition3D(cc.math.vec3(cc.winSize.width/2, cc.winSize.height/2, -20)); + teapot.setRotation3D(cc.math.vec3(-90, 180, 0)); + teapot.setScale(10); + teapot.runAction(cc.rotateBy(1.5, cc.math.vec3(0, 30, 0)).repeatForever()); + this.addChild(teapot); + + //pass mesh's attribute to shader + var offset = 0; + var attributeCount = teapot.getMesh().getMeshVertexAttribCount(); + for(var i = 0; i < attributeCount; ++i){ + var meshattribute = teapot.getMesh().getMeshVertexAttribute(i); + state.setVertexAttribPointer(cc.attributeNames[meshattribute.vertexAttrib], + meshattribute.size, + meshattribute.type, + gl.FALSE, + teapot.getMesh().getVertexSizeInBytes(), + offset); + offset += meshattribute.attribSizeBytes; + } + } +}); + +// +// Flow control +// +var arrayOfSprite3DTest = [ + Sprite3DBasicTest, + Sprite3DHitTest, + AsyncLoadSprite3DTest, + Sprite3DWithSkinTest, + Animate3DTest, + AttachmentTest, + Sprite3DReskinTest, + Sprite3DWithOBBPerformanceTest, + Sprite3DMirrorTest, + QuaternionTest, + Sprite3DEmptyTest, + Sprite3DForceDepthTest, + UseCaseSprite3D1, + UseCaseSprite3D2 +]; + +// 3DEffect use custom shader which is not supported on WP8/WinRT yet. +if (cc.sys.os !== cc.sys.OS_WP8 || cc.sys.os !== cc.sys.OS_WINRT) { + arrayOfSprite3DTest = arrayOfSprite3DTest.concat([ + Sprite3DEffectTest, + Sprite3DWithSkinOutlineTest, + Sprite3DLightMapTest, + Sprite3DUVAnimationTest, + Sprite3DFakeShadowTest, + Sprite3DBasicToonShaderTest, + ]); +} + +var nextSprite3DTest = function () { + Sprite3DTestIdx++; + Sprite3DTestIdx = Sprite3DTestIdx % arrayOfSprite3DTest.length; + + if(window.sideIndexBar){ + Sprite3DTestIdx = window.sideIndexBar.changeTest(Sprite3DTestIdx, 36); + } + + return new arrayOfSprite3DTest[Sprite3DTestIdx ](); +}; +var previousSprite3DTest = function () { + Sprite3DTestIdx--; + if (Sprite3DTestIdx < 0) + Sprite3DTestIdx += arrayOfSprite3DTest.length; + + if(window.sideIndexBar){ + Sprite3DTestIdx = window.sideIndexBar.changeTest(Sprite3DTestIdx, 36); + } + + return new arrayOfSprite3DTest[Sprite3DTestIdx ](); +}; +var restartSprite3DTest = function () { + return new arrayOfSprite3DTest[Sprite3DTestIdx ](); +}; diff --git a/tests/js-tests/src/SpriteTest/SpriteTest.js b/tests/js-tests/src/SpriteTest/SpriteTest.js new file mode 100644 index 0000000000..3909bd49bc --- /dev/null +++ b/tests/js-tests/src/SpriteTest/SpriteTest.js @@ -0,0 +1,5499 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 TAG_TILE_MAP = 1; +var TAG_SPRITE_BATCH_NODE = 1; +var TAG_NODE = 2; +var TAG_ANIMATION1 = 1; +var TAG_SPRITE_LEFT = 2; +var TAG_SPRITE_RIGHT = 3; + +var TAG_SPRITE1 = 0; +var TAG_SPRITE2 = 1; +var TAG_SPRITE3 = 2; +var TAG_SPRITE4 = 3; +var TAG_SPRITE5 = 4; +var TAG_SPRITE6 = 5; +var TAG_SPRITE7 = 6; +var TAG_SPRITE8 = 7; + +var IDC_NEXT = 100; +var IDC_BACK = 101; +var IDC_RESTART = 102; + +var spriteTestIdx = -1; + +var spriteFrameCache = cc.spriteFrameCache; + +//------------------------------------------------------------------ +// +// SpriteTestDemo +// +//------------------------------------------------------------------ +var SpriteTestDemo = BaseTestLayer.extend({ + _title:"", + _subtitle:"", + + ctor:function () { + if (arguments.length === 0) { + this._super(cc.color(0, 0, 0, 255), cc.color(98, 99, 117, 255)); + } else { + this._super.apply(this, arguments); + } + }, + + onRestartCallback:function (sender) { + var s = new SpriteTestScene(); + s.addChild(restartSpriteTest()); + director.runScene(s); + }, + + onNextCallback:function (sender) { + var s = new SpriteTestScene(); + s.addChild(nextSpriteTest()); + director.runScene(s); + }, + + onBackCallback:function (sender) { + var s = new SpriteTestScene(); + s.addChild(previousSpriteTest()); + director.runScene(s); + }, + + // automation + numberOfPendingTests:function () { + return ( (arrayOfSpriteTest.length - 1) - spriteTestIdx ); + }, + + getTestNumber:function () { + return spriteTestIdx; + } +}); + +//------------------------------------------------------------------ +// +// Sprite1 +// +//------------------------------------------------------------------ +var Sprite1 = SpriteTestDemo.extend({ + _title:"Non Batched Sprite ", + _subtitle:"Tap screen to add more sprites", + + ctor:function () { + //----start0----ctor + this._super(); + + this.addNewSpriteWithCoords(cc.p(winSize.width / 2, winSize.height / 2)); + + if ('touches' in cc.sys.capabilities) { + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded: function(touches, event){ + for (var it = 0; it < touches.length; it++) { + var touch = touches[it]; + if (!touch) + break; + + var location = touch.getLocation(); + event.getCurrentTarget().addNewSpriteWithCoords(location); + } + } + }, this); + } else if ('mouse' in cc.sys.capabilities) + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseUp: function(event){ + event.getCurrentTarget().addNewSpriteWithCoords(event.getLocation()); + } + }, this); + //----end0---- + }, + + addNewSpriteWithCoords:function (p) { + //----start0----addNewSpriteWithCoords + var idx = 0 | (Math.random() * 14); + var x = (idx % 5) * 85; + var y = (0 | (idx / 5)) * 121; + var sprite = new cc.Sprite(s_grossini_dance_atlas, cc.rect(x, y, 85, 121)); + this.addChild(sprite); + sprite.x = p.x; + sprite.y = p.y; + + var action; + var random = Math.random(); + if (random < 0.20) { + action = cc.scaleBy(3, 2); + } else if (random < 0.40) { + action = cc.rotateBy(3, 360); + } else if (random < 0.60) { + action = cc.blink(1, 3); + } else if (random < 0.8) { + action = cc.tintBy(2, 0, -255, -255); + } else { + action = cc.fadeOut(2); + } + + var action_back = action.reverse(); + var seq = cc.sequence(action, action_back); + + sprite.runAction(seq.repeatForever()); + this.testSprite = sprite; + //----end0---- + }, + // + // Automation + // + testDuration:1, + pixel:{"0":51, "1":0, "2":51, "3":255}, + testSprite:null, + setupAutomation:function () { + var fun = function () { + var sprite = new cc.Sprite(s_grossini_dance_atlas, cc.rect(0, 0, 85, 121)); + this.addChild(sprite, 999); + sprite.x = winSize.width / 2; + sprite.y = winSize.height / 2; + }; + this.scheduleOnce(fun, 0.5); + }, + getExpectedResult:function () { + var ret = {"useBatch":false, "pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 2, winSize.height / 2, 5, 5); + var ret = {"useBatch":this.testSprite.getBatchNode() != null, "pixel":this.containsPixel(ret1, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteBatchNode1 +// +//------------------------------------------------------------------ +var SpriteBatchNode1 = SpriteTestDemo.extend({ + + _title:"Batched Sprite ", + _subtitle:"Tap screen to add more sprites", + + ctor:function () { + //----start1----ctor + this._super(); + if ('touches' in cc.sys.capabilities) { + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded: function (touches, event) { + for (var it = 0; it < touches.length; it++) { + var touch = touches[it]; + if (!touch) + break; + + var location = touch.getLocation(); + event.getCurrentTarget().addNewSpriteWithCoords(location); + } + } + }, this); + } else if ('mouse' in cc.sys.capabilities) + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseUp: function(event){ + event.getCurrentTarget().addNewSpriteWithCoords(event.getLocation()); + } + }, this); + + var batchNode = new cc.SpriteBatchNode(s_grossini_dance_atlas, 50); + this.addChild(batchNode, 0, TAG_SPRITE_BATCH_NODE); + this.addNewSpriteWithCoords(cc.p(winSize.width / 2, winSize.height / 2)); + //----end1---- + }, + + addNewSpriteWithCoords:function (p) { + //----start1----addNewSpriteWithCoords + var batchNode = this.getChildByTag(TAG_SPRITE_BATCH_NODE); + + var idx = 0 | (Math.random() * 14); + var x = (idx % 5) * 85; + var y = (0 | (idx / 5)) * 121; + + var sprite = new cc.Sprite(batchNode.texture, cc.rect(x, y, 85, 121)); + batchNode.addChild(sprite); + + sprite.x = p.x; + + sprite.y = p.y; + + var action; + var random = Math.random(); + + if (random < 0.20) + action = cc.scaleBy(3, 2); + else if (random < 0.40) + action = cc.rotateBy(3, 360); + else if (random < 0.60) + action = cc.blink(1, 3); + else if (random < 0.8) + action = cc.tintBy(2, 0, -255, -255); + else + action = cc.fadeOut(2); + + var action_back = action.reverse(); + var seq = cc.sequence(action, action_back); + + sprite.runAction(seq.repeatForever()); + this.testSprite = sprite; + //----end1---- + }, + + // + // Automation + // + testDuration:1, + pixel:{"0":51, "1":0, "2":51, "3":255}, + testSprite:null, + setupAutomation:function () { + var fun = function () { + var sprite = new cc.Sprite(s_grossini_dance_atlas, cc.rect(0, 0, 85, 121)); + this.addChild(sprite, 999); + sprite.x = winSize.width / 2; + sprite.y = winSize.height / 2; + } + this.scheduleOnce(fun, 0.5); + }, + getExpectedResult:function () { + var ret = {"useBatch":true, "pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 2, winSize.height / 2, 5, 5); + var ret = {"useBatch":this.testSprite.getBatchNode() != null, "pixel":this.containsPixel(ret1, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteColorOpacity +// +//------------------------------------------------------------------ +var SpriteColorOpacity = SpriteTestDemo.extend({ + + _title:"Sprite: Color & Opacity", + + ctor:function () { + //----start11----ctor + this._super(); + var sprite1 = new cc.Sprite(s_grossini_dance_atlas, cc.rect(0, 121, 85, 121)); + var sprite2 = new cc.Sprite(s_grossini_dance_atlas, cc.rect(85, 121, 85, 121)); + var sprite3 = new cc.Sprite(s_grossini_dance_atlas, cc.rect(85 * 2, 121, 85, 121)); + var sprite4 = new cc.Sprite(s_grossini_dance_atlas, cc.rect(85 * 3, 121, 85, 121)); + + var sprite5 = new cc.Sprite(s_grossini_dance_atlas, cc.rect(0, 121, 85, 121)); + var sprite6 = new cc.Sprite(s_grossini_dance_atlas, cc.rect(85, 121, 85, 121)); + var sprite7 = new cc.Sprite(s_grossini_dance_atlas, cc.rect(85 * 2, 121, 85, 121)); + var sprite8 = new cc.Sprite(s_grossini_dance_atlas, cc.rect(85 * 3, 121, 85, 121)); + + sprite1.x = (winSize.width / 5); + + sprite1.y = (winSize.height / 3); + sprite2.x = (winSize.width / 5) * 2; + sprite2.y = (winSize.height / 3); + sprite3.x = (winSize.width / 5) * 3; + sprite3.y = (winSize.height / 3); + sprite4.x = (winSize.width / 5) * 4; + sprite4.y = (winSize.height / 3); + sprite5.x = (winSize.width / 5); + sprite5.y = (winSize.height / 3) * 2; + sprite6.x = (winSize.width / 5) * 2; + sprite6.y = (winSize.height / 3) * 2; + sprite7.x = (winSize.width / 5) * 3; + sprite7.y = (winSize.height / 3) * 2; + sprite8.x = (winSize.width / 5) * 4; + sprite8.y = (winSize.height / 3) * 2; + + var delay = cc.delayTime(0.25); + var action = cc.fadeOut(2); + var action_back = action.reverse(); + var fade = cc.sequence(action, delay.clone(), action_back).repeatForever(); + + var tintRed = cc.tintBy(2, 0, -255, -255); + var tintRedBack = tintRed.reverse(); + var red = cc.sequence(tintRed, delay.clone(), tintRedBack).repeatForever(); + + var tintGreen = cc.tintBy(2, -255, 0, -255); + var tintGreenBack = tintGreen.reverse(); + var green = cc.sequence(tintGreen, delay.clone(), tintGreenBack).repeatForever(); + + var tintBlue = cc.tintBy(2, -255, -255, 0); + var tintBlueBack = tintBlue.reverse(); + var blue = cc.sequence(tintBlue, delay.clone(), tintBlueBack).repeatForever(); + + // late add: test dirtyColor and dirtyPosition + this.addChild(sprite1, 0, TAG_SPRITE1); + this.addChild(sprite2, 0, TAG_SPRITE2); + this.addChild(sprite3, 0, TAG_SPRITE3); + this.addChild(sprite4, 0, TAG_SPRITE4); + this.addChild(sprite5, 0, TAG_SPRITE5); + this.addChild(sprite6, 0, TAG_SPRITE6); + this.addChild(sprite7, 0, TAG_SPRITE7); + this.addChild(sprite8, 0, TAG_SPRITE8); + + sprite5.runAction(red); + sprite6.runAction(green); + sprite7.runAction(blue); + sprite8.runAction(fade); + + this.schedule(this.removeAndAddSprite, 2); + //----end11---- + }, + // this function test if remove and add works as expected: +// color array and vertex array should be reindexed + removeAndAddSprite:function (dt) { + //----start11----removeAndAddSprite + var sprite = this.getChildByTag(TAG_SPRITE5); + + this.removeChild(sprite, false); + this.addChild(sprite, 0, TAG_SPRITE5); + //----end11---- + }, + // + // Automation + // + testDuration:2.1, + pixel1:{"0":255, "1":0, "2":0, "3":255}, + pixel2:{"0":0, "1":204, "2":0, "3":255}, + pixel3:{"0":0, "1":0, "2":153, "3":255}, + pixel4:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes", "pixel4":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels((winSize.width / 5) * 1, (winSize.height / 3) * 2 + 40, 5, 5); + var ret2 = this.readPixels((winSize.width / 5) * 2, (winSize.height / 3) * 2 + 40, 5, 5); + var ret3 = this.readPixels((winSize.width / 5) * 3, (winSize.height / 3) * 2 + 40, 5, 5); + var ret4 = this.readPixels((winSize.width / 5) * 4, (winSize.height / 3) * 2 + 40, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2) ? "yes" : "no", + "pixel3":this.containsPixel(ret3, this.pixel3) ? "yes" : "no", + "pixel4":this.containsPixel(ret4, this.pixel4) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteBatchNodeColorOpacity +// +//------------------------------------------------------------------ +var SpriteBatchNodeColorOpacity = SpriteTestDemo.extend({ + + _title:"SpriteBatchNode: Color & Opacity", + + ctor:function () { + //----start12----ctor + this._super(); + // small capacity. Testing resizing. + // Don't use capacity=1 in your real game. It is expensive to resize the capacity + var batch = new cc.SpriteBatchNode(s_grossini_dance_atlas, 1); + this.addChild(batch, 0, TAG_SPRITE_BATCH_NODE); + + var sprite1 = new cc.Sprite(batch.texture, cc.rect(0, 121, 85, 121)); + var sprite2 = new cc.Sprite(batch.texture, cc.rect(85, 121, 85, 121)); + var sprite3 = new cc.Sprite(batch.texture, cc.rect(85 * 2, 121, 85, 121)); + var sprite4 = new cc.Sprite(batch.texture, cc.rect(85 * 3, 121, 85, 121)); + + var sprite5 = new cc.Sprite(batch.texture, cc.rect(0, 121, 85, 121)); + var sprite6 = new cc.Sprite(batch.texture, cc.rect(85, 121, 85, 121)); + var sprite7 = new cc.Sprite(batch.texture, cc.rect(85 * 2, 121, 85, 121)); + var sprite8 = new cc.Sprite(batch.texture, cc.rect(85 * 3, 121, 85, 121)); + + + sprite1.x = (winSize.width / 5) * 1; + sprite1.y = (winSize.height / 3) * 1; + sprite2.x = (winSize.width / 5) * 2; + sprite2.y = (winSize.height / 3) * 1; + sprite3.x = (winSize.width / 5) * 3; + sprite3.y = (winSize.height / 3) * 1; + sprite4.x = (winSize.width / 5) * 4; + sprite4.y = (winSize.height / 3) * 1; + sprite5.x = (winSize.width / 5) * 1; + sprite5.y = (winSize.height / 3) * 2; + sprite6.x = (winSize.width / 5) * 2; + sprite6.y = (winSize.height / 3) * 2; + sprite7.x = (winSize.width / 5) * 3; + sprite7.y = (winSize.height / 3) * 2; + sprite8.x = (winSize.width / 5) * 4; + sprite8.y = (winSize.height / 3) * 2; + + var delay = cc.delayTime(0.25); + var action = cc.fadeOut(2); + var action_back = action.reverse(); + var fade = cc.sequence(action, delay.clone(), action_back).repeatForever(); + + var tintRed = cc.tintBy(2, 0, -255, -255); + var red = cc.sequence(tintRed, delay.clone(), tintRed.reverse()).repeatForever(); + + var tintGreen = cc.tintBy(2, -255, 0, -255); + var tintGreenBack = tintGreen.reverse(); + var green = cc.sequence(tintGreen, delay.clone(), tintGreenBack).repeatForever(); + + var tintBlue = cc.tintBy(2, -255, -255, 0); + var tintBlueBack = tintBlue.reverse(); + var blue = cc.sequence(tintBlue, delay.clone(), tintBlueBack).repeatForever(); + + // late add: test dirtyColor and dirtyPosition + batch.addChild(sprite1, 0, TAG_SPRITE1); + batch.addChild(sprite2, 0, TAG_SPRITE2); + batch.addChild(sprite3, 0, TAG_SPRITE3); + batch.addChild(sprite4, 0, TAG_SPRITE4); + batch.addChild(sprite5, 0, TAG_SPRITE5); + batch.addChild(sprite6, 0, TAG_SPRITE6); + batch.addChild(sprite7, 0, TAG_SPRITE7); + batch.addChild(sprite8, 0, TAG_SPRITE8); + + sprite5.runAction(red); + sprite6.runAction(green); + sprite7.runAction(blue); + sprite8.runAction(fade); + + this.schedule(this.removeAndAddSprite, 2); + //----end12---- + }, + // this function test if remove and add works as expected: + // color array and vertex array should be reindexed + removeAndAddSprite:function (dt) { + //----start12----removeAndAddSprite + var batch = this.getChildByTag(TAG_SPRITE_BATCH_NODE); + var sprite = batch.getChildByTag(TAG_SPRITE5); + + batch.removeChild(sprite, false); + batch.addChild(sprite, 0, TAG_SPRITE5); + //----end12---- + }, + // + // Automation + // + testDuration:2.1, + pixel1:{"0":255, "1":0, "2":0, "3":255}, + pixel2:{"0":0, "1":204, "2":0, "3":255}, + pixel3:{"0":0, "1":0, "2":153, "3":255}, + pixel4:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes", "pixel4":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels((winSize.width / 5) * 1, (winSize.height / 3) * 2 + 40, 5, 5); + var ret2 = this.readPixels((winSize.width / 5) * 2, (winSize.height / 3) * 2 + 40, 5, 5); + var ret3 = this.readPixels((winSize.width / 5) * 3, (winSize.height / 3) * 2 + 40, 5, 5); + var ret4 = this.readPixels((winSize.width / 5) * 4, (winSize.height / 3) * 2 + 40, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2) ? "yes" : "no", + "pixel3":this.containsPixel(ret3, this.pixel3) ? "yes" : "no", + "pixel4":this.containsPixel(ret4, this.pixel4) ? "yes" : "no"}; + return JSON.stringify(ret); + } + +}); + +//------------------------------------------------------------------ +// +// SpriteZOrder +// +//------------------------------------------------------------------ +var SpriteZOrder = SpriteTestDemo.extend({ + _dir:0, + _title:"Sprite: Z order", + ctor:function () { + //----start13----ctor + this._super(); + this._dir = 1; + + var sprite; + var step = winSize.width / 11; + for (var i = 0; i < 5; i++) { + sprite = new cc.Sprite(s_grossini_dance_atlas, cc.rect(85 * 0, 121 * 1, 85, 121)); + sprite.x = (i + 1) * step; + sprite.y = winSize.height / 2; + this.addChild(sprite, i); + } + + for (i = 5; i < 10; i++) { + sprite = new cc.Sprite(s_grossini_dance_atlas, cc.rect(85 * 1, 121 * 0, 85, 121)); + sprite.x = (i + 1) * step; + sprite.y = winSize.height / 2; + this.addChild(sprite, 14 - i); + } + + sprite = new cc.Sprite(s_grossini_dance_atlas, cc.rect(85 * 3, 121 * 0, 85, 121)); + this.addChild(sprite, -1, TAG_SPRITE1); + sprite.x = winSize.width / 2; + sprite.y = winSize.height / 2 - 20; + sprite.scaleX = 10; + sprite.color = cc.color.RED; + + this.schedule(this.reorderSprite, 1); + //----end13---- + }, + reorderSprite:function (dt) { + //----start13----reorderSprite + var sprite = this.getChildByTag(TAG_SPRITE1); + var z = sprite.zIndex; + if (z < -1) + this._dir = 1; + if (z > 10) + this._dir = -1; + z += this._dir * 3; + this.reorderChild(sprite, z); + //----end13---- + }, + // + // Automation + // + testDuration:4.2, + pixel:{"0":255, "1":0, "2":0, "3":255}, + getExpectedResult:function () { + var ret = {"pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var step = winSize.width / 11; + var ret1 = this.readPixels((6 + 1) * step, winSize.height / 2 + 10, 5, 5); + var ret = {"pixel":this.containsPixel(ret1, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteBatchNodeZOrder +// +//------------------------------------------------------------------ +var SpriteBatchNodeZOrder = SpriteTestDemo.extend({ + _dir:0, + _title:"SpriteBatch: Z order", + ctor:function () { + //----start14----ctor + this._super(); + this._dir = 1; + + // small capacity. Testing resizing. + // Don't use capacity=1 in your real game. It is expensive to resize the capacity + var batch = new cc.SpriteBatchNode(s_grossini_dance_atlas, 1); + this.addChild(batch, 0, TAG_SPRITE_BATCH_NODE); + + var sprite; + var step = winSize.width / 11; + for (var i = 0; i < 5; i++) { + sprite = new cc.Sprite(batch.texture, cc.rect(85 * 0, 121 * 1, 85, 121)); + sprite.x = (i + 1) * step; + sprite.y = winSize.height / 2; + batch.addChild(sprite, i); + } + + for (i = 5; i < 10; i++) { + sprite = new cc.Sprite(batch.texture, cc.rect(85 * 1, 121 * 0, 85, 121)); + sprite.x = (i + 1) * step; + sprite.y = winSize.height / 2; + batch.addChild(sprite, 14 - i); + } + + sprite = new cc.Sprite(batch.texture, cc.rect(85 * 3, 121 * 0, 85, 121)); + batch.addChild(sprite, -1, TAG_SPRITE1); + sprite.x = winSize.width / 2; + sprite.y = winSize.height / 2 - 20; + sprite.scaleX = 10; + sprite.color = cc.color.RED; + this.schedule(this.reorderSprite, 1); + //----end14---- + }, + reorderSprite:function (dt) { + //----start14----reorderSprite + var batch = this.getChildByTag(TAG_SPRITE_BATCH_NODE); + var sprite = batch.getChildByTag(TAG_SPRITE1); + var z = sprite.zIndex; + if (z < -1) + this._dir = 1; + if (z > 10) + this._dir = -1; + z += this._dir * 3; + batch.reorderChild(sprite, z); + //----end14---- + }, + // + // Automation + // + testDuration:4.2, + pixel:{"0":255, "1":0, "2":0, "3":255}, + getExpectedResult:function () { + var ret = {"pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var step = winSize.width / 11; + var ret1 = this.readPixels((6 + 1) * step, winSize.height / 2 + 10, 5, 5); + var ret = {"pixel":this.containsPixel(ret1, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteBatchNodeReorder +// +//------------------------------------------------------------------ +var SpriteBatchNodeReorder = SpriteTestDemo.extend({ + + _title:"SpriteBatchNode: reorder #1", + _subtitle:"Should not crash", + + ctor:function () { + //----start15----ctor + this._super(); + var a = []; + var asmtest = new cc.SpriteBatchNode(s_ghosts); + + for (var i = 0; i < 10; i++) { + var s1 = new cc.Sprite(asmtest.texture, cc.rect(0, 0, 50, 50)); + a.push(s1); + asmtest.addChild(s1, 10); + } + + for (i = 0; i < 10; i++) { + if (i != 5) + asmtest.reorderChild(a[i], 9); + } + + var prev = -1, currentIndex; + var children = asmtest.children; + var child; + for (i = 0; i < children.length; i++) { + child = children[i]; + if (!child) + break; + + //TODO need fixed + currentIndex = child.atlasIndex; + //cc.Assert(prev == currentIndex - 1, "Child order failed"); + ////----UXLog("children %x - atlasIndex:%d", child, currentIndex); + prev = currentIndex; + } + + prev = -1; + var sChildren = asmtest.descendants; + for (i = 0; i < sChildren.length; i++) { + child = sChildren[i]; + if (!child) + break; + + currentIndex = child.atlasIndex; + //cc.Assert(prev == currentIndex - 1, "Child order failed"); + ////----UXLog("descendant %x - atlasIndex:%d", child, currentIndex); + prev = currentIndex; + } + //----end15---- + }, + // + // Automation + // + testDuration:1.2, + getExpectedResult:function () { + return JSON.stringify(true); + }, + getCurrentResult:function () { + return JSON.stringify(true); + } +}); + +//------------------------------------------------------------------ +// +// SpriteBatchNodeReorderIssue744 +// +//------------------------------------------------------------------ +var SpriteBatchNodeReorderIssue744 = SpriteTestDemo.extend({ + _title:"SpriteBatchNode: reorder issue #744", + _subtitle:"Should not crash", + + ctor:function () { + //----start16----ctor + this._super(); + + // Testing issue #744 + // http://code.google.com/p/cocos2d-iphone/issues/detail?id=744 + var batch = new cc.SpriteBatchNode(s_grossini_dance_atlas, 15); + this.addChild(batch, 0, TAG_SPRITE_BATCH_NODE); + + var sprite = new cc.Sprite(batch.texture, cc.rect(0, 0, 85, 121)); + sprite.x = winSize.width / 2; + sprite.y = winSize.height / 2; + batch.addChild(sprite, 3); + batch.reorderChild(sprite, 1); + //----end16---- + }, + // + // Automation + // + testDuration:1.2, + pixel:{"0":51, "1":0, "2":51, "3":255}, + getExpectedResult:function () { + var ret = {"pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 2, winSize.height / 2, 5, 5); + var ret = {"pixel":this.containsPixel(ret1, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteBatchNodeReorderIssue766 +// +//------------------------------------------------------------------ +var SpriteBatchNodeReorderIssue766 = SpriteTestDemo.extend({ + _batchNode:null, + _sprite1:null, + _sprite2:null, + _sprite3:null, + + _title:"SpriteBatchNode: reorder issue #766", + _subtitle:"In 2 seconds 1 sprite will be reordered", + + ctor:function () { + //----start17----ctor + this._super(); + this._batchNode = new cc.SpriteBatchNode(s_piece, 15); + this.addChild(this._batchNode, 1, 0); + + this._sprite1 = this.makeSpriteZ(2); + this._sprite1.x = 200; + this._sprite1.y = 160; + + this._sprite2 = this.makeSpriteZ(3); + this._sprite2.x = 264; + this._sprite2.y = 160; + + this._sprite3 = this.makeSpriteZ(4); + this._sprite3.x = 328; + this._sprite3.y = 160; + + this.schedule(this.reorderSprite, 2); + //----end17---- + }, + reorderSprite:function (dt) { + //----start17----reorderSprite + this.unschedule(this.reorderSprite); + + this._batchNode.reorderChild(this._sprite1, 4); + //----end17---- + }, + makeSpriteZ:function (aZ) { + //----start17----makeSpriteZ + var sprite = new cc.Sprite(this._batchNode.texture, cc.rect(128, 0, 64, 64)); + this._batchNode.addChild(sprite, aZ + 1, 0); + + //children + var spriteShadow = new cc.Sprite(this._batchNode.texture, cc.rect(0, 0, 64, 64)); + spriteShadow.opacity = 128; + sprite.addChild(spriteShadow, aZ, 3); + + var spriteTop = new cc.Sprite(this._batchNode.texture, cc.rect(64, 0, 64, 64)); + sprite.addChild(spriteTop, aZ + 2, 3); + + return sprite; + //----end17---- + }, + // + // Automation + // + testDuration:2.2, + pixel1:{"0":0, "1":0, "2":0, "3":255}, + pixel2:{"0":255, "1":255, "2":255, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(213, 159, 5, 5); + var ret2 = this.readPixels(211, 108, 5, 5); + var ret = {"pixel1":!this.containsPixel(ret1, this.pixel1) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteBatchNodeReorderIssue767 +// +//------------------------------------------------------------------ +var SpriteBatchNodeReorderIssue767 = SpriteTestDemo.extend({ + _title:"SpriteBatchNode: reorder issue #767", + _subtitle:"Should not crash", + + ctor:function () { + //----start18----ctor + this._super(); + + spriteFrameCache.addSpriteFrames(s_ghostsPlist, s_ghosts); + // + // SpriteBatchNode: 3 levels of children + // + var aParent = new cc.SpriteBatchNode(s_ghosts); + this.addChild(aParent, 0, TAG_SPRITE1); + + // parent + var l1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("father.gif")); + l1.x = winSize.width / 2; + l1.y = winSize.height / 2; + aParent.addChild(l1, 0, TAG_SPRITE2); + var l1W = l1.width, l1H = l1.height; + + // child left + var l2a = new cc.Sprite(spriteFrameCache.getSpriteFrame("sister1.gif")); + l2a.x = -25 + l1W / 2; + l2a.y = 0 + l1H / 2; + l1.addChild(l2a, -1, TAG_SPRITE_LEFT); + var l2aW = l2a.width, l2aH = l2a.height; + + + // child right + var l2b = new cc.Sprite(spriteFrameCache.getSpriteFrame("sister2.gif")); + l2b.x = 25 + l1W / 2; + l2b.y = 0 + l1H / 2; + l1.addChild(l2b, 1, TAG_SPRITE_RIGHT); + var l2bW = l2b.width, l2bH = l2b.height; + + + // child left bottom + var l3a1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("child1.gif")); + l3a1.scale = 0.65; + l3a1.x = 0 + l2aW / 2; + l3a1.y = -50 + l2aH / 2; + l2a.addChild(l3a1, -1); + + // child left top + var l3a2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("child1.gif")); + l3a2.scale = 0.65; + l3a2.x = 0 + l2aW / 2; + l3a2.y = +50 + l2aH / 2; + l2a.addChild(l3a2, 1); + + // child right bottom + var l3b1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("child1.gif")); + l3b1.scale = 0.65; + l3b1.x = 0 + l2bW / 2; + l3b1.y = -50 + l2bH / 2; + l2b.addChild(l3b1, -1); + + // child right top + var l3b2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("child1.gif")); + l3b2.scale = 0.65; + l3b2.x = 0 + l2bW / 2; + l3b2.y = +50 + l2bH / 2; + l2b.addChild(l3b2, 1); + + this.schedule(this.reorderSprites, 1); + //----end18---- + }, + reorderSprites:function (dt) { + //----start18----reorderSprites + var spritebatch = this.getChildByTag(TAG_SPRITE1); + var father = spritebatch.getChildByTag(TAG_SPRITE2); + var left = father.getChildByTag(TAG_SPRITE_LEFT); + var right = father.getChildByTag(TAG_SPRITE_RIGHT); + + var newZLeft = 1; + + if (left.zIndex === 1) + newZLeft = -1; + + father.reorderChild(left, newZLeft); + father.reorderChild(right, -newZLeft); + //----end18---- + }, + // + // Automation + // + testDuration:1.5, + pixel1:{"0":255, "1":204, "2":153, "3":255}, + pixel2:{"0":255, "1":255, "2":255, "3":255}, + curPixel1:null, + curPixel2:null, + setupAutomation:function () { + var fun = function(){ + this.curPixel1 = this.readPixels(winSize.width / 2 + 11, winSize.height / 2 - 11, 2, 2); + } + this.scheduleOnce(fun, 0.5); + }, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + this.curPixel2 = this.readPixels(winSize.width / 2 + 11, winSize.height / 2 - 11, 2, 2); + var ret = {"pixel1":this.containsPixel(this.curPixel1, this.pixel1) ? "yes" : "no", + "pixel2":this.containsPixel(this.curPixel2, this.pixel2) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteZVertex +// +//------------------------------------------------------------------ +var SpriteZVertex = SpriteTestDemo.extend({ + _dir:0, + _time:0, + _title:"Sprite: openGL Z vertex", + _subtitle:"Scene should rotate", + + ctor:function () { + //----start19----ctor + this._super(cc.color(255, 0, 0, 80), cc.color(255, 98, 117, 20)); + + + if ("opengl" in cc.sys.capabilities) { + + gl.enable(gl.DEPTH_TEST); + // + // This test tests z-order + // If you are going to use it is better to use a 3D projection + // + // WARNING: + // The developer is resposible for ordering it's sprites according to it's Z if the sprite has + // transparent parts. + // + + // + // Configure shader to mimic glAlphaTest + // + var alphaTestShader = cc.shaderCache.getProgram("ShaderPositionTextureColorAlphaTest"); + var glprogram = alphaTestShader.getProgram(); + var alphaValueLocation = gl.getUniformLocation(glprogram, cc.UNIFORM_ALPHA_TEST_VALUE_S); + + // set alpha test value + // NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison + gl.useProgram(glprogram); + alphaTestShader.setUniformLocationF32(alphaValueLocation, 0.5); + + this._dir = 1; + this._time = 0; + + var step = winSize.width / 12; + + var node = new cc.Node(); + // camera uses the center of the image as the pivoting point + node.width = winSize.width; + node.height = winSize.height; + node.anchorX = 0.5; + node.anchorY = 0.5; + node.x = winSize.width / 2; + node.y = winSize.height / 2; + + this.addChild(node, 0); + var sprite; + for (var i = 0; i < 5; i++) { + sprite = new cc.Sprite(s_grossini_dance_atlas, cc.rect(0, 121, 85, 121)); + sprite.x = (i + 1) * step; + sprite.y = winSize.height / 2; + sprite.vertexZ = 10 + i * 40; + sprite.shaderProgram = alphaTestShader; + node.addChild(sprite, 0); + } + + for (i = 5; i < 11; i++) { + sprite = new cc.Sprite(s_grossini_dance_atlas, cc.rect(85, 0, 85, 121)); + sprite.x = (i + 1) * step; + sprite.y = winSize.height / 2; + sprite.vertexZ = 10 + (10 - i) * 40; + sprite.shaderProgram = alphaTestShader; + node.addChild(sprite, 0); + } + + this.runAction(cc.orbitCamera(10, 1, 0, 0, 360, 0, 0)); + } else { + var label = new cc.LabelTTF("Not supported on HTML5-canvas", "Times New Roman", 30); + this.addChild(label); + label.x = winSize.width / 2; + label.y = winSize.height / 2; + } + //----end19---- + }, + onEnter:function () { + //----start19----onEnter + this._super(); + if ("opengl" in cc.sys.capabilities) { + director.setProjection(cc.Director.PROJECTION_3D); + gl.enable(gl.DEPTH_TEST); + + // Avoid Z-fighting with menu and title + var menu = this.getChildByTag(BASE_TEST_MENU_TAG); + menu.vertexZ = 1; + var title = this.getChildByTag(BASE_TEST_TITLE_TAG); + title.vertexZ = 1; + var subtitle = this.getChildByTag(BASE_TEST_SUBTITLE_TAG); + subtitle.vertexZ = 1; + } + //----end19---- + }, + onExit:function () { + //----start19----onExit + if ("opengl" in cc.sys.capabilities) { + director.setProjection(cc.Director.PROJECTION_2D); + gl.disable(gl.DEPTH_TEST); + } + this._super(); + //----end19---- + }, + // Automation + testDuration:2.2, + pixel1:{"0":51, "1":0, "2":51, "3":255}, + pixel2:{"0":0, "1":0, "2":0, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 2 - 171, winSize.height / 2, 5, 5); + var ret2 = this.readPixels(winSize.width / 2 - 189, winSize.height / 2, 5, 5); + var ret3 = this.readPixels(winSize.width / 2 - 146, winSize.height / 2, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1, false) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2, false) ? "yes" : "no", + "pixel3":this.containsPixel(ret3, this.pixel2, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteBatchNodeZVertex +// +//------------------------------------------------------------------ +var SpriteBatchNodeZVertex = SpriteTestDemo.extend({ + _dir:0, + _time:0, + _title:"SpriteBatchNode: openGL Z vertex", + _subtitle:"Scene should rotate", + + ctor:function () { + //----start20----ctor + this._super(cc.color(255, 0, 0, 80), cc.color(255, 98, 117, 20)); + + if ("opengl" in cc.sys.capabilities) { + + // + // This test tests z-order + // If you are going to use it is better to use a 3D projection + // + // WARNING: + // The developer is resposible for ordering it's sprites according to it's Z if the sprite has + // transparent parts. + // + + // + // Configure shader to mimic glAlphaTest + // + var alphaTestShader = cc.shaderCache.getProgram("ShaderPositionTextureColorAlphaTest"); + var glprogram = alphaTestShader.getProgram(); + var alphaValueLocation = gl.getUniformLocation(glprogram, cc.UNIFORM_ALPHA_TEST_VALUE_S); + + // set alpha test value + // NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison + gl.useProgram(glprogram); + alphaTestShader.setUniformLocationF32(alphaValueLocation, 0.5); + + var step = winSize.width / 12; + + // small capacity. Testing resizing. + // Don't use capacity=1 in your real game. It is expensive to resize the capacity + var batch = new cc.SpriteBatchNode(s_grossini_dance_atlas, 1); + // camera uses the center of the image as the pivoting point + batch.width = winSize.width; + batch.height = winSize.height; + batch.anchorX = 0.5; + batch.anchorY = 0.5; + batch.x = winSize.width / 2; + batch.y = winSize.height / 2; + batch.shaderProgram = alphaTestShader; + + this.addChild(batch, 0, TAG_SPRITE_BATCH_NODE); + var sprite; + + for (var i = 0; i < 5; i++) { + sprite = new cc.Sprite(batch.texture, cc.rect(0, 121, 85, 121)); + sprite.x = (i + 1) * step; + sprite.y = winSize.height / 2; + sprite.vertexZ = 10 + i * 40; + batch.addChild(sprite, 0); + + } + + for (i = 5; i < 11; i++) { + sprite = new cc.Sprite(batch.texture, cc.rect(85, 0, 85, 121)); + sprite.x = (i + 1) * step; + sprite.y = winSize.height / 2; + sprite.vertexZ = 10 + (10 - i) * 40; + batch.addChild(sprite, 0); + } + + this.runAction(cc.orbitCamera(10, 1, 0, 0, 360, 0, 0)); + } else { + var label = new cc.LabelTTF("Not supported on HTML5-canvas", "Times New Roman", 30); + this.addChild(label); + label.x = winSize.width / 2; + label.y = winSize.height / 2; + } + //----end20---- + }, + onEnter:function () { + //----start20----onEnter + this._super(); + + if ("opengl" in cc.sys.capabilities) { + director.setProjection(cc.Director.PROJECTION_3D); + gl.enable(gl.DEPTH_TEST); + + // Avoid Z-fighting with menu and title + var menu = this.getChildByTag(BASE_TEST_MENU_TAG); + menu.vertexZ = 1; + var title = this.getChildByTag(BASE_TEST_TITLE_TAG); + title.vertexZ = 1; + var subtitle = this.getChildByTag(BASE_TEST_SUBTITLE_TAG); + subtitle.vertexZ = 1; + + } + //----end20---- + }, + onExit:function () { + //----start20----onExit + if ("opengl" in cc.sys.capabilities) { + director.setProjection(cc.Director.PROJECTION_2D); + gl.disable(gl.DEPTH_TEST); + } + this._super(); + //----end20---- + }, + // Automation + testDuration:2.2, + pixel1:{"0":51, "1":0, "2":51, "3":255}, + pixel2:{"0":0, "1":0, "2":0, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 2 - 171, winSize.height / 2, 5, 5); + var ret2 = this.readPixels(winSize.width / 2 - 189, winSize.height / 2, 5, 5); + var ret3 = this.readPixels(winSize.width / 2 - 146, winSize.height / 2, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1, false) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2, false) ? "yes" : "no", + "pixel3":this.containsPixel(ret3, this.pixel2, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteAnchorPoint +// +//------------------------------------------------------------------ +var SpriteAnchorPoint = SpriteTestDemo.extend({ + _title:"Sprite: anchor point", + + ctor:function () { + //----start4----ctor + this._super(); + + for (var i = 0; i < 3; i++) { + var rotate = cc.rotateBy(10, 360); + var action = rotate.repeatForever(); + var sprite = new cc.Sprite(s_grossini_dance_atlas, cc.rect(85 * i, 121, 85, 121)); + sprite.x = winSize.width / 4 * (i + 1); + sprite.y = winSize.height / 2; + + var point = new cc.Sprite(s_pathR1); + point.scale = 0.25; + point.x = sprite.x; + point.y = sprite.y; + this.addChild(point, 10); + + switch (i) { + case 0: + sprite.anchorX = 0; + sprite.anchorY = 0; + break; + case 1: + sprite.anchorX = 0.5; + sprite.anchorY = 0.5; + break; + case 2: + sprite.anchorX = 1; + sprite.anchorY = 1; + break; + } + + point.x = sprite.x; + + point.y = sprite.y; + + //var copy = action.clone(); + sprite.runAction(action); + this.addChild(sprite, i); + } + //----end4---- + }, + // + // Automation + // + testDuration:0.15, + pixel:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 4 + 45, winSize.height / 2 + 104, 5, 5); + var ret2 = this.readPixels(winSize.width / 4 * 2 - 3, winSize.height / 2 + 44, 5, 5); + var ret3 = this.readPixels(winSize.width / 4 * 3 - 44, winSize.height / 2 - 16, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel) ? "yes" : "no", "pixel2":this.containsPixel(ret2, this.pixel) ? "yes" : "no", "pixel3":this.containsPixel(ret3, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteBatchNodeAnchorPoint +// +//------------------------------------------------------------------ +var SpriteBatchNodeAnchorPoint = SpriteTestDemo.extend({ + _title:"SpriteBatchNode: anchor point", + + ctor:function () { + //----start5----ctor + this._super(); + // small capacity. Testing resizing. + // Don't use capacity=1 in your real game. It is expensive to resize the capacity + var batch = new cc.SpriteBatchNode(s_grossini_dance_atlas, 1); + this.addChild(batch, 0, TAG_SPRITE_BATCH_NODE); + + for (var i = 0; i < 3; i++) { + var rotate = cc.rotateBy(10, 360); + var action = rotate.repeatForever(); + var sprite = new cc.Sprite(batch.texture, cc.rect(85 * i, 121, 85, 121)); + sprite.x = winSize.width / 4 * (i + 1); + sprite.y = winSize.height / 2; + + var point = new cc.Sprite(s_pathR1); + point.scale = 0.25; + point.x = sprite.x; + point.y = sprite.y; + this.addChild(point, 1); + + switch (i) { + case 0: + sprite.anchorX = 0; + sprite.anchorY = 0; + break; + case 1: + sprite.anchorX = 0.5; + sprite.anchorY = 0.5; + break; + case 2: + sprite.anchorX = 1; + sprite.anchorY = 1; + break; + } + + point.x = sprite.x; + + point.y = sprite.y; + sprite.runAction(action); + batch.addChild(sprite, i); + } + //----end5---- + }, + // + // Automation + // + testDuration:0.15, + pixel:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 4 + 45, winSize.height / 2 + 104, 5, 5); + var ret2 = this.readPixels(winSize.width / 4 * 2 - 3, winSize.height / 2 + 44, 5, 5); + var ret3 = this.readPixels(winSize.width / 4 * 3 - 44, winSize.height / 2 - 16, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel) ? "yes" : "no", "pixel2":this.containsPixel(ret2, this.pixel) ? "yes" : "no", "pixel3":this.containsPixel(ret3, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// Sprite6 +// +//------------------------------------------------------------------ +var Sprite6 = SpriteTestDemo.extend({ + _title:"SpriteBatchNode transformation", + + ctor:function () { + //----start21----ctor + this._super(); + // small capacity. Testing resizing + // Don't use capacity=1 in your real game. It is expensive to resize the capacity + var batch = new cc.SpriteBatchNode(s_grossini_dance_atlas, 1); + this.addChild(batch, 0, TAG_SPRITE_BATCH_NODE); + batch.ignoreAnchorPointForPosition(true); + + batch.anchorX = 0.5; + + batch.anchorY = 0.5; + batch.width = winSize.width; + batch.height = winSize.height; + + // SpriteBatchNode actions + var rotate1 = cc.rotateBy(5, 360); + var rotate_back = rotate1.reverse(); + var rotate_seq = cc.sequence(rotate1, rotate_back); + var rotate_forever = rotate_seq.repeatForever(); + + var scale = cc.scaleBy(5, 1.5); + var scale_back = scale.reverse(); + var scale_seq = cc.sequence(scale, scale_back); + var scale_forever = scale_seq.repeatForever(); + + for (var i = 0; i < 3; i++) { + var sprite = new cc.Sprite(batch.texture, cc.rect(85 * i, 121, 85, 121)); + switch (i) { + case 0: + sprite.x = winSize.width / 2 - 100; + sprite.y = winSize.height / 2; + break; + case 1: + sprite.x = winSize.width / 2; + sprite.y = winSize.height / 2; + break; + case 2: + sprite.x = winSize.width / 2 + 100; + sprite.y = winSize.height / 2; + break; + } + var rotate = cc.rotateBy(5, 360); + var action = rotate.repeatForever(); + sprite.runAction(action.clone()); + batch.addChild(sprite, i); + } + + batch.runAction(scale_forever); + batch.runAction(rotate_forever); + //----end21---- + }, + // Automation + testDuration:2, + pixel:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 2 + 111, winSize.height / 2 + 82, 5, 5); + var ret2 = this.readPixels(winSize.width / 2 - 148, winSize.height / 2 - 58, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel, false) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteFlip +// +//------------------------------------------------------------------ +var SpriteFlip = SpriteTestDemo.extend({ + _title:"Sprite Flip X & Y", + + ctor:function () { + //----start22----ctor + this._super(); + var sprite1 = new cc.Sprite(s_grossini_dance_atlas, cc.rect(85, 121, 85, 121)); + sprite1.x = winSize.width / 2 - 100; + sprite1.y = winSize.height / 2; + this.addChild(sprite1, 0, TAG_SPRITE1); + + var sprite2 = new cc.Sprite(s_grossini_dance_atlas, cc.rect(85, 121, 85, 121)); + sprite2.x = winSize.width / 2 + 100; + sprite2.y = winSize.height / 2; + this.addChild(sprite2, 0, TAG_SPRITE2); + + this.schedule(this.onFlipSprites, 1); + //----end22---- + }, + onFlipSprites:function (dt) { + //----start22----onFlipSprites + var sprite1 = this.getChildByTag(TAG_SPRITE1); + var sprite2 = this.getChildByTag(TAG_SPRITE2); + + sprite1.flippedX = !sprite1.flippedX; + sprite2.flippedY = !sprite2.flippedY; + //----end22---- + }, + // + // Automation + // + testDuration:1.5, + pixel:{"0":255, "1":204, "2":153, "3":255}, + pixel1:null, + pixel2:null, + pixel3:null, + pixel4:null, + setupAutomation:function () { + this.scheduleOnce(this.getBeforePixel, 0.5); + }, + getBeforePixel:function () { + this.pixel1 = this.readPixels(winSize.width / 2 - 131, winSize.height / 2 - 11, 5, 5); + this.pixel2 = this.readPixels(winSize.width / 2 + 100, winSize.height / 2 + 44, 5, 5); + }, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes", "pixel4":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + this.pixel3 = this.readPixels(winSize.width / 2 - 69, winSize.height / 2 - 11, 5, 5); + this.pixel4 = this.readPixels(winSize.width / 2 + 100, winSize.height / 2 - 44, 5, 5); + var ret = {"pixel1":this.containsPixel(this.pixel1, this.pixel) ? "yes" : "no", + "pixel2":this.containsPixel(this.pixel2, this.pixel) ? "yes" : "no", + "pixel3":this.containsPixel(this.pixel3, this.pixel) ? "yes" : "no", + "pixel4":this.containsPixel(this.pixel4, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteBatchNodeFlip +// +//------------------------------------------------------------------ +var SpriteBatchNodeFlip = SpriteTestDemo.extend({ + _title:"SpriteBatchNode Flip X & Y", + + ctor:function () { + //----start23----ctor + this._super(); + var batch = new cc.SpriteBatchNode(s_grossini_dance_atlas, 10); + this.addChild(batch, 0, TAG_SPRITE_BATCH_NODE); + + var sprite1 = new cc.Sprite(batch.texture, cc.rect(85, 121, 85, 121)); + sprite1.x = winSize.width / 2 - 100; + sprite1.y = winSize.height / 2; + batch.addChild(sprite1, 0, TAG_SPRITE1); + + var sprite2 = new cc.Sprite(batch.texture, cc.rect(85, 121, 85, 121)); + sprite2.x = winSize.width / 2 + 100; + sprite2.y = winSize.height / 2; + batch.addChild(sprite2, 0, TAG_SPRITE2); + + this.schedule(this.onFlipSprites, 1); + //----end23---- + }, + onFlipSprites:function (dt) { + //----start23----onFlipSprites + var batch = this.getChildByTag(TAG_SPRITE_BATCH_NODE); + var sprite1 = batch.getChildByTag(TAG_SPRITE1); + var sprite2 = batch.getChildByTag(TAG_SPRITE2); + + sprite1.flippedX = !sprite1.flippedX; + sprite2.flippedY = !sprite2.flippedY; + //----end23---- + }, + // + // Automation + // + testDuration:1.5, + pixel:{"0":255, "1":204, "2":153, "3":255}, + pixel1:null, + pixel2:null, + pixel3:null, + pixel4:null, + setupAutomation:function () { + this.scheduleOnce(this.getBeforePixel, 0.5); + }, + getBeforePixel:function () { + this.pixel1 = this.readPixels(winSize.width / 2 - 131, winSize.height / 2 - 11, 5, 5); + this.pixel2 = this.readPixels(winSize.width / 2 + 100, winSize.height / 2 + 44, 5, 5); + }, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes", "pixel4":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + this.pixel3 = this.readPixels(winSize.width / 2 - 69, winSize.height / 2 - 11, 5, 5); + this.pixel4 = this.readPixels(winSize.width / 2 + 100, winSize.height / 2 - 44, 5, 5); + var ret = {"pixel1":this.containsPixel(this.pixel1, this.pixel) ? "yes" : "no", + "pixel2":this.containsPixel(this.pixel2, this.pixel) ? "yes" : "no", + "pixel3":this.containsPixel(this.pixel3, this.pixel) ? "yes" : "no", + "pixel4":this.containsPixel(this.pixel4, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteAliased +// +//------------------------------------------------------------------ +var SpriteAliased = SpriteTestDemo.extend({ + _title:"Sprite Aliased", + _subtitle:"You should see pixelated sprites", + + ctor:function () { + //----start24----ctor + this._super(); + var sprite1 = new cc.Sprite(s_grossini_dance_atlas, cc.rect(85, 121, 85, 121)); + sprite1.x = winSize.width / 2 - 100; + sprite1.y = winSize.height / 2; + this.addChild(sprite1, 0, TAG_SPRITE1); + + var sprite2 = new cc.Sprite(s_grossini_dance_atlas, cc.rect(85, 121, 85, 121)); + sprite2.x = winSize.width / 2 + 100; + sprite2.y = winSize.height / 2; + this.addChild(sprite2, 0, TAG_SPRITE2); + + var scale = cc.scaleBy(2, 5); + var scale_back = scale.reverse(); + var seq = cc.sequence(scale, scale_back); + var repeat = seq.repeatForever(); + + var scale2 = cc.scaleBy(2, 5); + var scale_back2 = scale2.reverse(); + var seq2 = cc.sequence(scale2, scale_back2); + var repeat2 = seq2.repeatForever(); + + sprite1.runAction(repeat); + sprite2.runAction(repeat2); + //----end24---- + }, + onEnter:function () { + //----start24----onEnter + this._super(); + // + // IMPORTANT: + // This change will affect every sprite that uses the same texture + // So sprite1 and sprite2 will be affected by this change + // + if (!cc.sys.isNative && !("opengl" in cc.sys.capabilities)) { + var label = new cc.LabelTTF("Not supported on HTML5-canvas", "Times New Roman", 30); + this.addChild(label); + label.x = winSize.width / 2; + label.y = winSize.height / 2; + } else { + var sprite = this.getChildByTag(TAG_SPRITE1); + sprite.texture.setAliasTexParameters(); + } + + //----end24---- + }, + onExit:function () { + //----start24----onExit + if (cc.sys.isNative || ("opengl" in cc.sys.capabilities)) { + var sprite = this.getChildByTag(TAG_SPRITE1); + sprite.texture.setAntiAliasTexParameters(); + } + this._super(); + //----end24---- + } +}); + +//------------------------------------------------------------------ +// +// SpriteBatchNodeAliased +// +//------------------------------------------------------------------ +var SpriteBatchNodeAliased = SpriteTestDemo.extend({ + _title:"SpriteBatchNode Aliased", + _subtitle:"You should see pixelated sprites", + + ctor:function () { + //----start25----ctor + this._super(); + var batch = new cc.SpriteBatchNode(s_grossini_dance_atlas, 10); + this.addChild(batch, 0, TAG_SPRITE_BATCH_NODE); + + var sprite1 = new cc.Sprite(batch.texture, cc.rect(85, 121, 85, 121)); + sprite1.x = winSize.width / 2 - 100; + sprite1.y = winSize.height / 2; + batch.addChild(sprite1, 0, TAG_SPRITE1); + + var sprite2 = new cc.Sprite(batch.texture, cc.rect(85, 121, 85, 121)); + sprite2.x = winSize.width / 2 + 100; + sprite2.y = winSize.height / 2; + batch.addChild(sprite2, 0, TAG_SPRITE2); + + var scale = cc.scaleBy(2, 5); + var scale_back = scale.reverse(); + var seq = cc.sequence(scale, scale_back); + var repeat = seq.repeatForever(); + + var scale2 = cc.scaleBy(2, 5); + var scale_back2 = scale2.reverse(); + var seq2 = cc.sequence(scale2, scale_back2); + var repeat2 = seq2.repeatForever(); + + sprite1.runAction(repeat); + sprite2.runAction(repeat2); + //----end25---- + }, + onEnter:function () { + //----start25----onEnter + this._super(); + // + // IMPORTANT: + // This change will affect every sprite that uses the same texture + // So sprite1 and sprite2 will be affected by this change + // + if (!cc.sys.isNative && !("opengl" in cc.sys.capabilities)) { + var label = new cc.LabelTTF("Not supported on HTML5-canvas", "Times New Roman", 30); + this.addChild(label); + label.x = winSize.width / 2; + label.y = winSize.height / 2; + } else { + var sprite = this.getChildByTag(TAG_SPRITE_BATCH_NODE); + sprite.texture.setAliasTexParameters(); + } + //----end25---- + + }, + onExit:function () { + //----start25----onExit + if (cc.sys.isNative || ("opengl" in cc.sys.capabilities)) { + var sprite = this.getChildByTag(TAG_SPRITE_BATCH_NODE); + sprite.texture.setAntiAliasTexParameters(); + } + this._super(); + //----end25---- + } +}); + +//------------------------------------------------------------------ +// +// SpriteNewTexture +// +//------------------------------------------------------------------ +var SpriteNewTexture = SpriteTestDemo.extend({ + _usingTexture1:false, + _texture1:null, + _texture2:null, + _title:"Sprite New texture (tap)", + + ctor:function () { + //----start26----ctor + this._super(); + + if ('touches' in cc.sys.capabilities){ + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded:function (touches, event) { + event.getCurrentTarget().onChangeTexture(); + } + }, this); + } else if ('mouse' in cc.sys.capabilities) + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseUp: function(event){ + event.getCurrentTarget().onChangeTexture(); + } + }, this); + + var node = new cc.Node(); + this.addChild(node, 0, TAG_SPRITE_BATCH_NODE); + + this._texture1 = cc.textureCache.addImage(s_grossini_dance_atlas); + this._texture2 = cc.textureCache.addImage(s_grossini_dance_atlas_mono); + + this._usingTexture1 = true; + + for (var i = 0; i < 30; i++) { + this.addNewSprite(); + } + //----end26---- + }, + + addNewSprite:function () { + //----start26----addNewSprite + var p = cc.p(Math.random() * winSize.width, Math.random() * winSize.height); + + var idx = 0 | (Math.random() * 14); + var x = (idx % 5) * 85; + var y = (0 | (idx / 5)) * 121; + + + var node = this.getChildByTag(TAG_SPRITE_BATCH_NODE); + var sprite = new cc.Sprite(this._texture1, cc.rect(x, y, 85, 121)); + node.addChild(sprite); + + sprite.x = p.x; + + sprite.y = p.y; + + var action; + var random = Math.random(); + + if (random < 0.20) + action = cc.scaleBy(3, 2); + else if (random < 0.40) + action = cc.rotateBy(3, 360); + else if (random < 0.60) + action = cc.blink(1, 3); + // else if (random < 0.8) + // action = cc.tintBy(2, 0, -255, -255); + else + action = cc.fadeOut(2); + + var action_back = action.reverse(); + var seq = cc.sequence(action, action_back); + + sprite.runAction(seq.repeatForever()); + //----end26---- + }, + + onChangeTexture:function () { + //----start26----onChangeTexture + var node = this.getChildByTag(TAG_SPRITE_BATCH_NODE); + var children = node.children, sprite, i; + + if (this._usingTexture1) { //-. win32 : Let's it make just simple sentence + for (i = 0; i < children.length; i++) { + sprite = children[i]; + if (!sprite) + break; + sprite.texture = this._texture2; + } + this._usingTexture1 = false; + } else { + for (i = 0; i < children.length; i++) { + sprite = children[i]; + if (!sprite) + break; + sprite.texture = this._texture1; + } + this._usingTexture1 = true; + } + //----end26---- + }, + + // + // Automation + // + testDuration:1, + pixel:{"0":51, "1":0, "2":51, "3":255}, + setupAutomation:function () { + this.scheduleOnce(this.addTestSprite, 0.5); + }, + addTestSprite:function () { + var node = this.getChildByTag(TAG_SPRITE_BATCH_NODE); + var sprite = new cc.Sprite(this._texture1, cc.rect(0, 0, 85, 121)); + sprite.x = winSize.width / 2; + sprite.y = winSize.height / 2; + node.addChild(sprite); + }, + getExpectedResult:function () { + var ret = {"pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 2, winSize.height / 2, 5, 5); + var ret = {"pixel":this.containsPixel(ret1, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteBatchNodeNewTexture +// +//------------------------------------------------------------------ +var SpriteBatchNodeNewTexture = SpriteTestDemo.extend({ + _texture1:null, + _texture2:null, + _title:"SpriteBatchNode new texture (tap)", + + ctor:function () { + //----start27----ctor + this._super(); + if ('touches' in cc.sys.capabilities){ + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded:function (touches, event) { + event.getCurrentTarget().onChangeTexture(); + } + }, this); + } else if ('mouse' in cc.sys.capabilities) + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseUp: function(event){ + event.getCurrentTarget().onChangeTexture(); + } + }, this); + + var batch = new cc.SpriteBatchNode(s_grossini_dance_atlas, 50); + this.addChild(batch, 0, TAG_SPRITE_BATCH_NODE); + + this._texture1 = batch.texture; + this._texture2 = cc.textureCache.addImage(s_grossini_dance_atlas_mono); + + for (var i = 0; i < 30; i++) { + this.addNewSprite(); + } + //----end27---- + }, + addNewSprite:function () { + //----start27----addNewSprite + var s = winSize; + + var p = cc.p(Math.random() * winSize.width, Math.random() * winSize.height); + + var batch = this.getChildByTag(TAG_SPRITE_BATCH_NODE); + + var idx = 0 | (Math.random() * 14); + var x = (idx % 5) * 85; + var y = (0 | (idx / 5)) * 121; + + var sprite = new cc.Sprite(batch.texture, cc.rect(x, y, 85, 121)); + batch.addChild(sprite); + + sprite.x = p.x; + + sprite.y = p.y; + + var action; + var random = Math.random(); + + if (random < 0.20) + action = cc.scaleBy(3, 2); + else if (random < 0.40) + action = cc.rotateBy(3, 360); + else if (random < 0.60) + action = cc.blink(1, 3); + //else if (random < 0.8) + // action = cc.tintBy(2, 0, -255, -255); + else + action = cc.fadeOut(2); + var action_back = action.reverse(); + var seq = cc.sequence(action, action_back); + + sprite.runAction(seq.repeatForever()); + //----end27---- + }, + onChangeTexture:function () { + //----start27----onChangeTexture + var batch = this.getChildByTag(TAG_SPRITE_BATCH_NODE); + + if (batch.texture == this._texture1) + batch.texture = this._texture2; + else + batch.texture = this._texture1; + //----end27---- + }, + + // + // Automation + // + testDuration:1, + pixel:{"0":51, "1":0, "2":51, "3":255}, + setupAutomation:function () { + this.scheduleOnce(this.addTestSprite, 0.5); + }, + addTestSprite:function () { + var node = this.getChildByTag(TAG_SPRITE_BATCH_NODE); + var sprite = new cc.Sprite(this._texture1, cc.rect(0, 0, 85, 121)); + sprite.x = winSize.width / 2; + sprite.y = winSize.height / 2; + node.addChild(sprite); + }, + getExpectedResult:function () { + var ret = {"pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 2, winSize.height / 2, 5, 5); + var ret = {"pixel":this.containsPixel(ret1, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteFrameTest +// +//------------------------------------------------------------------ +var SpriteFrameTest = SpriteTestDemo.extend({ + _sprite1:null, + _sprite2:null, + _counter:0, + _title:"Sprite vs. SpriteBatchNode animation", + _subtitle:"Testing issue #792", + + onEnter:function () { + //----start2----onEnter + this._super(); + // IMPORTANT: + // The sprite frames will be cached AND RETAINED, and they won't be released unless you call + // cc.spriteFrameCache.removeUnusedSpriteFrames); + spriteFrameCache.addSpriteFrames(s_grossiniPlist); + spriteFrameCache.addSpriteFrames(s_grossini_grayPlist, s_grossini_gray); + spriteFrameCache.addSpriteFrames(s_grossini_bluePlist, s_grossini_blue); + + // + // Animation using Sprite BatchNode + // + this._sprite1 = new cc.Sprite("#grossini_dance_01.png"); + this._sprite1.x = winSize.width / 2 - 80; + this._sprite1.y = winSize.height / 2; + + var spritebatch = new cc.SpriteBatchNode(s_grossini); + spritebatch.addChild(this._sprite1); + this.addChild(spritebatch); + + var animFrames = []; + var str = ""; + var frame; + for (var i = 1; i < 15; i++) { + str = "grossini_dance_" + (i < 10 ? ("0" + i) : i) + ".png"; + frame = spriteFrameCache.getSpriteFrame(str); + animFrames.push(frame); + } + + var animation = new cc.Animation(animFrames, 0.3); + this._sprite1.runAction(cc.animate(animation).repeatForever()); + + // to test issue #732, uncomment the following line + this._sprite1.flippedX = false; + this._sprite1.flippedY = false; + + // + // Animation using standard Sprite + // + this._sprite2 = new cc.Sprite("#grossini_dance_01.png"); + this._sprite2.x = winSize.width / 2 + 80; + this._sprite2.y = winSize.height / 2; + this.addChild(this._sprite2); + + var moreFrames = []; + for (i = 1; i < 15; i++) { + str = "grossini_dance_gray_" + (i < 10 ? ("0" + i) : i) + ".png"; + frame = spriteFrameCache.getSpriteFrame(str); + moreFrames.push(frame); + } + + for (i = 1; i < 5; i++) { + str = "grossini_blue_0" + i + ".png"; + frame = spriteFrameCache.getSpriteFrame(str); + moreFrames.push(frame); + } + + // append frames from another batch + moreFrames = moreFrames.concat(animFrames); + var animMixed = new cc.Animation(moreFrames, 0.3); + + this._sprite2.runAction(cc.animate(animMixed).repeatForever()); + + // to test issue #732, uncomment the following line + this._sprite2.flippedX = false; + this._sprite2.flippedY = false; + + this.schedule(this.onStartIn05Secs, 0.5); + this._counter = 0; + //----end2---- + }, + onExit:function () { + //----start2----onExit + this._super(); + spriteFrameCache.removeSpriteFramesFromFile(s_grossiniPlist); + spriteFrameCache.removeSpriteFramesFromFile(s_grossini_grayPlist); + spriteFrameCache.removeSpriteFramesFromFile(s_grossini_bluePlist); + //----end2---- + }, + onStartIn05Secs:function () { + //----start2----onStartIn05Secs + this.unschedule(this.onStartIn05Secs); + this.schedule(this.onFlipSprites, 1.0); + //----end2---- + }, + onFlipSprites:function (dt) { + //----start2----onFlipSprites + this._counter++; + + var fx = false; + var fy = false; + var i = this._counter % 4; + + switch (i) { + case 0: + fx = false; + fy = false; + break; + case 1: + fx = true; + fy = false; + break; + case 2: + fx = false; + fy = true; + break; + case 3: + fx = true; + fy = true; + break; + } + + this._sprite1.flippedX = fx; + this._sprite1.flippedY = fy; + this._sprite2.flippedX = fx; + this._sprite2.flippedY = fy; + //----end2---- + }, + // + // Automation + // + testDuration:3.1, + pixel1:{"0":255, "1":204, "2":153, "3":255}, + pixel2:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 2 - 50, winSize.height / 2 + 8, 5, 5); + var ret2 = this.readPixels(winSize.width / 2 - 80, winSize.height / 2 - 42, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteFrameAliasNameTest +// +//------------------------------------------------------------------ +var SpriteFrameAliasNameTest = SpriteTestDemo.extend({ + _title:"SpriteFrame Alias Name", + _subtitle:"SpriteFrames are obtained using the alias name", + onEnter:function (){ + //----start3----onEnter + this._super(); + // IMPORTANT: + // The sprite frames will be cached AND RETAINED, and they won't be released unless you call + // + // cc.SpriteFrameCache is a cache of cc.SpriteFrames + // cc.SpriteFrames each contain a texture id and a rect (frame). + spriteFrameCache.addSpriteFrames(s_grossini_aliasesPlist, s_grossini_aliases); + + // + // Animation using Sprite batch + // + // A cc.SpriteBatchNode can reference one and only one texture (one .png file) + // Sprites that are contained in that texture can be instantiatied as cc.Sprites and then added to the cc.SpriteBatchNode + // All cc.Sprites added to a cc.SpriteBatchNode are drawn in one OpenGL ES draw call + // If the cc.Sprites are not added to a cc.SpriteBatchNode then an OpenGL ES draw call will be needed for each one, which is less efficient + // + // When you animate a sprite, CCAnimation changes the frame of the sprite using setDisplayFrame: (this is why the animation must be in the same texture) + // When setDisplayFrame: is used in the CCAnimation it changes the frame to one specified by the cc.SpriteFrames that were added to the animation, + // but texture id is still the same and so the sprite is still a child of the cc.SpriteBatchNode, + // and therefore all the animation sprites are also drawn as part of the cc.SpriteBatchNode + // + var sprite = new cc.Sprite("#grossini_dance_01.png"); + sprite.x = winSize.width / 2; + sprite.y = winSize.height / 2; + + var spriteBatch = new cc.SpriteBatchNode(s_grossini_aliases); + spriteBatch.addChild(sprite); + this.addChild(spriteBatch); + + var animFrames = []; + var str = ""; + for (var i = 1; i < 15; i++) { + // Obtain frames by alias name + str = "dance_" + (i < 10 ? ("0" + i) : i); + var frame = spriteFrameCache.getSpriteFrame(str); + animFrames.push(frame); + } + + var animation = new cc.Animation(animFrames, 0.3); + // 14 frames * 1sec = 14 seconds + sprite.runAction(cc.animate(animation).repeatForever()); + this.testSprite = sprite; + //----end3---- + }, + onExit:function () { + this._super(); + spriteFrameCache.removeSpriteFramesFromFile(s_grossini_aliasesPlist); + }, + // + // Automation + // + testDuration:0.5, + pixel:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 2 - 32, winSize.height / 2 - 10, 5, 5); + var ret = {"pixel":this.containsPixel(ret1, this.pixel, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteOffsetAnchorRotation +// +//------------------------------------------------------------------ +var SpriteOffsetAnchorRotation = SpriteTestDemo.extend({ + + _title:"Sprite offset + anchor + rot", + ctor:function () { + //----start6----ctor + this._super(); + spriteFrameCache.addSpriteFrames(s_grossiniPlist); + spriteFrameCache.addSpriteFrames(s_grossini_grayPlist, s_grossini_gray); + + for (var i = 0; i < 3; i++) { + // + // Animation using Sprite BatchNode + // + var sprite = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_01.png")); + sprite.x = winSize.width / 4 * (i + 1); + sprite.y = winSize.height / 2; + + var point = new cc.Sprite(s_pathR1); + point.scale = 0.25; + point.x = sprite.x; + point.y = sprite.y; + this.addChild(point, 1); + + switch (i) { + case 0: + sprite.anchorX = 0; + sprite.anchorY = 0; + break; + case 1: + sprite.anchorX = 0.5; + sprite.anchorY = 0.5; + break; + case 2: + sprite.anchorX = 1; + sprite.anchorY = 1; + break; + } + + point.x = sprite.x; + + point.y = sprite.y; + + var animFrames = []; + var str = ""; + for (var j = 1; j < 15; j++) { + str = "grossini_dance_" + (j < 10 ? ("0" + j) : j) + ".png"; + var frame = spriteFrameCache.getSpriteFrame(str); + animFrames.push(frame); + } + + var animation = new cc.Animation(animFrames, 0.3); + sprite.runAction(cc.animate(animation).repeatForever()); + sprite.runAction(cc.rotateBy(10, 360).repeatForever()); + + this.addChild(sprite, 0); + } + //----end6---- + }, + onExit:function () { + //----start6----onExit + this._super(); + spriteFrameCache.removeSpriteFramesFromFile(s_grossiniPlist); + spriteFrameCache.removeSpriteFramesFromFile(s_grossini_grayPlist); + //----end6---- + }, + // + // Automation + // + testDuration:5, + pixel:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 4 - 13, winSize.height / 2 - 50, 5, 5); + var ret2 = this.readPixels(winSize.width / 4 * 2 + 29, winSize.height / 2 + 11, 5, 5); + var ret3 = this.readPixels(winSize.width / 4 * 3 + 71, winSize.height / 2 + 71, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel) ? "yes" : "no", "pixel2":this.containsPixel(ret2, this.pixel) ? "yes" : "no", "pixel3":this.containsPixel(ret3, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteBatchNodeOffsetAnchorRotation +// +//------------------------------------------------------------------ +var SpriteBatchNodeOffsetAnchorRotation = SpriteTestDemo.extend({ + _title:"SpriteBatchNode offset + anchor + rot", + + ctor:function () { + //----start7----ctor + this._super(); + + spriteFrameCache.addSpriteFrames(s_grossiniPlist); + spriteFrameCache.addSpriteFrames(s_grossini_grayPlist, s_grossini_gray); + + var spritebatch = new cc.SpriteBatchNode(s_grossini); + this.addChild(spritebatch); + + for (var i = 0; i < 3; i++) { + // + // Animation using Sprite BatchNode + // + var sprite = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_01.png")); + sprite.x = winSize.width / 4 * (i + 1); + sprite.y = winSize.height / 2; + + var point = new cc.Sprite(s_pathR1); + point.scale = 0.25; + point.x = sprite.x; + point.y = sprite.y; + this.addChild(point, 200); + + switch (i) { + case 0: + sprite.anchorX = 0; + sprite.anchorY = 0; + break; + case 1: + sprite.anchorX = 0.5; + sprite.anchorY = 0.5; + break; + case 2: + sprite.anchorX = 1; + sprite.anchorY = 1; + break; + } + point.x = sprite.x; + point.y = sprite.y; + + var animFrames = []; + var str = ""; + for (var k = 1; k < 15; k++) { + str = "grossini_dance_" + (k < 10 ? ("0" + k) : k) + ".png"; + var frame = spriteFrameCache.getSpriteFrame(str); + animFrames.push(frame); + } + + var animation = new cc.Animation(animFrames, 0.3); + sprite.runAction(cc.animate(animation).repeatForever()); + sprite.runAction(cc.rotateBy(10, 360).repeatForever()); + + spritebatch.addChild(sprite, i); + } + //----end7---- + }, + onExit:function () { + this._super(); + spriteFrameCache.removeSpriteFramesFromFile(s_grossiniPlist); + spriteFrameCache.removeSpriteFramesFromFile(s_grossini_grayPlist); + }, + // + // Automation + // + testDuration:5, + pixel:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 4 - 13, winSize.height / 2 - 50, 5, 5); + var ret2 = this.readPixels(winSize.width / 4 * 2 + 29, winSize.height / 2 + 11, 5, 5); + var ret3 = this.readPixels(winSize.width / 4 * 3 + 71, winSize.height / 2 + 71, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel) ? "yes" : "no", "pixel2":this.containsPixel(ret2, this.pixel) ? "yes" : "no", "pixel3":this.containsPixel(ret3, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteOffsetAnchorScale +// +//------------------------------------------------------------------ +var SpriteOffsetAnchorScale = SpriteTestDemo.extend({ + + _title:"Sprite offset + anchor + scale", + + ctor:function () { + //----start8----ctor + this._super(); + spriteFrameCache.addSpriteFrames(s_grossiniPlist); + spriteFrameCache.addSpriteFrames(s_grossini_grayPlist, s_grossini_gray); + + for (var i = 0; i < 3; i++) { + // + // Animation using Sprite BatchNode + // + var sprite = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_01.png")); + sprite.x = winSize.width / 4 * (i + 1); + sprite.y = winSize.height / 2; + + var point = new cc.Sprite(s_pathR1); + point.scale = 0.25; + point.x = sprite.x; + point.y = sprite.y; + this.addChild(point, 1); + + switch (i) { + case 0: + sprite.anchorX = 0; + sprite.anchorY = 0; + break; + case 1: + sprite.anchorX = 0.5; + sprite.anchorY = 0.5; + break; + case 2: + sprite.anchorX = 1; + sprite.anchorY = 1; + break; + } + + point.x = sprite.x; + + point.y = sprite.y; + + var animFrames = []; + var str = ""; + for (var k = 1; k <= 14; k++) { + str = "grossini_dance_" + (k < 10 ? ("0" + k) : k) + ".png"; + var frame = spriteFrameCache.getSpriteFrame(str); + animFrames.push(frame); + } + + var animation = new cc.Animation(animFrames, 0.3); + sprite.runAction(cc.animate(animation).repeatForever()); + + var scale = cc.scaleBy(2, 2); + var scale_back = scale.reverse(); + var delay = cc.delayTime(0.25); + var seq_scale = cc.sequence(scale, delay, scale_back); + sprite.runAction(seq_scale.repeatForever()); + + this.addChild(sprite, 0); + } + //----end8---- + }, + onExit:function () { + //----start8----onExit + this._super(); + spriteFrameCache.removeSpriteFramesFromFile(s_grossiniPlist); + spriteFrameCache.removeSpriteFramesFromFile(s_grossini_grayPlist); + //----end8---- + }, + // + // Automation + // + testDuration:2.1, + pixel:{"0":153, "1":0, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 4 * 3 - 85, winSize.height / 2 - 106, 5, 5); + var ret2 = this.readPixels(winSize.width / 4 * 2, winSize.height / 2 + 13, 5, 5); + var ret3 = this.readPixels(winSize.width / 4 + 82, winSize.height / 2 + 133, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel) ? "yes" : "no", "pixel2":this.containsPixel(ret2, this.pixel) ? "yes" : "no", "pixel3":this.containsPixel(ret3, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + + +//------------------------------------------------------------------ +// +// SpriteBatchNodeOffsetAnchorScale +// +//------------------------------------------------------------------ +var SpriteBatchNodeOffsetAnchorScale = SpriteTestDemo.extend({ + + _title:"SpriteBatchNode offset + anchor + scale", + + ctor:function () { + this._super(); + //----start9----ctor + var batch = new cc.SpriteBatchNode(s_grossini); + this.addChild(batch); + + spriteFrameCache.addSpriteFrames(s_grossiniPlist); + spriteFrameCache.addSpriteFrames(s_grossini_grayPlist, s_grossini_gray); + + for (var i = 0; i < 3; i++) { + // + // Animation using Sprite BatchNode + // + var sprite = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_01.png")); + sprite.x = winSize.width / 4 * (i + 1); + sprite.y = winSize.height / 2; + + var point = new cc.Sprite(s_pathR1); + point.scale = 0.25; + point.x = sprite.x; + point.y = sprite.y; + this.addChild(point, 200); + + switch (i) { + case 0: + sprite.anchorX = 0; + sprite.anchorY = 0; + break; + case 1: + sprite.anchorX = 0.5; + sprite.anchorY = 0.5; + break; + case 2: + sprite.anchorX = 1; + sprite.anchorY = 1; + break; + } + + point.x = sprite.x; + point.y = sprite.y; + + var animFrames = []; + var str = ""; + for (var k = 1; k <= 14; k++) { + str = "grossini_dance_" + (k < 10 ? ("0" + k) : k) + ".png"; + var frame = spriteFrameCache.getSpriteFrame(str); + animFrames.push(frame); + } + + var animation = new cc.Animation(animFrames, 0.3); + sprite.runAction(cc.animate(animation).repeatForever()); + + var scale = cc.scaleBy(2, 2); + var scale_back = scale.reverse(); + var seq_scale = cc.sequence(scale, scale_back); + sprite.runAction(seq_scale.repeatForever()); + + batch.addChild(sprite, i); + } + //----end9---- + }, + onExit:function () { + //----start9----onExit + this._super(); + spriteFrameCache.removeSpriteFramesFromFile(s_grossiniPlist); + spriteFrameCache.removeSpriteFramesFromFile(s_grossini_grayPlist); + //----end9---- + }, + // + // Automation + // + testDuration:2.1, + pixel:{"0":153, "1":0, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 4 * 3 - 85, winSize.height / 2 - 106, 5, 5); + var ret2 = this.readPixels(winSize.width / 4 * 2, winSize.height / 2 + 13, 5, 5); + var ret3 = this.readPixels(winSize.width / 4 + 82, winSize.height / 2 + 133, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel) ? "yes" : "no", "pixel2":this.containsPixel(ret2, this.pixel) ? "yes" : "no", "pixel3":this.containsPixel(ret3, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +// +// SpriteOffsetAnchorSkew +// +var SpriteOffsetAnchorSkew = SpriteTestDemo.extend({ + + _title:"Sprite offset + anchor + skew", + + ctor:function () { + //----start41----ctor + this._super(); + spriteFrameCache.addSpriteFrames(s_grossiniPlist); + spriteFrameCache.addSpriteFrames(s_grossini_grayPlist, s_grossini_gray); + + for (var i = 0; i < 3; i++) { + // + // Animation using Sprite batch + // + var sprite = new cc.Sprite("#grossini_dance_01.png"); + sprite.x = winSize.width / 4 * (i + 1); + sprite.y = winSize.height / 2; + + var point = new cc.Sprite(s_pathR1); + point.scale = 0.25; + point.x = sprite.x; + point.y = sprite.y; + this.addChild(point, 1); + + switch (i) { + case 0: + sprite.anchorX = 0; + sprite.anchorY = 0; + break; + case 1: + sprite.anchorX = 0.5; + sprite.anchorY = 0.5; + break; + case 2: + sprite.anchorX = 1; + sprite.anchorY = 1; + break; + } + + point.x = sprite.x; + point.y = sprite.y; + + var animFrames = []; + var tmp = ""; + for (var j = 1; j <= 14; j++) { + tmp = "grossini_dance_" + (j < 10 ? ("0" + j) : j) + ".png"; + var frame = spriteFrameCache.getSpriteFrame(tmp); + animFrames.push(frame); + } + + var animation = new cc.Animation(animFrames, 0.3); + sprite.runAction(cc.animate(animation).repeatForever()); + + var skewX = cc.skewBy(2, 45, 0); + var skewX_back = skewX.reverse(); + var skewY = cc.skewBy(2, 0, 45); + var skewY_back = skewY.reverse(); + + var seq_skew = cc.sequence(skewX, skewX_back, skewY, skewY_back); + sprite.runAction(seq_skew.repeatForever()); + + this.addChild(sprite, 0); + } + //----end41---- + }, + // + // Automation + // + testDuration:2, + pixel:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 4 + 142, winSize.height / 2 + 98, 5, 5); + var ret2 = this.readPixels(winSize.width / 4 * 2 + 50, winSize.height / 2 + 43, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +// +// SpriteBatchNodeOffsetAnchorSkew +// +var SpriteBatchNodeOffsetAnchorSkew = SpriteTestDemo.extend({ + + _title:"SpriteBatchNode offset + anchor + skew", + + ctor:function () { + //----start42----ctor + this._super(); + spriteFrameCache.addSpriteFrames(s_grossiniPlist); + spriteFrameCache.addSpriteFrames(s_grossini_grayPlist, s_grossini_gray); + + var spritebatch = new cc.SpriteBatchNode(s_grossini); + this.addChild(spritebatch); + + for (var i = 0; i < 3; i++) { + // + // Animation using Sprite batch + // + var sprite = new cc.Sprite("#grossini_dance_01.png"); + sprite.x = winSize.width / 4 * (i + 1); + sprite.y = winSize.height / 2; + + var point = new cc.Sprite(s_pathR1); + point.scale = 0.25; + point.x = sprite.x; + point.y = sprite.y; + this.addChild(point, 200); + + switch (i) { + case 0: + sprite.anchorX = 0; + sprite.anchorY = 0; + break; + case 1: + sprite.anchorX = 0.5; + sprite.anchorY = 0.5; + break; + case 2: + sprite.anchorX = 1; + sprite.anchorY = 1; + break; + } + + point.x = sprite.x; + point.y = sprite.y; + + var animFrames = []; + var tmp = ""; + for (var j = 1; j <= 14; j++) { + tmp = "grossini_dance_" + (j < 10 ? ("0" + j) : j) + ".png"; + var frame = spriteFrameCache.getSpriteFrame(tmp); + animFrames.push(frame); + } + + var animation = new cc.Animation(animFrames, 0.3); + sprite.runAction(cc.animate(animation).repeatForever()); + + animFrames = null; + + var skewX = cc.skewBy(2, 45, 0); + var skewX_back = skewX.reverse(); + var skewY = cc.skewBy(2, 0, 45); + var skewY_back = skewY.reverse(); + + var seq_skew = cc.sequence(skewX, skewX_back, skewY, skewY_back); + sprite.runAction(seq_skew.repeatForever()); + + spritebatch.addChild(sprite, i); + } + //----end42---- + }, + // + // Automation + // + testDuration:2, + pixel:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 4 + 142, winSize.height / 2 + 98, 5, 5); + var ret2 = this.readPixels(winSize.width / 4 * 2 + 50, winSize.height / 2 + 43, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +// +// SpriteOffsetAnchorSkewScale +// +var SpriteOffsetAnchorSkewScale = SpriteTestDemo.extend({ + + _title:"Sprite anchor + skew + scale", + ctor:function () { + //----start43----ctor + this._super(); + spriteFrameCache.addSpriteFrames(s_grossiniPlist); + spriteFrameCache.addSpriteFrames(s_grossini_grayPlist, s_grossini_gray); + + for (var i = 0; i < 3; i++) { + // + // Animation using Sprite batch + // + var sprite = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_01.png")); + sprite.x = winSize.width / 4 * (i + 1); + sprite.y = winSize.height / 2; + + var point = new cc.Sprite(s_pathR1); + point.scale = 0.25; + point.x = sprite.x; + point.y = sprite.y; + this.addChild(point, 1); + + switch (i) { + case 0: + sprite.anchorX = 0; + sprite.anchorY = 0; + break; + case 1: + sprite.anchorX = 0.5; + sprite.anchorY = 0.5; + break; + case 2: + sprite.anchorX = 1; + sprite.anchorY = 1; + break; + } + + point.x = sprite.x; + point.y = sprite.y; + + var animFrames = []; + var tmp = ""; + for (var j = 1; j <= 14; j++) { + tmp = "grossini_dance_" + (j < 10 ? ("0" + j) : j) + ".png"; + var frame = spriteFrameCache.getSpriteFrame(tmp); + animFrames.push(frame); + } + + var animation = new cc.Animation(animFrames, 0.3); + sprite.runAction(cc.animate(animation).repeatForever()); + + animFrames = null; + + // Skew + var skewX = cc.skewBy(2, 45, 0); + var skewX_back = skewX.reverse(); + var skewY = cc.skewBy(2, 0, 45); + var skewY_back = skewY.reverse(); + + var seq_skew = cc.sequence(skewX, skewX_back, skewY, skewY_back); + sprite.runAction(seq_skew.repeatForever()); + + // Scale + var scale = cc.scaleBy(2, 2); + var scale_back = scale.reverse(); + var seq_scale = cc.sequence(scale, scale_back); + sprite.runAction(seq_scale.repeatForever()); + + this.addChild(sprite, 0); + } + //----end43---- + }, + // + // Automation + // + testDuration:2, + pixel:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 4 + 121, winSize.height / 2 + 99, 5, 5); + var ret2 = this.readPixels(winSize.width / 4 * 2 - 83, winSize.height / 2 - 21, 5, 5); + var ret3 = this.readPixels(winSize.width / 4 * 3 - 286, winSize.height / 2 - 140, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel) ? "yes" : "no", + "pixel3":this.containsPixel(ret3, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +// +// SpriteBatchNodeOffsetAnchorSkewScale +// +var SpriteBatchNodeOffsetAnchorSkewScale = SpriteTestDemo.extend({ + + _title:"SpriteBatchNode anchor + skew + scale", + + ctor:function () { + //----start44----ctor + this._super(); + + spriteFrameCache.addSpriteFrames(s_grossiniPlist); + spriteFrameCache.addSpriteFrames(s_grossini_grayPlist, s_grossini_gray); + + var spritebatch = new cc.SpriteBatchNode(s_grossini); + this.addChild(spritebatch); + + for (var i = 0; i < 3; i++) { + // + // Animation using Sprite batch + // + var sprite = new cc.Sprite("#grossini_dance_01.png"); + sprite.x = winSize.width / 4 * (i + 1); + sprite.y = winSize.height / 2; + + var point = new cc.Sprite(s_pathR1); + point.scale = 0.25; + point.x = sprite.x; + point.y = sprite.y; + this.addChild(point, 200); + + switch (i) { + case 0: + sprite.anchorX = 0; + sprite.anchorY = 0; + break; + case 1: + sprite.anchorX = 0.5; + sprite.anchorY = 0.5; + break; + case 2: + sprite.anchorX = 1; + sprite.anchorY = 1; + break; + } + + point.x = sprite.x; + point.y = sprite.y; + + var animFrames = []; + var tmp = ""; + for (var j = 1; j <= 14; j++) { + tmp = "grossini_dance_" + (j < 10 ? ("0" + j) : j) + ".png"; + var frame = spriteFrameCache.getSpriteFrame(tmp); + animFrames.push(frame); + } + + var animation = new cc.Animation(animFrames, 0.3); + sprite.runAction(cc.animate(animation).repeatForever()); + + animFrames = null; + + // skew + var skewX = cc.skewBy(2, 45, 0); + var skewX_back = skewX.reverse(); + var skewY = cc.skewBy(2, 0, 45); + var skewY_back = skewY.reverse(); + + var seq_skew = cc.sequence(skewX, skewX_back, skewY, skewY_back); + sprite.runAction(seq_skew.repeatForever()); + + // scale + var scale = cc.scaleBy(2, 2); + var scale_back = scale.reverse(); + var seq_scale = cc.sequence(scale, scale_back); + sprite.runAction(seq_scale.repeatForever()); + + spritebatch.addChild(sprite, i); + } + //----end44---- + }, + // + // Automation + // + testDuration:2, + pixel:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 4 + 121, winSize.height / 2 + 99, 5, 5); + var ret2 = this.readPixels(winSize.width / 4 * 2 - 83, winSize.height / 2 - 21, 5, 5); + var ret3 = this.readPixels(winSize.width / 4 * 3 - 286, winSize.height / 2 - 140, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel) ? "yes" : "no", + "pixel3":this.containsPixel(ret3, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +// +// SpriteOffsetAnchorFlip +// +var SpriteOffsetAnchorFlip = SpriteTestDemo.extend({ + + _title:"Sprite offset + anchor + flip", + _subtitle:"issue #1078", + + ctor:function () { + //----start45----ctor + this._super(); + spriteFrameCache.addSpriteFrames(s_grossiniPlist); + spriteFrameCache.addSpriteFrames(s_grossini_grayPlist, s_grossini_gray); + + for (var i = 0; i < 3; i++) { + // + // Animation using Sprite batch + // + var sprite = new cc.Sprite("#grossini_dance_01.png"); + sprite.x = winSize.width / 4 * (i + 1); + sprite.y = winSize.height / 2; + + var point = new cc.Sprite(s_pathR1); + point.scale = 0.25; + point.x = sprite.x; + point.y = sprite.y; + this.addChild(point, 1); + + switch (i) { + case 0: + sprite.anchorX = 0; + sprite.anchorY = 0; + break; + case 1: + sprite.anchorX = 0.5; + sprite.anchorY = 0.5; + break; + case 2: + sprite.anchorX = 1; + sprite.anchorY = 1; + break; + } + + point.x = sprite.x; + point.y = sprite.y; + + var animFrames = []; + var tmp = ""; + for (var j = 1; j <= 14; j++) { + tmp = "grossini_dance_" + (j < 10 ? ("0" + j) : j) + ".png"; + var frame = spriteFrameCache.getSpriteFrame(tmp); + animFrames.push(frame); + } + + var animation = new cc.Animation(animFrames, 0.3); + sprite.runAction(cc.animate(animation).repeatForever()); + + animFrames = null; + + var flip = cc.flipY(true); + var flip_back = cc.flipY(false); + var delay = cc.delayTime(1); + var delay1 = cc.delayTime(1); + var seq = cc.sequence(delay, flip, delay1, flip_back); + sprite.runAction(seq.repeatForever()); + + this.addChild(sprite, 0); + } + //----end45---- + }, + // + // Automation + // + testDuration:1.5, + pixel:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 4 + 40, winSize.height / 2 + 18, 5, 5); + var ret2 = this.readPixels(winSize.width / 4 * 2, winSize.height / 2 - 44, 5, 5); + var ret3 = this.readPixels(winSize.width / 4 * 3 - 45, winSize.height / 2 - 105, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel) ? "yes" : "no", "pixel2":this.containsPixel(ret2, this.pixel) ? "yes" : "no", "pixel3":this.containsPixel(ret3, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +// +// SpriteBatchNodeOffsetAnchorFlip +// +var SpriteBatchNodeOffsetAnchorFlip = SpriteTestDemo.extend({ + + _title:"SpriteBatchNode offset + anchor + flip", + _subtitle:"issue #1078", + + ctor:function () { + //----start46----ctor + this._super(); + spriteFrameCache.addSpriteFrames(s_grossiniPlist); + spriteFrameCache.addSpriteFrames(s_grossini_grayPlist, s_grossini_gray); + + var spritebatch = new cc.SpriteBatchNode(s_grossini); + this.addChild(spritebatch); + + for (var i = 0; i < 3; i++) { + // + // Animation using Sprite batch + // + var sprite = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_01.png")); + sprite.x = winSize.width / 4 * (i + 1); + sprite.y = winSize.height / 2; + + var point = new cc.Sprite(s_pathR1); + point.scale = 0.25; + point.x = sprite.x; + point.y = sprite.y; + this.addChild(point, 200); + + switch (i) { + case 0: + sprite.anchorX = 0; + sprite.anchorY = 0; + break; + case 1: + sprite.anchorX = 0.5; + sprite.anchorY = 0.5; + break; + case 2: + sprite.anchorX = 1; + sprite.anchorY = 1; + break; + } + + point.x = sprite.x; + point.y = sprite.y; + + var animFrames = []; + var tmp = ""; + for (var j = 1; j <= 14; j++) { + tmp = "grossini_dance_" + (j < 10 ? ("0" + j) : j) + ".png"; + var frame = spriteFrameCache.getSpriteFrame(tmp); + animFrames.push(frame); + } + + var animation = new cc.Animation(animFrames, 0.3); + sprite.runAction(cc.animate(animation).repeatForever()); + + animFrames = null; + + var flip = cc.flipY(true); + var flip_back = cc.flipY(false); + var delay = cc.delayTime(1); + var seq = cc.sequence(delay, flip, delay.clone(), flip_back); + sprite.runAction(seq.repeatForever()); + + spritebatch.addChild(sprite, i); + } + //----end46---- + }, + // + // Automation + // + testDuration:1.5, + pixel:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 4 + 40, winSize.height / 2 + 18, 5, 5); + var ret2 = this.readPixels(winSize.width / 4 * 2, winSize.height / 2 - 44, 5, 5); + var ret3 = this.readPixels(winSize.width / 4 * 3 - 45, winSize.height / 2 - 105, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel) ? "yes" : "no", "pixel2":this.containsPixel(ret2, this.pixel) ? "yes" : "no", "pixel3":this.containsPixel(ret3, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteAnimationSplit +// +//------------------------------------------------------------------ +var SpriteAnimationSplit = SpriteTestDemo.extend({ + + _title:"Sprite: Animation + flip", + ctor:function () { + //----start10----ctor + this._super(); + var texture = cc.textureCache.addImage(s_dragon_animation); + + // manually add frames to the frame cache + var frame0 = new cc.SpriteFrame(texture, cc.rect(132 * 0, 132 * 0, 132, 132)); + var frame1 = new cc.SpriteFrame(texture, cc.rect(132 * 1, 132 * 0, 132, 132)); + var frame2 = new cc.SpriteFrame(texture, cc.rect(132 * 2, 132 * 0, 132, 132)); + var frame3 = new cc.SpriteFrame(texture, cc.rect(132 * 3, 132 * 0, 132, 132)); + var frame4 = new cc.SpriteFrame(texture, cc.rect(132 * 0, 132 * 1, 132, 132)); + var frame5 = new cc.SpriteFrame(texture, cc.rect(132 * 1, 132 * 1, 132, 132)); + + // + // Animation using Sprite BatchNode + // + var sprite = new cc.Sprite(frame0); + sprite.x = winSize.width / 2; + sprite.y = winSize.height / 2; + this.addChild(sprite); + + var animFrames = []; + animFrames.push(frame0); + animFrames.push(frame1); + animFrames.push(frame2); + animFrames.push(frame3); + animFrames.push(frame4); + animFrames.push(frame5); + + var animation = new cc.Animation(animFrames, 0.2); + var animate = cc.animate(animation); + var delay = cc.delayTime(0.5); + var seq = cc.sequence(animate, + cc.flipX(true), + animate.clone(), + delay, + cc.flipX(false)); + + sprite.runAction(seq.repeatForever()); + //----end10---- + }, + onExit:function () { + this._super(); + }, + // + // Automation + // + testDuration:2.8, + pixel1:{"0":208, "1":208, "2":208, "3":255}, + pixel2:{"0":0, "1":0, "2":0, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 2 + 52, winSize.height / 2 - 29, 5, 5); + var ret2 = this.readPixels(winSize.width / 2, winSize.height / 2 - 22, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1, true, 3) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteHybrid +// +//------------------------------------------------------------------ +var SpriteHybrid = SpriteTestDemo.extend({ + _usingSpriteBatchNode:false, + _title:"Hybrid.Sprite* sprite Test", + + ctor:function () { + //----start28----ctor + this._super(); + // parents + var parent1 = new cc.Node(); + var parent2 = new cc.SpriteBatchNode(s_grossini, 50); + + this.addChild(parent1, 0, TAG_NODE); + this.addChild(parent2, 0, TAG_SPRITE_BATCH_NODE); + + // IMPORTANT: + // The sprite frames will be cached AND RETAINED, and they won't be released unless you call + spriteFrameCache.addSpriteFrames(s_grossiniPlist); + + // create 250 sprites + // only show 80% of them + for (var i = 1; i <= 250; i++) { + var spriteIdx = Math.round(Math.random() * 14); + if (spriteIdx === 0) + spriteIdx = 1; + var str = "grossini_dance_" + (spriteIdx < 10 ? ("0" + spriteIdx) : spriteIdx) + ".png"; + + var frame = spriteFrameCache.getSpriteFrame(str); + var sprite = new cc.Sprite(frame); + parent1.addChild(sprite, i, i); + + var x = -1000; + var y = -1000; + if (Math.random() < 0.2) { + x = Math.random() * winSize.width; + y = Math.random() * winSize.height; + } + sprite.x = x; + sprite.y = y; + + var action = cc.rotateBy(4, 360); + sprite.runAction(action.repeatForever()); + } + + this._usingSpriteBatchNode = false; + + this.schedule(this.reparentSprite, 2); + //----end28---- + }, + onExit:function () { + //----start28----onExit + this._super(); + spriteFrameCache.removeSpriteFramesFromFile(s_grossiniPlist); + //----end28---- + }, + reparentSprite:function () { + //----start28----reparentSprite + var p1 = this.getChildByTag(TAG_NODE); + var p2 = this.getChildByTag(TAG_SPRITE_BATCH_NODE); + + var retArray = []; + var node; + + if (this._usingSpriteBatchNode) { + var tempNode = p2; + p2 = p1; + p1 = tempNode; + } + ////----UXLog("New parent is: %x", p2); + + var children = p1.children; + for (var i = 0; i < children.length; i++) { + node = children[i]; + if (!node) + break; + + retArray.push(node); + } + + p1.removeAllChildren(false); + for (i = 0; i < retArray.length; i++) { + node = retArray[i]; + if (!node) + break; + + p2.addChild(node, i, i); + } + + this._usingSpriteBatchNode = !this._usingSpriteBatchNode; + //----end28---- + }, + // + // Automation + // + testDuration:2.5, + pixel:{"0":51, "1":0, "2":51, "3":255}, + firstPixel1:false, + firstPixel2:false, + setupAutomation:function () { + this.scheduleOnce(this.addTestSprite, 1); + this.scheduleOnce(this.checkFirstPixel, 1.5); + }, + addTestSprite:function () { + var p = this.getChildByTag(TAG_NODE); + var frame = spriteFrameCache.getSpriteFrame("grossini_dance_01.png"); + var sprite1 = new cc.Sprite(frame); + sprite1.retain(); + p.addChild(sprite1, 1000); + sprite1.x = winSize.width / 4; + sprite1.y = winSize.height / 2; + var sprite2 = new cc.Sprite(frame); + sprite2.retain(); + p.addChild(sprite2, 1000); + sprite2.x = winSize.width / 2; + sprite2.y = winSize.height / 2; + }, + checkFirstPixel:function () { + var ret1 = this.readPixels(winSize.width / 4, winSize.height / 2, 5, 5); + var ret2 = this.readPixels(winSize.width / 2, winSize.height / 2, 5, 5); + this.firstPixel1 = this.containsPixel(ret1, this.pixel); + this.firstPixel2 = this.containsPixel(ret2, this.pixel); + }, + getExpectedResult:function () { + var ret = {"firstPixel1":true, "firstPixel2":true, "secondPixel1":true, "pixel2":true}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var pixel1 = this.readPixels(winSize.width / 4, winSize.height / 2, 5, 5); + var pixel2 = this.readPixels(winSize.width / 2, winSize.height / 2, 5, 5); + var secondPixel1 = this.containsPixel(pixel1, this.pixel); + var secondPixel2 = this.containsPixel(pixel2, this.pixel); + var ret = {"firstPixel1":this.firstPixel1, "firstPixel2":this.firstPixel2, "secondPixel1":secondPixel1, "pixel2":secondPixel2}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteBatchNodeChildren +// +//------------------------------------------------------------------ +var SpriteBatchNodeChildren = SpriteTestDemo.extend({ + _title:"SpriteBatchNode Grand Children", + + ctor:function () { + //----start29----ctor + this._super(); + // parents + var batch = new cc.SpriteBatchNode(s_grossini, 50); + this.addChild(batch, 0, TAG_SPRITE_BATCH_NODE); + + spriteFrameCache.addSpriteFrames(s_grossiniPlist); + + var sprite1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_01.png")); + sprite1.x = winSize.width / 3; + sprite1.y = winSize.height / 2; + + var sprite2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_02.png")); + sprite2.x = 50; + sprite2.y = 50; + + var sprite3 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_03.png")); + sprite3.x = -50; + sprite3.y = -50; + + batch.addChild(sprite1); + sprite1.addChild(sprite2); + sprite1.addChild(sprite3); + + // BEGIN NEW CODE + var animFrames = []; + var str = ""; + for (var i = 1; i < 15; i++) { + str = "grossini_dance_" + (i < 10 ? ("0" + i) : i) + ".png"; + var frame = spriteFrameCache.getSpriteFrame(str); + animFrames.push(frame); + } + + var animation = new cc.Animation(animFrames, 0.2); + sprite1.runAction(cc.animate(animation).repeatForever()); + // END NEW CODE + + var action = cc.moveBy(2, cc.p(200, 0)); + var action_back = action.reverse(); + var action_rot = cc.rotateBy(2, 360); + var action_s = cc.scaleBy(2, 2); + var action_s_back = action_s.reverse(); + + var seq2 = action_rot.reverse(); + sprite2.runAction(seq2.repeatForever()); + + sprite1.runAction(action_rot.repeatForever()); + sprite1.runAction(cc.sequence(action, action_back).repeatForever()); + sprite1.runAction(cc.sequence(action_s, action_s_back).repeatForever()); + //----end29---- + }, + // + // Automation + // + testDuration:0.5, + pixel:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 3 - 47, winSize.height / 2 + 107, 5, 5); + var ret2 = this.readPixels(winSize.width / 3 + 95, winSize.height / 2 - 5, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel) ? "yes" : "no", "pixel2":this.containsPixel(ret2, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteBatchNodeChildrenZ +// +//------------------------------------------------------------------ +var SpriteBatchNodeChildrenZ = SpriteTestDemo.extend({ + + _title:"SpriteBatchNode Children Z", + + ctor:function () { + //----start30----ctor + this._super(); + // parents + var batch; + var sprite1, sprite2, sprite3; + spriteFrameCache.addSpriteFrames(s_grossiniPlist); + + // test 1 + batch = new cc.SpriteBatchNode(s_grossini, 50); + this.addChild(batch, 0, TAG_SPRITE_BATCH_NODE); + + sprite1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_01.png")); + sprite1.x = winSize.width / 3; + sprite1.y = winSize.height / 2; + + sprite2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_02.png")); + sprite2.x = 20; + sprite2.y = 30; + + sprite3 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_03.png")); + sprite3.x = -20; + sprite3.y = 30; + + batch.addChild(sprite1); + sprite1.addChild(sprite2, 2); + sprite1.addChild(sprite3, -2); + + // test 2 + batch = new cc.SpriteBatchNode(s_grossini, 50); + this.addChild(batch, 0, TAG_SPRITE_BATCH_NODE); + + sprite1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_01.png")); + sprite1.x = 2 * winSize.width / 3; + sprite1.y = winSize.height / 2; + + sprite2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_02.png")); + sprite2.x = 20; + sprite2.y = 30; + + sprite3 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_03.png")); + sprite3.x = -20; + sprite3.y = 30; + + batch.addChild(sprite1); + sprite1.addChild(sprite2, -2); + sprite1.addChild(sprite3, 2); + + // test 3 + batch = new cc.SpriteBatchNode(s_grossini, 50); + this.addChild(batch, 0, TAG_SPRITE_BATCH_NODE); + + sprite1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_01.png")); + sprite1.x = winSize.width / 2 - 90; + sprite1.y = winSize.height / 4; + + sprite2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_02.png")); + sprite2.x = winSize.width / 2 - 60; + sprite2.y = winSize.height / 4; + + sprite3 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_03.png")); + sprite3.x = winSize.width / 2 - 30; + sprite3.y = winSize.height / 4; + + batch.addChild(sprite1, 10); + batch.addChild(sprite2, -10); + batch.addChild(sprite3, -5); + + // test 4 + batch = new cc.SpriteBatchNode(s_grossini, 50); + this.addChild(batch, 0, TAG_SPRITE_BATCH_NODE); + + sprite1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_01.png")); + sprite1.x = winSize.width / 2 + 30; + sprite1.y = winSize.height / 4; + + sprite2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_02.png")); + sprite2.x = winSize.width / 2 + 60; + sprite2.y = winSize.height / 4; + + sprite3 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_03.png")); + sprite3.x = winSize.width / 2 + 90; + sprite3.y = winSize.height / 4; + + batch.addChild(sprite1, -10); + batch.addChild(sprite2, -5); + batch.addChild(sprite3, -2); + //----end30---- + }, + // + // Automation + // + testDuration:1, + pixel1:{"0":51, "1":0, "2":51, "3":255}, + pixel2:{"0":51, "1":0, "2":51, "3":255}, + pixel3:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(2 * winSize.width / 3 - 20, winSize.height / 2, 5, 5); + var ret2 = this.readPixels(winSize.width / 3 - 20, winSize.height / 2 + 115, 5, 5); + var ret3 = this.readPixels(winSize.width / 2 + 30, winSize.height / 4 - 10, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1) ? "yes" : "no", + "pixel2":!this.containsPixel(ret2, this.pixel2) ? "yes" : "no", + "pixel3":this.containsPixel(ret3, this.pixel3) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteChildrenVisibility +// +//------------------------------------------------------------------ +var SpriteChildrenVisibility = SpriteTestDemo.extend({ + _title:"Sprite & SpriteBatchNode Visibility", + + ctor:function () { + //----start31----ctor + this._super(); + + spriteFrameCache.addSpriteFrames(s_grossiniPlist); + // + // SpriteBatchNode + // + // parents + var aParent = new cc.SpriteBatchNode(s_grossini, 50); + aParent.x = winSize.width / 3; + aParent.y = winSize.height / 2; + this.addChild(aParent, 0); + + var sprite1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_01.png")); + sprite1.x = 0; + sprite1.y = 0; + + var sprite2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_02.png")); + sprite2.x = 20; + sprite2.y = 30; + + var sprite3 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_03.png")); + sprite3.x = -20; + sprite3.y = 30; + + aParent.addChild(sprite1); + sprite1.addChild(sprite2, -2); + sprite1.addChild(sprite3, 2); + + sprite1.runAction(cc.blink(5, 10)); + + // + // Sprite + // + aParent = new cc.Node(); + aParent.x = 2 * winSize.width / 3; + aParent.y = winSize.height / 2; + this.addChild(aParent, 0); + + sprite1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_01.png")); + sprite1.x = 0; + sprite1.y = 0; + + sprite2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_02.png")); + sprite2.x = 20; + sprite2.y = 30; + + sprite3 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_03.png")); + sprite3.x = -20; + sprite3.y = 30; + + aParent.addChild(sprite1); + sprite1.addChild(sprite2, -2); + sprite1.addChild(sprite3, 2); + + sprite1.runAction(cc.blink(5, 10)); + //----end31---- + }, + // + // Automation + // + testDuration:1.7, + pixel1:{"0":0, "1":0, "2":0, "3":255}, + pixel2:{"0":255, "1":204, "2":153, "3":255}, + visible1:null, + visible2:null, + setupAutomation:function () { + this.scheduleOnce(this.getSpriteVisible, 1.2); + }, + getSpriteVisible:function () { + var ret1 = this.readPixels(winSize.width / 3, winSize.height / 2 + 38, 5, 5); + var ret2 = this.readPixels(2 * winSize.width / 3, winSize.height / 2 + 38, 5, 5); + this.visible1 = this.containsPixel(ret1, this.pixel1) ? "true" : "false"; + this.visible2 = this.containsPixel(ret2, this.pixel1) ? "true" : "false"; + }, + getExpectedResult:function () { + var ret = {"visible1":"true", "visible2":"true", "visible3":"false", "visible4":"false"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 3, winSize.height / 2 + 38, 5, 5); + var ret2 = this.readPixels(2 * winSize.width / 3, winSize.height / 2 + 38, 5, 5); + this.visible3 = this.containsPixel(ret1, this.pixel2) ? "true" : "false"; + this.visible4 = this.containsPixel(ret2, this.pixel2) ? "true" : "false"; + var ret = {"visible1":this.visible1, "visible2":this.visible2, "visible3":this.visible3, "visible4":this.visible4}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteChildrenVisibilityIssue665 +// +//------------------------------------------------------------------ +var SpriteChildrenVisibilityIssue665 = SpriteTestDemo.extend({ + + _title:"Sprite & SpriteBatchNode Visibility", + _subtitle:"No sprites should be visible", + + ctor:function () { + //----start32----ctor + this._super(); + spriteFrameCache.addSpriteFrames(s_grossiniPlist); + // + // SpriteBatchNode + // + // parents + var aParent = new cc.SpriteBatchNode(s_grossini, 50); + aParent.x = winSize.width / 3; + aParent.y = winSize.height / 2; + this.addChild(aParent, 0); + + var sprite1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_01.png")); + sprite1.x = 0; + sprite1.y = 0; + + var sprite2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_02.png")); + sprite2.x = 20; + sprite2.y = 30; + + var sprite3 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_03.png")); + sprite3.x = -20; + sprite3.y = 30; + + // test issue #665 + sprite1.visible = false; + + aParent.addChild(sprite1); + sprite1.addChild(sprite2, -2); + sprite1.addChild(sprite3, 2); + + // + // Sprite + // + aParent = new cc.Node(); + aParent.x = 2 * winSize.width / 3; + aParent.y = winSize.height / 2; + this.addChild(aParent, 0); + + sprite1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_01.png")); + sprite1.x = 0; + sprite1.y = 0; + + sprite2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_02.png")); + sprite2.x = 20; + sprite2.y = 30; + + sprite3 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_03.png")); + sprite3.x = -20; + sprite3.y = 30; + + // test issue #665 + sprite1.visible = false; + + aParent.addChild(sprite1); + sprite1.addChild(sprite2, -2); + sprite1.addChild(sprite3, 2); + //----end32---- + }, + // + // Automation + // + testDuration:1, + pixel:{"0":0, "1":0, "2":0, "3":255}, + getExpectedResult:function () { + var ret = {"visible1":"false", "visible2":"false"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 3, winSize.height / 2 + 38, 5, 5); + var ret2 = this.readPixels(2 * winSize.width / 3, winSize.height / 2 + 38, 5, 5); + var ret = {"visible1":this.containsPixel(ret1, this.pixel) ? "false" : "true", "visible2":this.containsPixel(ret2, this.pixel) ? "false" : "true"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteChildrenAnchorPoint +// +//------------------------------------------------------------------ +var SpriteChildrenAnchorPoint = SpriteTestDemo.extend({ + + _title:"Sprite: children + anchor", + + ctor:function () { + //----start33----ctor + this._super(); + spriteFrameCache.addSpriteFrames(s_grossiniPlist); + + var aParent = new cc.Node(); + this.addChild(aParent, 0); + + // anchor (0,0) + var sprite1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_08.png")); + sprite1.x = winSize.width / 4; + sprite1.y = winSize.height / 2; + sprite1.anchorX = 0; + sprite1.anchorY = 0; + + var sprite2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_02.png")); + sprite2.x = 20; + sprite2.y = 30; + + var sprite3 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_03.png")); + sprite3.x = -20; + sprite3.y = 30; + + var sprite4 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_04.png")); + sprite4.x = 0; + sprite4.y = 0; + sprite4.scale = 0.5; + + aParent.addChild(sprite1); + sprite1.addChild(sprite2, -2); + sprite1.addChild(sprite3, -2); + sprite1.addChild(sprite4, 3); + + var point = new cc.Sprite(s_pathR1); + point.scale = 0.25; + point.x = sprite1.x; + point.y = sprite1.y; + this.addChild(point, 10); + + // anchor (0.5, 0.5) + sprite1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_08.png")); + sprite1.x = winSize.width / 2; + sprite1.y = winSize.height / 2; + sprite1.anchorX = 0.5; + sprite1.anchorY = 0.5; + + sprite2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_02.png")); + sprite2.x = 20; + sprite2.y = 30; + + sprite3 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_03.png")); + sprite3.x = -20; + sprite3.y = 30; + + sprite4 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_04.png")); + sprite4.x = 0; + sprite4.y = 0; + sprite4.scale = 0.5; + + aParent.addChild(sprite1); + sprite1.addChild(sprite2, -2); + sprite1.addChild(sprite3, -2); + sprite1.addChild(sprite4, 3); + + point = new cc.Sprite(s_pathR1); + point.scale = 0.25; + point.x = sprite1.x; + point.y = sprite1.y; + this.addChild(point, 10); + + // anchor (1,1) + sprite1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_08.png")); + sprite1.x = winSize.width / 2 + winSize.width / 4; + sprite1.y = winSize.height / 2; + sprite1.anchorX = 1; + sprite1.anchorY = 1; + + sprite2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_02.png")); + sprite2.x = 20; + sprite2.y = 30; + + sprite3 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_03.png")); + sprite3.x = -20; + sprite3.y = 30; + + sprite4 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_04.png")); + sprite4.x = 0; + sprite4.y = 0; + sprite4.scale = 0.5; + + aParent.addChild(sprite1); + sprite1.addChild(sprite2, -2); + sprite1.addChild(sprite3, -2); + sprite1.addChild(sprite4, 3); + + point = new cc.Sprite(s_pathR1); + point.scale = 0.25; + point.x = sprite1.x; + point.y = sprite1.y; + this.addChild(point, 10); + //----end33---- + }, + // + // Automation + // + testDuration:1, + pixel:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(3 * winSize.width / 4 - 87, winSize.height / 2 - 99, 5, 5); + var ret2 = this.readPixels(2 * winSize.width / 4 - 59, winSize.height / 2 - 66, 5, 5); + var ret3 = this.readPixels(winSize.width / 4 - 15, winSize.height / 2 - 6, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel) ? "yes" : "no", "pixel2":this.containsPixel(ret2, this.pixel) ? "yes" : "no", "pixel3":this.containsPixel(ret3, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteBatchNodeChildrenAnchorPoint +// +//------------------------------------------------------------------ +var SpriteBatchNodeChildrenAnchorPoint = SpriteTestDemo.extend({ + + _title:"SpriteBatchNode: children + anchor", + + ctor:function () { + //----start34----ctor + this._super(); + + spriteFrameCache.addSpriteFrames(s_grossiniPlist); + // + // SpriteBatchNode + // + // parents + var aParent = new cc.SpriteBatchNode(s_grossini, 50); + this.addChild(aParent, 0); + + // anchor (0,0) + var sprite1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_08.png")); + sprite1.x = winSize.width / 4; + sprite1.y = winSize.height / 2; + sprite1.anchorX = 0; + sprite1.anchorY = 0; + + var sprite2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_02.png")); + sprite2.x = 20; + sprite2.y = 30; + + var sprite3 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_03.png")); + sprite3.x = -20; + sprite3.y = 30; + + var sprite4 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_04.png")); + sprite4.x = 0; + sprite4.y = 0; + sprite4.scale = 0.5; + + aParent.addChild(sprite1); + sprite1.addChild(sprite2, -2); + sprite1.addChild(sprite3, -2); + sprite1.addChild(sprite4, 3); + + var point = new cc.Sprite(s_pathR1); + point.scale = 0.25; + point.x = sprite1.x; + point.y = sprite1.y; + this.addChild(point, 10); + + // anchor (0.5, 0.5) + sprite1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_08.png")); + sprite1.x = winSize.width / 2; + sprite1.y = winSize.height / 2; + sprite1.anchorX = 0.5; + sprite1.anchorY = 0.5; + + sprite2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_02.png")); + sprite2.x = 20; + sprite2.y = 30; + + sprite3 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_03.png")); + sprite3.x = -20; + sprite3.y = 30; + + sprite4 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_04.png")); + sprite4.x = 0; + sprite4.y = 0; + sprite4.scale = 0.5; + + aParent.addChild(sprite1); + sprite1.addChild(sprite2, -2); + sprite1.addChild(sprite3, -2); + sprite1.addChild(sprite4, 3); + + point = new cc.Sprite(s_pathR1); + point.scale = 0.25; + point.x = sprite1.x; + point.y = sprite1.y; + this.addChild(point, 10); + + + // anchor (1,1) + sprite1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_08.png")); + sprite1.x = winSize.width / 2 + winSize.width / 4; + sprite1.y = winSize.height / 2; + sprite1.anchorX = 1; + sprite1.anchorY = 1; + + sprite2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_02.png")); + sprite2.x = 20; + sprite2.y = 30; + + sprite3 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_03.png")); + sprite3.x = -20; + sprite3.y = 30; + + sprite4 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossini_dance_04.png")); + sprite4.x = 0; + sprite4.y = 0; + sprite4.scale = 0.5; + + aParent.addChild(sprite1); + sprite1.addChild(sprite2, -2); + sprite1.addChild(sprite3, -2); + sprite1.addChild(sprite4, 3); + + point = new cc.Sprite(s_pathR1); + point.scale = 0.25; + point.x = sprite1.x; + point.y = sprite1.y; + this.addChild(point, 10); + //----end34---- + }, + // + // Automation + // + testDuration:1, + pixel:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(3 * winSize.width / 4 - 87, winSize.height / 2 - 99, 5, 5); + var ret2 = this.readPixels(2 * winSize.width / 4 - 59, winSize.height / 2 - 66, 5, 5); + var ret3 = this.readPixels(winSize.width / 4 - 15, winSize.height / 2 - 6, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel) ? "yes" : "no", "pixel2":this.containsPixel(ret2, this.pixel) ? "yes" : "no", "pixel3":this.containsPixel(ret3, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteBatchNodeChildrenScale +// +//------------------------------------------------------------------ +var SpriteBatchNodeChildrenScale = SpriteTestDemo.extend({ + + _title:"Sprite/BatchNode + child + scale + rot", + + ctor:function () { + //----start35----ctor + this._super(); + spriteFrameCache.addSpriteFrames(s_grossini_familyPlist); + + var rot = cc.rotateBy(10, 360); + var seq = rot.repeatForever(); + + // + // Children + Scale using Sprite + // Test 1 + // + var aParent = new cc.Node(); + var sprite1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossinis_sister1.png")); + sprite1.x = winSize.width / 4; + sprite1.y = winSize.height / 4; + sprite1.scaleX = 0.5; + sprite1.scaleY = 2.0; + sprite1.runAction(seq); + + + var sprite2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossinis_sister2.png")); + sprite2.x = 50; + sprite2.y = 0; + + this.addChild(aParent); + aParent.addChild(sprite1); + sprite1.addChild(sprite2); + + rot = cc.rotateBy(10, 360); + seq = rot.repeatForever(); + // + // Children + Scale using SpriteBatchNode + // Test 2 + // + aParent = new cc.SpriteBatchNode(s_grossini_family); + sprite1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossinis_sister1.png")); + sprite1.x = 3 * winSize.width / 4; + sprite1.y = winSize.height / 4; + sprite1.scaleX = 0.5; + sprite1.scaleY = 2.0; + sprite1.runAction(seq); + + sprite2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossinis_sister2.png")); + sprite2.x = 50; + sprite2.y = 0; + + this.addChild(aParent); + aParent.addChild(sprite1); + sprite1.addChild(sprite2); + + rot = cc.rotateBy(10, 360); + seq = rot.repeatForever(); + // + // Children + Scale using Sprite + // Test 3 + // + aParent = new cc.Node(); + sprite1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossinis_sister1.png")); + sprite1.x = winSize.width / 4; + sprite1.y = 2 * winSize.height / 3; + sprite1.scaleX = 1.5; + sprite1.scaleY = 0.5; + sprite1.runAction(seq); + + sprite2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossinis_sister2.png")); + sprite2.x = 50; + sprite2.y = 0; + + this.addChild(aParent); + aParent.addChild(sprite1); + sprite1.addChild(sprite2); + + rot = cc.rotateBy(10, 360); + seq = rot.repeatForever(); + // + // Children + Scale using Sprite + // Test 4 + // + aParent = new cc.SpriteBatchNode(s_grossini_family); + sprite1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossinis_sister1.png")); + sprite1.x = 3 * winSize.width / 4; + sprite1.y = 2 * winSize.height / 3; + sprite1.scaleX = 1.5; + sprite1.scaleY = 0.5; + sprite1.runAction(seq); + + sprite2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("grossinis_sister2.png")); + sprite2.x = 50; + sprite2.y = 0; + + this.addChild(aParent); + aParent.addChild(sprite1); + sprite1.addChild(sprite2); + //----end35---- + }, + // + // Automation + // + testDuration:2.5, + pixel1:{"0":56, "1":116, "2":142, "3":255}, + pixel2:{"0":0, "1":0, "2":0, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes", "pixel4":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 4 - 31, 2 * winSize.height / 3 + 16, 5, 5); + var ret2 = this.readPixels(winSize.width / 4 - 38, 2 * winSize.height / 3 + 16, 3, 3); + var ret3 = this.readPixels(3 * winSize.width / 4 - 31, 2 * winSize.height / 3 + 16, 5, 5); + var ret4 = this.readPixels(3 * winSize.width / 4 - 38, 2 * winSize.height / 3 + 16, 3, 3); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2) ? "yes" : "no", + "pixel3":this.containsPixel(ret3, this.pixel1) ? "yes" : "no", + "pixel4":this.containsPixel(ret4, this.pixel2) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteChildrenChildren +// +//------------------------------------------------------------------ +var SpriteChildrenChildren = SpriteTestDemo.extend({ + _title:"Sprite multiple levels of children", + + ctor:function () { + //----start36----ctor + this._super(); + + spriteFrameCache.addSpriteFrames(s_ghostsPlist); + + var rot = cc.rotateBy(10, 360); + var seq = rot.repeatForever(); + + var rot_back = rot.reverse(); + var rot_back_fe = rot_back.repeatForever(); + + // + // SpriteBatchNode: 3 levels of children + // + var aParent = new cc.Node(); + this.addChild(aParent); + + // parent + var l1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("father.gif")); + l1.x = winSize.width / 2; + l1.y = winSize.height / 2; + l1.runAction(seq.clone()); + aParent.addChild(l1); + var l1W = l1.width, l1H = l1.height; + + // child left + var l2a = new cc.Sprite(spriteFrameCache.getSpriteFrame("sister1.gif")); + l2a.x = -50 + l1W / 2; + l2a.y = 0 + l1H / 2; + l2a.runAction(rot_back_fe.clone()); + l1.addChild(l2a); + var l2aW = l2a.width, l2aH = l2a.height; + + + // child right + var l2b = new cc.Sprite(spriteFrameCache.getSpriteFrame("sister2.gif")); + l2b.x = +50 + l1W / 2; + l2b.y = 0 + l1H / 2; + l2b.runAction(rot_back_fe.clone()); + l1.addChild(l2b); + var l2bW = l2b.width, l2bH = l2b.height; + + + // child left bottom + var l3a1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("child1.gif")); + l3a1.scale = 0.45; + l3a1.x = 0 + l2aW / 2; + l3a1.y = -100 + l2aH / 2; + l2a.addChild(l3a1); + + // child left top + var l3a2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("child1.gif")); + l3a2.scale = 0.45; + l3a2.x = 0 + l2aW / 2; + l3a2.y = +100 + l2aH / 2; + l2a.addChild(l3a2); + + // child right bottom + var l3b1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("child1.gif")); + l3b1.scale = 0.45; + l3b1.setFlippedY(true); + l3b1.x = 0 + l2bW / 2; + l3b1.y = -100 + l2bH / 2; + l2b.addChild(l3b1); + + // child right top + var l3b2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("child1.gif")); + l3b2.scale = 0.45; + l3b2.setFlippedY(true); + l3b2.x = 0 + l2bW / 2; + l3b2.y = +100 + l2bH / 2; + l2b.addChild(l3b2); + //----end36---- + }, + // + // Automation + // + testDuration:4, + pixel:{"0":153, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes", "pixel4":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 2 + 42, winSize.height / 2 + 145, 5, 5); + var ret2 = this.readPixels(winSize.width / 2 - 39, winSize.height / 2 + 55, 5, 5); + var ret3 = this.readPixels(winSize.width / 2 - 39, winSize.height / 2 - 146, 5, 5); + var ret4 = this.readPixels(winSize.width / 2 + 42, winSize.height / 2 - 56, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel) ? "yes" : "no", + "pixel3":this.containsPixel(ret3, this.pixel) ? "yes" : "no", + "pixel4":this.containsPixel(ret4, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteBatchNodeChildrenChildren +// +//------------------------------------------------------------------ +var SpriteBatchNodeChildrenChildren = SpriteTestDemo.extend({ + + _title:"SpriteBatchNode multiple levels of children", + + ctor:function () { + //----start37----ctor + this._super(); + + spriteFrameCache.addSpriteFrames(s_ghostsPlist); + + var rot = cc.rotateBy(10, 360); + var seq = rot.repeatForever(); + + var rot_back = rot.reverse(); + var rot_back_fe = rot_back.repeatForever(); + + // + // SpriteBatchNode: 3 levels of children + // + var aParent = new cc.SpriteBatchNode(s_ghosts); + if ("opengl" in cc.sys.capabilities) + aParent.texture.generateMipmap(); + this.addChild(aParent); + + // parent + var l1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("father.gif")); + l1.x = winSize.width / 2; + l1.y = winSize.height / 2; + l1.runAction(seq.clone()); + aParent.addChild(l1); + var l1W = l1.width, l1H = l1.height; + + // child left + var l2a = new cc.Sprite(spriteFrameCache.getSpriteFrame("sister1.gif")); + l2a.x = -50 + l1W / 2; + l2a.y = 0 + l1H / 2; + l2a.runAction(rot_back_fe.clone()); + l1.addChild(l2a); + var l2aW = l2a.width, l2aH = l2a.height; + + + // child right + var l2b = new cc.Sprite(spriteFrameCache.getSpriteFrame("sister2.gif")); + l2b.x = 50 + l1W / 2; + l2b.y = 0 + l1H / 2; + l2b.runAction(rot_back_fe.clone()); + l1.addChild(l2b); + var l2bW = l2b.width, l2bH = l2b.height; + + + // child left bottom + var l3a1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("child1.gif")); + l3a1.scale = 0.45; + l3a1.x = 0 + l2aW / 2; + l3a1.y = -100 + l2aH / 2; + l2a.addChild(l3a1); + + // child left top + var l3a2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("child1.gif")); + l3a2.scale = 0.45; + l3a2.x = 0 + l2aW / 2; + l3a2.y = +100 + l2aH / 2; + l2a.addChild(l3a2); + + // child right bottom + var l3b1 = new cc.Sprite(spriteFrameCache.getSpriteFrame("child1.gif")); + l3b1.scale = 0.45; + l3b1.setFlippedY(true); + l3b1.x = 0 + l2bW / 2; + l3b1.y = -100 + l2bH / 2; + l2b.addChild(l3b1); + + // child right top + var l3b2 = new cc.Sprite(spriteFrameCache.getSpriteFrame("child1.gif")); + l3b2.scale = 0.45; + l3b2.setFlippedY(true); + l3b2.x = 0 + l2bW / 2; + l3b2.y = +100 + l2bH / 2; + l2b.addChild(l3b2); + //----end37---- + }, + // + // Automation + // + testDuration:4, + pixel:{"0":153, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes", "pixel4":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 2 + 42, winSize.height / 2 + 145, 5, 5); + var ret2 = this.readPixels(winSize.width / 2 - 39, winSize.height / 2 + 55, 5, 5); + var ret3 = this.readPixels(winSize.width / 2 - 39, winSize.height / 2 - 146, 5, 5); + var ret4 = this.readPixels(winSize.width / 2 + 42, winSize.height / 2 - 56, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel) ? "yes" : "no", + "pixel3":this.containsPixel(ret3, this.pixel) ? "yes" : "no", + "pixel4":this.containsPixel(ret4, this.pixel) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteNilTexture +// +//------------------------------------------------------------------ +var SpriteNilTexture = SpriteTestDemo.extend({ + + _title:"Sprite without texture", + _subtitle:"opacity and color should work", + + ctor:function () { + //----start38----ctor + this._super(); + + // TEST: If no texture is given, then Opacity + Color should work. + var sprite = new cc.Sprite(); + sprite.setTextureRect(cc.rect(0, 0, 300, 300)); + // sprite.color = cc.color.RED; + sprite.color = cc.color(255, 0, 0); + sprite.opacity = 128; + sprite.x = 3 * winSize.width / 4; + sprite.y = winSize.height / 2; + this.addChild(sprite, 100); + + sprite = new cc.Sprite(); + sprite.setTextureRect(cc.rect(0, 0, 300, 300)); + //sprite.color = cc.color.BLUE; + sprite.color = cc.color(0, 0, 255); + sprite.opacity = 128; + sprite.x = winSize.width / 4; + sprite.y = winSize.height / 2; + this.addChild(sprite, 100); + //----end38---- + }, + // + // Automation + // + testDuration:1, + pixel1:{"0":0, "1":0, "2":128, "3":255}, + pixel2:{"0":128, "1":0, "2":0, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 4, winSize.height / 2, 5, 5); + var ret2 = this.readPixels(3 * winSize.width / 4, winSize.height / 2, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1) ? "yes" : "no", "pixel2":this.containsPixel(ret2, this.pixel2) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// SpriteSubclass +// +//------------------------------------------------------------------ +var MySprite1 = cc.Sprite.extend({ + _ivar:0, + ctor: function(spriteFrameName) { + this._super(spriteFrameName); + } +}); + +var MySprite2 = cc.Sprite.extend({ + _ivar:0, + ctor: function(name) { + this._super(name); + } +}); + +var SpriteSubclass = SpriteTestDemo.extend({ + _title:"Sprite subclass", + _subtitle:"Testing initWithTexture:rect method", + + ctor:function () { + //----start39----ctor + this._super(); + + spriteFrameCache.addSpriteFrames(s_ghostsPlist); + var aParent = new cc.SpriteBatchNode(s_ghosts); + + // MySprite1 + var sprite = new MySprite1("#father.gif"); + sprite.x = winSize.width / 4; + sprite.y = winSize.height / 2; + aParent.addChild(sprite); + this.addChild(aParent); + + // MySprite2 + var sprite2 = new MySprite2(s_pathGrossini); + this.addChild(sprite2); + sprite2.x = winSize.width / 4 * 3; + sprite2.y = winSize.height / 2; + //----end39---- + }, + // + // Automation + // + testDuration:1, + pixel1:{"0":249, "1":30, "2":20, "3":255}, + pixel2:{"0":255, "1":204, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 4, winSize.height / 2 - 15, 5, 5); + var ret2 = this.readPixels(winSize.width / 4 * 3, winSize.height / 2 + 44, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1) ? "yes" : "no", "pixel2":this.containsPixel(ret2, this.pixel2) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// AnimationCache +// +//------------------------------------------------------------------ +var AnimationCacheTest = SpriteTestDemo.extend({ + + _title:"AnimationCache", + _subtitle:"Sprite should be animated", + + ctor:function () { + //----start40----ctor + this._super(); + spriteFrameCache.addSpriteFrames(s_grossiniPlist); + spriteFrameCache.addSpriteFrames(s_grossini_grayPlist); + spriteFrameCache.addSpriteFrames(s_grossini_bluePlist); + + // + // create animation "dance" + // + var animFrames = []; + var frame, animFrame; + var str = ""; + for (var i = 1; i < 15; i++) { + str = "grossini_dance_" + (i < 10 ? ("0" + i) : i) + ".png"; + frame = spriteFrameCache.getSpriteFrame(str); + animFrame = new cc.AnimationFrame(frame, 1); + animFrames.push(animFrame); + } + + var animation = new cc.Animation(animFrames, 0.2); + + // Add an animation to the Cache + cc.animationCache.addAnimation(animation, "dance"); + + // + // create animation "dance gray" + // + animFrames = []; + for (i = 1; i < 15; i++) { + str = "grossini_dance_gray_" + (i < 10 ? ("0" + i) : i) + ".png"; + frame = spriteFrameCache.getSpriteFrame(str); + animFrames.push(frame); + } + + animation = new cc.Animation(animFrames, 0.2); + + // Add an animation to the Cache + cc.animationCache.addAnimation(animation, "dance_gray"); + + // + // create animation "dance blue" + // + animFrames = []; + for (i = 1; i < 4; i++) { + str = "grossini_blue_0" + i + ".png"; + frame = spriteFrameCache.getSpriteFrame(str); + animFrames.push(frame); + } + + animation = new cc.Animation(animFrames, 0.2); + + // Add an animation to the Cache + cc.animationCache.addAnimation(animation, "dance_blue"); + + var animCache = cc.animationCache; + + var normal = animCache.getAnimation("dance"); + normal.setRestoreOriginalFrame(true); + var dance_grey = animCache.getAnimation("dance_gray"); + dance_grey.setRestoreOriginalFrame(true); + var dance_blue = animCache.getAnimation("dance_blue"); + dance_blue.setRestoreOriginalFrame(true); + + var animN = cc.animate(normal); + var animG = cc.animate(dance_grey); + var animB = cc.animate(dance_blue); + + var seq = cc.sequence(animN, animG, animB); + + frame = spriteFrameCache.getSpriteFrame("grossini_dance_01.png"); + var grossini = new cc.Sprite(frame); + + grossini.x = winSize.width / 2; + + grossini.y = winSize.height / 2; + this.addChild(grossini); + + // run the animation + grossini.runAction(seq); + //----end40---- + }, + // + // Automation + // + testDuration:6.5, + ePixel1:{"0":51, "1":0, "2":51, "3":255}, + ePixel2:{"0":15, "1":15, "2":15, "3":255}, + ePixel3:{"0":0, "1":38, "2":0, "3":255}, + cPixel1:null, + cPixel2:null, + cPixel3:null, + setupAutomation:function () { + //----start40----setupAutomation + var fun1 = function () { + this.cPixel1 = this.readPixels(winSize.width / 2, winSize.height / 2, 5, 5); + } + this.scheduleOnce(fun1, 0.4); + + var fun2 = function () { + this.cPixel2 = this.readPixels(winSize.width / 2, winSize.height / 2, 5, 5); + } + this.scheduleOnce(fun2, 3.2); + + var fun3 = function () { + this.cPixel3 = this.readPixels(winSize.width / 2, winSize.height / 2, 5, 5); + } + this.scheduleOnce(fun3, 6); + //----end40---- + }, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret = {"pixel1":this.containsPixel(this.cPixel1, this.ePixel1) ? "yes" : "no", "pixel2":this.containsPixel(this.cPixel2, this.ePixel2) ? "yes" : "no", "pixel3":this.containsPixel(this.cPixel3, this.ePixel3, true, 5) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +var NodeSort = SpriteTestDemo.extend({ + _node:null, + _sprite1:null, + _sprite2:null, + _sprite3:null, + _sprite4:null, + _sprite5:null, + + _title:"node sort same index", + _subtitle:"tag order in console should be 2,1,3,4,5", + + ctor:function () { + //----start49----ctor + this._super(); + this._node = new cc.Node(); + this.addChild(this._node, 0, 0); + + this._sprite1 = new cc.Sprite(s_piece, cc.rect(128, 0, 64, 64)); + this._sprite1.x = 100; + this._sprite1.y = 160; + this._node.addChild(this._sprite1, -6, 1); + + this._sprite2 = new cc.Sprite(s_piece, cc.rect(128, 0, 64, 64)); + this._sprite2.x = 164; + this._sprite2.y = 160; + this._node.addChild(this._sprite2, -6, 2); + + this._sprite4 = new cc.Sprite(s_piece, cc.rect(128, 0, 64, 64)); + this._sprite4.x = 292; + this._sprite4.y = 160; + this._node.addChild(this._sprite4, -3, 4); + + this._sprite3 = new cc.Sprite(s_piece, cc.rect(128, 0, 64, 64)); + this._sprite3.x = 228; + this._sprite3.y = 160; + this._node.addChild(this._sprite3, -4, 3); + + this._sprite5 = new cc.Sprite(s_piece, cc.rect(128, 0, 64, 64)); + this._sprite5.x = 356; + this._sprite5.y = 160; + this._node.addChild(this._sprite5, -3, 5); + + this.schedule(this.reorderSprite); + //----end49---- + }, + + reorderSprite:function (dt) { + //----start49----reorderSprite + this.unschedule(this.reorderSprite); + + cc.log("Before reorder--"); + + var i = 0; + var child; + var nodeChildren = this._node.children; + for (i = 0; i < nodeChildren.length; i++) { + child = nodeChildren[i]; + cc.log("tag:" + child.tag + " z: " + child.zIndex); + } + + //z-4 + this._node.reorderChild(this._node.children[0], -6); + this._node.sortAllChildren(); + + cc.log("After reorder--"); + nodeChildren = this._node.children; + for (i = 0; i < nodeChildren.length; i++) { + child = nodeChildren[i]; + cc.log("tag:" + child.tag + " z: " + + child.zIndex); + this.testOrders.push(child.tag); + } + //----end49---- + }, + // + // Automation + // + testDuration:1, + testOrders:[], + getExpectedResult:function () { + return JSON.stringify([2, 1, 3, 4, 5]); + }, + getCurrentResult:function () { + return JSON.stringify(this.testOrders); + } +}); + +var SpriteBatchNodeReorderSameIndex = SpriteTestDemo.extend({ + _batchNode:null, + _sprite1:null, + _sprite2:null, + _sprite3:null, + _sprite4:null, + _sprite5:null, + + _title:"SpriteBatchNodeReorder same index", + _subtitle:"tag order in console should be 2,3,4,5,1", + + ctor:function () { + //----start47----ctor + this._super(); + this._batchNode = new cc.SpriteBatchNode(s_piece, 15); + this.addChild(this._batchNode, 1, 0); + + this._sprite1 = new cc.Sprite(this._batchNode.texture, cc.rect(128, 0, 64, 64)); + this._sprite1.x = 100; + this._sprite1.y = 160; + this._batchNode.addChild(this._sprite1, 3, 1); + + this._sprite2 = new cc.Sprite(this._batchNode.texture, cc.rect(128, 0, 64, 64)); + this._sprite2.x = 164; + this._sprite2.y = 160; + this._batchNode.addChild(this._sprite2, 4, 2); + + this._sprite3 = new cc.Sprite(this._batchNode.texture, cc.rect(128, 0, 64, 64)); + this._sprite3.x = 228; + this._sprite3.y = 160; + this._batchNode.addChild(this._sprite3, 4, 3); + + this._sprite4 = new cc.Sprite(this._batchNode.texture, cc.rect(128, 0, 64, 64)); + this._sprite4.x = 292; + this._sprite4.y = 160; + this._batchNode.addChild(this._sprite4, 5, 4); + + this._sprite5 = new cc.Sprite(this._batchNode.texture, cc.rect(128, 0, 64, 64)); + this._sprite5.x = 356; + this._sprite5.y = 160; + this._batchNode.addChild(this._sprite5, 6, 5); + + this.scheduleOnce(this.reorderSprite, 2); + //----end47---- + }, + + reorderSprite:function (dt) { + //----start47----reorderSprite + this._batchNode.reorderChild(this._sprite4, 4); + this._batchNode.reorderChild(this._sprite5, 4); + this._batchNode.reorderChild(this._sprite1, 4); + + this._batchNode.sortAllChildren(); + + var descendants = this._batchNode.descendants; + + for (var i = 0; i < descendants.length; i++) { + var child = descendants[i]; + cc.log("tag:" + child.tag); + this.testDescendants.push(child.tag); + } + //----end47---- + }, + // + // Automation + // + testDuration:2.2, + testDescendants:[], + getExpectedResult:function () { + return JSON.stringify([2, 3, 4, 5, 1]); + }, + getCurrentResult:function () { + return JSON.stringify(this.testDescendants); + } +}); + +var SpriteBatchNodeReorderOneChild = SpriteTestDemo.extend({ + _batchNode:null, + _reoderSprite:null, + + _title:"SpriteBatchNode reorder 1 child", + ctor:function () { + //----start48----ctor + this._super(); + + spriteFrameCache.addSpriteFrames(s_ghostsPlist); + // + // SpriteBatchNode: 3 levels of children + // + var aParent = new cc.SpriteBatchNode(s_ghosts); + + this._batchNode = aParent; + //[[aParent texture] generateMipmap]; + if ("opengl" in cc.sys.capabilities) + aParent.texture.generateMipmap(); + this.addChild(aParent); + + // parent + var l1 = new cc.Sprite("#father.gif"); + l1.x = winSize.width / 2; + l1.y = winSize.height / 2; + + aParent.addChild(l1); + var l1W = l1.width, l1H = l1.height; + + // child left + var l2a = new cc.Sprite("#sister1.gif"); + l2a.x = -10 + l1W / 2; + l2a.y = 0 + l1H / 2; + + l1.addChild(l2a, 1); + var l2aW = l2a.width, l2aH = l2a.height; + + // child right + var l2b = new cc.Sprite("#sister2.gif"); + l2b.x = +50 + l1W / 2; + l2b.y = 0 + l1H / 2; + + l1.addChild(l2b, 2); + var l2bW = l2b.width, l2bH = l2b.height; + + // child left bottom + var l3a1 = new cc.Sprite("#child1.gif"); + l3a1.scale = 0.45; + l3a1.x = 0 + l2aW / 2; + l3a1.y = -50 + l2aH / 2; + l2a.addChild(l3a1, 1); + + // child left top + var l3a2 = new cc.Sprite("#child1.gif"); + l3a2.scale = 0.45; + l3a2.x = 0 + l2aW / 2; + l3a2.y = +50 + l2aH / 2; + l2a.addChild(l3a2, 2); + + this._reoderSprite = l2a; + + // child right bottom + var l3b1 = new cc.Sprite("#child1.gif"); + l3b1.scale = 0.45; + l3b1.setFlippedY(true); + l3b1.x = 0 + l2bW / 2; + l3b1.y = -50 + l2bH / 2; + l2b.addChild(l3b1); + + // child right top + var l3b2 = new cc.Sprite("#child1.gif"); + l3b2.scale = 0.45; + l3b2.setFlippedY(true); + l3b2.x = 0 + l2bW / 2; + l3b2.y = 50 + l2bH / 2; + l2b.addChild(l3b2); + + this.scheduleOnce(this.reorderSprite, 2.0); + //----end48---- + }, + + reorderSprite:function (dt) { + this._reoderSprite.parent.reorderChild(this._reoderSprite, -1); + this._batchNode.sortAllChildren(); + //cc.Sprite* child; + //CCARRAY_FOREACH(batchNode.descendants,child) NSLog(@"tag %i",child.tag); + }, + // + // Automation + // + testDuration:2.5, + pixel:{"0":0, "1":102, "2":255, "3":255}, + getExpectedResult:function () { + var ret = {"pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 2 - 11, winSize.height / 2 + 33, 3, 3); + var ret = {"pixel":this.containsPixel(ret1, this.pixel, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +var SpriteBatchNodeSkewNegativeScaleChildren = SpriteTestDemo.extend({ + _title:"SpriteBatchNode + children + skew", + _subtitle:"SpriteBatchNode skew + negative scale with children", + + ctor:function () { + //----start51----ctor + this._super(); + + var cache = spriteFrameCache; + cache.addSpriteFrames(s_grossiniPlist); + cache.addSpriteFrames(s_grossini_grayPlist, s_grossini_gray); + + var spritebatch = new cc.SpriteBatchNode(s_grossini); + this.addChild(spritebatch); + + for (var i = 0; i < 2; i++) { + var sprite = new cc.Sprite("#grossini_dance_01.png"); + sprite.x = winSize.width / 4 * (i + 1); + sprite.y = winSize.height / 2; + + // Skew + var skewX = cc.skewBy(2, 45, 0); + var skewX_back = skewX.reverse(); + var skewY = cc.skewBy(2, 0, 45); + var skewY_back = skewY.reverse(); + + if (i === 1) + sprite.scale = -1.0; + + var seq_skew = cc.sequence(skewX, skewX_back, skewY, skewY_back); + sprite.runAction(seq_skew.repeatForever()); + + var child1 = new cc.Sprite("#grossini_dance_01.png"); + child1.x = sprite.width / 2.0; + child1.y = sprite.height / 2.0; + + child1.scale = 0.8; + sprite.addChild(child1); + spritebatch.addChild(sprite, i); + } + //----end51---- + }, + // + // Automation + // + testDuration:6, + pixel1:{"0":51, "1":0, "2":51, "3":255}, + pixel2:{"0":0, "1":0, "2":0, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 4 + 21, winSize.height / 2 + 22, 5, 5); + var ret2 = this.readPixels(winSize.width / 4 + 11, winSize.height / 2 + 14, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1) ? "yes" : "no", + "pixel2":!this.containsPixel(ret2, this.pixel2) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +var SpriteSkewNegativeScaleChildren = SpriteTestDemo.extend({ + _title:"Sprite + children + skew", + _subtitle:"Sprite skew + negative scale with children", + + ctor:function () { + //----start50----ctor + this._super(); + + var cache = spriteFrameCache; + cache.addSpriteFrames(s_grossiniPlist); + cache.addSpriteFrames(s_grossini_grayPlist, s_grossini_gray); + + var parent = new cc.Node(); + this.addChild(parent); + + for (var i = 0; i < 2; i++) { + var sprite = new cc.Sprite("#grossini_dance_01.png"); + sprite.x = winSize.width / 4 * (i + 1); + sprite.y = winSize.height / 2; + + // Skew + var skewX = cc.skewBy(2, 45, 0); + var skewX_back = skewX.reverse(); + var skewY = cc.skewBy(2, 0, 45); + var skewY_back = skewY.reverse(); + + if (i === 1) + sprite.scale = -1.0; + + var seq_skew = cc.sequence(skewX, skewX_back, skewY, skewY_back); + sprite.runAction(seq_skew.repeatForever()); + + var child1 = new cc.Sprite("#grossini_dance_01.png"); + child1.x = sprite.width / 2.0; + child1.y = sprite.height / 2.0; + + sprite.addChild(child1); + child1.scale = 0.8; + parent.addChild(sprite, i); + } + //----end50---- + }, + // + // Automation + // + testDuration:6, + pixel1:{"0":51, "1":0, "2":51, "3":255}, + pixel2:{"0":0, "1":0, "2":0, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 4 + 21, winSize.height / 2 + 22, 5, 5); + var ret2 = this.readPixels(winSize.width / 4 + 11, winSize.height / 2 + 14, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1, false) ? "yes" : "no", + "pixel2":!this.containsPixel(ret2, this.pixel2, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +var DoubleSprite = cc.Sprite.extend({ + HD:false, + + ctor:function (fileName) { + this._super(fileName); + //var resolutionType = texture.getResolutionType(); + //this.HD = ( resolutionType == cc.kCCResolutioniPhoneRetinaDisplay || resolutionType == kCCResolutioniPadRetinaDisplay ); + }, + + setContentSize:function (size) { + var newSize = cc.size(size.width, size.height); + // If Retina Display and Texture is in HD then scale the vertex rect + if (cc.contentScaleFactor() == 2 && !this.HD) { + newSize.width *= 2; + newSize.height *= 2; + } + this._super(newSize); + }, + _setWidth:function (value) { + // If Retina Display and Texture is in HD then scale the vertex rect + if (cc.contentScaleFactor() == 2 && !this.HD) { + value *= 2; + } + this._super(value); + }, + _setHeight:function (value) { + // If Retina Display and Texture is in HD then scale the vertex rect + if (cc.contentScaleFactor() == 2 && !this.HD) { + value *= 2; + } + this._super(value); + }, + + setVertexRect:function (rect) { + // If Retina Display and Texture is in HD then scale the vertex rect + if (cc.contentScaleFactor() == 2 && !this.HD) { + rect.width *= 2; + rect.height *= 2; + } + this._super(rect); + } +}); + +cc.defineGetterSetter(DoubleSprite.prototype, "width", DoubleSprite.prototype._getWidth, DoubleSprite.prototype._setWidth); +cc.defineGetterSetter(DoubleSprite.prototype, "height", DoubleSprite.prototype._getHeight, DoubleSprite.prototype._setHeight); + +var SpriteDoubleResolution = SpriteTestDemo.extend({ + + _title:"Sprite Double resolution", + _subtitle:"Retina Display. SD (left) should be equal to HD (right)", + + ctor:function () { + //----start52----ctor + this._super(); + + // + // LEFT: SD sprite + // + // there is no HD resolution file of grossini_dance_08. + var spriteSD = new DoubleSprite(s_grossiniDance08); + this.addChild(spriteSD); + spriteSD.x = winSize.width / 4; + spriteSD.y = winSize.height / 2; + + var child1_left = new DoubleSprite(s_grossiniDance08); + spriteSD.addChild(child1_left); + child1_left.x = -30; + child1_left.y = 0; + + var child1_right = new cc.Sprite(s_pathGrossini); + spriteSD.addChild(child1_right); + child1_left.x = spriteSD.height; + child1_left.y = 0; + + // + // RIGHT: HD sprite + // + // there is an HD version of grossini.png + var spriteHD = new cc.Sprite(s_pathGrossini); + this.addChild(spriteHD); + spriteHD.x = winSize.width / 4 * 3; + spriteHD.y = winSize.height / 2; + + var child2_left = new DoubleSprite(s_grossiniDance08); + spriteHD.addChild(child2_left); + child2_left.x = -30; + child2_left.y = 0; + + var child2_right = new cc.Sprite(s_pathGrossini); + spriteHD.addChild(child2_right); + child2_left.x = spriteHD.height; + child2_left.y = 0; + + + // Actions + var scale = cc.scaleBy(2, 0.5); + var scale_back = scale.reverse(); + var seq = cc.sequence(scale, scale_back); + + var seq_copy = seq.clone(); + + spriteSD.runAction(seq); + spriteHD.runAction(seq_copy); + //----end52---- + } +}); + +var AnimationCacheFile = SpriteTestDemo.extend({ + + _title:"AnimationCache - Load file", + _subtitle:"Sprite should be animated", + + ctor:function () { + //----start54----ctor + this._super(); + var frameCache = spriteFrameCache; + frameCache.addSpriteFrames(s_grossiniPlist); + frameCache.addSpriteFrames(s_grossini_grayPlist); + frameCache.addSpriteFrames(s_grossini_bluePlist); + + // Purge previously loaded animation + if(cc.animationCache._clear) + cc.animationCache._clear(); + var animCache = cc.animationCache; + + // Add an animation to the Cache + // XXX API-FIX XXX + // renamed from addAnimationsWithFile to addAnimations + animCache.addAnimations(s_animationsPlist); + + var normal = animCache.getAnimation("dance_1"); + normal.setRestoreOriginalFrame(true); + var dance_grey = animCache.getAnimation("dance_2"); + dance_grey.setRestoreOriginalFrame(true); + var dance_blue = animCache.getAnimation("dance_3"); + dance_blue.setRestoreOriginalFrame(true); + + var animN = cc.animate(normal); + var animG = cc.animate(dance_grey); + var animB = cc.animate(dance_blue); + + var seq = cc.sequence(animN, animG, animB); + + // create an sprite with frame name + // texture-less sprites are not supported + var grossini = new cc.Sprite("#grossini_dance_01.png"); + + grossini.x = winSize.width / 2; + + grossini.y = winSize.height / 2; + this.addChild(grossini); + + // run the animation + grossini.runAction(seq); + //----end54---- + }, + // + // Automation + // + testDuration:6.5, + ePixel1:{"0":51, "1":0, "2":51, "3":255}, + ePixel2:{"0":15, "1":15, "2":15, "3":255}, + ePixel3:{"0":0, "1":38, "2":0, "3":255}, + cPixel1:null, + cPixel2:null, + cPixel3:null, + setupAutomation:function () { + this.scheduleOnce(this.getPixel1, 0.4); + this.scheduleOnce(this.getPixel2, 3.2); + this.scheduleOnce(this.getPixel3, 6); + }, + getPixel1:function () { + this.cPixel1 = this.readPixels(winSize.width / 2, winSize.height / 2, 5, 5); + }, + getPixel2:function () { + this.cPixel2 = this.readPixels(winSize.width / 2, winSize.height / 2, 5, 5); + }, + getPixel3:function () { + this.cPixel3 = this.readPixels(winSize.width / 2, winSize.height / 2, 5, 5); + }, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret = {"pixel1":this.containsPixel(this.cPixel1, this.ePixel1) ? "yes" : "no", "pixel2":this.containsPixel(this.cPixel2, this.ePixel2) ? "yes" : "no", "pixel3":this.containsPixel(this.cPixel3, this.ePixel3, true, 5) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +var SpriteBatchBug1217 = SpriteTestDemo.extend({ + + _title:"SpriteBatch - Bug 1217", + _subtitle:"Adding big family to spritebatch. You shall see 3 heads", + + ctor:function () { + //----start53----ctor + this._super(); + var bn = new cc.SpriteBatchNode(s_grossini_dance_atlas, 15); + + var s1 = new cc.Sprite(bn.texture, cc.rect(0, 0, 57, 57)); + var s2 = new cc.Sprite(bn.texture, cc.rect(0, 0, 57, 57)); + var s3 = new cc.Sprite(bn.texture, cc.rect(0, 0, 57, 57)); + + s1.color = cc.color(255, 0, 0); + s2.color = cc.color(0, 255, 0); + s3.color = cc.color(0, 0, 255); + + s1.x = 20; + + s1.y = 200; + s2.x = 100; + s2.y = 0; + s3.x = 100; + s3.y = 0; + + bn.x = 0; + + bn.y = 0; + + //!!!!! + s1.addChild(s2); + s2.addChild(s3); + bn.addChild(s1); + + this.addChild(bn); + //----end53---- + }, + // Automation + testDuration:2.1, + pixel1:{"0":51, "1":0, "2":0, "3":255}, + pixel2:{"0":0, "1":0, "2":0, "3":255}, + pixel3:{"0":0, "1":0, "2":51, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(20, 174, 3, 3); + var ret2 = this.readPixels(90, 145, 3, 3); + var ret3 = this.readPixels(163, 116, 3, 3); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1, false) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2, false) ? "yes" : "no", + "pixel3":this.containsPixel(ret3, this.pixel3, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +var TextureColorCacheIssue = SpriteTestDemo.extend({ + + _title:"Texture Color Cache Issue Test", + _subtitle:"You should see two different sprites colored green and blue", + + ctor:function () { + //----start55----ctor + this._super(); + + var spriteFrameCache = cc.spriteFrameCache; + spriteFrameCache.addSpriteFrames(s_tcc_issue_1_plist, s_tcc_issue_1); + spriteFrameCache.addSpriteFrames(s_tcc_issue_2_plist, s_tcc_issue_2); + + var grossini = new cc.Sprite('#tcc_grossini_dance_01.png'); + grossini.x = winSize.width / 3; + grossini.y = winSize.height / 2; + + var sister = new cc.Sprite('#tcc_grossinis_sister1.png'); + sister.x = winSize.width / 3 * 2; + sister.y = winSize.height / 2; + + this.addChild(grossini); + this.addChild(sister); + + grossini.color = cc.color(1, 255, 1); + sister.color = cc.color(1, 1, 255); + //----end55---- + }, + onExit:function () { + //----start55----onExit + spriteFrameCache.removeSpriteFramesFromFile(s_tcc_issue_1_plist); + spriteFrameCache.removeSpriteFramesFromFile(s_tcc_issue_2_plist); + this._super(); + //----end55---- + }, + // Automation + pixel1:{"0":0, "1":204, "2":0, "3":255}, + pixel2:{"0":0, "1":0, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 3, winSize.height / 2 + 43, 5, 5); + var ret2 = this.readPixels(winSize.width / 3 * 2, winSize.height / 2 - 6, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1, true, 3) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2, true, 3) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +var TextureColorCacheIssue2 = SpriteTestDemo.extend({ + + _title:"Texture Color Cache Issue Test #2", + _subtitle:"You should see two different sprites magenta and yellow", + + ctor:function () { + //----start56----ctor + this._super(); + + var spriteFrameCache = cc.spriteFrameCache; + spriteFrameCache.addSpriteFrames(s_tcc_issue_1_plist, s_tcc_issue_1); + spriteFrameCache.addSpriteFrames(s_tcc_issue_2_plist, s_tcc_issue_2); + + var grossini = new cc.Sprite('#tcc_grossini_dance_01.png'); + grossini.x = winSize.width / 3; + grossini.y = winSize.height / 2; + + var sister = new cc.Sprite('#tcc_grossinis_sister1.png'); + sister.x = winSize.width / 3 * 2; + sister.y = winSize.height / 2; + + this.addChild(grossini); + this.addChild(sister); + + grossini.color = cc.color(255, 255, 0); + sister.color = cc.color(255, 0, 255); + //----end56---- + }, + onExit:function () { + //----start56----onExit + spriteFrameCache.removeSpriteFramesFromFile(s_tcc_issue_1_plist); + spriteFrameCache.removeSpriteFramesFromFile(s_tcc_issue_2_plist); + this._super(); + //----end56---- + }, + // Automation + pixel1:{"0":255, "1":204, "2":0, "3":255}, + pixel2:{"0":255, "1":0, "2":153, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 3, winSize.height / 2 + 43, 5, 5); + var ret2 = this.readPixels(winSize.width / 3 * 2, winSize.height / 2 - 3, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1, true, 5) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2, true, 5) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +var TextureRotatedSpriteFrame = SpriteTestDemo.extend({ + + _title:"Sub Sprite (rotated source)", + _subtitle:"createWithSpriteFrameName(); sub sprite", + + ctor:function () { + //----start57----ctor + this._super(); + + cc.spriteFrameCache.addSpriteFrames(s_s9s_blocks9_plist); + + var block = new cc.Sprite('#blocks9r.png'); + + var x = winSize.width / 2; + var y = 0 + (winSize.height / 2); + + block.setTextureRect(cc.rect(32, 32, 32, 32), true, cc.rect(32, 32, 32, 32)); + + block.x = x; + + block.y = y; + this.addChild(block); + //----end57---- + }, + // Automation + pixel1:{"0":255, "1":204, "2":153, "3":255}, + pixel2:{"0":51, "1":0, "2":51, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(winSize.width / 2 - 14, winSize.height / 2 - 8, 5, 5); + var ret2 = this.readPixels(winSize.width / 2 + 12, winSize.height / 2, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1, true, 5) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2, true, 5) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +var SpriteWithRepeatingTexture = SpriteTestDemo.extend({ + + _title:"Sprite with Repeating texture", + _subtitle:"aTexture.setTexParameters(cc.LINEAR, cc.LINEAR, cc.REPEAT, cc.REPEAT);", + + ctor:function () { + //----start58----ctor + this._super(); + var block = new cc.Sprite(s_pathBlock); + + var x = winSize.width / 2; + var y = (winSize.height / 2); + + block.setTextureRect(cc.rect(0,0, 320,240)); + block.setPosition(x, y); + block.getTexture().setTexParameters(cc.LINEAR, cc.LINEAR, cc.REPEAT, cc.REPEAT); + this.addChild(block); + //----end58---- + } +}); + +var SpriteBlendFuncTest = SpriteTestDemo.extend({ + //webgl only + _title: "", //Sprite BlendFunc test + _subtitle: "", + + ctor: function(){ + //----start59----ctor + this._super(); + + var destFactors = [gl.ZERO, gl.ONE, gl.SRC_COLOR, gl.ONE_MINUS_SRC_COLOR, gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA], + srcFactors = [gl.ZERO, gl.ONE, gl.DST_COLOR, gl.ONE_MINUS_DST_COLOR, gl.DST_ALPHA, gl.ONE_MINUS_DST_ALPHA]; + var destTitles = ["ZERO", "ONE", "SRC_COLOR", "ONE_MINUS_SRC_COLOR", "SRC_ALPHA", "ONE_MINUS_SRC_ALPHA"], + srcTitles = ["ZERO", "ONE", "DST_COLOR", "ONE_MINUS_DST_COLOR", "SRC_ALPHA", "ONE_MINUS_SRC_ALPHA"]; + + var sourceImg = "res/Images/dot.png", destImg = "res/Images/wood.jpg"; + var sourceTexture = cc.textureCache.addImage(sourceImg); + sourceTexture.handleLoadedTexture(true); + var sourceSprite = new cc.Sprite(sourceImg); + var destSprite = new cc.Sprite(destImg); + sourceSprite.setScale(0.8); + destSprite.setScale(0.8); + sourceSprite.setPosition(60,400); + destSprite.setPosition(120,400); + this.addChild(sourceSprite); + this.addChild(destSprite); + + var i, j, title, fontSize, titleLabel; + for(i = 0; i < destTitles.length; i++){ + title = destTitles[i]; + fontSize = (title.length > 10) ? 14 : 18; + titleLabel = new cc.LabelTTF(title, "Arial", fontSize); + titleLabel.setAnchorPoint(0, 0.5); + titleLabel.setPosition(0, 355 - 60 * i); + this.addChild(titleLabel); + } + + for(i = 0; i < srcTitles.length; i++){ + title = srcTitles[i]; + fontSize = (title.length > 10) ? 14 : 18; + titleLabel = new cc.LabelTTF(title, "Arial", fontSize); + titleLabel.setAnchorPoint(0, 0.5); + titleLabel.setPosition(220 + i * 60, 390); + titleLabel.setRotation(-20); + this.addChild(titleLabel); + } + //j = 0; + for(i = 0; i < srcFactors.length; i++){ + for(j = 0; j < destFactors.length; j++){ + sourceSprite = new cc.Sprite(sourceImg); + //sourceSprite.setScale(0.8); + sourceSprite.setPosition( 220 + i * 60, 355 - j * 60); + sourceSprite.setBlendFunc(srcFactors[i], destFactors[j]); + + + destSprite = new cc.Sprite(destImg); + //destSprite.setScale(0.8); + destSprite.setPosition( 220 + i * 60, 355 - j * 60); +// destSprite.setBlendFunc(srcFactors[j], destFactors[i]); + + this.addChild(destSprite,1); + this.addChild(sourceSprite,2); + } + } + //----end59---- + } +}); + +var SpriteTestScene = TestScene.extend({ + runThisTest:function (num) { + spriteTestIdx = (num || num == 0) ? (num - 1) : -1; + var layer = nextSpriteTest(); + this.addChild(layer); + + director.runScene(this); + } +}); + +// +// Flow control +// +var arrayOfSpriteTest = [ + Sprite1, + SpriteBatchNode1, + SpriteFrameTest, + SpriteFrameAliasNameTest, + SpriteAnchorPoint, + SpriteBatchNodeAnchorPoint, + SpriteOffsetAnchorRotation, + SpriteBatchNodeOffsetAnchorRotation, + SpriteOffsetAnchorScale, + SpriteBatchNodeOffsetAnchorScale, + SpriteAnimationSplit, + SpriteColorOpacity, + SpriteBatchNodeColorOpacity, + SpriteZOrder, + SpriteBatchNodeZOrder, + SpriteBatchNodeReorder, + SpriteBatchNodeReorderIssue744, + SpriteBatchNodeReorderIssue766, + SpriteBatchNodeReorderIssue767, + SpriteZVertex, + SpriteBatchNodeZVertex, + Sprite6, + SpriteFlip, + SpriteBatchNodeFlip, + SpriteAliased, + SpriteBatchNodeAliased, + SpriteNewTexture, + SpriteBatchNodeNewTexture, + SpriteHybrid, + SpriteBatchNodeChildren, + SpriteBatchNodeChildrenZ, + SpriteChildrenVisibility, + SpriteChildrenVisibilityIssue665, + SpriteChildrenAnchorPoint, + SpriteBatchNodeChildrenAnchorPoint, + SpriteBatchNodeChildrenScale, + SpriteChildrenChildren, + SpriteBatchNodeChildrenChildren, + SpriteNilTexture, + SpriteSubclass, + AnimationCacheTest, + SpriteOffsetAnchorSkew, + SpriteBatchNodeOffsetAnchorSkew, + SpriteOffsetAnchorSkewScale, + SpriteBatchNodeOffsetAnchorSkewScale, + SpriteOffsetAnchorFlip, + SpriteBatchNodeOffsetAnchorFlip, + SpriteBatchNodeReorderSameIndex, + SpriteBatchNodeReorderOneChild, + NodeSort, + SpriteSkewNegativeScaleChildren, + SpriteBatchNodeSkewNegativeScaleChildren, + SpriteDoubleResolution, + SpriteBatchBug1217, + AnimationCacheFile, + TextureColorCacheIssue, + TextureColorCacheIssue2, + TextureRotatedSpriteFrame, + SpriteWithRepeatingTexture, + SpriteBlendFuncTest +]; + +var nextSpriteTest = function () { + spriteTestIdx++; + spriteTestIdx = spriteTestIdx % arrayOfSpriteTest.length; + + if(window.sideIndexBar){ + spriteTestIdx = window.sideIndexBar.changeTest(spriteTestIdx, 36); + } + + return new arrayOfSpriteTest[spriteTestIdx ](); +}; +var previousSpriteTest = function () { + spriteTestIdx--; + if (spriteTestIdx < 0) + spriteTestIdx += arrayOfSpriteTest.length; + + if(window.sideIndexBar){ + spriteTestIdx = window.sideIndexBar.changeTest(spriteTestIdx, 36); + } + + return new arrayOfSpriteTest[spriteTestIdx ](); +}; +var restartSpriteTest = function () { + return new arrayOfSpriteTest[spriteTestIdx ](); +}; + diff --git a/tests/js-tests/src/SysTest/ScriptTestTempFile.js b/tests/js-tests/src/SysTest/ScriptTestTempFile.js new file mode 100644 index 0000000000..f9edd31553 --- /dev/null +++ b/tests/js-tests/src/SysTest/ScriptTestTempFile.js @@ -0,0 +1,38 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 ScriptTestTempLayer = cc.Layer.extend({ + ctor : function () { + this._super(); + + var labelTest = new cc.LabelTTF("this is the ScriptTestTempLayer old file", "Verdana", 32, cc.size(winSize.width, 50), cc.TEXT_ALIGNMENT_CENTER); + var size = cc.winSize; + labelTest.setPosition(size.width / 2, size.height / 4); + this.addChild(labelTest); + + } + +}); diff --git a/tests/js-tests/src/SysTest/SysTest.js b/tests/js-tests/src/SysTest/SysTest.js new file mode 100644 index 0000000000..bfa114b764 --- /dev/null +++ b/tests/js-tests/src/SysTest/SysTest.js @@ -0,0 +1,330 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + 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. + ****************************************************************************/ + +var sysTestSceneIdx = -1; +//------------------------------------------------------------------ +// +// SysTestBase +// +//------------------------------------------------------------------ +var SysTestBase = BaseTestLayer.extend({ + _title:"", + _subtitle:"", + + ctor:function() { + this._super(cc.color(0,0,0,255), cc.color(98,99,117,255)); + }, + + onRestartCallback:function (sender) { + var s = new SysTestScene(); + s.addChild(restartSysTest()); + director.runScene(s); + }, + onNextCallback:function (sender) { + var s = new SysTestScene(); + s.addChild(nextSysTest()); + director.runScene(s); + }, + onBackCallback:function (sender) { + var s = new SysTestScene(); + s.addChild(previousSysTest()); + director.runScene(s); + }, + // automation + numberOfPendingTests:function() { + return ( (arrayOfSysTest.length-1) - sysTestSceneIdx ); + }, + + getTestNumber:function() { + return sysTestSceneIdx; + } + +}); + +//------------------------------------------------------------------ +// +// LocalStorageTest +// +//------------------------------------------------------------------ +var LocalStorageTest = SysTestBase.extend({ + _title:"LocalStorage Test ", + _subtitle:"See the console", + + ctor:function () { + this._super(); + + var key = 'key_' + Math.random(); + var ls = cc.sys.localStorage; + cc.log(1); + ls.setItem(key, "Hello world"); + + cc.log(2); + var r = ls.getItem(key); + cc.log(r); + + cc.log(3); + ls.removeItem(key); + + cc.log(4); + r = ls.getItem(key); + cc.log(r); + } + +}); + +//------------------------------------------------------------------ +// +// CapabilitiesTest +// +//------------------------------------------------------------------ +var CapabilitiesTest = SysTestBase.extend({ + _title:"Capabilities Test ", + _subtitle:"See the console", + + ctor:function () { + this._super(); + + var c = cc.sys.capabilities; + for( var i in c ) + cc.log( i + " = " + c[i] ); + } + +}); + +var SysTestScene = TestScene.extend({ + runThisTest:function (num) { + sysTestSceneIdx = (num || num == 0) ? (num - 1) : -1; + var layer = nextSysTest(); + this.addChild(layer); + + director.runScene(this); + } +}); + +//------------------------------------------------------------------ +// +// Script dynamic reload test +// +//------------------------------------------------------------------ +var tempJSFileName = "ScriptTestTempFile.js"; +var ScriptTestLayer = SysTestBase.extend({ + _tempLayer:null, + _am : null, + startDownload:function () { + if (!cc.sys.isNative) + { + return; + } + var manifestPath = "Manifests/ScriptTest/project.manifest"; + var storagePath = ((jsb.fileUtils ? jsb.fileUtils.getWritablePath() : "/") + "JSBTests/AssetsManagerTest/ScriptTest/"); + cc.log("Storage path for this test : " + storagePath); + + if (this._am) + { + this._am.release(); + this._am = null; + } + + this._am = new jsb.AssetsManager(manifestPath, storagePath); + this._am.retain(); + if (!this._am.getLocalManifest().isLoaded()) + { + cc.log("Fail to update assets, step skipped."); + that.clickMeShowTempLayer(); + } + else { + var that = this; + var listener = new jsb.EventListenerAssetsManager(this._am, function (event) { + var scene; + switch (event.getEventCode()) { + case jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST: + cc.log("No local manifest file found, skip assets update."); + that.clickMeShowTempLayer(); + break; + case jsb.EventAssetsManager.UPDATE_PROGRESSION: + cc.log(event.getPercent() + "%"); + break; + case jsb.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST: + case jsb.EventAssetsManager.ERROR_PARSE_MANIFEST: + cc.log("Fail to download manifest file, update skipped."); + that.clickMeShowTempLayer(); + break; + case jsb.EventAssetsManager.ALREADY_UP_TO_DATE: + case jsb.EventAssetsManager.UPDATE_FINISHED: + cc.log("Update finished. " + event.getMessage()); + require(tempJSFileName); + that.clickMeShowTempLayer(); + break; + case jsb.EventAssetsManager.UPDATE_FAILED: + cc.log("Update failed. " + event.getMessage()); + break; + case jsb.EventAssetsManager.ERROR_UPDATING: + cc.log("Asset update error: " + event.getAssetId() + ", " + event.getMessage()); + break; + case jsb.EventAssetsManager.ERROR_DECOMPRESS: + cc.log(event.getMessage()); + break; + default: + break; + } + }); + cc.eventManager.addListener(listener, 1); + this._am.update(); + } + }, + clickMeShowTempLayer:function () { + this.removeChildByTag(233, true); + this._tempLayer = new ScriptTestTempLayer(); + this.addChild(this._tempLayer, 0, 233); + }, + clickMeReloadTempLayer:function(){ + cc.sys.cleanScript(tempJSFileName); + if (!cc.sys.isNative) + { + this.clickMeShowTempLayer(); + } + else + { + this.startDownload(); + } + + }, + onExit : function () { + if (this._am) + { + this._am.release(); + this._am = null; + } + + this._super(); + }, + ctor : function () { + this._super(); + + var menu = new cc.Menu(); + menu.setPosition(cc.p(0, 0)); + menu.width = winSize.width; + menu.height = winSize.height; + this.addChild(menu, 1); + var item1 = new cc.MenuItemLabel(new cc.LabelTTF("Click me show tempLayer", "Arial", 22), this.clickMeShowTempLayer, this); + menu.addChild(item1); + + var item2 = new cc.MenuItemLabel(new cc.LabelTTF("Click me reload tempLayer", "Arial", 22), this.clickMeReloadTempLayer, this); + menu.addChild(item2); + + menu.alignItemsVerticallyWithPadding(8); + menu.setPosition(cc.pAdd(cc.visibleRect.left, cc.p(+180, 0))); + }, + + getTitle : function() { + return "ScriptTest only used in native"; + } + +}); + +//------------------------------------------------------------------ +// +// Restart game test +// +//------------------------------------------------------------------ +var RestartGameLayerTest = SysTestBase.extend({ + getTitle : function() { + return "RestartGameTest only used in native"; + }, + restartGame:function() + { + cc.game.restart(); + }, + ctor : function () { + this._super(); + var menu = new cc.Menu(); + menu.setPosition(cc.p(0, 0)); + menu.width = winSize.width; + menu.height = winSize.height; + this.addChild(menu, 1); + var item1 = new cc.MenuItemLabel(new cc.LabelTTF("restartGame", "Arial", 22), this.restartGame, this); + menu.addChild(item1); + menu.setPosition(cc.pAdd(cc.visibleRect.left, cc.p(+180, 0))); + } +}); + +var OpenURLTest = SysTestBase.extend({ + getTitle:function(){ + return "Open URL Test"; + }, + + ctor:function(){ + this._super(); + + var label = new cc.LabelTTF("Touch the screen to open\nthe cocos2d-x home page", "Arial", 22); + this.addChild(label); + label.setPosition(cc.winSize.width/2, cc.winSize.height/2); + + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches: true, + onTouchBegan: function(){ + return true; + }, + onTouchEnded: function(){ + cc.sys.openURL("http://www.cocos2d-x.org/"); + } + }, this); + + } +}); + +// +// Flow control +// + +var arrayOfSysTest = [ + LocalStorageTest, + CapabilitiesTest, + OpenURLTest +]; + +if (cc.sys.isNative && cc.sys.OS_WINDOWS != cc.sys.os) { + arrayOfSysTest.push(ScriptTestLayer); + arrayOfSysTest.push(RestartGameLayerTest); +} + +var nextSysTest = function () { + sysTestSceneIdx++; + sysTestSceneIdx = sysTestSceneIdx % arrayOfSysTest.length; + + return new arrayOfSysTest[sysTestSceneIdx](); +}; +var previousSysTest = function () { + sysTestSceneIdx--; + if (sysTestSceneIdx < 0) + sysTestSceneIdx += arrayOfSysTest.length; + + return new arrayOfSysTest[sysTestSceneIdx](); +}; +var restartSysTest = function () { + return new arrayOfSysTest[sysTestSceneIdx](); +}; + diff --git a/tests/js-tests/src/TextInputTest/TextInputTest.js b/tests/js-tests/src/TextInputTest/TextInputTest.js new file mode 100644 index 0000000000..a2714cd4d6 --- /dev/null +++ b/tests/js-tests/src/TextInputTest/TextInputTest.js @@ -0,0 +1,424 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 TEXT_INPUT_FONT_NAME = "Thonburi"; +var TEXT_INPUT_FONT_SIZE = 36; + +var sceneIdx = -1; + +var textInputGetRect = function (node) { + var rc = cc.rect(node.x, node.y, node.width, node.height); + rc.x -= rc.width / 2; + rc.y -= rc.height / 2; + return rc; +}; + +/** + @brief TextInputTest for retain prev, reset, next, main menu buttons. + */ +var TextInputTest = cc.Layer.extend({ + notificationLayer:null, + ctor:function() { + this._super(); + this.init(); + }, + + restartCallback:function (sender) { + var scene = new TextInputTestScene(); + scene.addChild(restartTextInputTest()); + cc.director.runScene(scene); + }, + nextCallback:function (sender) { + var scene = new TextInputTestScene(); + scene.addChild(nextTextInputTest()); + cc.director.runScene(scene); + }, + backCallback:function (sender) { + var scene = new TextInputTestScene(); + scene.addChild(previousTextInputTest()); + cc.director.runScene(scene); + }, + + title:function () { + return "text input test"; + }, + + addKeyboardNotificationLayer:function (layer) { + this.notificationLayer = layer; + this.addChild(layer); + }, + + onEnter:function () { + this._super(); + + var winSize = cc.director.getWinSize(); + + var label = new cc.LabelTTF(this.title(), "Arial", 24); + this.addChild(label); + label.x = winSize.width / 2; + label.y = winSize.height - 50; + + var subTitle = this.subtitle(); + if (subTitle && subTitle !== "") { + var l = new cc.LabelTTF(subTitle, "Thonburi", 16); + this.addChild(l, 1); + l.x = winSize.width / 2; + l.y = winSize.height - 80; + } + + var item1 = new cc.MenuItemImage(s_pathB1, s_pathB2, this.backCallback, this); + var item2 = new cc.MenuItemImage(s_pathR1, s_pathR2, this.restartCallback, this); + var item3 = new cc.MenuItemImage(s_pathF1, s_pathF2, this.nextCallback, this); + + var menu = new cc.Menu(item1, item2, item3); + menu.x = 0; + menu.y = 0; + item1.x = winSize.width / 2 - 100; + item1.y = 30; + item2.x = winSize.width / 2; + item2.y = 30; + item3.x = winSize.width / 2 + 100; + item3.y = 30; + + this.addChild(menu, 1); + } +}); + +////////////////////////////////////////////////////////////////////////// +// KeyboardNotificationLayer for test IME keyboard notification. +////////////////////////////////////////////////////////////////////////// +var KeyboardNotificationLayer = TextInputTest.extend({ + _trackNode:null, + _beginPos:null, + + ctor:function () { + this._super(); + + if( 'touches' in cc.sys.capabilities ){ + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesEnded: this.onTouchesEnded + }, this); + } else if ('mouse' in cc.sys.capabilities ) + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseUp: this.onMouseUp + }, this); + }, + + subtitle:function () { + return ""; + }, + + onClickTrackNode:function (clicked) { + }, + + keyboardWillShow:function (info) { + cc.log("TextInputTest:keyboardWillShowAt(origin:" + info.end.x + "," + info.end.y + + ", size:" + info.end.width + "," + info.end.height + ")"); + + if (!this._trackNode) + return; + + var rectTracked = textInputGetRect(this._trackNode); + cc.log("TextInputTest:trackingNodeAt(origin:" + info.end.x + "," + info.end.y + + ", size:" + info.end.width + "," + info.end.height + ")"); + + // if the keyboard area doesn't intersect with the tracking node area, nothing need to do. + if (!cc.rectIntersectsRect(rectTracked, info.end)) + return; + + // assume keyboard at the bottom of screen, calculate the vertical adjustment. + var adjustVert = cc.rectGetMaxY(info.end) - cc.rectGetMinY(rectTracked); + cc.log("TextInputTest:needAdjustVerticalPosition(" + adjustVert + ")"); + + // move all the children node of KeyboardNotificationLayer + var children = this.children; + for (var i = 0; i < children.length; ++i) { + var node = children[i]; + node.y += adjustVert; + } + }, + + onTouchesEnded:function (touches, event) { + var target = event.getCurrentTarget(); + if (!target._trackNode) + return; + + // grab first touch + if(touches.length == 0) + return; + + var touch = touches[0]; + var point = touch.getLocation(); + + // decide the trackNode is clicked. + cc.log("KeyboardNotificationLayer:clickedAt(" + point.x + "," + point.y + ")"); + + var rect = textInputGetRect(target._trackNode); + cc.log("KeyboardNotificationLayer:TrackNode at(origin:" + rect.x + "," + rect.y + + ", size:" + rect.width + "," + rect.height + ")"); + + target.onClickTrackNode(cc.rectContainsPoint(rect, point)); + cc.log("----------------------------------"); + }, + + onMouseUp:function (event) { + var target = event.getCurrentTarget(); + if (!target._trackNode) + return; + + var point = event.getLocation(); + + // decide the trackNode is clicked. + cc.log("KeyboardNotificationLayer:clickedAt(" + point.x + "," + point.y + ")"); + + var rect = textInputGetRect(target._trackNode); + cc.log("KeyboardNotificationLayer:TrackNode at(origin:" + rect.x + "," + rect.y + + ", size:" + rect.width + "," + rect.height + ")"); + + target.onClickTrackNode(cc.rectContainsPoint(rect, point)); + cc.log("----------------------------------"); + } +}); + +////////////////////////////////////////////////////////////////////////// +// TextFieldTTFDefaultTest for test TextFieldTTF default behavior. +////////////////////////////////////////////////////////////////////////// +var TextFieldTTFDefaultTest = KeyboardNotificationLayer.extend({ + subtitle:function () { + return "TextFieldTTF with default behavior test"; + }, + onClickTrackNode:function (clicked) { + var textField = this._trackNode; + if (clicked) { + // TextFieldTTFTest be clicked + cc.log("TextFieldTTFDefaultTest:CCTextFieldTTF attachWithIME"); + textField.attachWithIME(); + } else { + // TextFieldTTFTest not be clicked + cc.log("TextFieldTTFDefaultTest:CCTextFieldTTF detachWithIME"); + textField.detachWithIME(); + } + }, + + onEnter:function () { + this._super(); + + // add CCTextFieldTTF + var winSize = cc.director.getWinSize(); + + var textField = new cc.TextFieldTTF("", + TEXT_INPUT_FONT_NAME, + TEXT_INPUT_FONT_SIZE); + this.addChild(textField); + textField.x = winSize.width / 2; + textField.y = winSize.height / 2; + + this._trackNode = textField; + } +}); + +////////////////////////////////////////////////////////////////////////// +// TextFieldTTFActionTest +////////////////////////////////////////////////////////////////////////// +var TextFieldTTFActionTest = KeyboardNotificationLayer.extend({ + _textField:null, + _textFieldAction:null, + _action:false, + _charLimit:0, // the textfield max char limit + + ctor:function () { + this._super(); + }, + + callbackRemoveNodeWhenDidAction:function (node) { + this.removeChild(node, true); + }, + + // KeyboardNotificationLayer + subtitle:function () { + return "CCTextFieldTTF with action and char limit test"; + }, + onClickTrackNode:function (clicked) { + var textField = this._trackNode; + if (clicked) { + // TextFieldTTFTest be clicked + cc.log("TextFieldTTFActionTest:CCTextFieldTTF attachWithIME"); + textField.attachWithIME(); + } else { + // TextFieldTTFTest not be clicked + cc.log("TextFieldTTFActionTest:CCTextFieldTTF detachWithIME"); + textField.detachWithIME(); + } + }, + + //CCLayer + onEnter:function () { + this._super(); + + this._charLimit = 20; + this._textFieldAction = cc.sequence( + cc.fadeOut(0.25), + cc.fadeIn(0.25) + ).repeatForever(); + this._action = false; + + // add CCTextFieldTTF + var winSize = cc.director.getWinSize(); + + this._textField = new cc.TextFieldTTF("", + TEXT_INPUT_FONT_NAME, + TEXT_INPUT_FONT_SIZE); + this.addChild(this._textField); + this._textField.setDelegate(this); + + this._textField.x = winSize.width / 2; + this._textField.y = winSize.height / 2; + this._trackNode = this._textField; + }, + + //CCTextFieldDelegate + onTextFieldAttachWithIME:function (sender) { + if (!this._action) { + this._textField.runAction(this._textFieldAction); + this._action = true; + } + return false; + }, + onTextFieldDetachWithIME:function (sender) { + if (this._action) { + this._textField.stopAction(this._textFieldAction); + this._textField.opacity = 255; + this._action = false; + } + return false; + }, + onTextFieldInsertText:function (sender, text, len) { + // if insert enter, treat as default to detach with ime + if ('\n' == text) { + return false; + } + + // if the textfield's char count more than m_nCharLimit, doesn't insert text anymore. + if (sender.getCharCount() >= this._charLimit) { + return true; + } + + // create a insert text sprite and do some action + var label = new cc.LabelTTF(text, TEXT_INPUT_FONT_NAME, TEXT_INPUT_FONT_SIZE); + this.addChild(label); + var color = cc.color(226, 121, 7); + label.color = color; + + // move the sprite from top to position + var endX = sender.x, endY = sender.y; + if (sender.getCharCount()) { + endX += sender.width / 2; + } + + var duration = 0.5; + label.x = endX; + label.y = cc.director.getWinSize().height - label.height * 2; + label.scale = 8; + + var seq = cc.sequence( + cc.spawn( + cc.moveTo(duration, cc.p(endX, endY)), + cc.scaleTo(duration, 1), + cc.fadeOut(duration)), + cc.callFunc(this.callbackRemoveNodeWhenDidAction, this)); + label.runAction(seq); + return false; + }, + + onTextFieldDeleteBackward:function (sender, delText, len) { + // create a delete text sprite and do some action + var label = new cc.LabelTTF(delText, TEXT_INPUT_FONT_NAME, TEXT_INPUT_FONT_SIZE); + this.addChild(label); + + // move the sprite to fly out + var beginX = sender.x, beginY = sender.y; + beginX += (sender.width - label.width) / 2.0; + + var winSize = cc.director.getWinSize(); + var endPos = cc.p(-winSize.width / 4.0, winSize.height * (0.5 + Math.random() / 2.0)); + + var duration = 1; + var rotateDuration = 0.2; + var repeatTime = 5; + label.x = beginX; + label.y = beginY; + + var seq = cc.sequence( + cc.spawn( + cc.moveTo(duration, endPos), + cc.rotateBy(rotateDuration, (Math.random() % 2) ? 360 : -360).repeat(repeatTime), + cc.fadeOut(duration)), + cc.callFunc(this.callbackRemoveNodeWhenDidAction, this)); + label.runAction(seq); + return false; + }, + onDraw:function (sender) { + return false; + } +}); + +var TextInputTestScene = TestScene.extend({ + runThisTest:function (num) { + sceneIdx = (num || num == 0) ? (num - 1) : -1; + var layer = nextTextInputTest(); + + this.addChild(layer); + cc.director.runScene(this); + } +}); + +// +// Flow control +// +var arrayOfTextInputTest = [ + TextFieldTTFDefaultTest, + TextFieldTTFActionTest +]; + +var nextTextInputTest = function () { + sceneIdx++; + sceneIdx = sceneIdx % arrayOfTextInputTest.length; + + return new arrayOfTextInputTest[sceneIdx](); +}; +var previousTextInputTest = function () { + sceneIdx--; + if (sceneIdx < 0) + sceneIdx += arrayOfTextInputTest.length; + + return new arrayOfTextInputTest[sceneIdx](); +}; +var restartTextInputTest = function () { + return new arrayOfTextInputTest[sceneIdx](); +}; + diff --git a/tests/js-tests/src/TextureCacheTest/TextureCacheTest.js b/tests/js-tests/src/TextureCacheTest/TextureCacheTest.js new file mode 100644 index 0000000000..0b6b819726 --- /dev/null +++ b/tests/js-tests/src/TextureCacheTest/TextureCacheTest.js @@ -0,0 +1,266 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 TextureCacheTestBase = BaseTestLayer.extend({ + _title:"", + _subtitle:"", + + ctor:function() { + this._super(cc.color(0,0,0,255), cc.color(98,99,117,255)); + }, + + onRestartCallback:function (sender) { + var s = new TexCacheTestScene(); + s.addChild(restartTexCacheTest()); + director.runScene(s); + }, + onNextCallback:function (sender) { + var s = new TexCacheTestScene(); + s.addChild(nextTexCacheTest()); + director.runScene(s); + }, + onBackCallback:function (sender) { + var s = new TexCacheTestScene(); + s.addChild(previousTexCacheTest()); + director.runScene(s); + } +}); + +var TextureCacheTest = TextureCacheTestBase.extend({ + _title:"Texture Cache Loading Test", + _labelLoading:null, + _labelPercent:null, + _numberOfSprites:20, + _numberOfLoadedSprites:0, + ctor:function () { + this._super(); + + var size = cc.director.getWinSize(); + + this._labelLoading = new cc.LabelTTF("loading...", "Arial", 15); + this._labelPercent = new cc.LabelTTF("%0", "Arial", 15); + + this._labelLoading.x = size.width / 2; + + this._labelLoading.y = size.height / 2 - 20; + this._labelPercent.x = size.width / 2; + this._labelPercent.y = size.height / 2 + 20; + + this.addChild(this._labelLoading); + this.addChild(this._labelPercent); + + var texCache = cc.textureCache; + // load textrues + texCache.addImageAsync("res/Images/HelloWorld.png", this.loadingCallBack, this); + texCache.addImageAsync("res/Images/grossini.png", this.loadingCallBack, this); + texCache.addImageAsync("res/Images/grossini_dance_01.png", this.loadingCallBack, this); + texCache.addImageAsync("res/Images/grossini_dance_02.png", this.loadingCallBack, this); + texCache.addImageAsync("res/Images/grossini_dance_03.png", this.loadingCallBack, this); + texCache.addImageAsync("res/Images/grossini_dance_04.png", this.loadingCallBack, this); + texCache.addImageAsync("res/Images/grossini_dance_05.png", this.loadingCallBack, this); + texCache.addImageAsync("res/Images/grossini_dance_06.png", this.loadingCallBack, this); + texCache.addImageAsync("res/Images/grossini_dance_07.png", this.loadingCallBack, this); + texCache.addImageAsync("res/Images/grossini_dance_08.png", this.loadingCallBack, this); + texCache.addImageAsync("res/Images/grossini_dance_09.png", this.loadingCallBack, this); + texCache.addImageAsync("res/Images/grossini_dance_10.png", this.loadingCallBack, this); + texCache.addImageAsync("res/Images/grossini_dance_11.png", this.loadingCallBack, this); + texCache.addImageAsync("res/Images/grossini_dance_12.png", this.loadingCallBack, this); + texCache.addImageAsync("res/Images/grossini_dance_13.png", this.loadingCallBack, this); + texCache.addImageAsync("res/Images/grossini_dance_14.png", this.loadingCallBack, this); + texCache.addImageAsync("res/Images/background1.png", this.loadingCallBack, this); + texCache.addImageAsync("res/Images/background2.png", this.loadingCallBack, this); + texCache.addImageAsync("res/Images/background3.png", this.loadingCallBack, this); + texCache.addImageAsync("res/Images/blocks.png", this.loadingCallBack, this); + }, + addSprite:function () { + var size = cc.director.getWinSize(); + + // create sprites + var bg = new cc.Sprite("res/Images/HelloWorld.png"); + bg.x = size.width / 2; + bg.y = size.height / 2; + //bg.scale = 1.7; + + var s1 = new cc.Sprite("res/Images/grossini.png"); + var s2 = new cc.Sprite("res/Images/grossini_dance_01.png"); + var s3 = new cc.Sprite("res/Images/grossini_dance_02.png"); + var s4 = new cc.Sprite("res/Images/grossini_dance_03.png"); + var s5 = new cc.Sprite("res/Images/grossini_dance_04.png"); + var s6 = new cc.Sprite("res/Images/grossini_dance_05.png"); + var s7 = new cc.Sprite("res/Images/grossini_dance_06.png"); + var s8 = new cc.Sprite("res/Images/grossini_dance_07.png"); + var s9 = new cc.Sprite("res/Images/grossini_dance_08.png"); + var s10 = new cc.Sprite("res/Images/grossini_dance_09.png"); + var s11 = new cc.Sprite("res/Images/grossini_dance_10.png"); + var s12 = new cc.Sprite("res/Images/grossini_dance_11.png"); + var s13 = new cc.Sprite("res/Images/grossini_dance_12.png"); + var s14 = new cc.Sprite("res/Images/grossini_dance_13.png"); + var s15 = new cc.Sprite("res/Images/grossini_dance_14.png"); + + // just loading textures to slow down + var s16 = new cc.Sprite("res/Images/background1.png"); + var s17 = new cc.Sprite("res/Images/background2.png"); + var s18 = new cc.Sprite("res/Images/background3.png"); + var s19 = new cc.Sprite("res/Images/blocks.png"); + + s1.x = 50; + s1.y = 50; + s2.x = 60; + s2.y = 50; + s3.x = 70; + s3.y = 50; + s4.x = 80; + s4.y = 50; + s5.x = 90; + s5.y = 50; + s6.x = 100; + s6.y = 50; + + s7.x = 50; + s7.y = 180; + s8.x = 60; + s8.y = 180; + s9.x = 70; + s9.y = 180; + s10.x = 80; + s10.y = 180; + s11.x = 90; + s11.y = 180; + s12.x = 100; + s12.y = 180; + + s13.x = 50; + s13.y = 270; + s14.x = 60; + s14.y = 270; + s15.x = 70; + s15.y = 270; + + this.addChild(bg); + + this.addChild(s1); + this.addChild(s2); + this.addChild(s3); + this.addChild(s4); + this.addChild(s5); + this.addChild(s6); + this.addChild(s7); + this.addChild(s8); + this.addChild(s9); + this.addChild(s10); + this.addChild(s11); + this.addChild(s12); + this.addChild(s13); + this.addChild(s14); + this.addChild(s15); + }, + loadingCallBack:function (obj) { + ++this._numberOfLoadedSprites; + this._labelPercent.setString((this._numberOfLoadedSprites / this._numberOfSprites) * 100 + ''); + if (this._numberOfLoadedSprites == this._numberOfSprites) { + this.removeChild(this._labelLoading, true); + this.removeChild(this._labelPercent, true); + this.addSprite(); + } + } +}); + +var RemoteTextureTest = TextureCacheTestBase.extend({ + _title:"Remote Texture Test", + _subtitle:"", + _remoteTex: "http://cn.cocos2d-x.org/image/logo.png", + _sprite : null, + onEnter:function () { + this._super(); + if('opengl' in cc.sys.capabilities && !cc.sys.isNative){ + var label = new cc.LabelTTF("Not support Loading texture from remote site on HTML5-WebGL", "Times New Roman", 28); + label.x = winSize.width / 2; + label.y = winSize.height / 2; + this.addChild(label, 100); + } else + this.scheduleOnce(this.startDownload, 0.1); + }, + + startDownload: function() { + cc.textureCache.addImageAsync(this._remoteTex, this.texLoaded, this); + }, + + texLoaded: function(texture) { + if (texture instanceof cc.Texture2D) { + cc.log("Remote texture loaded: " + this._remoteTex); + if (this._sprite) { + this.removeChild(this._sprite); + } + this._sprite = new cc.Sprite(texture); + this._sprite.x = cc.winSize.width/2; + this._sprite.y = cc.winSize.height/2; + this.addChild(this._sprite); + } + else { + cc.log("Fail to load remote texture"); + } + } +}); + + +// +// Flow control +// + +var texCacheTestSceneIdx = -1; + +var TexCacheTestScene = TestScene.extend({ + runThisTest:function (num) { + texCacheTestSceneIdx = (num || num == 0) ? (num - 1) : -1; + var layer = nextTexCacheTest(); + this.addChild(layer); + + cc.director.runScene(this); + } +}); + +var arrayOfTexCacheTest = [ + TextureCacheTest, + RemoteTextureTest +]; + +var nextTexCacheTest = function () { + texCacheTestSceneIdx++; + texCacheTestSceneIdx = texCacheTestSceneIdx % arrayOfTexCacheTest.length; + + return new arrayOfTexCacheTest[texCacheTestSceneIdx](); +}; +var previousTexCacheTest = function () { + texCacheTestSceneIdx--; + if (texCacheTestSceneIdx < 0) + texCacheTestSceneIdx += arrayOfTexCacheTest.length; + + return new arrayOfTexCacheTest[texCacheTestSceneIdx](); +}; +var restartTexCacheTest = function () { + return new arrayOfTexCacheTest[texCacheTestSceneIdx](); +}; + diff --git a/tests/js-tests/src/TileMapTest/TileMapTest.js b/tests/js-tests/src/TileMapTest/TileMapTest.js new file mode 100644 index 0000000000..7cf21293dc --- /dev/null +++ b/tests/js-tests/src/TileMapTest/TileMapTest.js @@ -0,0 +1,1733 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 TAG_TILE_MAP = 1; +var tileTestSceneIdx = -1; +//------------------------------------------------------------------ +// +// TileDemo +// +//------------------------------------------------------------------ +var TileDemoProps = { + ctor:function () { + this._super(); + + if ('touches' in cc.sys.capabilities){ + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesMoved: function (touches, event) { + var touch = touches[0]; + var delta = touch.getDelta(); + + var node = event.getCurrentTarget().getChildByTag(TAG_TILE_MAP); + node.x += delta.x; + node.y += delta.y; + } + }, this); + } else if ('mouse' in cc.sys.capabilities) + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseMove: function(event){ + if(event.getButton() == cc.EventMouse.BUTTON_LEFT){ + var node = event.getCurrentTarget().getChildByTag(TAG_TILE_MAP); + node.x += event.getDeltaX(); + node.y += event.getDeltaY(); + } + } + }, this); + }, + title:function () { + return "No title"; + }, + subtitle:function () { + return "drag the screen"; + }, + + onRestartCallback:function (sender) { + var s = new TileMapTestScene(); + s.addChild(restartTileMapTest()); + director.runScene(s); + }, + onNextCallback:function (sender) { + var s = new TileMapTestScene(); + s.addChild(nextTileMapTest()); + director.runScene(s); + }, + onBackCallback:function (sender) { + var s = new TileMapTestScene(); + s.addChild(previousTileMapTest()); + director.runScene(s); + }, + // automation + numberOfPendingTests:function () { + return ( (arrayOfTileMapTest.length - 1) - tileTestSceneIdx ); + }, + getTestNumber:function () { + return tileTestSceneIdx; + } +}; +var TileDemo = BaseTestLayer.extend(TileDemoProps); + +/******************for vertexz bug**************/ +var FixBugBaseTest = cc.Layer.extend(BaseTestLayerProps); +var TMXFixBugLayer = FixBugBaseTest.extend(TileDemoProps); +/***********************************************************/ + +var TileMapTest = TileDemo.extend({ + ctor:function () { + this._super(); + var map = new cc.TileMapAtlas(s_tilesPng, s_levelMapTga, 16, 16); + if ("opengl" in cc.sys.capabilities) + map.texture.setAntiAliasTexParameters(); + + this.log("ContentSize: " + map.width + " " + map.height); + + map.releaseMap(); + + this.addChild(map, 0, TAG_TILE_MAP); + + map.anchorX = 0; + map.anchorY = 0.5; + + var scale = cc.scaleBy(4, 0.8); + var scaleBack = scale.reverse(); + + var seq = cc.sequence(scale, scaleBack); + + map.runAction(seq.repeatForever()); + }, + title:function () { + return "TileMapAtlas"; + } +}); + +var TileMapEditTest = TileDemo.extend({ + ctor:function () { + this._super(); + var map = new cc.TileMapAtlas(s_tilesPng, s_levelMapTga, 16, 16); + // Create an Aliased Atlas + map.texture.setAliasTexParameters(); + this.log("ContentSize: " + map.width + " " + map.height); + + // If you are not going to use the Map, you can free it now + // [tilemap releaseMap); + // And if you are going to use, it you can access the data with: + + this.schedule(this.updateMap, 0.2);//:@selector(updateMap:) interval:0.2f); + + this.addChild(map, 0, TAG_TILE_MAP); + + map.anchorX = 0; + map.anchorY = 0; + map.x = -20; + map.y = -200; + + }, + title:function () { + return "Editable TileMapAtlas"; + }, + updateMap:function (dt) { + // IMPORTANT + // The only limitation is that you cannot change an empty, or assign an empty tile to a tile + // The value 0 not rendered so don't assign or change a tile with value 0 + + var tilemap = this.getChildByTag(TAG_TILE_MAP); + + // NEW since v0.7 + var c = tilemap.getTileAt(cc.p(13, 21)); + c.r++; + c.r %= 50; + if (c.r == 0) + c.r = 1; + + // NEW since v0.7 + tilemap.setTile(c, cc.p(13, 21)); + } +}); + +//------------------------------------------------------------------ +// +// TMXOrthoTest +// +//------------------------------------------------------------------ +var TMXOrthoTest = TileDemo.extend({ + ctor:function () { + this._super(); + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/orthogonal-test1.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + map.runAction(new cc.ScaleBy(2, 0.5)); + }, + title:function () { + return "TMX Ortho test"; + }, + + // Automation + testDuration:2.1, + pixel1:{"0":218, "1":218, "2":208, "3":255}, + pixel2:{"0":193, "1":143, "2":72, "3":255}, + pixel3:{"0":200, "1":15, "2":160, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(82, 114, 10, 10); + var ret2 = this.readPixels(475, 100, 10, 10); + var ret3 = this.readPixels(312, 196, 10, 10); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1, false) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2, false) ? "yes" : "no", + "pixel3":this.containsPixel(ret3, this.pixel3, true,5) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXOrthoTest2 +// +//------------------------------------------------------------------ +var TMXOrthoTest2 = TileDemo.extend({ + ctor:function () { + this._super(); + // + // Test orthogonal with 3d camera and anti-alias textures + // + // it should not flicker. No artifacts should appear + // + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/orthogonal-test2.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + }, + title:function () { + return "TMX Orthogonal test 2"; + }, + onEnter:function () { + this._super(); + director.setProjection(cc.Director.PROJECTION_3D); + }, + onExit:function () { + this._super(); + director.setProjection(cc.Director.PROJECTION_2D); + }, + + // Automation + pixel1:{"0":192, "1":144, "2":16, "3":255}, + pixel2:{"0":255, "1":255, "2":255, "3":255}, + pixel3:{"0":40, "1":0, "2":0, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(99, 142, 5, 5); + var ret2 = this.readPixels(238, 270, 5, 5); + var ret3 = this.readPixels(419, 239, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1, false) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2, false) ? "yes" : "no", + "pixel3":this.containsPixel(ret3, this.pixel3, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + + +//------------------------------------------------------------------ +// +// TMXOrthoTest3 +// +//------------------------------------------------------------------ +var TMXOrthoTest3 = TileDemo.extend({ + ctor:function () { + this._super(); + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/orthogonal-test3.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + map.scale = 0.2; + map.anchorX = 0.5; + map.anchorY = 0.5; + }, + title:function () { + return "TMX anchorPoint test"; + }, + + // Automation + pixel1:{"0":247, "1":196, "2":131, "3":255}, + pixel2:{"0":0, "1":0, "2":0, "3":255}, + pixel3:{"0":0, "1":0, "2":0, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(0, 0, 10, 10); + var ret2 = this.readPixels(107, 58, 10, 10); + var ret3 = this.readPixels(58, 107, 10, 10); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1, false) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2, false) ? "yes" : "no", + "pixel3":this.containsPixel(ret3, this.pixel3, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXOrthoTest4 +// +//------------------------------------------------------------------ +var TMXOrthoTest4 = TileDemo.extend({ + ctor:function () { + this._super(); + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/orthogonal-test4.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + map.anchorX = 0; + map.anchorY = 0; + + var layer = map.getLayer("Layer 0"); + var s = layer.getLayerSize(); + + this.tx = s.width - 10; + this.ty = s.height - 1; + + var sprite; + sprite = layer.getTileAt(cc.p(0, 0)); + sprite.scale = 2; + + sprite = layer.getTileAt(cc.p(s.width - 1, 0)); + sprite.scale = 2; + + sprite = layer.getTileAt(cc.p(0, s.height - 1)); + sprite.scale = 2; + + sprite = layer.getTileAt(cc.p(s.width - 1, s.height - 1)); + sprite.scale = 2; + + this.scheduleOnce(this.onRemoveSprite, 0.2); + }, + onRemoveSprite:function (dt) { + var map = this.getChildByTag(TAG_TILE_MAP); + + var layer = map.getLayer("Layer 0"); + var layerSize = layer.getLayerSize(); + + var sprite = layer.getTileAt(cc.p(layerSize.width - 1, 0)); + layer.removeChild(sprite, true); + + this.testLayerSize = layerSize; + }, + title:function () { + return "TMX width/height test"; + }, + + // + // Automation + // + testDuration:3, + testLayerSize:null, + pixel:{"0":0, "1":0, "2":0, "3":255}, + getExpectedResult:function () { + var ret = {"width":14, "height":8, "pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(433, 240, 10, 10); + var ret = {"width":this.testLayerSize.width, "height":this.testLayerSize.height, "pixel":this.containsPixel(ret1, this.pixel, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + + +//------------------------------------------------------------------ +// +// TMXReadWriteTest +// +//------------------------------------------------------------------ +var TMXReadWriteTest = TileDemo.extend({ + gid:0, + ctor:function () { + this._super(); + + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/orthogonal-test2.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + var layer = map.getLayer("Layer 0"); + if ("opengl" in cc.sys.capabilities) + layer.texture.setAntiAliasTexParameters(); + + map.scale = 1; + + var tile0 = layer.getTileAt(cc.p(1, 63)); + var tile1 = layer.getTileAt(cc.p(2, 63)); + var tile2 = layer.getTileAt(cc.p(3, 62));//cc.p(1,62)); + var tile3 = layer.getTileAt(cc.p(2, 62)); + + tile0.anchorX = 0.5; + tile0.anchorY = 0.5; + tile1.anchorX = 0.5; + tile1.anchorY = 0.5; + tile2.anchorX = 0.5; + tile2.anchorY = 0.5; + tile3.anchorX = 0.5; + tile3.anchorY = 0.5; + + var move = cc.moveBy(0.5, cc.p(0, 160)); + var rotate = cc.rotateBy(2, 360); + var scale = cc.scaleBy(2, 5); + var opacity = cc.fadeOut(2); + var fadein = cc.fadeIn(2); + var scaleback = cc.scaleTo(1, 1); + var finish = cc.callFunc(this.onRemoveSprite); // 'this' is optional. Since it is not used, it is not passed. + + var seq0 = cc.sequence(move, rotate, scale, opacity, fadein, scaleback, finish); + + tile0.runAction(seq0); + tile1.runAction(seq0.clone()); + tile2.runAction(seq0.clone()); + tile3.runAction(seq0.clone()); + + this.gid = layer.getTileGIDAt(cc.p(0, 63)); + + this.schedule(this.updateCol, 2.0); + this.schedule(this.repaintWithGID, 2.0); + this.schedule(this.removeTiles, 1.0); + + this.gid2 = 0; + }, + onRemoveSprite:function (sender) { + var p = sender.parent; + if (p) { + p.removeChild(sender, true); + } + }, + updateCol:function (dt) { + var map = this.getChildByTag(TAG_TILE_MAP); + var layer = map.getChildByTag(0); + + var s = layer.getLayerSize(); + + for (var y = 0; y < s.height; y++) { + layer.setTileGID(this.gid2, cc.p(3, y)); + } + + this.gid2 = (this.gid2 + 1) % 80; + }, + repaintWithGID:function (dt) { + + var map = this.getChildByTag(TAG_TILE_MAP); + var layer = map.getChildByTag(0); + + var s = layer.getLayerSize(); + for (var x = 0; x < s.width; x++) { + var y = s.height - 1; + var tmpgid = layer.getTileGIDAt(cc.p(x, y)); + layer.setTileGID(tmpgid + 1, cc.p(x, y)); + } + }, + removeTiles:function (dt) { + this.unschedule(this.removeTiles); + + var map = this.getChildByTag(TAG_TILE_MAP); + + var layer = map.getChildByTag(0); + var s = layer.getLayerSize(); + + for (var y = 0; y < s.height; y++) { + layer.removeTileAt(cc.p(5.0, y)); + } + }, + title:function () { + return "TMX Read/Write test"; + }, + + // + // Automation + // + testDuration:2.2, + pixel1:{"0":0, "1":144, "2":0, "3":255}, + pixel2:{"0":192, "1":144, "2":16, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(168, 203, 5, 5); + var ret2 = this.readPixels(239, 239, 5, 5); + var ret = {"pixel1":!this.containsPixel(ret1, this.pixel1, false) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXHexTest +// +//------------------------------------------------------------------ +var TMXHexTest = TileDemo.extend({ + ctor:function () { + this._super(); + var color = new cc.LayerColor(cc.color(64, 64, 64, 255)); + this.addChild(color, -1); + + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/hexa-test.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + }, + title:function () { + return "TMX Hex test"; + }, + + // + // Automation + // + pixel1:{"0":250, "1":202, "2":73, "3":255}, + pixel2:{"0":150, "1":219, "2":10, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(438, 226, 10, 10); + var ret2 = this.readPixels(195, 0, 10, 10); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1, false) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXIsoTest +// +//------------------------------------------------------------------ +var TMXIsoTest = TileDemo.extend({ + ctor:function () { + this._super(); + var color = new cc.LayerColor(cc.color(64, 64, 64, 255)); + this.addChild(color, -1); + + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/iso-test.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + // move map to the center of the screen + var ms = map.getMapSize(); + var ts = map.getTileSize(); + map.runAction(cc.moveTo(1.0, cc.p(-ms.width * ts.width / 2, -ms.height * ts.height / 2))); + }, + title:function () { + return "TMX Isometric test 0"; + }, + + // + // Automation + // + pixel:{"0":0, "1":0, "2":0, "3":255}, + getExpectedResult:function () { + var ret = {"pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = true; + for (var i = 0; i < 6; i++) { + var item = this.readPixels(438, 226, 3, 3); + if (!this.containsPixel(item, this.pixel, false)) { + ret1 = false; + } + } + var ret = { "pixel":ret1 == true ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXIsoTest1 +// +//------------------------------------------------------------------ +var TMXIsoTest1 = TileDemo.extend({ + ctor:function () { + this._super(); + var color = new cc.LayerColor(cc.color(64, 64, 64, 255)); + this.addChild(color, -1); + + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/iso-test1.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + map.anchorX = 0.5; + map.anchorY = 0.5; + }, + title:function () { + return "TMX Isometric test + anchorPoint"; + }, + + // + // Automation + // + pixel:{"0":0, "1":0, "2":0, "3":255}, + getExpectedResult:function () { + var ret = {"pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = true; + for (var i = 0; i < 6; i++) { + var item = this.readPixels(438, 226, 3, 3); + if (!this.containsPixel(item, this.pixel, false)) { + ret1 = false; + } + } + var ret = { "pixel":ret1 == true ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXIsoTest2 +// +//------------------------------------------------------------------ +var TMXIsoTest2 = TileDemo.extend({ + ctor:function () { + this._super(); + var color = new cc.LayerColor(cc.color(64, 64, 64, 255)); + this.addChild(color, -1); + + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/iso-test2.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + // move map to the center of the screen + var ms = map.getMapSize(); + var ts = map.getTileSize(); + map.runAction(cc.moveTo(1.0, cc.p(-ms.width * ts.width / 2, -ms.height * ts.height / 2))); + }, + title:function () { + return "TMX Isometric test 2"; + }, + + // + // Automation + // + testDuration:1.2, + pixel:{"0":0, "1":0, "2":0, "3":255}, + getExpectedResult:function () { + var ret = {"pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = true; + for (var i = 1; i < 6; i++) { + var item = this.readPixels(62 * i, 191, 5, 5); + if (!this.containsPixel(item, this.pixel, true, 2)) { + ret1 = false; + } + } + var ret = { "pixel":ret1 == true ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXUncompressedTest +// +//------------------------------------------------------------------ +var TMXUncompressedTest = TileDemo.extend({ + ctor:function () { + this._super(); + var color = new cc.LayerColor(cc.color(64, 64, 64, 255)); + this.addChild(color, -1); + + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/iso-test2-uncompressed.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + // move map to the center of the screen + var ms = map.getMapSize(); + var ts = map.getTileSize(); + map.runAction(cc.moveTo(1.0, cc.p(-ms.width * ts.width / 2, -ms.height * ts.height / 2))); + + // testing release map + var childrenArray = map.children; + var layer = null; + for (var i = 0, len = childrenArray.length; i < len; i++) { + layer = childrenArray[i]; + if (!layer) + break; + + layer.releaseMap(); + } + }, + title:function () { + return "TMX Uncompressed test"; + }, + + // + // Automation + // + testDuration:1.2, + pixel:{"0":0, "1":0, "2":0, "3":255}, + getExpectedResult:function () { + var ret = {"pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = true; + for (var i = 1; i < 6; i++) { + var item = this.readPixels(62 * i, 191, 5, 5); + if (!this.containsPixel(item, this.pixel, true, 2)) { + ret1 = false; + } + } + var ret = { "pixel":ret1 == true ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXTilesetTest +// +//------------------------------------------------------------------ +var TMXTilesetTest = TileDemo.extend({ + ctor:function () { + this._super(); + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/orthogonal-test5.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + if ("opengl" in cc.sys.capabilities) { + var layer; + layer = map.getLayer("Layer 0"); + layer.texture.setAntiAliasTexParameters(); + + layer = map.getLayer("Layer 1"); + layer.texture.setAntiAliasTexParameters(); + + layer = map.getLayer("Layer 2"); + layer.texture.setAntiAliasTexParameters(); + } + }, + title:function () { + return "TMX Tileset test"; + }, + // Automation + testDuration:1, + pixel1:{"0":255, "1":0, "2":0, "3":255}, + pixel2:{"0":213, "1":202, "2":190, "3":255}, + pixel3:{"0":61, "1":118, "2":71, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(53, 80, 5, 5); + var ret2 = this.readPixels(38, 151, 5, 5); + var ret3 = this.readPixels(345, 202, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1, false) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2, false) ? "yes" : "no", + "pixel3":this.containsPixel(ret3, this.pixel3, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXOrthoObjectsTest +// +//------------------------------------------------------------------ +var TMXOrthoObjectsTest = TileDemo.extend({ + ctor:function () { + this._super(); + var drawNode = new cc.DrawNode(); + drawNode.setLineWidth(3); + drawNode.setDrawColor(cc.color(255,255,255,255)); + this.addChild(drawNode); + + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/ortho-objects.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + var group = map.getObjectGroup("Object Group 1"); + var array = group.getObjects(); + var dict; + + for (var i = 0, len = array.length; i < len; i++) { + dict = array[i]; + if (!dict) + break; + for (var k in dict) { + this.log(k + ' = ' + dict[k]); + } + + var x = dict["x"], y = dict["y"]; + var width = dict["width"], height = dict["height"]; + + drawNode.drawSegment(cc.p(x, y), cc.p((x + width), y)); + drawNode.drawSegment(cc.p((x + width), y), cc.p((x + width), (y + height))); + drawNode.drawSegment(cc.p((x + width), (y + height)), cc.p(x, (y + height))); + drawNode.drawSegment(cc.p(x, (y + height)), cc.p(x, y)); + } + + //Automation parameters + this.testObjects = array; + }, + onEnter:function () { + this._super(); + this.anchorX = 0; + this.anchorY = 0; + }, + title:function () { + return "TMX Ortho object test"; + }, + subtitle:function () { + return "You should see a white box around the 3 platforms"; + }, + + // + // Automation + // + testObjects:null, + getExpectedResult:function () { + var ret = []; + ret.push({"name":"Object", "type":"", "x":0, "y":0, "width":352, "height":32}); + ret.push({"name":"Object", "type":"", "x":224, "y":64, "width":160, "height":32 }); + ret.push({"name":"platform", "type":"platform", "x":2, "y":131, "width":125, "height":60}); + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret = []; + var obj = null; + for (var i = 0; i < this.testObjects.length; i++) { + obj = this.testObjects[i]; + ret.push({"name":obj["name"] || "", "type":obj["type"] || "", "x":parseFloat(obj["x"]), "y":parseFloat(obj["y"]), "width":parseFloat(obj["width"]), "height":parseFloat(obj["height"])}); + } + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXIsoObjectsTest +// +//------------------------------------------------------------------ +var TMXIsoObjectsTest = TileDemo.extend({ + ctor:function () { + this._super(); + + var drawNode = new cc.DrawNode(); + drawNode.setLineWidth(3); + drawNode.setDrawColor(cc.color(255,255,255,255)); + this.addChild(drawNode); + + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/iso-test-objectgroup.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + var group = map.getObjectGroup("Object Group 1"); + var array = group.getObjects(); + var dict; + for (var i = 0, len = array.length; i < len; i++) { + dict = array[i]; + if (!dict) + break; + for (var k in dict) { + this.log(k + ' = ' + dict[k]); + } + + var x = dict["x"], y = dict["y"]; + var width = dict["width"], height = dict["height"]; + + drawNode.drawSegment(cc.p(x, y), cc.p((x + width), y)); + drawNode.drawSegment(cc.p((x + width), y), cc.p((x + width), (y + height))); + drawNode.drawSegment(cc.p((x + width), (y + height)), cc.p(x, (y + height))); + drawNode.drawSegment(cc.p(x, (y + height)), cc.p(x, y)); + } + + //Automation parameters + this.testObjects = array; + }, + + onEnter:function () { + this._super(); + this.anchorX = 0; + this.anchorY = 0; + }, + + title:function () { + return "TMX Iso object test"; + }, + subtitle:function () { + return "You need to parse them manually. See bug #810"; + }, + + // + // Automation + // + testObjects:null, + getExpectedResult:function () { + var ret = []; + ret.push({"name":"platform 1", "type":"", "x":0, "y":0, "width":32, "height":30}); + ret.push({"name":"", "type":"", "x":0, "y":285, "width":31, "height":32}); + ret.push({"name":"", "type":"", "x":130, "y":129, "width":29, "height":29}); + ret.push({"name":"", "type":"", "x":290, "y":1, "width":28, "height":29}); + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret = []; + var obj = null; + for (var i = 0; i < this.testObjects.length; i++) { + obj = this.testObjects[i]; + ret.push({"name":obj["name"] || "", "type":obj["type"] || "", "x":parseFloat(obj["x"]), "y":parseFloat(obj["y"]), "width":parseFloat(obj["width"]), "height":parseFloat(obj["height"])}); + } + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXResizeTest +// +//------------------------------------------------------------------ +var TMXResizeTest = TileDemo.extend({ + ctor:function () { + this._super(); + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/orthogonal-test5.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + var layer; + layer = map.getLayer("Layer 0"); + + var ls = layer.getLayerSize(); + for (var y = 0; y < ls.height; y++) { + for (var x = 0; x < ls.width; x++) { + layer.setTileGID(1, cc.p(x, y)); + } + } + }, + title:function () { + return "TMX resize test"; + }, + subtitle:function () { + return "Should not crash. Testing issue #740"; + }, + // + // Automation + // + testDuration:0.25, + pixel:{"0":169, "1":120, "2":76, "3":255}, + getExpectedResult:function () { + var ret = {"pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(156, 156, 5, 5); + var ret = {"pixel":this.containsPixel(ret1, this.pixel, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXIsoZorder +// +//------------------------------------------------------------------ +var TMXIsoZorder = TileDemo.extend({ + tamara:null, + ctor:function () { + this._super(); + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/iso-test-zorder.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + map.x = -map.width / 2; + map.y = 0; + + this.tamara = new cc.Sprite(s_pathSister1); + map.addChild(this.tamara, map.children.length); + var mapWidth = map.getMapSize().width * map.getTileSize().width; + this.tamara.x = mapWidth / 2; + this.tamara.y = 0; + this.tamara.anchorX = 0.5; + this.tamara.anchorY = 0; + + var move = cc.moveBy(5, cc.pMult(cc.p(300, 250), 0.75)); + var back = move.reverse(); + var delay = cc.delayTime(0.5); + var seq = cc.sequence(move, delay, back); + this.tamara.runAction(seq.repeatForever()); + + this.schedule(this.repositionSprite); + }, + title:function () { + return "TMX Iso Zorder"; + }, + subtitle:function () { + return "Sprite should hide behind the trees"; + }, + onExit:function () { + this.unschedule(this.repositionSprite); + this._super(); + }, + repositionSprite:function (dt) { + var map = this.getChildByTag(TAG_TILE_MAP); + + // there are only 4 layers. (grass and 3 trees layers) + // if tamara < 48, z=4 + // if tamara < 96, z=3 + // if tamara < 144, z=2 + + var newZ = 4 - (this.tamara.y / 48); + newZ = parseInt(Math.max(newZ, 0), 10); + map.reorderChild(this.tamara, newZ); + }, + // + // Automation + // + testDuration:5.2, + pixel:{"0":255, "1":255, "2":255, "3":255}, + getExpectedResult:function () { + var ret = {"pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(223, 247, 5, 5); + var ret = {"pixel":this.containsPixel(ret1, this.pixel, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXOrthoZorder +// +//------------------------------------------------------------------ +var TMXOrthoZorder = TileDemo.extend({ + tamara:null, + ctor:function () { + this._super(); + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/orthogonal-test-zorder.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + this.tamara = new cc.Sprite(s_pathSister1); + map.addChild(this.tamara, map.children.length, TAG_TILE_MAP); + this.tamara.anchorX = 0.5; + this.tamara.anchorY = 0; + + var move = cc.moveBy(5, cc.pMult(cc.p(400, 450), 0.58)); + var back = move.reverse(); + var seq = cc.sequence(move, back); + this.tamara.runAction(seq.repeatForever()); + + this.schedule(this.repositionSprite); + }, + title:function () { + return "TMX Ortho Zorder"; + }, + subtitle:function () { + return "Sprite should hide behind the trees"; + }, + repositionSprite:function (dt) { + var map = this.getChildByTag(TAG_TILE_MAP); + + // there are only 4 layers. (grass and 3 trees layers) + // if tamara < 81, z=4 + // if tamara < 162, z=3 + // if tamara < 243,z=2 + + // -10: customization for this particular sample + var newZ = 4 - ((this.tamara.y - 10) / 81); + newZ = Math.max(newZ, 0); + + map.reorderChild(this.tamara, newZ); + }, + // + // Automation + // + testDuration:2, + pixel1:{"0":117, "1":185, "2":63, "3":255}, + pixel2:{"0":91, "1":55, "2":20, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(86, 131, 5, 5); + var ret2 = this.readPixels(84, 200, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1, false) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2, true, 5) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXIsoVertexZ +// +//------------------------------------------------------------------ +var TMXIsoVertexZ = TMXFixBugLayer.extend({ + tamara:null, + ctor:function () { + this._super(); + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/iso-test-vertexz.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + map.x = -map.width / 2; + map.y = 0; + + // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you + // can use any cc.Sprite and it will work OK. + var layer = map.getLayer("Trees"); + this.tamara = layer.getTileAt(cc.p(29, 29)); + + var move = cc.moveBy(5, cc.pMult(cc.p(300, 250), 0.75)); + var back = move.reverse(); + var delay = cc.delayTime(0.5); + var seq = cc.sequence(move, delay, back); + this.tamara.runAction(seq.repeatForever()); + + if (!cc.sys.isNative && !("opengl" in cc.sys.capabilities)) { + var label = new cc.LabelTTF("Not supported on HTML5-canvas", "Times New Roman", 30); + this.addChild(label); + label.x = winSize.width / 2; + label.y = winSize.height / 2; + } + + this.schedule(this.repositionSprite); + }, + title:function () { + return "TMX Iso VertexZ"; + }, + subtitle:function () { + return "Sprite should hide behind the trees"; + }, + onEnter:function () { + this._super(); + // TIP: 2d projection should be used + director.setProjection(cc.Director.PROJECTION_2D); + }, + onExit:function () { + // At exit use any other projection. + // director.setProjection:cc.Director.PROJECTION_3D); + this._super(); + }, + repositionSprite:function (dt) { + // tile height is 64x32 + // map size: 30x30 + var z = -( (this.tamara.y + 32) / 16); + this.tamara.vertexZ = z; + }, + // + // Automation + // + testDuration:5.2, + pixel:{"0":255, "1":255, "2":255, "3":255}, + getExpectedResult:function () { + var ret = {"pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(224, 246, 4, 4); + var ret = {"pixel":this.containsPixel(ret1, this.pixel, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXOrthoVertexZ +// +//------------------------------------------------------------------ +var TMXOrthoVertexZ = TMXFixBugLayer.extend({ + tamara:null, + ctor:function () { + this._super(); + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/orthogonal-test-vertexz.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you + // can use any cc.Sprite and it will work OK. + var layer = map.getLayer("trees"); + this.tamara = layer.getTileAt(cc.p(0, 11)); + this.log("vertexZ: " + this.tamara.vertexZ); + + var move = cc.moveBy(5, cc.pMult(cc.p(400, 450), 0.55)); + var back = move.reverse(); + var delay = cc.delayTime(0.5); + var seq = cc.sequence(move, delay, back); + this.tamara.runAction(seq.repeatForever()); + + if (!cc.sys.isNative && !("opengl" in cc.sys.capabilities)) { + var label = new cc.LabelTTF("Not supported on HTML5-canvas", "Times New Roman", 30); + this.addChild(label); + label.x = winSize.width / 2; + label.y = winSize.height / 2; + } + + this.schedule(this.repositionSprite); + + this.log("DEPTH BUFFER MUST EXIST IN ORDER"); + }, + title:function () { + return "TMX Ortho vertexZ"; + }, + subtitle:function () { + return "Sprite should hide behind the trees"; + }, + onEnter:function () { + this._super(); + + // TIP: 2d projection should be used + director.setProjection(cc.Director.PROJECTION_2D); + }, + onExit:function () { + // At exit use any other projection. + // director.setProjection:cc.Director.PROJECTION_3D); + this._super(); + }, + repositionSprite:function (dt) { + // tile height is 101x81 + // map size: 12x12 + this.tamara.vertexZ = -(this.tamara.y + 81) / 81; + }, + // + // Automation + // + testDuration:5.2, + pixel:{"0":119, "1":205, "2":73, "3":255}, + getExpectedResult:function () { + var ret = {"pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(266, 331, 5, 5); + var ret = {"pixel":this.containsPixel(ret1, this.pixel, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXIsoMoveLayer +// +//------------------------------------------------------------------ +var TMXIsoMoveLayer = TileDemo.extend({ + ctor:function () { + this._super(); + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/iso-test-movelayer.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + map.x = -700; + map.y = -50; + }, + title:function () { + return "TMX Iso Move Layer"; + }, + subtitle:function () { + return "Trees should be horizontally aligned"; + } +}); + +//------------------------------------------------------------------ +// +// TMXOrthoMoveLayer +// +//------------------------------------------------------------------ +var TMXOrthoMoveLayer = TileDemo.extend({ + ctor:function () { + this._super(); + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/orthogonal-test-movelayer.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + }, + title:function () { + return "TMX Ortho Move Layer"; + }, + subtitle:function () { + return "Trees should be horizontally aligned"; + } +}); + +//------------------------------------------------------------------ +// +// TMXTilePropertyTest +// +//------------------------------------------------------------------ +var TMXTilePropertyTest = TileDemo.extend({ + ctor:function () { + this._super(); + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/ortho-tile-property.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + for (var i = 1; i <= 6; i++) { + var properties = map.getPropertiesForGID(i); + this.log("GID:" + i + ", Properties:" + JSON.stringify(properties)); + this.propertiesList.push(properties) + } + }, + title:function () { + return "TMX Tile Property Test"; + }, + subtitle:function () { + return "In the console you should see tile properties"; + }, + // + // Automation + // + testDuration:0.25, + propertiesList:[], + getExpectedResult:function () { + var ret = []; + ret.push({"test":"sss", "type":"object"}); + ret.push({"type":"object"}); + ret.push({"type":"object"}); + ret.push({"type":"platform"}); + ret.push({"type":"platform"}); + ret.push({"type":"platform"}); + return JSON.stringify(ret); + }, + getCurrentResult:function () { + return JSON.stringify(this.propertiesList); + } +}); + +//------------------------------------------------------------------ +// +// TMXOrthoFlipTest +// +//------------------------------------------------------------------ +var TMXOrthoFlipTest = TileDemo.extend({ + ctor:function () { + this._super(); + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/ortho-rotation-test.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + this.log("ContentSize:" + map.width + "," + map.height); + + var action = new cc.ScaleBy(2, 0.5); + map.runAction(action); + }, + title:function () { + return "TMX tile flip test"; + }, + // + // Automation + // + testDuration:2.2, + pixel:{"0":41, "1":42, "2":54, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(93, 153, 5, 5); + var ret2 = this.readPixels(105, 153, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel, false) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXOrthoFlipRunTimeTest +// +//------------------------------------------------------------------ +var TMXOrthoFlipRunTimeTest = TileDemo.extend({ + ctor:function () { + this._super(); + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/ortho-rotation-test.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + this.log("ContentSize:" + map.width + "," + map.height); + + var action = new cc.ScaleBy(2, 0.5); + map.runAction(action); + + this.schedule(this.onFlipIt, 1); + }, + title:function () { + return "TMX tile flip run time test"; + }, + subtitle:function () { + return "in 2 sec bottom left tiles will flip"; + }, + onFlipIt:function () { + var map = this.getChildByTag(TAG_TILE_MAP); + var layer = map.getLayer("Layer 0"); + + //blue diamond + var tileCoord = cc.p(1, 10); + var flags = layer.getTileFlagsAt(tileCoord); + var GID = layer.getTileGIDAt(tileCoord); + // Vertical + if ((flags & cc.TMX_TILE_VERTICAL_FLAG) >>> 0) { + flags = (flags & ~cc.TMX_TILE_VERTICAL_FLAG >>> 0) >>> 0; + } else { + flags = (flags | cc.TMX_TILE_VERTICAL_FLAG) >>> 0; + } + layer.setTileGID(GID, tileCoord, flags); + + tileCoord = cc.p(1, 8); + flags = layer.getTileFlagsAt(tileCoord); + GID = layer.getTileGIDAt(tileCoord); + // Vertical + if ((flags & cc.TMX_TILE_VERTICAL_FLAG) >>> 0) + flags = (flags & ~cc.TMX_TILE_VERTICAL_FLAG >>> 0) >>> 0; + else + flags = (flags | cc.TMX_TILE_VERTICAL_FLAG) >>> 0; + layer.setTileGID(GID, tileCoord, flags); + + tileCoord = cc.p(2, 8); + flags = layer.getTileFlagsAt(tileCoord); + GID = layer.getTileGIDAt(tileCoord); + // Horizontal + if ((flags & cc.TMX_TILE_HORIZONTAL_FLAG) >>> 0) + flags = (flags & ~cc.TMX_TILE_HORIZONTAL_FLAG >>> 0) >>> 0; + else + flags = (flags | cc.TMX_TILE_HORIZONTAL_FLAG) >>> 0; + layer.setTileGID(GID, tileCoord, flags); + }, + // + // Automation + // + testDuration:3.2, + pixel:{"0":41, "1":42, "2":54, "3":255}, + pixel1:null, + setupAutomation:function () { + var fun = function () { + this.pixel1 = this.readPixels(104, 154, 5, 5); + } + this.scheduleOnce(fun, 2.2); + }, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + this.pixel2 = this.readPixels(145, 154, 5, 5); + var ret = {"pixel1":this.containsPixel(this.pixel1, this.pixel, false) ? "yes" : "no", + "pixel2":this.containsPixel(this.pixel2, this.pixel, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXOrthoFromXMLTest +// +//------------------------------------------------------------------ +var TMXOrthoFromXMLTest = TileDemo.extend({ + ctor:function () { + this._super(); + + var resources = s_resprefix + "TileMaps"; + var filePath = s_resprefix + "TileMaps/orthogonal-test1.tmx"; + var xmlStr = cc.loader.getRes(filePath); + var map = new cc.TMXTiledMap(xmlStr, resources); + this.addChild(map, 0, TAG_TILE_MAP); + + cc.log("ContentSize: " + map.width + ", " + map.height); + + if ("opengl" in cc.sys.capabilities) { + var mapChildren = map.children; + for (var i = 0; i < mapChildren.length; i++) { + var child = mapChildren[i]; + if (child) + child.texture.setAntiAliasTexParameters(); + } + } + + var action = new cc.ScaleBy(2, 0.5); + map.runAction(action); + }, + title:function () { + return "TMX created from XML test"; + }, + // + // Automation + // + testDuration:2.2, + pixel1:{"0":210, "1":210, "2":200, "3":255}, + pixel2:{"0":243, "1":202, "2":86, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(326, 120, 5, 5); + var ret2 = this.readPixels(124, 246, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1, false) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXBug987 +// +//------------------------------------------------------------------ +var TMXBug987 = TileDemo.extend({ + ctor:function () { + this._super(); + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/orthogonal-test6.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + this.log("ContentSize:" + map.width + "," + map.height); + + var childs = map.children; + var node = null; + for (var i = 0, len = childs.length; i < len; i++) { + node = childs[i]; + if (!node) break; + if ("opengl" in cc.sys.capabilities) + node.texture.setAntiAliasTexParameters(); + } + + map.anchorX = 0; + map.anchorY = 0; + var layer = map.getLayer("Tile Layer 1"); + layer.setTileGID(3, cc.p(2, 2)); + }, + title:function () { + return "TMX Bug 987"; + }, + subtitle:function () { + return "You should see an square"; + }, + // + // Automation + // + testDuration:0.25, + pixel1:{"0":162, "1":152, "2":98, "3":255}, + pixel2:{"0":255, "1":208, "2":148, "3":255}, + pixel3:{"0":182, "1":182, "2":146, "3":255}, + getExpectedResult:function () { + var ret = {"pixel1":"yes", "pixel2":"yes", "pixel3":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(64, 224, 5, 5); + var ret2 = this.readPixels(4, 165, 5, 5); + var ret3 = this.readPixels(144, 140, 5, 5); + var ret = {"pixel1":this.containsPixel(ret1, this.pixel1, false) ? "yes" : "no", + "pixel2":this.containsPixel(ret2, this.pixel2, false) ? "yes" : "no", + "pixel3":this.containsPixel(ret3, this.pixel3, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +//------------------------------------------------------------------ +// +// TMXBug787 +// +//------------------------------------------------------------------ +var TMXBug787 = TileDemo.extend({ + ctor:function () { + this._super(); + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/iso-test-bug787.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + map.scale = 0.25; + }, + title:function () { + return "TMX Bug 787"; + }, + subtitle:function () { + return "You should see a map"; + }, + // + // Automation + // + testDuration:0.25, + pixel:{"0":255, "1":255, "2":255, "3":255}, + getExpectedResult:function () { + var ret = {"pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(364, 243, 5, 5); + var ret = {"pixel":this.containsPixel(ret1, this.pixel, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +var TMXGIDObjectsTest = TileDemo.extend({ + ctor:function () { + this._super(); + + var drawNode = new cc.DrawNode(); + drawNode.setLineWidth(3); + drawNode.setDrawColor(cc.color(255,255,255,255)); + this.addChild(drawNode); + + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/test-object-layer.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + this.log("ContentSize:" + map.width + "," + map.height); + this.log("---. Iterating over all the group objets"); + + var group = map.getObjectGroup("Object Layer 1"); + var array = group.getObjects(); + var dict; + for (var i = 0, len = array.length; i < len; i++) { + dict = array[i]; + if (!dict) + break; + for (var k in dict) { + this.log(k + ' = ' + dict[k]); + } + + var x = dict["x"], y = dict["y"]; + var width = dict["width"], height = dict["height"]; + + if (width != 0 && height != 0) { + drawNode.drawSegment(cc.p(x, y), cc.p((x + width), y)); + drawNode.drawSegment(cc.p((x + width), y), cc.p((x + width), (y + height))); + drawNode.drawSegment(cc.p((x + width), (y + height)), cc.p(x, (y + height))); + drawNode.drawSegment(cc.p(x, (y + height)), cc.p(x, y)); + } + } + this.testObjects = array; + }, + title:function () { + return "TMX GID objects"; + }, + subtitle:function () { + return "Tiles are created from an object group"; + }, + // + // Automation + // + testObjects:[], + getExpectedResult:function () { + var ret = []; + ret.push({"name":"sandro", "type":"", "x":97, "y":6, "width":0, "height":0}); + ret.push({"name":"", "type":"", "x":119, "y":19, "width":0, "height":0}); + ret.push({"name":"", "type":"", "x":140, "y":38, "width":0, "height":0}); + ret.push({"name":"", "type":"", "x":160, "y":57, "width":0, "height":0}); + ret.push({"name":"", "type":"", "x":180, "y":71, "width":0, "height":0}); + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret = []; + var obj = null; + for (var i = 0; i < this.testObjects.length; i++) { + obj = this.testObjects[i]; + ret.push({"name":obj["name"] || "", "type":obj["type"] || "", "x":parseFloat(obj["x"]), "y":parseFloat(obj["y"]), "width":parseFloat(obj["width"] || 0), "height":parseFloat(obj["height"] || 0)}); + } + return JSON.stringify(ret); + } +}); + + +var TMXIsoOffsetTest = TileDemo.extend({ + ctor:function () { + this._super(); + var map = new cc.TMXTiledMap(s_resprefix + "TileMaps/tile_iso_offset.tmx"); + this.addChild(map, 0, TAG_TILE_MAP); + + }, + title:function () { + return "TMX Tile Offset"; + }, + subtitle:function () { + return "Testing offset of tiles"; + }, + // + // Automation + // + testDuration:0.25, + pixel:{"0":168, "1":168, "2":168, "3":255}, + getExpectedResult:function () { + var ret = {"pixel":"yes"}; + return JSON.stringify(ret); + }, + getCurrentResult:function () { + var ret1 = this.readPixels(150, 260, 5, 5); + var ret = {"pixel":this.containsPixel(ret1, this.pixel, false) ? "yes" : "no"}; + return JSON.stringify(ret); + } +}); + +var TileMapTestScene = TestScene.extend({ + runThisTest:function (num) { + tileTestSceneIdx = (num || num == 0) ? (num - 1) : -1; + var layer = nextTileMapTest(); + this.addChild(layer); + // fix bug #486, #419. + // "test" is the default value in CCDirector::setGLDefaultValues() + // but TransitionTest may setDepthTest(false), we should revert it here + cc.director.setDepthTest(true); + + director.runScene(this); + } +}); + +// +// Flow control +// +var arrayOfTileMapTest = [ + TMXOrthoTest, + TMXOrthoTest2, + TMXOrthoTest3, + TMXOrthoTest4, + TMXReadWriteTest, + TMXHexTest, + TMXIsoTest, + TMXIsoTest1, + TMXIsoTest2, + TMXUncompressedTest, + TMXTilesetTest, + TMXOrthoObjectsTest, + TMXIsoObjectsTest, + TMXResizeTest, + TMXIsoZorder, + TMXOrthoZorder, + TMXIsoVertexZ, + TMXOrthoVertexZ, + TMXIsoMoveLayer, + TMXOrthoMoveLayer, + TMXTilePropertyTest, + TMXOrthoFlipTest, + TMXOrthoFlipRunTimeTest, + TMXOrthoFromXMLTest, + TMXBug987, + TMXBug787, + TMXIsoOffsetTest +]; + +if ( !cc.sys.isNative ){ + //This test is supported only in HTML5 + arrayOfTileMapTest.push(TMXGIDObjectsTest); +} + +var nextTileMapTest = function () { + tileTestSceneIdx++; + tileTestSceneIdx = tileTestSceneIdx % arrayOfTileMapTest.length; + + return new arrayOfTileMapTest[tileTestSceneIdx](); +}; +var previousTileMapTest = function () { + tileTestSceneIdx--; + if (tileTestSceneIdx < 0) + tileTestSceneIdx += arrayOfTileMapTest.length; + + return new arrayOfTileMapTest[tileTestSceneIdx](); +}; +var restartTileMapTest = function () { + return new arrayOfTileMapTest[tileTestSceneIdx](); +}; + diff --git a/tests/js-tests/src/TouchesTest/Ball.js b/tests/js-tests/src/TouchesTest/Ball.js new file mode 100644 index 0000000000..a7bf5dddd6 --- /dev/null +++ b/tests/js-tests/src/TouchesTest/Ball.js @@ -0,0 +1,98 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 Ball = cc.Sprite.extend({ + _velocity:cc.p(0,0), + _radius:0, + radius:function () { + return this._radius; + }, + setRadius:function (rad) { + this._radius = rad; + }, + move:function (delta) { + this.x += this._velocity.x * delta; + this.y += this._velocity.y * delta; + var winSize = cc.director.getWinSize(); + if (this.x > winSize.width - this.radius()) { + this.x = winSize.width - this.radius(); + this._velocity.x *= -1; + } else if (this.x < this.radius()) { + this.x = this.radius(); + this._velocity.x *= -1; + } + }, + collideWithPaddle:function (paddle) { + var paddleRect = paddle.rect(); + + paddleRect.x += paddle.x; + paddleRect.y += paddle.y; + + var lowY = cc.rectGetMinY(paddleRect); + var midY = cc.rectGetMidY(paddleRect); + var highY = cc.rectGetMaxY(paddleRect); + + var leftX = cc.rectGetMinX(paddleRect); + var rightX = cc.rectGetMaxX(paddleRect); + + if ((this.x > leftX) && (this.x < rightX)) { + var hit = false; + var angleOffset = 0.0; + if ((this.y > midY) && (this.y <= (highY + this.radius()))) { + this.y = highY + this.radius(); + hit = true; + angleOffset = Math.PI / 2; + } else if (this.y < midY && this.y >= lowY - this.radius()) { + this.y = lowY - this.radius(); + hit = true; + angleOffset = -Math.PI / 2; + } + + if (hit) { + var hitAngle = cc.pToAngle(cc.p(paddle.x - this.x, paddle.y - this.y)) + angleOffset; + + var scalarVelocity = cc.pLength(this._velocity) * 1.00000005; + var velocityAngle = -cc.pToAngle(this._velocity) + 0.00000005 * hitAngle; + //this._velocity = -this._velocity.y; + this._velocity = cc.pMult(cc.pForAngle(velocityAngle), scalarVelocity); + } + } + }, + setVelocity:function (velocity) { + this._velocity = velocity; + }, + getVelocity:function () { + return this._velocity; + } +}); +Ball.ballWithTexture = function (texture) { + var ball = new Ball(); + ball.initWithTexture(texture); + if (texture instanceof cc.Texture2D) + ball.setRadius(texture.width / 2); + else if ((texture instanceof HTMLImageElement) || (texture instanceof HTMLCanvasElement)) + ball.setRadius(texture.width / 2); + return ball; +}; diff --git a/tests/js-tests/src/TouchesTest/Paddle.js b/tests/js-tests/src/TouchesTest/Paddle.js new file mode 100644 index 0000000000..1509f77daf --- /dev/null +++ b/tests/js-tests/src/TouchesTest/Paddle.js @@ -0,0 +1,106 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 PADDLE_STATE_GRABBED = 0; +var PADDLE_STATE_UNGRABBED = 1; + +var Paddle = cc.Sprite.extend({ + _state:PADDLE_STATE_UNGRABBED, + _rect:null, + + ctor: function(){ + this._super(); + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouches: true, + onTouchBegan: this.onTouchBegan, + onTouchMoved: this.onTouchMoved, + onTouchEnded: this.onTouchEnded + }, this); + }, + + rect:function () { + return cc.rect(-this._rect.width / 2, -this._rect.height / 2, this._rect.width, this._rect.height); + }, + initWithTexture:function (aTexture) { + if (this._super(aTexture)) { + this._state = PADDLE_STATE_UNGRABBED; + } + if (aTexture instanceof cc.Texture2D) { + this._rect = cc.rect(0, 0, aTexture.width, aTexture.height); + } else if ((aTexture instanceof HTMLImageElement) || (aTexture instanceof HTMLCanvasElement)) { + this._rect = cc.rect(0, 0, aTexture.width, aTexture.height); + } + return true; + }, + + containsTouchLocation:function (touch) { + var getPoint = touch.getLocation(); + var myRect = this.rect(); + + myRect.x += this.x; + myRect.y += this.y; + return cc.rectContainsPoint(myRect, getPoint);//this.convertTouchToNodeSpaceAR(touch)); + }, + + onTouchBegan:function (touch, event) { + var target = event.getCurrentTarget(); + if (target._state != PADDLE_STATE_UNGRABBED) return false; + if (!target.containsTouchLocation(touch)) return false; + + target._state = PADDLE_STATE_GRABBED; + return true; + }, + onTouchMoved:function (touch, event) { + var target = event.getCurrentTarget(); + // If it weren't for the TouchDispatcher, you would need to keep a reference + // to the touch from touchBegan and check that the current touch is the same + // as that one. + // Actually, it would be even more complicated since in the Cocos dispatcher + // you get Array instead of 1 cc.Touch, so you'd need to loop through the set + // in each touchXXX method. + cc.assert(target._state == PADDLE_STATE_GRABBED, "Paddle - Unexpected state!"); + + var touchPoint = touch.getLocation(); + //touchPoint = cc.director.convertToGL( touchPoint ); + + target.x = touchPoint.x; + }, + onTouchEnded:function (touch, event) { + var target = event.getCurrentTarget(); + cc.assert(target._state == PADDLE_STATE_GRABBED, "Paddle - Unexpected state!"); + target._state = PADDLE_STATE_UNGRABBED; + }, + touchDelegateRetain:function () { + }, + touchDelegateRelease:function () { + } +}); +Paddle.paddleWithTexture = function (aTexture) { + var paddle = new Paddle(); + paddle.initWithTexture(aTexture); + + return paddle; +}; diff --git a/tests/js-tests/src/TouchesTest/TouchesTest.js b/tests/js-tests/src/TouchesTest/TouchesTest.js new file mode 100644 index 0000000000..fb74472355 --- /dev/null +++ b/tests/js-tests/src/TouchesTest/TouchesTest.js @@ -0,0 +1,123 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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 HIGH_PLAYER = 0; +var LOW_PLAYER = 1; +var STATUS_BAR_HEIGHT = 20.0; +var SPRITE_TAG = 0; + +var TouchesTestScene = TestScene.extend({ + ctor:function () { + this._super(true); + var pongLayer = new PongLayer(); + this.addChild(pongLayer); + }, + runThisTest:function () { + cc.director.runScene(this); + }, + MainMenuCallback:function (sender) { + this._super(sender); + } +}); + +var PongLayer = cc.Layer.extend({ + _ball:null, + _paddles:[], + _ballStartingVelocity:null, + _winSize:null, + + ctor:function () { + this._super(); + this._ballStartingVelocity = cc.p(20.0, -100.0); + this._winSize = cc.director.getWinSize(); + + this._ball = Ball.ballWithTexture(cc.textureCache.addImage(s_ball)); + this._ball.x = this._winSize.width / 2; + this._ball.y = this._winSize.height / 2; + this._ball.setVelocity(this._ballStartingVelocity); + this.addChild(this._ball); + + var paddleTexture = cc.textureCache.addImage(s_paddle); + + this._paddles = []; + + var paddle = Paddle.paddleWithTexture(paddleTexture); + paddle.x = this._winSize.width / 2; + paddle.y = 15; + this._paddles.push(paddle); + + paddle = Paddle.paddleWithTexture(paddleTexture); + paddle.x = this._winSize.width / 2; + paddle.y = this._winSize.height - STATUS_BAR_HEIGHT - 15; + this._paddles.push(paddle); + + paddle = Paddle.paddleWithTexture(paddleTexture); + paddle.x = this._winSize.width / 2; + paddle.y = 100; + this._paddles.push(paddle); + + paddle = Paddle.paddleWithTexture(paddleTexture); + paddle.x = this._winSize.width / 2; + paddle.y = this._winSize.height - STATUS_BAR_HEIGHT - 100; + this._paddles.push(paddle); + + for (var i = 0; i < this._paddles.length; i++) { + if (!this._paddles[i]) + break; + + this.addChild(this._paddles[i]); + } + + this.schedule(this.doStep); + }, + resetAndScoreBallForPlayer:function (player) { + if (Math.abs(this._ball.getVelocity().y) < 300) { + this._ballStartingVelocity = cc.pMult(this._ballStartingVelocity, -1.1); + } else { + this._ballStartingVelocity = cc.pMult(this._ballStartingVelocity, -1); + } + this._ball.setVelocity(this._ballStartingVelocity); + this._ball.x = this._winSize.width / 2; + this._ball.y = this._winSize.height / 2; + + // TODO -- scoring + }, + doStep:function (delta) { + this._ball.move(delta); + + for (var i = 0; i < this._paddles.length; i++) { + if (!this._paddles[i]) + break; + + this._ball.collideWithPaddle(this._paddles[i]); + } + + if (this._ball.y > this._winSize.height - STATUS_BAR_HEIGHT + this._ball.radius()) + this.resetAndScoreBallForPlayer(LOW_PLAYER); + else if (this._ball.y < -this._ball.radius()) + this.resetAndScoreBallForPlayer(HIGH_PLAYER); + this._ball.draw(); + } +}); diff --git a/tests/js-tests/src/TransitionsTest/TransitionsTest.js b/tests/js-tests/src/TransitionsTest/TransitionsTest.js new file mode 100644 index 0000000000..f6f0173e6b --- /dev/null +++ b/tests/js-tests/src/TransitionsTest/TransitionsTest.js @@ -0,0 +1,458 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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. + ****************************************************************************/ +TRANSITION_DURATION = 1.2; + +var arrayOfTransitionsTest = [ + + {title:"JumpZoomTransition", transitionFunc:function (t, s) { + return new JumpZoomTransition(t, s); + }}, + + {title:"TransitionProgressRadialCCW", transitionFunc:function (t, s) { + return new cc.TransitionProgressRadialCCW(t, s); + }}, + + {title:"TransitionProgressRadialCW", transitionFunc:function (t, s) { + return new cc.TransitionProgressRadialCW(t, s); + }}, + + {title:"TransitionProgressHorizontal", transitionFunc:function (t, s) { + return new cc.TransitionProgressHorizontal(t, s); + }}, + + {title:"TransitionProgressVertical", transitionFunc:function (t, s) { + return new cc.TransitionProgressVertical(t, s); + }}, + + {title:"TransitionProgressInOut", transitionFunc:function (t, s) { + return new cc.TransitionProgressInOut(t, s); + }}, + + {title:"TransitionProgressOutIn", transitionFunc:function (t, s) { + return new cc.TransitionProgressOutIn(t, s); + }}, + + //ok + {title:"FadeTransition", transitionFunc:function (t, s) { + return FadeTransition(t, s); + }}, + {title:"FadeWhiteTransition", transitionFunc:function (t, s) { + return FadeWhiteTransition(t, s); + }}, + + {title:"ShrinkGrowTransition", transitionFunc:function (t, s) { + return ShrinkGrowTransition(t, s); + }}, + {title:"RotoZoomTransition", transitionFunc:function (t, s) { + return RotoZoomTransition(t, s); + }}, + {title:"MoveInLTransition", transitionFunc:function (t, s) { + return MoveInLTransition(t, s); + }}, + {title:"MoveInRTransition", transitionFunc:function (t, s) { + return MoveInRTransition(t, s); + }}, + {title:"MoveInTTransition", transitionFunc:function (t, s) { + return MoveInTTransition(t, s); + }}, + {title:"MoveInBTransition", transitionFunc:function (t, s) { + return MoveInBTransition(t, s); + }}, + {title:"SlideInLTransition", transitionFunc:function (t, s) { + return SlideInLTransition(t, s); + }}, + {title:"SlideInRTransition", transitionFunc:function (t, s) { + return SlideInRTransition(t, s); + }}, + {title:"SlideInTTransition", transitionFunc:function (t, s) { + return SlideInTTransition(t, s); + }}, + {title:"SlideInBTransition", transitionFunc:function (t, s) { + return SlideInBTransition(t, s); + }}, + {title:"CCTransitionRadialCCW", transitionFunc:function (t, s) { + return CCTransitionRadialCCW(t, s); + }}, + {title:"CCTransitionRadialCW", transitionFunc:function (t, s) { + return CCTransitionRadialCW(t, s); + }} +]; + +if ('opengl' in cc.sys.capabilities) { + arrayOfTransitionsTest = arrayOfTransitionsTest.concat( + [ + {title: "FlipXLeftOver", transitionFunc: function (t, s) { + return FlipXLeftOver(t, s); + }}, + {title: "FlipXRightOver", transitionFunc: function (t, s) { + return FlipXRightOver(t, s); + }}, + {title: "FlipYUpOver", transitionFunc: function (t, s) { + return FlipYUpOver(t, s); + }}, + {title: "FlipYDownOver", transitionFunc: function (t, s) { + return FlipYDownOver(t, s); + }}, + {title: "FlipAngularLeftOver", transitionFunc: function (t, s) { + return FlipAngularLeftOver(t, s); + }}, + {title: "FlipAngularRightOver", transitionFunc: function (t, s) { + return FlipAngularRightOver(t, s); + }}, + {title: "ZoomFlipXLeftOver", transitionFunc: function (t, s) { + return ZoomFlipXLeftOver(t, s); + }}, + {title: "ZoomFlipXRightOver", transitionFunc: function (t, s) { + return ZoomFlipXRightOver(t, s); + }}, + {title: "ZoomFlipYUpOver", transitionFunc: function (t, s) { + return ZoomFlipYUpOver(t, s); + }}, + {title: "ZoomFlipYDownOver", transitionFunc: function (t, s) { + return ZoomFlipYDownOver(t, s); + }}, + {title: "ZoomFlipAngularLeftOver", transitionFunc: function (t, s) { + return ZoomFlipAngularLeftOver(t, s); + }}, + {title: "ZoomFlipAngularRightOver", transitionFunc: function (t, s) { + return ZoomFlipAngularRightOver(t, s); + }}, + {title: "PageTransitionForward", transitionFunc: function (t, s) { + return PageTransitionForward(t, s); + }}, + {title: "PageTransitionBackward", transitionFunc: function (t, s) { + return PageTransitionBackward(t, s); + }}, + {title: "FadeTRTransition", transitionFunc: function (t, s) { + return FadeTRTransition(t, s); + }}, + {title: "FadeBLTransition", transitionFunc: function (t, s) { + return FadeBLTransition(t, s); + }}, + {title: "FadeUpTransition", transitionFunc: function (t, s) { + return FadeUpTransition(t, s); + }}, + {title: "FadeDownTransition", transitionFunc: function (t, s) { + return FadeDownTransition(t, s); + }}, + {title: "TurnOffTilesTransition", transitionFunc: function (t, s) { + return TurnOffTilesTransition(t, s); + }}, + {title: "SplitRowsTransition", transitionFunc: function (t, s) { + return SplitRowsTransition(t, s); + }}, + {title: "CCTransitionCrossFade", transitionFunc: function (t, s) { + return CCTransitionCrossFade(t, s); + }}, + {title: "SplitColsTransition", transitionFunc: function (t, s) { + return SplitColsTransition(t, s); + }} + ]); +} + +var transitionsIdx = 0; + +// the class inherit from TestScene +// every .Scene each test used must inherit from TestScene, +// make sure the test have the menu item for back to main menu +var TransitionsTestScene = TestScene.extend({ + runThisTest:function () { + var layer = new TestLayer1(); + this.addChild(layer); + director.runScene(this); + } +}); + +var TransitionBase = BaseTestLayer.extend({ + + testDuration:TRANSITION_DURATION + 0.1, + title:function() { + return arrayOfTransitionsTest[transitionsIdx].title; + }, + ctor:function () { + this._super(this.colorA, this.colorB); + + var x, y; + var size = director.getWinSize(); + x = size.width; + y = size.height; + + var bg1 = new cc.Sprite(this.backgroundImage); + bg1.x = size.width / 2; + bg1.y = size.height / 2; + bg1.scale = 1.7; + this.addChild(bg1); + + var title = new cc.LabelTTF(this.title(), "Thonburi", 32); + this.addChild(title); + title.color = cc.color(255, 32, 32); + title.x = x / 2; + title.y = y - 100; + + var label = new cc.LabelTTF(this.sceneName, "Marker Felt", 38); + label.color = cc.color(16, 16, 255); + label.x = x / 2; + label.y = y / 2; + this.addChild(label); + + this.schedule(this.step, 1.0); + }, + onRestartCallback:function (sender) { + var s = new TransitionsTestScene(); + + var layer = this.createNextScene(); + s.addChild(layer); + var scene = arrayOfTransitionsTest[transitionsIdx].transitionFunc(TRANSITION_DURATION, s); + + if (scene) + director.runScene(scene); + }, + onNextCallback:function (sender) { + transitionsIdx++; + transitionsIdx = transitionsIdx % arrayOfTransitionsTest.length; + + var s = new TransitionsTestScene(); + + var layer = this.createNextScene(); + s.addChild(layer); + + var scene = arrayOfTransitionsTest[transitionsIdx].transitionFunc(TRANSITION_DURATION, s); + if (scene) + director.runScene(scene); + }, + onBackCallback:function (sender) { + transitionsIdx--; + if (transitionsIdx < 0) + transitionsIdx += arrayOfTransitionsTest.length; + + var s = new TransitionsTestScene(); + var layer = this.createNextScene(); + s.addChild(layer); + + var scene = arrayOfTransitionsTest[transitionsIdx].transitionFunc(TRANSITION_DURATION, s); + if (scene) + director.runScene(scene); + }, + + step:function (dt) { + }, + + onEnter:function () { + this._super(); + this.log("" + this.sceneName + " onEnter"); + }, + onEnterTransitionDidFinish:function () { + this._super(); + this.log("" + this.sceneName + " onEnterTransitionDidFinish"); + }, + + onExitTransitionDidStart:function () { + this._super(); + this.log("" + this.sceneName + " onExitTransitionDidStart"); + }, + + onExit:function () { + this._super(); + this.log("" + this.sceneName + " onExit"); + }, + // automation + numberOfPendingTests:function() { + return ( (arrayOfTransitionsTest.length-1) - transitionsIdx ); + }, + + getTestNumber:function() { + return transitionsIdx; + } + +}); +var TestLayer1 = TransitionBase.extend({ + backgroundImage:s_back1, + colorA:cc.color(0,0,0,255), + colorB:cc.color(160,99,117,255), + sceneName:"Scene 1", + createNextScene:function() { + return new TestLayer2(); + } +}); + +var TestLayer2 = TransitionBase.extend({ + backgroundImage:s_back2, + colorA:cc.color(0,0,0,255), + colorB:cc.color(99,160,117,255), + sceneName:"Scene 2", + createNextScene:function() { + return new TestLayer1(); + } +}); + +var JumpZoomTransition = function (t, s) { + return new cc.TransitionJumpZoom(t, s); +}; +var FadeTransition = function (t, s) { + return new cc.TransitionFade(t, s); +}; + +var FadeWhiteTransition = function (t, s) { + return new cc.TransitionFade(t, s, cc.color(255, 255, 255)); +}; + +var FlipXLeftOver = function (t, s) { + return new cc.TransitionFlipX(t, s, cc.TRANSITION_ORIENTATION_LEFT_OVER); +}; + +var FlipXRightOver = function (t, s) { + return new cc.TransitionFlipX(t, s, cc.TRANSITION_ORIENTATION_RIGHT_OVER); +}; + +var FlipYUpOver = function (t, s) { + return new cc.TransitionFlipY(t, s, cc.TRANSITION_ORIENTATION_UP_OVER); +}; + +var FlipYDownOver = function (t, s) { + return new cc.TransitionFlipY(t, s, cc.TRANSITION_ORIENTATION_DOWN_OVER); +}; + +var FlipAngularLeftOver = function (t, s) { + return new cc.TransitionFlipAngular(t, s, cc.TRANSITION_ORIENTATION_LEFT_OVER); +}; + +var FlipAngularRightOver = function (t, s) { + return new cc.TransitionFlipAngular(t, s, cc.TRANSITION_ORIENTATION_RIGHT_OVER); +}; + +var ZoomFlipXLeftOver = function (t, s) { + return new cc.TransitionZoomFlipX(t, s, cc.TRANSITION_ORIENTATION_LEFT_OVER); +}; + +var ZoomFlipXRightOver = function (t, s) { + return new cc.TransitionZoomFlipX(t, s, cc.TRANSITION_ORIENTATION_RIGHT_OVER); +}; + +var ZoomFlipYUpOver = function (t, s) { + return new cc.TransitionZoomFlipY(t, s, cc.TRANSITION_ORIENTATION_UP_OVER); +}; + +var ZoomFlipYDownOver = function (t, s) { + return new cc.TransitionZoomFlipY(t, s, cc.TRANSITION_ORIENTATION_DOWN_OVER); +}; + +var ZoomFlipAngularLeftOver = function (t, s) { + return new cc.TransitionZoomFlipAngular(t, s, cc.TRANSITION_ORIENTATION_LEFT_OVER); +}; + +var ZoomFlipAngularRightOver = function (t, s) { + return new cc.TransitionZoomFlipAngular(t, s, cc.TRANSITION_ORIENTATION_RIGHT_OVER); +}; + +var ShrinkGrowTransition = function (t, s) { + return new cc.TransitionShrinkGrow(t, s); +}; + +var RotoZoomTransition = function (t, s) { + return new cc.TransitionRotoZoom(t, s); +}; + +var MoveInLTransition = function (t, s) { + return new cc.TransitionMoveInL(t, s); +}; + +var MoveInRTransition = function (t, s) { + return new cc.TransitionMoveInR(t, s); +}; + +var MoveInTTransition = function (t, s) { + return new cc.TransitionMoveInT(t, s); +}; + +var MoveInBTransition = function (t, s) { + return new cc.TransitionMoveInB(t, s); +}; + +var SlideInLTransition = function (t, s) { + return new cc.TransitionSlideInL(t, s); +}; + +var SlideInRTransition = function (t, s) { + return new cc.TransitionSlideInR(t, s); +}; + +var SlideInTTransition = function (t, s) { + return new cc.TransitionSlideInT(t, s); +}; + +var SlideInBTransition = function (t, s) { + return new cc.TransitionSlideInB(t, s); +}; + +var CCTransitionCrossFade = function (t, s) { + return new cc.TransitionCrossFade(t, s); +}; + +var CCTransitionRadialCCW = function (t, s) { + return new cc.TransitionProgressRadialCCW(t, s); +}; + +var CCTransitionRadialCW = function (t, s) { + return new cc.TransitionProgressRadialCW(t, s); +}; + +var PageTransitionForward = function (t, s) { + director.setDepthTest(true); + return new cc.TransitionPageTurn(t, s, false); +}; + +var PageTransitionBackward = function (t, s) { + director.setDepthTest(true); + return new cc.TransitionPageTurn(t, s, true); +}; + +var FadeTRTransition = function (t, s) { + return new cc.TransitionFadeTR(t, s); +}; + +var FadeBLTransition = function (t, s) { + return new cc.TransitionFadeBL(t, s); +}; + +var FadeUpTransition = function (t, s) { + return new cc.TransitionFadeUp(t, s); +}; + +var FadeDownTransition = function (t, s) { + return new cc.TransitionFadeDown(t, s); +}; + +var TurnOffTilesTransition = function (t, s) { + return new cc.TransitionTurnOffTiles(t, s); +}; + +var SplitRowsTransition = function (t, s) { + return new cc.TransitionSplitRows(t, s); +}; + +var SplitColsTransition = function (t, s) { + return new cc.TransitionSplitCols(t, s); +}; diff --git a/tests/js-tests/src/UnitTest/UnitTest.js b/tests/js-tests/src/UnitTest/UnitTest.js new file mode 100644 index 0000000000..18cb060356 --- /dev/null +++ b/tests/js-tests/src/UnitTest/UnitTest.js @@ -0,0 +1,284 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + 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. + ****************************************************************************/ + +var unitTestSceneIdx = -1; + +//------------------------------------------------------------------ +// +// UnitTestBase +// +//------------------------------------------------------------------ +var UnitTestBase = BaseTestLayer.extend({ + _title:"", + _subtitle:"", + + onRestartCallback:function (sender) { + var s = new UnitTestScene(); + s.addChild(restartUnitTest()); + director.runScene(s); + }, + onNextCallback:function (sender) { + var s = new UnitTestScene(); + s.addChild(nextUnitTest()); + director.runScene(s); + }, + onBackCallback:function (sender) { + var s = new UnitTestScene(); + s.addChild(previousUnitTest()); + director.runScene(s); + }, + + // automation + numberOfPendingTests:function() { + return ( (arrayOfUnitTest.length-1) - unitTestSceneIdx ); + }, + + getTestNumber:function() { + return unitTestSceneIdx; + } + +}); + +//------------------------------------------------------------------ +// +// RectUnitTest +// +//------------------------------------------------------------------ +var RectUnitTest = UnitTestBase.extend({ + _title:"Rect Unit Test", + _subtitle:"See console for possible errors", + + onEnter:function () { + this._super(); + this.runTest(); + }, + + runTest:function () { + + var ret = []; + var rectA; + var rectB; + var rectC; + var point; + var r; + + this.log("Test 1: rectIntersectsRect 1"); + rectA = cc.rect(0,0,5,10); + rectB = cc.rect(4,9,5,10); + r = cc.rectIntersectsRect(rectA, rectB); + if(!r) + throw "Fail rectIntersectsRect 1"; + ret.push(r); + + this.log("Test 2: rectIntersectsRect 2"); + rectA = cc.rect(0,0,5,10); + rectB = cc.rect(40,90,5,10); + r = cc.rectIntersectsRect(rectA, rectB); + if(r) + throw "Fail rectIntersectsRect 2"; + ret.push(r); + + this.log("Test 3: rectIntersection"); + rectA = cc.rect(0,0,5,10); + rectB = cc.rect(4,9,5,10); + rectC = cc.rectIntersection(rectA, rectB); + r = cc.rectEqualToRect(rectC, cc.rect(4,9,1,1) ); + if(!r) + throw "Fail rectIntersection"; + ret.push(r); + + this.log("Test 4: rectUnion"); + rectA = cc.rect(0,0,5,10); + rectB = cc.rect(4,9,5,10); + rectC = cc.rectUnion(rectA, rectB); + r = cc.rectEqualToRect(rectC, cc.rect(0,0,9,19) ); + if(!r) + throw "Fail rectUnion"; + ret.push(r); + + this.log("Test 5: rectContainsPoint 1"); + rectA = cc.rect(0,0,5,10); + point = cc.p(1,1); + r = cc.rectContainsPoint(rectA, point); + if(!r) + throw "Fail rectContainsPoint 1"; + ret.push(r); + + this.log("Test 6: rectContainsPoint 2"); + rectA = cc.rect(0,0,5,10); + point = cc.p(1,-1); + r = cc.rectContainsPoint(rectA, point); + if(r) + throw "Fail rectContainsPoint 2"; + ret.push(r); + + this.log("Test 7: rect property x"); + rectA = cc.rect(1,2,3,4); + if( rectA.x != 1) + throw "Fail rect property x"; + ret.push(rectA.x); + + this.log("Test 8: rect property y"); + rectA = cc.rect(1,2,3,4); + if( rectA.y != 2) + throw "Fail rect property y"; + ret.push(rectA.y); + + this.log("Test 9: rect property width"); + rectA = cc.rect(1,2,3,4); + if( rectA.width != 3) + throw "Fail rect property width"; + ret.push(rectA.width); + + this.log("Test 10: rect property height"); + rectA = cc.rect(1,2,3,4); + if( rectA.height != 4) + throw "Fail rect property height"; + ret.push(rectA.height); + + this.log("Test 11: getBoundingBox()"); + var node = new cc.Node(); + node.width = 99; + node.height = 101; + var bb = node.getBoundingBox(); + if( bb.height != 101 || bb.width != 99) + throw "Fail getBoundingBox()"; + ret.push( bb.height ); + ret.push( bb.width ); + return ret; + }, + + // + // Automation + // + testDuration:0.1, + + getExpectedResult:function() { + var ret = [true,false,true,true,true,false,1,2,3,4,101,99]; + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = this.runTest(); + return JSON.stringify(ret); + } + +}); + +//------------------------------------------------------------------ +// +// DictionaryToFromTest +// +//------------------------------------------------------------------ +var DictionaryToFromTest = UnitTestBase.extend({ + _title:"Dictionary To/From Test", + _subtitle:"Sends and receives a dictionary to JSB", + + ctor:function() { + this._super(); + + this.runTest(); + }, + + runTest:function() { + var frameCache = cc.spriteFrameCache; + frameCache.addSpriteFrames(s_grossiniPlist); + + // Purge previously loaded animation + var animCache = cc.animationCache; + animCache.addAnimations(s_animations2Plist); + + var normal = animCache.getAnimation("dance_1"); + var frame = normal.getFrames()[0]; + var dict = frame.getUserInfo(); + this.log( JSON.stringify(dict) ); + frame.setUserInfo( { + "array":[1,2,3,"hello world"], + "bool0":0, // false XXX + "bool1":1, // true XXX + "dict":{"key1":"value1", "key2":2}, + "number":42, + "string":"hello!" + }); + + dict = frame.getUserInfo(); + this.log(JSON.stringify(dict)); + return dict; + }, + + // + // Automation + // + testDuration:0.1, + + getExpectedResult:function() { + var ret = this.sortObject( {"array":[1,2,3,"hello world"],"bool0":0,"bool1":1,"dict":{"key1":"value1","key2":2},"number":42,"string":"hello!"} ); + + return JSON.stringify(ret); + }, + + getCurrentResult:function() { + var ret = this.sortObject( this.runTest() ); + return JSON.stringify(ret); + } +}); + +var UnitTestScene = TestScene.extend({ + runThisTest:function (num) { + unitTestSceneIdx = (num || num == 0) ? (num - 1) : -1; + var layer = nextUnitTest(); + this.addChild(layer); + + director.runScene(this); + } +}); + +// +// Flow control +// + +var arrayOfUnitTest = [ + + RectUnitTest, + DictionaryToFromTest + +]; + +var nextUnitTest = function () { + unitTestSceneIdx++; + unitTestSceneIdx = unitTestSceneIdx % arrayOfUnitTest.length; + + return new arrayOfUnitTest[unitTestSceneIdx](); +}; +var previousUnitTest = function () { + unitTestSceneIdx--; + if (unitTestSceneIdx < 0) + unitTestSceneIdx += arrayOfUnitTest.length; + + return new arrayOfUnitTest[unitTestSceneIdx](); +}; +var restartUnitTest = function () { + return new arrayOfUnitTest[unitTestSceneIdx](); +}; + diff --git a/tests/js-tests/src/XHRTest/XHRArrayBufferTest.js b/tests/js-tests/src/XHRTest/XHRArrayBufferTest.js new file mode 100644 index 0000000000..e155546948 --- /dev/null +++ b/tests/js-tests/src/XHRTest/XHRArrayBufferTest.js @@ -0,0 +1,121 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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. + ****************************************************************************/ + +//some utils functions +function ensureLeftAligned (label) { + label.anchorX = 0; + label.anchorY = 1; + label.textAlign = cc.TEXT_ALIGNMENT_LEFT; +} + +function streamXHREventsToLabel ( xhr, label, textbox, method ) { + // Simple events + ['loadstart', 'abort', 'error', 'load', 'loadend', 'timeout'].forEach(function (eventname) { + xhr["on" + eventname] = function () { + label.string += "\nEvent : " + eventname + } + }); + + // Special event + xhr.onreadystatechange = function () { + if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status <= 207)) { + var httpStatus = xhr.statusText; + var response = xhr.responseText.substring(0, 100) + "..."; + textbox.string = method + " Response (100 chars):\n" + textbox.string += response + label.string += "\nStatus: Got " + method + " response! " + httpStatus + } + } +} + + +var XHRArrayBufferTestScene = TestScene.extend({ + ctor:function () { + this._super(true); + var xhrLayer = new XHRArrayBufferTestLayer(); + this.addChild(xhrLayer); + }, + runThisTest:function () { + cc.director.runScene(this); + }, + MainMenuCallback:function (sender) { + this._super(sender); + } +}); + +var XHRArrayBufferTestLayer = cc.Layer.extend({ + ctor:function () { + this._super(); + }, + + onEnter: function() { + this._super(); + var l = new cc.LabelTTF("Get infos via XHR", "Thonburi", 16); + this.addChild(l, 1); + l.x = winSize.width / 2; + l.y = winSize.height - 60; + + this.sendPostArrayBuffer(); + }, + + sendPostArrayBuffer: function() { + var statusPostLabel = new cc.LabelTTF("Status:", "Thonburi", 12); + this.addChild(statusPostLabel, 1); + + statusPostLabel.x = 10; + statusPostLabel.y = winSize.height - 100; + ensureLeftAligned(statusPostLabel); + statusPostLabel.setString("Status: Send Post Request to httpbin.org with ArrayBuffer"); + + + var responseLabel = new cc.LabelTTF("", "Thonburi", 16); + this.addChild(responseLabel, 1); + ensureLeftAligned(responseLabel); + responseLabel.x = 10; + responseLabel.y = winSize.height / 2; + + var xhr = cc.loader.getXMLHttpRequest(); + streamXHREventsToLabel(xhr, statusPostLabel, responseLabel, "POST"); + + xhr.open("POST", "http://httpbin.org/post"); + //set Content-type "text/plain" to post ArrayBuffer or ArrayBufferView + xhr.setRequestHeader("Content-Type","text/plain"); + // Uint8Array is an ArrayBufferView + xhr.send(new Uint8Array([1,2,3,4,5])); + }, + + scrollViewDidScroll:function (view) { + }, + scrollViewDidZoom:function (view) { + } +}); + +var runXHRArrayBufferTest = function () { + var pScene = new cc.Scene(); + var pLayer = new XHRArrayBufferTestLayer(); + pScene.addChild(pLayer); + cc.director.runScene(pScene); +}; diff --git a/tests/js-tests/src/XHRTest/XHRTest.js b/tests/js-tests/src/XHRTest/XHRTest.js new file mode 100644 index 0000000000..002da553db --- /dev/null +++ b/tests/js-tests/src/XHRTest/XHRTest.js @@ -0,0 +1,181 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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. + ****************************************************************************/ + +//some utils functions +function ensureLeftAligned (label) { + label.anchorX = 0; + label.anchorY = 1; + label.textAlign = cc.TEXT_ALIGNMENT_LEFT; +} + +function streamXHREventsToLabel ( xhr, label, textbox, method ) { + // Simple events + ['loadstart', 'abort', 'error', 'load', 'loadend', 'timeout'].forEach(function (eventname) { + xhr["on" + eventname] = function () { + label.string += "\nEvent : " + eventname + } + }); + + // Special event + xhr.onreadystatechange = function () { + if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status <= 207)) { + var httpStatus = xhr.statusText; + var response = xhr.responseText.substring(0, 100) + "..."; + textbox.string = method + " Response (100 chars):\n" + textbox.string += response + label.string += "\nStatus: Got " + method + " response! " + httpStatus + } + } +} + + +var XHRTestScene = TestScene.extend({ + ctor:function () { + this._super(true); + var xhrLayer = new XHRTestLayer(); + this.addChild(xhrLayer); + }, + runThisTest:function () { + cc.director.runScene(this); + }, + MainMenuCallback:function (sender) { + this._super(sender); + } +}); + +var XHRTestLayer = cc.Layer.extend({ + ctor:function () { + this._super(); + }, + + onEnter: function() { + this._super(); + var l = new cc.LabelTTF("Get infos via XHR", "Thonburi", 16); + this.addChild(l, 1); + l.x = winSize.width / 2; + l.y = winSize.height - 60; + + this.sendGetRequest(); + this.sendPostPlainText(); + this.sendPostForms(); + }, + + sendGetRequest: function() { + var statusGetLabel = new cc.LabelTTF("Status:", "Thonburi", 12); + this.addChild(statusGetLabel, 1); + + statusGetLabel.x = 10 + statusGetLabel.y = winSize.height - 100; + ensureLeftAligned(statusGetLabel); + statusGetLabel.setString("Status: Send Get Request to httpbin.org"); + + var responseLabel = new cc.LabelTTF("", "Thonburi", 16); + this.addChild(responseLabel, 1); + + ensureLeftAligned(responseLabel); + responseLabel.x = 10; + responseLabel.y = winSize.height / 2; + + var xhr = cc.loader.getXMLHttpRequest(); + streamXHREventsToLabel(xhr, statusGetLabel, responseLabel, "GET"); + // 5 seconds for timeout + xhr.timeout = 5000; + + //set arguments with ?xxx=xxx&yyy=yyy + xhr.open("GET", "http://httpbin.org/get?show_env=1", true); + xhr.send(); + }, + + sendPostPlainText: function() { + var statusPostLabel = new cc.LabelTTF("Status:", "Thonburi", 12); + this.addChild(statusPostLabel, 1); + + statusPostLabel.x = winSize.width / 10 * 3; + statusPostLabel.y = winSize.height - 100; + ensureLeftAligned(statusPostLabel); + statusPostLabel.setString("Status: Send Post Request to httpbin.org with plain text"); + + + var responseLabel = new cc.LabelTTF("", "Thonburi", 16); + this.addChild(responseLabel, 1); + ensureLeftAligned(responseLabel); + responseLabel.x = winSize.width / 10 * 3; + responseLabel.y = winSize.height / 2; + + var xhr = cc.loader.getXMLHttpRequest(); + streamXHREventsToLabel(xhr, statusPostLabel, responseLabel, "POST"); + + xhr.open("POST", "http://httpbin.org/post"); + //set Content-type "text/plain;charset=UTF-8" to post plain text + xhr.setRequestHeader("Content-Type","text/plain;charset=UTF-8"); + xhr.send("plain text message"); + }, + + sendPostForms: function() { + var statusPostLabel = new cc.LabelTTF("Status:", "Thonburi", 12); + this.addChild(statusPostLabel, 1); + + statusPostLabel.x = winSize.width / 10 * 7; + statusPostLabel.y = winSize.height - 100; + ensureLeftAligned(statusPostLabel); + statusPostLabel.setString("Status: Send Post Request to httpbin.org width form data"); + + var responseLabel = new cc.LabelTTF("", "Thonburi", 16); + this.addChild(responseLabel, 1); + + ensureLeftAligned(responseLabel); + responseLabel.x = winSize.width / 10 * 7; + responseLabel.y = winSize.height / 2; + + var xhr = cc.loader.getXMLHttpRequest(); + streamXHREventsToLabel(xhr, statusPostLabel, responseLabel, "POST"); + + xhr.open("POST", "http://httpbin.org/post"); + //set Content-Type "application/x-www-form-urlencoded" to post form data + //mulipart/form-data for upload + xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); + /** + form : { + "a" : "hello", + "b" : "world" + } + **/ + var args = "a=hello&b=world"; + xhr.send(args); + }, + + scrollViewDidScroll:function (view) { + }, + scrollViewDidZoom:function (view) { + } +}); + +var runXHRTest = function () { + var pScene = new cc.Scene(); + var pLayer = new XHRTestLayer(); + pScene.addChild(pLayer); + cc.director.runScene(pScene); +}; \ No newline at end of file diff --git a/tests/js-tests/src/tests-main.js b/tests/js-tests/src/tests-main.js new file mode 100644 index 0000000000..63a321e51c --- /dev/null +++ b/tests/js-tests/src/tests-main.js @@ -0,0 +1,688 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + 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 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. + ****************************************************************************/ + +// globals +var director = null; +var winSize = null; + +var PLATFORM_JSB = 1 << 0; +var PLATFORM_HTML5 = 1 << 1; +var PLATFORM_HTML5_WEBGL = 1 << 2; +var PLATFROM_ANDROID = 1 << 3; +var PLATFROM_IOS = 1 << 4; +var PLATFORM_MAC = 1 << 5; +var PLATFORM_JSB_AND_WEBGL = PLATFORM_JSB | PLATFORM_HTML5_WEBGL; +var PLATFORM_ALL = PLATFORM_JSB | PLATFORM_HTML5 | PLATFORM_HTML5_WEBGL | PLATFROM_ANDROID | PLATFROM_IOS; +var PLATFROM_APPLE = PLATFROM_IOS | PLATFORM_MAC; + +// automation vars +var autoTestEnabled = autoTestEnabled || false; +var autoTestCurrentTestName = autoTestCurrentTestName || "N/A"; + +var TestScene = cc.Scene.extend({ + ctor:function (bPortrait) { + this._super(); + this.init(); + + var label = new cc.LabelTTF("Main Menu", "Arial", 20); + var menuItem = new cc.MenuItemLabel(label, this.onMainMenuCallback, this); + + var menu = new cc.Menu(menuItem); + menu.x = 0; + menu.y = 0; + menuItem.x = winSize.width - 50; + menuItem.y = 25; + + if(!window.sideIndexBar){ + this.addChild(menu, 1); + } + }, + onMainMenuCallback:function () { + var scene = new cc.Scene(); + var layer = new TestController(); + scene.addChild(layer); + var transition = new cc.TransitionProgressRadialCCW(0.5,scene); + director.runScene(transition); + }, + + runThisTest:function () { + // override me + } + +}); + +//Controller stuff +var LINE_SPACE = 40; +var curPos = cc.p(0,0); + +var TestController = cc.LayerGradient.extend({ + _itemMenu:null, + _beginPos:0, + isMouseDown:false, + + ctor:function() { + this._super(cc.color(0,0,0,255), cc.color(0x46,0x82,0xB4,255)); + + // globals + director = cc.director; + winSize = director.getWinSize(); + + // add close menu + var closeItem = new cc.MenuItemImage(s_pathClose, s_pathClose, this.onCloseCallback, this); + closeItem.x = winSize.width - 30; + closeItem.y = winSize.height - 30; + + var subItem1 = new cc.MenuItemFont("Automated Test: Off"); + subItem1.fontSize = 18; + var subItem2 = new cc.MenuItemFont("Automated Test: On"); + subItem2.fontSize = 18; + + var toggleAutoTestItem = new cc.MenuItemToggle(subItem1, subItem2); + toggleAutoTestItem.setCallback(this.onToggleAutoTest, this); + toggleAutoTestItem.x = winSize.width - toggleAutoTestItem.width / 2 - 10; + toggleAutoTestItem.y = 20; + toggleAutoTestItem.setVisible(false); + if( autoTestEnabled ) + toggleAutoTestItem.setSelectedIndex(1); + + + var menu = new cc.Menu(closeItem, toggleAutoTestItem);//pmenu is just a holder for the close button + menu.x = 0; + menu.y = 0; + + // add menu items for tests + this._itemMenu = new cc.Menu();//item menu is where all the label goes, and the one gets scrolled + + for (var i = 0, len = testNames.length; i < len; i++) { + var label = new cc.LabelTTF(testNames[i].title, "Arial", 24); + var menuItem = new cc.MenuItemLabel(label, this.onMenuCallback, this); + this._itemMenu.addChild(menuItem, i + 10000); + menuItem.x = winSize.width / 2; + menuItem.y = (winSize.height - (i + 1) * LINE_SPACE); + + // enable disable + if ( !cc.sys.isNative) { + if( 'opengl' in cc.sys.capabilities ){ + menuItem.enabled = (testNames[i].platforms & PLATFORM_HTML5) | (testNames[i].platforms & PLATFORM_HTML5_WEBGL); + }else{ + menuItem.setEnabled( testNames[i].platforms & PLATFORM_HTML5 ); + } + } else { + if (cc.sys.os == cc.sys.OS_ANDROID) { + menuItem.setEnabled( testNames[i].platforms & ( PLATFORM_JSB | PLATFROM_ANDROID ) ); + } else if (cc.sys.os == cc.sys.OS_IOS) { + menuItem.setEnabled( testNames[i].platforms & ( PLATFORM_JSB | PLATFROM_IOS) ); + } else if (cc.sys.os == cc.sys.OS_OSX) { + menuItem.setEnabled( testNames[i].platforms & ( PLATFORM_JSB | PLATFORM_MAC) ); + } else { + menuItem.setEnabled( testNames[i].platforms & PLATFORM_JSB ); + } + } + } + + this._itemMenu.width = winSize.width; + this._itemMenu.height = (testNames.length + 1) * LINE_SPACE; + this._itemMenu.x = curPos.x; + this._itemMenu.y = curPos.y; + this.addChild(this._itemMenu); + this.addChild(menu, 1); + + // 'browser' can use touches or mouse. + // The benefit of using 'touches' in a browser, is that it works both with mouse events or touches events + if ('touches' in cc.sys.capabilities) + cc.eventManager.addListener({ + event: cc.EventListener.TOUCH_ALL_AT_ONCE, + onTouchesMoved: function (touches, event) { + var target = event.getCurrentTarget(); + var delta = touches[0].getDelta(); + target.moveMenu(delta); + return true; + } + }, this); + else if ('mouse' in cc.sys.capabilities) { + cc.eventManager.addListener({ + event: cc.EventListener.MOUSE, + onMouseMove: function (event) { + if(event.getButton() == cc.EventMouse.BUTTON_LEFT) + event.getCurrentTarget().moveMenu(event.getDelta()); + }, + onMouseScroll: function (event) { + var delta = cc.sys.isNative ? event.getScrollY() * 6 : -event.getScrollY(); + event.getCurrentTarget().moveMenu({y : delta}); + return true; + } + }, this); + } + }, + onEnter:function(){ + this._super(); + this._itemMenu.y = TestController.YOffset; + }, + onMenuCallback:function (sender) { + TestController.YOffset = this._itemMenu.y; + var idx = sender.getLocalZOrder() - 10000; + // get the userdata, it's the index of the menu item clicked + // create the test scene and run it + + autoTestCurrentTestName = testNames[idx].title; + + var testCase = testNames[idx]; + var res = testCase.resource || []; + cc.LoaderScene.preload(res, function () { + var scene = testCase.testScene(); + if (scene) { + scene.runThisTest(); + } + }, this); + }, + onCloseCallback:function () { + window.history && window.history.go(-1); + }, + onToggleAutoTest:function() { + autoTestEnabled = !autoTestEnabled; + }, + + moveMenu:function(delta) { + var newY = this._itemMenu.y + delta.y; + if (newY < 0 ) + newY = 0; + + if( newY > ((testNames.length + 1) * LINE_SPACE - winSize.height)) + newY = ((testNames.length + 1) * LINE_SPACE - winSize.height); + + this._itemMenu.y = newY; + } +}); +TestController.YOffset = 0; +var testNames = [ + { + title:"ActionManager Test", + platforms: PLATFORM_ALL, + linksrc:"src/ActionManagerTest/ActionManagerTest.js", + testScene:function () { + return new ActionManagerTestScene(); + } + }, + { + title:"Actions Test", + platforms: PLATFORM_ALL, + linksrc:"src/ActionsTest/ActionsTest.js", + testScene:function () { + return new ActionsTestScene(); + } + }, + { + title:"Bake Layer Test", + platforms: PLATFORM_HTML5, + linksrc:"src/BakeLayerTest/BakeLayerTest.js", + testScene:function () { + return new BakeLayerTestScene(); + } + }, + { + title:"BillBoard Test", + platforms: PLATFORM_JSB, + linksrc:"src/BillBoardTest/BillBoardTest.js", + testScene:function () { + return new BillBoardTestScene(); + } + }, + { + title:"Box2D Test", + resource:g_box2d, + platforms: PLATFORM_HTML5, + linksrc:"src/Box2dTest/Box2dTest.js", + testScene:function () { + return new Box2DTestScene(); + } + }, + { + title:"Camera3D Test", + platforms: PLATFORM_JSB, + linksrc:"src/Camera3DTest/Camera3DTest.js", + testScene:function () { + return new Camera3DTestScene(); + } + }, + { + title:"Chipmunk Test", + platforms: PLATFORM_ALL, + linksrc:"src/ChipmunkTest/ChipmunkTest.js", + testScene:function () { + return new ChipmunkTestScene(); + } + }, + //"BugsTest", + { + title:"Click and Move Test", + platforms: PLATFORM_ALL, + linksrc:"src/ClickAndMoveTest/ClickAndMoveTest.js", + testScene:function () { + return new ClickAndMoveTestScene(); + } + }, + { + title:"ClippingNode Test", + platforms: PLATFORM_ALL, + linksrc:"src/ClippingNodeTest/ClippingNodeTest.js", + testScene:function () { + return new ClippingNodeTestScene(); + } + }, + { + title:"CocosDenshion Test", + resource:g_cocosdeshion, + platforms: PLATFORM_ALL, + linksrc:"src/CocosDenshionTest/CocosDenshionTest.js", + testScene:function () { + return new CocosDenshionTestScene(); + } + }, + { + title:"CocoStudio Test", + resource:g_cocoStudio, + platforms: PLATFORM_ALL, + linksrc:"", + testScene:function () { + return new CocoStudioTestScene(); + } + }, + { + title:"CurrentLanguage Test", + platforms: PLATFORM_ALL, + linksrc:"src/CurrentLanguageTest/CurrentLanguageTest.js", + testScene:function () { + return new CurrentLanguageTestScene(); + } + }, + //"CurlTest", + { + title:"DrawPrimitives Test", + platforms: PLATFORM_ALL, + linksrc:"src/DrawPrimitivesTest/DrawPrimitivesTest.js", + testScene:function () { + return new DrawPrimitivesTestScene(); + } + }, + { + title:"EaseActions Test", + platforms: PLATFORM_ALL, + linksrc:"src/EaseActionsTest/EaseActionsTest.js", + testScene:function () { + return new EaseActionsTestScene(); + } + }, + { + title:"Event Manager Test", + resource:g_eventDispatcher, + platforms: PLATFORM_ALL, + linksrc:"src/NewEventManagerTest/NewEventManagerTest.js", + testScene:function () { + return new EventDispatcherTestScene(); + } + }, + { + title:"Event Test", + platforms: PLATFORM_ALL, + linksrc:"src/EventTest/EventTest.js", + testScene:function () { + return new EventTestScene(); + } + }, + { + title:"Extensions Test", + resource:g_extensions, + platforms: PLATFORM_ALL, + linksrc:"", + testScene:function () { + return new ExtensionsTestScene(); + } + }, + { + title:"Effects Test", + platforms: PLATFORM_JSB_AND_WEBGL, + linksrc:"src/EffectsTest/EffectsTest.js", + testScene:function () { + return new EffectsTestScene(); + } + }, + { + title:"Effects Advanced Test", + platforms: PLATFORM_JSB_AND_WEBGL, + linksrc:"src/EffectsAdvancedTest/EffectsAdvancedTest.js", + testScene:function () { + return new EffectAdvanceScene(); + } + }, + { + title:"Facebook SDK Test", + platforms: PLATFROM_ANDROID | PLATFROM_IOS | PLATFORM_HTML5, + linksrc:"src/FacebookTest/FacebookTestsManager.js", + testScene:function () { + return new FacebookTestScene(); + } + }, + { + title:"Font Test", + resource:g_fonts, + platforms: PLATFORM_ALL, + linksrc:"src/FontTest/FontTest.js", + testScene:function () { + return new FontTestScene(); + } + }, + { + title:"UI Test", + resource:g_ui, + platforms: PLATFORM_ALL, + linksrc:"", + testScene:function () { + return new GUITestScene(); + } + }, + //"HiResTest", + { + title:"Interval Test", + platforms: PLATFORM_ALL, + linksrc:"src/IntervalTest/IntervalTest.js", + testScene:function () { + return new IntervalTestScene(); + } + }, + { + title:"Label Test", + resource:g_label, + platforms: PLATFORM_ALL, + linksrc:"src/LabelTest/LabelTest.js", + testScene:function () { + return new LabelTestScene(); + } + }, + { + title:"Layer Test", + platforms: PLATFORM_ALL, + linksrc:"src/LayerTest/LayerTest.js", + testScene:function () { + return new LayerTestScene(); + } + }, + { + title:"Light Test", + platforms: PLATFORM_JSB, + linksrc:"src/LightTest/LightTest.js", + testScene:function () { + return new LightTestScene(); + } + }, + { + title:"Loader Test", + platforms: PLATFORM_ALL, + linksrc:"src/LoaderTest/LoaderTest.js", + testScene:function () { + return new LoaderTestScene(); + } + }, + { + title:"Menu Test", + resource:g_menu, + platforms: PLATFORM_ALL, + linksrc:"src/MenuTest/MenuTest.js", + testScene:function () { + return new MenuTestScene(); + } + }, + { + title:"MotionStreak Test", + platforms: PLATFORM_JSB_AND_WEBGL, + linksrc:"src/MotionStreakTest/MotionStreakTest.js", + testScene:function () { + return new MotionStreakTestScene(); + } + }, + { + title:"Node Test", + platforms: PLATFORM_ALL, + linksrc:"src/CocosNodeTest/CocosNodeTest.js", + testScene:function () { + return new NodeTestScene(); + } + }, + { + title:"OpenGL Test", + resource:g_opengl_resources, + platforms: PLATFORM_JSB_AND_WEBGL, + linksrc:"src/OpenGLTest/OpenGLTest.js", + testScene:function () { + return new OpenGLTestScene(); + } + }, + { + title:"Parallax Test", + resource:g_parallax, + platforms: PLATFORM_ALL, + linksrc:"src/ParallaxTest/ParallaxTest.js", + testScene:function () { + return new ParallaxTestScene(); + } + }, + { + title:"Particle Test", + platforms: PLATFORM_ALL, + linksrc:"", + resource:g_particle, + testScene:function () { + return new ParticleTestScene(); + } + }, + { + title:"Path Tests", + platforms: PLATFORM_ALL, + linksrc:"src/PathTest/PathTest.js", + testScene:function () { + return new PathTestScene(); + } + }, + { + title:"Performance Test", + platforms: PLATFORM_ALL, + linksrc:"", + resource:g_performace, + testScene:function () { + return new PerformanceTestScene(); + } + }, + { + title:"ProgressActions Test", + platforms: PLATFORM_ALL, + linksrc:"src/ProgressActionsTest/ProgressActionsTest.js", + testScene:function () { + return new ProgressActionsTestScene(); + } + }, + { + title:"Reflection Test", + platforms: PLATFROM_ANDROID | PLATFROM_APPLE, + linksrc:"src/ReflectionTest/ReflectionTest.js", + testScene:function () { + return new ReflectionTestScene(); + } + }, + { + title:"RenderTexture Test", + platforms: PLATFORM_ALL, + linksrc:"src/RenderTextureTest/RenderTextureTest.js", + testScene:function () { + return new RenderTextureTestScene(); + } + }, + { + title:"RotateWorld Test", + platforms: PLATFORM_ALL, + linksrc:"src/RotateWorldTest/RotateWorldTest.js", + testScene:function () { + return new RotateWorldTestScene(); + } + }, + { + title:"Scene Test", + platforms: PLATFORM_ALL, + linksrc:"src/SceneTest/SceneTest.js", + testScene:function () { + return new SceneTestScene(); + } + }, + { + title:"Scheduler Test", + platforms: PLATFORM_ALL, + linksrc:"src/SchedulerTest/SchedulerTest.js", + testScene:function () { + return new SchedulerTestScene(); + } + }, + { + title:"Spine Test", + resource: g_spine, + platforms: PLATFORM_ALL, + linksrc:"src/SpineTest/SpineTest.js", + testScene:function () { + return new SpineTestScene(); + } + }, + { + title:"Sprite3D Test", + platforms: PLATFORM_JSB, + linksrc:"src/Sprite3DTest/Sprite3DTest.js", + testScene:function () { + return new Sprite3DTestScene(); + } + }, + { + title:"Sprite Test", + resource:g_sprites, + platforms: PLATFORM_ALL, + linksrc:"src/SpriteTest/SpriteTest.js", + testScene:function () { + return new SpriteTestScene(); + } + }, + { + title:"Scale9Sprite Test", + resource:g_s9s_blocks, + platforms: PLATFORM_ALL, + linksrc:"src/ExtensionsTest/S9SpriteTest/S9SpriteTest.js", + testScene:function () { + return new S9SpriteTestScene(); + } + }, + { + title:"TextInput Test", + platforms: PLATFORM_HTML5, + linksrc:"src/TextInputTest/TextInputTest.js", + testScene:function () { + return new TextInputTestScene(); + } + }, + //"Texture2DTest", + { + title:"TextureCache Test", + platforms: PLATFORM_ALL, + linksrc:"src/TextureCacheTest/TextureCacheTest.js", + testScene:function () { + return new TexCacheTestScene(); + } + }, + { + title:"TileMap Test", + resource:g_tilemaps, + platforms: PLATFORM_ALL, + linksrc:"src/TileMapTest/TileMapTest.js", + testScene:function () { + return new TileMapTestScene(); + } + }, + { + title:"Touches Test", + resource:g_touches, + platforms: PLATFORM_HTML5, + linksrc:"src/TouchesTest/TouchesTest.js", + testScene:function () { + return new TouchesTestScene(); + } + }, + { + title:"Transitions Test", + resource:g_transitions, + platforms: PLATFORM_ALL, + linksrc:"", + testScene:function () { + return new TransitionsTestScene(); + } + }, + { + title:"Unit Tests", + platforms: PLATFORM_ALL, + linksrc:"src/UnitTest/UnitTest.js", + testScene:function () { + return new UnitTestScene(); + } + }, + { + title:"Sys Tests", + platforms: PLATFORM_ALL, + linksrc:"src/SysTest/SysTest.js", + testScene:function () { + return new SysTestScene(); + } + }, + { + title:"cocos2d JS Presentation", + platforms: PLATFORM_JSB, + linksrc:"src/Presentation/Presentation.js", + testScene:function () { + return new PresentationScene(); + } + }, + { + title:"XMLHttpRequest", + platforms: PLATFORM_ALL, + linksrc:"src/XHRTest/XHRTest.js", + testScene:function () { + return new XHRTestScene(); + } + }, + { + title:"XMLHttpRequest send ArrayBuffer", + platforms: PLATFORM_ALL, + linksrc:"src/XHRTest/XHRArrayBufferTest.js", + testScene:function () { + return new XHRArrayBufferTestScene(); + } + } + + //"UserDefaultTest", + //"ZwoptexTest", +]; \ No newline at end of file diff --git a/tests/js-tests/src/tests_resources.js b/tests/js-tests/src/tests_resources.js new file mode 100644 index 0000000000..b17d38166c --- /dev/null +++ b/tests/js-tests/src/tests_resources.js @@ -0,0 +1,1092 @@ +// Resources prefix +var s_resprefix = ""; + +var s_pathGrossini = "Images/grossini.png"; +var s_pathSister1 = "Images/grossinis_sister1.png"; +var s_pathSister2 = "Images/grossinis_sister2.png"; +var s_pathB1 = "Images/b1.png"; +var s_pathB2 = "Images/b2.png"; +var s_pathR1 = "Images/r1.png"; +var s_pathR2 = "Images/r2.png"; +var s_pathF1 = "Images/f1.png"; +var s_pathF2 = "Images/f2.png"; +var s_pathBlock = "Images/blocks.png"; +var s_back = "Images/background.png"; +var s_back1 = "Images/background1.png"; +var s_back2 = "Images/background2.png"; +var s_back3 = "Images/background3.png"; +var s_stars1 = "Images/stars.png"; +var s_stars2 = "Images/stars2.png"; +var s_fire = "Images/fire.png"; +var s_snow = "Images/snow.png"; +var s_streak = "Images/streak.png"; +var s_playNormal = "Images/btn-play-normal.png"; +var s_playSelect = "Images/btn-play-selected.png"; +var s_aboutNormal = "Images/btn-about-normal.png"; +var s_aboutSelect = "Images/btn-about-selected.png"; +var s_highNormal = "Images/btn-highscores-normal.png"; +var s_highSelect = "Images/btn-highscores-selected.png"; +var s_ball = "Images/ball.png"; +var s_paddle = "Images/paddle.png"; +var s_pathClose = "Images/close.png"; +var s_menuItem = "Images/menuitemsprite.png"; +var s_shapeModeMenuItem = "Images/shapemode.png"; +var s_textureModeMenuItem = "Images/texturemode.png"; +var s_MovementMenuItem = "Images/movement.png"; +var s_sendScore = "Images/SendScoreButton.png"; +var s_pressSendScore = "Images/SendScoreButtonPressed.png"; +var s_power = "Images/powered.png"; +var s_atlasTest = "Images/atlastest.png"; +var s_stars2Grayscale = "Images/stars2-grayscale.png"; +var s_starsGrayscale = "Images/stars-grayscale.png"; +var s_grossini_dance_atlas = "Images/grossini_dance_atlas.png"; +var s_piece = "Images/piece.png"; +var s_grossini_dance_atlas_mono = "Images/grossini_dance_atlas-mono.png"; +var s_lookup_desktop_plist = "Images/lookup-desktop.plist"; +var s_lookup_mobile_plist = "Images/lookup-mobile.plist"; +var s_lookup_html5_plist = "Images/lookup-html5.plist"; + +var s_grossini = "animations/grossini.png"; +var s_grossini_gray = "animations/grossini_gray.png"; +var s_grossini_blue = "animations/grossini_blue.png"; +var s_grossini_aliases = "animations/grossini-aliases.png"; +var s_dragon_animation = "animations/dragon_animation.png"; +var s_ghosts = "animations/ghosts.png"; +var s_grossini_family = "animations/grossini_family.png"; + +var s_tcc_issue_1 = "animations/tcc_issue_1.png"; +var s_tcc_issue_2 = "animations/tcc_issue_2.png"; +var s_tcc_issue_1_plist = "animations/tcc_issue_1.plist"; +var s_tcc_issue_2_plist = "animations/tcc_issue_2.plist"; + +var s_Cowboy_json = "armatuCowboy.ExportJson"; +var s_Cowboy_plist = "armatuCowboy0.plist"; +var s_Cowboy_png = "armatuCowboy0.png"; +var s_hero_json = "armatuhero.ExportJson"; +var s_hero0_plist = "armatuhero0.plist"; +var s_hero0_png = "armatuhero0.png"; +var s_horse_json = "armatuhorse.ExportJson"; +var s_horse0_plist = "armatuhorse0.plist"; +var s_horse0_png = "armatuhorse0.png"; +var s_bear_json = "armatubear.ExportJson"; +var s_bear0_plist = "armatubear0.plist"; +var s_bear0_png = "armatubear0.png"; +var s_blood_plist = "armatublood.plist"; +var s_HeroAnimation_json = "armatuHeroAnimation.ExportJson"; +var s_HeroAnimation0_plist = "armatuHeroAnimation0.plist"; +var s_HeroAnimation0_png = "armatuHeroAnimation0.png"; +var s_cyborg_plist = "armatucyborg.plist"; +var s_cyborg_png = "armatucyborg.png"; +var s_cyborg_xml = "armatucyborg.xml"; +var s_Dragon_plist = "armatuDragon.plist"; +var s_Dragon_png = "armatuDragon.png"; +var s_Dragon_xml = "armatuDragon.xml"; +var s_knight_plist = "armatuknight.plist"; +var s_knight_png = "armatuknight.png"; +var s_knight_xml = "armatuknight.xml"; +var s_robot_plist = "armaturobot.plist"; +var s_robot_png = "armaturobot.png"; +var s_robot_xml = "armaturobot.xml"; +var s_weapon_plist = "armatuweapon.plist"; +var s_weapon_png = "armatuweapon.png"; +var s_weapon_xml = "armatuweapon.xml"; +var s_testEasing_json = "armatutestEasing.ExportJson"; +var s_testEasing0_plist = "armatutestEasing0.plist"; +var s_testEasing0_png = "armatutestEasing0.png"; + +var s_s9s_blocks9 = "Images/blocks9ss.png"; +var s_s9s_blocks9_plist = "Images/blocks9ss.plist"; +var s_blocks9 = "Images/blocks9.png"; + +var s_s9s_ui = "Images/ui.png"; +var s_s9s_ui_plist = "Images/ui.plist"; + +var s_boilingFoamPlist = "Images/BoilingFoam.plist"; +var s_grossiniPlist = "animations/grossini.plist"; +var s_grossini_grayPlist = "animations/grossini_gray.plist"; +var s_grossini_bluePlist = "animations/grossini_blue.plist"; +var s_grossini_aliasesPlist = "animations/grossini-aliases.plist"; +var s_ghostsPlist = "animations/ghosts.plist"; +var s_grossini_familyPlist = "animations/grossini_family.plist"; +var s_animations2Plist = "animations/animations-2.plist"; +var s_animationsPlist = "animations/animations.plist"; + +var s_helloWorld = "Images/HelloWorld.png"; +var s_grossiniDance01 = "Images/grossini_dance_01.png"; +var s_grossiniDance02 = "Images/grossini_dance_02.png"; +var s_grossiniDance03 = "Images/grossini_dance_03.png"; +var s_grossiniDance04 = "Images/grossini_dance_04.png"; +var s_grossiniDance05 = "Images/grossini_dance_05.png"; +var s_grossiniDance06 = "Images/grossini_dance_06.png"; +var s_grossiniDance07 = "Images/grossini_dance_07.png"; +var s_grossiniDance08 = "Images/grossini_dance_08.png"; +var s_grossiniDance09 = "Images/grossini_dance_09.png"; +var s_grossiniDance10 = "Images/grossini_dance_10.png"; +var s_grossiniDance11 = "Images/grossini_dance_11.png"; +var s_grossiniDance12 = "Images/grossini_dance_12.png"; +var s_grossiniDance13 = "Images/grossini_dance_13.png"; +var s_grossiniDance14 = "Images/grossini_dance_14.png"; + +var s_arrows = "Images/arrows.png"; +var s_arrowsBar = "Images/arrowsBar.png"; +var s_arrows_hd = "Images/arrows-hd.png"; +var s_arrowsBar_hd = "Images/arrowsBar-hd.png"; + +// tilemaps resource +var s_tilesPng = "TileMaps/tiles.png"; +var s_levelMapTga = "TileMaps/levelmap.tga"; +var s_fixedOrthoTest2Png = "TileMaps/fixed-ortho-test2.png"; +var s_hexaTilesPng = "TileMaps/hexa-tiles.png"; +var s_isoTestPng = "TileMaps/iso-test.png"; +var s_isoTest2Png = "TileMaps/iso-test2.png"; +var s_isoPng = "TileMaps/iso.png"; +var s_orthoTest1BwPng = "TileMaps/ortho-test1_bw.png"; +var s_orthoTest1Png = "TileMaps/ortho-test1.png"; +var s_tilesHdPng = "TileMaps/tiles-hd.png"; +var s_tmwDesertSpacingHdPng = "TileMaps/tmw_desert_spacing-hd.png"; +var s_tmwDesertSpacingPng = "TileMaps/tmw_desert_spacing.png"; +var s_tileISOOffsetPng = "TileMaps/tile_iso_offset.png"; +var s_tileISOOffsetTmx = "TileMaps/tile_iso_offset.tmx"; + +var s_fnTuffyBoldItalicCharmapPng = "fonts/tuffy_bold_italic-charmap.png"; +var s_fpsImages = "fonts/fps_images.png"; +var s_bitmapFontTest = "fonts/bitmapFontTest.png"; +var s_bitmapFontTest2 = "fonts/bitmapFontTest2.png"; +var s_bitmapFontTest3 = "fonts/bitmapFontTest3.png"; +var s_bitmapFontTest4 = "fonts/bitmapFontTest4.png"; +var s_bitmapFontTest5 = "fonts/bitmapFontTest5.png"; +var s_konqa32 = "fonts/konqa32.png"; +var s_konqa32_hd = "fonts/konqa32-hd.png"; +var s_bitmapFontChinese = "fonts/bitmapFontChinese.png"; +var s_arial16 = "fonts/arial16.png"; +var s_larabie_16 = "fonts/larabie-16.png"; +var s_larabie_16_hd = "fonts/larabie-16-hd.png"; +var s_futura48 = "fonts/futura-48.png"; +var s_arial_unicode_26 = "fonts/arial-unicode-26.png"; + +var s_bitmapFontTest_fnt = "fonts/bitmapFontTest.fnt"; +var s_bitmapFontTest2_fnt = "fonts/bitmapFontTest2.fnt"; +var s_bitmapFontTest3_fnt = "fonts/bitmapFontTest3.fnt"; +var s_bitmapFontTest4_fnt = "fonts/bitmapFontTest4.fnt"; +var s_bitmapFontTest5_fnt = "fonts/bitmapFontTest5.fnt"; +var s_konqa32_fnt = "fonts/konqa32.fnt"; +var s_konqa32_hd_fnt = "fonts/konqa32-hd.fnt"; +var s_bitmapFontChinese_fnt = "fonts/bitmapFontChinese.fnt"; +var s_arial16_fnt = "fonts/arial16.fnt"; +var s_futura48_fnt = "fonts/futura-48.fnt"; +var s_helvetica32_fnt = "fonts/helvetica-32.fnt"; +var s_geneva32_fnt = "fonts/geneva-32.fnt"; +var s_helvetica_helvetica_32_png = "fonts/helvetica-geneva-32.png"; +var s_arial_unicode_26_fnt = "fonts/arial-unicode-26.fnt"; +var s_markerFelt_fnt = "fonts/markerFelt.fnt"; +var s_markerFelt_png = "fonts/markerFelt.png"; +var s_markerFelt_hd_fnt = "fonts/markerFelt-hd.fnt"; +var s_markerFelt_hd_png = "fonts/markerFelt-hd.png"; + +var s_larabie_16_plist = "fonts/larabie-16.plist"; +var s_larabie_16_hd_plist = "fonts/larabie-16-hd.plist"; +var s_tuffy_bold_italic_charmap = "fonts/tuffy_bold_italic-charmap.plist"; +var s_tuffy_bold_italic_charmap_hd = "fonts/tuffy_bold_italic-charmap-hd.plist"; + +var s_particles = "Images/particles.png"; +var s_particles_hd = "Images/particles-hd.png"; +var s_texture512 = "Images/texture512x512.png"; +var s_hole_effect_png = "Images/hole_effect.png"; +var s_hole_stencil_png = "Images/hole_stencil.png"; +var s_pathFog = "Images/Fog.png"; +var s_circle_plist = "Images/bugs/circle.plist"; +var s_circle_png = "Images/bugs/circle.png"; + +var s_extensions_background = "extensions/background.png"; +var s_extensions_buttonBackground = "extensions/buttonBackground.png"; +var s_extensions_button = "extensions/button.png"; +var s_extensions_buttonHighlighted = "extensions/buttonHighlighted.png"; +var s_extensions_ribbon = "extensions/ribbon.png"; +var s_image_icon = "Images/Icon.png"; +var s_html5_logo = "Images/cocos-html5.png"; + +var g_resources = [ + //global + s_grossini_dance_atlas, + s_pathFog, + s_circle_plist, + s_circle_png, + s_texture512, + s_hole_effect_png, + s_hole_stencil_png, + s_pathB1, + s_pathB2, + s_pathR1, + s_pathR2, + s_pathF1, + s_pathF2, + s_pathBlock, + s_back3, + s_fire, + s_pathClose, + s_pathGrossini, + s_pathSister1, + s_pathSister2, + s_grossiniDance01, + s_grossiniDance02, + s_grossiniDance03, + s_grossiniDance04, + s_grossiniDance05, + s_grossiniDance06, + s_grossiniDance07, + s_grossiniDance08, + s_grossiniDance09, + s_grossiniDance10, + s_grossiniDance11, + s_grossiniDance12, + s_grossiniDance13, + s_grossiniDance14, + + s_grossini, + s_grossiniPlist, + + s_animations2Plist, + s_grossini_blue, + s_grossini_bluePlist, + s_grossini_family, + s_grossini_familyPlist, + s_helloWorld, + s_bitmapFontTest5, + s_playNormal, + s_playSelect, + s_bitmapFontTest5_fnt, + s_extensions_background, + s_extensions_ribbon +]; + +var g_sprites = [ + s_piece, + s_grossini_gray, + s_grossini_blue, + s_grossini_aliases, + s_dragon_animation, + s_ghosts, + s_grossini_family, + + s_grossini_dance_atlas_mono, + s_animationsPlist, + s_grossini_grayPlist, + s_grossini_bluePlist, + s_grossini_aliasesPlist, + s_ghostsPlist, + s_grossini_familyPlist, + + s_tcc_issue_1_plist, + s_tcc_issue_2_plist, + s_tcc_issue_1, + s_tcc_issue_2, + + s_s9s_blocks9_plist, + s_s9s_blocks9, + "Images/dot.png", + "Images/wood.jpg" +]; + +var g_menu = [ + s_bitmapFontTest3_fnt, + s_bitmapFontTest3, + s_aboutNormal, + s_aboutSelect, + s_highNormal, + s_highSelect, + s_menuItem, + s_sendScore, + s_pressSendScore, + s_fpsImages +]; + +var g_touches = [ + s_ball, + s_paddle +]; + +var g_s9s_blocks = [ + s_s9s_blocks9_plist, + s_s9s_blocks9, + s_blocks9, + s_s9s_ui, + s_s9s_ui_plist +]; + +var g_opengl_resources = [ + //preload shader source + "Shaders/example_Outline.fsh", + "Shaders/example_Outline.vsh", + "Shaders/example_Blur.fsh", + "Shaders/example_ColorBars.fsh", + "Shaders/example_ColorBars.vsh", + "Shaders/example_Flower.fsh", + "Shaders/example_Flower.vsh", + "Shaders/example_Heart.fsh", + "Shaders/example_Heart.vsh", + "Shaders/example_Julia.fsh", + "Shaders/example_Julia.vsh", + "Shaders/example_Mandelbrot.fsh", + "Shaders/example_Mandelbrot.vsh", + "Shaders/example_Monjori.fsh", + "Shaders/example_Monjori.vsh", + "Shaders/example_Plasma.fsh", + "Shaders/example_Plasma.vsh", + "Shaders/example_Twist.fsh", + "Shaders/example_Twist.vsh", + + "fonts/west_england-64.fnt", + "fonts/west_england-64.png" +]; + +var g_label = [ + //s_atlasTest, + s_bitmapFontTest, + s_bitmapFontTest2, + s_bitmapFontTest3, + s_bitmapFontTest4, + s_konqa32, + s_konqa32_hd, + s_bitmapFontChinese, + s_arial16, + s_larabie_16, + s_larabie_16_hd, + s_futura48, + s_arial_unicode_26, + s_fnTuffyBoldItalicCharmapPng, + + s_arrows, + s_arrowsBar, + s_arrows_hd, + s_arrowsBar_hd, + s_larabie_16_plist, + s_larabie_16_hd_plist, + s_tuffy_bold_italic_charmap, + s_tuffy_bold_italic_charmap_hd, + s_bitmapFontTest_fnt, + s_bitmapFontTest2_fnt, + s_bitmapFontTest3_fnt, + s_bitmapFontTest4_fnt, + s_konqa32_fnt, + s_konqa32_hd_fnt, + s_bitmapFontChinese_fnt, + s_arial16_fnt, + s_futura48_fnt, + s_helvetica32_fnt, + s_geneva32_fnt, + s_helvetica_helvetica_32_png, + s_arial_unicode_26_fnt, + s_markerFelt_fnt, + s_markerFelt_png, + s_markerFelt_hd_fnt, + s_markerFelt_hd_png, + "fonts/strings.xml" +]; + +var g_transitions = [ + s_back1, + s_back2 +]; + +var g_box2d = [ + s_pathBlock +]; + +var g_cocosdeshion = [ + "Sound/background.mp3", + "Sound/effect2.mp3" + //"Sound/background.ogg", //one sound only, cc.audio can auto select other format to load if the sound format isn't supported on some browser. + //"Sound/effect2.ogg" +]; + +var g_parallax = [ + "TileMaps/orthogonal-test2.tmx", + s_fixedOrthoTest2Png, + s_power, + s_back +]; + +var g_eventDispatcher = [ + "Images/CyanSquare.png", + "Images/MagentaSquare.png", + "Images/YellowSquare.png", + "Images/ball.png", + s_extensions_button, + s_extensions_buttonHighlighted, + s_extensions_buttonBackground +]; + +var g_particle = [ + s_fpsImages, + s_starsGrayscale, + s_stars2Grayscale, + s_textureModeMenuItem, + s_shapeModeMenuItem, + s_MovementMenuItem, + s_stars1, + s_stars2, + s_snow, + s_particles, + s_particles_hd, + "Particles/BoilingFoam.plist", + "Particles/BurstPipe.plist", + "Particles/Comet.plist", + "Particles/debian.plist", + "Particles/ExplodingRing.plist", + "Particles/Flower.plist", + "Particles/Galaxy.plist", + "Particles/LavaFlow.plist", + "Particles/Phoenix.plist", + "Particles/SmallSun.plist", + "Particles/SpinningPeas.plist", + "Particles/Spiral.plist", + "Particles/SpookyPeas.plist", + "Particles/TestPremultipliedAlpha.plist", + "Particles/Upsidedown.plist" +]; + +var g_fonts = [ + //@face-font for WebFonts + { + type:"font", + name:"Thonburi", + srcs:["fonts/Thonburi.eot", "fonts/Thonburi.ttf"] + }, + { + type:"font", + name:"Schwarzwald Regular", + srcs:["fonts/Schwarzwald_Regular.eot", "fonts/Schwarzwald Regular.ttf"] + }, + { + type:"font", + name:"ThonburiBold", + srcs:["fonts/ThonburiBold.eot", "fonts/ThonburiBold.ttf"] + }, + { + type:"font", + name:"Courier New", + srcs:["fonts/Courier New.eot", "fonts/Courier New.ttf"] + } +]; + +var g_extensions = [ + s_image_icon, + s_extensions_background, + s_extensions_buttonBackground, + s_extensions_button, + s_extensions_buttonHighlighted, + s_extensions_ribbon, + + //ccbi resource + "ccb/HelloCocosBuilder.ccbi", + "ccb/ccb/TestAnimations.ccbi", + "ccb/ccb/TestAnimationsSub.ccbi", + "ccb/ccb/TestButtons.ccbi", + "ccb/ccb/TestHeader.ccbi", + "ccb/ccb/TestLabels.ccbi", + "ccb/ccb/TestMenus.ccbi", + "ccb/ccb/TestParticleSystems.ccbi", + "ccb/ccb/TestScrollViews.ccbi", + "ccb/ccb/TestScrollViewsContentA.ccbi", + "ccb/ccb/TestSprites.ccbi", + + "ccb/ccbParticleStars.png", + "ccb/btn-test-0.png", + "ccb/animated-grossini.png", + "ccb/btn-a-0.png", + "ccb/btn-a-1.png", + "ccb/btn-a-2.png", + "ccb/btn-b-0.png", + "ccb/btn-b-1.png", + "ccb/btn-b-2.png", + "ccb/btn-back-0.png", + "ccb/btn-back-1.png", + "ccb/btn-test-0.png", + "ccb/btn-test-1.png", + "ccb/btn-test-2.png", + "ccb/burst.png", + "ccb/flower.jpg", + "ccb/grossini-generic.png", + "ccb/jungle.png", + "ccb/jungle-left.png", + "ccb/jungle-right.png", + "ccb/logo.png", + "ccb/logo-icon.png", + "ccb/markerfelt24shadow.png", + "ccb/particle-fire.png", + "ccb/particle-smoke.png", + "ccb/particle-snow.png", + "ccb/particle-stars.png", + "ccb/scale-9-demo.png", + "extensions/green_edit.png", + "extensions/orange_edit.png", + "extensions/yellow_edit.png", + "extensions/switch-mask.png", + "extensions/switch-on.png", + "extensions/switch-off.png", + "extensions/switch-thumb.png", + "extensions/sliderProgress.png", + "extensions/sliderProgress2.png", + "extensions/sliderThumb.png", + "extensions/sliderTrack.png", + "extensions/sliderTrack2.png", + "extensions/stepper-minus.png", + "extensions/stepper-plus.png", + "extensions/potentiometerButton.png", + "extensions/potentiometerProgress.png", + "extensions/potentiometerTrack.png", + "extensions/CCControlColourPickerSpriteSheet.plist", + "extensions/CCControlColourPickerSpriteSheet.png", + + "ccb/markerfelt24shadow.fnt", + + "ccb/grossini-generic.plist", + "ccb/animated-grossini.plist" +]; + +var g_cocoStudio = [ + //Armature + s_Cowboy_json , + s_Cowboy_plist, + s_Cowboy_png, + s_hero_json, + s_hero0_plist, + s_hero0_png, + s_horse_json, + s_horse0_plist, + s_horse0_png, + s_bear_json, + s_bear0_plist, + s_bear0_png, + s_blood_plist, + s_HeroAnimation_json, + s_HeroAnimation0_plist, + s_HeroAnimation0_png, + s_cyborg_plist , + s_cyborg_png , + s_cyborg_xml , + s_Dragon_plist , + s_Dragon_png , + s_Dragon_xml , + s_knight_plist , + s_knight_png , + s_knight_xml , + s_robot_plist , + s_robot_png , + s_robot_xml , + s_weapon_plist , + s_weapon_png , + s_weapon_xml , + s_testEasing_json , + s_testEasing0_plist , + s_testEasing0_png , + +//GUI + "Particles/SmallSun.plist", + "Images/b1.png", + "Images/b2.png", + "Images/f1.png", + "Images/f2.png", + "cocosui/CCS/Button/background.png", + "cocosui/CCS/Button/buttonBackground.png", + "cocosui/CCS/Button/buttonHighlighted.png", + "cocosui/CCS/Button/button_n.png", + "cocosui/CCS/Button/button_p.png", + "cocosui/CCS/Button/ribbon.png", + "cocosui/CCS/Button/Button_1.json", + "cocosui/CCS/CheckBox/background.png", + "cocosui/CCS/CheckBox/buttonBackground.png", + "cocosui/CCS/CheckBox/ribbon.png", + "cocosui/CCS/CheckBox/selected01.png", + "cocosui/CCS/CheckBox/selected02.png", + "cocosui/CCS/CheckBox/checkbox_1.json", + "cocosui/CCS/CheckBox/MainScene.json", + "cocosui/CCS/CheckBox/Default/CheckBox_Disable.png", + "cocosui/CCS/CheckBox/img/btn_music.png", + "cocosui/CCS/CheckBox/img/btn_sound_off.png", + "cocosui/CCS/ImageView/background.png", + "cocosui/CCS/ImageView/buttonBackground.png", + "cocosui/CCS/ImageView/buttonHighlighted.png", + "cocosui/CCS/ImageView/GUI/image.png", + "cocosui/CCS/ImageView/ribbon.png", + "cocosui/CCS/ImageView/ImageView_1.json", + "cocosui/CCS/LabelAtlas/background.png", + "cocosui/CCS/LabelAtlas/buttonBackground.png", + "cocosui/CCS/LabelAtlas/GUI/labelatlasimg.png", + "cocosui/CCS/LabelAtlas/ribbon.png", + "cocosui/CCS/LabelAtlas/labelatlas_1.json", + "cocosui/CCS/LabelBMFont/background.png", + "cocosui/CCS/LabelBMFont/buttonBackground.png", + "cocosui/CCS/LabelBMFont/GUI/missing-font.fnt", + "cocosui/CCS/LabelBMFont/GUI/missing-font.png", + "cocosui/CCS/LabelBMFont/ribbon.png", + "cocosui/CCS/LabelBMFont/labelbmfont_1.json", + "cocosui/CCS/Label/background.png", + "cocosui/CCS/Label/buttonBackground.png", + "cocosui/CCS/Label/ribbon.png", + "cocosui/CCS/Label/label_1.json", + "cocosui/CCS/Layout/BackgroundImage/background.png", + "cocosui/CCS/Layout/BackgroundImage/buttonBackground.png", + "cocosui/CCS/Layout/BackgroundImage/button_n.png", + "cocosui/CCS/Layout/BackgroundImage/button_p.png", + "cocosui/CCS/Layout/BackgroundImage/GUI/image.png", + "cocosui/CCS/Layout/BackgroundImage/Hello.png", + "cocosui/CCS/Layout/BackgroundImage/ribbon.png", + "cocosui/CCS/Layout/BackgroundImage/selected01.png", + "cocosui/CCS/Layout/BackgroundImage/selected02.png", + "cocosui/CCS/Layout/BackgroundImage/backgroundimage_1.json", + "cocosui/CCS/Layout/Color/background.png", + "cocosui/CCS/Layout/Color/buttonBackground.png", + "cocosui/CCS/Layout/Color/button_n.png", + "cocosui/CCS/Layout/Color/button_p.png", + "cocosui/CCS/Layout/Color/GUI/image.png", + "cocosui/CCS/Layout/Color/ribbon.png", + "cocosui/CCS/Layout/Color/selected01.png", + "cocosui/CCS/Layout/Color/selected02.png", + "cocosui/CCS/Layout/Color/color_1.json", + "cocosui/CCS/Layout/Layout/background.png", + "cocosui/CCS/Layout/Layout/buttonBackground.png", + "cocosui/CCS/Layout/Layout/button_n.png", + "cocosui/CCS/Layout/Layout/button_p.png", + "cocosui/CCS/Layout/Layout/GUI/image.png", + "cocosui/CCS/Layout/Layout/ribbon.png", + "cocosui/CCS/Layout/Layout/selected01.png", + "cocosui/CCS/Layout/Layout/selected02.png", + "cocosui/CCS/Layout/Layout/layout_1.json", + "cocosui/CCS/Layout/Gradient_Color/background.png", + "cocosui/CCS/Layout/Gradient_Color/buttonBackground.png", + "cocosui/CCS/Layout/Gradient_Color/button_n.png", + "cocosui/CCS/Layout/Gradient_Color/button_p.png", + "cocosui/CCS/Layout/Gradient_Color/GUI/image.png", + "cocosui/CCS/Layout/Gradient_Color/ribbon.png", + "cocosui/CCS/Layout/Gradient_Color/selected01.png", + "cocosui/CCS/Layout/Gradient_Color/selected02.png", + "cocosui/CCS/Layout/Gradient_Color/gradient_color_1.json", + "cocosui/CCS/Layout/Linear_Horizontal/background.png", + "cocosui/CCS/Layout/Linear_Horizontal/buttonBackground.png", + "cocosui/CCS/Layout/Linear_Horizontal/button_n.png", + "cocosui/CCS/Layout/Linear_Horizontal/button_p.png", + "cocosui/CCS/Layout/Linear_Horizontal/GUI/image.png", + "cocosui/CCS/Layout/Linear_Horizontal/ribbon.png", + "cocosui/CCS/Layout/Linear_Horizontal/selected01.png", + "cocosui/CCS/Layout/Linear_Horizontal/selected02.png", + "cocosui/CCS/Layout/Linear_Horizontal/linear_horizontal.json", + "cocosui/CCS/Layout/Linear_Vertical/background.png", + "cocosui/CCS/Layout/Linear_Vertical/buttonBackground.png", + "cocosui/CCS/Layout/Linear_Vertical/button_n.png", + "cocosui/CCS/Layout/Linear_Vertical/button_p.png", + "cocosui/CCS/Layout/Linear_Vertical/GUI/image.png", + "cocosui/CCS/Layout/Linear_Vertical/ribbon.png", + "cocosui/CCS/Layout/Linear_Vertical/selected01.png", + "cocosui/CCS/Layout/Linear_Vertical/selected02.png", + "cocosui/CCS/Layout/Linear_Vertical/linear_vertical.json", + "cocosui/CCS/Layout/Relative_Align_Location/background.png", + "cocosui/CCS/Layout/Relative_Align_Location/buttonBackground.png", + "cocosui/CCS/Layout/Relative_Align_Location/button_n.png", + "cocosui/CCS/Layout/Relative_Align_Location/button_p.png", + "cocosui/CCS/Layout/Relative_Align_Location/GUI/image.png", + "cocosui/CCS/Layout/Relative_Align_Location/ribbon.png", + "cocosui/CCS/Layout/Relative_Align_Location/selected01.png", + "cocosui/CCS/Layout/Relative_Align_Location/selected02.png", + "cocosui/CCS/Layout/Relative_Align_Location/relative_align_location.json", + "cocosui/CCS/Layout/Relative_Align_Parent/background.png", + "cocosui/CCS/Layout/Relative_Align_Parent/buttonBackground.png", + "cocosui/CCS/Layout/Relative_Align_Parent/button_n.png", + "cocosui/CCS/Layout/Relative_Align_Parent/button_p.png", + "cocosui/CCS/Layout/Relative_Align_Parent/GUI/image.png", + "cocosui/CCS/Layout/Relative_Align_Parent/ribbon.png", + "cocosui/CCS/Layout/Relative_Align_Parent/selected01.png", + "cocosui/CCS/Layout/Relative_Align_Parent/selected02.png", + "cocosui/CCS/Layout/Relative_Align_Parent/relative_align_parent.json", + "cocosui/CCS/Layout/Scale9/background.png", + "cocosui/CCS/Layout/Scale9/buttonBackground.png", + "cocosui/CCS/Layout/Scale9/button_n.png", + "cocosui/CCS/Layout/Scale9/button_p.png", + "cocosui/CCS/Layout/Scale9/GUI/image.png", + "cocosui/CCS/Layout/Scale9/ribbon.png", + "cocosui/CCS/Layout/Scale9/selected01.png", + "cocosui/CCS/Layout/Scale9/selected02.png", + "cocosui/CCS/Layout/Scale9/slider_bar.png", + "cocosui/CCS/Layout/Scale9/scale9.json", + "cocosui/CCS/ListView/Horizontal/background.png", + "cocosui/CCS/ListView/Horizontal/buttonBackground.png", + "cocosui/CCS/ListView/Horizontal/button_p.png", + "cocosui/CCS/ListView/Horizontal/GUI/button.png", + "cocosui/CCS/ListView/Horizontal/GUI/image.png", + "cocosui/CCS/ListView/Horizontal/ribbon.png", + "cocosui/CCS/ListView/Horizontal/horizontal_1.json", + "cocosui/CCS/ListView/Vertical/background.png", + "cocosui/CCS/ListView/Vertical/buttonBackground.png", + "cocosui/CCS/ListView/Vertical/button_p.png", + "cocosui/CCS/ListView/Vertical/GUI/button.png", + "cocosui/CCS/ListView/Vertical/GUI/image.png", + "cocosui/CCS/ListView/Vertical/ribbon.png", + "cocosui/CCS/ListView/Vertical/vertical_1.json", + "cocosui/CCS/LoadingBar/background.png", + "cocosui/CCS/LoadingBar/buttonBackground.png", + "cocosui/CCS/LoadingBar/GUI/loadingbar.png", + "cocosui/CCS/LoadingBar/ribbon.png", + "cocosui/CCS/LoadingBar/loadingbar_1.json", + "cocosui/CCS/PageView/background.png", + "cocosui/CCS/PageView/buttonBackground.png", + "cocosui/CCS/PageView/button_n.png", + "cocosui/CCS/PageView/ribbon.png", + "cocosui/CCS/PageView/pageview_1.json", + "cocosui/CCS/ScrollView/Both/background.png", + "cocosui/CCS/ScrollView/Both/buttonBackground.png", + "cocosui/CCS/ScrollView/Both/button_n.png", + "cocosui/CCS/ScrollView/Both/button_p.png", + "cocosui/CCS/ScrollView/Both/GUI/image.png", + "cocosui/CCS/ScrollView/Both/ribbon.png", + "cocosui/CCS/ScrollView/Both/selected01.png", + "cocosui/CCS/ScrollView/Both/selected02.png", + "cocosui/CCS/ScrollView/Both/both_1.json", + "cocosui/CCS/ScrollView/Horizontal/background.png", + "cocosui/CCS/ScrollView/Horizontal/buttonBackground.png", + "cocosui/CCS/ScrollView/Horizontal/button_n.png", + "cocosui/CCS/ScrollView/Horizontal/button_p.png", + "cocosui/CCS/ScrollView/Horizontal/GUI/image.png", + "cocosui/CCS/ScrollView/Horizontal/ribbon.png", + "cocosui/CCS/ScrollView/Horizontal/selected01.png", + "cocosui/CCS/ScrollView/Horizontal/selected02.png", + "cocosui/CCS/ScrollView/Horizontal/horizontal_1.json", + "cocosui/CCS/ScrollView/Vertical/background.png", + "cocosui/CCS/ScrollView/Vertical/buttonBackground.png", + "cocosui/CCS/ScrollView/Vertical/button_n.png", + "cocosui/CCS/ScrollView/Vertical/button_p.png", + "cocosui/CCS/ScrollView/Vertical/GUI/image.png", + "cocosui/CCS/ScrollView/Vertical/ribbon.png", + "cocosui/CCS/ScrollView/Vertical/selected01.png", + "cocosui/CCS/ScrollView/Vertical/selected02.png", + "cocosui/CCS/ScrollView/Vertical/vertical_1.json", + "cocosui/CCS/Slider/2014-1-26 11-42-09.png", + "cocosui/CCS/Slider/2014-1-26 11-43-52.png", + "cocosui/CCS/Slider/background.png", + "cocosui/CCS/Slider/buttonBackground.png", + "cocosui/CCS/Slider/ribbon.png", + "cocosui/CCS/Slider/silder_progressBar.png", + "cocosui/CCS/Slider/slider_bar.png", + "cocosui/CCS/Slider/slider_bar_button.png", + "cocosui/CCS/Slider/slider_1.json", + "cocosui/CCS/TextField/background.png", + "cocosui/CCS/TextField/buttonBackground.png", + "cocosui/CCS/TextField/ribbon.png", + "cocosui/CCS/TextField/textfield_1.json", + "cocosui/CCS/WidgetAddNode/background.png", + "cocosui/CCS/WidgetAddNode/buttonBackground.png", + "cocosui/CCS/WidgetAddNode/ribbon.png", + "cocosui/CCS/WidgetAddNode/widget_add_node.json", + "Sound/background-music-aac.wav", + "Sound/pew-pew-lei.wav", + //Components + "components/Player.png", + "components/Projectile.png", + "components/Target.png", + //Scene + "scenetest/ArmatureComponentTest/ArmatureComponentTest.json", + "scenetest/ArmatureComponentTest/fishes/blowFish/Blowfish.ExportJson", + "scenetest/ArmatureComponentTest/fishes/blowFish/Blowfish0.plist", + "scenetest/ArmatureComponentTest/fishes/blowFish/Blowfish0.png", + "scenetest/ArmatureComponentTest/fishes/Butterflyfish/Butterflyfish.ExportJson", + "scenetest/ArmatureComponentTest/fishes/Butterflyfish/Butterflyfish0.plist", + "scenetest/ArmatureComponentTest/fishes/Butterflyfish/Butterflyfish0.png", + "scenetest/ArmatureComponentTest/Images/startMenuBG.png", + "scenetest/AttributeComponentTest/AttributeComponentTest.json", + "scenetest/AttributeComponentTest/grossinis_sister1.png", + "scenetest/AttributeComponentTest/grossinis_sister2.png", + "scenetest/AttributeComponentTest/PlayerAttribute.json", + "scenetest/BackgroundComponentTest/BackgroundComponentTest.json", + "scenetest/BackgroundComponentTest/Images/startMenuBG.png", + "scenetest/BackgroundComponentTest/Misc/music_logo.mp3", + "scenetest/BackgroundComponentTest/Misc/music_logo.wav", + "scenetest/BackgroundComponentTest/Particles/qipao01.plist", + "scenetest/BackgroundComponentTest/Particles/qipao01.png", + "scenetest/BackgroundComponentTest/startMenu/Fish_UI/starMenuButton01.png", + "scenetest/BackgroundComponentTest/startMenu/Fish_UI/starMenuButton02.png", + "scenetest/BackgroundComponentTest/startMenu/Fish_UI/ui_logo_001-hd.png", + "scenetest/BackgroundComponentTest/startMenu/startMenu_1.json", + "scenetest/EffectComponentTest/CowBoy/Cowboy.ExportJson", + "scenetest/EffectComponentTest/CowBoy/Cowboy0.plist", + "scenetest/EffectComponentTest/CowBoy/Cowboy0.png", + "scenetest/EffectComponentTest/EffectComponentTest.json", + "scenetest/EffectComponentTest/pew-pew-lei.wav", + "scenetest/LoadSceneEdtiorFileTest/fishes/blowFish/Blowfish.ExportJson", + "scenetest/LoadSceneEdtiorFileTest/fishes/blowFish/Blowfish0.plist", + "scenetest/LoadSceneEdtiorFileTest/fishes/blowFish/Blowfish0.png", + "scenetest/LoadSceneEdtiorFileTest/fishes/Butterflyfish/Butterflyfish.ExportJson", + "scenetest/LoadSceneEdtiorFileTest/fishes/Butterflyfish/Butterflyfish0.plist", + "scenetest/LoadSceneEdtiorFileTest/fishes/Butterflyfish/Butterflyfish0.png", + "scenetest/LoadSceneEdtiorFileTest/FishJoy2.json", + "scenetest/LoadSceneEdtiorFileTest/Images/startMenuBG.png", + "scenetest/LoadSceneEdtiorFileTest/Misc/music_logo.mp3", + "scenetest/LoadSceneEdtiorFileTest/Misc/music_logo.wav", + "scenetest/LoadSceneEdtiorFileTest/Particles/qipao01.plist", + "scenetest/LoadSceneEdtiorFileTest/Particles/qipao01.png", + "scenetest/LoadSceneEdtiorFileTest/startMenu/Fish_UI/starMenuButton01.png", + "scenetest/LoadSceneEdtiorFileTest/startMenu/Fish_UI/starMenuButton02.png", + "scenetest/LoadSceneEdtiorFileTest/startMenu/Fish_UI/ui_logo_001-hd.png", + "scenetest/LoadSceneEdtiorFileTest/startMenu/startMenu_1.json", + "scenetest/ParticleComponentTest/ParticleComponentTest.json", + "scenetest/ParticleComponentTest/SmallSun.plist", + "scenetest/ParticleComponentTest/Upsidedown.plist", + "scenetest/SpriteComponentTest/grossinis_sister1.png", + "scenetest/SpriteComponentTest/grossinis_sister2.png", + "scenetest/SpriteComponentTest/SpriteComponentTest.json", + "scenetest/TmxMapComponentTest/iso-test.png", + "scenetest/TmxMapComponentTest/iso-test.tmx", + "scenetest/TmxMapComponentTest/TmxMapComponentTest.json", + "scenetest/TriggerTest/fishes/blowFish/Blowfish.ExportJson", + "scenetest/TriggerTest/fishes/blowFish/Blowfish0.plist", + "scenetest/TriggerTest/fishes/blowFish/Blowfish0.png", + "scenetest/TriggerTest/fishes/Butterflyfish/Butterflyfish.ExportJson", + "scenetest/TriggerTest/fishes/Butterflyfish/Butterflyfish0.plist", + "scenetest/TriggerTest/fishes/Butterflyfish/Butterflyfish0.png", + "scenetest/TriggerTest/Images/startMenuBG.png", + "scenetest/TriggerTest/TriggerTest.json", + "scenetest/UIComponentTest/fishes/blowFish/Blowfish.ExportJson", + "scenetest/UIComponentTest/fishes/blowFish/Blowfish0.plist", + "scenetest/UIComponentTest/fishes/blowFish/Blowfish0.png", + "scenetest/UIComponentTest/fishes/Butterflyfish/Butterflyfish.ExportJson", + "scenetest/UIComponentTest/fishes/Butterflyfish/Butterflyfish0.plist", + "scenetest/UIComponentTest/fishes/Butterflyfish/Butterflyfish0.png", + "scenetest/UIComponentTest/Images/startMenuBG.png", + "scenetest/UIComponentTest/starMenuButton/starMenuButton.ExportJson", + "scenetest/UIComponentTest/starMenuButton/starMenuButton0.plist", + "scenetest/UIComponentTest/starMenuButton/starMenuButton0.png", + "scenetest/UIComponentTest/UIComponentTest.json", + + //parser + "cocosui/CCS/ccs1_3/CCSV1_3_1.ExportJson", + "cocosui/CCS/ccs1_3/CocostudioV1_30.plist", + "cocosui/CCS/ccs1_3/CocostudioV1_30.png", + "cocosui/CCS/ccs1_3/SmallSun.plist", + "cocosui/CCS/ccs1_3/GUI/labelatlasimg.png", + "cocosui/CCS/ccs1_3/GUI/missing-font.fnt", + "cocosui/CCS/ccs1_3/GUI/missing-font.png", + "cocosui/CCS/ccs1_4/CCS1_4_1.ExportJson", + "cocosui/CCS/ccs1_4/Cocostudio1_40.plist", + "cocosui/CCS/ccs1_4/Cocostudio1_40.png", + "cocosui/CCS/ccs1_4/SmallSun.plist", + "cocosui/CCS/ccs1_4/GUI/labelatlasimg.png", + "cocosui/CCS/ccs1_4/GUI/missing-font.fnt", + "cocosui/CCS/ccs1_4/GUI/missing-font.png", + "cocosui/CCS/ccs1_5/CCS1_5_1.ExportJson", + "cocosui/CCS/ccs1_5/Cocostudio1_50.plist", + "cocosui/CCS/ccs1_5/Cocostudio1_50.png", + "cocosui/CCS/ccs1_5/SmallSun.plist", + "cocosui/CCS/ccs1_5/GUI/labelatlasimg.png", + "cocosui/CCS/ccs1_5/GUI/missing-font.fnt", + "cocosui/CCS/ccs1_5/GUI/missing-font.png", + + "cocosui/CCS/2.1/MainScene.json", + "cocosui/CCS/2.1/plist1/Plist.plist", + "cocosui/CCS/2.1/Plist/ui.plist", + "cocosui/CCS/2.1/LoadingBar/pipe2.png", + "cocosui/CCS/2.1/Slider/2013-8-13 15-44-11.png", + "cocosui/CCS/2.1/Slider/teehanlax - iOS 6 - iPhone_slider01.png", + "cocosui/CCS/2.1/particle/blue.plist", + "cocosui/CCS/2.1/Default/Slider_Back.png", + "cocosui/CCS/2.1/Default/SliderNode_Normal.png", + "cocosui/CCS/2.1/Default/SliderNode_Press.png", + "cocosui/CCS/2.1/Default/SliderNode_Disable.png", + "cocosui/CCS/2.1/Default/Slider_PressBar.png", + "cocosui/CCS/2.1/Default/defaultParticle.plist", + "cocosui/CCS/2.1/Default/TextAtlas.png", + "cocosui/CCS/2.1/fonts_weapon_001-hd.png", + "cocosui/CCS/2.1/FNT/futura.fnt", + "cocosui/CCS/2.1/Default/defaultBMFont.fnt", + "cocosui/CCS/2.1/FNT/Heiti18.fnt", + + "Particles/BoilingFoam.plist", + "cocosui/CustomImageViewTest/NewProject_2_1.ExportJson", + "cocosui/CustomImageViewTest/NewProject_20.plist", + "cocosui/CustomImageViewTest/NewProject_20.png" +]; + +var g_ui = [ + "cocosui/switch-mask.png", + "cocosui/animationbuttonnormal.png", + "cocosui/animationbuttonpressed.png", + "cocosui/arrow.png", + "cocosui/b11.png", + "cocosui/backtotopnormal.png", + "cocosui/backtotoppressed.png", + "cocosui/bitmapFontTest2.fnt", + "cocosui/bitmapFontTest2.png", + "cocosui/button.png", + "cocosui/buttonHighlighted.png", + "cocosui/ccicon.png", + "cocosui/check_box_active.png", + "cocosui/check_box_active_disable.png", + "cocosui/check_box_active_press.png", + "cocosui/check_box_normal.png", + "cocosui/check_box_normal_disable.png", + "cocosui/check_box_normal_press.png", + "cocosui/CloseNormal.png", + "cocosui/CloseSelected.png", + "cocosui/green_edit.png", + "cocosui/grossini-aliases.png", + "cocosui/Hello.png", + "cocosui/labelatlas.png", + "cocosui/loadingbar.png", + {type:"font", name:"Marker Felt", srcs:["cocosui/Marker Felt.ttf"]}, + "cocosui/scrollviewbg.png", + "cocosui/slidbar.png", + "cocosui/sliderballnormal.png", + "cocosui/sliderballpressed.png", + "cocosui/sliderProgress.png", + "cocosui/sliderProgress2.png", + "cocosui/sliderThumb.png", + "cocosui/sliderTrack.png", + "cocosui/sliderTrack2.png", + "cocosui/slider_bar_active_9patch.png", + "cocosui/UITest/b1.png", + "cocosui/UITest/b2.png", + "cocosui/UITest/background.png", + "cocosui/UITest/buttonBackground.png", + "cocosui/UITest/f1.png", + "cocosui/UITest/f2.png", + "cocosui/UITest/r1.png", + "cocosui/UITest/r2.png", + "cocosui/UITest/ribbon.png", + "cocosui/UITest/UITest.json", + "cocosui/100/100.ExportJson", + "cocosui/100/1000.plist", + "cocosui/100/1000.png", + s_s9s_blocks9_plist, + "cocosui/CloseSelected.png" +]; + +var g_performace = [ + "animations/crystals.plist", + "animations/crystals.png", + "Images/fps_images.png", + "Images/spritesheet1.png", + "Images/sprites_test/sprite-0-0.png", + "Images/sprites_test/sprite-0-1.png", + "Images/sprites_test/sprite-0-2.png", + "Images/sprites_test/sprite-0-3.png", + "Images/sprites_test/sprite-0-4.png", + "Images/sprites_test/sprite-0-5.png", + "Images/sprites_test/sprite-0-6.png", + "Images/sprites_test/sprite-0-7.png", + "Images/sprites_test/sprite-1-0.png", + "Images/sprites_test/sprite-1-1.png", + "Images/sprites_test/sprite-1-2.png", + "Images/sprites_test/sprite-1-3.png", + "Images/sprites_test/sprite-1-4.png", + "Images/sprites_test/sprite-1-5.png", + "Images/sprites_test/sprite-1-6.png", + "Images/sprites_test/sprite-1-7.png", + "Images/sprites_test/sprite-2-0.png", + "Images/sprites_test/sprite-2-1.png", + "Images/sprites_test/sprite-2-2.png", + "Images/sprites_test/sprite-2-3.png", + "Images/sprites_test/sprite-2-4.png", + "Images/sprites_test/sprite-2-5.png", + "Images/sprites_test/sprite-2-6.png", + "Images/sprites_test/sprite-2-7.png", + "Images/sprites_test/sprite-3-0.png", + "Images/sprites_test/sprite-3-1.png", + "Images/sprites_test/sprite-3-2.png", + "Images/sprites_test/sprite-3-3.png", + "Images/sprites_test/sprite-3-4.png", + "Images/sprites_test/sprite-3-5.png", + "Images/sprites_test/sprite-3-6.png", + "Images/sprites_test/sprite-3-7.png", + "Images/sprites_test/sprite-4-0.png", + "Images/sprites_test/sprite-4-1.png", + "Images/sprites_test/sprite-4-2.png", + "Images/sprites_test/sprite-4-3.png", + "Images/sprites_test/sprite-4-4.png", + "Images/sprites_test/sprite-4-5.png", + "Images/sprites_test/sprite-4-6.png", + "Images/sprites_test/sprite-4-7.png", + "Images/sprites_test/sprite-5-0.png", + "Images/sprites_test/sprite-5-1.png", + "Images/sprites_test/sprite-5-2.png", + "Images/sprites_test/sprite-5-3.png", + "Images/sprites_test/sprite-5-4.png", + "Images/sprites_test/sprite-5-5.png", + "Images/sprites_test/sprite-5-6.png", + "Images/sprites_test/sprite-5-7.png", + "Images/sprites_test/sprite-6-0.png", + "Images/sprites_test/sprite-6-1.png", + "Images/sprites_test/sprite-6-2.png", + "Images/sprites_test/sprite-6-3.png", + "Images/sprites_test/sprite-6-4.png", + "Images/sprites_test/sprite-6-5.png", + "Images/sprites_test/sprite-6-6.png", + "Images/sprites_test/sprite-6-7.png", + "Images/sprites_test/sprite-7-0.png", + "Images/sprites_test/sprite-7-1.png", + "Images/sprites_test/sprite-7-2.png", + "Images/sprites_test/sprite-7-3.png", + "Images/sprites_test/sprite-7-4.png", + "Images/sprites_test/sprite-7-5.png", + "Images/sprites_test/sprite-7-6.png", + "Images/sprites_test/sprite-7-7.png" +]; + +var g_tilemaps = [ + //image + s_fixedOrthoTest2Png, + s_hexaTilesPng, + s_isoTestPng, + s_isoTest2Png, + s_isoPng, + s_orthoTest1BwPng, + s_orthoTest1Png, + s_tilesHdPng, + s_tmwDesertSpacingHdPng, + s_tmwDesertSpacingPng, + s_tilesPng, + s_tileISOOffsetPng, + s_tileISOOffsetTmx, + "TileMaps/ortho-test2.png", + + //tmx + "TileMaps/orthogonal-test1.tmx", + "TileMaps/orthogonal-test1.tsx", + "TileMaps/orthogonal-test2.tmx", + "TileMaps/orthogonal-test3.tmx", + "TileMaps/orthogonal-test4.tmx", + "TileMaps/orthogonal-test4-hd.tmx", + "TileMaps/orthogonal-test5.tmx", + "TileMaps/orthogonal-test6.tmx", + "TileMaps/orthogonal-test6-hd.tmx", + "TileMaps/hexa-test.tmx", + "TileMaps/iso-test.tmx", + "TileMaps/iso-test1.tmx", + "TileMaps/iso-test2.tmx", + "TileMaps/iso-test2-uncompressed.tmx", + "TileMaps/ortho-objects.tmx", + "TileMaps/iso-test-objectgroup.tmx", + "TileMaps/iso-test-zorder.tmx", + "TileMaps/orthogonal-test-zorder.tmx", + "TileMaps/iso-test-vertexz.tmx", + "TileMaps/orthogonal-test-vertexz.tmx", + "TileMaps/iso-test-movelayer.tmx", + "TileMaps/orthogonal-test-movelayer.tmx", + "TileMaps/iso-test-bug787.tmx", + "TileMaps/test-object-layer.tmx", + "TileMaps/ortho-tile-property.tmx", + "TileMaps/ortho-rotation-test.tmx" +]; + +var g_spine = [ + "skeletons/spineboy.atlas", + "skeletons/spineboy.json", + "skeletons/spineboy.png", + "skeletons/sprite.png", + "skeletons/goblins-ffd.png", + "skeletons/goblins-ffd.atlas", + "skeletons/goblins-ffd.json" +]; + +var g_ccs2 = [ + "ActionTimeline/boy_1.csb", + "ActionTimeline/armature/Cowboy0.plist", + "cocosui/UIEditorTest/UILabelBMFont_Editor/GUI/missing-font.fnt", + "cocosui/UIEditorTest/UILabelBMFont_Editor/GUI/missing-font.png" +]; diff --git a/tests/lua-empty-test/.cocos-project.json b/tests/lua-empty-test/.cocos-project.json index 4b78642cd0..470ad30447 100644 --- a/tests/lua-empty-test/.cocos-project.json +++ b/tests/lua-empty-test/.cocos-project.json @@ -1,7 +1,7 @@ { "win32_cfg": { "project_path": "../../build", - "sln_file": "cocos2d-win32.vc2012.sln", + "sln_file": "cocos2d-win32.vc2013.sln", "project_name": "lua-empty-test", "build_cfg_path": "project/proj.win32" }, diff --git a/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj b/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj index 5c39dc9739..b59e642b9b 100644 --- a/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj +++ b/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj @@ -18,18 +18,12 @@ Application Unicode - v100 - v110 - v110_xp v120 v120_xp Application Unicode - v100 - v110 - v110_xp v120 v120_xp @@ -48,7 +42,7 @@ - <_ProjectFileVersion>10.0.40219.1 + <_ProjectFileVersion>12.0.21005.1 $(SolutionDir)$(Configuration).win32\lua-empty-test\ $(Configuration).win32\ true diff --git a/tests/lua-tests/.cocos-project.json b/tests/lua-tests/.cocos-project.json index ee001808a8..aaef81cc15 100644 --- a/tests/lua-tests/.cocos-project.json +++ b/tests/lua-tests/.cocos-project.json @@ -1,7 +1,7 @@ { "win32_cfg": { "project_path": "../../build", - "sln_file": "cocos2d-win32.vc2012.sln", + "sln_file": "cocos2d-win32.vc2013.sln", "project_name": "lua-tests", "build_cfg_path": "project/proj.win32" }, diff --git a/tests/lua-tests/project/proj.android/jni/Application.mk b/tests/lua-tests/project/proj.android/jni/Application.mk index 07aa592b13..18444678c9 100644 --- a/tests/lua-tests/project/proj.android/jni/Application.mk +++ b/tests/lua-tests/project/proj.android/jni/Application.mk @@ -1,6 +1,6 @@ APP_STL := gnustl_static -APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char +APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCC_ENABLE_BULLET_INTEGRATION=1 -std=c++11 -fsigned-char APP_LDFLAGS := -latomic diff --git a/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj b/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj index 0cc4844115..1f682aea45 100644 --- a/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj +++ b/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj @@ -19,9 +19,6 @@ Application true Unicode - v100 - v110 - v110_xp v120 v120_xp @@ -29,9 +26,6 @@ Application false Unicode - v100 - v110 - v110_xp v120 v120_xp diff --git a/tools/bindings-generator b/tools/bindings-generator index af67671bfd..ca96fc9301 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit af67671bfd8394e8a5e13d702e57f3fd7eaa5c78 +Subproject commit ca96fc9301c1fd7eceff05f033eb96cb09d74a47 diff --git a/tools/cocos2d-console b/tools/cocos2d-console index f56ddf5c11..fe7ccc496d 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit f56ddf5c118a2652d0d7eb796872420a69f532af +Subproject commit fe7ccc496d507c66dbfef2907fec9ac39d737300 diff --git a/tools/gen-prebuilt/build_config.json b/tools/gen-prebuilt/build_config.json index 0c250ef587..fd0730e1cd 100644 --- a/tools/gen-prebuilt/build_config.json +++ b/tools/gen-prebuilt/build_config.json @@ -10,7 +10,7 @@ } }, "win32_proj_info" : { - "build/cocos2d-win32.vc2012.sln" : { + "build/cocos2d-win32.vc2013.sln" : { "outputdir" : "prebuilt/win32", "targets" : [ "libcocosdenshion", "libbox2d", "libchipmunk", diff --git a/tools/jenkins-scripts/configs/cocos-2dx-develop-win32.py b/tools/jenkins-scripts/configs/cocos-2dx-develop-win32.py index 1e55080898..87f8674032 100644 --- a/tools/jenkins-scripts/configs/cocos-2dx-develop-win32.py +++ b/tools/jenkins-scripts/configs/cocos-2dx-develop-win32.py @@ -5,8 +5,8 @@ print 'Build Config:' print ' Host:win7 x86' print ' Branch:develop' print ' Target:win32' -print ' "%VS110COMNTOOLS%..\IDE\devenv.com" "build\cocos2d-win32.vc2012.sln" /Build "Debug|Win32"' -if(os.path.exists('build/cocos2d-win32.vc2012.sln') == False): +print ' "%VS110COMNTOOLS%..\IDE\devenv.com" "build\cocos2d-win32.vc2013.sln" /Build "Debug|Win32"' +if(os.path.exists('build/cocos2d-win32.vc2013.sln') == False): node_name = os.environ['NODE_NAME'] source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name source_dir = source_dir.replace("/", os.sep) @@ -14,7 +14,7 @@ if(os.path.exists('build/cocos2d-win32.vc2012.sln') == False): os.system('git pull origin develop') os.system('git submodule update --init --force') -ret = subprocess.call('"%VS110COMNTOOLS%..\IDE\devenv.com" "build\cocos2d-win32.vc2012.sln" /Build "Debug|Win32"', shell=True) +ret = subprocess.call('"%VS110COMNTOOLS%..\IDE\devenv.com" "build\cocos2d-win32.vc2013.sln" /Build "Debug|Win32"', shell=True) os.system('git clean -xdf -f') print 'build exit' print ret diff --git a/tools/jenkins-scripts/daily-build.py b/tools/jenkins-scripts/daily-build.py index 6f6cd81bb4..1927826709 100644 --- a/tools/jenkins-scripts/daily-build.py +++ b/tools/jenkins-scripts/daily-build.py @@ -70,15 +70,9 @@ def do_build_slaves(): # patch_cpp_empty_test() slave_build_scripts = jenkins_script_path + "android-build.sh" elif(node_name == 'win32' or node_name == 'win32_win7' or node_name == 'win32_bak'): - if branch == 'v3': - slave_build_scripts = jenkins_script_path + "win32-vs2012-build.bat" - else: - slave_build_scripts = jenkins_script_path + "win32-vs2013-build.bat" + slave_build_scripts = jenkins_script_path + "win32-vs2013-build.bat" elif(node_name == 'windows-universal' or node_name == 'windows-universal_bak'): - if branch == 'v3': - slave_build_scripts = jenkins_script_path + "windows-universal-v3.bat" - else: - slave_build_scripts = jenkins_script_path + "windows-universal.bat" + slave_build_scripts = jenkins_script_path + "windows-universal.bat" elif(node_name == 'ios_mac' or node_name == 'ios' or node_name == 'ios_bak'): slave_build_scripts = jenkins_script_path + "ios-build.sh" elif(node_name == 'mac' or node_name == 'mac_bak'): diff --git a/tools/jenkins-scripts/do-pull-request-builder.py b/tools/jenkins-scripts/do-pull-request-builder.py index c917144f60..1b923a3ab9 100755 --- a/tools/jenkins-scripts/do-pull-request-builder.py +++ b/tools/jenkins-scripts/do-pull-request-builder.py @@ -1,148 +1,28 @@ -#Github pull reqest builder for Jenkins - -import json import os -import urllib2 -import urllib -import base64 -import requests import sys import traceback -import subprocess - -#set Jenkins build description using submitDescription to mock browser behavior -http_proxy = '' -if('HTTP_PROXY' in os.environ): - http_proxy = os.environ['HTTP_PROXY'] -proxyDict = {'http': http_proxy, 'https': http_proxy} +import json branch = "v3" -pr_num = 0 -workspace = "." node_name = "ios" -# for local debugging purpose, you could change the value to 0 and run -# this scripts in your local machine -remote_build = 1 +payload_str = os.environ['payload'] +payload_str = payload_str.decode('utf-8', 'ignore') +#parse to json obj +payload = json.loads(payload_str) +pr_num = payload['number'] -def set_jenkins_job_description(desc, url): - req_data = urllib.urlencode({'description': desc}) - request = urllib2.Request(url + 'submitDescription', req_data) - #print(os.environ['BUILD_URL']) - request.add_header('Content-Type', 'application/x-www-form-urlencoded') - user_name = os.environ['JENKINS_ADMIN'] - password = os.environ['JENKINS_ADMIN_PW'] - base64string = base64.encodestring(user_name + ":" + password).replace('\n', '') - request.add_header("Authorization", "Basic " + base64string) - try: - urllib2.urlopen(request) - except: - traceback.print_exc() +#get pr target branch +branch = payload['branch'] +workspace = os.environ['WORKSPACE'] +node_name = os.environ['NODE_NAME'] - -def check_current_3rd_libs(branch): +def download_3rd_libs(branch): #run download-deps.py print("prepare to downloading ...") os.system('python download-deps.py -r no') -def send_notifies_to_github(): - global branch - global pr_num - global workspace - global node_name - # get payload from os env - payload_str = os.environ['payload'] - payload_str = payload_str.decode('utf-8', 'ignore') - #parse to json obj - payload = json.loads(payload_str) - - #get pull number - pr_num = payload['number'] - print 'pr_num:' + str(pr_num) - - #build for pull request action 'open' and 'synchronize', skip 'close' - action = payload['action'] - print 'action: ' + action - - #pr = payload['pull_request'] - - url = payload['html_url'] - print "url:" + url - pr_desc = '

pr#' + str(pr_num) + ' is ' + action + '

' - - #get statuses url - statuses_url = payload['statuses_url'] - - #get pr target branch - branch = payload['branch'] - workspace = os.environ['WORKSPACE'] - node_name = os.environ['NODE_NAME'] - - #set commit status to pending - # target_url = os.environ['BUILD_URL'] - jenkins_url = os.environ['JENKINS_URL'] - job_name = os.environ['JOB_NAME'].split('/')[0] - build_number = os.environ['BUILD_NUMBER'] - target_url = jenkins_url + 'job/' + job_name + '/' + build_number + '/' - - set_jenkins_job_description(pr_desc, target_url) - - data = {"state": "pending", "target_url": target_url, "context": "Jenkins CI", "description": "Build started..."} - access_token = os.environ['GITHUB_ACCESS_TOKEN'] - Headers = {"Authorization": "token " + access_token} - - try: - requests.post(statuses_url, data=json.dumps(data), headers=Headers, proxies=proxyDict) - except: - traceback.print_exc() - -def syntronize_remote_pr(): - global workspace - global branch - global pr_num - #reset path to workspace root - os.system("cd " + workspace) - #pull latest code - os.system("git fetch origin " + branch) - os.system("git --version") - os.system("git checkout " + branch) - os.system("git merge origin/" + branch) - os.system("git branch -D pull" + str(pr_num)) - #clean workspace - print "Before checkout: git clean -xdf -f" - os.system("git clean -xdf -f") - #fetch pull request to local repo - git_fetch_pr = "git fetch origin pull/" + str(pr_num) + "/head" - ret = os.system(git_fetch_pr) - if(ret != 0): - sys.exit(1) - - #checkout a new branch from v3 or v4-develop - git_checkout = "git checkout -b " + "pull" + str(pr_num) - os.system(git_checkout) - #merge pull reqeust head - subprocess.call("git merge --no-edit FETCH_HEAD", shell=True) - - # The follow method is not working for Azure server - # p = os.popen('git merge --no-edit FETCH_HEAD') - # r = p.read() - # #check if merge fail - # if output.find('CONFLICT') > 0: - # print output - # raise Exception('There are conflicts in your PR!') - - # After checkout a new branch, clean workspace again - print "After checkout: git clean -xdf -f" - os.system("git clean -xdf -f") - - #update submodule - git_update_submodule = "git submodule update --init --force" - ret = os.system(git_update_submodule) - if(ret != 0): - sys.exit(1) - - def gen_scripting_bindings(): global branch # Generate binding glue codes @@ -164,15 +44,9 @@ def do_build_slaves(): # patch_cpp_empty_test() slave_build_scripts = jenkins_script_path + "android-build.sh" elif(node_name == 'win32' or node_name == 'win32_win7' or node_name == 'win32_bak'): - if branch != 'v4': - slave_build_scripts = jenkins_script_path + "win32-vs2012-build.bat" - else: - slave_build_scripts = jenkins_script_path + "win32-vs2013-build.bat" + slave_build_scripts = jenkins_script_path + "win32-vs2013-build.bat" elif(node_name == 'windows-universal' or node_name == 'windows-universal_bak'): - if branch != 'v4': - slave_build_scripts = jenkins_script_path + "windows-universal-v3.bat" - else: - slave_build_scripts = jenkins_script_path + "windows-universal.bat" + slave_build_scripts = jenkins_script_path + "windows-universal.bat" elif(node_name == 'ios_mac' or node_name == 'ios' or node_name == 'ios_bak'): slave_build_scripts = jenkins_script_path + "ios-build.sh" elif(node_name == 'mac' or node_name == 'mac_bak'): @@ -189,44 +63,35 @@ def do_build_slaves(): print "build finished and return " + str(ret) return ret - -def main(): - global pr_num +def cleanup_workspace(): global workspace global branch - global node_name - global remote_build - - if remote_build == 1: - send_notifies_to_github() - #syntronize local git repository with remote and merge the PR - syntronize_remote_pr() - #copy check_current_3rd_libs - check_current_3rd_libs(branch) + global pr_num + #clean workspace + os.system("cd " + workspace) + os.system("git reset --hard") + os.system("git clean -xdf -f") + os.system("git checkout " + branch) + os.system("git branch -D pull" + str(pr_num)) +def main(): + download_3rd_libs(branch) #generate jsb and luabindings gen_scripting_bindings() #start build jobs on each slave ret = do_build_slaves() + cleanup_workspace() + exit_code = 1 if ret == 0: exit_code = 0 else: exit_code = 1 - #clean workspace - if remote_build == 1: - os.system("cd " + workspace) - os.system("git reset --hard") - os.system("git clean -xdf -f") - os.system("git checkout " + branch) - os.system("git branch -D pull" + str(pr_num)) - else: - print "local build, no need to cleanup" - return(exit_code) + # -------------- main -------------- if __name__ == '__main__': sys_ret = 0 diff --git a/tools/jenkins-scripts/pull-request-builder.py b/tools/jenkins-scripts/pull-request-builder.py index 4539b46a98..018ac03b57 100755 --- a/tools/jenkins-scripts/pull-request-builder.py +++ b/tools/jenkins-scripts/pull-request-builder.py @@ -1,11 +1,142 @@ import os import sys import traceback +import urllib +import urllib2 +import base64 +import json +import requests +import subprocess + +#set Jenkins build description using submitDescription to mock browser behavior +http_proxy = '' +if('HTTP_PROXY' in os.environ): + http_proxy = os.environ['HTTP_PROXY'] +proxyDict = {'http': http_proxy, 'https': http_proxy} + +branch = "v3" +pr_num = 0 +workspace = "." +node_name = "ios" + +def set_jenkins_job_description(desc, url): + req_data = urllib.urlencode({'description': desc}) + request = urllib2.Request(url + 'submitDescription', req_data) + #print(os.environ['BUILD_URL']) + request.add_header('Content-Type', 'application/x-www-form-urlencoded') + user_name = os.environ['JENKINS_ADMIN'] + password = os.environ['JENKINS_ADMIN_PW'] + base64string = base64.encodestring(user_name + ":" + password).replace('\n', '') + request.add_header("Authorization", "Basic " + base64string) + try: + urllib2.urlopen(request) + except: + traceback.print_exc() + +def send_notifies_to_github(): + global branch + global pr_num + global workspace + global node_name + # get payload from os env + payload_str = os.environ['payload'] + payload_str = payload_str.decode('utf-8', 'ignore') + #parse to json obj + payload = json.loads(payload_str) + + #get pull number + pr_num = payload['number'] + print 'pr_num:' + str(pr_num) + + #build for pull request action 'open' and 'synchronize', skip 'close' + action = payload['action'] + print 'action: ' + action + + #pr = payload['pull_request'] + + url = payload['html_url'] + print "url:" + url + pr_desc = '

pr#' + str(pr_num) + ' is ' + action + '

' + + #get statuses url + statuses_url = payload['statuses_url'] + + #get pr target branch + branch = payload['branch'] + workspace = os.environ['WORKSPACE'] + node_name = os.environ['NODE_NAME'] + + #set commit status to pending + # target_url = os.environ['BUILD_URL'] + jenkins_url = os.environ['JENKINS_URL'] + job_name = os.environ['JOB_NAME'].split('/')[0] + build_number = os.environ['BUILD_NUMBER'] + target_url = jenkins_url + 'job/' + job_name + '/' + build_number + '/' + + set_jenkins_job_description(pr_desc, target_url) + + data = {"state": "pending", "target_url": target_url, "context": "Jenkins CI", "description": "Build started..."} + access_token = os.environ['GITHUB_ACCESS_TOKEN'] + Headers = {"Authorization": "token " + access_token} + + try: + requests.post(statuses_url, data=json.dumps(data), headers=Headers, proxies=proxyDict) + except: + traceback.print_exc() + +def syntronize_remote_pr(): + global workspace + global branch + global pr_num + #reset path to workspace root + os.system("cd " + workspace) + #pull latest code + os.system("git fetch origin " + branch) + os.system("git --version") + os.system("git checkout " + branch) + os.system("git merge origin/" + branch) + os.system("git branch -D pull" + str(pr_num)) + #clean workspace + print "Before checkout: git clean -xdf -f" + os.system("git clean -xdf -f") + #fetch pull request to local repo + git_fetch_pr = "git fetch origin pull/" + str(pr_num) + "/head" + ret = os.system(git_fetch_pr) + if(ret != 0): + sys.exit(1) + + #checkout a new branch from v3 or v4-develop + git_checkout = "git checkout -b " + "pull" + str(pr_num) + os.system(git_checkout) + #merge pull reqeust head + subprocess.call("git merge --no-edit FETCH_HEAD", shell=True) + + # The follow method is not working for Azure server + # p = os.popen('git merge --no-edit FETCH_HEAD') + # r = p.read() + # #check if merge fail + # if output.find('CONFLICT') > 0: + # print output + # raise Exception('There are conflicts in your PR!') + + # After checkout a new branch, clean workspace again + print "After checkout: git clean -xdf -f" + os.system("git clean -xdf -f") + + #update submodule + git_update_submodule = "git submodule update --init --force" + ret = os.system(git_update_submodule) + if(ret != 0): + sys.exit(1) + # -------------- main -------------- if __name__ == '__main__': sys_ret = 0 try: + send_notifies_to_github() + #syntronize local git repository with remote and merge the PR + syntronize_remote_pr() jenkins_script_path = "tools" + os.sep + "jenkins-scripts" + os.sep + "do-pull-request-builder.py" sys_ret = os.system("python " + jenkins_script_path) except: diff --git a/tools/jenkins-scripts/slave-scripts/win32-vs2012-build.bat b/tools/jenkins-scripts/slave-scripts/win32-vs2012-build.bat deleted file mode 100755 index 339d000880..0000000000 --- a/tools/jenkins-scripts/slave-scripts/win32-vs2012-build.bat +++ /dev/null @@ -1,2 +0,0 @@ -call "%VS120COMNTOOLS%vsvars32.bat" -msbuild build\cocos2d-win32.vc2012.sln /t:Build /p:Platform="Win32" /p:Configuration="Release" /m diff --git a/tools/jenkins-scripts/slave-scripts/windows-universal-v3.bat b/tools/jenkins-scripts/slave-scripts/windows-universal-v3.bat deleted file mode 100755 index 7959cc3aed..0000000000 --- a/tools/jenkins-scripts/slave-scripts/windows-universal-v3.bat +++ /dev/null @@ -1,2 +0,0 @@ -call "%VS120COMNTOOLS%vsvars32.bat" -msbuild build\cocos2d-win8.1-universal.sln /t:Build /p:Platform="Win32" /p:Configuration="Release" /m diff --git a/tools/particle/convert_YCoordFlipped.py b/tools/particle/convert_YCoordFlipped.py index 0626ebd894..33a1557177 100755 --- a/tools/particle/convert_YCoordFlipped.py +++ b/tools/particle/convert_YCoordFlipped.py @@ -31,7 +31,7 @@ def writeFlippedConvertFlag(plistDict): #process file def processConvertFile(filename): - #print a line to seperate files + #print a line to separate files print ('') if(not os.path.isfile(filename)): print(filename + ' dose not exist!') diff --git a/tools/simulator/libsimulator/proj.win32/libsimulator.vcxproj b/tools/simulator/libsimulator/proj.win32/libsimulator.vcxproj index 5787237b71..e44617b9ce 100644 --- a/tools/simulator/libsimulator/proj.win32/libsimulator.vcxproj +++ b/tools/simulator/libsimulator/proj.win32/libsimulator.vcxproj @@ -19,18 +19,14 @@ StaticLibrary true - v110 v120 - v110_xp v120_xp Unicode StaticLibrary false - v110 v120 - v110_xp v120_xp true Unicode diff --git a/tools/tojs/README.mdown b/tools/tojs/README.mdown new file mode 100644 index 0000000000..9b31226156 --- /dev/null +++ b/tools/tojs/README.mdown @@ -0,0 +1,57 @@ +How to Use bindings-generator +================== + +On Windows: +------------ + +* Make sure that you have installed `android-ndk-r9b`. +* Download python2.7.3 (32bit) from (http://www.python.org/ftp/python/2.7.3/python-2.7.3.msi). +* Add the installed path of python (e.g. C:\Python27) to windows environment variable named 'PATH'. +* Download pyyaml from http://pyyaml.org/download/pyyaml/PyYAML-3.10.win32-py2.7.exe and install it. +* Download pyCheetah from https://raw.github.com/dumganhar/cocos2d-x/download/downloads/Cheetah.zip, unzip it to "C:\Python27\Lib\site-packages" +* Set environment variables (`NDK_ROOT`) +* Go to "cocos2d-x/tools/tojs" folder, and run "genbindings.py". The generated codes will be under "cocos\scripting\auto-generated\js-bindings". + + +On MAC: +---------- + +* The OSX 10.9 has a built-in python2.7 and if your os don't have python2.7 then use [Homebrew](http://brew.sh/) to install the python and use pip install the python dependencies. +
+	brew install python
+
+ +* Install python dependices by pip. +
+    sudo easy_install pip
+    sudo pip install PyYAML
+	sudo pip install Cheetah
+
+ +* Download [64bit ndk-r9b-x86_64](http://dl.google.com/android/ndk/android-ndk-r9b-darwin-x86_64.tar.bz2) from [google](http://developer.android.com/tools/sdk/ndk/index.html) +* Run +
+	export NDK_ROOT=/path/to/android-ndk-r9b
+    ./genbindings.py
+
+ + +On Ubuntu Linux 12.04 64bit +------------ + +* Install python +
+	sudo apt-get install python2.7
+
+* Install python dependices by pip. +
+	sudo apt-get install python-pip
+	sudo pip install PyYAML
+	sudo pip install Cheetah
+
+* Download [64bit ndk-r9b-x86_64]( https://dl.google.com/android/ndk/android-ndk-r9b-linux-x86_64.tar.bz2) from [google](http://developer.android.com/tools/sdk/ndk/index.html) +* Go to "cocos2d-x/tools/tojs", Run +
+	export NDK_ROOT=/path/to/android-ndk-r9b
+    ./genbindings.py
+
diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini new file mode 100644 index 0000000000..cc73a73799 --- /dev/null +++ b/tools/tojs/cocos2dx.ini @@ -0,0 +1,187 @@ +[cocos2d-x] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = cocos2dx + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = cc + +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include +android_flags = -D_SIZE_T_DEFINED_ + +clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include +clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ + +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external +cocos_flags = -DANDROID + +cxxgenerator_headers = + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/audio/include/SimpleAudioEngine.h %(cocosdir)s/cocos/2d/CCProtectedNode.h %(cocosdir)s/cocos/base/CCAsyncTaskPool.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 = 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 Image .*Light$ AsyncTaskPool + +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.* GLProgram + +# what should we skip? in the format ClassName::[function function] +# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. + +skip = Node::[^setPosition$ setGLServerState description getUserObject .*UserData getGLServerState .*schedule setContentSize setAnchorPoint setColor pause resume setAdditionalTransform convertToWorldSpace], + Sprite::[getQuad ^setPosition$], + NodeGrid::[setGrid], + SpriteBatchNode::[getDescendants], + MotionStreak::[draw update], + DrawNode::[drawPolygon listenBackToForeground], + Director::[getAccelerometer getProjection getFrustum getRenderer getConsole], + Layer.*::[didAccelerate keyPressed keyReleased], + Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns], + MenuItem.*::[create setCallback], + MenuItemToggle::[initWithCallback], + Copying::[*], + LabelProtocol::[*], + LabelTextFormatProtocol::[*], + Label::[getLettersInfo createWithTTF setTTFConfig getFontAtlas listenToBackground listenToFontAtlasPurge], + .*Delegate::[*], + PoolManager::[*], + Texture2D::[initWithPVRTCData addPVRTCImage releaseData setTexParameters initWithData keepData getPixelFormatInfoMap updateWithData], + Set::[begin end acceptVisitor], + IMEDispatcher::[*], + Thread::[*], + Profiler::[*], + ProfilingTimer::[*], + CallFunc::[create initWithFunction (g|s)etTargetCallback], + CallFuncN::[create initWithFunction], + SAXParser::[(?!(init))], + SAXDelegator::[*], + Color3bObject::[*], + TouchDispatcher::[*], + EGLTouchDelegate::[*], + ScriptEngineManager::[*], + KeypadHandler::[*], + Invocation::[*], + GLView::[end swapBuffers getAllTouches], + GLViewProtocol::[pollInputEvents handleTouches.* setScissorInPoints getScissorRect isScissorEnabled swapBuffers], + SchedulerScriptHandlerEntry::[*], + Size::[*], + Point::[*], + PointArray::[*], + Rect::[*], + String::[*], + Data::[*], + Dictionary::[*], + Array::[*], + Range::[*], + NotificationObserver::[*], + Image::[initWithString initWithImageData], + Sequence::[create], + Spawn::[create], + RotateTo::[calculateAngles], + GLProgram::[getProgram setUniformLocationWith(1|2|3|4)fv setUniformLocationWith(2|3|4)iv setUniformLocationWithMatrix(2|3|4)fv], + GLProgramState::[setUniformVec4 setVertexAttribPointer], + 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], + TiledGrid3D::[tile originalTile getOriginalTile (g|s)etTile], + TMXLayer::[getTiles], + TMXMapInfo::[startElement endElement textHandler], + ParticleSystemQuad::[postStep setBatchNode draw setTexture$ setTotalParticles updateQuadWithParticle setupIndices listenBackToForeground initWithTotalParticles particleWithFile node], + LayerMultiplex::[create layerWith.* initWithLayers], + CatmullRom.*::[create actionWithDuration initWithDuration], + Bezier.*::[create actionWithDuration initWithDuration], + CardinalSpline.*::[create actionWithDuration setPoints initWithDuration], + Scheduler::[pause resume ^unschedule$ unscheduleUpdate unscheduleAllForTarget schedule isTargetPaused isScheduled], + TextureCache::[addPVRTCImage], + *::[copyWith.* onEnter.* onExit.* ^description$ getObjectType onTouch.* onAcc.* onKey.* onRegisterTouchListener], + FileUtils::[getFileData getDataFromFile setFilenameLookupDictionary destroyInstance getFullPathCache], + Application::[^application.* ^run$ getCurrentLanguageCode setAnimationInterval], + Camera::[getEyeXYZ getCenterXYZ getUpXYZ], + ccFontDefinition::[*], + NewTextureAtlas::[*], + RenderTexture::[listenToBackground listenToForeground saveToFile], + TextFieldTTF::[(g|s)etDelegate], + EventListenerVector::[*], + EventListener(Touch|Keyboard|Mouse|Focus).*::[create], + EventTouch::[(s|g)etTouches], + EventKeyboard::[*], + Device::[getTextureDataForText], + EventDispatcher::[dispatchCustomEvent], + EventCustom::[getUserData setUserData], + Component::[serialize], + EventListenerCustom::[init], + EventListener::[init], + Scene::[getCameras getLights initWithPhysics createWithPhysics getPhysicsWorld], + Animate3D::[*], + Sprite3D::[*], + AttachNode::[*], + Animation3D::[*], + Skeleton3D::[*], + Mesh::[*], + Animation3DCache::[*], + Sprite3DMaterialCache::[*], + Sprite3DCache::[*], + Bone3D::[*], + Device::[getTextureDataForText], + BillBoard::[*], + Camera::[unproject isVisibleInFrustum], + ClippingNode::[init] + +rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame], + MenuItemFont::[setFontNameObj=setFontName setFontSizeObj=setFontSize getFontSizeObj=getFontSize getFontNameObj=getFontName], + ProgressTimer::[setReverseProgress=setReverseDirection], + Animation::[create=createWithAnimationFrames], + AnimationCache::[addAnimationsWithFile=addAnimations], + GLProgram::[initWithByteArrays=initWithString initWithFilenames=init setUniformLocationWith1i=setUniformLocationI32 bindAttribLocation=addAttribute], + Node::[getGLProgram=getShaderProgram setGLProgram=setShaderProgram getPositionZ=getVertexZ setPositionZ=setVertexZ removeFromParentAndCleanup=removeFromParent removeAllChildrenWithCleanup=removeAllChildren setRotationSkewX=setRotationX setRotationSkewY=setRotationY getRotationSkewX=getRotationX getRotationSkewY=getRotationY getNodeToParentTransform=getNodeToParentTransform3D getParentToNodeTransform=getParentToNodeTransform3D getNodeToWorldTransform=getNodeToWorldTransform3D getWorldToNodeTransform=getWorldToNodeTransform3D getNodeToWorldAffineTransform=getNodeToWorldTransform getNodeToParentAffineTransform=getNodeToParentTransform getParentToNodeAffineTransform=getParentToNodeTransform getWorldToNodeAffineTransform=getWorldToNodeTransform], + LabelAtlas::[create=_create], + Sprite::[getPositionZ=getVertexZ setPositionZ=setVertexZ], + SpriteBatchNode::[removeAllChildrenWithCleanup=removeAllChildren], + DrawNode::[drawQuadraticBezier=drawQuadBezier], + FileUtils::[loadFilenameLookupDictionaryFromFile=loadFilenameLookup], + SimpleAudioEngine::[preloadBackgroundMusic=preloadMusic setBackgroundMusicVolume=setMusicVolume getBackgroundMusicVolume=getMusicVolume playBackgroundMusic=playMusic stopBackgroundMusic=stopMusic pauseBackgroundMusic=pauseMusic resumeBackgroundMusic=resumeMusic rewindBackgroundMusic=rewindMusic isBackgroundMusicPlaying=isMusicPlaying willPlayBackgroundMusic=willPlayMusic], + EventDispatcher::[addCustomEventListener=addCustomListener removeEventListener=removeListener removeEventListenersForType=removeListeners removeEventListenersForTarget=removeListeners removeCustomEventListeners=removeCustomListeners removeAllEventListeners=removeAllListeners pauseEventListenersForTarget=pauseTarget resumeEventListenersForTarget=resumeTarget], + EventMouse::[getMouseButton=getButton setMouseButton=setButton setCursorPosition=setLocation getCursorX=getLocationX getCursorY=getLocationY], + Configuration::[getInfo=dumpInfo], + ComponentContainer::[get=getComponent], + LayerColor::[initWithColor=init], + GLProgramCache::[getGLProgram=getProgram addGLProgram=addProgram reloadDefaultGLPrograms=reloadDefaultShaders loadDefaultGLPrograms=loadDefaultShaders], + TextFieldTTF::[textFieldWithPlaceHolder=create], + Texture2D::[getGLProgram=getShaderProgram setGLProgram=setShaderProgram], + Speed::[setSpeed=_setSpeed getSpeed=_getSpeed] + +rename_classes = ParticleSystemQuad::ParticleSystem, + SimpleAudioEngine::AudioEngine, + __NodeRGBA::NodeRGBA, + __LayerRGBA::LayerRGBA, + SAXParser::PlistParser, + GLProgramCache::ShaderCache, + CallFunc::_CallFunc, + CallFuncN::CallFunc + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = Node Director SimpleAudioEngine FileUtils TMXMapInfo Application GLViewProtocol SAXParser Configuration + +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = Ref Clonable + +# classes that create no constructor +# Set is special and we will use a hand-written constructor + +abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set SimpleAudioEngine FileUtils Application GLViewProtocol GLView ComponentContainer SAXParser Configuration EventListener BaseLight AsyncTaskPool + +# 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 diff --git a/tools/tojs/cocos2dx_3d.ini b/tools/tojs/cocos2dx_3d.ini new file mode 100644 index 0000000000..89b25c189a --- /dev/null +++ b/tools/tojs/cocos2dx_3d.ini @@ -0,0 +1,68 @@ +[cocos2dx_3d] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = cocos2dx_3d + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = jsb + +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include +android_flags = -D_SIZE_T_DEFINED_ + +clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include +clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ + +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external +cocos_flags = -DANDROID + +cxxgenerator_headers = + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/cocos/cocos2d.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 = Animate3D Sprite3D Animation3D Skeleton3D ^Mesh$ AttachNode BillBoard Sprite3DCache TextureCube Skybox Terrain + +classes_need_extend = Sprite3D + +# what should we skip? in the format ClassName::[function function] +# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. + +skip = Skeleton3D::[create], + Sprite3D::[getAABB getMeshArrayByName createAsync], + Mesh::[create getMeshCommand getAABB getDefaultGLProgram getMeshVertexAttribute draw], + Sprite3DCache::[addSprite3DData getSpriteData], + Animation3D::[getBoneCurves], + TextureCube::[setTexParameters], + Terrain::[getAABB getQuadTree create] + + +rename_functions = + +rename_classes = + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = + +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = Clonable Ref + +# classes that create no constructor +# Set is special and we will use a hand-written constructor +abstract_classes = Sprite3DCache + +# 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 + diff --git a/tools/tojs/cocos2dx_3d_ext.ini b/tools/tojs/cocos2dx_3d_ext.ini new file mode 100644 index 0000000000..880f537410 --- /dev/null +++ b/tools/tojs/cocos2dx_3d_ext.ini @@ -0,0 +1,61 @@ +[cocos2dx_3d_extension] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = cocos2dx_3d_extension + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = jsb + +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include +android_flags = -D_SIZE_T_DEFINED_ + +clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include +clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ + +cocos_headers = -I%(cocosdir)s -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external +cocos_flags = -DANDROID + +cxxgenerator_headers = + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/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 = ParticleSystem3D PUParticleSystem3D + +classes_need_extend = + +# what should we skip? in the format ClassName::[function function] +# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. + +skip = ParticleSystem3D::[draw setEmitter setRender .*Affector getParticlePool], + PUParticleSystem3D::[get.*ParticlePool forceEmission addEmitter getAffector getEmitter addListener removeListener .*Observer .*BehaviourTemplate makeParticleLocal] + +rename_functions = + +rename_classes = + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = + +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = + +# classes that create no constructor +# Set is special and we will use a hand-written constructor +abstract_classes = + +# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. +script_control_cpp = no diff --git a/tools/tojs/cocos2dx_builder.ini b/tools/tojs/cocos2dx_builder.ini new file mode 100644 index 0000000000..d4928754c6 --- /dev/null +++ b/tools/tojs/cocos2dx_builder.ini @@ -0,0 +1,65 @@ +[cocos2dx_builder] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = cocos2dx_builder + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = cc + +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include +android_flags = -D_SIZE_T_DEFINED_ + +clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include +clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ + +cocos_headers = -I%(cocosdir)s -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external + +cocos_flags = -DANDROID + +cxxgenerator_headers = + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/cocos/editor-support/cocosbuilder/CocosBuilder.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 = CCBReader.* CCBAnimationManager.* + +# what should we skip? in the format ClassName::[function function] +# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. + +skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getCCBMemberVariableAssigner readFloat getCCBSelectorResolver toLowerCase lastPathComponent deletePathExtension endsWith concat getResolutionScale getAnimatedProperties readBool readInt addOwnerCallbackNode addDocumentCallbackName readCachedString readNodeGraphFromData addDocumentCallbackNode getLoadedSpriteSheet initWithData readFileWithCleanUp getOwner$ readNodeGraphFromFile createSceneWithNodeGraphFromFile getAnimationManagers$ setAnimationManagers], + CCBAnimationManager::[setAnimationCompletedCallback addNode getSequences getDelegate], + .*Delegate::[*], + .*Loader.*::[*], + *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener] + +rename_functions = + +rename_classes = CCBReader::_Reader, + CCBAnimationManager::BuilderAnimationManager + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = + +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = Ref + +# classes that create no constructor +# Set is special and we will use a hand-written constructor +abstract_classes = + +# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. +script_control_cpp = no + diff --git a/tools/tojs/cocos2dx_extension.ini b/tools/tojs/cocos2dx_extension.ini new file mode 100644 index 0000000000..8bb67dbbc9 --- /dev/null +++ b/tools/tojs/cocos2dx_extension.ini @@ -0,0 +1,75 @@ +[cocos2dx_extension] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = cocos2dx_extension + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = cc + +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include +android_flags = -D_SIZE_T_DEFINED_ + +clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include +clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ + +cocos_headers = -I%(cocosdir)s -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external + +cocos_flags = -DANDROID + +cxxgenerator_headers = + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/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 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 +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. + +skip = ScrollView::[(g|s)etDelegate$], + .*Delegate::[*], + .*Loader.*::[*], + *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener], + TableView::[create (g|s)etDataSource$ (g|s)etDelegate], + Control::[removeHandleOfControlEvent addHandleOfControlEvent], + ControlUtils::[*], + ControlSwitchSprite::[*], + ActionManagerEx::[initWithDictionary], + ActionNode::[initWithDictionary], + ActionObject::[initWithDictionary], + Manifest::[getAssets], + AssetsManagerEx::[getFailedAssets updateAssets] + +rename_functions = + +rename_classes = AssetsManagerEx::AssetsManager, + EventAssetsManagerEx::EventAssetsManager, + EventListenerAssetsManagerEx::EventListenerAssetsManager + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = + +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = Ref + +# classes that create no constructor +# Set is special and we will use a hand-written constructor +abstract_classes = Manifest + +# 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 ControlButton ControlStepper ControlSwitch ControlSlider ControlColourPicker ControlPotentiometer diff --git a/tools/tojs/cocos2dx_spine.ini b/tools/tojs/cocos2dx_spine.ini new file mode 100644 index 0000000000..2561e3e4b5 --- /dev/null +++ b/tools/tojs/cocos2dx_spine.ini @@ -0,0 +1,43 @@ +[cocos2dx_spine] +prefix = cocos2dx_spine + +target_namespace = sp + +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include +android_flags = -D_SIZE_T_DEFINED_ + +clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include +clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ -DNO_JS_ASSERT -DUINT32_MAX=0xffffffff + +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external/spidermonkey/include/android -I%(cocosdir)s/external + +cocos_flags = -DANDROID + +cxxgenerator_headers = + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +headers = %(cocosdir)s/cocos/editor-support/spine/spine-cocos2dx.h %(jsbdir)s/manual/spine/jsb_cocos2dx_spine_manual.h + +classes = SkeletonRenderer SkeletonAnimation + +classes_need_extend = SkeletonAnimation + +skip = SkeletonRenderer::[createWithData findBone findSlot getAttachment], + SkeletonAnimation::[createWithData getCurrent setAnimation addAnimation] + +remove_prefix = + +classes_have_no_parents = + +base_classes_to_skip = + +abstract_classes = + +script_control_cpp = + +rename_functions = SkeletonAnimation::[createWithFile=create], + SkeletonRenderer::[createWithFile=create] + +rename_classes = SkeletonRenderer::Skeleton \ No newline at end of file diff --git a/tools/tojs/cocos2dx_studio.ini b/tools/tojs/cocos2dx_studio.ini new file mode 100644 index 0000000000..720a5b11c0 --- /dev/null +++ b/tools/tojs/cocos2dx_studio.ini @@ -0,0 +1,83 @@ +[cocos2dx_studio] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = cocos2dx_studio + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = ccs + +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include +android_flags = -D_SIZE_T_DEFINED_ + +clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include +clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ -DNO_JS_ASSERT -DUINT32_MAX=0xffffffff + +cocos_headers = -I%(cocosdir)s/external -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android -I%(jsbdir)s/manual -I%(cocosdir)s/external/spidermonkey/include/android + +cocos_flags = -DANDROID + +cxxgenerator_headers = + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/cocos/editor-support/cocostudio/CocoStudio.h %(cocosdir)s/cocos/editor-support/cocostudio/CCObjectExtensionData.h %(jsbdir)s/manual/cocostudio/jsb_cocos2dx_studio_conversions.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 = Armature ArmatureAnimation Skin Bone ColliderDetector ColliderBody ArmatureDataManager InputDelegate ComController ComAudio ComAttribute ComRender ActionManagerEx SceneReader GUIReader BatchNode ActionObject BaseData Tween ColliderFilter DisplayManager DecorativeDisplay ProcessBase AnimationData MovementData ContourData TextureData ActionTimelineData ActionTimeline ActionTimelineCache Frame TextureFrame RotationFrame SkewFrame VisibleFrame RotationSkewFrame PositionFrame ScaleFrame AnchorPointFrame InnerActionFrame ColorFrame AlphaFrame EventFrame ZOrderFrame NodeReader Timeline CSLoader ObjectExtensionData + +# what should we skip? in the format ClassName::[function function] +# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. + +skip = *::[createInstance ^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener (s|g)etUserObject ccTouch.*], + InputDelegate::[didAccelerate on.*], + GUIReader::[*], + ComAttribute::[getDict], + BatchNode::[init draw], + Armature::[createBone updateBlendType getBody setBody getShapeList], + Skin::[getSkinData setSkinData], + ArmatureAnimation::[updateHandler updateFrameData frameEvent setMovementEventCallFunc setFrameEventCallFunc], + ArmatureDataManager::[getTextureDatas], + ActionManagerEx::[initWithDictionary purgeActionManager], + Bone::[getTweenData getBoneData], + BaseData::[copy subtract], + ColliderFilter::[updateShape], + Tween::[(s|g)etMovementBoneData], + ActionNode::[initWithDictionary], + ActionObject::[initWithDictionary], + ColliderDetector::[addContourData.* removeContourData], + ColliderBody::[getContourData getCalculatedVertexList], + SceneReader::[*], + CSLoader::[*], + ActionTimelineCache::[*], + Frame::[(s|g)etEasingParams] + +rename_functions = Armature::[getBoundingBox=boundingBox], + ActionTimeline::[IsAnimationInfoExists=isAnimationInfoExists] + +rename_classes = ActionManagerEx::ActionManager + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = InputDelegate SceneReader DecorativeDisplay ActionTimelineCache NodeReader CSLoader + +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = Ref + +# classes that create no constructor +# Set is special and we will use a hand-written constructor +abstract_classes = ColliderDetector ColliderBody ArmatureDataManager InputDelegate InputDelegate ActionManagerEx SceneReader GUIReader BatchNode ColliderFilter DecorativeDisplay ActionTimelineCache NodeReader CSLoader + +# 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 = Armature ComController diff --git a/tools/tojs/cocos2dx_ui.ini b/tools/tojs/cocos2dx_ui.ini new file mode 100644 index 0000000000..8fa317061d --- /dev/null +++ b/tools/tojs/cocos2dx_ui.ini @@ -0,0 +1,73 @@ +[cocos2dx_ui] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = cocos2dx_ui + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = ccui + +# the native namespace in which this module locates, this parameter is used for avoid conflict of the same class name in different modules, as "cocos2d::Label" <-> "cocos2d::ui::Label". +cpp_namespace = cocos2d::ui + +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include +android_flags = -D_SIZE_T_DEFINED_ + +clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include +clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ + +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external + +cocos_flags = -DANDROID + +cxxgenerator_headers = + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/cocos/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 UICCTextField ScrollView PageView ListView LayoutParameter LinearLayoutParameter RelativeLayoutParameter VideoPlayer HBox VBox RelativeBox Scale9Sprite EditBox$ LayoutComponent + +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$ LayoutComponent + +# what should we skip? in the format ClassName::[function function] +# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. + +skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener ccTouch.* addEventListener addTouchEventListener], + Widget::[(s|g)etUserObject], + Layer::[getInputManager], + LayoutParameter::[(s|g)etMargin], + ImageView::[doubleClickEvent checkDoubleClick], + RichText::[getVirtualRendererSize], + EditBox::[(g|s)etDelegate ^keyboard.* touchDownAction getScriptEditBoxHandler registerScriptEditBoxHandler unregisterScriptEditBoxHandler] + +rename_functions = Widget::[init=_init], + ImageView::[init=_init], + EditBox::[getText=getString setText=setString] + +rename_classes = + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = Helper + +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = Ref + +# classes that create no constructor +# Set is special and we will use a hand-written constructor +abstract_classes = Helper LayoutManager + +# 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 + diff --git a/tools/tojs/genbindings.py b/tools/tojs/genbindings.py new file mode 100755 index 0000000000..d02e29cc89 --- /dev/null +++ b/tools/tojs/genbindings.py @@ -0,0 +1,189 @@ +#!/usr/bin/python + +# This script is used to generate luabinding glue codes. +# Android ndk version must be ndk-r9b. + + +import sys +import os, os.path +import shutil +import ConfigParser +import subprocess +import re +from contextlib import contextmanager + + +def _check_ndk_root_env(): + ''' Checking the environment NDK_ROOT, which will be used for building + ''' + + try: + NDK_ROOT = os.environ['NDK_ROOT'] + except Exception: + print "NDK_ROOT not defined. Please define NDK_ROOT in your environment." + sys.exit(1) + + return NDK_ROOT + +def _check_python_bin_env(): + ''' Checking the environment PYTHON_BIN, which will be used for building + ''' + + try: + PYTHON_BIN = os.environ['PYTHON_BIN'] + except Exception: + print "PYTHON_BIN not defined, use current python." + PYTHON_BIN = sys.executable + + return PYTHON_BIN + + +class CmdError(Exception): + pass + + +@contextmanager +def _pushd(newDir): + previousDir = os.getcwd() + os.chdir(newDir) + yield + os.chdir(previousDir) + +def _run_cmd(command): + ret = subprocess.call(command, shell=True) + if ret != 0: + message = "Error running command" + raise CmdError(message) + +def main(): + + cur_platform= '??' + llvm_path = '??' + ndk_root = _check_ndk_root_env() + # del the " in the path + ndk_root = re.sub(r"\"", "", ndk_root) + python_bin = _check_python_bin_env() + + platform = sys.platform + if platform == 'win32': + cur_platform = 'windows' + elif platform == 'darwin': + cur_platform = platform + elif 'linux' in platform: + cur_platform = 'linux' + else: + print 'Your platform is not supported!' + sys.exit(1) + + 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(x64_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 + elif os.path.isdir(x64_llvm_path): + llvm_path = x64_llvm_path + else: + print 'llvm toolchain not found!' + print 'path: %s or path: %s are not valid! ' % (x86_llvm_path, x64_llvm_path) + sys.exit(1) + + project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) + cocos_root = os.path.abspath(project_root) + jsb_root = os.path.abspath(os.path.join(project_root, 'cocos/scripting/js-bindings')) + cxx_generator_root = os.path.abspath(os.path.join(project_root, 'tools/bindings-generator')) + + # save config to file + config = ConfigParser.ConfigParser() + config.set('DEFAULT', 'androidndkdir', ndk_root) + config.set('DEFAULT', 'clangllvmdir', llvm_path) + config.set('DEFAULT', 'cocosdir', cocos_root) + config.set('DEFAULT', 'jsbdir', jsb_root) + config.set('DEFAULT', 'cxxgeneratordir', cxx_generator_root) + config.set('DEFAULT', 'extra_flags', '') + + # To fix parse error on windows, we must difine __WCHAR_MAX__ and undefine __MINGW32__ . + if platform == 'win32': + config.set('DEFAULT', 'extra_flags', '-D__WCHAR_MAX__=0x7fffffff -U__MINGW32__') + + conf_ini_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'userconf.ini')) + + print 'generating userconf.ini...' + with open(conf_ini_file, 'w') as configfile: + config.write(configfile) + + + # set proper environment variables + if 'linux' in platform or platform == 'darwin': + os.putenv('LD_LIBRARY_PATH', '%s/libclang' % cxx_generator_root) + if platform == 'win32': + path_env = os.environ['PATH'] + os.putenv('PATH', r'%s;%s\libclang;%s\tools\win32;' % (path_env, cxx_generator_root, cxx_generator_root)) + + + try: + + tojs_root = '%s/tools/tojs' % project_root + output_dir = '%s/cocos/scripting/js-bindings/auto' % project_root + + cmd_args = {'cocos2dx.ini' : ('cocos2d-x', 'jsb_cocos2dx_auto'), \ + 'cocos2dx_extension.ini' : ('cocos2dx_extension', 'jsb_cocos2dx_extension_auto'), \ + 'cocos2dx_builder.ini' : ('cocos2dx_builder', 'jsb_cocos2dx_builder_auto'), \ + 'cocos2dx_ui.ini' : ('cocos2dx_ui', 'jsb_cocos2dx_ui_auto'), \ + 'cocos2dx_studio.ini' : ('cocos2dx_studio', 'jsb_cocos2dx_studio_auto'), \ + 'cocos2dx_spine.ini' : ('cocos2dx_spine', 'jsb_cocos2dx_spine_auto'), \ + 'cocos2dx_3d.ini' : ('cocos2dx_3d', 'jsb_cocos2dx_3d_auto'), \ + 'cocos2dx_3d_ext.ini' : ('cocos2dx_3d_extension', 'jsb_cocos2dx_3d_extension_auto') + } + target = 'spidermonkey' + generator_py = '%s/generator.py' % cxx_generator_root + for key in cmd_args.keys(): + args = cmd_args[key] + cfg = '%s/%s' % (tojs_root, key) + print 'Generating bindings for %s...' % (key[:-4]) + command = '%s %s %s -s %s -t %s -o %s -n %s' % (python_bin, generator_py, cfg, args[0], target, output_dir, args[1]) + _run_cmd(command) + + if platform == 'win32': + with _pushd(output_dir): + _run_cmd('dos2unix *') + + + custom_cmd_args = {} + if len(custom_cmd_args) > 0: + output_dir = '%s/frameworks/custom/auto' % project_root + for key in custom_cmd_args.keys(): + args = custom_cmd_args[key] + cfg = '%s/%s' % (tojs_root, key) + print 'Generating bindings for %s...' % (key[:-4]) + command = '%s %s %s -s %s -t %s -o %s -n %s' % (python_bin, generator_py, cfg, args[0], target, output_dir, args[1]) + _run_cmd(command) + if platform == 'win32': + with _pushd(output_dir): + _run_cmd('dos2unix *') + + print '----------------------------------------' + print 'Generating javascript bindings succeeds.' + print '----------------------------------------' + + except Exception as e: + if e.__class__.__name__ == 'CmdError': + print '-------------------------------------' + print 'Generating javascript bindings fails.' + print '-------------------------------------' + sys.exit(1) + else: + raise + + +# -------------- main -------------- +if __name__ == '__main__': + main() diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index bfdfcaa122..a4a584b03f 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -137,7 +137,10 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS Device::[getTextureDataForText], BillBoard::[*], Camera::[unproject], - SpritePolygonCache::[addSpritePolygonCache getSpritePolygonCache] + SpritePolygonCache::[addSpritePolygonCache getSpritePolygonCache], + EventListenerCustom::[init], + EventListener::[init], + RotateTo::[calculateAngles] rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame], ProgressTimer::[setReverseProgress=setReverseDirection], @@ -162,7 +165,7 @@ base_classes_to_skip = Clonable # classes that create no constructor # Set is special and we will use a hand-written constructor -abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set FileUtils Application ClippingNode Label GLViewImpl GLView EventAcceleration DisplayLinkDirector Component Console +abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set FileUtils Application ClippingNode Label GLViewImpl GLView EventAcceleration DisplayLinkDirector Component Console EventListener BaseLight # 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 diff --git a/tools/tolua/cocos2dx_3d.ini b/tools/tolua/cocos2dx_3d.ini index 8fc0bbfeb0..bc477cc2a2 100644 --- a/tools/tolua/cocos2dx_3d.ini +++ b/tools/tolua/cocos2dx_3d.ini @@ -13,7 +13,7 @@ android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ -cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external cocos_flags = -DANDROID cxxgenerator_headers = @@ -35,13 +35,13 @@ classes = Animate3D Sprite3D Animation3D Skeleton3D ^Mesh$ AttachNode BillBoard # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = Mesh::[create getAABB getVertexBuffer hasVertexAttrib getSkin getMeshIndexData getGLProgramState getPrimitiveType getIndexCount getIndexFormat getIndexBuffer], - Sprite3D::[getSkin getAABB getMeshArrayByName createAsync], +skip = Mesh::[create getAABB getVertexBuffer hasVertexAttrib getSkin getMeshIndexData getGLProgramState getPrimitiveType getIndexCount getIndexFormat getIndexBuffer getMeshCommand getDefaultGLProgram], + Sprite3D::[getSkin getAABB getMeshArrayByName createAsync init initWithFile initFrom loadFromCache loadFromFile visit genGLProgramState createNode createAttachSprite3DNode createSprite3DNode getMeshIndexData addMesh onAABBDirty afterAsyncLoad], Skeleton3D::[create], Animation3D::[getBoneCurveByName getBoneCurves], BillBoard::[draw], Sprite3DCache::[addSprite3DData getSpriteData], - Terrain::[lookForIndicesLODSkrit lookForIndicesLOD insertIndicesLOD insertIndicesLODSkirt getIntersectionPoint getAABB getQuadTree create getHeight] + Terrain::[lookForIndicesLODSkrit lookForIndicesLOD insertIndicesLOD insertIndicesLODSkirt getIntersectionPoint getAABB getQuadTree create getHeight getHeightData] rename_functions = @@ -59,7 +59,7 @@ base_classes_to_skip = Clonable # classes that create no constructor # Set is special and we will use a hand-written constructor -abstract_classes = +abstract_classes = Sprite3D # 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 diff --git a/tools/tolua/cocos2dx_audioengine.ini b/tools/tolua/cocos2dx_audioengine.ini index 717f3e62fe..d50bab7b0d 100644 --- a/tools/tolua/cocos2dx_audioengine.ini +++ b/tools/tolua/cocos2dx_audioengine.ini @@ -15,7 +15,7 @@ android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ -cocos_headers = -I%(cocosdir)s -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android +cocos_headers = -I%(cocosdir)s -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external cocos_flags = -DANDROID diff --git a/tools/tolua/cocos2dx_cocosbuilder.ini b/tools/tolua/cocos2dx_cocosbuilder.ini index 410fdeb5a5..5b3d49d5c6 100644 --- a/tools/tolua/cocos2dx_cocosbuilder.ini +++ b/tools/tolua/cocos2dx_cocosbuilder.ini @@ -13,7 +13,7 @@ android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ -cocos_headers = -I%(cocosdir)s -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android +cocos_headers = -I%(cocosdir)s -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external cocos_flags = -DANDROID diff --git a/tools/tolua/cocos2dx_cocosdenshion.ini b/tools/tolua/cocos2dx_cocosdenshion.ini index 6e337f3b84..bbdf8117a3 100644 --- a/tools/tolua/cocos2dx_cocosdenshion.ini +++ b/tools/tolua/cocos2dx_cocosdenshion.ini @@ -13,7 +13,7 @@ android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ -cocos_headers = -I%(cocosdir)s -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android +cocos_headers = -I%(cocosdir)s -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external cocos_flags = -DANDROID diff --git a/tools/tolua/cocos2dx_controller.ini b/tools/tolua/cocos2dx_controller.ini index aed359d313..24de77361c 100644 --- a/tools/tolua/cocos2dx_controller.ini +++ b/tools/tolua/cocos2dx_controller.ini @@ -15,7 +15,7 @@ android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ -cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/base -I%(cocosdir)s/cocos/platform/android +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/base -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external cocos_flags = -DANDROID cxxgenerator_headers = diff --git a/tools/tolua/cocos2dx_experimental.ini b/tools/tolua/cocos2dx_experimental.ini index 908f6e26c5..4c3946a5b4 100644 --- a/tools/tolua/cocos2dx_experimental.ini +++ b/tools/tolua/cocos2dx_experimental.ini @@ -13,7 +13,7 @@ android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ -cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external cocos_flags = -DANDROID diff --git a/tools/tolua/cocos2dx_experimental_video.ini b/tools/tolua/cocos2dx_experimental_video.ini index 918170b977..160429d700 100644 --- a/tools/tolua/cocos2dx_experimental_video.ini +++ b/tools/tolua/cocos2dx_experimental_video.ini @@ -15,7 +15,7 @@ android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ -cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external cocos_flags = -DANDROID diff --git a/tools/tolua/cocos2dx_experimental_webview.ini b/tools/tolua/cocos2dx_experimental_webview.ini index 4e91348306..232322f38d 100644 --- a/tools/tolua/cocos2dx_experimental_webview.ini +++ b/tools/tolua/cocos2dx_experimental_webview.ini @@ -15,7 +15,7 @@ android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ -cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external cocos_flags = -DANDROID diff --git a/tools/tolua/cocos2dx_physics.ini b/tools/tolua/cocos2dx_physics.ini index c5042f1dde..6a763b9d9d 100644 --- a/tools/tolua/cocos2dx_physics.ini +++ b/tools/tolua/cocos2dx_physics.ini @@ -15,7 +15,7 @@ android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ -cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external cocos_flags = -DANDROID diff --git a/tools/tolua/cocos2dx_spine.ini b/tools/tolua/cocos2dx_spine.ini index 8520f7d06d..015d1e65b4 100644 --- a/tools/tolua/cocos2dx_spine.ini +++ b/tools/tolua/cocos2dx_spine.ini @@ -13,7 +13,7 @@ android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ -cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external cocos_flags = -DANDROID diff --git a/tools/travis-scripts/generate-bindings.sh b/tools/travis-scripts/generate-bindings.sh index a96a07566b..d5fa15dfef 100755 --- a/tools/travis-scripts/generate-bindings.sh +++ b/tools/travis-scripts/generate-bindings.sh @@ -17,14 +17,17 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" PROJECT_ROOT="$DIR/../.." TOLUA_ROOT="$PROJECT_ROOT/tools/tolua" -AUTO_GENERATED_DIR="$PROJECT_ROOT/cocos/scripting/lua-bindings/auto" -COMMITTAG="[AUTO]: updating luabinding automatically" +TOJS_ROOT="$PROJECT_ROOT/tools/tojs" +LUA_AUTO_GENERATED_DIR="$PROJECT_ROOT/cocos/scripting/lua-bindings/auto" +JS_AUTO_GENERATED_DIR="$PROJECT_ROOT/cocos/scripting/js-bindings/auto" +COMMITTAG="[AUTO]: updating luabinding & jsbinding automatically" ELAPSEDSECS=`date +%s` COCOS_BRANCH="update_lua_bindings_$ELAPSEDSECS" COCOS_ROBOT_REMOTE="https://${GH_USER}:${GH_PASSWORD}@github.com/${GH_USER}/cocos2d-x.git" PULL_REQUEST_REPO="https://api.github.com/repos/cocos2d/cocos2d-x/pulls" FETCH_REMOTE_BRANCH="v3" -COMMIT_PATH="cocos/scripting/lua-bindings/auto" +LUA_COMMIT_PATH="cocos/scripting/lua-bindings/auto" +JS_COMMIT_PATH="cocos/scripting/js-bindings/auto" # Exit on error set -e @@ -52,6 +55,11 @@ generate_bindings_glue_codes() pushd "$TOLUA_ROOT" ./genbindings.py popd + + echo "Create auto-generated jsbinding glue codes." + pushd "$TOJS_ROOT" + ./genbindings.py + popd } if [ "$GEN_BINDING"x != "YES"x ]; then @@ -65,8 +73,11 @@ git config user.email ${GH_EMAIL} git config user.name ${GH_USER} popd -rm -rf "$AUTO_GENERATED_DIR" -mkdir "$AUTO_GENERATED_DIR" +rm -rf "$LUA_AUTO_GENERATED_DIR" +mkdir "$LUA_AUTO_GENERATED_DIR" + +rm -rf "$JS_AUTO_GENERATED_DIR" +mkdir "$JS_AUTO_GENERATED_DIR" # 1. Generate LUA bindings generate_bindings_glue_codes @@ -97,10 +108,14 @@ git fetch origin ${FETCH_REMOTE_BRANCH} # Don't exit on non-zero return value set +e -git diff FETCH_HEAD --stat --exit-code ${COMMIT_PATH} +git diff FETCH_HEAD --stat --exit-code ${LUA_COMMIT_PATH} -DIFF_RETVAL=$? -if [ $DIFF_RETVAL -eq 0 ] +LUA_DIFF_RETVAL=$? + +git diff FETCH_HEAD --stat --exit-code ${JS_COMMIT_PATH} + +JS_DIFF_RETVAL=$? +if [ $LUA_DIFF_RETVAL -eq 0 -a $JS_DIFF_RETVAL -eq 0 ] then echo echo "No differences in generated files" @@ -116,7 +131,8 @@ fi # Exit on error set -e -git add -f --all "$AUTO_GENERATED_DIR" +git add -f --all "$LUA_AUTO_GENERATED_DIR" +git add -f --all "$JS_AUTO_GENERATED_DIR" git checkout -b "$COCOS_BRANCH" git commit -m "$COMMITTAG" diff --git a/tools/travis-scripts/generate-cocosfiles.sh b/tools/travis-scripts/generate-cocosfiles.sh index ce0c68f998..d946787499 100755 --- a/tools/travis-scripts/generate-cocosfiles.sh +++ b/tools/travis-scripts/generate-cocosfiles.sh @@ -6,7 +6,7 @@ PROJECT_ROOT="$DIR"/../.. COMMITTAG="[AUTO][ci skip]: updating cocos2dx_files.json" PUSH_REPO="https://api.github.com/repos/cocos2d/cocos2d-x/pulls" OUTPUT_FILE_PATH="${PROJECT_ROOT}/templates/cocos2dx_files.json" -FETCH_REMOTE_BRANCH="v3.6" +FETCH_REMOTE_BRANCH="v3" COMMIT_PATH="templates/cocos2dx_files.json" # Exit on error diff --git a/tools/travis-scripts/generate-template-files.py b/tools/travis-scripts/generate-template-files.py index f629d71f68..43df0dfc87 100755 --- a/tools/travis-scripts/generate-template-files.py +++ b/tools/travis-scripts/generate-template-files.py @@ -42,8 +42,10 @@ class CocosFileList: self.rootDir = "" self.fileList_com=[] self.fileList_lua=[] + self.fileList_js=[] self.luaPath = ["cocos/scripting/lua-bindings", "external/lua", "tools/bindings-generator", "tools/tolua"] + self.jsPath = ["cocos/scripting/js-bindings", "external/spidermonkey", "tools/bindings-generator", "tools/tojs", "web"] def readIngoreFile(self, fileName): """ @@ -93,8 +95,17 @@ class CocosFileList: if relativePath.upper().find(luaPath.upper()) == 0: foundLuaModule = True break + + foundJSModule = False + for jsPath in self.jsPath: + if relativePath.upper().find(jsPath.upper()) == 0: + foundJSModule = True + break + if foundLuaModule: self.fileList_lua.append("%s/" %relativePath) + elif foundJSModule: + self.fileList_js.append("%s/" %relativePath) else: self.fileList_com.append("%s/" %relativePath) self.__parseFileList(path) @@ -123,8 +134,17 @@ class CocosFileList: if relativePath.upper().find(luaPath.upper()) == 0: foundLuaModule = True break + + foundJSModule = False + for jsPath in self.jsPath: + if relativePath.upper().find(jsPath.upper()) == 0: + foundJSModule = True + break + if foundLuaModule: self.fileList_lua.append(relativePath) + elif foundJSModule: + self.fileList_js.append(relativePath) else: self.fileList_com.append(relativePath) @@ -151,7 +171,8 @@ class CocosFileList: f = open(fileName,"w") self.fileList_com.sort() self.fileList_lua.sort() - content ={'common':self.fileList_com,'lua':self.fileList_lua} + self.fileList_js.sort() + content ={'common':self.fileList_com,'lua':self.fileList_lua,'js':self.fileList_js} json.dump(content,f,sort_keys=True,indent=4) f.close() return True diff --git a/tools/travis-scripts/travis_mac.yml b/tools/travis-scripts/travis_mac.yml index 0178cb0cc2..d5ea1235f9 100644 --- a/tools/travis-scripts/travis_mac.yml +++ b/tools/travis-scripts/travis_mac.yml @@ -16,4 +16,4 @@ notifications: # whitelist branches: only: - - v3.6 + - v3 diff --git a/web b/web new file mode 160000 index 0000000000..bd519eeca9 --- /dev/null +++ b/web @@ -0,0 +1 @@ +Subproject commit bd519eeca93c0237e531d5b7a9246f30c4f29291